refactor support for application overlay in api v >= 26 (#364)
This commit is contained in:
parent
3710cf5eb3
commit
78c1b935b9
1 changed files with 11 additions and 8 deletions
|
@ -424,12 +424,7 @@ public class AutofillService extends AccessibilityService {
|
|||
builder.setMessage(getString(R.string.autofill_paste_username, password.getUsername()));
|
||||
|
||||
dialog = builder.create();
|
||||
//noinspection ConstantConditions
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
|
||||
} else {
|
||||
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
|
||||
}
|
||||
this.setDialogType(dialog);
|
||||
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
|
||||
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
|
||||
dialog.show();
|
||||
|
@ -494,8 +489,7 @@ public class AutofillService extends AccessibilityService {
|
|||
});
|
||||
|
||||
dialog = builder.create();
|
||||
//noinspection ConstantConditions
|
||||
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
|
||||
this.setDialogType(dialog);
|
||||
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
|
||||
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
|
||||
// arbitrary non-annoying size
|
||||
|
@ -508,6 +502,15 @@ public class AutofillService extends AccessibilityService {
|
|||
dialog.show();
|
||||
}
|
||||
|
||||
private void setDialogType(AlertDialog dialog) {
|
||||
//noinspection ConstantConditions
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
|
||||
} else {
|
||||
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInterrupt() {
|
||||
|
||||
|
|
Loading…
Reference in a new issue