This commit is contained in:
Matthew Wong 2015-12-31 18:38:10 -05:00
parent 963859b347
commit 35e30a67c4
4 changed files with 17 additions and 10 deletions

View file

@ -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");

View file

@ -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) {

View file

@ -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) {

View file

@ -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);