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
*
*
* 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
*/

View File

@ -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) {

View File

@ -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;
}

View File

@ -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")

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<GregorianCalendar> keysExpiryDates,
ArrayList<Integer> keysUsages,
@ -359,11 +359,11 @@ public class PgpKeyOperation {
PGPSecretKeyRing secretKeyRing = keyGen.generateSecretKeyRing();
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,
SaveKeyringParcel saveParcel)
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
for(String userId : new IterableIterator<String>(userIds.iterator())) {
for (String userId : new IterableIterator<String>(userIds.iterator())) {
PGPSignature sig = signatureGenerator.generateCertification(userId, publicKey);
publicKey = PGPPublicKey.addCertification(publicKey, userId, sig);
}

View File

@ -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);

View File

@ -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(),

View File

@ -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);

View File

@ -46,20 +46,20 @@ public class SaveKeyringParcel implements Parcelable {
public SaveKeyringParcel() {}
private SaveKeyringParcel(Parcel source)
{
userIDs = (ArrayList<String>)source.readSerializable();
originalIDs = (ArrayList<String>)source.readSerializable();
deletedIDs = (ArrayList<String>)source.readSerializable();
private SaveKeyringParcel(Parcel source) {
userIDs = (ArrayList<String>) source.readSerializable();
originalIDs = (ArrayList<String>) source.readSerializable();
deletedIDs = (ArrayList<String>) 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<GregorianCalendar>)source.readSerializable();
}
keysExpiryDates = (ArrayList<GregorianCalendar>) source.readSerializable();
keysUsages = source.readArrayList(Integer.class.getClassLoader());
newPassPhrase = 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
ArrayList<String> userIds = mUserIdsAdapter.getSelectedUserIds();
if(userIds.isEmpty()) {
if (userIds.isEmpty()) {
Toast.makeText(CertifyKeyActivity.this, "No User IDs to sign selected!",
Toast.LENGTH_SHORT).show();
return;

View File

@ -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

View File

@ -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);
}

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();
} 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;

View File

@ -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<Choice> adapter = new ArrayAdapter<Choice>(getActivity(),
android.R.layout.simple_spinner_item, choices);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

View File

@ -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;
}

View File

@ -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<Long> allPubRowIds =
ProviderHelper.getPublicKeyRingsRowIds(getActivity());
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
+ " = '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";

View File

@ -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);

View File

@ -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;

View File

@ -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

View File

@ -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<String> getSelectedUserIds() {
ArrayList<String> result = new ArrayList<String>();
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));
}

View File

@ -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);
}

View File

@ -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);
}
}
}
}

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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();
}
}
}

View File

@ -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;
}

View File

@ -24,7 +24,7 @@ public class IterableIterator<T> implements Iterable<T> {
public IterableIterator(Iterator<T> iter, boolean failsafe) {
mIter = iter;
if(failsafe && mIter == null) {
if (failsafe && mIter == null) {
// is there a better way?
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
*/
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) {