Work on add subkey dialog design

This commit is contained in:
Dominik Schürmann 2014-08-05 18:35:48 +02:00
parent d377d1f23d
commit 04cdd45e1a
5 changed files with 137 additions and 96 deletions

View File

@ -32,6 +32,9 @@ import android.view.View;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.DatePicker;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
@ -54,11 +57,18 @@ public class AddSubkeyDialogFragment extends DialogFragment {
private static final String ARG_WILL_BE_MASTER_KEY = "will_be_master_key"; private static final String ARG_WILL_BE_MASTER_KEY = "will_be_master_key";
private OnAlgorithmSelectedListener mAlgorithmSelectedListener; private OnAlgorithmSelectedListener mAlgorithmSelectedListener;
private CheckBox mNoExpiryCheckBox;
private DatePicker mExpiryDatePicker;
private Spinner mAlgorithmSpinner; private Spinner mAlgorithmSpinner;
private Spinner mKeySizeSpinner; private Spinner mKeySizeSpinner;
private TextView mCustomKeyTextView; private TextView mCustomKeyTextView;
private EditText mCustomKeyEditText; private EditText mCustomKeyEditText;
private TextView mCustomKeyInfoTextView; private TextView mCustomKeyInfoTextView;
private CheckBox mFlagCertify;
private CheckBox mFlagSign;
private CheckBox mFlagEncrypt;
private CheckBox mFlagAuthenticate;
public void setOnAlgorithmSelectedListener(OnAlgorithmSelectedListener listener) { public void setOnAlgorithmSelectedListener(OnAlgorithmSelectedListener listener) {
mAlgorithmSelectedListener = listener; mAlgorithmSelectedListener = listener;
@ -85,11 +95,33 @@ public class AddSubkeyDialogFragment extends DialogFragment {
CustomAlertDialogBuilder dialog = new CustomAlertDialogBuilder(context); CustomAlertDialogBuilder dialog = new CustomAlertDialogBuilder(context);
View view = mInflater.inflate(R.layout.create_key_dialog, null); View view = mInflater.inflate(R.layout.add_subkey_dialog, null);
dialog.setView(view); dialog.setView(view);
dialog.setTitle(R.string.title_create_key); dialog.setTitle(R.string.title_create_key);
mAlgorithmSpinner = (Spinner) view.findViewById(R.id.create_key_algorithm); mNoExpiryCheckBox = (CheckBox) view.findViewById(R.id.add_subkey_no_expiry);
mExpiryDatePicker = (DatePicker) view.findViewById(R.id.add_subkey_expiry_date_picker);
mAlgorithmSpinner = (Spinner) view.findViewById(R.id.add_subkey_algorithm);
mKeySizeSpinner = (Spinner) view.findViewById(R.id.add_subkey_size);
mCustomKeyTextView = (TextView) view.findViewById(R.id.add_subkey_custom_key_size_label);
mCustomKeyEditText = (EditText) view.findViewById(R.id.add_subkey_custom_key_size_input);
mCustomKeyInfoTextView = (TextView) view.findViewById(R.id.add_subkey_custom_key_size_info);
mFlagCertify = (CheckBox) view.findViewById(R.id.add_subkey_flag_certify);
mFlagSign = (CheckBox) view.findViewById(R.id.add_subkey_flag_sign);
mFlagEncrypt = (CheckBox) view.findViewById(R.id.add_subkey_flag_encrypt);
mFlagAuthenticate = (CheckBox) view.findViewById(R.id.add_subkey_flag_authenticate);
mNoExpiryCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
mExpiryDatePicker.setVisibility(View.GONE);
} else {
mExpiryDatePicker.setVisibility(View.VISIBLE);
}
}
});
ArrayList<Choice> choices = new ArrayList<Choice>(); ArrayList<Choice> choices = new ArrayList<Choice>();
choices.add(new Choice(Constants.choice.algorithm.dsa, getResources().getString( choices.add(new Choice(Constants.choice.algorithm.dsa, getResources().getString(
R.string.dsa))); R.string.dsa)));
@ -97,10 +129,8 @@ public class AddSubkeyDialogFragment extends DialogFragment {
choices.add(new Choice(Constants.choice.algorithm.elgamal, getResources().getString( choices.add(new Choice(Constants.choice.algorithm.elgamal, getResources().getString(
R.string.elgamal))); R.string.elgamal)));
} }
choices.add(new Choice(Constants.choice.algorithm.rsa, getResources().getString( choices.add(new Choice(Constants.choice.algorithm.rsa, getResources().getString(
R.string.rsa))); R.string.rsa)));
ArrayAdapter<Choice> adapter = new ArrayAdapter<Choice>(context, ArrayAdapter<Choice> adapter = new ArrayAdapter<Choice>(context,
android.R.layout.simple_spinner_item, choices); android.R.layout.simple_spinner_item, choices);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
@ -113,7 +143,7 @@ public class AddSubkeyDialogFragment extends DialogFragment {
} }
} }
mKeySizeSpinner = (Spinner) view.findViewById(R.id.create_key_size);
// dynamic ArrayAdapter must be created (instead of ArrayAdapter.getFromResource), because it's content may change // dynamic ArrayAdapter must be created (instead of ArrayAdapter.getFromResource), because it's content may change
ArrayAdapter<CharSequence> keySizeAdapter = new ArrayAdapter<CharSequence>(context, android.R.layout.simple_spinner_item, ArrayAdapter<CharSequence> keySizeAdapter = new ArrayAdapter<CharSequence>(context, android.R.layout.simple_spinner_item,
new ArrayList<CharSequence>(Arrays.asList(getResources().getStringArray(R.array.rsa_key_size_spinner_values)))); new ArrayList<CharSequence>(Arrays.asList(getResources().getStringArray(R.array.rsa_key_size_spinner_values))));
@ -121,9 +151,6 @@ public class AddSubkeyDialogFragment extends DialogFragment {
mKeySizeSpinner.setAdapter(keySizeAdapter); mKeySizeSpinner.setAdapter(keySizeAdapter);
mKeySizeSpinner.setSelection(1); // Default to 4096 for the key length mKeySizeSpinner.setSelection(1); // Default to 4096 for the key length
mCustomKeyTextView = (TextView) view.findViewById(R.id.custom_key_size_label);
mCustomKeyEditText = (EditText) view.findViewById(R.id.custom_key_size_input);
mCustomKeyInfoTextView = (TextView) view.findViewById(R.id.custom_key_size_info);
dialog.setPositiveButton(android.R.string.ok, dialog.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@ -148,7 +175,8 @@ public class AddSubkeyDialogFragment extends DialogFragment {
public void onClick(DialogInterface di, int id) { public void onClick(DialogInterface di, int id) {
di.dismiss(); di.dismiss();
} }
}); }
);
final AlertDialog alertDialog = dialog.show(); final AlertDialog alertDialog = dialog.show();

View File

@ -92,10 +92,10 @@ public class EditSubkeyExpiryDialogFragment extends DialogFragment {
alert.setTitle(R.string.expiry_date_dialog_title); alert.setTitle(R.string.expiry_date_dialog_title);
LayoutInflater inflater = activity.getLayoutInflater(); LayoutInflater inflater = activity.getLayoutInflater();
View view = inflater.inflate(R.layout.expiry_dialog, null); View view = inflater.inflate(R.layout.edit_subkey_expiry_dialog, null);
alert.setView(view); alert.setView(view);
mDatePicker = (DatePicker) view.findViewById(R.id.datePicker); mDatePicker = (DatePicker) view.findViewById(R.id.edit_subkey_expiry_date_picker);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
// will crash with IllegalArgumentException if we set a min date // will crash with IllegalArgumentException if we set a min date

View File

@ -29,8 +29,6 @@ import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Log;
import java.util.Arrays;
public class EditUserIdDialogFragment extends DialogFragment { public class EditUserIdDialogFragment extends DialogFragment {
private static final String ARG_MESSENGER = "messenger"; private static final String ARG_MESSENGER = "messenger";

View File

@ -6,10 +6,70 @@
<TableLayout <TableLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingLeft="16dp" android:paddingLeft="16dp"
android:paddingRight="16dp" android:paddingRight="16dp"
android:stretchColumns="1"> android:stretchColumns="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/key_creation_el_gamal_info" />
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/label_algorithm" />
<Spinner
android:id="@+id/add_subkey_algorithm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="4dp" />
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/label_key_size" />
<Spinner
android:id="@+id/add_subkey_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:padding="4dp" />
</TableRow>
<TextView
android:id="@+id/add_subkey_custom_key_size_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/key_size_custom_info"
android:visibility="gone" />
<EditText
android:id="@+id/add_subkey_custom_key_size_input"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="number"
android:visibility="gone" />
<TextView
android:id="@+id/add_subkey_custom_key_size_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
<TableRow> <TableRow>
<TextView <TextView
@ -20,15 +80,35 @@
android:paddingRight="10dip" android:paddingRight="10dip"
android:text="@string/label_expiry" /> android:text="@string/label_expiry" />
<Button <CheckBox
android:id="@+id/expiry" android:id="@+id/add_subkey_no_expiry"
android:layout_width="match_parent" android:checked="true"
android:layout_height="40dp" android:layout_width="wrap_content"
android:text="@string/none" android:layout_height="wrap_content"
android:background="@drawable/button_edgy" /> android:text="@string/btn_no_date" />
</TableRow> </TableRow>
<TableRow android:id="@+id/row_certify"> <TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingRight="10dip" />
<DatePicker
android:id="@+id/add_subkey_expiry_date_picker"
android:layout_gravity="center_horizontal"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:spinnersShown="true"
android:calendarViewShown="false" />
</TableRow>
<TableRow>
<TextView <TextView
android:id="@+id/label_usage" android:id="@+id/label_usage"
@ -38,32 +118,31 @@
android:paddingRight="10dip" android:paddingRight="10dip"
android:text="@string/label_usage" /> android:text="@string/label_usage" />
<CheckBox <CheckBox
android:id="@+id/chkCertify" android:id="@+id/add_subkey_flag_certify"
android:enabled="false" android:enabled="false"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/flag_certify" /> android:text="@string/flag_certify" />
</TableRow> </TableRow>
<TableRow android:id="@+id/row_sign"> <TableRow>
<TextView <TextView
android:id="@+id/label_usage2"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:paddingRight="10dip" android:paddingRight="10dip" />
android:text="@string/label_usage" />
<CheckBox <CheckBox
android:id="@+id/chkSign" android:id="@+id/add_subkey_flag_sign"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/flag_sign" /> android:text="@string/flag_sign" />
</TableRow> </TableRow>
<TableRow android:id="@+id/row_encrypt"> <TableRow>
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -72,13 +151,13 @@
android:paddingRight="10dip" /> android:paddingRight="10dip" />
<CheckBox <CheckBox
android:id="@+id/chkEncrypt" android:id="@+id/add_subkey_flag_encrypt"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/flag_encrypt" /> android:text="@string/flag_encrypt" />
</TableRow> </TableRow>
<TableRow android:id="@+id/row_authenticate"> <TableRow>
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -87,76 +166,12 @@
android:paddingRight="10dip" /> android:paddingRight="10dip" />
<CheckBox <CheckBox
android:id="@+id/chkAuthenticate" android:id="@+id/add_subkey_flag_authenticate"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/flag_authenticate" /> android:text="@string/flag_authenticate" />
</TableRow> </TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="4dp"
android:text="@string/key_creation_el_gamal_info" />
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="4dp"
android:text="@string/label_algorithm" />
<Spinner
android:id="@+id/create_key_algorithm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="4dp" />
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="4dp"
android:text="@string/label_key_size" />
<Spinner
android:id="@+id/create_key_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:padding="4dp" />
</TableRow>
<TextView
android:id="@+id/custom_key_size_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="4dp"
android:text="@string/key_size_custom_info"
android:visibility="gone" />
<EditText
android:id="@+id/custom_key_size_input"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="number"
android:visibility="gone" />
<TextView
android:id="@+id/custom_key_size_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="4dp" />
</TableLayout> </TableLayout>
</ScrollView> </ScrollView>

View File

@ -4,8 +4,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<DatePicker xmlns:android="http://schemas.android.com/apk/res/android" <DatePicker
android:id="@+id/datePicker" android:id="@+id/edit_subkey_expiry_date_picker"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"