more UI code style fixes
This commit is contained in:
@@ -351,7 +351,7 @@ public class DecryptActivity extends DrawerActivity {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.e(Constants.TAG,
|
Log.e(Constants.TAG,
|
||||||
"Direct binary data without actual file in filesystem is not supported. Please use the Remote Service API!");
|
"Direct binary data without actual file in filesystem is not supported. Please use the Remote Service API!");
|
||||||
Toast.makeText(this, R.string.error_only_files_are_supported, Toast.LENGTH_LONG)
|
Toast.makeText(this, R.string.error_only_files_are_supported, Toast.LENGTH_LONG)
|
||||||
.show();
|
.show();
|
||||||
// end activity
|
// end activity
|
||||||
@@ -519,7 +519,9 @@ public class DecryptActivity extends DrawerActivity {
|
|||||||
AppMsg.STYLE_ALERT).show();
|
AppMsg.STYLE_ALERT).show();
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if (inStream != null) inStream.close();
|
if (inStream != null) {
|
||||||
|
inStream.close();
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -221,15 +221,15 @@ public class DrawerActivity extends ActionBarActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class NavigationDrawerAdapter extends ArrayAdapter<NavItem> {
|
private class NavigationDrawerAdapter extends ArrayAdapter<NavItem> {
|
||||||
Context context;
|
Context mContext;
|
||||||
int layoutResourceId;
|
int mLayoutResourceId;
|
||||||
NavItem data[] = null;
|
NavItem mData[] = null;
|
||||||
|
|
||||||
public NavigationDrawerAdapter(Context context, int layoutResourceId, NavItem[] data) {
|
public NavigationDrawerAdapter(Context context, int layoutResourceId, NavItem[] data) {
|
||||||
super(context, layoutResourceId, data);
|
super(context, layoutResourceId, data);
|
||||||
this.layoutResourceId = layoutResourceId;
|
this.mLayoutResourceId = layoutResourceId;
|
||||||
this.context = context;
|
this.mContext = context;
|
||||||
this.data = data;
|
this.mData = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -238,21 +238,21 @@ public class DrawerActivity extends ActionBarActivity {
|
|||||||
NavItemHolder holder = null;
|
NavItemHolder holder = null;
|
||||||
|
|
||||||
if (row == null) {
|
if (row == null) {
|
||||||
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
|
LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
|
||||||
row = inflater.inflate(layoutResourceId, parent, false);
|
row = inflater.inflate(mLayoutResourceId, parent, false);
|
||||||
|
|
||||||
holder = new NavItemHolder();
|
holder = new NavItemHolder();
|
||||||
holder.img = (FontAwesomeText) row.findViewById(R.id.drawer_item_icon);
|
holder.mImg = (FontAwesomeText) row.findViewById(R.id.drawer_item_icon);
|
||||||
holder.txtTitle = (TextView) row.findViewById(R.id.drawer_item_text);
|
holder.mTxtTitle = (TextView) row.findViewById(R.id.drawer_item_text);
|
||||||
|
|
||||||
row.setTag(holder);
|
row.setTag(holder);
|
||||||
} else {
|
} else {
|
||||||
holder = (NavItemHolder) row.getTag();
|
holder = (NavItemHolder) row.getTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
NavItem item = data[position];
|
NavItem item = mData[position];
|
||||||
holder.txtTitle.setText(item.title);
|
holder.mTxtTitle.setText(item.title);
|
||||||
holder.img.setIcon(item.icon);
|
holder.mImg.setIcon(item.icon);
|
||||||
|
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
@@ -260,8 +260,8 @@ public class DrawerActivity extends ActionBarActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static class NavItemHolder {
|
static class NavItemHolder {
|
||||||
FontAwesomeText img;
|
FontAwesomeText mImg;
|
||||||
TextView txtTitle;
|
TextView mTxtTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -73,7 +73,7 @@ public class KeyListActivity extends DrawerActivity {
|
|||||||
case R.id.menu_key_list_secret_export:
|
case R.id.menu_key_list_secret_export:
|
||||||
mExportHelper.showExportKeysDialog(null, Id.type.secret_key, Constants.path.APP_DIR_FILE_SEC);
|
mExportHelper.showExportKeysDialog(null, Id.type.secret_key, Constants.path.APP_DIR_FILE_SEC);
|
||||||
|
|
||||||
|
return true;
|
||||||
default:
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ import java.util.List;
|
|||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
public class PreferencesActivity extends PreferenceActivity {
|
public class PreferencesActivity extends PreferenceActivity {
|
||||||
|
|
||||||
public final static String ACTION_PREFS_GEN = "org.sufficientlysecure.keychain.ui.PREFS_GEN";
|
public static final String ACTION_PREFS_GEN = "org.sufficientlysecure.keychain.ui.PREFS_GEN";
|
||||||
public final static String ACTION_PREFS_ADV = "org.sufficientlysecure.keychain.ui.PREFS_ADV";
|
public static final String ACTION_PREFS_ADV = "org.sufficientlysecure.keychain.ui.PREFS_ADV";
|
||||||
|
|
||||||
private PreferenceScreen mKeyServerPreference = null;
|
private PreferenceScreen mKeyServerPreference = null;
|
||||||
private static Preferences mPreferences;
|
private static Preferences mPreferences;
|
||||||
@@ -81,12 +81,12 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
(IntegerListPreference) findPreference(Constants.pref.DEFAULT_ENCRYPTION_ALGORITHM));
|
(IntegerListPreference) findPreference(Constants.pref.DEFAULT_ENCRYPTION_ALGORITHM));
|
||||||
|
|
||||||
int[] valueIds = new int[]{Id.choice.compression.none, Id.choice.compression.zip,
|
int[] valueIds = new int[]{Id.choice.compression.none, Id.choice.compression.zip,
|
||||||
Id.choice.compression.zlib, Id.choice.compression.bzip2,};
|
Id.choice.compression.zlib, Id.choice.compression.bzip2, };
|
||||||
String[] entries = new String[]{
|
String[] entries = new String[]{
|
||||||
getString(R.string.choice_none) + " (" + getString(R.string.compression_fast) + ")",
|
getString(R.string.choice_none) + " (" + getString(R.string.compression_fast) + ")",
|
||||||
"ZIP (" + getString(R.string.compression_fast) + ")",
|
"ZIP (" + getString(R.string.compression_fast) + ")",
|
||||||
"ZLIB (" + getString(R.string.compression_fast) + ")",
|
"ZLIB (" + getString(R.string.compression_fast) + ")",
|
||||||
"BZIP2 (" + getString(R.string.compression_very_slow) + ")",};
|
"BZIP2 (" + getString(R.string.compression_very_slow) + ")", };
|
||||||
String[] values = new String[valueIds.length];
|
String[] values = new String[valueIds.length];
|
||||||
for (int i = 0; i < values.length; ++i) {
|
for (int i = 0; i < values.length; ++i) {
|
||||||
values[i] = "" + valueIds[i];
|
values[i] = "" + valueIds[i];
|
||||||
@@ -104,9 +104,11 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
(IntegerListPreference) findPreference(Constants.pref.DEFAULT_FILE_COMPRESSION),
|
(IntegerListPreference) findPreference(Constants.pref.DEFAULT_FILE_COMPRESSION),
|
||||||
entries, values);
|
entries, values);
|
||||||
|
|
||||||
initializeAsciiArmour((CheckBoxPreference) findPreference(Constants.pref.DEFAULT_ASCII_ARMOUR));
|
initializeAsciiArmour(
|
||||||
|
(CheckBoxPreference) findPreference(Constants.pref.DEFAULT_ASCII_ARMOUR));
|
||||||
|
|
||||||
initializeForceV3Signatures((CheckBoxPreference) findPreference(Constants.pref.FORCE_V3_SIGNATURES));
|
initializeForceV3Signatures(
|
||||||
|
(CheckBoxPreference) findPreference(Constants.pref.FORCE_V3_SIGNATURES));
|
||||||
|
|
||||||
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
|
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
|
||||||
// Load the legacy preferences headers
|
// Load the legacy preferences headers
|
||||||
@@ -216,12 +218,12 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
(IntegerListPreference) findPreference(Constants.pref.DEFAULT_ENCRYPTION_ALGORITHM));
|
(IntegerListPreference) findPreference(Constants.pref.DEFAULT_ENCRYPTION_ALGORITHM));
|
||||||
|
|
||||||
int[] valueIds = new int[]{Id.choice.compression.none, Id.choice.compression.zip,
|
int[] valueIds = new int[]{Id.choice.compression.none, Id.choice.compression.zip,
|
||||||
Id.choice.compression.zlib, Id.choice.compression.bzip2,};
|
Id.choice.compression.zlib, Id.choice.compression.bzip2, };
|
||||||
String[] entries = new String[]{
|
String[] entries = new String[]{
|
||||||
getString(R.string.choice_none) + " (" + getString(R.string.compression_fast) + ")",
|
getString(R.string.choice_none) + " (" + getString(R.string.compression_fast) + ")",
|
||||||
"ZIP (" + getString(R.string.compression_fast) + ")",
|
"ZIP (" + getString(R.string.compression_fast) + ")",
|
||||||
"ZLIB (" + getString(R.string.compression_fast) + ")",
|
"ZLIB (" + getString(R.string.compression_fast) + ")",
|
||||||
"BZIP2 (" + getString(R.string.compression_very_slow) + ")",};
|
"BZIP2 (" + getString(R.string.compression_very_slow) + ")", };
|
||||||
String[] values = new String[valueIds.length];
|
String[] values = new String[valueIds.length];
|
||||||
for (int i = 0; i < values.length; ++i) {
|
for (int i = 0; i < values.length; ++i) {
|
||||||
values[i] = "" + valueIds[i];
|
values[i] = "" + valueIds[i];
|
||||||
@@ -239,9 +241,11 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
(IntegerListPreference) findPreference(Constants.pref.DEFAULT_FILE_COMPRESSION),
|
(IntegerListPreference) findPreference(Constants.pref.DEFAULT_FILE_COMPRESSION),
|
||||||
entries, values);
|
entries, values);
|
||||||
|
|
||||||
initializeAsciiArmour((CheckBoxPreference) findPreference(Constants.pref.DEFAULT_ASCII_ARMOUR));
|
initializeAsciiArmour(
|
||||||
|
(CheckBoxPreference) findPreference(Constants.pref.DEFAULT_ASCII_ARMOUR));
|
||||||
|
|
||||||
initializeForceV3Signatures((CheckBoxPreference) findPreference(Constants.pref.FORCE_V3_SIGNATURES));
|
initializeForceV3Signatures(
|
||||||
|
(CheckBoxPreference) findPreference(Constants.pref.FORCE_V3_SIGNATURES));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,9 +273,9 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
int valueIds[] = {PGPEncryptedData.AES_128, PGPEncryptedData.AES_192,
|
int valueIds[] = {PGPEncryptedData.AES_128, PGPEncryptedData.AES_192,
|
||||||
PGPEncryptedData.AES_256, PGPEncryptedData.BLOWFISH, PGPEncryptedData.TWOFISH,
|
PGPEncryptedData.AES_256, PGPEncryptedData.BLOWFISH, PGPEncryptedData.TWOFISH,
|
||||||
PGPEncryptedData.CAST5, PGPEncryptedData.DES, PGPEncryptedData.TRIPLE_DES,
|
PGPEncryptedData.CAST5, PGPEncryptedData.DES, PGPEncryptedData.TRIPLE_DES,
|
||||||
PGPEncryptedData.IDEA,};
|
PGPEncryptedData.IDEA, };
|
||||||
String entries[] = {"AES-128", "AES-192", "AES-256", "Blowfish", "Twofish", "CAST5",
|
String entries[] = {"AES-128", "AES-192", "AES-256", "Blowfish", "Twofish", "CAST5",
|
||||||
"DES", "Triple DES", "IDEA",};
|
"DES", "Triple DES", "IDEA", };
|
||||||
String values[] = new String[valueIds.length];
|
String values[] = new String[valueIds.length];
|
||||||
for (int i = 0; i < values.length; ++i) {
|
for (int i = 0; i < values.length; ++i) {
|
||||||
values[i] = "" + valueIds[i];
|
values[i] = "" + valueIds[i];
|
||||||
@@ -296,9 +300,9 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
(final IntegerListPreference mHashAlgorithm, int[] valueIds, String[] entries, String[] values) {
|
(final IntegerListPreference mHashAlgorithm, int[] valueIds, String[] entries, String[] values) {
|
||||||
valueIds = new int[]{HashAlgorithmTags.MD5, HashAlgorithmTags.RIPEMD160,
|
valueIds = new int[]{HashAlgorithmTags.MD5, HashAlgorithmTags.RIPEMD160,
|
||||||
HashAlgorithmTags.SHA1, HashAlgorithmTags.SHA224, HashAlgorithmTags.SHA256,
|
HashAlgorithmTags.SHA1, HashAlgorithmTags.SHA224, HashAlgorithmTags.SHA256,
|
||||||
HashAlgorithmTags.SHA384, HashAlgorithmTags.SHA512,};
|
HashAlgorithmTags.SHA384, HashAlgorithmTags.SHA512, };
|
||||||
entries = new String[]{"MD5", "RIPEMD-160", "SHA-1", "SHA-224", "SHA-256", "SHA-384",
|
entries = new String[]{"MD5", "RIPEMD-160", "SHA-1", "SHA-224", "SHA-256", "SHA-384",
|
||||||
"SHA-512",};
|
"SHA-512", };
|
||||||
values = new String[valueIds.length];
|
values = new String[valueIds.length];
|
||||||
for (int i = 0; i < values.length; ++i) {
|
for (int i = 0; i < values.length; ++i) {
|
||||||
values[i] = "" + valueIds[i];
|
values[i] = "" + valueIds[i];
|
||||||
@@ -317,8 +321,9 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initializeMessageCompression
|
private static void initializeMessageCompression(
|
||||||
(final IntegerListPreference mMessageCompression, int[] valueIds, String[] entries, String[] values) {
|
final IntegerListPreference mMessageCompression,
|
||||||
|
int[] valueIds, String[] entries, String[] values) {
|
||||||
mMessageCompression.setEntries(entries);
|
mMessageCompression.setEntries(entries);
|
||||||
mMessageCompression.setEntryValues(values);
|
mMessageCompression.setEntryValues(values);
|
||||||
mMessageCompression.setValue("" + mPreferences.getDefaultMessageCompression());
|
mMessageCompression.setValue("" + mPreferences.getDefaultMessageCompression());
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class SelectPublicKeyActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
SelectPublicKeyFragment mSelectFragment;
|
SelectPublicKeyFragment mSelectFragment;
|
||||||
|
|
||||||
long selectedMasterKeyIds[];
|
long mSelectedMasterKeyIds[];
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -79,7 +79,7 @@ public class SelectPublicKeyActivity extends ActionBarActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create an instance of the fragment
|
// Create an instance of the fragment
|
||||||
mSelectFragment = SelectPublicKeyFragment.newInstance(selectedMasterKeyIds);
|
mSelectFragment = SelectPublicKeyFragment.newInstance(mSelectedMasterKeyIds);
|
||||||
|
|
||||||
// Add the fragment to the 'fragment_container' FrameLayout
|
// Add the fragment to the 'fragment_container' FrameLayout
|
||||||
getSupportFragmentManager().beginTransaction()
|
getSupportFragmentManager().beginTransaction()
|
||||||
@@ -124,7 +124,7 @@ public class SelectPublicKeyActivity extends ActionBarActivity {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// preselected master keys
|
// preselected master keys
|
||||||
selectedMasterKeyIds = intent.getLongArrayExtra(EXTRA_SELECTED_MASTER_KEY_IDS);
|
mSelectedMasterKeyIds = intent.getLongArrayExtra(EXTRA_SELECTED_MASTER_KEY_IDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cancelClicked() {
|
private void cancelClicked() {
|
||||||
|
|||||||
@@ -54,7 +54,8 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
|
|||||||
GregorianCalendar mExpiryDate;
|
GregorianCalendar mExpiryDate;
|
||||||
|
|
||||||
private int mDatePickerResultCount = 0;
|
private int mDatePickerResultCount = 0;
|
||||||
private DatePickerDialog.OnDateSetListener mExpiryDateSetListener = new DatePickerDialog.OnDateSetListener() {
|
private DatePickerDialog.OnDateSetListener mExpiryDateSetListener =
|
||||||
|
new DatePickerDialog.OnDateSetListener() {
|
||||||
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
|
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
|
||||||
// Note: Ignore results after the first one - android sends multiples.
|
// Note: Ignore results after the first one - android sends multiples.
|
||||||
if (mDatePickerResultCount++ == 0) {
|
if (mDatePickerResultCount++ == 0) {
|
||||||
@@ -89,7 +90,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
|
|||||||
new Choice(Id.choice.usage.encrypt_only, getResources().getString(
|
new Choice(Id.choice.usage.encrypt_only, getResources().getString(
|
||||||
R.string.choice_encrypt_only)),
|
R.string.choice_encrypt_only)),
|
||||||
new Choice(Id.choice.usage.sign_and_encrypt, getResources().getString(
|
new Choice(Id.choice.usage.sign_and_encrypt, getResources().getString(
|
||||||
R.string.choice_sign_and_encrypt)),};
|
R.string.choice_sign_and_encrypt)), };
|
||||||
ArrayAdapter<Choice> adapter = new ArrayAdapter<Choice>(getContext(),
|
ArrayAdapter<Choice> adapter = new ArrayAdapter<Choice>(getContext(),
|
||||||
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);
|
||||||
@@ -129,13 +130,15 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// setCalendarViewShown() is supported from API 11 onwards.
|
// setCalendarViewShown() is supported from API 11 onwards.
|
||||||
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) {
|
||||||
// Hide calendarView in tablets because of the unix warparound bug.
|
// Hide calendarView in tablets because of the unix warparound bug.
|
||||||
dialog.getDatePicker().setCalendarViewShown(false);
|
dialog.getDatePicker().setCalendarViewShown(false);
|
||||||
|
}
|
||||||
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) {
|
||||||
if (dialog != null && mCreatedDate != null) {
|
if (dialog != null && mCreatedDate != null) {
|
||||||
dialog.getDatePicker().setMinDate(mCreatedDate.getTime().getTime() + DateUtils.DAY_IN_MILLIS);
|
dialog.getDatePicker()
|
||||||
|
.setMinDate(
|
||||||
|
mCreatedDate.getTime().getTime() + DateUtils.DAY_IN_MILLIS);
|
||||||
} else {
|
} else {
|
||||||
//When created date isn't available
|
//When created date isn't available
|
||||||
dialog.getDatePicker().setMinDate(date.getTime().getTime() + DateUtils.DAY_IN_MILLIS);
|
dialog.getDatePicker().setMinDate(date.getTime().getTime() + DateUtils.DAY_IN_MILLIS);
|
||||||
@@ -277,7 +280,8 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
|
|||||||
|
|
||||||
class ExpiryDatePickerDialog extends DatePickerDialog {
|
class ExpiryDatePickerDialog extends DatePickerDialog {
|
||||||
|
|
||||||
public ExpiryDatePickerDialog(Context context, OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth) {
|
public ExpiryDatePickerDialog(Context context, OnDateSetListener callBack,
|
||||||
|
int year, int monthOfYear, int dayOfMonth) {
|
||||||
super(context, callBack, year, monthOfYear, dayOfMonth);
|
super(context, callBack, year, monthOfYear, dayOfMonth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
|||||||
|
|
||||||
private Choice mNewKeyAlgorithmChoice;
|
private Choice mNewKeyAlgorithmChoice;
|
||||||
private int mNewKeySize;
|
private int mNewKeySize;
|
||||||
private boolean canEdit = true;
|
private boolean mCanEdit = true;
|
||||||
|
|
||||||
private ActionBarActivity mActivity;
|
private ActionBarActivity mActivity;
|
||||||
|
|
||||||
@@ -95,8 +95,8 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setCanEdit(boolean bCanEdit) {
|
public void setCanEdit(boolean bCanEdit) {
|
||||||
canEdit = bCanEdit;
|
mCanEdit = bCanEdit;
|
||||||
if (!canEdit) {
|
if (!mCanEdit) {
|
||||||
mPlusButton.setVisibility(View.INVISIBLE);
|
mPlusButton.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,7 +137,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
|||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (canEdit) {
|
if (mCanEdit) {
|
||||||
switch (mType) {
|
switch (mType) {
|
||||||
case Id.type.user_id: {
|
case Id.type.user_id: {
|
||||||
UserIdEditor view = (UserIdEditor) mInflater.inflate(
|
UserIdEditor view = (UserIdEditor) mInflater.inflate(
|
||||||
@@ -151,15 +151,18 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
case Id.type.key: {
|
case Id.type.key: {
|
||||||
CreateKeyDialogFragment mCreateKeyDialogFragment = CreateKeyDialogFragment.newInstance(mEditors.getChildCount());
|
CreateKeyDialogFragment mCreateKeyDialogFragment =
|
||||||
mCreateKeyDialogFragment.setOnAlgorithmSelectedListener(new CreateKeyDialogFragment.OnAlgorithmSelectedListener() {
|
CreateKeyDialogFragment.newInstance(mEditors.getChildCount());
|
||||||
@Override
|
mCreateKeyDialogFragment
|
||||||
public void onAlgorithmSelected(Choice algorithmChoice, int keySize) {
|
.setOnAlgorithmSelectedListener(
|
||||||
mNewKeyAlgorithmChoice = algorithmChoice;
|
new CreateKeyDialogFragment.OnAlgorithmSelectedListener() {
|
||||||
mNewKeySize = keySize;
|
@Override
|
||||||
createKey();
|
public void onAlgorithmSelected(Choice algorithmChoice, int keySize) {
|
||||||
}
|
mNewKeyAlgorithmChoice = algorithmChoice;
|
||||||
});
|
mNewKeySize = keySize;
|
||||||
|
createKey();
|
||||||
|
}
|
||||||
|
});
|
||||||
mCreateKeyDialogFragment.show(mActivity.getSupportFragmentManager(), "createKeyDialog");
|
mCreateKeyDialogFragment.show(mActivity.getSupportFragmentManager(), "createKeyDialog");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -186,7 +189,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
|||||||
if (mEditors.getChildCount() == 0) {
|
if (mEditors.getChildCount() == 0) {
|
||||||
view.setIsMainUserId(true);
|
view.setIsMainUserId(true);
|
||||||
}
|
}
|
||||||
view.setCanEdit(canEdit);
|
view.setCanEdit(mCanEdit);
|
||||||
mEditors.addView(view);
|
mEditors.addView(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,7 +210,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
|||||||
view.setEditorListener(this);
|
view.setEditorListener(this);
|
||||||
boolean isMasterKey = (mEditors.getChildCount() == 0);
|
boolean isMasterKey = (mEditors.getChildCount() == 0);
|
||||||
view.setValue(list.get(i), isMasterKey, usages.get(i));
|
view.setValue(list.get(i), isMasterKey, usages.get(i));
|
||||||
view.setCanEdit(canEdit);
|
view.setCanEdit(mCanEdit);
|
||||||
mEditors.addView(view);
|
mEditors.addView(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package org.sufficientlysecure.keychain.ui.widget;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.util.Patterns;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -38,14 +39,6 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene
|
|||||||
private AutoCompleteTextView mEmail;
|
private AutoCompleteTextView mEmail;
|
||||||
private EditText mComment;
|
private EditText mComment;
|
||||||
|
|
||||||
// see http://www.regular-expressions.info/email.html
|
|
||||||
// RFC 2822 if we omit the syntax using double quotes and square brackets
|
|
||||||
// android.util.Patterns.EMAIL_ADDRESS is only available as of Android 2.2+
|
|
||||||
private static final Pattern EMAIL_PATTERN = Pattern
|
|
||||||
.compile(
|
|
||||||
"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?",
|
|
||||||
Pattern.CASE_INSENSITIVE);
|
|
||||||
|
|
||||||
public static class NoNameException extends Exception {
|
public static class NoNameException extends Exception {
|
||||||
static final long serialVersionUID = 0xf812773343L;
|
static final long serialVersionUID = 0xf812773343L;
|
||||||
|
|
||||||
@@ -142,7 +135,7 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene
|
|||||||
String comment = ("" + mComment.getText()).trim();
|
String comment = ("" + mComment.getText()).trim();
|
||||||
|
|
||||||
if (email.length() > 0) {
|
if (email.length() > 0) {
|
||||||
Matcher emailMatcher = EMAIL_PATTERN.matcher(email);
|
Matcher emailMatcher = Patterns.EMAIL_ADDRESS.matcher(email);
|
||||||
if (!emailMatcher.matches()) {
|
if (!emailMatcher.matches()) {
|
||||||
throw new InvalidEmailException(getContext().getString(R.string.error_invalid_email,
|
throw new InvalidEmailException(getContext().getString(R.string.error_invalid_email,
|
||||||
email));
|
email));
|
||||||
|
|||||||
Reference in New Issue
Block a user