mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
Merge pull request #60 from bcbarnes-gmx/Issue43
Change key bit length control into a dropdown
This commit is contained in:
commit
cb2d2ba0c2
@ -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>
|
||||
|
||||
|
@ -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>
|
@ -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 -->
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user