diff --git a/android/app/src/main/java/cn/toside/music/mobile/lyric/LyricView.java b/android/app/src/main/java/cn/toside/music/mobile/lyric/LyricView.java index 93967c4..2203153 100644 --- a/android/app/src/main/java/cn/toside/music/mobile/lyric/LyricView.java +++ b/android/app/src/main/java/cn/toside/music/mobile/lyric/LyricView.java @@ -178,9 +178,18 @@ public class LyricView extends Activity implements View.OnTouchListener { if (isLock) { layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; textView.setBackgroundColor(Color.TRANSPARENT); + + // 修复 Android 12 的穿透点击问题 + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) { + layoutParams.alpha = 0.8f; + } } else { layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; textView.setBackgroundResource(R.drawable.rounded_corner); + + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) { + layoutParams.alpha = 1.0f; + } } // TYPE_SYSTEM_ALERT 系统提示,它总是出现在应用程序窗口之上 @@ -280,6 +289,9 @@ public class LyricView extends Activity implements View.OnTouchListener { isLock = true; if (windowManager == null || textView == null) return; layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) { + layoutParams.alpha = 0.8f; + } textView.setBackgroundColor(Color.TRANSPARENT); windowManager.updateViewLayout(textView, layoutParams); } @@ -288,6 +300,9 @@ public class LyricView extends Activity implements View.OnTouchListener { isLock = false; if (windowManager == null || textView == null) return; layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) { + layoutParams.alpha = 1.0f; + } textView.setBackgroundResource(R.drawable.rounded_corner); windowManager.updateViewLayout(textView, layoutParams); } diff --git a/publish/changeLog.md b/publish/changeLog.md index 13c91c3..3cb825a 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -5,3 +5,7 @@ ### 优化 - 过滤tx源某些不支持播放的歌曲,解决播放此类内容会导致意外的问题 + +### 修复 + +- 修复Android 12下的桌面歌词锁定后还是无法在应用外点击歌词后面下面的内容的问题