passwordfragment changes

This commit is contained in:
Matthew Wong 2015-08-11 13:34:14 -04:00
parent 7c41795ded
commit d42c526b64
5 changed files with 33 additions and 5 deletions

View file

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

View file

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

View file

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

View file

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

View file

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