summaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorMatthew Wong <wongma@protonmail.ch>2015-08-10 13:11:42 -0400
committerMatthew Wong <wongma@protonmail.ch>2015-08-14 17:36:49 -0400
commit2889454d324c9d210cafc51b47b7645cdd8abb26 (patch)
tree755553c9fac373669d85c9272c4bcbc043ab3b5b /app/src
parent3523a0497b3268485ffcf7107480d473cc930223 (diff)
More tweaks of dialog dismissal behaviour
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.java1
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java4
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java27
-rw-r--r--app/src/main/res/layout/autofill_recycler_view.xml2
-rw-r--r--app/src/main/res/xml/autofill_config.xml2
5 files changed, 27 insertions, 9 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.java b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.java
index 77a44c7a..2d538504 100644
--- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.java
+++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.java
@@ -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
diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java
new file mode 100644
index 00000000..6f212149
--- /dev/null
+++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java
@@ -0,0 +1,4 @@
+package com.zeapo.pwdstore.autofill;
+
+public class AutofillPreferenceActivity {
+}
diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java
index ebe12c9c..b30277ba 100644
--- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java
+++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java
@@ -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) {
diff --git a/app/src/main/res/layout/autofill_recycler_view.xml b/app/src/main/res/layout/autofill_recycler_view.xml
index 6130fd1a..836cbcf5 100644
--- a/app/src/main/res/layout/autofill_recycler_view.xml
+++ b/app/src/main/res/layout/autofill_recycler_view.xml
@@ -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
diff --git a/app/src/main/res/xml/autofill_config.xml b/app/src/main/res/xml/autofill_config.xml
index adf418e6..a604fc07 100644
--- a/app/src/main/res/xml/autofill_config.xml
+++ b/app/src/main/res/xml/autofill_config.xml
@@ -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"