Trivial spacing changes to conform to style guide

This commit is contained in:
Thialfihar 2014-04-02 01:43:40 +02:00
parent 8e503bd263
commit dd4a1e3f52
29 changed files with 87 additions and 85 deletions

View File

@ -41,14 +41,14 @@ public class KeychainApplication extends Application {
/* /*
* Sets Bouncy (Spongy) Castle as preferred security provider * Sets Bouncy (Spongy) Castle as preferred security provider
* *
* insertProviderAt() position starts from 1 * insertProviderAt() position starts from 1
*/ */
Security.insertProviderAt(new BouncyCastleProvider(), 1); Security.insertProviderAt(new BouncyCastleProvider(), 1);
/* /*
* apply RNG fixes * apply RNG fixes
* *
* among other things, executes Security.insertProviderAt(new * among other things, executes Security.insertProviderAt(new
* LinuxPRNGSecureRandomProvider(), 1) for Android <= SDK 17 * LinuxPRNGSecureRandomProvider(), 1) for Android <= SDK 17
*/ */

View File

@ -30,7 +30,7 @@ public class ClipboardReflection {
/** /**
* Wrapper around ClipboardManager based on Android version using Reflection API * Wrapper around ClipboardManager based on Android version using Reflection API
* *
* @param context * @param context
* @param text * @param text
*/ */
@ -57,7 +57,7 @@ public class ClipboardReflection {
/** /**
* Wrapper around ClipboardManager based on Android version using Reflection API * Wrapper around ClipboardManager based on Android version using Reflection API
* *
* @param context * @param context
*/ */
public static CharSequence getClipboardText(Context context) { public static CharSequence getClipboardText(Context context) {

View File

@ -75,7 +75,7 @@ public class ExportHelper {
int type = keyType; int type = keyType;
mExportFilename = data.getString(FileDialogFragment.MESSAGE_DATA_FILENAME); 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; type = Id.type.public_secret_key;
} }

View File

@ -65,14 +65,16 @@ public class PgpConversionHelper {
try { try {
while ((obj = factory.nextObject()) != null) { while ((obj = factory.nextObject()) != null) {
PGPSecretKey secKey = null; PGPSecretKey secKey = null;
if(obj instanceof PGPSecretKey) { if (obj instanceof PGPSecretKey) {
if ((secKey = (PGPSecretKey)obj ) == null) { secKey = (PGPSecretKey) obj;
if (secKey == null) {
Log.e(Constants.TAG, "No keys given!"); Log.e(Constants.TAG, "No keys given!");
} }
keys.add(secKey); 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; PGPSecretKeyRing keyRing = null;
if ((keyRing = (PGPSecretKeyRing)obj) == null) { keyRing = (PGPSecretKeyRing) obj;
if (keyRing == null) {
Log.e(Constants.TAG, "No keys given!"); Log.e(Constants.TAG, "No keys given!");
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

View File

@ -219,7 +219,7 @@ public class PgpKeyOperation {
} }
private Pair<PGPSecretKeyRing,PGPPublicKeyRing> buildNewSecretKey( private Pair<PGPSecretKeyRing, PGPPublicKeyRing> buildNewSecretKey(
ArrayList<String> userIds, ArrayList<PGPSecretKey> keys, ArrayList<String> userIds, ArrayList<PGPSecretKey> keys,
ArrayList<GregorianCalendar> keysExpiryDates, ArrayList<GregorianCalendar> keysExpiryDates,
ArrayList<Integer> keysUsages, ArrayList<Integer> keysUsages,
@ -359,11 +359,11 @@ public class PgpKeyOperation {
PGPSecretKeyRing secretKeyRing = keyGen.generateSecretKeyRing(); PGPSecretKeyRing secretKeyRing = keyGen.generateSecretKeyRing();
PGPPublicKeyRing publicKeyRing = keyGen.generatePublicKeyRing(); PGPPublicKeyRing publicKeyRing = keyGen.generatePublicKeyRing();
return new Pair<PGPSecretKeyRing,PGPPublicKeyRing>(secretKeyRing, publicKeyRing); return new Pair<PGPSecretKeyRing, PGPPublicKeyRing>(secretKeyRing, publicKeyRing);
} }
public Pair<PGPSecretKeyRing,PGPPublicKeyRing> buildSecretKey (PGPSecretKeyRing mKR, public Pair<PGPSecretKeyRing, PGPPublicKeyRing> buildSecretKey(PGPSecretKeyRing mKR,
PGPPublicKeyRing pKR, PGPPublicKeyRing pKR,
SaveKeyringParcel saveParcel) SaveKeyringParcel saveParcel)
throws PgpGeneralMsgIdException, PGPException, SignatureException, IOException { throws PgpGeneralMsgIdException, PGPException, SignatureException, IOException {
@ -676,7 +676,7 @@ public class PgpKeyOperation {
*/ */
return new Pair<PGPSecretKeyRing,PGPPublicKeyRing>(mKR, pKR); return new Pair<PGPSecretKeyRing, PGPPublicKeyRing>(mKR, pKR);
} }
@ -723,7 +723,7 @@ public class PgpKeyOperation {
} }
// fetch public key ring, add the certification and return it // fetch public key ring, add the certification and return it
for(String userId : new IterableIterator<String>(userIds.iterator())) { for (String userId : new IterableIterator<String>(userIds.iterator())) {
PGPSignature sig = signatureGenerator.generateCertification(userId, publicKey); PGPSignature sig = signatureGenerator.generateCertification(userId, publicKey);
publicKey = PGPPublicKey.addCertification(publicKey, userId, sig); publicKey = PGPPublicKey.addCertification(publicKey, userId, sig);
} }

View File

@ -508,13 +508,14 @@ public class ProviderHelper {
*/ */
public static boolean getMasterKeyCanCertify(Context context, Uri queryUri) { public static boolean getMasterKeyCanCertify(Context context, Uri queryUri) {
String[] projection = new String[]{ String[] projection = new String[] {
KeyRings.MASTER_KEY_ID, KeyRings.MASTER_KEY_ID,
"(SELECT COUNT(sign_keys." + Keys._ID + ") FROM " + Tables.KEYS "(SELECT COUNT(sign_keys." + Keys._ID + ") FROM " + Tables.KEYS
+ " AS sign_keys WHERE sign_keys." + Keys.KEY_RING_ROW_ID + " = " + " AS sign_keys WHERE sign_keys." + Keys.KEY_RING_ROW_ID + " = "
+ KeychainDatabase.Tables.KEY_RINGS + "." + KeyRings._ID + KeychainDatabase.Tables.KEY_RINGS + "." + KeyRings._ID
+ " AND sign_keys." + Keys.CAN_CERTIFY + " = '1' AND " + Keys.IS_MASTER_KEY + " AND sign_keys." + Keys.CAN_CERTIFY + " = '1' AND " + Keys.IS_MASTER_KEY
+ " = 1) AS sign",}; + " = 1) AS sign",
};
ContentResolver cr = context.getContentResolver(); ContentResolver cr = context.getContentResolver();
Cursor cursor = cr.query(queryUri, projection, null, null, null); Cursor cursor = cr.query(queryUri, projection, null, null, null);

View File

@ -95,7 +95,7 @@ public class RemoteServiceActivity extends ActionBarActivity {
if (ACTION_REGISTER.equals(action)) { if (ACTION_REGISTER.equals(action)) {
final String packageName = extras.getString(EXTRA_PACKAGE_NAME); final String packageName = extras.getString(EXTRA_PACKAGE_NAME);
final byte[] packageSignature = extras.getByteArray(EXTRA_PACKAGE_SIGNATURE); 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 // Inflate a "Done"/"Cancel" custom action bar view
ActionBarHelper.setTwoButtonView(getSupportActionBar(), ActionBarHelper.setTwoButtonView(getSupportActionBar(),

View File

@ -818,7 +818,7 @@ public class KeychainIntentService extends IntentService
return; return;
} }
// contextualize the exception, if necessary // contextualize the exception, if necessary
if(e instanceof PgpGeneralMsgIdException) { if (e instanceof PgpGeneralMsgIdException) {
e = ((PgpGeneralMsgIdException) e).getContextualized(this); e = ((PgpGeneralMsgIdException) e).getContextualized(this);
} }
Log.e(Constants.TAG, "ApgService Exception: ", e); Log.e(Constants.TAG, "ApgService Exception: ", e);

View File

@ -46,20 +46,20 @@ public class SaveKeyringParcel implements Parcelable {
public SaveKeyringParcel() {} public SaveKeyringParcel() {}
private SaveKeyringParcel(Parcel source) private SaveKeyringParcel(Parcel source) {
{ userIDs = (ArrayList<String>) source.readSerializable();
userIDs = (ArrayList<String>)source.readSerializable(); originalIDs = (ArrayList<String>) source.readSerializable();
originalIDs = (ArrayList<String>)source.readSerializable(); deletedIDs = (ArrayList<String>) source.readSerializable();
deletedIDs = (ArrayList<String>)source.readSerializable();
newIDs = source.createBooleanArray(); newIDs = source.createBooleanArray();
primaryIDChanged = source.readByte() != 0; primaryIDChanged = source.readByte() != 0;
moddedKeys = source.createBooleanArray(); moddedKeys = source.createBooleanArray();
byte[] tmp = source.createByteArray(); byte[] tmp = source.createByteArray();
if (tmp == null) if (tmp == null) {
deletedKeys = null; deletedKeys = null;
else } else {
deletedKeys = PgpConversionHelper.BytesToPGPSecretKeyList(tmp); deletedKeys = PgpConversionHelper.BytesToPGPSecretKeyList(tmp);
keysExpiryDates = (ArrayList<GregorianCalendar>)source.readSerializable(); }
keysExpiryDates = (ArrayList<GregorianCalendar>) source.readSerializable();
keysUsages = source.readArrayList(Integer.class.getClassLoader()); keysUsages = source.readArrayList(Integer.class.getClassLoader());
newPassPhrase = source.readString(); newPassPhrase = source.readString();
oldPassPhrase = source.readString(); oldPassPhrase = source.readString();

View File

@ -306,7 +306,7 @@ public class CertifyKeyActivity extends ActionBarActivity implements
// Bail out if there is not at least one user id selected // Bail out if there is not at least one user id selected
ArrayList<String> userIds = mUserIdsAdapter.getSelectedUserIds(); ArrayList<String> userIds = mUserIdsAdapter.getSelectedUserIds();
if(userIds.isEmpty()) { if (userIds.isEmpty()) {
Toast.makeText(CertifyKeyActivity.this, "No User IDs to sign selected!", Toast.makeText(CertifyKeyActivity.this, "No User IDs to sign selected!",
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
return; return;

View File

@ -205,7 +205,7 @@ public class DecryptFileFragment extends DecryptFragment {
} else { } else {
AppMsg.makeText(getActivity(), R.string.decryption_successful, AppMsg.makeText(getActivity(), R.string.decryption_successful,
AppMsg.STYLE_INFO).show(); AppMsg.STYLE_INFO).show();
if (mDeleteAfter.isChecked()) { if (mDeleteAfter.isChecked()) {
// Create and show dialog to delete original file // Create and show dialog to delete original file
DeleteFileDialogFragment deleteFileDialog = DeleteFileDialogFragment DeleteFileDialogFragment deleteFileDialog = DeleteFileDialogFragment

View File

@ -58,7 +58,7 @@ public class DrawerActivity extends ActionBarActivity {
// if the left margin of the loaded layout is close to the // if the left margin of the loaded layout is close to the
// one used in tablets then set drawer as open and locked // 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.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerList);
mDrawerLayout.setScrimColor(Color.TRANSPARENT); mDrawerLayout.setScrimColor(Color.TRANSPARENT);
mIsDrawerLocked = true; mIsDrawerLocked = true;
@ -82,7 +82,7 @@ public class DrawerActivity extends ActionBarActivity {
// enable ActionBar app icon to behave as action to toggle nav drawer // enable ActionBar app icon to behave as action to toggle nav drawer
// if the drawer is not locked // if the drawer is not locked
if ( !mIsDrawerLocked ) { if (!mIsDrawerLocked) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setHomeButtonEnabled(true);
} }
@ -109,7 +109,7 @@ public class DrawerActivity extends ActionBarActivity {
} }
}; };
if ( !mIsDrawerLocked ) { if (!mIsDrawerLocked) {
mDrawerLayout.setDrawerListener(mDrawerToggle); mDrawerLayout.setDrawerListener(mDrawerToggle);
} else { } else {
// If the drawer is locked open make it un-focusable // If the drawer is locked open make it un-focusable
@ -218,9 +218,9 @@ public class DrawerActivity extends ActionBarActivity {
// setTitle(mDrawerTitles[position]); // setTitle(mDrawerTitles[position]);
// If drawer isn't locked just close the drawer and // If drawer isn't locked just close the drawer and
// it will move to the selected item by itself (via drawer toggle listener) // it will move to the selected item by itself (via drawer toggle listener)
if ( !mIsDrawerLocked ) { if (!mIsDrawerLocked) {
mDrawerLayout.closeDrawer(mDrawerList); mDrawerLayout.closeDrawer(mDrawerList);
// else move to the selected item yourself // else move to the selected item yourself
} else { } else {
callIntentForDrawerItem(mSelectedItem); callIntentForDrawerItem(mSelectedItem);
} }

View File

@ -339,7 +339,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
Toast.makeText(this, R.string.error_save_first, Toast.LENGTH_LONG).show(); Toast.makeText(this, R.string.error_save_first, Toast.LENGTH_LONG).show();
} else { } else {
long masterKeyId = ProviderHelper.getMasterKeyId(this, mDataUri); 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, mExportHelper.showExportKeysDialog(ids, Id.type.secret_key, Constants.Path.APP_DIR_FILE_SEC,
null); null);
return true; return true;

View File

@ -112,7 +112,7 @@ public class EncryptFileFragment extends Fragment {
}); });
mFileCompression = (Spinner) view.findViewById(R.id.fileCompression); 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) + " (" new Choice(Id.choice.compression.none, getString(R.string.choice_none) + " ("
+ getString(R.string.compression_fast) + ")"), + getString(R.string.compression_fast) + ")"),
new Choice(Id.choice.compression.zip, "ZIP (" new Choice(Id.choice.compression.zip, "ZIP ("
@ -120,7 +120,8 @@ public class EncryptFileFragment extends Fragment {
new Choice(Id.choice.compression.zlib, "ZLIB (" new Choice(Id.choice.compression.zlib, "ZLIB ("
+ getString(R.string.compression_fast) + ")"), + getString(R.string.compression_fast) + ")"),
new Choice(Id.choice.compression.bzip2, "BZIP2 (" new Choice(Id.choice.compression.bzip2, "BZIP2 ("
+ getString(R.string.compression_very_slow) + ")"),}; + getString(R.string.compression_very_slow) + ")"),
};
ArrayAdapter<Choice> adapter = new ArrayAdapter<Choice>(getActivity(), ArrayAdapter<Choice> adapter = new ArrayAdapter<Choice>(getActivity(),
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);

View File

@ -65,7 +65,7 @@ public class ImportKeysClipboardFragment extends Fragment {
String sendText = ""; String sendText = "";
if (clipboardText != null) { if (clipboardText != null) {
sendText = clipboardText.toString(); 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)); mImportActivity.loadFromFingerprintUri(null, Uri.parse(sendText));
return; return;
} }

View File

@ -185,7 +185,7 @@ public class KeyListFragment extends Fragment
} }
case R.id.menu_key_list_multi_export: { case R.id.menu_key_list_multi_export: {
ids = mStickyList.getWrappedList().getCheckedItemIds(); ids = mStickyList.getWrappedList().getCheckedItemIds();
long[] masterKeyIds = new long[2*ids.length]; long[] masterKeyIds = new long[2 * ids.length];
ArrayList<Long> allPubRowIds = ArrayList<Long> allPubRowIds =
ProviderHelper.getPublicKeyRingsRowIds(getActivity()); ProviderHelper.getPublicKeyRingsRowIds(getActivity());
for (int i = 0; i < ids.length; i++) { for (int i = 0; i < ids.length; i++) {

View File

@ -141,7 +141,8 @@ public class SelectSecretKeyFragment extends ListFragment implements
+ Keys.IS_REVOKED + " = '0' AND valid_keys." + Keys.CAN_SIGN + Keys.IS_REVOKED + " = '0' AND valid_keys." + Keys.CAN_SIGN
+ " = '1' AND valid_keys." + Keys.CREATION + " <= '" + now + "' AND " + " = '1' AND valid_keys." + Keys.CREATION + " <= '" + now + "' AND "
+ "(valid_keys." + Keys.EXPIRY + " IS NULL OR valid_keys." + Keys.EXPIRY + "(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"; String orderBy = UserIds.USER_ID + " ASC";

View File

@ -53,12 +53,12 @@ public class SelectSecretKeyLayoutFragment extends Fragment implements LoaderMan
private SelectSecretKeyCallback mCallback; private SelectSecretKeyCallback mCallback;
final String[] PROJECTION = new String[]{ private static final String[] PROJECTION = new String[] {
KeychainContract.UserIds.USER_ID, KeychainContract.UserIds.USER_ID,
KeychainContract.KeyRings.MASTER_KEY_ID KeychainContract.KeyRings.MASTER_KEY_ID,
}; };
final int INDEX_USER_ID = 0; private static final int INDEX_USER_ID = 0;
final int INDEX_MASTER_KEY_ID = 1; private static final int INDEX_MASTER_KEY_ID = 1;
public interface SelectSecretKeyCallback { public interface SelectSecretKeyCallback {
void onKeySelected(long secretKeyId); void onKeySelected(long secretKeyId);

View File

@ -125,7 +125,7 @@ public class ViewKeyActivity extends ActionBarActivity {
case R.id.menu_key_view_export_file: case R.id.menu_key_view_export_file:
long masterKeyId = long masterKeyId =
ProviderHelper.getPublicMasterKeyId(this, Long.valueOf(mDataUri.getLastPathSegment())); ProviderHelper.getPublicMasterKeyId(this, Long.valueOf(mDataUri.getLastPathSegment()));
long[] ids = new long[]{masterKeyId}; long[] ids = new long[] {masterKeyId};
mExportHelper.showExportKeysDialog(ids, Id.type.public_key, mExportHelper.showExportKeysDialog(ids, Id.type.public_key,
Constants.Path.APP_DIR_FILE_PUB, null); Constants.Path.APP_DIR_FILE_PUB, null);
return true; return true;

View File

@ -148,8 +148,7 @@ public class ViewKeyKeysAdapter extends CursorAdapter {
DateFormat.getDateFormat(context).format(expiryDate) + ")"); DateFormat.getDateFormat(context).format(expiryDate) + ")");
keyExpiry.setVisibility(View.VISIBLE); keyExpiry.setVisibility(View.VISIBLE);
} } else {
else {
keyExpiry.setVisibility(View.GONE); keyExpiry.setVisibility(View.GONE);
} }
// if key is expired or revoked, strike through text // if key is expired or revoked, strike through text

View File

@ -55,14 +55,15 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter {
@Override @Override
public Cursor swapCursor(Cursor newCursor) { public Cursor swapCursor(Cursor newCursor) {
initIndex(newCursor); initIndex(newCursor);
if(mCheckStates != null) { if (mCheckStates != null) {
mCheckStates.clear(); mCheckStates.clear();
if(newCursor != null) { if (newCursor != null) {
int count = newCursor.getCount(); int count = newCursor.getCount();
mCheckStates.ensureCapacity(count); mCheckStates.ensureCapacity(count);
// initialize to true (use case knowledge: we usually want to sign all uids) // 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); mCheckStates.add(true);
}
} }
} }
@ -100,8 +101,9 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter {
vAddress.setText(userId[1]); vAddress.setText(userId[1]);
// don't care further if checkboxes aren't shown // don't care further if checkboxes aren't shown
if(mCheckStates == null) if (mCheckStates == null) {
return; return;
}
final CheckBox vCheckBox = (CheckBox) view.findViewById(R.id.checkBox); final CheckBox vCheckBox = (CheckBox) view.findViewById(R.id.checkBox);
final int position = cursor.getPosition(); final int position = cursor.getPosition();
@ -124,8 +126,8 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter {
public ArrayList<String> getSelectedUserIds() { public ArrayList<String> getSelectedUserIds() {
ArrayList<String> result = new ArrayList<String>(); ArrayList<String> result = new ArrayList<String>();
for(int i = 0; i < mCheckStates.size(); i++) { for (int i = 0; i < mCheckStates.size(); i++) {
if(mCheckStates.get(i)) { if (mCheckStates.get(i)) {
mCursor.moveToPosition(i); mCursor.moveToPosition(i);
result.add(mCursor.getString(mIndexUserId)); result.add(mCursor.getString(mIndexUserId));
} }

View File

@ -138,9 +138,10 @@ public class CreateKeyDialogFragment extends DialogFragment {
final AdapterView.OnItemSelectedListener weakRsaListener = new AdapterView.OnItemSelectedListener() { final AdapterView.OnItemSelectedListener weakRsaListener = new AdapterView.OnItemSelectedListener() {
@Override @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
final Choice selectedAlgorithm = (Choice)algorithm.getSelectedItem(); final Choice selectedAlgorithm = (Choice) algorithm.getSelectedItem();
final int selectedKeySize = Integer.parseInt((String)keySize.getSelectedItem()); final int selectedKeySize = Integer.parseInt((String) keySize.getSelectedItem());
final boolean isWeakRsa = (selectedAlgorithm.getId() == Id.choice.algorithm.rsa && selectedKeySize <= 1024); final boolean isWeakRsa = (selectedAlgorithm.getId() == Id.choice.algorithm.rsa &&
selectedKeySize <= 1024);
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(!isWeakRsa); alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(!isWeakRsa);
} }

View File

@ -184,12 +184,10 @@ public class DeleteKeyDialogFragment extends DialogFragment {
if (cursor == null || cursor.getCount() == 0 || !checkDeleteSecret.isChecked()) { if (cursor == null || cursor.getCount() == 0 || !checkDeleteSecret.isChecked()) {
isSuccessfullyDeleted = true; isSuccessfullyDeleted = true;
} }
} finally { } finally {
if (cursor != null) { if (cursor != null) {
cursor.close(); cursor.close();
} }
} }
dismiss(); dismiss();
@ -200,9 +198,7 @@ public class DeleteKeyDialogFragment extends DialogFragment {
sendMessageToHandler(MESSAGE_ERROR, null); sendMessageToHandler(MESSAGE_ERROR, null);
} }
} }
});
}
);
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override @Override
@ -232,5 +228,4 @@ public class DeleteKeyDialogFragment extends DialogFragment {
Log.w(Constants.TAG, "Messenger is null!", e); Log.w(Constants.TAG, "Messenger is null!", e);
} }
} }
}
}

View File

@ -82,7 +82,7 @@ public class FoldableLinearLayout extends LinearLayout {
* @param attrs * @param attrs
*/ */
private void processAttributes(Context context, AttributeSet attrs) { private void processAttributes(Context context, AttributeSet attrs) {
if(attrs != null) { if (attrs != null) {
TypedArray a = context.obtainStyledAttributes(attrs, TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.FoldableLinearLayout, 0, 0); R.styleable.FoldableLinearLayout, 0, 0);
mFoldedIconName = a.getString(R.styleable.FoldableLinearLayout_foldedIcon); mFoldedIconName = a.getString(R.styleable.FoldableLinearLayout_foldedIcon);
@ -102,7 +102,7 @@ public class FoldableLinearLayout extends LinearLayout {
protected void onFinishInflate() { protected void onFinishInflate() {
// if the migration has already happened // if the migration has already happened
// there is no need to move any children // there is no need to move any children
if(!mHasMigrated) { if (!mHasMigrated) {
migrateChildrenToContainer(); migrateChildrenToContainer();
mHasMigrated = true; mHasMigrated = true;
} }
@ -120,10 +120,10 @@ public class FoldableLinearLayout extends LinearLayout {
int childNum = getChildCount(); int childNum = getChildCount();
View[] children = new View[childNum]; View[] children = new View[childNum];
for(int i = 0; i < childNum; i++) { for (int i = 0; i < childNum; i++) {
children[i] = getChildAt(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(); detachAllViewsFromParent();
// Inflate the inner foldable_linearlayout.xml // Inflate the inner foldable_linearlayout.xml
LayoutInflater inflator = (LayoutInflater)getContext().getSystemService( LayoutInflater inflator = (LayoutInflater) getContext().getSystemService(
Context.LAYOUT_INFLATER_SERVICE); Context.LAYOUT_INFLATER_SERVICE);
mFoldableLayout = inflator.inflate(R.layout.foldable_linearlayout, this, true); mFoldableLayout = inflator.inflate(R.layout.foldable_linearlayout, this, true);
mFoldableContainer = (LinearLayout) mFoldableLayout.findViewById(R.id.foldableContainer); mFoldableContainer = (LinearLayout) mFoldableLayout.findViewById(R.id.foldableContainer);
// Push previously collected children into foldableContainer. // Push previously collected children into foldableContainer.
for(int i = 0; i < childNum; i++) { for (int i = 0; i < childNum; i++) {
addView(children[i]); addView(children[i]);
} }
} }
@ -196,7 +196,7 @@ public class FoldableLinearLayout extends LinearLayout {
*/ */
@Override @Override
public void addView(View child) { public void addView(View child) {
if(mFoldableContainer != null) { if (mFoldableContainer != null) {
mFoldableContainer.addView(child); mFoldableContainer.addView(child);
} }
} }

View File

@ -148,7 +148,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
date = new GregorianCalendar(TimeZone.getTimeZone("UTC")); 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). * the DatePickerDialog title is buggy (unix warparound bug).
* See: https://code.google.com/p/android/issues/detail?id=49066 * 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); boolean isDSAKey = (key.getPublicKey().getAlgorithm() == PGPPublicKey.DSA);
if (isElGamalKey) { if (isElGamalKey) {
mChkSign.setVisibility(View.INVISIBLE); mChkSign.setVisibility(View.INVISIBLE);
TableLayout table = (TableLayout)findViewById(R.id.table_keylayout); TableLayout table = (TableLayout) findViewById(R.id.table_keylayout);
TableRow row = (TableRow)findViewById(R.id.row_sign); TableRow row = (TableRow) findViewById(R.id.row_sign);
table.removeView(row); table.removeView(row);
} }
if (isDSAKey) { if (isDSAKey) {
mChkEncrypt.setVisibility(View.INVISIBLE); mChkEncrypt.setVisibility(View.INVISIBLE);
TableLayout table = (TableLayout)findViewById(R.id.table_keylayout); TableLayout table = (TableLayout) findViewById(R.id.table_keylayout);
TableRow row = (TableRow)findViewById(R.id.row_encrypt); TableRow row = (TableRow) findViewById(R.id.row_encrypt);
table.removeView(row); table.removeView(row);
} }
if (!mIsMasterKey) { if (!mIsMasterKey) {
mChkCertify.setVisibility(View.INVISIBLE); mChkCertify.setVisibility(View.INVISIBLE);
TableLayout table = (TableLayout)findViewById(R.id.table_keylayout); TableLayout table = (TableLayout) findViewById(R.id.table_keylayout);
TableRow row = (TableRow)findViewById(R.id.row_certify); TableRow row = (TableRow) findViewById(R.id.row_certify);
table.removeView(row); table.removeView(row);
} else { } else {
TextView mLabelUsage2= (TextView) findViewById(R.id.label_usage2); TextView mLabelUsage2 = (TextView) findViewById(R.id.label_usage2);
mLabelUsage2.setVisibility(View.INVISIBLE); mLabelUsage2.setVisibility(View.INVISIBLE);
} }

View File

@ -195,8 +195,8 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
for (int i = 0; i < mEditors.getChildCount(); ++i) { for (int i = 0; i < mEditors.getChildCount(); ++i) {
Editor editor = (Editor) mEditors.getChildAt(i); Editor editor = (Editor) mEditors.getChildAt(i);
if (mType == Id.type.user_id) { if (mType == Id.type.user_id) {
if(((UserIdEditor)editor).getIsOriginallyMainUserID()) { if (((UserIdEditor) editor).getIsOriginallyMainUserID()) {
return ((UserIdEditor)editor).getOriginalID(); return ((UserIdEditor) editor).getOriginalID();
} }
} }
} }

View File

@ -239,9 +239,9 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene
@Override @Override
public boolean needsSaving() { public boolean needsSaving() {
boolean retval = false; //(mOriginallyMainUserID != isMainUserId()); boolean retval = false; //(mOriginallyMainUserID != isMainUserId());
retval |= !(mOriginalName.equals( ("" + mName.getText()).trim() ) ); retval |= !(mOriginalName.equals(("" + mName.getText()).trim()));
retval |= !(mOriginalEmail.equals( ("" + mEmail.getText()).trim() ) ); retval |= !(mOriginalEmail.equals(("" + mEmail.getText()).trim()));
retval |= !(mOriginalComment.equals( ("" + mComment.getText()).trim() ) ); retval |= !(mOriginalComment.equals(("" + mComment.getText()).trim()));
retval |= mIsNewId; retval |= mIsNewId;
return retval; return retval;
} }

View File

@ -24,7 +24,7 @@ public class IterableIterator<T> implements Iterable<T> {
public IterableIterator(Iterator<T> iter, boolean failsafe) { public IterableIterator(Iterator<T> iter, boolean failsafe) {
mIter = iter; mIter = iter;
if(failsafe && mIter == null) { if (failsafe && mIter == null) {
// is there a better way? // is there a better way?
mIter = new ArrayList<T>().iterator(); mIter = new ArrayList<T>().iterator();
} }

View File

@ -36,7 +36,7 @@ public class ProgressScaler implements ProgressDialogUpdater {
* Set progressDialogUpdater of ProgressDialog by sending message to handler on UI thread * Set progressDialogUpdater of ProgressDialog by sending message to handler on UI thread
*/ */
public void setProgress(String message, int progress, int max) { 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) { public void setProgress(int resourceId, int progress, int max) {