From 3bb40a59907d89ab72d93fb51854dff294e22997 Mon Sep 17 00:00:00 2001
From: tehcneko <7764726+tehcneko@users.noreply.github.com>
Date: Sat, 27 Feb 2021 20:59:16 +0800
Subject: [PATCH] [app] blurrrr
---
.../LSPosedManagerServiceClient.java | 19 ++++++
.../manager/ui/activity/MainActivity.java | 4 +-
.../ui/fragment/StatusDialogBuilder.java | 4 +-
.../manager/util/BlurBehindDialogBuilder.java | 60 +++++++++++++++++++
.../util/svg/ExternalFileResolver.java | 19 ++++++
.../lsposed/manager/util/svg/SvgDecoder.java | 1 -
.../util/svg/SvgDrawableTranscoder.java | 1 -
7 files changed, 102 insertions(+), 6 deletions(-)
create mode 100644 app/src/main/java/io/github/lsposed/manager/util/BlurBehindDialogBuilder.java
diff --git a/app/src/main/java/io/github/lsposed/manager/receivers/LSPosedManagerServiceClient.java b/app/src/main/java/io/github/lsposed/manager/receivers/LSPosedManagerServiceClient.java
index 423e834e..989d23fb 100644
--- a/app/src/main/java/io/github/lsposed/manager/receivers/LSPosedManagerServiceClient.java
+++ b/app/src/main/java/io/github/lsposed/manager/receivers/LSPosedManagerServiceClient.java
@@ -1,3 +1,22 @@
+/*
+ * This file is part of LSPosed.
+ *
+ * LSPosed is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * LSPosed is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with LSPosed. If not, see .
+ *
+ * Copyright (C) 2021 LSPosed Contributors
+ */
+
package io.github.lsposed.manager.receivers;
import android.content.pm.PackageInfo;
diff --git a/app/src/main/java/io/github/lsposed/manager/ui/activity/MainActivity.java b/app/src/main/java/io/github/lsposed/manager/ui/activity/MainActivity.java
index 673daa9f..3ff3d25a 100644
--- a/app/src/main/java/io/github/lsposed/manager/ui/activity/MainActivity.java
+++ b/app/src/main/java/io/github/lsposed/manager/ui/activity/MainActivity.java
@@ -27,7 +27,6 @@ import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
-import androidx.appcompat.app.AlertDialog;
import androidx.core.text.HtmlCompat;
import com.bumptech.glide.Glide;
@@ -41,6 +40,7 @@ import io.github.lsposed.manager.databinding.ActivityMainBinding;
import io.github.lsposed.manager.databinding.DialogAboutBinding;
import io.github.lsposed.manager.ui.activity.base.BaseActivity;
import io.github.lsposed.manager.ui.fragment.StatusDialogBuilder;
+import io.github.lsposed.manager.util.BlurBehindDialogBuilder;
import io.github.lsposed.manager.util.GlideHelper;
import io.github.lsposed.manager.util.ModuleUtil;
import io.github.lsposed.manager.util.NavUtil;
@@ -80,7 +80,7 @@ public class MainActivity extends BaseActivity {
R.string.about_view_source_code,
"GitHub",
"Telegram"), HtmlCompat.FROM_HTML_MODE_LEGACY));
- new AlertDialog.Builder(this)
+ new BlurBehindDialogBuilder(this)
.setView(binding.getRoot())
.show();
});
diff --git a/app/src/main/java/io/github/lsposed/manager/ui/fragment/StatusDialogBuilder.java b/app/src/main/java/io/github/lsposed/manager/ui/fragment/StatusDialogBuilder.java
index e69e9511..74059110 100644
--- a/app/src/main/java/io/github/lsposed/manager/ui/fragment/StatusDialogBuilder.java
+++ b/app/src/main/java/io/github/lsposed/manager/ui/fragment/StatusDialogBuilder.java
@@ -27,7 +27,6 @@ import android.view.LayoutInflater;
import android.view.View;
import androidx.annotation.NonNull;
-import androidx.appcompat.app.AlertDialog;
import androidx.core.text.HtmlCompat;
import java.io.BufferedReader;
@@ -40,9 +39,10 @@ import io.github.lsposed.manager.BuildConfig;
import io.github.lsposed.manager.ConfigManager;
import io.github.lsposed.manager.R;
import io.github.lsposed.manager.databinding.StatusInstallerBinding;
+import io.github.lsposed.manager.util.BlurBehindDialogBuilder;
@SuppressLint("StaticFieldLeak")
-public class StatusDialogBuilder extends AlertDialog.Builder {
+public class StatusDialogBuilder extends BlurBehindDialogBuilder {
private static final String CPU_ABI;
private static final String CPU_ABI2;
diff --git a/app/src/main/java/io/github/lsposed/manager/util/BlurBehindDialogBuilder.java b/app/src/main/java/io/github/lsposed/manager/util/BlurBehindDialogBuilder.java
new file mode 100644
index 00000000..54424439
--- /dev/null
+++ b/app/src/main/java/io/github/lsposed/manager/util/BlurBehindDialogBuilder.java
@@ -0,0 +1,60 @@
+/*
+ * This file is part of LSPosed.
+ *
+ * LSPosed is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * LSPosed is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with LSPosed. If not, see .
+ *
+ * Copyright (C) 2021 LSPosed Contributors
+ */
+
+package io.github.lsposed.manager.util;
+
+import android.content.Context;
+import android.os.Build;
+import android.view.SurfaceControl;
+import android.view.View;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AlertDialog;
+
+public class BlurBehindDialogBuilder extends AlertDialog.Builder {
+ public BlurBehindDialogBuilder(@NonNull Context context) {
+ super(context);
+ }
+
+ @NonNull
+ @Override
+ public AlertDialog create() {
+ AlertDialog dialog = super.create();
+ dialog.setOnShowListener(d -> setBackgroundBlurRadius(dialog.getWindow().getDecorView()));
+ return dialog;
+ }
+
+ private void setBackgroundBlurRadius(View view) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+ try {
+ Object viewRootImpl = view.getClass().getMethod("getViewRootImpl").invoke(view);
+ if (viewRootImpl == null) {
+ return;
+ }
+ SurfaceControl surfaceControl = (SurfaceControl) viewRootImpl.getClass().getMethod("getSurfaceControl").invoke(viewRootImpl);
+
+ SurfaceControl.Transaction transaction = new SurfaceControl.Transaction();
+ transaction.getClass().getDeclaredMethod("setBackgroundBlurRadius", SurfaceControl.class, int.class).invoke(transaction, surfaceControl, 150);
+ transaction.apply();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/io/github/lsposed/manager/util/svg/ExternalFileResolver.java b/app/src/main/java/io/github/lsposed/manager/util/svg/ExternalFileResolver.java
index ecfcd181..cb394250 100644
--- a/app/src/main/java/io/github/lsposed/manager/util/svg/ExternalFileResolver.java
+++ b/app/src/main/java/io/github/lsposed/manager/util/svg/ExternalFileResolver.java
@@ -1,3 +1,22 @@
+/*
+ * This file is part of LSPosed.
+ *
+ * LSPosed is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * LSPosed is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with LSPosed. If not, see .
+ *
+ * Copyright (C) 2021 LSPosed Contributors
+ */
+
package io.github.lsposed.manager.util.svg;
import android.graphics.Bitmap;
diff --git a/app/src/main/java/io/github/lsposed/manager/util/svg/SvgDecoder.java b/app/src/main/java/io/github/lsposed/manager/util/svg/SvgDecoder.java
index 3838b777..fa17246e 100644
--- a/app/src/main/java/io/github/lsposed/manager/util/svg/SvgDecoder.java
+++ b/app/src/main/java/io/github/lsposed/manager/util/svg/SvgDecoder.java
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with LSPosed. If not, see .
*
- * Copyright (C) 2020 EdXposed Contributors
* Copyright (C) 2021 LSPosed Contributors
*/
diff --git a/app/src/main/java/io/github/lsposed/manager/util/svg/SvgDrawableTranscoder.java b/app/src/main/java/io/github/lsposed/manager/util/svg/SvgDrawableTranscoder.java
index 4bc9628f..b2e34737 100644
--- a/app/src/main/java/io/github/lsposed/manager/util/svg/SvgDrawableTranscoder.java
+++ b/app/src/main/java/io/github/lsposed/manager/util/svg/SvgDrawableTranscoder.java
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with LSPosed. If not, see .
*
- * Copyright (C) 2020 EdXposed Contributors
* Copyright (C) 2021 LSPosed Contributors
*/