Commit 15d72123 authored by mengcuiguang's avatar mengcuiguang

来电秀逻辑优化

parent 72a3dcbe
......@@ -216,8 +216,6 @@
android:name=".ui.activitys.KylVideoActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="portrait" />
<activity android:name=".call.detail.DetailActivity"
android:screenOrientation="portrait"/>
<activity android:name=".call.permission.PermissionActivity"
android:screenOrientation="portrait"/>
<activity android:name=".call.detail.DetailApplyActivity"
......
package com.mints.goodmoney.call.detail;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.view.View;
import android.widget.ImageView;
import android.widget.VideoView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.mints.goodmoney.R;
import com.mints.goodmoney.call.business.VideoDBHelper;
import com.mints.goodmoney.call.permission.PermissionActivity;
import com.mints.goodmoney.call.permission.PermissionManager;
/**
* 设置来电秀
* 作者:孟崔广
*/
public class DetailActivity extends AppCompatActivity {
public static final String KEY_VIDEO_PATH = "video_path";
public static final String KEY_SET_RINGTONE = "key_set_ringtone";
public static final int REQUEST_ID_PICK_VIDEO_CONTACT = 0;
private VideoView mVideoView;
private String mVideoPath;
private boolean mSetRingtone = true;
private String mContact = VideoDBHelper.UNKNOWN_NUMBER;
public static void startSelf(Context context, String path) {
if (context == null) {
return;
}
Intent intent = new Intent(context, DetailActivity.class);
intent.putExtra(DetailActivity.KEY_VIDEO_PATH, path);
if (!(context instanceof Activity)) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
context.startActivity(intent);
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
handleIntent();
init();
}
private void handleIntent() {
mVideoPath = getIntent().getStringExtra(KEY_VIDEO_PATH);
}
private void init() {
mVideoView = findViewById(R.id.video_view);
mVideoView.setOnPreparedListener(mp -> {
mp.start();
mp.setLooping(true);
});
mVideoView.setVideoPath(mVideoPath);
mVideoView.start();
}
private void selectVideoContact() {
Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(intent, REQUEST_ID_PICK_VIDEO_CONTACT);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_ID_PICK_VIDEO_CONTACT) {
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
PermissionManager.getInstance().onRequestPermissionsResult(this, requestCode, permissions, grantResults);
if (PermissionManager.getInstance().isContactEnabled(this)) {
selectVideoContact();
}
}
public void setShow(View view) {
if (PermissionManager.getInstance().checkEssential(this)) {
VideoDBHelper.getInstance().setSelectVideo(this, mContact, mVideoPath);
DetailApplyActivity.startSelf(this, mVideoPath, mSetRingtone);
} else {
PermissionActivity.startSelf(this);
}
}
}
......@@ -28,13 +28,16 @@ public class DetailApplyActivity extends AppCompatActivity {
private boolean mSetRingtone = true;
private String mVideoPath;
public static final String KEY_VIDEO_PATH = "video_path";
public static final String KEY_SET_RINGTONE = "key_set_ringtone";
public static void startSelf(Context context, String path, boolean setRingtone) {
if (context == null) {
return;
}
Intent intent = new Intent(context, DetailApplyActivity.class);
intent.putExtra(DetailActivity.KEY_VIDEO_PATH, path);
intent.putExtra(DetailActivity.KEY_SET_RINGTONE, setRingtone);
intent.putExtra(DetailApplyActivity.KEY_VIDEO_PATH, path);
intent.putExtra(DetailApplyActivity.KEY_SET_RINGTONE, setRingtone);
if (!(context instanceof Activity)) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
......@@ -56,8 +59,8 @@ public class DetailApplyActivity extends AppCompatActivity {
}
private void handleIntent() {
mSetRingtone = getIntent().getBooleanExtra(DetailActivity.KEY_SET_RINGTONE, true);
mVideoPath = getIntent().getStringExtra(DetailActivity.KEY_VIDEO_PATH);
mSetRingtone = getIntent().getBooleanExtra(DetailApplyActivity.KEY_SET_RINGTONE, true);
mVideoPath = getIntent().getStringExtra(DetailApplyActivity.KEY_VIDEO_PATH);
}
private void setRingtone() {
......
......@@ -10,7 +10,10 @@ import com.downloader.OnDownloadListener
import com.downloader.PRDownloader
import com.mints.goodmoney.R
import com.mints.goodmoney.ad.video.VideoAdingManager
import com.mints.goodmoney.call.detail.DetailActivity
import com.mints.goodmoney.call.business.VideoDBHelper
import com.mints.goodmoney.call.detail.DetailApplyActivity
import com.mints.goodmoney.call.permission.PermissionActivity
import com.mints.goodmoney.call.permission.PermissionManager
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.manager.UserManager
import com.mints.goodmoney.mvp.model.VideoAdingBean
......@@ -99,6 +102,10 @@ class KylVideoActivity : BaseActivity(), View.OnClickListener, KylVideoView {
when (v?.id) {
R.id.ivBack -> finish()
R.id.ivSetting -> {
if (downloadVedioSucFlag) {
readyGo()
return
}
RxPermissions(this)
.request(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)
.subscribe { granted: Boolean ->
......@@ -196,6 +203,17 @@ class KylVideoActivity : BaseActivity(), View.OnClickListener, KylVideoView {
return
}
DetailActivity.startSelf(this@KylVideoActivity, vedioPathName)
// DetailActivity.startSelf(this@KylVideoActivity, vedioPathName)
// finish()
readyGo()
}
private fun readyGo() {
if (PermissionManager.getInstance().checkEssential(this)) {
VideoDBHelper.getInstance().setSelectVideo(this, VideoDBHelper.UNKNOWN_NUMBER, vedioPathName)
DetailApplyActivity.startSelf(this, vedioPathName, true)
} else {
PermissionActivity.startSelf(this)
}
}
}
......@@ -3,6 +3,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.mints.goodmoney.call.widget.CustomVideoView
android:id="@+id/video_view"
android:layout_width="match_parent"
......@@ -22,4 +23,13 @@
android:onClick="setShow"
android:text="设置来电秀"
android:textColor="@color/white" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginTop="14dp"
android:onClick="ivOnfinish"
android:padding="20dp"
android:src="@mipmap/ic_left_arrow" />
</RelativeLayout>
\ No newline at end of file
......@@ -23,17 +23,16 @@
<TextView
android:id="@+id/ivSetting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_marginBottom="120dp"
android:drawableTop="@mipmap/ic_setting_vedio"
android:drawablePadding="4dp"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:background="@drawable/shape_tv_gold"
android:gravity="center"
android:text="设置来电秀"
android:textColor="@color/color_FF9837"
android:textSize="14sp"
android:layout_marginBottom="40dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent" />
android:textColor="@color/white" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -118,7 +118,7 @@
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_height="40dp"
android:layout_marginLeft="60dp"
android:layout_marginTop="40dp"
android:layout_marginRight="60dp"
......
......@@ -36,7 +36,7 @@
android:id="@+id/item_title_friends"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:drawableLeft="@mipmap/ic_friends_enable"
android:drawableTop="@mipmap/ic_friends"
android:drawablePadding="2dp"
android:text="平台分红"
android:textColor="@color/color_FF9837"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment