From 28eae3356739984f2c5057fa15b10e64917deb62 Mon Sep 17 00:00:00 2001 From: Matthew Wong Date: Thu, 5 Nov 2015 23:44:46 -0500 Subject: Use File instead of PasswordItem for using file to fill --- app/src/main/res/xml/autofill_config.xml | 1 - 1 file changed, 1 deletion(-) (limited to 'app/src/main/res/xml') diff --git a/app/src/main/res/xml/autofill_config.xml b/app/src/main/res/xml/autofill_config.xml index 62f82a5e..7dce1d83 100644 --- a/app/src/main/res/xml/autofill_config.xml +++ b/app/src/main/res/xml/autofill_config.xml @@ -5,5 +5,4 @@ android:accessibilityFeedbackType="feedbackGeneric" android:notificationTimeout="100" android:canRetrieveWindowContent="true" - android:canRequestEnhancedWebAccessibility="true" /> \ No newline at end of file -- cgit v1.2.3 From ebd565ec379e2209eafbbef8f86da0ca00bb29ff Mon Sep 17 00:00:00 2001 From: Matthew Wong Date: Wed, 30 Dec 2015 01:18:42 -0500 Subject: add always show dialog preference. --- app/build.gradle | 10 +++++----- .../zeapo/pwdstore/autofill/AutofillFragment.java | 3 +-- .../com/zeapo/pwdstore/autofill/AutofillService.java | 20 ++++++++++++-------- app/src/main/res/values/strings.xml | 5 +++-- app/src/main/res/xml/preference.xml | 6 +++++- build.gradle | 2 +- 6 files changed, 27 insertions(+), 19 deletions(-) (limited to 'app/src/main/res/xml') diff --git a/app/build.gradle b/app/build.gradle index 13a92edb..e161e9a9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,7 +4,7 @@ apply plugin: 'eclipse' android { compileSdkVersion 23 - buildToolsVersion "23.0.1" + buildToolsVersion "23.0.2" defaultConfig { applicationId "com.zeapo.pwdstore" minSdkVersion 15 @@ -56,10 +56,10 @@ android { } dependencies { - compile 'com.android.support:appcompat-v7:23.0.1' - compile 'com.android.support:recyclerview-v7:23.0.1' - compile 'com.android.support:cardview-v7:23.0.1' - compile 'com.android.support:design:23.0.1' + compile 'com.android.support:appcompat-v7:23.1.1' + compile 'com.android.support:recyclerview-v7:23.1.1' + compile 'com.android.support:cardview-v7:23.1.1' + compile 'com.android.support:design:23.1.1' compile 'org.sufficientlysecure:openpgp-api:9.0' compile ('org.eclipse.jgit:org.eclipse.jgit:3.7.1.201504261725-r') { exclude group: 'org.apache.httpcomponents', module: 'httpclient' diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.java b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.java index 123f4dc4..1c4c2076 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.java +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.java @@ -40,8 +40,7 @@ public class AutofillFragment extends DialogFragment { final AutofillPreferenceActivity callingActivity = (AutofillPreferenceActivity) getActivity(); LayoutInflater inflater = callingActivity.getLayoutInflater(); - final View view = View.inflate(callingActivity.getApplicationContext() - , R.layout.fragment_autofill, null); + final View view = inflater.inflate(R.layout.fragment_autofill, null); builder.setView(view); 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 88580e59..50ae3506 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java @@ -149,7 +149,9 @@ public class AutofillService extends AccessibilityService { appName = setMatchingPasswordsWeb(webViewTitle); } - if (items.isEmpty()) { // show anyway preference? + // if autofill_always checked, show dialog even if no matches (automatic + // or otherwise) + if (items.isEmpty() && !settings.getBoolean("autofill_always", false)) { return; } showDialog(appName); @@ -210,7 +212,7 @@ public class AutofillService extends AccessibilityService { items = searchPasswords(PasswordRepository.getRepositoryDirectory(this), appName); break; case "/never": - items.clear(); + items = new ArrayList<>(); return; default: getPreferredPasswords(preference); @@ -234,7 +236,7 @@ public class AutofillService extends AccessibilityService { } items = searchPasswords(PasswordRepository.getRepositoryDirectory(this), webViewTitle); } else { - items.clear(); + items = new ArrayList<>(); } return webViewTitle; } @@ -255,7 +257,6 @@ public class AutofillService extends AccessibilityService { } } - private ArrayList searchPasswords(File path, String appName) { ArrayList passList = PasswordRepository.getFilesList(path); @@ -322,12 +323,15 @@ public class AutofillService extends AccessibilityService { dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); // arbitrary non-annoying size - int height = 144; + int height = 88; + if (items.size() > 0) { + height += 66; + } if (items.size() > 1) { - height += 48; + height += 33; } - dialog.getWindow().setLayout((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 240, getResources().getDisplayMetrics()) - , (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, height, getResources().getDisplayMetrics())); + dialog.getWindow().setLayout((int) (240 * getApplicationContext().getResources().getDisplayMetrics().density) + , (int) (height * getApplicationContext().getResources().getDisplayMetrics().density)); dialog.show(); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index de289e48..3f4fb345 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -112,7 +112,7 @@ Set the time you want the password to be in clipboard Automatically Copy Password Automatically copy the password to the clipboard after decryption was successful. - SSH-key imported + SSH-key imported Error while trying to import the ssh-key Message : \n Recursive filtering @@ -121,10 +121,11 @@ Tap OK to go to Accessibility settings. There, tap Password Store under Services then tap the switch in the top right to turn it on or off. Once the service is on, a dialog will appear when you click on a password field in an app if a matching password for the app exists. Password Store attempts to match apps with passwords automatically. You can change this default setting and also matching settings per-app. - Per-app settings + App and website settings Customize autofill settings for specific apps. Automatically match by default Default to \'Automatically match\' for apps without custom settings. Otherwise, \'Never match.\' + Always show dialog Clear clipboard 20 times Store nonsense in the clipboard 20 times instead of just once. Useful on Samsung phones that feature clipboard history. diff --git a/app/src/main/res/xml/preference.xml b/app/src/main/res/xml/preference.xml index 639fdfe1..f8397bc3 100644 --- a/app/src/main/res/xml/preference.xml +++ b/app/src/main/res/xml/preference.xml @@ -79,7 +79,6 @@ + diff --git a/build.gradle b/build.gradle index 9cbebcf6..22422a8c 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ allprojects { ext { compileSdkVersion = 23 - buildToolsVersion = "23.0.1" + buildToolsVersion = "23.0.2" } subprojects { subproject -> afterEvaluate{ -- cgit v1.2.3 From cdf27fc24da18fc7e60b4db5b1b24bcab2b38e4f Mon Sep 17 00:00:00 2001 From: Matthew Wong Date: Wed, 30 Dec 2015 05:50:56 -0500 Subject: Get the URL in Chrome --- .../zeapo/pwdstore/autofill/AutofillService.java | 31 +++++++++++++++++++--- app/src/main/res/xml/autofill_config.xml | 2 +- 2 files changed, 29 insertions(+), 4 deletions(-) (limited to 'app/src/main/res/xml') 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 50ae3506..1025028a 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java @@ -17,7 +17,6 @@ import android.preference.PreferenceManager; import android.provider.Settings; import android.support.v7.app.AlertDialog; import android.util.Log; -import android.util.TypedValue; import android.view.WindowManager; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; @@ -38,7 +37,10 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URL; import java.util.ArrayList; +import java.util.List; import java.util.Map; public class AutofillService extends AccessibilityService { @@ -53,6 +55,7 @@ public class AutofillService extends AccessibilityService { private CharSequence packageName; private boolean ignoreActionFocus = false; private String webViewTitle = null; + private String webViewURL = null; public final class Constants { public static final String TAG = "Keychain"; @@ -84,6 +87,28 @@ public class AutofillService extends AccessibilityService { && event.getSource().getPackageName().equals("com.android.chrome"))) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { webViewTitle = searchWebView(getRootInActiveWindow()); + webViewURL = null; + if (webViewTitle != null) { + List nodes = getRootInActiveWindow() + .findAccessibilityNodeInfosByViewId("com.android.chrome:id/url_bar"); + for (AccessibilityNodeInfo node : nodes) + if (node.getText() != null) { + try { + webViewURL = new URL(node.getText().toString()).getHost(); + } catch (MalformedURLException e) { + if (e.toString().contains("Protocol not found")) { + try { + webViewURL = new URL("http://" + node.getText().toString()).getHost(); + } catch (MalformedURLException ignored) { + } + } + } + } + } + if (webViewTitle != null) + Log.d("Title", webViewTitle); + if (webViewURL != null) + Log.d("URL", webViewURL); } // nothing to do if not password field focus, android version, or field is keychain app @@ -166,10 +191,10 @@ public class AutofillService extends AccessibilityService { if (u == null) { continue; } - // this is not likely to always work if (u.getClassName() != null && u.getClassName().equals("android.webkit.WebView")) { - if (u.getContentDescription() != null) + if (u.getContentDescription() != null) { return u.getContentDescription().toString(); + } return ""; } if (searchWebView(u) != null) { diff --git a/app/src/main/res/xml/autofill_config.xml b/app/src/main/res/xml/autofill_config.xml index 7dce1d83..09e91174 100644 --- a/app/src/main/res/xml/autofill_config.xml +++ b/app/src/main/res/xml/autofill_config.xml @@ -1,7 +1,7 @@