mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-08-31 22:35:17 +00:00
Comments
This commit is contained in:
@@ -66,6 +66,8 @@ public class AutofillActivity extends AppCompatActivity {
|
|||||||
break;
|
break;
|
||||||
case REQUEST_CODE_PICK_MATCH_WITH:
|
case REQUEST_CODE_PICK_MATCH_WITH:
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
|
// need to not only decrypt the picked password, but also
|
||||||
|
// update the "match with" preference
|
||||||
Bundle extras = getIntent().getExtras();
|
Bundle extras = getIntent().getExtras();
|
||||||
String packageName = extras.getString("packageName");
|
String packageName = extras.getString("packageName");
|
||||||
boolean isWeb = extras.getBoolean("isWeb");
|
boolean isWeb = extras.getBoolean("isWeb");
|
||||||
|
@@ -50,7 +50,7 @@ public class AutofillFragment extends DialogFragment {
|
|||||||
final String appName = getArguments().getString("appName");
|
final String appName = getArguments().getString("appName");
|
||||||
isWeb = getArguments().getBoolean("isWeb");
|
isWeb = getArguments().getBoolean("isWeb");
|
||||||
|
|
||||||
// set the dialog icon and title or webName editText
|
// set the dialog icon and title or webURL editText
|
||||||
String iconPackageName;
|
String iconPackageName;
|
||||||
if (!isWeb) {
|
if (!isWeb) {
|
||||||
iconPackageName = packageName;
|
iconPackageName = packageName;
|
||||||
@@ -174,7 +174,7 @@ public class AutofillFragment extends DialogFragment {
|
|||||||
if (isWeb) {
|
if (isWeb) {
|
||||||
packageName = ((EditText) dialog.findViewById(R.id.webURL)).getText().toString();
|
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);
|
EditText webURL = (EditText) dialog.findViewById(R.id.webURL);
|
||||||
if (packageName.equals("")) {
|
if (packageName.equals("")) {
|
||||||
webURL.setError("URL cannot be blank");
|
webURL.setError("URL cannot be blank");
|
||||||
@@ -186,6 +186,8 @@ public class AutofillFragment extends DialogFragment {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// write to preferences accordingly
|
||||||
RadioGroup radioGroup = (RadioGroup) dialog.findViewById(R.id.autofill_radiogroup);
|
RadioGroup radioGroup = (RadioGroup) dialog.findViewById(R.id.autofill_radiogroup);
|
||||||
switch (radioGroup.getCheckedRadioButtonId()) {
|
switch (radioGroup.getCheckedRadioButtonId()) {
|
||||||
case R.id.use_default:
|
case R.id.use_default:
|
||||||
@@ -213,7 +215,7 @@ public class AutofillFragment extends DialogFragment {
|
|||||||
}
|
}
|
||||||
editor.apply();
|
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) {
|
if (callingActivity.recyclerAdapter != null) {
|
||||||
int position;
|
int position;
|
||||||
if (!isWeb) {
|
if (!isWeb) {
|
||||||
|
@@ -28,7 +28,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class AutofillPreferenceActivity extends AppCompatActivity {
|
public class AutofillPreferenceActivity extends AppCompatActivity {
|
||||||
|
|
||||||
RecyclerView recyclerView;
|
private RecyclerView recyclerView;
|
||||||
AutofillRecyclerAdapter recyclerAdapter; // let fragment have access
|
AutofillRecyclerAdapter recyclerAdapter; // let fragment have access
|
||||||
private RecyclerView.LayoutManager layoutManager;
|
private RecyclerView.LayoutManager layoutManager;
|
||||||
|
|
||||||
@@ -51,6 +51,7 @@ public class AutofillPreferenceActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
new populateTask().execute();
|
new populateTask().execute();
|
||||||
|
|
||||||
|
// if the preference activity was started from the autofill dialog
|
||||||
recreate = false;
|
recreate = false;
|
||||||
Bundle extras = getIntent().getExtras();
|
Bundle extras = getIntent().getExtras();
|
||||||
if (extras != null) {
|
if (extras != null) {
|
||||||
|
@@ -109,6 +109,8 @@ public class AutofillService extends AccessibilityService {
|
|||||||
|| event.getSource().getPackageName().equals("com.android.browser")))) {
|
|| event.getSource().getPackageName().equals("com.android.browser")))) {
|
||||||
webViewTitle = searchWebView(getRootInActiveWindow());
|
webViewTitle = searchWebView(getRootInActiveWindow());
|
||||||
|
|
||||||
|
// non-null webViewTitle means there is a webView. But still somehow
|
||||||
|
// getRootInActiveWindow() can be null, when switching windows
|
||||||
webViewURL = null;
|
webViewURL = null;
|
||||||
if (webViewTitle != null && getRootInActiveWindow() != null) {
|
if (webViewTitle != null && getRootInActiveWindow() != null) {
|
||||||
List<AccessibilityNodeInfo> nodes = getRootInActiveWindow()
|
List<AccessibilityNodeInfo> nodes = getRootInActiveWindow()
|
||||||
@@ -263,17 +265,15 @@ public class AutofillService extends AccessibilityService {
|
|||||||
String defValue = settings.getBoolean("autofill_default", true) ? "/first" : "/never";
|
String defValue = settings.getBoolean("autofill_default", true) ? "/first" : "/never";
|
||||||
SharedPreferences prefs;
|
SharedPreferences prefs;
|
||||||
String preference;
|
String preference;
|
||||||
|
|
||||||
|
// for websites unlike apps there can be blank preference of "" which
|
||||||
|
// means use default, so ignore it.
|
||||||
if (!isWeb) {
|
if (!isWeb) {
|
||||||
prefs = getSharedPreferences("autofill", Context.MODE_PRIVATE);
|
prefs = getSharedPreferences("autofill", Context.MODE_PRIVATE);
|
||||||
preference = prefs.getString(packageName, defValue);
|
preference = prefs.getString(packageName, defValue);
|
||||||
} else {
|
} else {
|
||||||
prefs = getSharedPreferences("autofill_web", Context.MODE_PRIVATE);
|
prefs = getSharedPreferences("autofill_web", Context.MODE_PRIVATE);
|
||||||
preference = defValue;
|
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();
|
Map<String, ?> prefsMap = prefs.getAll();
|
||||||
for (String key : prefsMap.keySet()) {
|
for (String key : prefsMap.keySet()) {
|
||||||
if ((webViewURL.toLowerCase().contains(key.toLowerCase()) || key.toLowerCase().contains(webViewURL.toLowerCase()))
|
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];
|
CharSequence itemNames[] = new CharSequence[items.size() + 2];
|
||||||
for (int i = 0; i < items.size(); i++) {
|
for (int i = 0; i < items.size(); i++) {
|
||||||
itemNames[i] = items.get(i).getName().replace(".gpg", "");
|
itemNames[i] = items.get(i).getName().replace(".gpg", "");
|
||||||
@@ -380,7 +382,7 @@ public class AutofillService extends AccessibilityService {
|
|||||||
intent.putExtra("pick", true);
|
intent.putExtra("pick", true);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else {
|
} else {
|
||||||
lastWhichItem--;
|
lastWhichItem--; // will add one element to items, so lastWhichItem=items.size()+1
|
||||||
Intent intent = new Intent(AutofillService.this, AutofillActivity.class);
|
Intent intent = new Intent(AutofillService.this, AutofillActivity.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);
|
||||||
intent.putExtra("pickMatchWith", true);
|
intent.putExtra("pickMatchWith", true);
|
||||||
|
Reference in New Issue
Block a user