mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-02-17 07:30:14 -05:00
More code style fixes for /ui
This commit is contained in:
parent
37c81400ac
commit
dc5c34ffc5
@ -98,7 +98,7 @@ public class EditKeyActivity extends ActionBarActivity {
|
||||
Vector<String> mUserIds;
|
||||
Vector<PGPSecretKey> mKeys;
|
||||
Vector<Integer> mKeysUsages;
|
||||
boolean masterCanSign = true;
|
||||
boolean mMasterCanSign = true;
|
||||
|
||||
ExportHelper mExportHelper;
|
||||
|
||||
@ -264,8 +264,8 @@ public class EditKeyActivity extends ActionBarActivity {
|
||||
// get master key id using row id
|
||||
long masterKeyId = ProviderHelper.getMasterKeyId(this, mDataUri);
|
||||
|
||||
masterCanSign = ProviderHelper.getMasterKeyCanSign(this, mDataUri);
|
||||
finallyEdit(masterKeyId, masterCanSign);
|
||||
mMasterCanSign = ProviderHelper.getMasterKeyCanSign(this, mDataUri);
|
||||
finallyEdit(masterKeyId, mMasterCanSign);
|
||||
}
|
||||
}
|
||||
|
||||
@ -432,12 +432,12 @@ public class EditKeyActivity extends ActionBarActivity {
|
||||
LinearLayout container = (LinearLayout) findViewById(R.id.edit_key_container);
|
||||
mUserIdsView = (SectionView) inflater.inflate(R.layout.edit_key_section, container, false);
|
||||
mUserIdsView.setType(Id.type.user_id);
|
||||
mUserIdsView.setCanEdit(masterCanSign);
|
||||
mUserIdsView.setCanEdit(mMasterCanSign);
|
||||
mUserIdsView.setUserIds(mUserIds);
|
||||
container.addView(mUserIdsView);
|
||||
mKeysView = (SectionView) inflater.inflate(R.layout.edit_key_section, container, false);
|
||||
mKeysView.setType(Id.type.key);
|
||||
mKeysView.setCanEdit(masterCanSign);
|
||||
mKeysView.setCanEdit(mMasterCanSign);
|
||||
mKeysView.setKeys(mKeys, mKeysUsages);
|
||||
container.addView(mKeysView);
|
||||
|
||||
@ -493,12 +493,13 @@ public class EditKeyActivity extends ActionBarActivity {
|
||||
}
|
||||
|
||||
String passphrase = null;
|
||||
if (mIsPassPhraseSet)
|
||||
if (mIsPassPhraseSet) {
|
||||
passphrase = PassphraseCacheService.getCachedPassphrase(this, masterKeyId);
|
||||
else
|
||||
} else {
|
||||
passphrase = "";
|
||||
}
|
||||
if (passphrase == null) {
|
||||
showPassphraseDialog(masterKeyId, masterCanSign);
|
||||
showPassphraseDialog(masterKeyId, mMasterCanSign);
|
||||
} else {
|
||||
mCurrentPassphrase = passphrase;
|
||||
finallySaveClicked();
|
||||
@ -531,7 +532,7 @@ public class EditKeyActivity extends ActionBarActivity {
|
||||
data.putSerializable(KeychainIntentService.SAVE_KEYRING_KEYS_EXPIRY_DATES,
|
||||
getKeysExpiryDates(mKeysView));
|
||||
data.putLong(KeychainIntentService.SAVE_KEYRING_MASTER_KEY_ID, getMasterKeyId());
|
||||
data.putBoolean(KeychainIntentService.SAVE_KEYRING_CAN_SIGN, masterCanSign);
|
||||
data.putBoolean(KeychainIntentService.SAVE_KEYRING_CAN_SIGN, mMasterCanSign);
|
||||
|
||||
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
|
||||
|
||||
|
@ -76,4 +76,4 @@ public class HelpActivity extends ActionBarActivity {
|
||||
mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.help_tab_about)),
|
||||
HelpAboutFragment.class, null, (selectedTab == 4));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,8 +58,9 @@ public class ImportKeysClipboardFragment extends Fragment {
|
||||
public void onClick(View v) {
|
||||
CharSequence clipboardText = ClipboardReflection.getClipboardText(getActivity());
|
||||
String sendText = "";
|
||||
if (clipboardText != null)
|
||||
if (clipboardText != null) {
|
||||
sendText = clipboardText.toString();
|
||||
}
|
||||
mImportActivity.loadCallback(sendText.getBytes(), null, null, null);
|
||||
}
|
||||
});
|
||||
|
@ -178,7 +178,8 @@ public class ImportKeysListFragment extends ListFragment implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public Loader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> onCreateLoader(int id, Bundle args) {
|
||||
public Loader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>>
|
||||
onCreateLoader(int id, Bundle args) {
|
||||
switch (id) {
|
||||
case LOADER_ID_BYTES: {
|
||||
InputData inputData = getInputData(mKeyBytes, mDataUri);
|
||||
|
@ -36,8 +36,8 @@ import android.text.TextUtils;
|
||||
import android.view.*;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.AbsListView.MultiChoiceModeListener;
|
||||
import android.widget.*;
|
||||
import android.widget.AbsListView.MultiChoiceModeListener;
|
||||
import com.beardedhen.androidbootstrap.BootstrapButton;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
@ -63,7 +63,8 @@ import java.util.HashMap;
|
||||
* Public key list with sticky list headers. It does _not_ extend ListFragment because it uses
|
||||
* StickyListHeaders library which does not extend upon ListView.
|
||||
*/
|
||||
public class KeyListFragment extends Fragment implements SearchView.OnQueryTextListener, AdapterView.OnItemClickListener,
|
||||
public class KeyListFragment extends Fragment
|
||||
implements SearchView.OnQueryTextListener, AdapterView.OnItemClickListener,
|
||||
LoaderManager.LoaderCallbacks<Cursor> {
|
||||
|
||||
private KeyListAdapter mAdapter;
|
||||
@ -185,7 +186,10 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL
|
||||
// todo: public/secret needs to be handled differently here
|
||||
ids = mStickyList.getWrappedList().getCheckedItemIds();
|
||||
ExportHelper mExportHelper = new ExportHelper((ActionBarActivity) getActivity());
|
||||
mExportHelper.showExportKeysDialog(ids, Id.type.public_key, Constants.path.APP_DIR_FILE_PUB);
|
||||
mExportHelper
|
||||
.showExportKeysDialog(ids,
|
||||
Id.type.public_key,
|
||||
Constants.path.APP_DIR_FILE_PUB);
|
||||
break;
|
||||
}
|
||||
case R.id.menu_key_list_multi_select_all: {
|
||||
@ -310,7 +314,10 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL
|
||||
} else {
|
||||
viewIntent = new Intent(getActivity(), ViewKeyActivityJB.class);
|
||||
}
|
||||
viewIntent.setData(KeychainContract.KeyRings.buildPublicKeyRingsByMasterKeyIdUri(Long.toString(mAdapter.getMasterKeyId(position))));
|
||||
viewIntent.setData(
|
||||
KeychainContract
|
||||
.KeyRings.buildPublicKeyRingsByMasterKeyIdUri(
|
||||
Long.toString(mAdapter.getMasterKeyId(position))));
|
||||
startActivity(viewIntent);
|
||||
}
|
||||
|
||||
@ -347,8 +354,12 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL
|
||||
for (String userId : notDeleted) {
|
||||
notDeletedMsg += userId + "\n";
|
||||
}
|
||||
Toast.makeText(getActivity(), getString(R.string.error_can_not_delete_contacts, notDeletedMsg)
|
||||
+ getResources().getQuantityString(R.plurals.error_can_not_delete_info, notDeleted.size()),
|
||||
Toast.makeText(getActivity(),
|
||||
getString(R.string.error_can_not_delete_contacts, notDeletedMsg)
|
||||
+ getResources()
|
||||
.getQuantityString(
|
||||
R.plurals.error_can_not_delete_info,
|
||||
notDeleted.size()),
|
||||
Toast.LENGTH_LONG).show();
|
||||
|
||||
mode.finish();
|
||||
@ -507,7 +518,9 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL
|
||||
button.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View view) {
|
||||
Intent editIntent = new Intent(getActivity(), EditKeyActivity.class);
|
||||
editIntent.setData(KeychainContract.KeyRings.buildSecretKeyRingsByMasterKeyIdUri(Long.toString(id)));
|
||||
editIntent.setData(
|
||||
KeychainContract.KeyRings
|
||||
.buildSecretKeyRingsByMasterKeyIdUri(Long.toString(id)));
|
||||
editIntent.setAction(EditKeyActivity.ACTION_EDIT_KEY);
|
||||
startActivityForResult(editIntent, 0);
|
||||
}
|
||||
@ -582,7 +595,8 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL
|
||||
String userId = mCursor.getString(KeyListFragment.INDEX_USER_ID);
|
||||
String headerText = convertView.getResources().getString(R.string.user_id_no_name);
|
||||
if (userId != null && userId.length() > 0) {
|
||||
headerText = "" + mCursor.getString(KeyListFragment.INDEX_USER_ID).subSequence(0, 1).charAt(0);
|
||||
headerText = "" +
|
||||
mCursor.getString(KeyListFragment.INDEX_USER_ID).subSequence(0, 1).charAt(0);
|
||||
}
|
||||
holder.mText.setText(headerText);
|
||||
holder.mCount.setVisibility(View.GONE);
|
||||
@ -605,9 +619,9 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL
|
||||
}
|
||||
|
||||
// early breakout: all secret keys are assigned id 0
|
||||
if (mCursor.getInt(KeyListFragment.INDEX_TYPE) == KeyTypes.SECRET)
|
||||
if (mCursor.getInt(KeyListFragment.INDEX_TYPE) == KeyTypes.SECRET) {
|
||||
return 1L;
|
||||
|
||||
}
|
||||
// otherwise, return the first character of the name as ID
|
||||
String userId = mCursor.getString(KeyListFragment.INDEX_USER_ID);
|
||||
if (userId != null && userId.length() > 0) {
|
||||
|
@ -132,7 +132,8 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T
|
||||
mSearchView = new EditText(context);
|
||||
mSearchView.setId(SEARCH_ID);
|
||||
mSearchView.setHint(R.string.menu_search);
|
||||
mSearchView.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.ic_action_search), null, null, null);
|
||||
mSearchView.setCompoundDrawablesWithIntrinsicBounds(
|
||||
getResources().getDrawable(R.drawable.ic_action_search), null, null, null);
|
||||
|
||||
linearLayout.addView(mSearchView, new FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
@ -270,7 +271,7 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T
|
||||
+ Keys.CAN_ENCRYPT + " = '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,};
|
||||
+ SelectKeyCursorAdapter.PROJECTION_ROW_VALID, };
|
||||
|
||||
String inMasterKeyList = null;
|
||||
if (mSelectedMasterKeyIds != null && mSelectedMasterKeyIds.length > 0) {
|
||||
|
@ -101,7 +101,10 @@ public class SelectSecretKeyLayoutFragment extends Fragment {
|
||||
mKeyUserIdRest.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
mKeyMasterKeyIdHex.setText(getActivity().getResources().getString(R.string.no_keys_added_or_updated) + " for master id: " + secretKeyId);
|
||||
mKeyMasterKeyIdHex.setText(
|
||||
getActivity().getResources()
|
||||
.getString(R.string.no_keys_added_or_updated)
|
||||
+ " for master id: " + secretKeyId);
|
||||
mKeyUserId.setVisibility(View.GONE);
|
||||
mKeyUserIdRest.setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -241,7 +241,8 @@ public class ViewKeyActivity extends ActionBarActivity {
|
||||
// we delete only this key, so MESSAGE_NOT_DELETED will solely contain this key
|
||||
Toast.makeText(ViewKeyActivity.this,
|
||||
getString(R.string.error_can_not_delete_contact)
|
||||
+ getResources().getQuantityString(R.plurals.error_can_not_delete_info, 1),
|
||||
+ getResources()
|
||||
.getQuantityString(R.plurals.error_can_not_delete_info, 1),
|
||||
Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
setResult(RESULT_CANCELED);
|
||||
|
@ -136,7 +136,10 @@ public class ViewKeyMainFragment extends Fragment implements
|
||||
mActionEdit.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View view) {
|
||||
Intent editIntent = new Intent(getActivity(), EditKeyActivity.class);
|
||||
editIntent.setData(KeychainContract.KeyRings.buildSecretKeyRingsByMasterKeyIdUri(Long.toString(masterKeyId)));
|
||||
editIntent.setData(
|
||||
KeychainContract
|
||||
.KeyRings.buildSecretKeyRingsByMasterKeyIdUri(
|
||||
Long.toString(masterKeyId)));
|
||||
editIntent.setAction(EditKeyActivity.ACTION_EDIT_KEY);
|
||||
startActivityForResult(editIntent, 0);
|
||||
}
|
||||
@ -169,21 +172,28 @@ public class ViewKeyMainFragment extends Fragment implements
|
||||
getActivity().getSupportLoaderManager().initLoader(LOADER_ID_KEYS, null, this);
|
||||
}
|
||||
|
||||
static final String[] KEYRING_PROJECTION = new String[]{KeychainContract.KeyRings._ID, KeychainContract.KeyRings.MASTER_KEY_ID,
|
||||
static final String[] KEYRING_PROJECTION =
|
||||
new String[]{KeychainContract.KeyRings._ID, KeychainContract.KeyRings.MASTER_KEY_ID,
|
||||
KeychainContract.UserIds.USER_ID};
|
||||
static final int KEYRING_INDEX_ID = 0;
|
||||
static final int KEYRING_INDEX_MASTER_KEY_ID = 1;
|
||||
static final int KEYRING_INDEX_USER_ID = 2;
|
||||
|
||||
static final String[] USER_IDS_PROJECTION = new String[]{KeychainContract.UserIds._ID, KeychainContract.UserIds.USER_ID,
|
||||
KeychainContract.UserIds.RANK,};
|
||||
static final String[] USER_IDS_PROJECTION =
|
||||
new String[]{KeychainContract.UserIds._ID, KeychainContract.UserIds.USER_ID,
|
||||
KeychainContract.UserIds.RANK, };
|
||||
// not the main user id
|
||||
static final String USER_IDS_SELECTION = KeychainContract.UserIds.RANK + " > 0 ";
|
||||
static final String USER_IDS_SORT_ORDER = KeychainContract.UserIds.USER_ID + " COLLATE LOCALIZED ASC";
|
||||
static final String USER_IDS_SORT_ORDER =
|
||||
KeychainContract.UserIds.USER_ID + " COLLATE LOCALIZED ASC";
|
||||
|
||||
static final String[] KEYS_PROJECTION = new String[]{KeychainContract.Keys._ID, KeychainContract.Keys.KEY_ID,
|
||||
KeychainContract.Keys.IS_MASTER_KEY, KeychainContract.Keys.ALGORITHM, KeychainContract.Keys.KEY_SIZE, KeychainContract.Keys.CAN_CERTIFY, KeychainContract.Keys.CAN_SIGN,
|
||||
KeychainContract.Keys.CAN_ENCRYPT, KeychainContract.Keys.CREATION, KeychainContract.Keys.EXPIRY, KeychainContract.Keys.FINGERPRINT};
|
||||
static final String[] KEYS_PROJECTION =
|
||||
new String[]{KeychainContract.Keys._ID, KeychainContract.Keys.KEY_ID,
|
||||
KeychainContract.Keys.IS_MASTER_KEY, KeychainContract.Keys.ALGORITHM,
|
||||
KeychainContract.Keys.KEY_SIZE, KeychainContract.Keys.CAN_CERTIFY,
|
||||
KeychainContract.Keys.CAN_SIGN, KeychainContract.Keys.CAN_ENCRYPT,
|
||||
KeychainContract.Keys.CREATION, KeychainContract.Keys.EXPIRY,
|
||||
KeychainContract.Keys.FINGERPRINT};
|
||||
static final String KEYS_SORT_ORDER = KeychainContract.Keys.RANK + " ASC";
|
||||
static final int KEYS_INDEX_ID = 0;
|
||||
static final int KEYS_INDEX_KEY_ID = 1;
|
||||
@ -266,7 +276,8 @@ public class ViewKeyMainFragment extends Fragment implements
|
||||
} else {
|
||||
Date creationDate = new Date(data.getLong(KEYS_INDEX_CREATION) * 1000);
|
||||
|
||||
mCreation.setText(DateFormat.getDateFormat(getActivity().getApplicationContext()).format(
|
||||
mCreation.setText(
|
||||
DateFormat.getDateFormat(getActivity().getApplicationContext()).format(
|
||||
creationDate));
|
||||
}
|
||||
|
||||
@ -276,7 +287,8 @@ public class ViewKeyMainFragment extends Fragment implements
|
||||
} else {
|
||||
Date expiryDate = new Date(data.getLong(KEYS_INDEX_EXPIRY) * 1000);
|
||||
|
||||
mExpiry.setText(DateFormat.getDateFormat(getActivity().getApplicationContext()).format(
|
||||
mExpiry.setText(
|
||||
DateFormat.getDateFormat(getActivity().getApplicationContext()).format(
|
||||
expiryDate));
|
||||
}
|
||||
|
||||
@ -397,5 +409,4 @@ public class ViewKeyMainFragment extends Fragment implements
|
||||
startActivity(signIntent);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -148,4 +148,4 @@ public class CreateKeyDialogFragment extends DialogFragment {
|
||||
return dialog.create();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,8 @@ public class DeleteFileDialogFragment extends DialogFragment {
|
||||
null);
|
||||
|
||||
// Message is received after deleting is done in ApgService
|
||||
KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(activity, deletingDialog) {
|
||||
KeychainIntentServiceHandler saveHandler =
|
||||
new KeychainIntentServiceHandler(activity, deletingDialog) {
|
||||
public void handleMessage(Message message) {
|
||||
// handle messages by standard ApgHandler first
|
||||
super.handleMessage(message);
|
||||
@ -120,4 +121,4 @@ public class DeleteFileDialogFragment extends DialogFragment {
|
||||
|
||||
return alert.create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,8 +117,9 @@ public class DeleteKeyDialogFragment extends DialogFragment {
|
||||
String selectionIDs = "";
|
||||
for (int i = 0; i < keyRingRowIds.length; i++) {
|
||||
selectionIDs += "'" + String.valueOf(keyRingRowIds[i]) + "'";
|
||||
if (i + 1 < keyRingRowIds.length)
|
||||
if (i + 1 < keyRingRowIds.length) {
|
||||
selectionIDs += ",";
|
||||
}
|
||||
}
|
||||
selection += selectionIDs + ")";
|
||||
|
||||
@ -139,7 +140,9 @@ public class DeleteKeyDialogFragment extends DialogFragment {
|
||||
|
||||
// check if a corresponding secret key exists...
|
||||
Cursor secretCursor = activity.getContentResolver().query(
|
||||
KeychainContract.KeyRings.buildSecretKeyRingsByMasterKeyIdUri(String.valueOf(masterKeyId)),
|
||||
KeychainContract.KeyRings
|
||||
.buildSecretKeyRingsByMasterKeyIdUri(
|
||||
String.valueOf(masterKeyId)),
|
||||
null, null, null, null
|
||||
);
|
||||
if (secretCursor != null && secretCursor.getCount() > 0) {
|
||||
@ -204,4 +207,4 @@ public class DeleteKeyDialogFragment extends DialogFragment {
|
||||
Log.w(Constants.TAG, "Messenger is null!", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor
|
||||
|
||||
private Messenger mMessenger;
|
||||
private EditText mPassphraseEditText;
|
||||
private boolean canKB;
|
||||
private boolean mCanKB;
|
||||
|
||||
/**
|
||||
* Creates new instance of this dialog fragment
|
||||
@ -128,7 +128,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor
|
||||
}
|
||||
});
|
||||
alert.setCancelable(false);
|
||||
canKB = false;
|
||||
mCanKB = false;
|
||||
return alert.create();
|
||||
}
|
||||
String userId = PgpKeyHelper.getMainUserIdSafe(activity, secretKey);
|
||||
@ -221,14 +221,14 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor
|
||||
}
|
||||
});
|
||||
|
||||
canKB = true;
|
||||
mCanKB = true;
|
||||
return alert.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle arg0) {
|
||||
super.onActivityCreated(arg0);
|
||||
if (canKB) {
|
||||
if (mCanKB) {
|
||||
// request focus and open soft keyboard
|
||||
mPassphraseEditText.requestFocus();
|
||||
getDialog().getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||
|
@ -100,8 +100,9 @@ public class ProgressDialogFragment extends DialogFragment {
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
super.onCancel(dialog);
|
||||
|
||||
if (this.mOnCancelListener != null)
|
||||
if (this.mOnCancelListener != null) {
|
||||
this.mOnCancelListener.onCancel(dialog);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -150,4 +151,4 @@ public class ProgressDialogFragment extends DialogFragment {
|
||||
|
||||
return dialog;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -183,4 +183,4 @@ public class SetPassphraseDialogFragment extends DialogFragment implements OnEdi
|
||||
Log.w(Constants.TAG, "Messenger is null!", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,4 +96,4 @@ public class ShareNfcDialogFragment extends DialogFragment {
|
||||
|
||||
return alert.create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user