Adjust variable/member naming to conform to style guide

In some cases change member accessibility, so the naming matches.
Also, some key words were reordered to comply with JLS suggestions.
This commit is contained in:
Thialfihar 2014-04-02 01:51:02 +02:00
parent dd4a1e3f52
commit d5983b324f
11 changed files with 82 additions and 79 deletions

View File

@ -30,7 +30,7 @@ import java.util.Vector;
* Singleton Implementation of a Preference Helper
*/
public class Preferences {
private static Preferences mPreferences;
private static Preferences sPreferences;
private SharedPreferences mSharedPreferences;
public static synchronized Preferences getPreferences(Context context) {
@ -38,10 +38,10 @@ public class Preferences {
}
public static synchronized Preferences getPreferences(Context context, boolean forceNew) {
if (mPreferences == null || forceNew) {
mPreferences = new Preferences(context);
if (sPreferences == null || forceNew) {
sPreferences = new Preferences(context);
}
return mPreferences;
return sPreferences;
}
private Preferences(Context context) {

View File

@ -22,14 +22,14 @@ import android.content.Context;
public class PgpGeneralMsgIdException extends Exception {
static final long serialVersionUID = 0xf812773343L;
private final int msgId;
private final int mMessageId;
public PgpGeneralMsgIdException(int msgId) {
super("msg[" + msgId + "]");
this.msgId = msgId;
public PgpGeneralMsgIdException(int messageId) {
super("msg[" + messageId + "]");
mMessageId = messageId;
}
public PgpGeneralException getContextualized(Context context) {
return new PgpGeneralException(context.getString(msgId), this);
return new PgpGeneralException(context.getString(mMessageId), this);
}
}

View File

@ -264,8 +264,8 @@ public class EncryptAsymmetricFragment extends Fragment {
case RESULT_CODE_SECRET_KEYS: {
if (resultCode == Activity.RESULT_OK) {
Uri uri_master_key = data.getData();
setSignatureKeyId(Long.valueOf(uri_master_key.getLastPathSegment()));
Uri uriMasterKey = data.getData();
setSignatureKeyId(Long.valueOf(uriMasterKey.getLastPathSegment()));
} else {
setSignatureKeyId(Id.key.none);
}

View File

@ -38,11 +38,11 @@ public class PreferencesActivity extends PreferenceActivity {
public static final String ACTION_PREFS_ADV = "org.sufficientlysecure.keychain.ui.PREFS_ADV";
private PreferenceScreen mKeyServerPreference = null;
private static Preferences mPreferences;
private static Preferences sPreferences;
@Override
protected void onCreate(Bundle savedInstanceState) {
mPreferences = Preferences.getPreferences(this);
sPreferences = Preferences.getPreferences(this);
super.onCreate(savedInstanceState);
// final ActionBar actionBar = getSupportActionBar();
@ -59,7 +59,7 @@ public class PreferencesActivity extends PreferenceActivity {
(IntegerListPreference) findPreference(Constants.Pref.PASS_PHRASE_CACHE_TTL));
mKeyServerPreference = (PreferenceScreen) findPreference(Constants.Pref.KEY_SERVERS);
String servers[] = mPreferences.getKeyServers();
String servers[] = sPreferences.getKeyServers();
mKeyServerPreference.setSummary(getResources().getQuantityString(R.plurals.n_key_servers,
servers.length, servers.length));
mKeyServerPreference
@ -68,7 +68,7 @@ public class PreferencesActivity extends PreferenceActivity {
Intent intent = new Intent(PreferencesActivity.this,
PreferencesKeyServerActivity.class);
intent.putExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS,
mPreferences.getKeyServers());
sPreferences.getKeyServers());
startActivityForResult(intent, Id.request.key_server_preference);
return false;
}
@ -125,7 +125,7 @@ public class PreferencesActivity extends PreferenceActivity {
}
String servers[] = data
.getStringArrayExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS);
mPreferences.setKeyServers(servers);
sPreferences.setKeyServers(servers);
mKeyServerPreference.setSummary(getResources().getQuantityString(
R.plurals.n_key_servers, servers.length, servers.length));
break;
@ -163,7 +163,7 @@ public class PreferencesActivity extends PreferenceActivity {
(IntegerListPreference) findPreference(Constants.Pref.PASS_PHRASE_CACHE_TTL));
mKeyServerPreference = (PreferenceScreen) findPreference(Constants.Pref.KEY_SERVERS);
String servers[] = mPreferences.getKeyServers();
String servers[] = sPreferences.getKeyServers();
mKeyServerPreference.setSummary(getResources().getQuantityString(R.plurals.n_key_servers,
servers.length, servers.length));
mKeyServerPreference
@ -172,7 +172,7 @@ public class PreferencesActivity extends PreferenceActivity {
Intent intent = new Intent(getActivity(),
PreferencesKeyServerActivity.class);
intent.putExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS,
mPreferences.getKeyServers());
sPreferences.getKeyServers());
startActivityForResult(intent, Id.request.key_server_preference);
return false;
}
@ -188,7 +188,7 @@ public class PreferencesActivity extends PreferenceActivity {
}
String servers[] = data
.getStringArrayExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS);
mPreferences.setKeyServers(servers);
sPreferences.setKeyServers(servers);
mKeyServerPreference.setSummary(getResources().getQuantityString(
R.plurals.n_key_servers, servers.length, servers.length));
break;
@ -256,14 +256,14 @@ public class PreferencesActivity extends PreferenceActivity {
}
private static void initializePassPassPhraceCacheTtl(final IntegerListPreference mPassphraseCacheTtl) {
mPassphraseCacheTtl.setValue("" + mPreferences.getPassPhraseCacheTtl());
mPassphraseCacheTtl.setValue("" + sPreferences.getPassPhraseCacheTtl());
mPassphraseCacheTtl.setSummary(mPassphraseCacheTtl.getEntry());
mPassphraseCacheTtl
.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
mPassphraseCacheTtl.setValue(newValue.toString());
mPassphraseCacheTtl.setSummary(mPassphraseCacheTtl.getEntry());
mPreferences.setPassPhraseCacheTtl(Integer.parseInt(newValue.toString()));
sPreferences.setPassPhraseCacheTtl(Integer.parseInt(newValue.toString()));
return false;
}
});
@ -282,14 +282,14 @@ public class PreferencesActivity extends PreferenceActivity {
}
mEncryptionAlgorithm.setEntries(entries);
mEncryptionAlgorithm.setEntryValues(values);
mEncryptionAlgorithm.setValue("" + mPreferences.getDefaultEncryptionAlgorithm());
mEncryptionAlgorithm.setValue("" + sPreferences.getDefaultEncryptionAlgorithm());
mEncryptionAlgorithm.setSummary(mEncryptionAlgorithm.getEntry());
mEncryptionAlgorithm
.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
mEncryptionAlgorithm.setValue(newValue.toString());
mEncryptionAlgorithm.setSummary(mEncryptionAlgorithm.getEntry());
mPreferences.setDefaultEncryptionAlgorithm(Integer.parseInt(newValue
sPreferences.setDefaultEncryptionAlgorithm(Integer.parseInt(newValue
.toString()));
return false;
}
@ -309,13 +309,13 @@ public class PreferencesActivity extends PreferenceActivity {
}
mHashAlgorithm.setEntries(entries);
mHashAlgorithm.setEntryValues(values);
mHashAlgorithm.setValue("" + mPreferences.getDefaultHashAlgorithm());
mHashAlgorithm.setValue("" + sPreferences.getDefaultHashAlgorithm());
mHashAlgorithm.setSummary(mHashAlgorithm.getEntry());
mHashAlgorithm.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
mHashAlgorithm.setValue(newValue.toString());
mHashAlgorithm.setSummary(mHashAlgorithm.getEntry());
mPreferences.setDefaultHashAlgorithm(Integer.parseInt(newValue.toString()));
sPreferences.setDefaultHashAlgorithm(Integer.parseInt(newValue.toString()));
return false;
}
});
@ -326,14 +326,14 @@ public class PreferencesActivity extends PreferenceActivity {
int[] valueIds, String[] entries, String[] values) {
mMessageCompression.setEntries(entries);
mMessageCompression.setEntryValues(values);
mMessageCompression.setValue("" + mPreferences.getDefaultMessageCompression());
mMessageCompression.setValue("" + sPreferences.getDefaultMessageCompression());
mMessageCompression.setSummary(mMessageCompression.getEntry());
mMessageCompression
.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
mMessageCompression.setValue(newValue.toString());
mMessageCompression.setSummary(mMessageCompression.getEntry());
mPreferences.setDefaultMessageCompression(Integer.parseInt(newValue
sPreferences.setDefaultMessageCompression(Integer.parseInt(newValue
.toString()));
return false;
}
@ -344,36 +344,36 @@ public class PreferencesActivity extends PreferenceActivity {
(final IntegerListPreference mFileCompression, String[] entries, String[] values) {
mFileCompression.setEntries(entries);
mFileCompression.setEntryValues(values);
mFileCompression.setValue("" + mPreferences.getDefaultFileCompression());
mFileCompression.setValue("" + sPreferences.getDefaultFileCompression());
mFileCompression.setSummary(mFileCompression.getEntry());
mFileCompression.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
mFileCompression.setValue(newValue.toString());
mFileCompression.setSummary(mFileCompression.getEntry());
mPreferences.setDefaultFileCompression(Integer.parseInt(newValue.toString()));
sPreferences.setDefaultFileCompression(Integer.parseInt(newValue.toString()));
return false;
}
});
}
private static void initializeAsciiArmour(final CheckBoxPreference mAsciiArmour) {
mAsciiArmour.setChecked(mPreferences.getDefaultAsciiArmour());
mAsciiArmour.setChecked(sPreferences.getDefaultAsciiArmour());
mAsciiArmour.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
mAsciiArmour.setChecked((Boolean) newValue);
mPreferences.setDefaultAsciiArmour((Boolean) newValue);
sPreferences.setDefaultAsciiArmour((Boolean) newValue);
return false;
}
});
}
private static void initializeForceV3Signatures(final CheckBoxPreference mForceV3Signatures) {
mForceV3Signatures.setChecked(mPreferences.getForceV3Signatures());
mForceV3Signatures.setChecked(sPreferences.getForceV3Signatures());
mForceV3Signatures
.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
mForceV3Signatures.setChecked((Boolean) newValue);
mPreferences.setForceV3Signatures((Boolean) newValue);
sPreferences.setForceV3Signatures((Boolean) newValue);
return false;
}
});

View File

@ -44,12 +44,12 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
protected List<ImportKeysListEntry> mData;
static class ViewHolder {
private TextView mainUserId;
private TextView mainUserIdRest;
private TextView keyId;
private TextView fingerprint;
private TextView algorithm;
private TextView status;
public TextView mainUserId;
public TextView mainUserIdRest;
public TextView keyId;
public TextView fingerprint;
public TextView algorithm;
public TextView status;
}
public ImportKeysAdapter(Activity activity) {

View File

@ -249,7 +249,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
/**
* Based on <a href="http://tools.ietf.org/html/rfc2440#section-9.1">OpenPGP Message Format</a>
*/
private final static SparseArray<String> ALGORITHM_IDS = new SparseArray<String>() {{
private static final SparseArray<String> ALGORITHM_IDS = new SparseArray<String>() {{
put(-1, "unknown"); // TODO: with resources
put(0, "unencrypted");
put(PGPPublicKey.RSA_GENERAL, "RSA");

View File

@ -30,9 +30,9 @@ public class PagerTabStripAdapter extends FragmentPagerAdapter {
private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
static final class TabInfo {
private final Class<?> clss;
private final Bundle args;
private final String title;
public final Class<?> clss;
public final Bundle args;
public final String title;
TabInfo(Class<?> clss, Bundle args, String title) {
this.clss = clss;

View File

@ -36,8 +36,8 @@ public class TabsAdapter extends FragmentStatePagerAdapter implements ActionBar.
private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
static final class TabInfo {
private final Class<?> clss;
private final Bundle args;
public final Class<?> clss;
public final Bundle args;
TabInfo(Class<?> clss, Bundle args) {
this.clss = clss;

View File

@ -37,7 +37,7 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter {
private int mIndexUserId, mIndexRank;
final private ArrayList<Boolean> mCheckStates;
private final ArrayList<Boolean> mCheckStates;
public ViewKeyUserIdsAdapter(Context context, Cursor c, int flags, boolean showCheckBoxes) {
super(context, c, flags);

View File

@ -51,12 +51,12 @@ public class DeleteKeyDialogFragment extends DialogFragment {
public static final int MESSAGE_OKAY = 1;
public static final int MESSAGE_ERROR = 0;
private boolean isSingleSelection = false;
private boolean mIsSingleSelection = false;
private TextView mainMessage;
private CheckBox checkDeleteSecret;
private LinearLayout deleteSecretKeyView;
private View inflateView;
private TextView mMainMessage;
private CheckBox mCheckDeleteSecret;
private LinearLayout mDeleteSecretKeyView;
private View mInflateView;
private Messenger mMessenger;
@ -90,12 +90,12 @@ public class DeleteKeyDialogFragment extends DialogFragment {
//Setup custom View to display in AlertDialog
LayoutInflater inflater = activity.getLayoutInflater();
inflateView = inflater.inflate(R.layout.view_key_delete_fragment, null);
builder.setView(inflateView);
mInflateView = inflater.inflate(R.layout.view_key_delete_fragment, null);
builder.setView(mInflateView);
deleteSecretKeyView = (LinearLayout) inflateView.findViewById(R.id.deleteSecretKeyView);
mainMessage = (TextView) inflateView.findViewById(R.id.mainMessage);
checkDeleteSecret = (CheckBox) inflateView.findViewById(R.id.checkDeleteSecret);
mDeleteSecretKeyView = (LinearLayout) mInflateView.findViewById(R.id.deleteSecretKeyView);
mMainMessage = (TextView) mInflateView.findViewById(R.id.mainMessage);
mCheckDeleteSecret = (CheckBox) mInflateView.findViewById(R.id.checkDeleteSecret);
builder.setTitle(R.string.warning);
@ -103,7 +103,7 @@ public class DeleteKeyDialogFragment extends DialogFragment {
if (keyRingRowIds.length == 1) {
Uri dataUri;
ArrayList<Long> publicKeyRings; //Any one will do
isSingleSelection = true;
mIsSingleSelection = true;
long selectedRow = keyRingRowIds[0];
long keyType;
@ -119,16 +119,16 @@ public class DeleteKeyDialogFragment extends DialogFragment {
}
String userId = ProviderHelper.getUserId(activity, dataUri);
//Hide the Checkbox and TextView since this is a single selection,user will be notified thru message
deleteSecretKeyView.setVisibility(View.GONE);
//Set message depending on which key it is.
mainMessage.setText(getString(keyType == Id.type.secret_key ? R.string.secret_key_deletion_confirmation
: R.string.public_key_deletetion_confirmation, userId));
// Hide the Checkbox and TextView since this is a single selection,
// user will be notified thru message
mDeleteSecretKeyView.setVisibility(View.GONE);
// Set message depending on which key it is.
mMainMessage.setText(getString(keyType == Id.type.secret_key ?
R.string.secret_key_deletion_confirmation :
R.string.public_key_deletetion_confirmation, userId));
} else {
deleteSecretKeyView.setVisibility(View.VISIBLE);
mainMessage.setText(R.string.key_deletion_confirmation_multi);
mDeleteSecretKeyView.setVisibility(View.VISIBLE);
mMainMessage.setText(R.string.key_deletion_confirmation_multi);
}
@ -171,8 +171,9 @@ public class DeleteKeyDialogFragment extends DialogFragment {
if (keyType == KeychainContract.KeyTypes.SECRET) {
if (checkDeleteSecret.isChecked() || isSingleSelection) {
ProviderHelper.deleteUnifiedKeyRing(activity, String.valueOf(masterKeyId), true);
if (mCheckDeleteSecret.isChecked() || mIsSingleSelection) {
ProviderHelper.deleteUnifiedKeyRing(activity,
String.valueOf(masterKeyId), true);
}
} else {
ProviderHelper.deleteUnifiedKeyRing(activity, String.valueOf(masterKeyId), false);
@ -180,8 +181,10 @@ public class DeleteKeyDialogFragment extends DialogFragment {
}
//Check if the selected rows have actually been deleted
cursor = activity.getContentResolver().query(queryUri, projection, selection, null, null);
if (cursor == null || cursor.getCount() == 0 || !checkDeleteSecret.isChecked()) {
cursor = activity.getContentResolver().query(
queryUri, projection, selection, null, null);
if (cursor == null || cursor.getCount() == 0 ||
!mCheckDeleteSecret.isChecked()) {
isSuccessfullyDeleted = true;
}
} finally {

View File

@ -61,7 +61,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
private Choice mNewKeyAlgorithmChoice;
private int mNewKeySize;
private boolean oldItemDeleted = false;
private boolean mOldItemDeleted = false;
private ArrayList<String> mDeletedIDs = new ArrayList<String>();
private ArrayList<PGPSecretKey> mDeletedKeys = new ArrayList<PGPSecretKey>();
private boolean mCanEdit = true;
@ -138,13 +138,13 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
* {@inheritDoc}
*/
public void onDeleted(Editor editor, boolean wasNewItem) {
oldItemDeleted |= !wasNewItem;
if (oldItemDeleted) {
if (mType == Id.type.user_id)
mDeletedIDs.add(((UserIdEditor)editor).getOriginalID());
else if (mType == Id.type.key)
mDeletedKeys.add(((KeyEditor)editor).getValue());
mOldItemDeleted |= !wasNewItem;
if (mOldItemDeleted) {
if (mType == Id.type.user_id) {
mDeletedIDs.add(((UserIdEditor) editor).getOriginalID());
} else if (mType == Id.type.key) {
mDeletedKeys.add(((KeyEditor) editor).getValue());
}
}
this.updateEditorsVisible();
if (mEditorListener != null) {
@ -167,7 +167,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
public boolean needsSaving()
{
//check each view for needs saving, take account of deleted items
boolean ret = oldItemDeleted;
boolean ret = mOldItemDeleted;
for (int i = 0; i < mEditors.getChildCount(); ++i) {
Editor editor = (Editor) mEditors.getChildAt(i);
ret |= editor.needsSaving();