further ui developments
This commit is contained in:
@@ -44,6 +44,10 @@ public final class Id {
|
||||
public static final int help = 0x21070010;
|
||||
public static final int key_server = 0x21070011;
|
||||
public static final int scanQRCode = 0x21070012;
|
||||
public static final int encrypt = 0x21070013;
|
||||
public static final int decrypt = 0x21070014;
|
||||
public static final int encrypt_ = 0x21070015;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.apg.ProgressDialogUpdater;
|
||||
import org.apg.Service;
|
||||
import org.apg.R;
|
||||
|
||||
import com.actionbarsherlock.app.ActionBar;
|
||||
import com.actionbarsherlock.app.SherlockActivity;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
@@ -75,8 +76,11 @@ public class BaseActivity extends SherlockActivity implements Runnable, Progress
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setDisplayShowTitleEnabled(true);
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
mPreferences = Preferences.getPreferences(this);
|
||||
setLanguage(this, mPreferences.getLanguage());
|
||||
|
||||
Apg.initialize(this);
|
||||
|
||||
@@ -97,36 +101,22 @@ public class BaseActivity extends SherlockActivity implements Runnable, Progress
|
||||
activity.startService(intent);
|
||||
}
|
||||
|
||||
@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: {
|
||||
startActivity(new Intent(this, AboutActivity.class));
|
||||
return true;
|
||||
}
|
||||
|
||||
case Id.menu.option.preferences: {
|
||||
startActivity(new Intent(this, PreferencesActivity.class));
|
||||
case android.R.id.home:
|
||||
startActivity(new Intent(this, MainActivity.class));
|
||||
return true;
|
||||
}
|
||||
|
||||
case Id.menu.option.search: {
|
||||
// TODO: needed?:
|
||||
case Id.menu.option.search:
|
||||
startSearch("", false, null, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
default: {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -422,17 +412,4 @@ public class BaseActivity extends SherlockActivity implements Runnable, Progress
|
||||
protected String getDeleteFile() {
|
||||
return mDeleteFile;
|
||||
}
|
||||
|
||||
public static void setLanguage(Context context, String language) {
|
||||
Locale locale;
|
||||
if (language == null || language.equals("")) {
|
||||
locale = Locale.getDefault();
|
||||
} else {
|
||||
locale = new Locale(language);
|
||||
}
|
||||
Configuration config = new Configuration();
|
||||
config.locale = locale;
|
||||
context.getResources().updateConfiguration(config,
|
||||
context.getResources().getDisplayMetrics());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,9 @@ import org.spongycastle.openpgp.PGPSecretKey;
|
||||
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.apg.R;
|
||||
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
@@ -113,6 +116,36 @@ public class EncryptActivity extends BaseActivity {
|
||||
|
||||
private boolean mGenerateSignature = false;
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
menu.add(1, Id.menu.option.encrypt, 0, R.string.btn_encrypt)
|
||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case Id.menu.option.key_server: {
|
||||
startActivity(new Intent(this, KeyServerQueryActivity.class));
|
||||
|
||||
return true;
|
||||
}
|
||||
case Id.menu.option.scanQRCode: {
|
||||
Intent intent = new Intent(this, ImportFromQRCodeActivity.class);
|
||||
intent.setAction(Apg.Intent.IMPORT_FROM_QR_CODE);
|
||||
startActivityForResult(intent, Id.request.import_from_qr_code);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
default: {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
@@ -87,7 +87,6 @@ public class MailListActivity extends ListActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Preferences prefs = Preferences.getPreferences(this);
|
||||
BaseActivity.setLanguage(this, prefs.getLanguage());
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.apg.Id;
|
||||
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
||||
import org.apg.R;
|
||||
|
||||
import com.actionbarsherlock.app.ActionBar;
|
||||
import com.actionbarsherlock.app.SherlockActivity;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
@@ -60,20 +61,22 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
public void encryptDecryptFileOnClick(View view) {
|
||||
Intent intent = new Intent(MainActivity.this, EncryptActivity.class);
|
||||
intent.setAction(Apg.Intent.ENCRYPT_FILE);
|
||||
startActivity(intent);
|
||||
|
||||
// intent.setAction(Apg.Intent.DECRYPT_FILE);
|
||||
}
|
||||
|
||||
public void encryptDecryptTextOnClick(View view) {
|
||||
public void encryptOnClick(View view) {
|
||||
Intent intent = new Intent(MainActivity.this, EncryptActivity.class);
|
||||
intent.setAction(Apg.Intent.ENCRYPT);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
// intent.setAction(Apg.Intent.DECRYPT);
|
||||
public void decryptOnClick(View view) {
|
||||
Intent intent = new Intent(MainActivity.this, EncryptActivity.class);
|
||||
intent.setAction(Apg.Intent.DECRYPT);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
public void scanQrcodeOnClick(View view) {
|
||||
Intent intent = new Intent(this, ImportFromQRCodeActivity.class);
|
||||
intent.setAction(Apg.Intent.IMPORT_FROM_QR_CODE);
|
||||
startActivityForResult(intent, Id.request.import_from_qr_code);
|
||||
}
|
||||
|
||||
public void helpOnClick(View view) {
|
||||
@@ -85,88 +88,92 @@ public class MainActivity extends BaseActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.main);
|
||||
|
||||
// if (!mPreferences.hasSeenHelp()) {
|
||||
// showDialog(Id.dialog.help);
|
||||
// }
|
||||
//
|
||||
// if (Apg.isReleaseVersion(this) && !mPreferences.hasSeenChangeLog(Apg.getVersion(this))) {
|
||||
// showDialog(Id.dialog.change_log);
|
||||
// }
|
||||
final ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setDisplayShowTitleEnabled(true);
|
||||
actionBar.setDisplayHomeAsUpEnabled(false);
|
||||
|
||||
// if (!mPreferences.hasSeenHelp()) {
|
||||
// showDialog(Id.dialog.help);
|
||||
// }
|
||||
//
|
||||
// if (Apg.isReleaseVersion(this) && !mPreferences.hasSeenChangeLog(Apg.getVersion(this))) {
|
||||
// showDialog(Id.dialog.change_log);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog(int id) {
|
||||
switch (id) {
|
||||
|
||||
// case Id.dialog.change_log: {
|
||||
// AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
||||
//
|
||||
// alert.setTitle("Changes " + Apg.getFullVersion(this));
|
||||
// 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("Changes:\n" + "* \n" + "\n"
|
||||
// + "WARNING: be careful editing your existing keys, as they "
|
||||
// + "WILL be stripped of certificates right now.\n" + "\n"
|
||||
// + "Also: key cross-certification is NOT supported, so signing "
|
||||
// + "with those keys will get a warning when the signature is " + "checked.\n"
|
||||
// + "\n" + "I hope APG continues to be useful to you, please send "
|
||||
// + "bug reports, feature wishes, feedback.");
|
||||
// alert.setView(layout);
|
||||
//
|
||||
// alert.setCancelable(false);
|
||||
// alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
// public void onClick(DialogInterface dialog, int id) {
|
||||
// MainActivity.this.removeDialog(Id.dialog.change_log);
|
||||
// mPreferences.setHasSeenChangeLog(Apg.getVersion(MainActivity.this), true);
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// return alert.create();
|
||||
// }
|
||||
// case Id.dialog.change_log: {
|
||||
// AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
||||
//
|
||||
// alert.setTitle("Changes " + Apg.getFullVersion(this));
|
||||
// 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("Changes:\n" + "* \n" + "\n"
|
||||
// + "WARNING: be careful editing your existing keys, as they "
|
||||
// + "WILL be stripped of certificates right now.\n" + "\n"
|
||||
// + "Also: key cross-certification is NOT supported, so signing "
|
||||
// + "with those keys will get a warning when the signature is " + "checked.\n"
|
||||
// + "\n" + "I hope APG continues to be useful to you, please send "
|
||||
// + "bug reports, feature wishes, feedback.");
|
||||
// alert.setView(layout);
|
||||
//
|
||||
// alert.setCancelable(false);
|
||||
// alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
// public void onClick(DialogInterface dialog, int id) {
|
||||
// MainActivity.this.removeDialog(Id.dialog.change_log);
|
||||
// mPreferences.setHasSeenChangeLog(Apg.getVersion(MainActivity.this), true);
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// return alert.create();
|
||||
// }
|
||||
|
||||
// case Id.dialog.help: {
|
||||
// AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
||||
//
|
||||
// alert.setTitle(R.string.title_help);
|
||||
//
|
||||
// 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(R.string.text_help);
|
||||
//
|
||||
// TransformFilter packageNames = new TransformFilter() {
|
||||
// public final String transformUrl(final Matcher match, String url) {
|
||||
// String name = match.group(1).toLowerCase();
|
||||
// if (name.equals("astro")) {
|
||||
// return "com.metago.astro";
|
||||
// } else if (name.equals("k-9 mail")) {
|
||||
// return "com.fsck.k9";
|
||||
// } else {
|
||||
// return "org.openintents.filemanager";
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// Pattern pattern = Pattern.compile("(OI File Manager|ASTRO|K-9 Mail)");
|
||||
// String scheme = "market://search?q=pname:";
|
||||
// message.setAutoLinkMask(0);
|
||||
// Linkify.addLinks(message, pattern, scheme, null, packageNames);
|
||||
//
|
||||
// alert.setView(layout);
|
||||
//
|
||||
// alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
// public void onClick(DialogInterface dialog, int id) {
|
||||
// MainActivity.this.removeDialog(Id.dialog.help);
|
||||
// mPreferences.setHasSeenHelp(true);
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// return alert.create();
|
||||
// }
|
||||
// case Id.dialog.help: {
|
||||
// AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
||||
//
|
||||
// alert.setTitle(R.string.title_help);
|
||||
//
|
||||
// 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(R.string.text_help);
|
||||
//
|
||||
// TransformFilter packageNames = new TransformFilter() {
|
||||
// public final String transformUrl(final Matcher match, String url) {
|
||||
// String name = match.group(1).toLowerCase();
|
||||
// if (name.equals("astro")) {
|
||||
// return "com.metago.astro";
|
||||
// } else if (name.equals("k-9 mail")) {
|
||||
// return "com.fsck.k9";
|
||||
// } else {
|
||||
// return "org.openintents.filemanager";
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// Pattern pattern = Pattern.compile("(OI File Manager|ASTRO|K-9 Mail)");
|
||||
// String scheme = "market://search?q=pname:";
|
||||
// message.setAutoLinkMask(0);
|
||||
// Linkify.addLinks(message, pattern, scheme, null, packageNames);
|
||||
//
|
||||
// alert.setView(layout);
|
||||
//
|
||||
// alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
// public void onClick(DialogInterface dialog, int id) {
|
||||
// MainActivity.this.removeDialog(Id.dialog.help);
|
||||
// mPreferences.setHasSeenHelp(true);
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// return alert.create();
|
||||
// }
|
||||
|
||||
default: {
|
||||
return super.onCreateDialog(id);
|
||||
@@ -176,55 +183,81 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
menu.add(0, Id.menu.option.manage_public_keys, 0, R.string.menu_managePublicKeys).setIcon(
|
||||
android.R.drawable.ic_menu_manage);
|
||||
menu.add(0, Id.menu.option.manage_secret_keys, 1, R.string.menu_manageSecretKeys).setIcon(
|
||||
android.R.drawable.ic_menu_manage);
|
||||
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.key_server, 4, R.string.menu_keyServer).setIcon(
|
||||
android.R.drawable.ic_menu_search);
|
||||
menu.add(3, Id.menu.option.about, 5, R.string.menu_about).setIcon(
|
||||
android.R.drawable.ic_menu_info_details);
|
||||
menu.add(3, Id.menu.option.help, 6, R.string.menu_help).setIcon(
|
||||
android.R.drawable.ic_menu_help);
|
||||
menu.add(0, Id.menu.option.preferences, 0, R.string.menu_preferences)
|
||||
.setIcon(R.drawable.ic_menu_settings_holo_light)
|
||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
menu.add(0, Id.menu.option.about, 1, R.string.menu_about).setShowAsAction(
|
||||
MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case Id.menu.option.create: {
|
||||
showDialog(Id.dialog.new_account);
|
||||
case Id.menu.option.about: {
|
||||
startActivity(new Intent(this, AboutActivity.class));
|
||||
return true;
|
||||
}
|
||||
|
||||
case Id.menu.option.manage_public_keys: {
|
||||
startActivity(new Intent(this, PublicKeyListActivity.class));
|
||||
return true;
|
||||
}
|
||||
|
||||
case Id.menu.option.manage_secret_keys: {
|
||||
startActivity(new Intent(this, SecretKeyListActivity.class));
|
||||
return true;
|
||||
}
|
||||
|
||||
case Id.menu.option.help: {
|
||||
showDialog(Id.dialog.help);
|
||||
return true;
|
||||
}
|
||||
|
||||
case Id.menu.option.key_server: {
|
||||
startActivity(new Intent(this, KeyServerQueryActivity.class));
|
||||
case Id.menu.option.preferences: {
|
||||
startActivity(new Intent(this, PreferencesActivity.class));
|
||||
return true;
|
||||
}
|
||||
|
||||
default: {
|
||||
return super.onOptionsItemSelected(item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// 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.key_server, 4, R.string.menu_keyServer).setIcon(
|
||||
// android.R.drawable.ic_menu_search);
|
||||
// menu.add(3, Id.menu.option.about, 5, R.string.menu_about).setIcon(
|
||||
// android.R.drawable.ic_menu_info_details);
|
||||
// menu.add(3, Id.menu.option.help, 6, R.string.menu_help).setIcon(
|
||||
// android.R.drawable.ic_menu_help);
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// switch (item.getItemId()) {
|
||||
// case Id.menu.option.create: {
|
||||
// showDialog(Id.dialog.new_account);
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// case Id.menu.option.manage_public_keys: {
|
||||
// startActivity(new Intent(this, PublicKeyListActivity.class));
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// case Id.menu.option.manage_secret_keys: {
|
||||
// startActivity(new Intent(this, SecretKeyListActivity.class));
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// case Id.menu.option.help: {
|
||||
// showDialog(Id.dialog.help);
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// case Id.menu.option.key_server: {
|
||||
// startActivity(new Intent(this, KeyServerQueryActivity.class));
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// default: {
|
||||
// return super.onOptionsItemSelected(item);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
|
||||
@@ -29,6 +29,10 @@ import org.spongycastle.bcpg.HashAlgorithmTags;
|
||||
import org.spongycastle.openpgp.PGPEncryptedData;
|
||||
import org.apg.R;
|
||||
|
||||
import com.actionbarsherlock.app.ActionBar;
|
||||
import com.actionbarsherlock.app.SherlockPreferenceActivity;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
@@ -41,7 +45,7 @@ import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Vector;
|
||||
|
||||
public class PreferencesActivity extends PreferenceActivity {
|
||||
public class PreferencesActivity extends SherlockPreferenceActivity {
|
||||
private ListPreference mLanguage = null;
|
||||
private IntegerListPreference mPassPhraseCacheTtl = null;
|
||||
private IntegerListPreference mEncryptionAlgorithm = null;
|
||||
@@ -56,66 +60,35 @@ public class PreferencesActivity extends PreferenceActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
mPreferences = Preferences.getPreferences(this);
|
||||
BaseActivity.setLanguage(this, mPreferences.getLanguage());
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
addPreferencesFromResource(R.xml.apg_preferences);
|
||||
final ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setDisplayShowTitleEnabled(true);
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
mLanguage = (ListPreference) findPreference(Constants.pref.LANGUAGE);
|
||||
Vector<CharSequence> entryVector = new Vector<CharSequence>(Arrays.asList(mLanguage.getEntries()));
|
||||
Vector<CharSequence> entryValueVector = new Vector<CharSequence>(Arrays.asList(mLanguage.getEntryValues()));
|
||||
String supportedLanguages[] = getResources().getStringArray(R.array.supported_languages);
|
||||
HashSet<String> supportedLanguageSet = new HashSet<String>(Arrays.asList(supportedLanguages));
|
||||
for (int i = entryVector.size() - 1; i > -1; --i)
|
||||
{
|
||||
if (!supportedLanguageSet.contains(entryValueVector.get(i)))
|
||||
{
|
||||
entryVector.remove(i);
|
||||
entryValueVector.remove(i);
|
||||
}
|
||||
}
|
||||
CharSequence dummy[] = new CharSequence[0];
|
||||
mLanguage.setEntries(entryVector.toArray(dummy));
|
||||
mLanguage.setEntryValues(entryValueVector.toArray(dummy));
|
||||
mLanguage.setValue(mPreferences.getLanguage());
|
||||
mLanguage.setSummary(mLanguage.getEntry());
|
||||
mLanguage.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
|
||||
{
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue)
|
||||
{
|
||||
mLanguage.setValue(newValue.toString());
|
||||
mLanguage.setSummary(mLanguage.getEntry());
|
||||
mPreferences.setLanguage(newValue.toString());
|
||||
return false;
|
||||
}
|
||||
});
|
||||
addPreferencesFromResource(R.xml.apg_preferences);
|
||||
|
||||
mPassPhraseCacheTtl = (IntegerListPreference) findPreference(Constants.pref.PASS_PHRASE_CACHE_TTL);
|
||||
mPassPhraseCacheTtl.setValue("" + mPreferences.getPassPhraseCacheTtl());
|
||||
mPassPhraseCacheTtl.setSummary(mPassPhraseCacheTtl.getEntry());
|
||||
mPassPhraseCacheTtl.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
|
||||
{
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue)
|
||||
{
|
||||
mPassPhraseCacheTtl.setValue(newValue.toString());
|
||||
mPassPhraseCacheTtl.setSummary(mPassPhraseCacheTtl.getEntry());
|
||||
mPreferences.setPassPhraseCacheTtl(Integer.parseInt(newValue.toString()));
|
||||
BaseActivity.startCacheService(PreferencesActivity.this, mPreferences);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
mPassPhraseCacheTtl
|
||||
.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
mPassPhraseCacheTtl.setValue(newValue.toString());
|
||||
mPassPhraseCacheTtl.setSummary(mPassPhraseCacheTtl.getEntry());
|
||||
mPreferences.setPassPhraseCacheTtl(Integer.parseInt(newValue.toString()));
|
||||
BaseActivity.startCacheService(PreferencesActivity.this, mPreferences);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
mEncryptionAlgorithm = (IntegerListPreference) findPreference(Constants.pref.DEFAULT_ENCRYPTION_ALGORITHM);
|
||||
int valueIds[] = {
|
||||
PGPEncryptedData.AES_128, PGPEncryptedData.AES_192, PGPEncryptedData.AES_256,
|
||||
PGPEncryptedData.BLOWFISH, PGPEncryptedData.TWOFISH, PGPEncryptedData.CAST5,
|
||||
PGPEncryptedData.DES, PGPEncryptedData.TRIPLE_DES, PGPEncryptedData.IDEA,
|
||||
};
|
||||
String entries[] = {
|
||||
"AES-128", "AES-192", "AES-256",
|
||||
"Blowfish", "Twofish", "CAST5",
|
||||
"DES", "Triple DES", "IDEA",
|
||||
};
|
||||
int valueIds[] = { PGPEncryptedData.AES_128, PGPEncryptedData.AES_192,
|
||||
PGPEncryptedData.AES_256, PGPEncryptedData.BLOWFISH, PGPEncryptedData.TWOFISH,
|
||||
PGPEncryptedData.CAST5, PGPEncryptedData.DES, PGPEncryptedData.TRIPLE_DES,
|
||||
PGPEncryptedData.IDEA, };
|
||||
String entries[] = { "AES-128", "AES-192", "AES-256", "Blowfish", "Twofish", "CAST5",
|
||||
"DES", "Triple DES", "IDEA", };
|
||||
String values[] = new String[valueIds.length];
|
||||
for (int i = 0; i < values.length; ++i) {
|
||||
values[i] = "" + valueIds[i];
|
||||
@@ -124,28 +97,23 @@ public class PreferencesActivity extends PreferenceActivity {
|
||||
mEncryptionAlgorithm.setEntryValues(values);
|
||||
mEncryptionAlgorithm.setValue("" + mPreferences.getDefaultEncryptionAlgorithm());
|
||||
mEncryptionAlgorithm.setSummary(mEncryptionAlgorithm.getEntry());
|
||||
mEncryptionAlgorithm.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
|
||||
{
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue)
|
||||
{
|
||||
mEncryptionAlgorithm.setValue(newValue.toString());
|
||||
mEncryptionAlgorithm.setSummary(mEncryptionAlgorithm.getEntry());
|
||||
mPreferences.setDefaultEncryptionAlgorithm(Integer.parseInt(newValue.toString()));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
mEncryptionAlgorithm
|
||||
.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
mEncryptionAlgorithm.setValue(newValue.toString());
|
||||
mEncryptionAlgorithm.setSummary(mEncryptionAlgorithm.getEntry());
|
||||
mPreferences.setDefaultEncryptionAlgorithm(Integer.parseInt(newValue
|
||||
.toString()));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
mHashAlgorithm = (IntegerListPreference) findPreference(Constants.pref.DEFAULT_HASH_ALGORITHM);
|
||||
valueIds = new int[] {
|
||||
HashAlgorithmTags.MD5, HashAlgorithmTags.RIPEMD160, HashAlgorithmTags.SHA1,
|
||||
HashAlgorithmTags.SHA224, HashAlgorithmTags.SHA256, HashAlgorithmTags.SHA384,
|
||||
HashAlgorithmTags.SHA512,
|
||||
};
|
||||
entries = new String[] {
|
||||
"MD5", "RIPEMD-160", "SHA-1",
|
||||
"SHA-224", "SHA-256", "SHA-384",
|
||||
"SHA-512",
|
||||
};
|
||||
valueIds = new int[] { HashAlgorithmTags.MD5, HashAlgorithmTags.RIPEMD160,
|
||||
HashAlgorithmTags.SHA1, HashAlgorithmTags.SHA224, HashAlgorithmTags.SHA256,
|
||||
HashAlgorithmTags.SHA384, HashAlgorithmTags.SHA512, };
|
||||
entries = new String[] { "MD5", "RIPEMD-160", "SHA-1", "SHA-224", "SHA-256", "SHA-384",
|
||||
"SHA-512", };
|
||||
values = new String[valueIds.length];
|
||||
for (int i = 0; i < values.length; ++i) {
|
||||
values[i] = "" + valueIds[i];
|
||||
@@ -154,10 +122,8 @@ public class PreferencesActivity extends PreferenceActivity {
|
||||
mHashAlgorithm.setEntryValues(values);
|
||||
mHashAlgorithm.setValue("" + mPreferences.getDefaultHashAlgorithm());
|
||||
mHashAlgorithm.setSummary(mHashAlgorithm.getEntry());
|
||||
mHashAlgorithm.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
|
||||
{
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue)
|
||||
{
|
||||
mHashAlgorithm.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
mHashAlgorithm.setValue(newValue.toString());
|
||||
mHashAlgorithm.setSummary(mHashAlgorithm.getEntry());
|
||||
mPreferences.setDefaultHashAlgorithm(Integer.parseInt(newValue.toString()));
|
||||
@@ -166,18 +132,13 @@ public class PreferencesActivity extends PreferenceActivity {
|
||||
});
|
||||
|
||||
mMessageCompression = (IntegerListPreference) findPreference(Constants.pref.DEFAULT_MESSAGE_COMPRESSION);
|
||||
valueIds = new int[] {
|
||||
Id.choice.compression.none,
|
||||
Id.choice.compression.zip,
|
||||
Id.choice.compression.zlib,
|
||||
Id.choice.compression.bzip2,
|
||||
};
|
||||
valueIds = new int[] { Id.choice.compression.none, Id.choice.compression.zip,
|
||||
Id.choice.compression.zlib, Id.choice.compression.bzip2, };
|
||||
entries = new String[] {
|
||||
getString(R.string.choice_none) + " (" + getString(R.string.fast) + ")",
|
||||
"ZIP (" + getString(R.string.fast) + ")",
|
||||
"ZLIB (" + getString(R.string.fast) + ")",
|
||||
"BZIP2 (" + getString(R.string.very_slow) + ")",
|
||||
};
|
||||
"BZIP2 (" + getString(R.string.very_slow) + ")", };
|
||||
values = new String[valueIds.length];
|
||||
for (int i = 0; i < values.length; ++i) {
|
||||
values[i] = "" + valueIds[i];
|
||||
@@ -186,26 +147,24 @@ public class PreferencesActivity extends PreferenceActivity {
|
||||
mMessageCompression.setEntryValues(values);
|
||||
mMessageCompression.setValue("" + mPreferences.getDefaultMessageCompression());
|
||||
mMessageCompression.setSummary(mMessageCompression.getEntry());
|
||||
mMessageCompression.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
|
||||
{
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue)
|
||||
{
|
||||
mMessageCompression.setValue(newValue.toString());
|
||||
mMessageCompression.setSummary(mMessageCompression.getEntry());
|
||||
mPreferences.setDefaultMessageCompression(Integer.parseInt(newValue.toString()));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
mMessageCompression
|
||||
.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
mMessageCompression.setValue(newValue.toString());
|
||||
mMessageCompression.setSummary(mMessageCompression.getEntry());
|
||||
mPreferences.setDefaultMessageCompression(Integer.parseInt(newValue
|
||||
.toString()));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
mFileCompression = (IntegerListPreference) findPreference(Constants.pref.DEFAULT_FILE_COMPRESSION);
|
||||
mFileCompression.setEntries(entries);
|
||||
mFileCompression.setEntryValues(values);
|
||||
mFileCompression.setValue("" + mPreferences.getDefaultFileCompression());
|
||||
mFileCompression.setSummary(mFileCompression.getEntry());
|
||||
mFileCompression.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
|
||||
{
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue)
|
||||
{
|
||||
mFileCompression.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
mFileCompression.setValue(newValue.toString());
|
||||
mFileCompression.setSummary(mFileCompression.getEntry());
|
||||
mPreferences.setDefaultFileCompression(Integer.parseInt(newValue.toString()));
|
||||
@@ -215,60 +174,74 @@ public class PreferencesActivity extends PreferenceActivity {
|
||||
|
||||
mAsciiArmour = (CheckBoxPreference) findPreference(Constants.pref.DEFAULT_ASCII_ARMOUR);
|
||||
mAsciiArmour.setChecked(mPreferences.getDefaultAsciiArmour());
|
||||
mAsciiArmour.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
|
||||
{
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue)
|
||||
{
|
||||
mAsciiArmour.setChecked((Boolean)newValue);
|
||||
mPreferences.setDefaultAsciiArmour((Boolean)newValue);
|
||||
mAsciiArmour.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
mAsciiArmour.setChecked((Boolean) newValue);
|
||||
mPreferences.setDefaultAsciiArmour((Boolean) newValue);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
mForceV3Signatures = (CheckBoxPreference) findPreference(Constants.pref.FORCE_V3_SIGNATURES);
|
||||
mForceV3Signatures.setChecked(mPreferences.getForceV3Signatures());
|
||||
mForceV3Signatures.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
|
||||
{
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue)
|
||||
{
|
||||
mForceV3Signatures.setChecked((Boolean)newValue);
|
||||
mPreferences.setForceV3Signatures((Boolean)newValue);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
mForceV3Signatures
|
||||
.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
mForceV3Signatures.setChecked((Boolean) newValue);
|
||||
mPreferences.setForceV3Signatures((Boolean) newValue);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
mKeyServerPreference = (PreferenceScreen) findPreference(Constants.pref.KEY_SERVERS);
|
||||
String servers[] = mPreferences.getKeyServers();
|
||||
mKeyServerPreference.setSummary(getResources().getString(R.string.nKeyServers, servers.length));
|
||||
mKeyServerPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Intent intent = new Intent(PreferencesActivity.this,
|
||||
KeyServerPreferenceActivity.class);
|
||||
intent.putExtra(Apg.EXTRA_KEY_SERVERS, mPreferences.getKeyServers());
|
||||
startActivityForResult(intent, Id.request.key_server_preference);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
mKeyServerPreference.setSummary(getResources().getString(R.string.nKeyServers,
|
||||
servers.length));
|
||||
mKeyServerPreference
|
||||
.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Intent intent = new Intent(PreferencesActivity.this,
|
||||
KeyServerPreferenceActivity.class);
|
||||
intent.putExtra(Apg.EXTRA_KEY_SERVERS, mPreferences.getKeyServers());
|
||||
startActivityForResult(intent, Id.request.key_server_preference);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
switch (requestCode) {
|
||||
case Id.request.key_server_preference: {
|
||||
if (resultCode == RESULT_CANCELED || data == null) {
|
||||
return;
|
||||
}
|
||||
String servers[] = data.getStringArrayExtra(Apg.EXTRA_KEY_SERVERS);
|
||||
mPreferences.setKeyServers(servers);
|
||||
mKeyServerPreference.setSummary(getResources().getString(R.string.nKeyServers, servers.length));
|
||||
break;
|
||||
case Id.request.key_server_preference: {
|
||||
if (resultCode == RESULT_CANCELED || data == null) {
|
||||
return;
|
||||
}
|
||||
String servers[] = data.getStringArrayExtra(Apg.EXTRA_KEY_SERVERS);
|
||||
mPreferences.setKeyServers(servers);
|
||||
mKeyServerPreference.setSummary(getResources().getString(R.string.nKeyServers,
|
||||
servers.length));
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
|
||||
case android.R.id.home:
|
||||
startActivity(new Intent(this, MainActivity.class));
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.apg.Id.menu.option;
|
||||
import org.spongycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.apg.R;
|
||||
|
||||
import com.actionbarsherlock.ActionBarSherlock;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
@@ -48,21 +49,49 @@ public class PublicKeyListActivity extends KeyListActivity {
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
menu.add(0, Id.menu.option.import_keys, 0, R.string.menu_importKeys).setIcon(
|
||||
android.R.drawable.ic_menu_add);
|
||||
menu.add(0, Id.menu.option.export_keys, 1, R.string.menu_exportKeys).setIcon(
|
||||
android.R.drawable.ic_menu_save);
|
||||
menu.add(1, Id.menu.option.search, 2, R.string.menu_search).setIcon(
|
||||
android.R.drawable.ic_menu_search);
|
||||
menu.add(1, Id.menu.option.preferences, 3, R.string.menu_preferences).setIcon(
|
||||
android.R.drawable.ic_menu_preferences);
|
||||
menu.add(1, Id.menu.option.about, 4, R.string.menu_about).setIcon(
|
||||
android.R.drawable.ic_menu_info_details);
|
||||
menu.add(1, Id.menu.option.scanQRCode, 5, R.string.menu_scanQRCode).setIcon(
|
||||
android.R.drawable.ic_menu_add);
|
||||
menu.add(1, Id.menu.option.key_server, 0, R.string.menu_keyServer)
|
||||
.setIcon(R.drawable.ic_menu_find_holo_light)
|
||||
.setShowAsAction(
|
||||
MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
menu.add(1, Id.menu.option.scanQRCode, 1, R.string.menu_scanQRCode)
|
||||
// .setIcon(R.drawable.ic_suggestions_add)
|
||||
.setShowAsAction(
|
||||
MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
menu.add(0, Id.menu.option.import_keys, 2, R.string.menu_importKeys)
|
||||
// .setIcon(R.drawable.ic_suggestions_add)
|
||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
menu.add(0, Id.menu.option.export_keys, 3, R.string.menu_exportKeys)
|
||||
// .setIcon(R.drawable.ic_menu_share_holo_light)
|
||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
menu.add(1, Id.menu.option.search, 4, R.string.menu_search)
|
||||
.setIcon(R.drawable.ic_menu_search_holo_light)
|
||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case Id.menu.option.key_server: {
|
||||
startActivity(new Intent(this, KeyServerQueryActivity.class));
|
||||
|
||||
return true;
|
||||
}
|
||||
case Id.menu.option.scanQRCode: {
|
||||
Intent intent = new Intent(this, ImportFromQRCodeActivity.class);
|
||||
intent.setAction(Apg.Intent.IMPORT_FROM_QR_CODE);
|
||||
startActivityForResult(intent, Id.request.import_from_qr_code);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
default: {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
@@ -150,23 +179,6 @@ public class PublicKeyListActivity extends KeyListActivity {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case Id.menu.option.scanQRCode: {
|
||||
Intent intent = new Intent(this, ImportFromQRCodeActivity.class);
|
||||
intent.setAction(Apg.Intent.IMPORT_FROM_QR_CODE);
|
||||
startActivityForResult(intent, Id.request.import_from_qr_code);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
default: {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
switch (requestCode) {
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.apg.Id.type;
|
||||
import org.apg.Id.menu.option;
|
||||
import org.apg.R;
|
||||
|
||||
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
@@ -55,40 +54,41 @@ public class SecretKeyListActivity extends KeyListActivity implements OnChildCli
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
menu.add(0, Id.menu.option.import_keys, 0, R.string.menu_importKeys)
|
||||
.setIcon(android.R.drawable.ic_menu_add);
|
||||
menu.add(0, Id.menu.option.export_keys, 1, R.string.menu_exportKeys)
|
||||
.setIcon(android.R.drawable.ic_menu_save);
|
||||
menu.add(1, Id.menu.option.create, 2, R.string.menu_createKey)
|
||||
.setIcon(android.R.drawable.ic_menu_add);
|
||||
menu.add(1, Id.menu.option.create, 0, R.string.menu_createKey)
|
||||
.setIcon(R.drawable.ic_suggestions_add)
|
||||
.setShowAsAction(
|
||||
MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
menu.add(0, Id.menu.option.import_keys, 1, R.string.menu_importKeys)
|
||||
// .setIcon(R.drawable.ic_menu_find_holo_light)
|
||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
menu.add(0, Id.menu.option.export_keys, 2, R.string.menu_exportKeys)
|
||||
// .setIcon(R.drawable.ic_menu_find_holo_light)
|
||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
|
||||
menu.add(3, Id.menu.option.search, 3, R.string.menu_search)
|
||||
.setIcon(android.R.drawable.ic_menu_search);
|
||||
menu.add(3, Id.menu.option.preferences, 4, R.string.menu_preferences)
|
||||
.setIcon(android.R.drawable.ic_menu_preferences);
|
||||
menu.add(3, Id.menu.option.about, 5, R.string.menu_about)
|
||||
.setIcon(android.R.drawable.ic_menu_info_details);
|
||||
.setIcon(R.drawable.ic_menu_search_holo_light)
|
||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case Id.menu.option.create: {
|
||||
createKey();
|
||||
return true;
|
||||
}
|
||||
case Id.menu.option.create: {
|
||||
createKey();
|
||||
return true;
|
||||
}
|
||||
|
||||
default: {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
default: {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
ExpandableListView.ExpandableListContextMenuInfo info =
|
||||
(ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
|
||||
ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
|
||||
int type = ExpandableListView.getPackedPositionType(info.packedPosition);
|
||||
|
||||
if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
|
||||
@@ -111,29 +111,31 @@ public class SecretKeyListActivity extends KeyListActivity implements OnChildCli
|
||||
}
|
||||
|
||||
switch (menuItem.getItemId()) {
|
||||
case Id.menu.edit: {
|
||||
mSelectedItem = groupPosition;
|
||||
checkPassPhraseAndEdit();
|
||||
return true;
|
||||
}
|
||||
case Id.menu.edit: {
|
||||
mSelectedItem = groupPosition;
|
||||
checkPassPhraseAndEdit();
|
||||
return true;
|
||||
}
|
||||
|
||||
case Id.menu.share: {
|
||||
mSelectedItem = groupPosition;
|
||||
|
||||
long keyId = ((KeyListAdapter) mList.getExpandableListAdapter()).getGroupId(mSelectedItem);
|
||||
String msg = keyId + "," + Apg.getFingerPrint(keyId);;
|
||||
|
||||
new IntentIntegrator(this).shareText(msg);
|
||||
}
|
||||
case Id.menu.share: {
|
||||
mSelectedItem = groupPosition;
|
||||
|
||||
default: {
|
||||
return super.onContextItemSelected(menuItem);
|
||||
}
|
||||
long keyId = ((KeyListAdapter) mList.getExpandableListAdapter())
|
||||
.getGroupId(mSelectedItem);
|
||||
String msg = keyId + "," + Apg.getFingerPrint(keyId);
|
||||
;
|
||||
|
||||
new IntentIntegrator(this).shareText(msg);
|
||||
}
|
||||
|
||||
default: {
|
||||
return super.onContextItemSelected(menuItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,
|
||||
int childPosition, long id) {
|
||||
int childPosition, long id) {
|
||||
mSelectedItem = groupPosition;
|
||||
checkPassPhraseAndEdit();
|
||||
return true;
|
||||
@@ -142,14 +144,15 @@ public class SecretKeyListActivity extends KeyListActivity implements OnChildCli
|
||||
@Override
|
||||
protected Dialog onCreateDialog(int id) {
|
||||
switch (id) {
|
||||
case Id.dialog.pass_phrase: {
|
||||
long keyId = ((KeyListAdapter) mList.getExpandableListAdapter()).getGroupId(mSelectedItem);
|
||||
return AskForSecretKeyPassPhrase.createDialog(this, keyId, this);
|
||||
}
|
||||
case Id.dialog.pass_phrase: {
|
||||
long keyId = ((KeyListAdapter) mList.getExpandableListAdapter())
|
||||
.getGroupId(mSelectedItem);
|
||||
return AskForSecretKeyPassPhrase.createDialog(this, keyId, this);
|
||||
}
|
||||
|
||||
default: {
|
||||
return super.onCreateDialog(id);
|
||||
}
|
||||
default: {
|
||||
return super.onCreateDialog(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,17 +190,17 @@ public class SecretKeyListActivity extends KeyListActivity implements OnChildCli
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
switch (requestCode) {
|
||||
case Id.message.create_key: // intentionally no break
|
||||
case Id.message.edit_key: {
|
||||
if (resultCode == RESULT_OK) {
|
||||
refreshList();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
break;
|
||||
case Id.message.create_key: // intentionally no break
|
||||
case Id.message.edit_key: {
|
||||
if (resultCode == RESULT_OK) {
|
||||
refreshList();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
@@ -27,7 +27,6 @@ import android.view.ViewGroup;
|
||||
*/
|
||||
public class DashboardLayout extends ViewGroup {
|
||||
private static final int UNEVEN_GRID_PENALTY_MULTIPLIER = 10;
|
||||
private static final int OVERLAP_PENALTY_MULTIPLIER = 10;
|
||||
|
||||
private int mMaxChildWidth = 0;
|
||||
private int mMaxChildHeight = 0;
|
||||
@@ -129,12 +128,8 @@ public class DashboardLayout extends ViewGroup {
|
||||
spaceDifference = Math.abs(vSpace - hSpace);
|
||||
if (rows * cols != visibleCount) {
|
||||
spaceDifference *= UNEVEN_GRID_PENALTY_MULTIPLIER;
|
||||
}
|
||||
if (hSpace < 0) {
|
||||
spaceDifference *= OVERLAP_PENALTY_MULTIPLIER;
|
||||
}
|
||||
if (vSpace < 0) {
|
||||
spaceDifference *= OVERLAP_PENALTY_MULTIPLIER;
|
||||
} else if (rows * mMaxChildHeight > height || cols * mMaxChildWidth > width) {
|
||||
spaceDifference *= UNEVEN_GRID_PENALTY_MULTIPLIER;
|
||||
}
|
||||
|
||||
if (spaceDifference < bestSpaceDifference) {
|
||||
|
||||
@@ -79,15 +79,14 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
String error = data.getString(Apg.EXTRA_ERROR);
|
||||
if (error != null) {
|
||||
Toast.makeText(getContext(),
|
||||
getContext().getString(R.string.errorMessage, error),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
getContext().getString(R.string.errorMessage, error),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
boolean gotNewKey = data.getBoolean("gotNewKey");
|
||||
if (gotNewKey) {
|
||||
KeyEditor view =
|
||||
(KeyEditor) mInflater.inflate(R.layout.edit_key_key_item,
|
||||
mEditors, false);
|
||||
KeyEditor view = (KeyEditor) mInflater.inflate(R.layout.edit_key_key_item,
|
||||
mEditors, false);
|
||||
view.setEditorListener(SectionView.this);
|
||||
boolean isMasterKey = (mEditors.getChildCount() == 0);
|
||||
view.setValue(mNewKey, isMasterKey);
|
||||
@@ -113,19 +112,19 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
public void setType(int type) {
|
||||
mType = type;
|
||||
switch (type) {
|
||||
case Id.type.user_id: {
|
||||
mTitle.setText(R.string.section_userIds);
|
||||
break;
|
||||
}
|
||||
case Id.type.user_id: {
|
||||
mTitle.setText(R.string.section_userIds);
|
||||
break;
|
||||
}
|
||||
|
||||
case Id.type.key: {
|
||||
mTitle.setText(R.string.section_keys);
|
||||
break;
|
||||
}
|
||||
case Id.type.key: {
|
||||
mTitle.setText(R.string.section_keys);
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,86 +159,80 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
/** {@inheritDoc} */
|
||||
public void onClick(View v) {
|
||||
switch (mType) {
|
||||
case Id.type.user_id: {
|
||||
UserIdEditor view =
|
||||
(UserIdEditor) mInflater.inflate(R.layout.edit_key_user_id_item,
|
||||
mEditors, false);
|
||||
view.setEditorListener(this);
|
||||
if (mEditors.getChildCount() == 0) {
|
||||
view.setIsMainUserId(true);
|
||||
}
|
||||
mEditors.addView(view);
|
||||
break;
|
||||
case Id.type.user_id: {
|
||||
UserIdEditor view = (UserIdEditor) mInflater.inflate(R.layout.edit_key_user_id_item,
|
||||
mEditors, false);
|
||||
view.setEditorListener(this);
|
||||
if (mEditors.getChildCount() == 0) {
|
||||
view.setIsMainUserId(true);
|
||||
}
|
||||
mEditors.addView(view);
|
||||
break;
|
||||
}
|
||||
|
||||
case Id.type.key: {
|
||||
AlertDialog.Builder dialog = new AlertDialog.Builder(getContext());
|
||||
|
||||
View view = mInflater.inflate(R.layout.create_key, null);
|
||||
dialog.setView(view);
|
||||
dialog.setTitle(R.string.title_createKey);
|
||||
dialog.setMessage(R.string.keyCreationElGamalInfo);
|
||||
|
||||
boolean wouldBeMasterKey = (mEditors.getChildCount() == 0);
|
||||
|
||||
final Spinner algorithm = (Spinner) view.findViewById(R.id.algorithm);
|
||||
Vector<Choice> choices = new Vector<Choice>();
|
||||
choices.add(new Choice(Id.choice.algorithm.dsa, getResources().getString(R.string.dsa)));
|
||||
if (!wouldBeMasterKey) {
|
||||
choices.add(new Choice(Id.choice.algorithm.elgamal, getResources().getString(
|
||||
R.string.elgamal)));
|
||||
}
|
||||
|
||||
case Id.type.key: {
|
||||
AlertDialog.Builder dialog = new AlertDialog.Builder(getContext());
|
||||
choices.add(new Choice(Id.choice.algorithm.rsa, getResources().getString(R.string.rsa)));
|
||||
|
||||
View view = mInflater.inflate(R.layout.create_key, null);
|
||||
dialog.setView(view);
|
||||
dialog.setTitle(R.string.title_createKey);
|
||||
dialog.setMessage(R.string.keyCreationElGamalInfo);
|
||||
|
||||
boolean wouldBeMasterKey = (mEditors.getChildCount() == 0);
|
||||
|
||||
final Spinner algorithm = (Spinner) view.findViewById(R.id.algorithm);
|
||||
Vector<Choice> choices = new Vector<Choice>();
|
||||
choices.add(new Choice(Id.choice.algorithm.dsa,
|
||||
getResources().getString(R.string.dsa)));
|
||||
if (!wouldBeMasterKey) {
|
||||
choices.add(new Choice(Id.choice.algorithm.elgamal,
|
||||
getResources().getString(R.string.elgamal)));
|
||||
ArrayAdapter<Choice> adapter = new ArrayAdapter<Choice>(getContext(),
|
||||
android.R.layout.simple_spinner_item, choices);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
algorithm.setAdapter(adapter);
|
||||
// make RSA the default
|
||||
for (int i = 0; i < choices.size(); ++i) {
|
||||
if (choices.get(i).getId() == Id.choice.algorithm.rsa) {
|
||||
algorithm.setSelection(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
choices.add(new Choice(Id.choice.algorithm.rsa,
|
||||
getResources().getString(R.string.rsa)));
|
||||
final EditText keySize = (EditText) view.findViewById(R.id.size);
|
||||
|
||||
ArrayAdapter<Choice> adapter =
|
||||
new ArrayAdapter<Choice>(getContext(),
|
||||
android.R.layout.simple_spinner_item,
|
||||
choices);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
algorithm.setAdapter(adapter);
|
||||
// make RSA the default
|
||||
for (int i = 0; i < choices.size(); ++i) {
|
||||
if (choices.get(i).getId() == Id.choice.algorithm.rsa) {
|
||||
algorithm.setSelection(i);
|
||||
break;
|
||||
dialog.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface di, int id) {
|
||||
di.dismiss();
|
||||
try {
|
||||
mNewKeySize = Integer.parseInt("" + keySize.getText());
|
||||
} catch (NumberFormatException e) {
|
||||
mNewKeySize = 0;
|
||||
}
|
||||
|
||||
mNewKeyAlgorithmChoice = (Choice) algorithm.getSelectedItem();
|
||||
createKey();
|
||||
}
|
||||
});
|
||||
|
||||
final EditText keySize = (EditText) view.findViewById(R.id.size);
|
||||
|
||||
dialog.setPositiveButton(android.R.string.ok,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface di, int id) {
|
||||
di.dismiss();
|
||||
try {
|
||||
mNewKeySize = Integer.parseInt("" + keySize.getText());
|
||||
} catch (NumberFormatException e) {
|
||||
mNewKeySize = 0;
|
||||
dialog.setCancelable(true);
|
||||
dialog.setNegativeButton(android.R.string.cancel,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface di, int id) {
|
||||
di.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
mNewKeyAlgorithmChoice = (Choice) algorithm.getSelectedItem();
|
||||
createKey();
|
||||
}
|
||||
});
|
||||
dialog.create().show();
|
||||
break;
|
||||
}
|
||||
|
||||
dialog.setCancelable(true);
|
||||
dialog.setNegativeButton(android.R.string.cancel,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface di, int id) {
|
||||
di.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
dialog.create().show();
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.updateEditorsVisible();
|
||||
}
|
||||
@@ -251,8 +244,8 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
|
||||
mEditors.removeAllViews();
|
||||
for (String userId : list) {
|
||||
UserIdEditor view =
|
||||
(UserIdEditor) mInflater.inflate(R.layout.edit_key_user_id_item, mEditors, false);
|
||||
UserIdEditor view = (UserIdEditor) mInflater.inflate(R.layout.edit_key_user_id_item,
|
||||
mEditors, false);
|
||||
view.setEditorListener(this);
|
||||
view.setValue(userId);
|
||||
if (mEditors.getChildCount() == 0) {
|
||||
@@ -271,8 +264,8 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
|
||||
mEditors.removeAllViews();
|
||||
for (PGPSecretKey key : list) {
|
||||
KeyEditor view =
|
||||
(KeyEditor) mInflater.inflate(R.layout.edit_key_key_item, mEditors, false);
|
||||
KeyEditor view = (KeyEditor) mInflater.inflate(R.layout.edit_key_key_item, mEditors,
|
||||
false);
|
||||
view.setEditorListener(this);
|
||||
boolean isMasterKey = (mEditors.getChildCount() == 0);
|
||||
view.setValue(key, isMasterKey);
|
||||
@@ -303,10 +296,8 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
} else {
|
||||
passPhrase = "";
|
||||
}
|
||||
mNewKey = Apg.createKey(getContext(),
|
||||
mNewKeyAlgorithmChoice.getId(),
|
||||
mNewKeySize, passPhrase,
|
||||
masterKey);
|
||||
mNewKey = Apg.createKey(getContext(), mNewKeyAlgorithmChoice.getId(), mNewKeySize,
|
||||
passPhrase, masterKey);
|
||||
} catch (NoSuchProviderException e) {
|
||||
error = "" + e;
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
|
||||
@@ -40,9 +40,9 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene
|
||||
private EditText mEmail;
|
||||
private EditText mComment;
|
||||
|
||||
private static final Pattern EMAIL_PATTERN =
|
||||
Pattern.compile("^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+[.]([a-zA-Z])+([a-zA-Z])+",
|
||||
Pattern.CASE_INSENSITIVE);
|
||||
private static final Pattern EMAIL_PATTERN = Pattern.compile(
|
||||
"^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+[.]([a-zA-Z])+([a-zA-Z])+",
|
||||
Pattern.CASE_INSENSITIVE);
|
||||
|
||||
public static class NoNameException extends Exception {
|
||||
static final long serialVersionUID = 0xf812773343L;
|
||||
@@ -124,8 +124,8 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene
|
||||
if (email.length() > 0) {
|
||||
Matcher emailMatcher = EMAIL_PATTERN.matcher(email);
|
||||
if (!emailMatcher.matches()) {
|
||||
throw new InvalidEmailException(
|
||||
getContext().getString(R.string.error_invalidEmail, email));
|
||||
throw new InvalidEmailException(getContext().getString(R.string.error_invalidEmail,
|
||||
email));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene
|
||||
}
|
||||
|
||||
public void onClick(View v) {
|
||||
final ViewGroup parent = (ViewGroup)getParent();
|
||||
final ViewGroup parent = (ViewGroup) getParent();
|
||||
if (v == mDeleteButton) {
|
||||
boolean wasMainUserId = mIsMainUserId.isChecked();
|
||||
parent.removeView(this);
|
||||
|
||||
Reference in New Issue
Block a user