mirror of
https://github.com/android-password-store/Android-Password-Store.git
synced 2026-05-01 03:05:31 +02:00
More tweaks of dialog dismissal behaviour
This commit is contained in:
parent
3523a0497b
commit
2889454d32
|
|
@ -31,7 +31,6 @@ import java.util.Map;
|
|||
// blank activity started by service for calling startIntentSenderForResult
|
||||
public class AutofillActivity extends AppCompatActivity {
|
||||
public static final int REQUEST_CODE_DECRYPT_AND_VERIFY = 9913;
|
||||
private boolean bound = false;
|
||||
|
||||
private RecyclerView recyclerView;
|
||||
AutofillRecyclerAdapter recyclerAdapter; // let fragment have access
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
package com.zeapo.pwdstore.autofill;
|
||||
|
||||
public class AutofillPreferenceActivity {
|
||||
}
|
||||
|
|
@ -18,6 +18,7 @@ import android.util.Log;
|
|||
import android.view.WindowManager;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.view.accessibility.AccessibilityWindowInfo;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.zeapo.pwdstore.R;
|
||||
|
|
@ -43,6 +44,7 @@ public class AutofillService extends AccessibilityService {
|
|||
private AccessibilityNodeInfo info; // the original source of the event (the edittext field)
|
||||
private ArrayList<PasswordItem> items; // password choices
|
||||
private AlertDialog dialog;
|
||||
private AccessibilityWindowInfo window;
|
||||
private static boolean unlockOK = false; // if openkeychain user interaction was successful
|
||||
private CharSequence packageName;
|
||||
private boolean ignoreActionFocus = false;
|
||||
|
|
@ -73,11 +75,18 @@ public class AutofillService extends AccessibilityService {
|
|||
if (!event.isPassword()
|
||||
|| Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2
|
||||
|| event.getPackageName().equals("org.sufficientlysecure.keychain")) {
|
||||
// dismiss dialog if WINDOW_STATE_CHANGED unless the keyboard caused it
|
||||
// the default keyboard showing/hiding is a window state changed event
|
||||
// on Android 5+ we can use getWindows() to determine when the original window is not visible
|
||||
// on Android 4.3 we have to use window state changed events and filter out the keyboard ones
|
||||
// there may be other exceptions...
|
||||
if (!(event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
|
||||
&& event.getPackageName().toString().contains("com.android.inputmethod"))
|
||||
&& dialog != null && dialog.isShowing()) {
|
||||
boolean dismiss;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
dismiss = !getWindows().contains(window);
|
||||
} else {
|
||||
dismiss = !(event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
|
||||
&& event.getPackageName().toString().contains("inputmethod"));
|
||||
}
|
||||
if (dismiss && dialog != null && dialog.isShowing()) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
return;
|
||||
|
|
@ -99,8 +108,14 @@ public class AutofillService extends AccessibilityService {
|
|||
return;
|
||||
}
|
||||
|
||||
// get the app name and find a corresponding password
|
||||
info = event.getSource();
|
||||
|
||||
// save the dialog's corresponding window so we can use getWindows() above to check whether dismiss
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
window = info.getWindow();
|
||||
}
|
||||
|
||||
// get the app name and find a corresponding password
|
||||
PackageManager packageManager = getPackageManager();
|
||||
ApplicationInfo applicationInfo;
|
||||
try {
|
||||
|
|
@ -134,10 +149,10 @@ public class AutofillService extends AccessibilityService {
|
|||
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
|
||||
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
|
||||
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
|
||||
dialog.getWindow().setLayout(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT);
|
||||
}
|
||||
dialog.setTitle(items.get(0).toString());
|
||||
dialog.show();
|
||||
dialog.getWindow().setLayout(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT);
|
||||
}
|
||||
|
||||
private ArrayList<PasswordItem> recursiveFilter(String filter, File dir) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/app_search"
|
||||
android:queryHint="Add an app to change its autofill setting"
|
||||
android:queryHint="Add an app to change its setting"
|
||||
android:iconifiedByDefault="false"/>
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:description="@string/autofill_description"
|
||||
android:accessibilityEventTypes="typeViewFocused|typeViewClicked|typeWindowStateChanged"
|
||||
android:accessibilityFlags="flagDefault"
|
||||
android:accessibilityFlags="flagDefault|flagRetrieveInteractiveWindows"
|
||||
android:accessibilityFeedbackType="feedbackGeneric"
|
||||
android:notificationTimeout="100"
|
||||
android:canRetrieveWindowContent="true"
|
||||
|
|
|
|||
Loading…
Reference in a new issue