Use monospace font and add show passphrase checkbox

This commit is contained in:
Matthew Wong 2015-07-18 14:14:00 -04:00
parent 9817760c4b
commit b5faaed496
4 changed files with 33 additions and 3 deletions

View file

@ -14,12 +14,16 @@ import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.text.InputType;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -42,7 +46,7 @@ public class SshKeyGen extends AppCompatActivity {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_ssh_keygen, container, false); final View v = inflater.inflate(R.layout.fragment_ssh_keygen, container, false);
Spinner spinner = (Spinner) v.findViewById(R.id.length); Spinner spinner = (Spinner) v.findViewById(R.id.length);
Integer[] lengths = new Integer[]{2048, 4096}; Integer[] lengths = new Integer[]{2048, 4096};
@ -50,6 +54,21 @@ public class SshKeyGen extends AppCompatActivity {
android.R.layout.simple_spinner_dropdown_item, lengths); android.R.layout.simple_spinner_dropdown_item, lengths);
spinner.setAdapter(adapter); spinner.setAdapter(adapter);
CheckBox checkbox = (CheckBox) v.findViewById(R.id.show_passphrase);
checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
EditText editText = (EditText) v.findViewById(R.id.passphrase);
int selection = editText.getSelectionEnd();
if (isChecked) {
editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
} else {
editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
}
editText.setSelection(selection);
}
});
return v; return v;
} }
} }

View file

@ -21,7 +21,8 @@
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:editable="false" android:editable="false"
android:textIsSelectable="true" android:textIsSelectable="true"
android:inputType="textVisiblePassword"/> android:inputType="textVisiblePassword"
android:fontFamily="monospace"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -36,9 +36,18 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/ssh_keygen_passphrase" android:hint="@string/ssh_keygen_passphrase"
android:inputType="textVisiblePassword"/> android:inputType="textPassword"
android:fontFamily="monospace"/>
</android.support.design.widget.TextInputLayout> </android.support.design.widget.TextInputLayout>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ssh_keygen_show_passphrase"
android:id="@+id/show_passphrase"
android:checked="false"
android:layout_marginTop="8dp"/>
<android.support.design.widget.TextInputLayout <android.support.design.widget.TextInputLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View file

@ -133,6 +133,7 @@
<string name="ssh_keygen_generate">Generate</string> <string name="ssh_keygen_generate">Generate</string>
<string name="ssh_keygen_copy">Copy</string> <string name="ssh_keygen_copy">Copy</string>
<string name="ssh_keygen_tip">Provide this public key to your Git server.</string> <string name="ssh_keygen_tip">Provide this public key to your Git server.</string>
<string name="ssh_keygen_show_passphrase">Show passphrase</string>
<!-- Misc --> <!-- Misc -->
<string name="dialog_ok">OK</string> <string name="dialog_ok">OK</string>