summaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/UserPreference.java51
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.java5
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.java4
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java6
-rw-r--r--app/src/main/res/layout/autofill_row_layout.xml2
-rw-r--r--app/src/main/res/layout/fragment_autofill.xml8
-rw-r--r--app/src/main/res/values-cs/strings.xml2
-rw-r--r--app/src/main/res/values/strings.xml15
-rw-r--r--app/src/main/res/xml/preference.xml14
9 files changed, 85 insertions, 22 deletions
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<AccessibilityServiceInfo> 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<AutofillRecycl
holder.view.setBackgroundResource(R.color.indigo_50);
break;
case "first":
- holder.secondary.setText("Automatically match");
+ holder.secondary.setText(R.string.autofill_apps_first);
break;
case "never":
- holder.secondary.setText("Never match");
+ holder.secondary.setText(R.string.autofill_apps_never);
break;
default:
holder.secondary.setText("Match with " + preference);
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 1e64e8c8..cd318394 100644
--- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java
+++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java
@@ -152,8 +152,8 @@ public class AutofillService extends AccessibilityService {
if (dialog == null) {
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.Theme_AppCompat_Dialog);
- builder.setNegativeButton("Cancel", null);
- builder.setPositiveButton("Fill", new DialogInterface.OnClickListener() {
+ builder.setNegativeButton(R.string.dialog_cancel, null);
+ builder.setPositiveButton(R.string.autofill_fill, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
decryptAndVerify();
@@ -161,7 +161,7 @@ public class AutofillService extends AccessibilityService {
});
builder.setNeutralButton("Settings", new DialogInterface.OnClickListener() {
@Override
- public void onClick(DialogInterface dialog, int which) {
+ public void onClick(DialogInterface dialog, int which) { //TODO make icon? gear?
// the user will have to return to the app themselves.
Intent intent = new Intent(AutofillService.this, AutofillPreferenceActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
diff --git a/app/src/main/res/layout/autofill_row_layout.xml b/app/src/main/res/layout/autofill_row_layout.xml
index 190c651f..6e51fab3 100644
--- a/app/src/main/res/layout/autofill_row_layout.xml
+++ b/app/src/main/res/layout/autofill_row_layout.xml
@@ -20,7 +20,6 @@
android:id="@+id/app_icon"
/>
-
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
@@ -41,7 +40,6 @@
android:textColor="@color/grey_600"/>
</LinearLayout>
-
</LinearLayout>
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 @@
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="Use default setting"
+ android:text="@string/autofill_apps_default"
android:id="@+id/use_default"
android:layout_gravity="center_vertical"
android:checked="false"/>
@@ -24,7 +24,7 @@
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="Automatically match"
+ android:text="@string/autofill_apps_first"
android:id="@+id/first"
android:layout_gravity="center_vertical"
android:checked="false"/>
@@ -32,7 +32,7 @@
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="Match with..."
+ android:text="@string/autofill_apps_match_ellipsis"
android:id="@+id/match"
android:layout_gravity="center_vertical"
android:checked="false"
@@ -48,7 +48,7 @@
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="Never match"
+ android:text="@string/autofill_apps_never"
android:id="@+id/never"
android:layout_gravity="center_vertical"
android:checked="false"
diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml
index 309ff2d6..8d97f2ef 100644
--- a/app/src/main/res/values-cs/strings.xml
+++ b/app/src/main/res/values-cs/strings.xml
@@ -116,8 +116,8 @@
<string name="ssh_key_error_dialog_text">Zpráva : \n</string>
<string name="pref_recursive_filter">Rekurzivní filtrování</string>
<string name="pref_recursive_filter_hint">Rekurzivní hledání hesel v aktuálním adresáři.</string>
+ <string name="pref_clear_clipboard_title">Zaplnit schránku 20krát</string>
<string name="pref_clear_clipboard_hint">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.</string>
- <string name="pref_clear_clipboard">Zaplnit schránku 20krát</string>
<!-- pwgen fragment -->
<string name="pwgen_generate">Generovat</string>
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 @@
<string name="ssh_key_error_dialog_text">Message : \n</string>
<string name="pref_recursive_filter">Recursive filtering</string>
<string name="pref_recursive_filter_hint">Recursively find passwords of the current directory.</string>
+ <string name="pref_autofill_enable_title">Enable autofill</string>
+ <string name="pref_autofill_enable_msg">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.</string>
+ <string name="pref_autofill_apps_title">Per-app settings</string>
+ <string name="pref_autofill_apps_hint">Customize autofill settings for specific apps.</string>
+ <string name="pref_autofill_default_title">Automatically match by default</string>
+ <string name="pref_autofill_default_hint">Default to \'Automatically match\' for apps without custom settings. Otherwise, \'Never match.\'</string>
+ <string name="pref_clear_clipboard_title">Clear clipboard 20 times</string>
<string name="pref_clear_clipboard_hint">Store nonsense in the clipboard 20 times instead of just once. Useful on Samsung phones that feature clipboard history.</string>
- <string name="pref_clear_clipboard">Clear clipboard 20 times</string>
<!-- pwgen fragment -->
<string name="pwgen_generate">Generate</string>
@@ -155,5 +161,10 @@
<string name="category_string">"Category: "</string>
<!-- Autofill -->
- <string name="autofill_description">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.</string>
+ <string name="autofill_description">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.</string>
+ <string name="autofill_fill">Fill</string>
+ <string name="autofill_apps_default">Use default setting</string>
+ <string name="autofill_apps_first">Automatically match</string>
+ <string name="autofill_apps_match_ellipsis">Match with…</string>
+ <string name="autofill_apps_never">Never match</string>
</resources>
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 @@
</PreferenceCategory>
<PreferenceCategory android:title="Autofill">
+ <CheckBoxPreference
+ android:defaultValue="true"
+ android:key="autofill_enable"
+ android:title="@string/pref_autofill_enable_title"/>
<Preference
android:key="autofill_apps"
- android:summary="Customize autofill settings for specific apps."
- android:title="Per-app settings"/>
+ android:summary="@string/pref_autofill_apps_hint"
+ android:title="@string/pref_autofill_apps_title"/>
<CheckBoxPreference
android:defaultValue="true"
android:key="autofill_default"
- android:summary="Default to 'Automatically match' for apps without custom settings. Otherwise, 'Never match.'"
- android:title="Automatically match by default"/>
+ android:summary="@string/pref_autofill_default_hint"
+ android:title="@string/pref_autofill_default_title"/>
</PreferenceCategory>
<PreferenceCategory android:title="Misc">
@@ -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" />
</PreferenceCategory>
</PreferenceScreen> \ No newline at end of file