diff options
author | uberspot <onexemailx@gmail.com> | 2014-03-13 21:07:21 +0200 |
---|---|---|
committer | uberspot <onexemailx@gmail.com> | 2014-03-13 21:30:56 +0200 |
commit | 4353ea37e223c0ed5b9f14c0226ce87ea992288c (patch) | |
tree | 50e709b3e02f392e4db2ae41290723b6c64b965f | |
parent | dc5c34ffc5e7e4f76f69f103d33b5a84616586fc (diff) | |
download | open-keychain-4353ea37e223c0ed5b9f14c0226ce87ea992288c.tar.gz open-keychain-4353ea37e223c0ed5b9f14c0226ce87ea992288c.tar.bz2 open-keychain-4353ea37e223c0ed5b9f14c0226ce87ea992288c.zip |
more UI code style fixes
9 files changed, 77 insertions, 70 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java index 42b20788f..f805198f1 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java @@ -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) { } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java index be22c8753..c0fd53007 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java @@ -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; } -}
\ No newline at end of file +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java index a70688cdf..0dda10c9c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java @@ -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); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java index 5660850b2..47372eb59 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java @@ -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 { } }); } -}
\ No newline at end of file +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyActivity.java index 7efb43cce..874703704 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyActivity.java @@ -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() { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/FixedListView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/FixedListView.java index 6245fd95c..da29f808a 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/FixedListView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/FixedListView.java @@ -52,4 +52,4 @@ public class FixedListView extends ListView { super.onMeasure(widthMeasureSpec, expandSpec); } -}
\ No newline at end of file +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index 0d15de982..7e0acfa28 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -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); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index d6e44ee4e..e5b6003b1 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -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); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java index 039e87446..d3c6f02fe 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java @@ -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)); |