aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Wong <wongma@protonmail.ch>2015-12-31 18:38:10 -0500
committerMatthew Wong <wongma@protonmail.ch>2015-12-31 18:38:10 -0500
commit35e30a67c49055b89633b1330a0151a176a74ef2 (patch)
tree946dd7364a8c563c0023f97e4cc8004bab5a0fef
parent963859b3476b330445e8e0d1ded0553b0a2cc18a (diff)
Comments
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.java2
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.java8
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java3
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java14
4 files changed, 17 insertions, 10 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.java b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.java
index 2ddcfa02..d40c5123 100644
--- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.java
+++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.java
@@ -66,6 +66,8 @@ public class AutofillActivity extends AppCompatActivity {
break;
case REQUEST_CODE_PICK_MATCH_WITH:
if (resultCode == RESULT_OK) {
+ // need to not only decrypt the picked password, but also
+ // update the "match with" preference
Bundle extras = getIntent().getExtras();
String packageName = extras.getString("packageName");
boolean isWeb = extras.getBoolean("isWeb");
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 0ad28a31..583b5064 100644
--- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.java
+++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.java
@@ -50,7 +50,7 @@ public class AutofillFragment extends DialogFragment {
final String appName = getArguments().getString("appName");
isWeb = getArguments().getBoolean("isWeb");
- // set the dialog icon and title or webName editText
+ // set the dialog icon and title or webURL editText
String iconPackageName;
if (!isWeb) {
iconPackageName = packageName;
@@ -174,7 +174,7 @@ public class AutofillFragment extends DialogFragment {
if (isWeb) {
packageName = ((EditText) dialog.findViewById(R.id.webURL)).getText().toString();
- // handle some errors
+ // handle some errors and don't dismiss the dialog
EditText webURL = (EditText) dialog.findViewById(R.id.webURL);
if (packageName.equals("")) {
webURL.setError("URL cannot be blank");
@@ -186,6 +186,8 @@ public class AutofillFragment extends DialogFragment {
return;
}
}
+
+ // write to preferences accordingly
RadioGroup radioGroup = (RadioGroup) dialog.findViewById(R.id.autofill_radiogroup);
switch (radioGroup.getCheckedRadioButtonId()) {
case R.id.use_default:
@@ -213,7 +215,7 @@ public class AutofillFragment extends DialogFragment {
}
editor.apply();
- // if recyclerAdapter has not loaded yet, there is no need to notify
+ // notify the recycler adapter if it is loaded
if (callingActivity.recyclerAdapter != null) {
int position;
if (!isWeb) {
diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java
index 81d0ddde..79f6565b 100644
--- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java
+++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java
@@ -28,7 +28,7 @@ import java.util.Map;
public class AutofillPreferenceActivity extends AppCompatActivity {
- RecyclerView recyclerView;
+ private RecyclerView recyclerView;
AutofillRecyclerAdapter recyclerAdapter; // let fragment have access
private RecyclerView.LayoutManager layoutManager;
@@ -51,6 +51,7 @@ public class AutofillPreferenceActivity extends AppCompatActivity {
new populateTask().execute();
+ // if the preference activity was started from the autofill dialog
recreate = false;
Bundle extras = getIntent().getExtras();
if (extras != null) {
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 e6a49bb9..ae99ba6d 100644
--- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java
+++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java
@@ -109,6 +109,8 @@ public class AutofillService extends AccessibilityService {
|| event.getSource().getPackageName().equals("com.android.browser")))) {
webViewTitle = searchWebView(getRootInActiveWindow());
+ // non-null webViewTitle means there is a webView. But still somehow
+ // getRootInActiveWindow() can be null, when switching windows
webViewURL = null;
if (webViewTitle != null && getRootInActiveWindow() != null) {
List<AccessibilityNodeInfo> nodes = getRootInActiveWindow()
@@ -263,17 +265,15 @@ public class AutofillService extends AccessibilityService {
String defValue = settings.getBoolean("autofill_default", true) ? "/first" : "/never";
SharedPreferences prefs;
String preference;
+
+ // for websites unlike apps there can be blank preference of "" which
+ // means use default, so ignore it.
if (!isWeb) {
prefs = getSharedPreferences("autofill", Context.MODE_PRIVATE);
preference = prefs.getString(packageName, defValue);
} else {
prefs = getSharedPreferences("autofill_web", Context.MODE_PRIVATE);
preference = defValue;
- }
-
- // for websites unlike apps there can be blank preference of "" which
- // means use default, so ignore it.
- if (isWeb) {
Map<String, ?> prefsMap = prefs.getAll();
for (String key : prefsMap.keySet()) {
if ((webViewURL.toLowerCase().contains(key.toLowerCase()) || key.toLowerCase().contains(webViewURL.toLowerCase()))
@@ -362,6 +362,8 @@ public class AutofillService extends AccessibilityService {
}
});
+ // populate the dialog items, always with pick + pick and match. Could
+ // make it optional (or make height a setting for the same effect)
CharSequence itemNames[] = new CharSequence[items.size() + 2];
for (int i = 0; i < items.size(); i++) {
itemNames[i] = items.get(i).getName().replace(".gpg", "");
@@ -380,7 +382,7 @@ public class AutofillService extends AccessibilityService {
intent.putExtra("pick", true);
startActivity(intent);
} else {
- lastWhichItem--;
+ lastWhichItem--; // will add one element to items, so lastWhichItem=items.size()+1
Intent intent = new Intent(AutofillService.this, AutofillActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.putExtra("pickMatchWith", true);