mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-08-31 14:25:28 +00:00
strings & enable service preference
This commit is contained in:
@@ -1,17 +1,22 @@
|
|||||||
package com.zeapo.pwdstore;
|
package com.zeapo.pwdstore;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.accessibilityservice.AccessibilityServiceInfo;
|
||||||
import android.app.DialogFragment;
|
import android.app.DialogFragment;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.CheckBoxPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.provider.Settings;
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.accessibility.AccessibilityManager;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
@@ -33,6 +38,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class UserPreference extends AppCompatActivity {
|
public class UserPreference extends AppCompatActivity {
|
||||||
@@ -192,6 +198,30 @@ public class UserPreference extends AppCompatActivity {
|
|||||||
return true;
|
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
|
@Override
|
||||||
@@ -199,6 +229,10 @@ public class UserPreference extends AppCompatActivity {
|
|||||||
super.onStart();
|
super.onStart();
|
||||||
final SharedPreferences sharedPreferences = getPreferenceManager().getSharedPreferences();
|
final SharedPreferences sharedPreferences = getPreferenceManager().getSharedPreferences();
|
||||||
findPreference("ssh_see_key").setEnabled(sharedPreferences.getBoolean("use_generated_key", false));
|
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();
|
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,
|
protected void onActivityResult(int requestCode, int resultCode,
|
||||||
Intent data) {
|
Intent data) {
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
|
@@ -68,6 +68,7 @@ public class AutofillFragment extends DialogFragment {
|
|||||||
View.OnClickListener matchPassword = new View.OnClickListener() {
|
View.OnClickListener matchPassword = new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
((RadioButton) view.findViewById(R.id.match)).toggle();
|
||||||
Intent intent = new Intent(getActivity(), PasswordStore.class);
|
Intent intent = new Intent(getActivity(), PasswordStore.class);
|
||||||
intent.putExtra("matchWith", true);
|
intent.putExtra("matchWith", true);
|
||||||
startActivityForResult(intent, MATCH_WITH);
|
startActivityForResult(intent, MATCH_WITH);
|
||||||
@@ -77,7 +78,7 @@ public class AutofillFragment extends DialogFragment {
|
|||||||
view.findViewById(R.id.matched).setOnClickListener(matchPassword);
|
view.findViewById(R.id.matched).setOnClickListener(matchPassword);
|
||||||
|
|
||||||
final SharedPreferences.Editor editor = prefs.edit();
|
final SharedPreferences.Editor editor = prefs.edit();
|
||||||
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.autofill_radiogroup);
|
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();
|
return builder.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -105,10 +105,10 @@ public class AutofillRecyclerAdapter extends RecyclerView.Adapter<AutofillRecycl
|
|||||||
holder.view.setBackgroundResource(R.color.indigo_50);
|
holder.view.setBackgroundResource(R.color.indigo_50);
|
||||||
break;
|
break;
|
||||||
case "first":
|
case "first":
|
||||||
holder.secondary.setText("Automatically match");
|
holder.secondary.setText(R.string.autofill_apps_first);
|
||||||
break;
|
break;
|
||||||
case "never":
|
case "never":
|
||||||
holder.secondary.setText("Never match");
|
holder.secondary.setText(R.string.autofill_apps_never);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
holder.secondary.setText("Match with " + preference);
|
holder.secondary.setText("Match with " + preference);
|
||||||
|
@@ -152,8 +152,8 @@ public class AutofillService extends AccessibilityService {
|
|||||||
|
|
||||||
if (dialog == null) {
|
if (dialog == null) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.Theme_AppCompat_Dialog);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.Theme_AppCompat_Dialog);
|
||||||
builder.setNegativeButton("Cancel", null);
|
builder.setNegativeButton(R.string.dialog_cancel, null);
|
||||||
builder.setPositiveButton("Fill", new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(R.string.autofill_fill, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
decryptAndVerify();
|
decryptAndVerify();
|
||||||
@@ -161,7 +161,7 @@ public class AutofillService extends AccessibilityService {
|
|||||||
});
|
});
|
||||||
builder.setNeutralButton("Settings", new DialogInterface.OnClickListener() {
|
builder.setNeutralButton("Settings", new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@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.
|
// the user will have to return to the app themselves.
|
||||||
Intent intent = new Intent(AutofillService.this, AutofillPreferenceActivity.class);
|
Intent intent = new Intent(AutofillService.this, AutofillPreferenceActivity.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
|
@@ -20,7 +20,6 @@
|
|||||||
android:id="@+id/app_icon"
|
android:id="@+id/app_icon"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -41,7 +40,6 @@
|
|||||||
android:textColor="@color/grey_600"/>
|
android:textColor="@color/grey_600"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
<RadioButton
|
<RadioButton
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Use default setting"
|
android:text="@string/autofill_apps_default"
|
||||||
android:id="@+id/use_default"
|
android:id="@+id/use_default"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:checked="false"/>
|
android:checked="false"/>
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
<RadioButton
|
<RadioButton
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Automatically match"
|
android:text="@string/autofill_apps_first"
|
||||||
android:id="@+id/first"
|
android:id="@+id/first"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:checked="false"/>
|
android:checked="false"/>
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
<RadioButton
|
<RadioButton
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Match with..."
|
android:text="@string/autofill_apps_match_ellipsis"
|
||||||
android:id="@+id/match"
|
android:id="@+id/match"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:checked="false"
|
android:checked="false"
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
<RadioButton
|
<RadioButton
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Never match"
|
android:text="@string/autofill_apps_never"
|
||||||
android:id="@+id/never"
|
android:id="@+id/never"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:checked="false"
|
android:checked="false"
|
||||||
|
@@ -116,8 +116,8 @@
|
|||||||
<string name="ssh_key_error_dialog_text">Zpráva : \n</string>
|
<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">Rekurzivní filtrování</string>
|
||||||
<string name="pref_recursive_filter_hint">Rekurzivní hledání hesel v aktuálním adresáři.</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_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 -->
|
<!-- pwgen fragment -->
|
||||||
<string name="pwgen_generate">Generovat</string>
|
<string name="pwgen_generate">Generovat</string>
|
||||||
|
@@ -117,8 +117,14 @@
|
|||||||
<string name="ssh_key_error_dialog_text">Message : \n</string>
|
<string name="ssh_key_error_dialog_text">Message : \n</string>
|
||||||
<string name="pref_recursive_filter">Recursive filtering</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_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_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 -->
|
<!-- pwgen fragment -->
|
||||||
<string name="pwgen_generate">Generate</string>
|
<string name="pwgen_generate">Generate</string>
|
||||||
@@ -155,5 +161,10 @@
|
|||||||
<string name="category_string">"Category: "</string>
|
<string name="category_string">"Category: "</string>
|
||||||
|
|
||||||
<!-- Autofill -->
|
<!-- 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>
|
</resources>
|
||||||
|
@@ -72,15 +72,19 @@
|
|||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory android:title="Autofill">
|
<PreferenceCategory android:title="Autofill">
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="autofill_enable"
|
||||||
|
android:title="@string/pref_autofill_enable_title"/>
|
||||||
<Preference
|
<Preference
|
||||||
android:key="autofill_apps"
|
android:key="autofill_apps"
|
||||||
android:summary="Customize autofill settings for specific apps."
|
android:summary="@string/pref_autofill_apps_hint"
|
||||||
android:title="Per-app settings"/>
|
android:title="@string/pref_autofill_apps_title"/>
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:key="autofill_default"
|
android:key="autofill_default"
|
||||||
android:summary="Default to 'Automatically match' for apps without custom settings. Otherwise, 'Never match.'"
|
android:summary="@string/pref_autofill_default_hint"
|
||||||
android:title="Automatically match by default"/>
|
android:title="@string/pref_autofill_default_title"/>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory android:title="Misc">
|
<PreferenceCategory android:title="Misc">
|
||||||
@@ -88,6 +92,6 @@
|
|||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="clear_clipboard_20x"
|
android:key="clear_clipboard_20x"
|
||||||
android:summary="@string/pref_clear_clipboard_hint"
|
android:summary="@string/pref_clear_clipboard_hint"
|
||||||
android:title="@string/pref_clear_clipboard" />
|
android:title="@string/pref_clear_clipboard_title" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
Reference in New Issue
Block a user