diff options
4 files changed, 37 insertions, 9 deletions
diff --git a/OpenPGP-Keychain/res/layout/create_key.xml b/OpenPGP-Keychain/res/layout/create_key.xml index 8858e8d80..8014dbefc 100644 --- a/OpenPGP-Keychain/res/layout/create_key.xml +++ b/OpenPGP-Keychain/res/layout/create_key.xml @@ -58,14 +58,12 @@ android:padding="4dp" android:text="@string/label_keySize" /> - <EditText + <Spinner android:id="@+id/create_key_size" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="right" - android:numeric="integer" - android:padding="4dp" - android:text="@string/default_key_bit_size" /> + android:padding="4dp" /> </TableRow> </TableLayout> diff --git a/OpenPGP-Keychain/res/values/arrays.xml b/OpenPGP-Keychain/res/values/arrays.xml index 05320c609..950a70821 100644 --- a/OpenPGP-Keychain/res/values/arrays.xml +++ b/OpenPGP-Keychain/res/values/arrays.xml @@ -43,5 +43,10 @@ <item>14400</item> <item>28800</item> </string-array> - + <string-array name="key_size_spinner_values"> + <item>@string/key_size_512</item> + <item>@string/key_size_1024</item> + <item>@string/key_size_2048</item> + <item>@string/key_size_4096</item> + </string-array> </resources>
\ No newline at end of file diff --git a/OpenPGP-Keychain/res/values/strings.xml b/OpenPGP-Keychain/res/values/strings.xml index d02cceff8..a0787a63a 100644 --- a/OpenPGP-Keychain/res/values/strings.xml +++ b/OpenPGP-Keychain/res/values/strings.xml @@ -324,11 +324,16 @@ <string name="filterInfo">Filter: \"%s\"</string> <string name="shareKeyringWith">Share keyring with…</string> + <!-- key bit length selections --> + <string name="key_size_512">512</string> + <string name="key_size_1024">1024</string> + <string name="key_size_2048">2048</string> + <string name="key_size_4096">4096</string> + <!-- misc --> <string name="fast">fast</string> <string name="slow">slow</string> <string name="very_slow">very slow</string> - <string name="default_key_bit_size">2048</string> <!-- APG 2.0 --> diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/SectionView.java index 6d94889cf..6992cc232 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -43,6 +43,8 @@ import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.ImageView; @@ -186,14 +188,32 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor } } - final EditText keySize = (EditText) view.findViewById(R.id.create_key_size); - + final Spinner keySize = (Spinner) view.findViewById(R.id.create_key_size); + ArrayAdapter<CharSequence> keySizeAdapter = ArrayAdapter.createFromResource(getContext(), R.array.key_size_spinner_values, android.R.layout.simple_spinner_item); + keySizeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + keySize.setAdapter(keySizeAdapter); + keySize.setSelection(2); // Default to 2048 for the key length dialog.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface di, int id) { di.dismiss(); try { - mNewKeySize = Integer.parseInt("" + keySize.getText()); + int nKeyIndex = keySize.getSelectedItemPosition(); + switch(nKeyIndex) + { + case 0: + mNewKeySize = 512; + break; + case 1: + mNewKeySize = 1024; + break; + case 2: + mNewKeySize = 2048; + break; + case 3: + mNewKeySize = 4096; + break; + } } catch (NumberFormatException e) { mNewKeySize = 0; } |