Address LayoutParams.FLAG_NOT_TOUCHABLE restriction on Andriod 12+

This commit is contained in:
devlearner 2022-12-02 06:13:54 +00:00 committed by Stypox
parent 391830558e
commit f860392ae9
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
1 changed files with 11 additions and 1 deletions

View File

@ -124,11 +124,21 @@ public class RouterActivity extends AppCompatActivity {
// Pass-through touch events to background activities
// so that our transparent window won't lock UI in the mean time
// network request is underway before showing PlaylistDialog or DownloadDialog
// (courtesy of https://stackoverflow.com/a/10606141)
// (ref: https://stackoverflow.com/a/10606141)
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
// Android never fails to impress us with a list of new restrictions per API.
// Starting with S (Android 12) one of the prerequisite conditions has to be met
// before the FLAG_NOT_TOUCHABLE flag is allowed to kick in:
// @see WindowManager.LayoutParams#FLAG_NOT_TOUCHABLE
// For our present purpose it seems we can just set LayoutParams.alpha to 0
// on the strength of "4. Fully transparent windows" without affecting the scrim of dialogs
final WindowManager.LayoutParams params = getWindow().getAttributes();
params.alpha = 0f;
getWindow().setAttributes(params);
super.onCreate(savedInstanceState);
Icepick.restoreInstanceState(this, savedInstanceState);