more UI code style fixes

This commit is contained in:
uberspot 2014-03-13 21:07:21 +02:00
parent dc5c34ffc5
commit 4353ea37e2
9 changed files with 77 additions and 70 deletions

View File

@ -351,7 +351,7 @@ public class DecryptActivity extends DrawerActivity {
}
} else {
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)
.show();
// end activity
@ -519,7 +519,9 @@ public class DecryptActivity extends DrawerActivity {
AppMsg.STYLE_ALERT).show();
} finally {
try {
if (inStream != null) inStream.close();
if (inStream != null) {
inStream.close();
}
} catch (Exception e) {
}
}

View File

@ -221,15 +221,15 @@ public class DrawerActivity extends ActionBarActivity {
}
private class NavigationDrawerAdapter extends ArrayAdapter<NavItem> {
Context context;
int layoutResourceId;
NavItem data[] = null;
Context mContext;
int mLayoutResourceId;
NavItem mData[] = null;
public NavigationDrawerAdapter(Context context, int layoutResourceId, NavItem[] data) {
super(context, layoutResourceId, data);
this.layoutResourceId = layoutResourceId;
this.context = context;
this.data = data;
this.mLayoutResourceId = layoutResourceId;
this.mContext = context;
this.mData = data;
}
@Override
@ -238,21 +238,21 @@ public class DrawerActivity extends ActionBarActivity {
NavItemHolder holder = null;
if (row == null) {
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
row = inflater.inflate(layoutResourceId, parent, false);
LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
row = inflater.inflate(mLayoutResourceId, parent, false);
holder = new NavItemHolder();
holder.img = (FontAwesomeText) row.findViewById(R.id.drawer_item_icon);
holder.txtTitle = (TextView) row.findViewById(R.id.drawer_item_text);
holder.mImg = (FontAwesomeText) row.findViewById(R.id.drawer_item_icon);
holder.mTxtTitle = (TextView) row.findViewById(R.id.drawer_item_text);
row.setTag(holder);
} else {
holder = (NavItemHolder) row.getTag();
}
NavItem item = data[position];
holder.txtTitle.setText(item.title);
holder.img.setIcon(item.icon);
NavItem item = mData[position];
holder.mTxtTitle.setText(item.title);
holder.mImg.setIcon(item.icon);
return row;
}
@ -260,8 +260,8 @@ public class DrawerActivity extends ActionBarActivity {
}
static class NavItemHolder {
FontAwesomeText img;
TextView txtTitle;
FontAwesomeText mImg;
TextView mTxtTitle;
}
}
}

View File

@ -73,7 +73,7 @@ public class KeyListActivity extends DrawerActivity {
case R.id.menu_key_list_secret_export:
mExportHelper.showExportKeysDialog(null, Id.type.secret_key, Constants.path.APP_DIR_FILE_SEC);
return true;
default:
return super.onOptionsItemSelected(item);
}

View File

@ -34,8 +34,8 @@ import java.util.List;
@SuppressLint("NewApi")
public class PreferencesActivity extends PreferenceActivity {
public final static 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_GEN = "org.sufficientlysecure.keychain.ui.PREFS_GEN";
public static final String ACTION_PREFS_ADV = "org.sufficientlysecure.keychain.ui.PREFS_ADV";
private PreferenceScreen mKeyServerPreference = null;
private static Preferences mPreferences;
@ -81,12 +81,12 @@ public class PreferencesActivity extends PreferenceActivity {
(IntegerListPreference) findPreference(Constants.pref.DEFAULT_ENCRYPTION_ALGORITHM));
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[]{
getString(R.string.choice_none) + " (" + getString(R.string.compression_fast) + ")",
"ZIP (" + 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];
for (int i = 0; i < values.length; ++i) {
values[i] = "" + valueIds[i];
@ -104,9 +104,11 @@ public class PreferencesActivity extends PreferenceActivity {
(IntegerListPreference) findPreference(Constants.pref.DEFAULT_FILE_COMPRESSION),
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) {
// Load the legacy preferences headers
@ -216,12 +218,12 @@ public class PreferencesActivity extends PreferenceActivity {
(IntegerListPreference) findPreference(Constants.pref.DEFAULT_ENCRYPTION_ALGORITHM));
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[]{
getString(R.string.choice_none) + " (" + getString(R.string.compression_fast) + ")",
"ZIP (" + 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];
for (int i = 0; i < values.length; ++i) {
values[i] = "" + valueIds[i];
@ -239,9 +241,11 @@ public class PreferencesActivity extends PreferenceActivity {
(IntegerListPreference) findPreference(Constants.pref.DEFAULT_FILE_COMPRESSION),
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,
PGPEncryptedData.AES_256, PGPEncryptedData.BLOWFISH, PGPEncryptedData.TWOFISH,
PGPEncryptedData.CAST5, PGPEncryptedData.DES, PGPEncryptedData.TRIPLE_DES,
PGPEncryptedData.IDEA,};
PGPEncryptedData.IDEA, };
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];
for (int i = 0; i < values.length; ++i) {
values[i] = "" + valueIds[i];
@ -296,9 +300,9 @@ public class PreferencesActivity extends PreferenceActivity {
(final IntegerListPreference mHashAlgorithm, int[] valueIds, String[] entries, String[] values) {
valueIds = new int[]{HashAlgorithmTags.MD5, HashAlgorithmTags.RIPEMD160,
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",
"SHA-512",};
"SHA-512", };
values = new String[valueIds.length];
for (int i = 0; i < values.length; ++i) {
values[i] = "" + valueIds[i];
@ -317,8 +321,9 @@ public class PreferencesActivity extends PreferenceActivity {
});
}
private static void initializeMessageCompression
(final IntegerListPreference mMessageCompression, int[] valueIds, String[] entries, String[] values) {
private static void initializeMessageCompression(
final IntegerListPreference mMessageCompression,
int[] valueIds, String[] entries, String[] values) {
mMessageCompression.setEntries(entries);
mMessageCompression.setEntryValues(values);
mMessageCompression.setValue("" + mPreferences.getDefaultMessageCompression());
@ -373,4 +378,4 @@ public class PreferencesActivity extends PreferenceActivity {
}
});
}
}
}

View File

@ -38,7 +38,7 @@ public class SelectPublicKeyActivity extends ActionBarActivity {
SelectPublicKeyFragment mSelectFragment;
long selectedMasterKeyIds[];
long mSelectedMasterKeyIds[];
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -79,7 +79,7 @@ public class SelectPublicKeyActivity extends ActionBarActivity {
}
// Create an instance of the fragment
mSelectFragment = SelectPublicKeyFragment.newInstance(selectedMasterKeyIds);
mSelectFragment = SelectPublicKeyFragment.newInstance(mSelectedMasterKeyIds);
// Add the fragment to the 'fragment_container' FrameLayout
getSupportFragmentManager().beginTransaction()
@ -124,7 +124,7 @@ public class SelectPublicKeyActivity extends ActionBarActivity {
// }
// preselected master keys
selectedMasterKeyIds = intent.getLongArrayExtra(EXTRA_SELECTED_MASTER_KEY_IDS);
mSelectedMasterKeyIds = intent.getLongArrayExtra(EXTRA_SELECTED_MASTER_KEY_IDS);
}
private void cancelClicked() {

View File

@ -52,4 +52,4 @@ public class FixedListView extends ListView {
super.onMeasure(widthMeasureSpec, expandSpec);
}
}
}

View File

@ -54,7 +54,8 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
GregorianCalendar mExpiryDate;
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) {
// Note: Ignore results after the first one - android sends multiples.
if (mDatePickerResultCount++ == 0) {
@ -89,7 +90,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
new Choice(Id.choice.usage.encrypt_only, getResources().getString(
R.string.choice_encrypt_only)),
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(),
android.R.layout.simple_spinner_item, choices);
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.
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.
dialog.getDatePicker().setCalendarViewShown(false);
}
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
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 {
//When created date isn't available
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 {
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);
}

View File

@ -55,7 +55,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
private Choice mNewKeyAlgorithmChoice;
private int mNewKeySize;
private boolean canEdit = true;
private boolean mCanEdit = true;
private ActionBarActivity mActivity;
@ -95,8 +95,8 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
}
public void setCanEdit(boolean bCanEdit) {
canEdit = bCanEdit;
if (!canEdit) {
mCanEdit = bCanEdit;
if (!mCanEdit) {
mPlusButton.setVisibility(View.INVISIBLE);
}
}
@ -137,7 +137,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
* {@inheritDoc}
*/
public void onClick(View v) {
if (canEdit) {
if (mCanEdit) {
switch (mType) {
case Id.type.user_id: {
UserIdEditor view = (UserIdEditor) mInflater.inflate(
@ -151,15 +151,18 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
}
case Id.type.key: {
CreateKeyDialogFragment mCreateKeyDialogFragment = CreateKeyDialogFragment.newInstance(mEditors.getChildCount());
mCreateKeyDialogFragment.setOnAlgorithmSelectedListener(new CreateKeyDialogFragment.OnAlgorithmSelectedListener() {
@Override
public void onAlgorithmSelected(Choice algorithmChoice, int keySize) {
mNewKeyAlgorithmChoice = algorithmChoice;
mNewKeySize = keySize;
createKey();
}
});
CreateKeyDialogFragment mCreateKeyDialogFragment =
CreateKeyDialogFragment.newInstance(mEditors.getChildCount());
mCreateKeyDialogFragment
.setOnAlgorithmSelectedListener(
new CreateKeyDialogFragment.OnAlgorithmSelectedListener() {
@Override
public void onAlgorithmSelected(Choice algorithmChoice, int keySize) {
mNewKeyAlgorithmChoice = algorithmChoice;
mNewKeySize = keySize;
createKey();
}
});
mCreateKeyDialogFragment.show(mActivity.getSupportFragmentManager(), "createKeyDialog");
break;
}
@ -186,7 +189,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
if (mEditors.getChildCount() == 0) {
view.setIsMainUserId(true);
}
view.setCanEdit(canEdit);
view.setCanEdit(mCanEdit);
mEditors.addView(view);
}
@ -207,7 +210,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
view.setEditorListener(this);
boolean isMasterKey = (mEditors.getChildCount() == 0);
view.setValue(list.get(i), isMasterKey, usages.get(i));
view.setCanEdit(canEdit);
view.setCanEdit(mCanEdit);
mEditors.addView(view);
}

View File

@ -18,6 +18,7 @@ package org.sufficientlysecure.keychain.ui.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Patterns;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
@ -38,14 +39,6 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene
private AutoCompleteTextView mEmail;
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 {
static final long serialVersionUID = 0xf812773343L;
@ -142,7 +135,7 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene
String comment = ("" + mComment.getText()).trim();
if (email.length() > 0) {
Matcher emailMatcher = EMAIL_PATTERN.matcher(email);
Matcher emailMatcher = Patterns.EMAIL_ADDRESS.matcher(email);
if (!emailMatcher.matches()) {
throw new InvalidEmailException(getContext().getString(R.string.error_invalid_email,
email));