From 1bb032adc68cb0fe043115fa84194b39113cc22a Mon Sep 17 00:00:00 2001 From: hd Date: Mon, 23 Dec 2024 05:05:05 +0800 Subject: [PATCH] fix: GalBgBlurHook setBackgroundBlurRadius throw exception --- .../java/io/github/duzhaokun123/hook/GalBgBlurHook.kt | 9 ++++++--- app/src/main/java/io/github/duzhaokun123/util/Windows.kt | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/github/duzhaokun123/hook/GalBgBlurHook.kt b/app/src/main/java/io/github/duzhaokun123/hook/GalBgBlurHook.kt index 73e0b94357..d26e4cdadb 100644 --- a/app/src/main/java/io/github/duzhaokun123/hook/GalBgBlurHook.kt +++ b/app/src/main/java/io/github/duzhaokun123/hook/GalBgBlurHook.kt @@ -117,12 +117,15 @@ object GalBgBlurHook : CommonConfigFunctionHook(SyncUtils.PROC_PEAK + SyncUtils. override fun initOnce(): Boolean { Activity::class.java.hookAfter(this, "onCreate", Bundle::class.java) { val activity = it.thisObject as Activity - when(activity::class.java.name) { + when (activity::class.java.name) { "com.tencent.mobileqq.richmediabrowser.AIOGalleryActivity", "com.tencent.mobileqq.activity.aio.photo.AIOGalleryActivity", "com.tencent.mobileqq.activity.photo.album.NewPhotoPreviewActivity", - "com.tencent.richframework.gallery.QQGalleryActivity"-> { - activity.window.blurBackground(ConfigManager.getDefaultConfig().getIntOrDefault(brCfg, 10), ConfigManager.getDefaultConfig().getFloat(bdCfg, 0.1F)) + "com.tencent.richframework.gallery.QQGalleryActivity" -> { + activity.window.blurBackground( + ConfigManager.getDefaultConfig().getIntOrDefault(brCfg, 10), + ConfigManager.getDefaultConfig().getFloat(bdCfg, 0.1F) + ) } } } diff --git a/app/src/main/java/io/github/duzhaokun123/util/Windows.kt b/app/src/main/java/io/github/duzhaokun123/util/Windows.kt index 8a73559552..43126bcf5f 100644 --- a/app/src/main/java/io/github/duzhaokun123/util/Windows.kt +++ b/app/src/main/java/io/github/duzhaokun123/util/Windows.kt @@ -10,9 +10,9 @@ fun Window.blurBackground(br: Int, bd: Float) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) return addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND) attributes.blurBehindRadius = br - setBackgroundBlurRadius(br) val blurEnableListener = { _: Boolean -> setDimAmount(bd) + setBackgroundBlurRadius(br) } decorView.addOnAttachStateChangeListener(object : View.OnAttachStateChangeListener { @RequiresApi(Build.VERSION_CODES.S)