From 02bfcf6c3f5ddd806dd9a92823926eced139842f Mon Sep 17 00:00:00 2001 From: Matthew Wong Date: Tue, 28 Jul 2015 03:11:02 -0400 Subject: Create app autofill service: a dialog pops up for all password fields & has a button to paste/set a password found in the store with name matching app's --- app/src/main/res/values/strings.xml | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/src/main/res/values/strings.xml') diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3a3d4061..825643bf 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -154,4 +154,6 @@ Generate "Category: " + + Auto-fills login fields. -- cgit v1.2.3 From 4b15ea3ae90fa870c622192cbf89eb5e02db97b6 Mon Sep 17 00:00:00 2001 From: Matthew Wong Date: Tue, 28 Jul 2015 12:36:09 -0400 Subject: Initialize the repository automatically, don't require the app to do it after a restart --- .../java/com/zeapo/pwdstore/AutofillService.java | 38 ++++++++++++++++++++-- app/src/main/res/values/strings.xml | 2 +- 2 files changed, 37 insertions(+), 3 deletions(-) (limited to 'app/src/main/res/values/strings.xml') diff --git a/app/src/main/java/com/zeapo/pwdstore/AutofillService.java b/app/src/main/java/com/zeapo/pwdstore/AutofillService.java index de5bcfd2..887e100e 100644 --- a/app/src/main/java/com/zeapo/pwdstore/AutofillService.java +++ b/app/src/main/java/com/zeapo/pwdstore/AutofillService.java @@ -61,6 +61,7 @@ public class AutofillService extends AccessibilityService { @Override public void onAccessibilityEvent(AccessibilityEvent event) { + // if returning to the source app from a successful AutofillActivity if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED && event.getPackageName().equals(packageName) && unlockOK) { decryptAndVerify(); @@ -78,6 +79,7 @@ public class AutofillService extends AccessibilityService { if (dialog != null && dialog.isShowing()) { dialog.dismiss(); } + // ignore the ACTION_FOCUS from decryptAndVerify if (ignoreActionFocus) { ignoreActionFocus = false; return; @@ -107,7 +109,6 @@ public class AutofillService extends AccessibilityService { }); dialog = builder.create(); dialog.setIcon(R.drawable.ic_launcher); - dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); @@ -120,7 +121,7 @@ public class AutofillService extends AccessibilityService { private ArrayList recursiveFilter(String filter, File dir) { ArrayList items = new ArrayList<>(); if (!PasswordRepository.isInitialized()) { - return items; + initialize(); } ArrayList passwordItems = dir == null ? PasswordRepository.getPasswords() : @@ -136,6 +137,39 @@ public class AutofillService extends AccessibilityService { return items; } + // just like PasswordRepository.initialize(). + private void initialize() { + File dir = null; + SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + + if (settings.getBoolean("git_external", false)) { + if (settings.getString("git_external_repo", null) != null) { + dir = new File(settings.getString("git_external_repo", null)); + } + } else { + dir = new File(getFilesDir() + "/store"); + } + // temp for debug + if (dir == null) { + Intent intent = new Intent(this, UserPreference.class); + intent.putExtra("operation", "git_external"); + startActivity(intent); + return; + } + + // uninitialize the repo if the dir does not exist or is absolutely empty + if (!dir.exists() || !dir.isDirectory() || FileUtils.listFiles(dir, null, false).isEmpty()) { + settings.edit().putBoolean("repository_initialized", false).apply(); + } + + if (!PasswordRepository.getPasswords(dir).isEmpty()) { + settings.edit().putBoolean("repository_initialized", true).apply(); + } + + // create the repository static variable in PasswordRepository + PasswordRepository.getRepository(new File(dir.getAbsolutePath() + "/.git")); + } + @Override public void onInterrupt() { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 825643bf..fa5358e2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -155,5 +155,5 @@ "Category: " - Auto-fills login fields. + Auto-fills password fields in apps. Only works for Android versions 4.3 and up. Does not rely on the clipboard for Android versions 5.0 and up. -- cgit v1.2.3 From ebe1f831e7659b63b76c2b39498b68d1fec61673 Mon Sep 17 00:00:00 2001 From: Matthew Wong Date: Fri, 14 Aug 2015 16:51:39 -0400 Subject: strings & enable service preference --- .../java/com/zeapo/pwdstore/UserPreference.java | 51 +++++++++++++++++++++- .../zeapo/pwdstore/autofill/AutofillFragment.java | 5 ++- .../pwdstore/autofill/AutofillRecyclerAdapter.java | 4 +- .../zeapo/pwdstore/autofill/AutofillService.java | 6 +-- app/src/main/res/layout/autofill_row_layout.xml | 2 - app/src/main/res/layout/fragment_autofill.xml | 8 ++-- app/src/main/res/values-cs/strings.xml | 2 +- app/src/main/res/values/strings.xml | 15 ++++++- app/src/main/res/xml/preference.xml | 14 +++--- 9 files changed, 85 insertions(+), 22 deletions(-) (limited to 'app/src/main/res/values/strings.xml') diff --git a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java index cb2d2881..283d5f47 100644 --- a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java +++ b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java @@ -1,17 +1,22 @@ package com.zeapo.pwdstore; -import android.app.AlertDialog; +import android.accessibilityservice.AccessibilityServiceInfo; import android.app.DialogFragment; +import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; import android.os.Bundle; +import android.preference.CheckBoxPreference; import android.preference.Preference; import android.preference.PreferenceFragment; import android.preference.PreferenceManager; +import android.provider.Settings; +import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; +import android.view.accessibility.AccessibilityManager; import android.widget.Toast; import com.google.common.base.Function; @@ -33,6 +38,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.HashSet; +import java.util.List; import java.util.Set; public class UserPreference extends AppCompatActivity { @@ -192,6 +198,30 @@ public class UserPreference extends AppCompatActivity { return true; } }); + + findPreference("autofill_enable").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + new AlertDialog.Builder(callingActivity). + setTitle(R.string.pref_autofill_enable_title). + setMessage(R.string.pref_autofill_enable_msg). + setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS); + startActivity(intent); + } + }). + setNegativeButton(R.string.dialog_cancel,new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + ((CheckBoxPreference) findPreference("autofill_enable")) + .setChecked(((UserPreference) getActivity()).isServiceEnabled()); + } + }).show(); + return false; + } + }); } @Override @@ -199,6 +229,10 @@ public class UserPreference extends AppCompatActivity { super.onStart(); final SharedPreferences sharedPreferences = getPreferenceManager().getSharedPreferences(); findPreference("ssh_see_key").setEnabled(sharedPreferences.getBoolean("use_generated_key", false)); + + // see if the autofill service is enabled and check the preference accordingly + ((CheckBoxPreference) findPreference("autofill_enable")) + .setChecked(((UserPreference) getActivity()).isServiceEnabled()); } } @@ -278,6 +312,21 @@ public class UserPreference extends AppCompatActivity { sshKey.close(); } + // Returns whether the autofill service is enabled + private boolean isServiceEnabled() { + AccessibilityManager am = (AccessibilityManager) this + .getSystemService(Context.ACCESSIBILITY_SERVICE); + List runningServices = am + .getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_GENERIC); + for (AccessibilityServiceInfo service : runningServices) { + if ("com.zeapo.pwdstore/.autofill.AutofillService".equals(service.getId())) { + return true; + } + } + return false; + } + + protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { 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 c2a30ffe..8cf58206 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.java +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.java @@ -68,6 +68,7 @@ public class AutofillFragment extends DialogFragment { View.OnClickListener matchPassword = new View.OnClickListener() { @Override public void onClick(View v) { + ((RadioButton) view.findViewById(R.id.match)).toggle(); Intent intent = new Intent(getActivity(), PasswordStore.class); intent.putExtra("matchWith", true); startActivityForResult(intent, MATCH_WITH); @@ -77,7 +78,7 @@ public class AutofillFragment extends DialogFragment { view.findViewById(R.id.matched).setOnClickListener(matchPassword); final SharedPreferences.Editor editor = prefs.edit(); - builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { + builder.setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.autofill_radiogroup); @@ -105,7 +106,7 @@ public class AutofillFragment extends DialogFragment { } } }); - builder.setNegativeButton("Cancel", null); + builder.setNegativeButton(R.string.dialog_cancel, null); return builder.create(); } diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.java b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.java index 01916650..8971c0af 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.java +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.java @@ -105,10 +105,10 @@ public class AutofillRecyclerAdapter extends RecyclerView.Adapter - - diff --git a/app/src/main/res/layout/fragment_autofill.xml b/app/src/main/res/layout/fragment_autofill.xml index e5534f41..af2b7017 100644 --- a/app/src/main/res/layout/fragment_autofill.xml +++ b/app/src/main/res/layout/fragment_autofill.xml @@ -16,7 +16,7 @@ @@ -24,7 +24,7 @@ @@ -32,7 +32,7 @@ Zpráva : \n Rekurzivní filtrování Rekurzivní hledání hesel v aktuálním adresáři. + Zaplnit schránku 20krát Uložit dvacet náhodných textů do schránky namísto pouze jednoho. Užitečné pro telefony Samsug, které nabízejí funkci historie schránky. - Zaplnit schránku 20krát Generovat diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fa5358e2..447139fb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -117,8 +117,14 @@ Message : \n Recursive filtering Recursively find passwords of the current directory. + Enable autofill + Tap OK to go to Accessibility settings. Once there, tap Password Store under Services then tap the switch in the top right to turn it on or off. + Per-app settings + Customize autofill settings for specific apps. + Automatically match by default + Default to \'Automatically match\' for apps without custom settings. Otherwise, \'Never match.\' + Clear clipboard 20 times Store nonsense in the clipboard 20 times instead of just once. Useful on Samsung phones that feature clipboard history. - Clear clipboard 20 times Generate @@ -155,5 +161,10 @@ "Category: " - Auto-fills password fields in apps. Only works for Android versions 4.3 and up. Does not rely on the clipboard for Android versions 5.0 and up. + Autofills password fields in apps. Only works for Android versions 4.3 and up. Does not rely on the clipboard for Android versions 5.0 and up. + Fill + Use default setting + Automatically match + Match with… + Never match diff --git a/app/src/main/res/xml/preference.xml b/app/src/main/res/xml/preference.xml index e8ba80cc..1c977992 100644 --- a/app/src/main/res/xml/preference.xml +++ b/app/src/main/res/xml/preference.xml @@ -72,15 +72,19 @@ + + android:summary="@string/pref_autofill_apps_hint" + android:title="@string/pref_autofill_apps_title"/> + android:summary="@string/pref_autofill_default_hint" + android:title="@string/pref_autofill_default_title"/> @@ -88,6 +92,6 @@ android:defaultValue="false" android:key="clear_clipboard_20x" android:summary="@string/pref_clear_clipboard_hint" - android:title="@string/pref_clear_clipboard" /> + android:title="@string/pref_clear_clipboard_title" /> \ No newline at end of file -- cgit v1.2.3 From ce59194228dcc358168332e088eedce2a3635b89 Mon Sep 17 00:00:00 2001 From: Matthew Wong Date: Sun, 16 Aug 2015 15:01:32 -0400 Subject: More instructions/information --- .../java/com/zeapo/pwdstore/UserPreference.java | 3 +- app/src/main/res/layout/autofill_instructions.xml | 63 ++++++++++++++++++++++ app/src/main/res/layout/fragment_autofill.xml | 8 +-- app/src/main/res/values/strings.xml | 4 +- 4 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 app/src/main/res/layout/autofill_instructions.xml (limited to 'app/src/main/res/values/strings.xml') diff --git a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java index b034ba82..8f8e8d66 100644 --- a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java +++ b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java @@ -15,6 +15,7 @@ import android.preference.PreferenceManager; import android.provider.Settings; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; +import android.text.SpannableStringBuilder; import android.view.MenuItem; import android.view.accessibility.AccessibilityManager; import android.widget.Toast; @@ -204,7 +205,7 @@ public class UserPreference extends AppCompatActivity { public boolean onPreferenceClick(Preference preference) { new AlertDialog.Builder(callingActivity). setTitle(R.string.pref_autofill_enable_title). - setMessage(R.string.pref_autofill_enable_msg). + setView(R.layout.autofill_instructions). setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { diff --git a/app/src/main/res/layout/autofill_instructions.xml b/app/src/main/res/layout/autofill_instructions.xml new file mode 100644 index 00000000..82ad16d1 --- /dev/null +++ b/app/src/main/res/layout/autofill_instructions.xml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_autofill.xml b/app/src/main/res/layout/fragment_autofill.xml index af2b7017..a5b1ac90 100644 --- a/app/src/main/res/layout/fragment_autofill.xml +++ b/app/src/main/res/layout/fragment_autofill.xml @@ -3,10 +3,10 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" - android:paddingBottom="@dimen/activity_vertical_margin" - android:paddingLeft="@dimen/activity_horizontal_margin" - android:paddingRight="@dimen/activity_horizontal_margin" - android:paddingTop="@dimen/activity_vertical_margin"> + android:paddingLeft="24dp" + android:paddingRight="24dp" + android:paddingTop="20dp" + android:paddingBottom="20dp"> Recursive filtering Recursively find passwords of the current directory. Enable autofill - Tap OK to go to Accessibility settings. Once there, tap Password Store under Services then tap the switch in the top right to turn it on or off. + 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 Customize autofill settings for specific apps. Automatically match by default -- cgit v1.2.3