From dc732cb573288a136a66fd74c0b8a48718907e52 Mon Sep 17 00:00:00 2001 From: Matthew Wong Date: Tue, 25 Aug 2015 13:47:13 -0400 Subject: Generated password EditText to TextView + fix generation bug --- app/src/main/java/com/zeapo/pwdstore/pwgen/pw_rand.java | 3 ++- .../main/java/com/zeapo/pwdstore/pwgenDialogFragment.java | 12 ++++++------ app/src/main/res/layout/fragment_pwgen.xml | 7 +++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/zeapo/pwdstore/pwgen/pw_rand.java b/app/src/main/java/com/zeapo/pwdstore/pwgen/pw_rand.java index 1f4acdec..945aaf71 100644 --- a/app/src/main/java/com/zeapo/pwdstore/pwgen/pw_rand.java +++ b/app/src/main/java/com/zeapo/pwdstore/pwgen/pw_rand.java @@ -19,7 +19,7 @@ public class pw_rand { * @return the generated password */ public static String rand(int size, int pwFlags) { - String password = ""; + String password; char cha; int i, featureFlags, num; String val; @@ -36,6 +36,7 @@ public class pw_rand { bank += pwgen.SYMBOLS_STR; } do { + password = ""; featureFlags = pwFlags; i = 0; while (i < size) { diff --git a/app/src/main/java/com/zeapo/pwdstore/pwgenDialogFragment.java b/app/src/main/java/com/zeapo/pwdstore/pwgenDialogFragment.java index 019396db..7d798a81 100644 --- a/app/src/main/java/com/zeapo/pwdstore/pwgenDialogFragment.java +++ b/app/src/main/java/com/zeapo/pwdstore/pwgenDialogFragment.java @@ -61,13 +61,13 @@ public class pwgenDialogFragment extends DialogFragment { TextView textView = (TextView) view.findViewById(R.id.lengthNumber); textView.setText(Integer.toString(prefs.getInt("length", 20))); - ((EditText) view.findViewById(R.id.passwordText)).setTypeface(monoTypeface); + ((TextView) view.findViewById(R.id.passwordText)).setTypeface(monoTypeface); builder.setPositiveButton(getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { EditText edit = (EditText) callingActivity.findViewById(R.id.crypto_password_edit); - EditText generate = (EditText) view.findViewById(R.id.passwordText); + TextView generate = (TextView) view.findViewById(R.id.passwordText); edit.append(generate.getText()); } }); @@ -86,16 +86,16 @@ public class pwgenDialogFragment extends DialogFragment { @Override public void onShow(DialogInterface dialog) { setPreferences(); - EditText editText = (EditText) view.findViewById(R.id.passwordText); - editText.setText(pwgen.generate(getActivity().getApplicationContext()).get(0)); + 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) { setPreferences(); - EditText editText = (EditText) view.findViewById(R.id.passwordText); - editText.setText(pwgen.generate(callingActivity.getApplicationContext()).get(0)); + TextView textView = (TextView) view.findViewById(R.id.passwordText); + textView.setText(pwgen.generate(callingActivity.getApplicationContext()).get(0)); } }); } diff --git a/app/src/main/res/layout/fragment_pwgen.xml b/app/src/main/res/layout/fragment_pwgen.xml index 072a78a9..c670b93b 100644 --- a/app/src/main/res/layout/fragment_pwgen.xml +++ b/app/src/main/res/layout/fragment_pwgen.xml @@ -14,14 +14,13 @@ android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivityFragment"> - + android:textIsSelectable="true"/>