more UI code style fixes
This commit is contained in:
@@ -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;
|
||||||
@@ -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
|
||||||
@@ -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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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) {
|
||||||
@@ -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,8 +151,11 @@ 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());
|
||||||
|
mCreateKeyDialogFragment
|
||||||
|
.setOnAlgorithmSelectedListener(
|
||||||
|
new CreateKeyDialogFragment.OnAlgorithmSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onAlgorithmSelected(Choice algorithmChoice, int keySize) {
|
public void onAlgorithmSelected(Choice algorithmChoice, int keySize) {
|
||||||
mNewKeyAlgorithmChoice = algorithmChoice;
|
mNewKeyAlgorithmChoice = algorithmChoice;
|
||||||
@@ -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