Skip to content

Commit f860392

Browse files
devlearnerStypox
authored andcommitted
Address LayoutParams.FLAG_NOT_TOUCHABLE restriction on Andriod 12+
1 parent 3918305 commit f860392

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

app/src/main/java/org/schabi/newpipe/RouterActivity.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,21 @@ protected void onCreate(final Bundle savedInstanceState) {
124124
// Pass-through touch events to background activities
125125
// so that our transparent window won't lock UI in the mean time
126126
// network request is underway before showing PlaylistDialog or DownloadDialog
127-
// (courtesy of https://stackoverflow.com/a/10606141)
127+
// (ref: https://stackoverflow.com/a/10606141)
128128
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
129129
| WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
130130
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
131131

132+
// Android never fails to impress us with a list of new restrictions per API.
133+
// Starting with S (Android 12) one of the prerequisite conditions has to be met
134+
// before the FLAG_NOT_TOUCHABLE flag is allowed to kick in:
135+
// @see WindowManager.LayoutParams#FLAG_NOT_TOUCHABLE
136+
// For our present purpose it seems we can just set LayoutParams.alpha to 0
137+
// on the strength of "4. Fully transparent windows" without affecting the scrim of dialogs
138+
final WindowManager.LayoutParams params = getWindow().getAttributes();
139+
params.alpha = 0f;
140+
getWindow().setAttributes(params);
141+
132142
super.onCreate(savedInstanceState);
133143
Icepick.restoreInstanceState(this, savedInstanceState);
134144

0 commit comments

Comments
 (0)