aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Wong <wongma@protonmail.ch>2015-07-11 12:51:00 -0400
committerMatthew Wong <wongma@protonmail.ch>2015-07-11 12:51:00 -0400
commit32cf7f7813c89f7eff43712705b1d1453637a180 (patch)
tree02a6e433ec610b8a3f2af780e743ec149afd5bee
parent20da17c2d835233e7a6f30d5c2f8b23364d95ade (diff)
Set default preferences (length 20, .etc) on first use of generator, only save preferences when they've been used to generate i.e. Generate pressed
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/pwgenDialogFragment.java16
1 files changed, 8 insertions, 8 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/pwgenDialogFragment.java b/app/src/main/java/com/zeapo/pwdstore/pwgenDialogFragment.java
index 6ebf6f91..af905b5d 100644
--- a/app/src/main/java/com/zeapo/pwdstore/pwgenDialogFragment.java
+++ b/app/src/main/java/com/zeapo/pwdstore/pwgenDialogFragment.java
@@ -55,13 +55,9 @@ public class pwgenDialogFragment extends DialogFragment {
TextView textView = (TextView) view.findViewById(R.id.lengthNumber);
textView.setText(Integer.toString(prefs.getInt("length", 20)));
- textView = (TextView) view.findViewById(R.id.passwordText);
- textView.setText(pwgen.generate(getActivity().getApplicationContext()).get(0));
-
builder.setPositiveButton(getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- pwgenDialogFragment.this.setPreferences();
TextView edit = (TextView) pwgenDialogFragment.this.getActivity().findViewById(R.id.crypto_password_edit);
TextView generate = (TextView) pwgenDialogFragment.this.getDialog().findViewById(R.id.passwordText);
edit.append(generate.getText());
@@ -81,13 +77,17 @@ public class pwgenDialogFragment extends DialogFragment {
ad.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
+ setPreferences();
+ TextView textView = (TextView) view.findViewById(R.id.passwordText);
+ textView.setText(pwgen.generate(getActivity().getApplicationContext()).get(0));
+
Button b = ad.getButton(AlertDialog.BUTTON_NEUTRAL);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- pwgenDialogFragment.this.setPreferences();
- TextView textView1 = (TextView) pwgenDialogFragment.this.getDialog().findViewById(R.id.passwordText);
- textView1.setText(pwgen.generate(pwgenDialogFragment.this.getActivity().getApplicationContext()).get(0));
+ setPreferences();
+ TextView textView = (TextView) getDialog().findViewById(R.id.passwordText);
+ textView.setText(pwgen.generate(getActivity().getApplicationContext()).get(0));
}
});
}
@@ -97,7 +97,7 @@ public class pwgenDialogFragment extends DialogFragment {
private boolean setPreferences () {
ArrayList<String> preferences = new ArrayList<>();
- if (!((CheckBox)getDialog().findViewById(R.id.numerals)).isChecked()) {
+ if (!((CheckBox) getDialog().findViewById(R.id.numerals)).isChecked()) {
preferences.add("0");
}
if (((CheckBox) getDialog().findViewById(R.id.symbols)).isChecked()) {