diff options
author | Matthew Wong <wongma@protonmail.ch> | 2015-12-30 01:18:42 -0500 |
---|---|---|
committer | Matthew Wong <wongma@protonmail.ch> | 2015-12-30 01:18:42 -0500 |
commit | ebd565ec379e2209eafbbef8f86da0ca00bb29ff (patch) | |
tree | 64032cc0b8629460844ce9971acf95523b1848a6 /app/src/main/java | |
parent | 5263ed10bbca73d8c454c4c37a7589b894977f75 (diff) |
add always show dialog preference.
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.java | 3 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java | 20 |
2 files changed, 13 insertions, 10 deletions
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<File> searchPasswords(File path, String appName) { ArrayList<File> 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(); } |