diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java index e4ce6c373..9b80e76f3 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java @@ -41,14 +41,14 @@ public class KeychainApplication extends Application { /* * Sets Bouncy (Spongy) Castle as preferred security provider - * + * * insertProviderAt() position starts from 1 */ Security.insertProviderAt(new BouncyCastleProvider(), 1); /* * apply RNG fixes - * + * * among other things, executes Security.insertProviderAt(new * LinuxPRNGSecureRandomProvider(), 1) for Android <= SDK 17 */ diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/compatibility/ClipboardReflection.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/compatibility/ClipboardReflection.java index 10bb8cf5d..1cac5762d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/compatibility/ClipboardReflection.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/compatibility/ClipboardReflection.java @@ -30,7 +30,7 @@ public class ClipboardReflection { /** * Wrapper around ClipboardManager based on Android version using Reflection API - * + * * @param context * @param text */ @@ -57,7 +57,7 @@ public class ClipboardReflection { /** * Wrapper around ClipboardManager based on Android version using Reflection API - * + * * @param context */ public static CharSequence getClipboardText(Context context) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java index 00a62ce58..43fdc7751 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java @@ -75,7 +75,7 @@ public class ExportHelper { int type = keyType; mExportFilename = data.getString(FileDialogFragment.MESSAGE_DATA_FILENAME); - if( data.getBoolean(FileDialogFragment.MESSAGE_DATA_CHECKED) ) { + if (data.getBoolean(FileDialogFragment.MESSAGE_DATA_CHECKED)) { type = Id.type.public_secret_key; } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpConversionHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpConversionHelper.java index 1f8dec7a1..7c25c2c2a 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpConversionHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpConversionHelper.java @@ -65,14 +65,16 @@ public class PgpConversionHelper { try { while ((obj = factory.nextObject()) != null) { PGPSecretKey secKey = null; - if(obj instanceof PGPSecretKey) { - if ((secKey = (PGPSecretKey)obj ) == null) { + if (obj instanceof PGPSecretKey) { + secKey = (PGPSecretKey) obj; + if (secKey == null) { Log.e(Constants.TAG, "No keys given!"); } keys.add(secKey); - } else if(obj instanceof PGPSecretKeyRing) { //master keys are sent as keyrings + } else if (obj instanceof PGPSecretKeyRing) { //master keys are sent as keyrings PGPSecretKeyRing keyRing = null; - if ((keyRing = (PGPSecretKeyRing)obj) == null) { + keyRing = (PGPSecretKeyRing) obj; + if (keyRing == null) { Log.e(Constants.TAG, "No keys given!"); } @SuppressWarnings("unchecked") diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index c91a932c5..d4fba68ff 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -219,7 +219,7 @@ public class PgpKeyOperation { } - private Pair buildNewSecretKey( + private Pair buildNewSecretKey( ArrayList userIds, ArrayList keys, ArrayList keysExpiryDates, ArrayList keysUsages, @@ -359,11 +359,11 @@ public class PgpKeyOperation { PGPSecretKeyRing secretKeyRing = keyGen.generateSecretKeyRing(); PGPPublicKeyRing publicKeyRing = keyGen.generatePublicKeyRing(); - return new Pair(secretKeyRing, publicKeyRing); + return new Pair(secretKeyRing, publicKeyRing); } - public Pair buildSecretKey (PGPSecretKeyRing mKR, + public Pair buildSecretKey(PGPSecretKeyRing mKR, PGPPublicKeyRing pKR, SaveKeyringParcel saveParcel) throws PgpGeneralMsgIdException, PGPException, SignatureException, IOException { @@ -676,7 +676,7 @@ public class PgpKeyOperation { */ - return new Pair(mKR, pKR); + return new Pair(mKR, pKR); } @@ -723,7 +723,7 @@ public class PgpKeyOperation { } // fetch public key ring, add the certification and return it - for(String userId : new IterableIterator(userIds.iterator())) { + for (String userId : new IterableIterator(userIds.iterator())) { PGPSignature sig = signatureGenerator.generateCertification(userId, publicKey); publicKey = PGPPublicKey.addCertification(publicKey, userId, sig); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java index 13dc2af2b..c88e3e22f 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java @@ -508,13 +508,14 @@ public class ProviderHelper { */ public static boolean getMasterKeyCanCertify(Context context, Uri queryUri) { - String[] projection = new String[]{ + String[] projection = new String[] { KeyRings.MASTER_KEY_ID, "(SELECT COUNT(sign_keys." + Keys._ID + ") FROM " + Tables.KEYS + " AS sign_keys WHERE sign_keys." + Keys.KEY_RING_ROW_ID + " = " + KeychainDatabase.Tables.KEY_RINGS + "." + KeyRings._ID + " AND sign_keys." + Keys.CAN_CERTIFY + " = '1' AND " + Keys.IS_MASTER_KEY - + " = 1) AS sign",}; + + " = 1) AS sign", + }; ContentResolver cr = context.getContentResolver(); Cursor cursor = cr.query(queryUri, projection, null, null, null); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java index a894da448..b2ab75cea 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java @@ -95,7 +95,7 @@ public class RemoteServiceActivity extends ActionBarActivity { if (ACTION_REGISTER.equals(action)) { final String packageName = extras.getString(EXTRA_PACKAGE_NAME); final byte[] packageSignature = extras.getByteArray(EXTRA_PACKAGE_SIGNATURE); - Log.d(Constants.TAG, "ACTION_REGISTER packageName: "+packageName); + Log.d(Constants.TAG, "ACTION_REGISTER packageName: " + packageName); // Inflate a "Done"/"Cancel" custom action bar view ActionBarHelper.setTwoButtonView(getSupportActionBar(), diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index bdd50c98d..14beae40c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -818,7 +818,7 @@ public class KeychainIntentService extends IntentService return; } // contextualize the exception, if necessary - if(e instanceof PgpGeneralMsgIdException) { + if (e instanceof PgpGeneralMsgIdException) { e = ((PgpGeneralMsgIdException) e).getContextualized(this); } Log.e(Constants.TAG, "ApgService Exception: ", e); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java index b7ae4e1f1..cc0f94b9b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java @@ -46,20 +46,20 @@ public class SaveKeyringParcel implements Parcelable { public SaveKeyringParcel() {} - private SaveKeyringParcel(Parcel source) - { - userIDs = (ArrayList)source.readSerializable(); - originalIDs = (ArrayList)source.readSerializable(); - deletedIDs = (ArrayList)source.readSerializable(); + private SaveKeyringParcel(Parcel source) { + userIDs = (ArrayList) source.readSerializable(); + originalIDs = (ArrayList) source.readSerializable(); + deletedIDs = (ArrayList) source.readSerializable(); newIDs = source.createBooleanArray(); primaryIDChanged = source.readByte() != 0; moddedKeys = source.createBooleanArray(); byte[] tmp = source.createByteArray(); - if (tmp == null) + if (tmp == null) { deletedKeys = null; - else + } else { deletedKeys = PgpConversionHelper.BytesToPGPSecretKeyList(tmp); - keysExpiryDates = (ArrayList)source.readSerializable(); + } + keysExpiryDates = (ArrayList) source.readSerializable(); keysUsages = source.readArrayList(Integer.class.getClassLoader()); newPassPhrase = source.readString(); oldPassPhrase = source.readString(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java index f551ee5c1..d041bc35e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java @@ -306,7 +306,7 @@ public class CertifyKeyActivity extends ActionBarActivity implements // Bail out if there is not at least one user id selected ArrayList userIds = mUserIdsAdapter.getSelectedUserIds(); - if(userIds.isEmpty()) { + if (userIds.isEmpty()) { Toast.makeText(CertifyKeyActivity.this, "No User IDs to sign selected!", Toast.LENGTH_SHORT).show(); return; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java index ed6366353..67cf8d3e3 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java @@ -205,7 +205,7 @@ public class DecryptFileFragment extends DecryptFragment { } else { AppMsg.makeText(getActivity(), R.string.decryption_successful, AppMsg.STYLE_INFO).show(); - + if (mDeleteAfter.isChecked()) { // Create and show dialog to delete original file DeleteFileDialogFragment deleteFileDialog = DeleteFileDialogFragment 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 f01e67449..e5a8fa8bc 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 @@ -58,7 +58,7 @@ public class DrawerActivity extends ActionBarActivity { // if the left margin of the loaded layout is close to the // one used in tablets then set drawer as open and locked - if( Math.abs(leftMarginLoaded - leftMarginInTablets) < errorInMarginAllowed) { + if (Math.abs(leftMarginLoaded - leftMarginInTablets) < errorInMarginAllowed) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerList); mDrawerLayout.setScrimColor(Color.TRANSPARENT); mIsDrawerLocked = true; @@ -82,7 +82,7 @@ public class DrawerActivity extends ActionBarActivity { // enable ActionBar app icon to behave as action to toggle nav drawer // if the drawer is not locked - if ( !mIsDrawerLocked ) { + if (!mIsDrawerLocked) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); } @@ -109,7 +109,7 @@ public class DrawerActivity extends ActionBarActivity { } }; - if ( !mIsDrawerLocked ) { + if (!mIsDrawerLocked) { mDrawerLayout.setDrawerListener(mDrawerToggle); } else { // If the drawer is locked open make it un-focusable @@ -218,9 +218,9 @@ public class DrawerActivity extends ActionBarActivity { // setTitle(mDrawerTitles[position]); // If drawer isn't locked just close the drawer and // it will move to the selected item by itself (via drawer toggle listener) - if ( !mIsDrawerLocked ) { + if (!mIsDrawerLocked) { mDrawerLayout.closeDrawer(mDrawerList); - // else move to the selected item yourself + // else move to the selected item yourself } else { callIntentForDrawerItem(mSelectedItem); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index bab1e6f5f..8ef4631dc 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -339,7 +339,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener Toast.makeText(this, R.string.error_save_first, Toast.LENGTH_LONG).show(); } else { long masterKeyId = ProviderHelper.getMasterKeyId(this, mDataUri); - long[] ids = new long[]{masterKeyId}; + long[] ids = new long[] {masterKeyId}; mExportHelper.showExportKeysDialog(ids, Id.type.secret_key, Constants.Path.APP_DIR_FILE_SEC, null); return true; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java index fb727d297..cee7dae87 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java @@ -112,7 +112,7 @@ public class EncryptFileFragment extends Fragment { }); mFileCompression = (Spinner) view.findViewById(R.id.fileCompression); - Choice[] choices = new Choice[]{ + Choice[] choices = new Choice[] { new Choice(Id.choice.compression.none, getString(R.string.choice_none) + " (" + getString(R.string.compression_fast) + ")"), new Choice(Id.choice.compression.zip, "ZIP (" @@ -120,7 +120,8 @@ public class EncryptFileFragment extends Fragment { new Choice(Id.choice.compression.zlib, "ZLIB (" + getString(R.string.compression_fast) + ")"), new Choice(Id.choice.compression.bzip2, "BZIP2 (" - + getString(R.string.compression_very_slow) + ")"),}; + + getString(R.string.compression_very_slow) + ")"), + }; ArrayAdapter adapter = new ArrayAdapter(getActivity(), android.R.layout.simple_spinner_item, choices); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysClipboardFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysClipboardFragment.java index e53762580..28e2091a9 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysClipboardFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysClipboardFragment.java @@ -65,7 +65,7 @@ public class ImportKeysClipboardFragment extends Fragment { String sendText = ""; if (clipboardText != null) { sendText = clipboardText.toString(); - if(sendText.toLowerCase(Locale.ENGLISH).startsWith(Constants.FINGERPRINT_SCHEME)) { + if (sendText.toLowerCase(Locale.ENGLISH).startsWith(Constants.FINGERPRINT_SCHEME)) { mImportActivity.loadFromFingerprintUri(null, Uri.parse(sendText)); return; } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java index 957c822d2..6da8a0262 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -185,7 +185,7 @@ public class KeyListFragment extends Fragment } case R.id.menu_key_list_multi_export: { ids = mStickyList.getWrappedList().getCheckedItemIds(); - long[] masterKeyIds = new long[2*ids.length]; + long[] masterKeyIds = new long[2 * ids.length]; ArrayList allPubRowIds = ProviderHelper.getPublicKeyRingsRowIds(getActivity()); for (int i = 0; i < ids.length; i++) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java index 2efa7d33a..1f0a1a197 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java @@ -141,7 +141,8 @@ public class SelectSecretKeyFragment extends ListFragment implements + Keys.IS_REVOKED + " = '0' AND valid_keys." + Keys.CAN_SIGN + " = '1' AND valid_keys." + Keys.CREATION + " <= '" + now + "' AND " + "(valid_keys." + Keys.EXPIRY + " IS NULL OR valid_keys." + Keys.EXPIRY - + " >= '" + now + "')) AS " + SelectKeyCursorAdapter.PROJECTION_ROW_VALID,}; + + " >= '" + now + "')) AS " + SelectKeyCursorAdapter.PROJECTION_ROW_VALID, + }; String orderBy = UserIds.USER_ID + " ASC"; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java index d1ba431d6..f0704bb0f 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java @@ -53,12 +53,12 @@ public class SelectSecretKeyLayoutFragment extends Fragment implements LoaderMan private SelectSecretKeyCallback mCallback; - final String[] PROJECTION = new String[]{ - KeychainContract.UserIds.USER_ID, - KeychainContract.KeyRings.MASTER_KEY_ID + private static final String[] PROJECTION = new String[] { + KeychainContract.UserIds.USER_ID, + KeychainContract.KeyRings.MASTER_KEY_ID, }; - final int INDEX_USER_ID = 0; - final int INDEX_MASTER_KEY_ID = 1; + private static final int INDEX_USER_ID = 0; + private static final int INDEX_MASTER_KEY_ID = 1; public interface SelectSecretKeyCallback { void onKeySelected(long secretKeyId); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index b9dcd2e21..b86c20880 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -125,7 +125,7 @@ public class ViewKeyActivity extends ActionBarActivity { case R.id.menu_key_view_export_file: long masterKeyId = ProviderHelper.getPublicMasterKeyId(this, Long.valueOf(mDataUri.getLastPathSegment())); - long[] ids = new long[]{masterKeyId}; + long[] ids = new long[] {masterKeyId}; mExportHelper.showExportKeysDialog(ids, Id.type.public_key, Constants.Path.APP_DIR_FILE_PUB, null); return true; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java index cf7ed670d..99a4d38e9 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java @@ -148,8 +148,7 @@ public class ViewKeyKeysAdapter extends CursorAdapter { DateFormat.getDateFormat(context).format(expiryDate) + ")"); keyExpiry.setVisibility(View.VISIBLE); - } - else { + } else { keyExpiry.setVisibility(View.GONE); } // if key is expired or revoked, strike through text diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java index 61572b9ce..21a150606 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java @@ -55,14 +55,15 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter { @Override public Cursor swapCursor(Cursor newCursor) { initIndex(newCursor); - if(mCheckStates != null) { + if (mCheckStates != null) { mCheckStates.clear(); - if(newCursor != null) { + if (newCursor != null) { int count = newCursor.getCount(); mCheckStates.ensureCapacity(count); // initialize to true (use case knowledge: we usually want to sign all uids) - for(int i = 0; i < count; i++) + for (int i = 0; i < count; i++) { mCheckStates.add(true); + } } } @@ -100,8 +101,9 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter { vAddress.setText(userId[1]); // don't care further if checkboxes aren't shown - if(mCheckStates == null) + if (mCheckStates == null) { return; + } final CheckBox vCheckBox = (CheckBox) view.findViewById(R.id.checkBox); final int position = cursor.getPosition(); @@ -124,8 +126,8 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter { public ArrayList getSelectedUserIds() { ArrayList result = new ArrayList(); - for(int i = 0; i < mCheckStates.size(); i++) { - if(mCheckStates.get(i)) { + for (int i = 0; i < mCheckStates.size(); i++) { + if (mCheckStates.get(i)) { mCursor.moveToPosition(i); result.add(mCursor.getString(mIndexUserId)); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CreateKeyDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CreateKeyDialogFragment.java index ffb45afc5..ad558a81e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CreateKeyDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CreateKeyDialogFragment.java @@ -138,9 +138,10 @@ public class CreateKeyDialogFragment extends DialogFragment { final AdapterView.OnItemSelectedListener weakRsaListener = new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { - final Choice selectedAlgorithm = (Choice)algorithm.getSelectedItem(); - final int selectedKeySize = Integer.parseInt((String)keySize.getSelectedItem()); - final boolean isWeakRsa = (selectedAlgorithm.getId() == Id.choice.algorithm.rsa && selectedKeySize <= 1024); + final Choice selectedAlgorithm = (Choice) algorithm.getSelectedItem(); + final int selectedKeySize = Integer.parseInt((String) keySize.getSelectedItem()); + final boolean isWeakRsa = (selectedAlgorithm.getId() == Id.choice.algorithm.rsa && + selectedKeySize <= 1024); alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(!isWeakRsa); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java index 3ff88aa2b..60dea2a41 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java @@ -184,12 +184,10 @@ public class DeleteKeyDialogFragment extends DialogFragment { if (cursor == null || cursor.getCount() == 0 || !checkDeleteSecret.isChecked()) { isSuccessfullyDeleted = true; } - } finally { if (cursor != null) { cursor.close(); } - } dismiss(); @@ -200,9 +198,7 @@ public class DeleteKeyDialogFragment extends DialogFragment { sendMessageToHandler(MESSAGE_ERROR, null); } } - - } - ); + }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override @@ -232,5 +228,4 @@ public class DeleteKeyDialogFragment extends DialogFragment { Log.w(Constants.TAG, "Messenger is null!", e); } } - -} \ No newline at end of file +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/FoldableLinearLayout.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/FoldableLinearLayout.java index f9a5b92f3..6b2f3bf06 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/FoldableLinearLayout.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/FoldableLinearLayout.java @@ -82,7 +82,7 @@ public class FoldableLinearLayout extends LinearLayout { * @param attrs */ private void processAttributes(Context context, AttributeSet attrs) { - if(attrs != null) { + if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FoldableLinearLayout, 0, 0); mFoldedIconName = a.getString(R.styleable.FoldableLinearLayout_foldedIcon); @@ -102,7 +102,7 @@ public class FoldableLinearLayout extends LinearLayout { protected void onFinishInflate() { // if the migration has already happened // there is no need to move any children - if(!mHasMigrated) { + if (!mHasMigrated) { migrateChildrenToContainer(); mHasMigrated = true; } @@ -120,10 +120,10 @@ public class FoldableLinearLayout extends LinearLayout { int childNum = getChildCount(); View[] children = new View[childNum]; - for(int i = 0; i < childNum; i++) { + for (int i = 0; i < childNum; i++) { children[i] = getChildAt(i); } - if(children[0].getId() == R.id.foldableControl) { + if (children[0].getId() == R.id.foldableControl) { } @@ -131,14 +131,14 @@ public class FoldableLinearLayout extends LinearLayout { detachAllViewsFromParent(); // Inflate the inner foldable_linearlayout.xml - LayoutInflater inflator = (LayoutInflater)getContext().getSystemService( + LayoutInflater inflator = (LayoutInflater) getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE); mFoldableLayout = inflator.inflate(R.layout.foldable_linearlayout, this, true); mFoldableContainer = (LinearLayout) mFoldableLayout.findViewById(R.id.foldableContainer); // Push previously collected children into foldableContainer. - for(int i = 0; i < childNum; i++) { + for (int i = 0; i < childNum; i++) { addView(children[i]); } } @@ -196,7 +196,7 @@ public class FoldableLinearLayout extends LinearLayout { */ @Override public void addView(View child) { - if(mFoldableContainer != null) { + if (mFoldableContainer != null) { mFoldableContainer.addView(child); } } 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 f4dad3edf..1f5b13c83 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 @@ -148,7 +148,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { date = new GregorianCalendar(TimeZone.getTimeZone("UTC")); } /* - * Using custom DatePickerDialog which overrides the setTitle because + * Using custom DatePickerDialog which overrides the setTitle because * the DatePickerDialog title is buggy (unix warparound bug). * See: https://code.google.com/p/android/issues/detail?id=49066 */ @@ -221,23 +221,23 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { boolean isDSAKey = (key.getPublicKey().getAlgorithm() == PGPPublicKey.DSA); if (isElGamalKey) { mChkSign.setVisibility(View.INVISIBLE); - TableLayout table = (TableLayout)findViewById(R.id.table_keylayout); - TableRow row = (TableRow)findViewById(R.id.row_sign); + TableLayout table = (TableLayout) findViewById(R.id.table_keylayout); + TableRow row = (TableRow) findViewById(R.id.row_sign); table.removeView(row); } if (isDSAKey) { mChkEncrypt.setVisibility(View.INVISIBLE); - TableLayout table = (TableLayout)findViewById(R.id.table_keylayout); - TableRow row = (TableRow)findViewById(R.id.row_encrypt); + TableLayout table = (TableLayout) findViewById(R.id.table_keylayout); + TableRow row = (TableRow) findViewById(R.id.row_encrypt); table.removeView(row); } if (!mIsMasterKey) { mChkCertify.setVisibility(View.INVISIBLE); - TableLayout table = (TableLayout)findViewById(R.id.table_keylayout); - TableRow row = (TableRow)findViewById(R.id.row_certify); + TableLayout table = (TableLayout) findViewById(R.id.table_keylayout); + TableRow row = (TableRow) findViewById(R.id.row_certify); table.removeView(row); } else { - TextView mLabelUsage2= (TextView) findViewById(R.id.label_usage2); + TextView mLabelUsage2 = (TextView) findViewById(R.id.label_usage2); mLabelUsage2.setVisibility(View.INVISIBLE); } 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 c04cc7674..272f43915 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 @@ -195,8 +195,8 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor for (int i = 0; i < mEditors.getChildCount(); ++i) { Editor editor = (Editor) mEditors.getChildAt(i); if (mType == Id.type.user_id) { - if(((UserIdEditor)editor).getIsOriginallyMainUserID()) { - return ((UserIdEditor)editor).getOriginalID(); + if (((UserIdEditor) editor).getIsOriginallyMainUserID()) { + return ((UserIdEditor) editor).getOriginalID(); } } } 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 52a78f9ad..71f5f0d86 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 @@ -239,9 +239,9 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene @Override public boolean needsSaving() { boolean retval = false; //(mOriginallyMainUserID != isMainUserId()); - retval |= !(mOriginalName.equals( ("" + mName.getText()).trim() ) ); - retval |= !(mOriginalEmail.equals( ("" + mEmail.getText()).trim() ) ); - retval |= !(mOriginalComment.equals( ("" + mComment.getText()).trim() ) ); + retval |= !(mOriginalName.equals(("" + mName.getText()).trim())); + retval |= !(mOriginalEmail.equals(("" + mEmail.getText()).trim())); + retval |= !(mOriginalComment.equals(("" + mComment.getText()).trim())); retval |= mIsNewId; return retval; } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/IterableIterator.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/IterableIterator.java index 40105df4f..3af674526 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/IterableIterator.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/IterableIterator.java @@ -24,7 +24,7 @@ public class IterableIterator implements Iterable { public IterableIterator(Iterator iter, boolean failsafe) { mIter = iter; - if(failsafe && mIter == null) { + if (failsafe && mIter == null) { // is there a better way? mIter = new ArrayList().iterator(); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/ProgressScaler.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/ProgressScaler.java index 15b70e22e..23961c05f 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/ProgressScaler.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/ProgressScaler.java @@ -36,7 +36,7 @@ public class ProgressScaler implements ProgressDialogUpdater { * Set progressDialogUpdater of ProgressDialog by sending message to handler on UI thread */ public void setProgress(String message, int progress, int max) { - mWrapped.setProgress(message, mFrom+ progress*(mTo-mFrom)/max, mMax); + mWrapped.setProgress(message, mFrom + progress * (mTo - mFrom) / max, mMax); } public void setProgress(int resourceId, int progress, int max) {