|
|
@@ -34,24 +34,23 @@ import android.provider.DocumentsContract;
|
|
|
import android.content.ComponentName;
|
|
|
import java.io.File;
|
|
|
import androidx.core.content.FileProvider;
|
|
|
+import android.os.Build;
|
|
|
|
|
|
//https://www.cnblogs.com/dwcg/articles/17933292.html
|
|
|
-public class DownloadTaskDialog {
|
|
|
+public class DownloadTaskDialog extends AlertDialog{
|
|
|
private Activity mActivity;
|
|
|
- AlertDialog alertDialog;
|
|
|
TextView tv_remote_ver,tv_log_dl,tv_img_dl;
|
|
|
|
|
|
public DownloadTaskDialog(Activity a){
|
|
|
+ super(a);
|
|
|
mActivity = a;
|
|
|
init();
|
|
|
}
|
|
|
|
|
|
private void init(){
|
|
|
- AlertDialog.Builder customizeDialog =
|
|
|
- new AlertDialog.Builder(mActivity);
|
|
|
final View dialogView = LayoutInflater.from(mActivity)
|
|
|
.inflate(R.layout.download_task_dialog,null);
|
|
|
- customizeDialog.setView(dialogView);
|
|
|
+ setView(dialogView);
|
|
|
tv_remote_ver = dialogView.findViewById(R.id.tv_remote_ver);
|
|
|
RxView.clicks( dialogView.findViewById(R.id.btn_close))
|
|
|
.throttleFirst( 500 , TimeUnit.MILLISECONDS )
|
|
|
@@ -98,8 +97,7 @@ public class DownloadTaskDialog {
|
|
|
showViaFileManager();
|
|
|
}
|
|
|
});
|
|
|
- alertDialog = customizeDialog.create();
|
|
|
- alertDialog.setCancelable(false);
|
|
|
+ setCancelable(false);
|
|
|
}
|
|
|
|
|
|
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
|
|
|
@@ -136,14 +134,20 @@ public class DownloadTaskDialog {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
public void show(){
|
|
|
+ Window window = getWindow();
|
|
|
+ focusNotAle(window);
|
|
|
+ super.show();
|
|
|
+ hideNavigationBar(window);
|
|
|
+ clearFocusNotAle(window);
|
|
|
EventBus.getDefault().register(this);
|
|
|
- alertDialog.show();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
public void dismiss(){
|
|
|
EventBus.getDefault().unregister(this);
|
|
|
- alertDialog.dismiss();
|
|
|
+ super.dismiss();
|
|
|
}
|
|
|
|
|
|
private void shareViaWechat(){
|
|
|
@@ -168,4 +172,44 @@ public class DownloadTaskDialog {
|
|
|
mActivity.startActivityForResult(intent,0);
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ public void hideNavigationBar(Window window) {
|
|
|
+ window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
|
|
|
+ window.getDecorView().setOnSystemUiVisibilityChangeListener(visibility -> {
|
|
|
+ int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
|
|
+ //布局位于状态栏下方
|
|
|
+ View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
|
|
+ //全屏
|
|
|
+ View.SYSTEM_UI_FLAG_FULLSCREEN |
|
|
|
+ //隐藏导航栏
|
|
|
+ View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
|
|
|
+ View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
|
|
|
+ if (Build.VERSION.SDK_INT >= 19) {
|
|
|
+ uiOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
|
|
+ } else {
|
|
|
+ uiOptions |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
|
|
|
+ }
|
|
|
+ window.getDecorView().setSystemUiVisibility(uiOptions);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * dialog 需要全屏的时候用,和clearFocusNotAle() 成对出现
|
|
|
+ * 在show 前调用 focusNotAle show后调用clearFocusNotAle
|
|
|
+ *
|
|
|
+ * @param window
|
|
|
+ */
|
|
|
+ public void focusNotAle(Window window) {
|
|
|
+ window.setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * dialog 需要全屏的时候用,focusNotAle() 成对出现
|
|
|
+ * 在show 前调用 focusNotAle show后调用clearFocusNotAle
|
|
|
+ *
|
|
|
+ * @param window
|
|
|
+ */
|
|
|
+ public void clearFocusNotAle(Window window) {
|
|
|
+ window.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
|
|
|
+ }
|
|
|
}
|