修复Android 12下的桌面歌词锁定后还是无法在应用外点击歌词后面下面的内容的问题

This commit is contained in:
lyswhut 2022-02-25 22:41:14 +08:00
parent b5ab44c29f
commit d4764ab30f
2 changed files with 19 additions and 0 deletions

View File

@ -178,9 +178,18 @@ public class LyricView extends Activity implements View.OnTouchListener {
if (isLock) { if (isLock) {
layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
textView.setBackgroundColor(Color.TRANSPARENT); textView.setBackgroundColor(Color.TRANSPARENT);
// 修复 Android 12 的穿透点击问题
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) {
layoutParams.alpha = 0.8f;
}
} else { } else {
layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
textView.setBackgroundResource(R.drawable.rounded_corner); textView.setBackgroundResource(R.drawable.rounded_corner);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) {
layoutParams.alpha = 1.0f;
}
} }
// TYPE_SYSTEM_ALERT 系统提示,它总是出现在应用程序窗口之上 // TYPE_SYSTEM_ALERT 系统提示,它总是出现在应用程序窗口之上
@ -280,6 +289,9 @@ public class LyricView extends Activity implements View.OnTouchListener {
isLock = true; isLock = true;
if (windowManager == null || textView == null) return; if (windowManager == null || textView == null) return;
layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; 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); textView.setBackgroundColor(Color.TRANSPARENT);
windowManager.updateViewLayout(textView, layoutParams); windowManager.updateViewLayout(textView, layoutParams);
} }
@ -288,6 +300,9 @@ public class LyricView extends Activity implements View.OnTouchListener {
isLock = false; isLock = false;
if (windowManager == null || textView == null) return; if (windowManager == null || textView == null) return;
layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; 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); textView.setBackgroundResource(R.drawable.rounded_corner);
windowManager.updateViewLayout(textView, layoutParams); windowManager.updateViewLayout(textView, layoutParams);
} }

View File

@ -5,3 +5,7 @@
### 优化 ### 优化
- 过滤tx源某些不支持播放的歌曲解决播放此类内容会导致意外的问题 - 过滤tx源某些不支持播放的歌曲解决播放此类内容会导致意外的问题
### 修复
- 修复Android 12下的桌面歌词锁定后还是无法在应用外点击歌词后面下面的内容的问题