diff options
author | Matthew Wong <wongma@protonmail.ch> | 2015-08-11 13:34:14 -0400 |
---|---|---|
committer | Matthew Wong <wongma@protonmail.ch> | 2015-08-14 17:36:50 -0400 |
commit | d42c526b648030ee251d9136b8d924395b74bb9c (patch) | |
tree | 2468dbaf5145d0f0a1dd4ce576d9d303fb7474b3 | |
parent | 7c41795ded9aff01c46cc798687e62736d2233e7 (diff) |
passwordfragment changes
5 files changed, 33 insertions, 5 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java index 72636043..1daa4f90 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java @@ -112,7 +112,11 @@ public class PasswordFragment extends Fragment{ ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); } else { - ((PasswordStore) getActivity()).decryptPassword(item); + if (getArguments().getBoolean("matchWith", false)) { + ((PasswordStore) getActivity()).matchPasswordWithApp(item); + } else { + ((PasswordStore) getActivity()).decryptPassword(item); + } } } diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java index e51ef201..39d918c8 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java @@ -289,6 +289,12 @@ public class PasswordStore extends AppCompatActivity { Bundle args = new Bundle(); args.putString("Path", PasswordRepository.getWorkTree().getAbsolutePath()); + // if the activity was started from the autofill settings, the + // intent is to match a clicked pwd with app. pass this to fragment + if (getIntent().getBooleanExtra("matchWith", false)) { + args.putBoolean("matchWith", true); + } + plist.setArguments(args); fragmentTransaction.addToBackStack("passlist"); @@ -531,4 +537,13 @@ public class PasswordStore extends AppCompatActivity { }) .show(); } + + public void matchPasswordWithApp(PasswordItem item) { + String path = item.getFile().getAbsolutePath(); + path = path.replace(PasswordRepository.getWorkTree() + "/", "").replace(".gpg", ""); + Intent data = new Intent(); + data.putExtra("path", path); + setResult(RESULT_OK, data); + finish(); + } } 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 b85dec6a..3e00edfb 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.java +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.java @@ -1,5 +1,6 @@ package com.zeapo.pwdstore.autofill; +import android.app.Activity; import android.content.DialogInterface; import android.content.Intent; import android.support.v7.app.AlertDialog; @@ -18,6 +19,7 @@ import com.zeapo.pwdstore.PasswordStore; import com.zeapo.pwdstore.R; public class AutofillFragment extends DialogFragment { + private static final int MATCH_WITH = 777; public AutofillFragment() { } @@ -57,7 +59,8 @@ public class AutofillFragment extends DialogFragment { public void onClick(View v) { // TODO figure out UI for this Intent intent = new Intent(getActivity(), PasswordStore.class); - startActivity(intent); + intent.putExtra("matchWith", true); + startActivityForResult(intent, MATCH_WITH); } }; view.findViewById(R.id.match).setOnClickListener(matchPassword); @@ -92,4 +95,12 @@ public class AutofillFragment extends DialogFragment { builder.setNegativeButton("Cancel", null); return builder.create(); } + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + if (resultCode == Activity.RESULT_OK) { + ((EditText) getDialog().findViewById(R.id.matched)).setText(data.getStringExtra("path")); + } + + } } 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 26680152..1b5e63b7 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.java +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.java @@ -1,11 +1,9 @@ package com.zeapo.pwdstore.autofill; -import android.app.DialogFragment; import android.content.Context; import android.content.SharedPreferences; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; -import android.os.Bundle; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; diff --git a/app/src/main/res/xml/preference.xml b/app/src/main/res/xml/preference.xml index 538f0387..9a42bb3e 100644 --- a/app/src/main/res/xml/preference.xml +++ b/app/src/main/res/xml/preference.xml @@ -75,7 +75,7 @@ <Preference android:key="autofill_apps" android:summary="Customize autofill settings for specific apps." - android:title="Autofill Apps"/> + android:title="Per-app settings"/> </PreferenceCategory> <PreferenceCategory android:title="Misc"> |