Merge remote-tracking branch 'upstream/master'

Conflicts:
	app/src/main/java/com/zeapo/pwdstore/pwgenDialogFragment.java
This commit is contained in:
Matthew Wong 2015-07-18 15:57:19 -04:00
commit 01b7b2102d
4 changed files with 24 additions and 13 deletions

View file

@ -327,17 +327,17 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
if (showPassword) { if (showPassword) {
findViewById(R.id.crypto_container).setVisibility(View.VISIBLE); 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"); String[] passContent = os.toString("UTF-8").split("\n");
((TextView) findViewById(R.id.crypto_password_show)) ((TextView) findViewById(R.id.crypto_password_show))
.setTypeface(type); .setTypeface(monoTypeface);
((TextView) findViewById(R.id.crypto_password_show)) ((TextView) findViewById(R.id.crypto_password_show))
.setText(passContent[0]); .setText(passContent[0]);
String extraContent = os.toString("UTF-8").replaceFirst(".*\n", ""); String extraContent = os.toString("UTF-8").replaceFirst(".*\n", "");
if (extraContent.length() != 0) { if (extraContent.length() != 0) {
((TextView) findViewById(R.id.crypto_extra_show)) ((TextView) findViewById(R.id.crypto_extra_show))
.setTypeface(type); .setTypeface(monoTypeface);
((TextView) findViewById(R.id.crypto_extra_show)) ((TextView) findViewById(R.id.crypto_extra_show))
.setText(extraContent); .setText(extraContent);
} }
@ -499,6 +499,9 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
decryptAndVerify(new Intent()); decryptAndVerify(new Intent());
} else if (extra.getString("Operation").equals("ENCRYPT")) { } else if (extra.getString("Operation").equals("ENCRYPT")) {
setContentView(R.layout.encrypt_layout); 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"); String cat = extra.getString("FILE_PATH");
cat = cat.replace(PasswordRepository.getWorkTree().getAbsolutePath(), ""); cat = cat.replace(PasswordRepository.getWorkTree().getAbsolutePath(), "");
cat = cat + "/"; cat = cat + "/";

View file

@ -1,16 +1,19 @@
package com.zeapo.pwdstore; package com.zeapo.pwdstore;
import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
import android.app.DialogFragment; import android.app.DialogFragment;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import com.zeapo.pwdstore.pwgen.pwgen; import com.zeapo.pwdstore.pwgen.pwgen;
@ -30,8 +33,11 @@ public class pwgenDialogFragment extends DialogFragment {
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 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); final View view = inflater.inflate(R.layout.fragment_pwgen, null);
Typeface monoTypeface = Typeface.createFromAsset(callingActivity.getAssets(), "fonts/sourcecodepro.ttf");
builder.setView(view); builder.setView(view);
SharedPreferences prefs SharedPreferences prefs
@ -55,11 +61,13 @@ public class pwgenDialogFragment extends DialogFragment {
TextView textView = (TextView) view.findViewById(R.id.lengthNumber); TextView textView = (TextView) view.findViewById(R.id.lengthNumber);
textView.setText(Integer.toString(prefs.getInt("length", 20))); 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() { builder.setPositiveButton(getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
TextView edit = (TextView) getActivity().findViewById(R.id.crypto_password_edit); EditText edit = (EditText) callingActivity.findViewById(R.id.crypto_password_edit);
TextView generate = (TextView) getDialog().findViewById(R.id.passwordText); EditText generate = (EditText) view.findViewById(R.id.passwordText);
edit.append(generate.getText()); edit.append(generate.getText());
} }
}); });
@ -78,7 +86,7 @@ public class pwgenDialogFragment extends DialogFragment {
@Override @Override
public void onShow(DialogInterface dialog) { public void onShow(DialogInterface dialog) {
setPreferences(); 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)); textView.setText(pwgen.generate(getActivity().getApplicationContext()).get(0));
Button b = ad.getButton(AlertDialog.BUTTON_NEUTRAL); Button b = ad.getButton(AlertDialog.BUTTON_NEUTRAL);
@ -86,7 +94,7 @@ public class pwgenDialogFragment extends DialogFragment {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
setPreferences(); 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)); textView.setText(pwgen.generate(getActivity().getApplicationContext()).get(0));
} }
}); });
@ -112,11 +120,11 @@ public class pwgenDialogFragment extends DialogFragment {
if (!((CheckBox) getDialog().findViewById(R.id.pronounceable)).isChecked()) { if (!((CheckBox) getDialog().findViewById(R.id.pronounceable)).isChecked()) {
preferences.add("s"); preferences.add("s");
} }
TextView textView = (TextView) getDialog().findViewById(R.id.lengthNumber); EditText textView = (EditText) getDialog().findViewById(R.id.lengthNumber);
try { try {
int length = Integer.valueOf(textView.getText().toString()); int length = Integer.valueOf(textView.getText().toString());
return pwgen.setPrefs(getActivity().getApplicationContext(), preferences, length); return pwgen.setPrefs(getActivity().getApplicationContext(), preferences, length);
} catch (NumberFormatException e) { } catch(NumberFormatException e) {
return pwgen.setPrefs(getActivity().getApplicationContext(), preferences); return pwgen.setPrefs(getActivity().getApplicationContext(), preferences);
} }
} }

View file

@ -66,12 +66,11 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:typeface="monospace" android:typeface="monospace"
android:layout_weight="1"/> android:layout_weight="1"/>
<ImageButton <Button
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:src="@drawable/ic_action_new"
android:background="@drawable/blue_rectangle"
android:id="@+id/generate_password" android:id="@+id/generate_password"
android:text="@string/pwd_generate_button"
android:onClick="handleClick"/> android:onClick="handleClick"/>
</LinearLayout> </LinearLayout>

View file

@ -149,5 +149,6 @@
<string name="show_password_pref_title">Show the password</string> <string name="show_password_pref_title">Show the password</string>
<string name="show_password_pref_summary">Control the visibility of the passwords once decrypted, this does not disable the password copy</string> <string name="show_password_pref_summary">Control the visibility of the passwords once decrypted, this does not disable the password copy</string>
<string name="toast_password_copied">Password copied into the clipboard</string> <string name="toast_password_copied">Password copied into the clipboard</string>
<string name="pwd_generate_button">Generate</string>
</resources> </resources>