mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
added pass phrase cache to preferences, not used yet, but preference and about menu item now show up in every activity
This commit is contained in:
parent
363dcb62b8
commit
2c5a80a16f
@ -27,11 +27,48 @@
|
|||||||
android:paddingTop="5dip"
|
android:paddingTop="5dip"
|
||||||
android:layout_marginRight="?android:attr/scrollbarSize">
|
android:layout_marginRight="?android:attr/scrollbarSize">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/section_general"
|
||||||
|
android:text="@string/section_general"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="1dip"
|
||||||
|
android:background="?android:attr/listDivider"
|
||||||
|
android:layout_marginBottom="5dip"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/label_passPhraseCache"
|
||||||
|
android:text="@string/label_passPhraseCache"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="0dip"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:paddingRight="10dip"/>
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/passPhraseCache"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/section_defaults"
|
android:id="@+id/section_defaults"
|
||||||
android:text="@string/section_defaults"
|
android:text="@string/section_defaults"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="5dip"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
@ -61,9 +98,9 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"/>
|
android:layout_gravity="center_vertical"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
<!-- section_lowerCase: capitalized words, no punctuation -->
|
<!-- section_lowerCase: capitalized words, no punctuation -->
|
||||||
<string name="section_userIds">User IDs</string>
|
<string name="section_userIds">User IDs</string>
|
||||||
<string name="section_keys">Keys</string>
|
<string name="section_keys">Keys</string>
|
||||||
|
<string name="section_general">General</string>
|
||||||
<string name="section_defaults">Defaults</string>
|
<string name="section_defaults">Defaults</string>
|
||||||
|
|
||||||
<!-- btn_lowerCase: capitalized words, no punctuation -->
|
<!-- btn_lowerCase: capitalized words, no punctuation -->
|
||||||
@ -92,6 +93,7 @@
|
|||||||
<string name="label_hashAlgorithm">Hash Algorithm</string>
|
<string name="label_hashAlgorithm">Hash Algorithm</string>
|
||||||
<string name="label_asymmetric">Public Key</string>
|
<string name="label_asymmetric">Public Key</string>
|
||||||
<string name="label_symmetric">Pass Phrase</string>
|
<string name="label_symmetric">Pass Phrase</string>
|
||||||
|
<string name="label_passPhraseCache">Pass Phrase Cache</string>
|
||||||
|
|
||||||
<string name="noKeysSelected">Select</string>
|
<string name="noKeysSelected">Select</string>
|
||||||
<string name="oneKeySelected">1 Selected</string>
|
<string name="oneKeySelected">1 Selected</string>
|
||||||
@ -111,6 +113,12 @@
|
|||||||
<string name="choice_signOnly">Sign only</string>
|
<string name="choice_signOnly">Sign only</string>
|
||||||
<string name="choice_encryptOnly">Encrypt only</string>
|
<string name="choice_encryptOnly">Encrypt only</string>
|
||||||
<string name="choice_signAndEncrypt">Sign and Encrypt</string>
|
<string name="choice_signAndEncrypt">Sign and Encrypt</string>
|
||||||
|
<string name="choice_15secs">15 secs</string>
|
||||||
|
<string name="choice_1min">1 min</string>
|
||||||
|
<string name="choice_3mins">3 mins</string>
|
||||||
|
<string name="choice_5mins">5 mins</string>
|
||||||
|
<string name="choice_10mins">10 mins</string>
|
||||||
|
<string name="choice_untilQuit">until quit</string>
|
||||||
|
|
||||||
<string name="dsa">DSA</string>
|
<string name="dsa">DSA</string>
|
||||||
<string name="elgamal">ElGamal</string>
|
<string name="elgamal">ElGamal</string>
|
||||||
|
@ -25,12 +25,20 @@ import android.app.Activity;
|
|||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
import android.view.ContextMenu;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ContextMenu.ContextMenuInfo;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class BaseActivity extends Activity
|
public class BaseActivity extends Activity
|
||||||
@ -61,6 +69,35 @@ public class BaseActivity extends Activity
|
|||||||
Apg.initialize(this);
|
Apg.initialize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
menu.add(0, Id.menu.option.preferences, 0, R.string.menu_preferences)
|
||||||
|
.setIcon(android.R.drawable.ic_menu_preferences);
|
||||||
|
menu.add(0, Id.menu.option.about, 1, R.string.menu_about)
|
||||||
|
.setIcon(android.R.drawable.ic_menu_info_details);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case Id.menu.option.about: {
|
||||||
|
showDialog(Id.dialog.about);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
case Id.menu.option.preferences: {
|
||||||
|
startActivity(new Intent(this, PreferencesActivity.class));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Dialog onCreateDialog(int id) {
|
protected Dialog onCreateDialog(int id) {
|
||||||
|
|
||||||
@ -101,6 +138,34 @@ public class BaseActivity extends Activity
|
|||||||
mProgressDialog = null;
|
mProgressDialog = null;
|
||||||
|
|
||||||
switch (id) {
|
switch (id) {
|
||||||
|
case Id.dialog.about: {
|
||||||
|
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
||||||
|
|
||||||
|
alert.setTitle("About " + Apg.FULL_VERSION);
|
||||||
|
|
||||||
|
LayoutInflater inflater =
|
||||||
|
(LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
View layout = inflater.inflate(R.layout.info, null);
|
||||||
|
TextView message = (TextView) layout.findViewById(R.id.message);
|
||||||
|
message.setText("This is an attempt to bring OpenPGP to Android. " +
|
||||||
|
"It is far from complete, but more features are planned (see website).\n\n" +
|
||||||
|
"Feel free to send bug reports, suggestions, feature requests, feedback, " +
|
||||||
|
"photographs.\n\n" +
|
||||||
|
"mail: thi@thialfihar.org\n" +
|
||||||
|
"site: http://apg.thialfihar.org\n\n" +
|
||||||
|
"This software is provided \"as is\", without warranty of any kind.");
|
||||||
|
alert.setView(layout);
|
||||||
|
|
||||||
|
alert.setPositiveButton(android.R.string.ok,
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
BaseActivity.this.removeDialog(Id.dialog.about);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return alert.create();
|
||||||
|
}
|
||||||
|
|
||||||
case Id.dialog.pass_phrase: {
|
case Id.dialog.pass_phrase: {
|
||||||
return AskForSecretKeyPassPhrase.createDialog(this, getSecretKeyId(), this);
|
return AskForSecretKeyPassPhrase.createDialog(this, getSecretKeyId(), this);
|
||||||
}
|
}
|
||||||
@ -291,6 +356,16 @@ public class BaseActivity extends Activity
|
|||||||
return mSecretKeyId;
|
return mSecretKeyId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPassPhraseCache() {
|
||||||
|
return mPreferences.getInt(Constants.pref.pass_phrase_cache_length, 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassPhraseCache(int value) {
|
||||||
|
SharedPreferences.Editor editor = mPreferences.edit();
|
||||||
|
editor.putInt(Constants.pref.pass_phrase_cache_length, value);
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
|
|
||||||
public int getDefaultEncryptionAlgorithm() {
|
public int getDefaultEncryptionAlgorithm() {
|
||||||
return mPreferences.getInt(Constants.pref.default_encryption_algorithm,
|
return mPreferences.getInt(Constants.pref.default_encryption_algorithm,
|
||||||
PGPEncryptedData.AES_256);
|
PGPEncryptedData.AES_256);
|
||||||
|
@ -28,5 +28,6 @@ public final class Constants {
|
|||||||
public static final String default_encryption_algorithm = "defaultEncryptionAlgorithm";
|
public static final String default_encryption_algorithm = "defaultEncryptionAlgorithm";
|
||||||
public static final String default_hash_algorithm = "defaultHashAlgorithm";
|
public static final String default_hash_algorithm = "defaultHashAlgorithm";
|
||||||
public static final String default_ascii_armour = "defaultAsciiArmour";
|
public static final String default_ascii_armour = "defaultAsciiArmour";
|
||||||
|
public static final String pass_phrase_cache_length = "passPhraseCacheLength";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,8 +128,12 @@ public class EditKeyActivity extends BaseActivity implements OnClickListener {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
menu.add(0, Id.menu.option.new_pass_phrase, 0,
|
menu.add(0, Id.menu.option.new_pass_phrase, 0,
|
||||||
(havePassPhrase() ? R.string.menu_changePassPhrase : R.string.menu_setCachedPassPhrase))
|
(havePassPhrase() ? R.string.menu_changePassPhrase : R.string.menu_setPassPhrase))
|
||||||
.setIcon(android.R.drawable.ic_menu_add);
|
.setIcon(android.R.drawable.ic_menu_add);
|
||||||
|
menu.add(0, Id.menu.option.preferences, 1, R.string.menu_preferences)
|
||||||
|
.setIcon(android.R.drawable.ic_menu_preferences);
|
||||||
|
menu.add(0, Id.menu.option.about, 2, R.string.menu_about)
|
||||||
|
.setIcon(android.R.drawable.ic_menu_info_details);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,10 +146,9 @@ public class EditKeyActivity extends BaseActivity implements OnClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
break;
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -157,7 +160,7 @@ public class EditKeyActivity extends BaseActivity implements OnClickListener {
|
|||||||
if (havePassPhrase()) {
|
if (havePassPhrase()) {
|
||||||
alert.setTitle(R.string.title_changePassPhrase);
|
alert.setTitle(R.string.title_changePassPhrase);
|
||||||
} else {
|
} else {
|
||||||
alert.setTitle(R.string.title_setCachedPassPhrase);
|
alert.setTitle(R.string.title_setPassPhrase);
|
||||||
}
|
}
|
||||||
alert.setMessage(R.string.enterPassPhraseTwice);
|
alert.setMessage(R.string.enterPassPhraseTwice);
|
||||||
|
|
||||||
@ -201,10 +204,9 @@ public class EditKeyActivity extends BaseActivity implements OnClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
break;
|
return super.onCreateDialog(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.onCreateDialog(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -177,34 +177,6 @@ public class MainActivity extends BaseActivity {
|
|||||||
return alert.create();
|
return alert.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
case Id.dialog.about: {
|
|
||||||
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
|
||||||
|
|
||||||
alert.setTitle("About " + Apg.FULL_VERSION);
|
|
||||||
|
|
||||||
LayoutInflater inflater =
|
|
||||||
(LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
||||||
View layout = inflater.inflate(R.layout.info, null);
|
|
||||||
TextView message = (TextView) layout.findViewById(R.id.message);
|
|
||||||
message.setText("This is an attempt to bring OpenPGP to Android. " +
|
|
||||||
"It is far from complete, but more features are planned (see website).\n\n" +
|
|
||||||
"Feel free to send bug reports, suggestions, feature requests, feedback, " +
|
|
||||||
"photographs.\n\n" +
|
|
||||||
"mail: thi@thialfihar.org\n" +
|
|
||||||
"site: http://apg.thialfihar.org\n\n" +
|
|
||||||
"This software is provided \"as is\", without warranty of any kind.");
|
|
||||||
alert.setView(layout);
|
|
||||||
|
|
||||||
alert.setPositiveButton(android.R.string.ok,
|
|
||||||
new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
|
||||||
MainActivity.this.removeDialog(Id.dialog.about);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return alert.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
case Id.dialog.change_log: {
|
case Id.dialog.change_log: {
|
||||||
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
||||||
|
|
||||||
@ -243,11 +215,9 @@ public class MainActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
break;
|
return super.onCreateDialog(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onCreateDialog(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -273,11 +243,6 @@ public class MainActivity extends BaseActivity {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Id.menu.option.about: {
|
|
||||||
showDialog(Id.dialog.about);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
case Id.menu.option.manage_public_keys: {
|
case Id.menu.option.manage_public_keys: {
|
||||||
startActivity(new Intent(this, PublicKeyListActivity.class));
|
startActivity(new Intent(this, PublicKeyListActivity.class));
|
||||||
return true;
|
return true;
|
||||||
@ -288,16 +253,10 @@ public class MainActivity extends BaseActivity {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Id.menu.option.preferences: {
|
|
||||||
startActivity(new Intent(this, PreferencesActivity.class));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
break;
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,6 +30,7 @@ import android.widget.Spinner;
|
|||||||
import android.widget.AdapterView.OnItemSelectedListener;
|
import android.widget.AdapterView.OnItemSelectedListener;
|
||||||
|
|
||||||
public class PreferencesActivity extends BaseActivity {
|
public class PreferencesActivity extends BaseActivity {
|
||||||
|
private Spinner mPassPhraseCache = null;
|
||||||
private Spinner mEncryptionAlgorithm = null;
|
private Spinner mEncryptionAlgorithm = null;
|
||||||
private Spinner mHashAlgorithm = null;
|
private Spinner mHashAlgorithm = null;
|
||||||
private CheckBox mAsciiArmour = null;
|
private CheckBox mAsciiArmour = null;
|
||||||
@ -39,13 +40,48 @@ public class PreferencesActivity extends BaseActivity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.preferences);
|
setContentView(R.layout.preferences);
|
||||||
|
|
||||||
|
mPassPhraseCache = (Spinner) findViewById(R.id.passPhraseCache);
|
||||||
|
|
||||||
|
Choice choices[] = {
|
||||||
|
new Choice(15, getString(R.string.choice_15secs)),
|
||||||
|
new Choice(60, getString(R.string.choice_1min)),
|
||||||
|
new Choice(180, getString(R.string.choice_3mins)),
|
||||||
|
new Choice(300, getString(R.string.choice_5mins)),
|
||||||
|
new Choice(600, getString(R.string.choice_10mins)),
|
||||||
|
new Choice(0, getString(R.string.choice_untilQuit)),
|
||||||
|
};
|
||||||
|
ArrayAdapter<Choice> adapter =
|
||||||
|
new ArrayAdapter<Choice>(this, android.R.layout.simple_spinner_item, choices);
|
||||||
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
|
mPassPhraseCache.setAdapter(adapter);
|
||||||
|
|
||||||
|
int passPhraseCache = getPassPhraseCache();
|
||||||
|
for (int i = 0; i < choices.length; ++i) {
|
||||||
|
if (choices[i].getId() == passPhraseCache) {
|
||||||
|
mPassPhraseCache.setSelection(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mPassPhraseCache.setOnItemSelectedListener(new OnItemSelectedListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemSelected(AdapterView<?> adapter, View view, int index, long id) {
|
||||||
|
setPassPhraseCache(((Choice) mPassPhraseCache.getSelectedItem()).getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNothingSelected(AdapterView<?> adapter) {
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
mEncryptionAlgorithm = (Spinner) findViewById(R.id.encryptionAlgorithm);
|
mEncryptionAlgorithm = (Spinner) findViewById(R.id.encryptionAlgorithm);
|
||||||
mHashAlgorithm = (Spinner) findViewById(R.id.hashAlgorithm);
|
mHashAlgorithm = (Spinner) findViewById(R.id.hashAlgorithm);
|
||||||
mAsciiArmour = (CheckBox) findViewById(R.id.asciiArmour);
|
mAsciiArmour = (CheckBox) findViewById(R.id.asciiArmour);
|
||||||
|
|
||||||
mAsciiArmour.setChecked(getDefaultAsciiArmour());
|
mAsciiArmour.setChecked(getDefaultAsciiArmour());
|
||||||
|
|
||||||
Choice choices[] = {
|
choices = new Choice[] {
|
||||||
new Choice(PGPEncryptedData.AES_128, "AES 128"),
|
new Choice(PGPEncryptedData.AES_128, "AES 128"),
|
||||||
new Choice(PGPEncryptedData.AES_192, "AES 192"),
|
new Choice(PGPEncryptedData.AES_192, "AES 192"),
|
||||||
new Choice(PGPEncryptedData.AES_256, "AES 256"),
|
new Choice(PGPEncryptedData.AES_256, "AES 256"),
|
||||||
@ -56,13 +92,13 @@ public class PreferencesActivity extends BaseActivity {
|
|||||||
new Choice(PGPEncryptedData.TRIPLE_DES, "Triple DES"),
|
new Choice(PGPEncryptedData.TRIPLE_DES, "Triple DES"),
|
||||||
new Choice(PGPEncryptedData.IDEA, "IDEA"),
|
new Choice(PGPEncryptedData.IDEA, "IDEA"),
|
||||||
};
|
};
|
||||||
ArrayAdapter<Choice> adapter =
|
adapter = new ArrayAdapter<Choice>(this, android.R.layout.simple_spinner_item, choices);
|
||||||
new ArrayAdapter<Choice>(this, 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);
|
||||||
mEncryptionAlgorithm.setAdapter(adapter);
|
mEncryptionAlgorithm.setAdapter(adapter);
|
||||||
|
|
||||||
|
int defaultEncryptionAlgorithm = getDefaultEncryptionAlgorithm();
|
||||||
for (int i = 0; i < choices.length; ++i) {
|
for (int i = 0; i < choices.length; ++i) {
|
||||||
if (choices[i].getId() == getDefaultEncryptionAlgorithm()) {
|
if (choices[i].getId() == defaultEncryptionAlgorithm) {
|
||||||
mEncryptionAlgorithm.setSelection(i);
|
mEncryptionAlgorithm.setSelection(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -80,7 +116,7 @@ public class PreferencesActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Choice choices2[] = {
|
choices = new Choice[] {
|
||||||
new Choice(HashAlgorithmTags.MD5, "MD5"),
|
new Choice(HashAlgorithmTags.MD5, "MD5"),
|
||||||
new Choice(HashAlgorithmTags.RIPEMD160, "RIPEMD160"),
|
new Choice(HashAlgorithmTags.RIPEMD160, "RIPEMD160"),
|
||||||
new Choice(HashAlgorithmTags.SHA1, "SHA1"),
|
new Choice(HashAlgorithmTags.SHA1, "SHA1"),
|
||||||
@ -89,12 +125,13 @@ public class PreferencesActivity extends BaseActivity {
|
|||||||
new Choice(HashAlgorithmTags.SHA384, "SHA384"),
|
new Choice(HashAlgorithmTags.SHA384, "SHA384"),
|
||||||
new Choice(HashAlgorithmTags.SHA512, "SHA512"),
|
new Choice(HashAlgorithmTags.SHA512, "SHA512"),
|
||||||
};
|
};
|
||||||
adapter = new ArrayAdapter<Choice>(this, android.R.layout.simple_spinner_item, choices2);
|
adapter = new ArrayAdapter<Choice>(this, 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);
|
||||||
mHashAlgorithm.setAdapter(adapter);
|
mHashAlgorithm.setAdapter(adapter);
|
||||||
|
|
||||||
for (int i = 0; i < choices2.length; ++i) {
|
int defaultHashAlgorithm = getDefaultHashAlgorithm();
|
||||||
if (choices2[i].getId() == getDefaultHashAlgorithm()) {
|
for (int i = 0; i < choices.length; ++i) {
|
||||||
|
if (choices[i].getId() == defaultHashAlgorithm) {
|
||||||
mHashAlgorithm.setSelection(i);
|
mHashAlgorithm.setSelection(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,10 @@ public class PublicKeyListActivity extends BaseActivity {
|
|||||||
.setIcon(android.R.drawable.ic_menu_add);
|
.setIcon(android.R.drawable.ic_menu_add);
|
||||||
menu.add(0, Id.menu.option.export_keys, 1, R.string.menu_exportKeys)
|
menu.add(0, Id.menu.option.export_keys, 1, R.string.menu_exportKeys)
|
||||||
.setIcon(android.R.drawable.ic_menu_save);
|
.setIcon(android.R.drawable.ic_menu_save);
|
||||||
|
menu.add(1, Id.menu.option.preferences, 2, R.string.menu_preferences)
|
||||||
|
.setIcon(android.R.drawable.ic_menu_preferences);
|
||||||
|
menu.add(1, Id.menu.option.about, 3, R.string.menu_about)
|
||||||
|
.setIcon(android.R.drawable.ic_menu_info_details);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,10 +93,9 @@ public class PublicKeyListActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
break;
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -230,11 +233,9 @@ public class PublicKeyListActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
break;
|
return super.onCreateDialog(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onCreateDialog(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void importKeys() {
|
public void importKeys() {
|
||||||
|
@ -76,6 +76,10 @@ public class SecretKeyListActivity extends BaseActivity implements OnChildClickL
|
|||||||
.setIcon(android.R.drawable.ic_menu_save);
|
.setIcon(android.R.drawable.ic_menu_save);
|
||||||
menu.add(1, Id.menu.option.create, 2, R.string.menu_createKey)
|
menu.add(1, Id.menu.option.create, 2, R.string.menu_createKey)
|
||||||
.setIcon(android.R.drawable.ic_menu_add);
|
.setIcon(android.R.drawable.ic_menu_add);
|
||||||
|
menu.add(2, Id.menu.option.preferences, 3, R.string.menu_preferences)
|
||||||
|
.setIcon(android.R.drawable.ic_menu_preferences);
|
||||||
|
menu.add(2, Id.menu.option.about, 4, R.string.menu_about)
|
||||||
|
.setIcon(android.R.drawable.ic_menu_info_details);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,10 +102,9 @@ public class SecretKeyListActivity extends BaseActivity implements OnChildClickL
|
|||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
break;
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -259,8 +262,11 @@ public class SecretKeyListActivity extends BaseActivity implements OnChildClickL
|
|||||||
long keyId = keyRing.getSecretKey().getKeyID();
|
long keyId = keyRing.getSecretKey().getKeyID();
|
||||||
return AskForSecretKeyPassPhrase.createDialog(this, keyId, this);
|
return AskForSecretKeyPassPhrase.createDialog(this, keyId, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
return super.onCreateDialog(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return super.onCreateDialog(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user