From ba1ce73dbaa3a60691b223dd7f131e3c05ddc683 Mon Sep 17 00:00:00 2001 From: Mohamed Zenadi Date: Sat, 18 Jul 2015 20:11:18 +0200 Subject: use monospaced font for passwords fix EditText being cast to textview --- .../java/com/zeapo/pwdstore/crypto/PgpHandler.java | 9 ++++++--- .../java/com/zeapo/pwdstore/pwgenDialogFragment.java | 20 ++++++++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java index 9c0bc877..2d007618 100644 --- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java +++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java @@ -327,17 +327,17 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne if (showPassword) { findViewById(R.id.crypto_container).setVisibility(View.VISIBLE); - Typeface type = Typeface.createFromAsset(getAssets(), "fonts/sourcecodepro.ttf"); + Typeface monoTypeface = Typeface.createFromAsset(getAssets(), "fonts/sourcecodepro.ttf"); String[] passContent = os.toString("UTF-8").split("\n"); ((TextView) findViewById(R.id.crypto_password_show)) - .setTypeface(type); + .setTypeface(monoTypeface); ((TextView) findViewById(R.id.crypto_password_show)) .setText(passContent[0]); String extraContent = os.toString("UTF-8").replaceFirst(".*\n", ""); if (extraContent.length() != 0) { ((TextView) findViewById(R.id.crypto_extra_show)) - .setTypeface(type); + .setTypeface(monoTypeface); ((TextView) findViewById(R.id.crypto_extra_show)) .setText(extraContent); } @@ -499,6 +499,9 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne decryptAndVerify(new Intent()); } else if (extra.getString("Operation").equals("ENCRYPT")) { setContentView(R.layout.encrypt_layout); + Typeface monoTypeface = Typeface.createFromAsset(getAssets(), "fonts/sourcecodepro.ttf"); + ((EditText) findViewById(R.id.crypto_password_edit)).setTypeface(monoTypeface); + ((EditText) findViewById(R.id.crypto_extra_edit)).setTypeface(monoTypeface); String cat = extra.getString("FILE_PATH"); cat = cat.replace(PasswordRepository.getWorkTree().getAbsolutePath(), ""); cat = cat + "/"; diff --git a/app/src/main/java/com/zeapo/pwdstore/pwgenDialogFragment.java b/app/src/main/java/com/zeapo/pwdstore/pwgenDialogFragment.java index af905b5d..494aa6cd 100644 --- a/app/src/main/java/com/zeapo/pwdstore/pwgenDialogFragment.java +++ b/app/src/main/java/com/zeapo/pwdstore/pwgenDialogFragment.java @@ -1,16 +1,19 @@ package com.zeapo.pwdstore; +import android.app.Activity; import android.app.Dialog; import android.app.DialogFragment; import android.content.Context; import android.content.DialogInterface; import android.content.SharedPreferences; +import android.graphics.Typeface; import android.os.Bundle; import android.support.v7.app.AlertDialog; import android.view.LayoutInflater; import android.view.View; import android.widget.Button; import android.widget.CheckBox; +import android.widget.EditText; import android.widget.TextView; import com.zeapo.pwdstore.pwgen.pwgen; @@ -30,8 +33,11 @@ public class pwgenDialogFragment extends DialogFragment { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); - LayoutInflater inflater = getActivity().getLayoutInflater(); + final Activity callingActivity = getActivity(); + LayoutInflater inflater = callingActivity.getLayoutInflater(); final View view = inflater.inflate(R.layout.fragment_pwgen, null); + Typeface monoTypeface = Typeface.createFromAsset(callingActivity.getAssets(), "fonts/sourcecodepro.ttf"); + builder.setView(view); SharedPreferences prefs @@ -55,11 +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); + builder.setPositiveButton(getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - TextView edit = (TextView) pwgenDialogFragment.this.getActivity().findViewById(R.id.crypto_password_edit); - TextView generate = (TextView) pwgenDialogFragment.this.getDialog().findViewById(R.id.passwordText); + EditText edit = (EditText) callingActivity.findViewById(R.id.crypto_password_edit); + EditText generate = (EditText) callingActivity.findViewById(R.id.passwordText); edit.append(generate.getText()); } }); @@ -78,7 +86,7 @@ public class pwgenDialogFragment extends DialogFragment { @Override public void onShow(DialogInterface dialog) { setPreferences(); - TextView textView = (TextView) view.findViewById(R.id.passwordText); + EditText textView = (EditText) view.findViewById(R.id.passwordText); textView.setText(pwgen.generate(getActivity().getApplicationContext()).get(0)); Button b = ad.getButton(AlertDialog.BUTTON_NEUTRAL); @@ -86,7 +94,7 @@ public class pwgenDialogFragment extends DialogFragment { @Override public void onClick(View v) { setPreferences(); - TextView textView = (TextView) getDialog().findViewById(R.id.passwordText); + EditText textView = (EditText) getDialog().findViewById(R.id.passwordText); textView.setText(pwgen.generate(getActivity().getApplicationContext()).get(0)); } }); @@ -112,7 +120,7 @@ public class pwgenDialogFragment extends DialogFragment { if (!((CheckBox) getDialog().findViewById(R.id.pronounceable)).isChecked()) { preferences.add("s"); } - TextView textView = (TextView) getDialog().findViewById(R.id.lengthNumber); + EditText textView = (EditText) getDialog().findViewById(R.id.lengthNumber); try { int length = Integer.valueOf(textView.getText().toString()); return pwgen.setPrefs(getActivity().getApplicationContext(), preferences, length); -- cgit v1.2.3 From 5cd34a3427fdca5ff58408ea6ff5bd00d49173bd Mon Sep 17 00:00:00 2001 From: Mohamed Zenadi Date: Sat, 18 Jul 2015 20:11:39 +0200 Subject: use a normal button rather than an image button --- app/src/main/res/layout/encrypt_layout.xml | 5 ++--- app/src/main/res/values/strings.xml | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'app/src') diff --git a/app/src/main/res/layout/encrypt_layout.xml b/app/src/main/res/layout/encrypt_layout.xml index dcb6bf88..84fe99c3 100644 --- a/app/src/main/res/layout/encrypt_layout.xml +++ b/app/src/main/res/layout/encrypt_layout.xml @@ -66,12 +66,11 @@ android:layout_height="wrap_content" android:typeface="monospace" android:layout_weight="1"/> - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a9b03151..1f2ae926 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -136,5 +136,6 @@ Show the password Control the visibility of the passwords once decrypted, this does not disable the password copy Password copied into the clipboard + Generate -- cgit v1.2.3 From 608f61b6051d8bd03fd75628c225cccb9c0bedde Mon Sep 17 00:00:00 2001 From: Mohamed Zenadi Date: Sat, 18 Jul 2015 20:18:04 +0200 Subject: fix a typo, the generate edit text is in the dialog not in the fragment --- app/src/main/java/com/zeapo/pwdstore/pwgenDialogFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/src') diff --git a/app/src/main/java/com/zeapo/pwdstore/pwgenDialogFragment.java b/app/src/main/java/com/zeapo/pwdstore/pwgenDialogFragment.java index 494aa6cd..1a42e2ba 100644 --- a/app/src/main/java/com/zeapo/pwdstore/pwgenDialogFragment.java +++ b/app/src/main/java/com/zeapo/pwdstore/pwgenDialogFragment.java @@ -67,7 +67,7 @@ public class pwgenDialogFragment extends DialogFragment { @Override public void onClick(DialogInterface dialog, int which) { EditText edit = (EditText) callingActivity.findViewById(R.id.crypto_password_edit); - EditText generate = (EditText) callingActivity.findViewById(R.id.passwordText); + EditText generate = (EditText) view.findViewById(R.id.passwordText); edit.append(generate.getText()); } }); -- cgit v1.2.3