ImportKeys: Refactoring
- Avoid instanceof and duplicated code
This commit is contained in:
@@ -218,7 +218,7 @@ public class CreateSecurityTokenImportResetFragment
|
||||
public void importKey() {
|
||||
|
||||
ArrayList<ParcelableKeyRing> keyList = new ArrayList<>();
|
||||
keyList.add(new ParcelableKeyRing(mTokenFingerprint, null));
|
||||
keyList.add(new ParcelableKeyRing(mTokenFingerprint, null, null, null));
|
||||
mKeyList = keyList;
|
||||
|
||||
mKeyserver = Preferences.getPreferences(getActivity()).getPreferredKeyserver();
|
||||
|
||||
@@ -144,7 +144,7 @@ public abstract class DecryptFragment extends Fragment implements LoaderManager.
|
||||
|
||||
{
|
||||
ParcelableKeyRing keyEntry = new ParcelableKeyRing(null,
|
||||
KeyFormattingUtils.convertKeyIdToHex(unknownKeyId));
|
||||
KeyFormattingUtils.convertKeyIdToHex(unknownKeyId), null, null);
|
||||
ArrayList<ParcelableKeyRing> selectedEntries = new ArrayList<>();
|
||||
selectedEntries.add(keyEntry);
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ import android.widget.Toast;
|
||||
import android.widget.ViewAnimator;
|
||||
|
||||
import com.cocosw.bottomsheet.BottomSheet;
|
||||
|
||||
import org.openintents.openpgp.OpenPgpMetadata;
|
||||
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||
import org.sufficientlysecure.keychain.BuildConfig;
|
||||
@@ -97,24 +98,24 @@ import org.sufficientlysecure.keychain.util.ParcelableHashMap;
|
||||
import org.sufficientlysecure.keychain.util.Preferences;
|
||||
|
||||
|
||||
/** Displays a list of decrypted inputs.
|
||||
*
|
||||
/**
|
||||
* Displays a list of decrypted inputs.
|
||||
* <p/>
|
||||
* This class has a complex control flow to manage its input URIs. Each URI
|
||||
* which is in mInputUris is also in exactly one of mPendingInputUris,
|
||||
* mCancelledInputUris, mCurrentInputUri, or a key in mInputDataResults.
|
||||
*
|
||||
* <p/>
|
||||
* Processing of URIs happens using a looping approach:
|
||||
* - There is always exactly one method running which works on mCurrentInputUri
|
||||
* - Processing starts in cryptoOperation(), which pops a new mCurrentInputUri
|
||||
* from the list of mPendingInputUris.
|
||||
* from the list of mPendingInputUris.
|
||||
* - Once a mCurrentInputUri is finished processing, it should be set to null and
|
||||
* control handed back to cryptoOperation()
|
||||
* control handed back to cryptoOperation()
|
||||
* - Control flow can move through asynchronous calls, and resume in callbacks
|
||||
* like onActivityResult() or onPermissionRequestResult().
|
||||
*
|
||||
* like onActivityResult() or onPermissionRequestResult().
|
||||
*/
|
||||
public class DecryptListFragment
|
||||
extends QueueingCryptoOperationFragment<InputDataParcel,InputDataResult>
|
||||
extends QueueingCryptoOperationFragment<InputDataParcel, InputDataResult>
|
||||
implements OnMenuItemClickListener {
|
||||
|
||||
public static final String ARG_INPUT_URIS = "input_uris";
|
||||
@@ -188,7 +189,7 @@ public class DecryptListFragment
|
||||
|
||||
outState.putParcelableArrayList(ARG_INPUT_URIS, mInputUris);
|
||||
|
||||
HashMap<Uri,InputDataResult> results = new HashMap<>(mInputUris.size());
|
||||
HashMap<Uri, InputDataResult> results = new HashMap<>(mInputUris.size());
|
||||
for (Uri uri : mInputUris) {
|
||||
if (mPendingInputUris.contains(uri)) {
|
||||
continue;
|
||||
@@ -218,7 +219,7 @@ public class DecryptListFragment
|
||||
|
||||
ArrayList<Uri> inputUris = getArguments().getParcelableArrayList(ARG_INPUT_URIS);
|
||||
ArrayList<Uri> cancelledUris = args.getParcelableArrayList(ARG_CANCELLED_URIS);
|
||||
ParcelableHashMap<Uri,InputDataResult> results = args.getParcelable(ARG_RESULTS);
|
||||
ParcelableHashMap<Uri, InputDataResult> results = args.getParcelable(ARG_RESULTS);
|
||||
|
||||
mCanDelete = args.getBoolean(ARG_CAN_DELETE, false);
|
||||
|
||||
@@ -230,11 +231,11 @@ public class DecryptListFragment
|
||||
private void displayInputUris(
|
||||
ArrayList<Uri> inputUris,
|
||||
ArrayList<Uri> cancelledUris,
|
||||
HashMap<Uri,InputDataResult> results) {
|
||||
HashMap<Uri, InputDataResult> results) {
|
||||
|
||||
mInputUris = inputUris;
|
||||
mCurrentInputUri = null;
|
||||
mInputDataResults = results != null ? results : new HashMap<Uri,InputDataResult>(inputUris.size());
|
||||
mInputDataResults = results != null ? results : new HashMap<Uri, InputDataResult>(inputUris.size());
|
||||
mCancelledInputUris = cancelledUris != null ? cancelledUris : new ArrayList<Uri>();
|
||||
|
||||
mPendingInputUris = new ArrayList<>();
|
||||
@@ -294,7 +295,7 @@ public class DecryptListFragment
|
||||
String filename = metadata.getFilename();
|
||||
if (TextUtils.isEmpty(filename)) {
|
||||
String ext = MimeTypeMap.getSingleton().getExtensionFromMimeType(metadata.getMimeType());
|
||||
filename = "decrypted" + (ext != null ? "."+ext : "");
|
||||
filename = "decrypted" + (ext != null ? "." + ext : "");
|
||||
}
|
||||
|
||||
// requires >=kitkat
|
||||
@@ -394,7 +395,7 @@ public class DecryptListFragment
|
||||
|
||||
}
|
||||
|
||||
HashMap<Uri,Drawable> mIconCache = new HashMap<>();
|
||||
HashMap<Uri, Drawable> mIconCache = new HashMap<>();
|
||||
|
||||
private void processResult(final Uri uri) {
|
||||
|
||||
@@ -561,7 +562,7 @@ public class DecryptListFragment
|
||||
|
||||
Intent chooserIntent = Intent.createChooser(intent, getString(R.string.intent_show));
|
||||
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,
|
||||
new Parcelable[] { internalIntent });
|
||||
new Parcelable[]{internalIntent});
|
||||
|
||||
startActivity(chooserIntent);
|
||||
|
||||
@@ -605,7 +606,7 @@ public class DecryptListFragment
|
||||
.putExtra(DisplayTextActivity.EXTRA_METADATA, metadata),
|
||||
BuildConfig.APPLICATION_ID, R.string.view_internal, R.mipmap.ic_launcher);
|
||||
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,
|
||||
new Parcelable[] { internalIntent });
|
||||
new Parcelable[]{internalIntent});
|
||||
}
|
||||
|
||||
startActivity(chooserIntent);
|
||||
@@ -632,7 +633,7 @@ public class DecryptListFragment
|
||||
|
||||
Log.d(Constants.TAG, "mCurrentInputUri=" + mCurrentInputUri);
|
||||
|
||||
if ( ! checkAndRequestReadPermission(activity, mCurrentInputUri)) {
|
||||
if (!checkAndRequestReadPermission(activity, mCurrentInputUri)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -644,15 +645,15 @@ public class DecryptListFragment
|
||||
|
||||
/**
|
||||
* Request READ_EXTERNAL_STORAGE permission on Android >= 6.0 to read content from "file" Uris.
|
||||
*
|
||||
* <p/>
|
||||
* This method returns true on Android < 6, or if permission is already granted. It
|
||||
* requests the permission and returns false otherwise, taking over responsibility
|
||||
* for mCurrentInputUri.
|
||||
*
|
||||
* <p/>
|
||||
* see https://commonsware.com/blog/2015/10/07/runtime-permissions-files-action-send.html
|
||||
*/
|
||||
private boolean checkAndRequestReadPermission(Activity activity, final Uri uri) {
|
||||
if ( ! ContentResolver.SCHEME_FILE.equals(uri.getScheme())) {
|
||||
if (!ContentResolver.SCHEME_FILE.equals(uri.getScheme())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -667,7 +668,7 @@ public class DecryptListFragment
|
||||
}
|
||||
|
||||
requestPermissions(
|
||||
new String[] { Manifest.permission.READ_EXTERNAL_STORAGE },
|
||||
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
|
||||
REQUEST_PERMISSION_READ_EXTERNAL_STORAGE);
|
||||
|
||||
return false;
|
||||
@@ -676,8 +677,8 @@ public class DecryptListFragment
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode,
|
||||
@NonNull String[] permissions,
|
||||
@NonNull int[] grantResults) {
|
||||
@NonNull String[] permissions,
|
||||
@NonNull int[] grantResults) {
|
||||
|
||||
if (requestCode != REQUEST_PERMISSION_READ_EXTERNAL_STORAGE) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
@@ -693,7 +694,7 @@ public class DecryptListFragment
|
||||
Iterator<Uri> it = mCancelledInputUris.iterator();
|
||||
while (it.hasNext()) {
|
||||
Uri uri = it.next();
|
||||
if ( ! ContentResolver.SCHEME_FILE.equals(uri.getScheme())) {
|
||||
if (!ContentResolver.SCHEME_FILE.equals(uri.getScheme())) {
|
||||
continue;
|
||||
}
|
||||
it.remove();
|
||||
@@ -711,7 +712,7 @@ public class DecryptListFragment
|
||||
Iterator<Uri> it = mPendingInputUris.iterator();
|
||||
while (it.hasNext()) {
|
||||
Uri uri = it.next();
|
||||
if ( ! ContentResolver.SCHEME_FILE.equals(uri.getScheme())) {
|
||||
if (!ContentResolver.SCHEME_FILE.equals(uri.getScheme())) {
|
||||
continue;
|
||||
}
|
||||
it.remove();
|
||||
@@ -766,7 +767,7 @@ public class DecryptListFragment
|
||||
|
||||
{
|
||||
ParcelableKeyRing keyEntry = new ParcelableKeyRing(null,
|
||||
KeyFormattingUtils.convertKeyIdToHex(unknownKeyId));
|
||||
KeyFormattingUtils.convertKeyIdToHex(unknownKeyId), null, null);
|
||||
ArrayList<ParcelableKeyRing> selectedEntries = new ArrayList<>();
|
||||
selectedEntries.add(keyEntry);
|
||||
|
||||
@@ -974,7 +975,7 @@ public class DecryptListFragment
|
||||
String filename;
|
||||
if (metadata == null) {
|
||||
filename = getString(R.string.filename_unknown);
|
||||
} else if ( ! TextUtils.isEmpty(metadata.getFilename())) {
|
||||
} else if (!TextUtils.isEmpty(metadata.getFilename())) {
|
||||
filename = metadata.getFilename();
|
||||
} else if (ClipDescription.compareMimeTypes(metadata.getMimeType(), Constants.MIME_TYPE_KEYS)) {
|
||||
filename = getString(R.string.filename_keys);
|
||||
@@ -1226,7 +1227,7 @@ public class DecryptListFragment
|
||||
vSigStatusText = (TextView) itemView.findViewById(R.id.result_signature_text);
|
||||
vSignatureLayout = itemView.findViewById(R.id.result_signature_layout);
|
||||
vSignatureName = (TextView) itemView.findViewById(R.id.result_signature_name);
|
||||
vSignatureMail= (TextView) itemView.findViewById(R.id.result_signature_email);
|
||||
vSignatureMail = (TextView) itemView.findViewById(R.id.result_signature_email);
|
||||
vSignatureAction = (ViewAnimator) itemView.findViewById(R.id.result_signature_action);
|
||||
|
||||
vFileList = (LinearLayout) itemView.findViewById(R.id.file_list);
|
||||
|
||||
@@ -362,12 +362,11 @@ public class ImportKeysListFragment extends Fragment implements
|
||||
ArrayList<ImportKeysListEntry> result = data.getResult();
|
||||
binding.setStatus(result.size() > 0 ? STATUS_LOADED : STATUS_EMPTY);
|
||||
|
||||
mAdapter.setLoaderState(mLoaderState);
|
||||
mAdapter.setData(result);
|
||||
|
||||
// free old cached key data
|
||||
mCachedKeyData = null;
|
||||
|
||||
mAdapter.setData(result);
|
||||
|
||||
GetKeyResult getKeyResult = (GetKeyResult) data.getOperationResult();
|
||||
switch (loader.getId()) {
|
||||
case LOADER_ID_BYTES:
|
||||
|
||||
@@ -197,7 +197,7 @@ public class ImportKeysProxyActivity extends FragmentActivity
|
||||
}
|
||||
|
||||
public void importKeys(String fingerprint) {
|
||||
ParcelableKeyRing keyEntry = new ParcelableKeyRing(fingerprint, null);
|
||||
ParcelableKeyRing keyEntry = new ParcelableKeyRing(fingerprint, null, null, null);
|
||||
ArrayList<ParcelableKeyRing> selectedEntries = new ArrayList<>();
|
||||
selectedEntries.add(keyEntry);
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ import android.widget.ViewAnimator;
|
||||
|
||||
import com.getbase.floatingactionbutton.FloatingActionButton;
|
||||
import com.getbase.floatingactionbutton.FloatingActionsMenu;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
||||
@@ -77,6 +78,7 @@ import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||
import org.sufficientlysecure.keychain.util.FabContainer;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.sufficientlysecure.keychain.util.Preferences;
|
||||
|
||||
import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter;
|
||||
import se.emilsjolander.stickylistheaders.StickyListHeadersListView;
|
||||
|
||||
@@ -244,7 +246,7 @@ public class KeyListFragment extends LoaderFragment
|
||||
|
||||
@Override
|
||||
public void onItemCheckedStateChanged(ActionMode mode, int position, long id,
|
||||
boolean checked) {
|
||||
boolean checked) {
|
||||
if (checked) {
|
||||
mAdapter.setNewSelection(position, true);
|
||||
} else {
|
||||
@@ -333,7 +335,7 @@ public class KeyListFragment extends LoaderFragment
|
||||
headerCursor.addRow(row);
|
||||
|
||||
Cursor dataCursor = data;
|
||||
data = new MergeCursor(new Cursor[] {
|
||||
data = new MergeCursor(new Cursor[]{
|
||||
headerCursor, dataCursor
|
||||
});
|
||||
}
|
||||
@@ -575,7 +577,7 @@ public class KeyListFragment extends LoaderFragment
|
||||
while (cursor.moveToNext()) {
|
||||
byte[] blob = cursor.getBlob(0);//fingerprint column is 0
|
||||
String fingerprint = KeyFormattingUtils.convertFingerprintToHex(blob);
|
||||
ParcelableKeyRing keyEntry = new ParcelableKeyRing(fingerprint, null);
|
||||
ParcelableKeyRing keyEntry = new ParcelableKeyRing(fingerprint, null, null, null);
|
||||
keyList.add(keyEntry);
|
||||
}
|
||||
mKeyList = keyList;
|
||||
|
||||
@@ -19,11 +19,6 @@
|
||||
package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.animation.ArgbEvaluator;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.annotation.SuppressLint;
|
||||
@@ -89,10 +84,10 @@ import org.sufficientlysecure.keychain.ui.ViewKeyFragment.PostponeType;
|
||||
import org.sufficientlysecure.keychain.ui.base.BaseSecurityTokenActivity;
|
||||
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper;
|
||||
import org.sufficientlysecure.keychain.ui.dialog.SetPassphraseDialogFragment;
|
||||
import org.sufficientlysecure.keychain.ui.util.ContentDescriptionHint;
|
||||
import org.sufficientlysecure.keychain.ui.util.FormattingUtils;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils.State;
|
||||
import org.sufficientlysecure.keychain.ui.util.ContentDescriptionHint;
|
||||
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||
import org.sufficientlysecure.keychain.ui.util.Notify.ActionListener;
|
||||
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
|
||||
@@ -103,6 +98,11 @@ import org.sufficientlysecure.keychain.util.NfcHelper;
|
||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
import org.sufficientlysecure.keychain.util.Preferences;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
||||
LoaderManager.LoaderCallbacks<Cursor>,
|
||||
@@ -114,7 +114,9 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({REQUEST_QR_FINGERPRINT, REQUEST_BACKUP, REQUEST_CERTIFY, REQUEST_DELETE})
|
||||
private @interface RequestType {}
|
||||
private @interface RequestType {
|
||||
}
|
||||
|
||||
static final int REQUEST_QR_FINGERPRINT = 1;
|
||||
static final int REQUEST_BACKUP = 2;
|
||||
static final int REQUEST_CERTIFY = 3;
|
||||
@@ -564,7 +566,7 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
||||
|
||||
private void startBackupActivity() {
|
||||
Intent intent = new Intent(this, BackupActivity.class);
|
||||
intent.putExtra(BackupActivity.EXTRA_MASTER_KEY_IDS, new long[] { mMasterKeyId });
|
||||
intent.putExtra(BackupActivity.EXTRA_MASTER_KEY_IDS, new long[]{mMasterKeyId});
|
||||
intent.putExtra(BackupActivity.EXTRA_SECRET, true);
|
||||
startActivity(intent);
|
||||
}
|
||||
@@ -721,7 +723,7 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
||||
manager.beginTransaction()
|
||||
.addToBackStack("security_token")
|
||||
.replace(R.id.view_key_fragment, frag)
|
||||
// if this is called while the activity wasn't resumed, just forget it happened
|
||||
// if this is called while the activity wasn't resumed, just forget it happened
|
||||
.commitAllowingStateLoss();
|
||||
}
|
||||
});
|
||||
@@ -1104,7 +1106,7 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
||||
KeychainContract.Keys.FINGERPRINT, ProviderHelper.FIELD_TYPE_BLOB);
|
||||
String fingerprint = KeyFormattingUtils.convertFingerprintToHex(blob);
|
||||
|
||||
ParcelableKeyRing keyEntry = new ParcelableKeyRing(fingerprint, null);
|
||||
ParcelableKeyRing keyEntry = new ParcelableKeyRing(fingerprint, null, null, null);
|
||||
ArrayList<ParcelableKeyRing> entries = new ArrayList<>();
|
||||
entries.add(keyEntry);
|
||||
mKeyList = entries;
|
||||
|
||||
@@ -29,12 +29,9 @@ import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.databinding.ImportKeysListItemBinding;
|
||||
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
|
||||
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
||||
import org.sufficientlysecure.keychain.keyimport.processing.BytesLoaderState;
|
||||
import org.sufficientlysecure.keychain.keyimport.processing.CloudLoaderState;
|
||||
import org.sufficientlysecure.keychain.keyimport.processing.ImportKeysListener;
|
||||
import org.sufficientlysecure.keychain.keyimport.processing.ImportKeysOperationCallback;
|
||||
import org.sufficientlysecure.keychain.keyimport.processing.ImportKeysResultListener;
|
||||
import org.sufficientlysecure.keychain.keyimport.processing.LoaderState;
|
||||
import org.sufficientlysecure.keychain.operations.ImportOperation;
|
||||
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing;
|
||||
@@ -54,7 +51,6 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
||||
private ImportKeysResultListener mListener;
|
||||
private boolean mAdvanced, mNonInteractive;
|
||||
|
||||
private LoaderState mLoaderState;
|
||||
private List<ImportKeysListEntry> mData;
|
||||
|
||||
private KeyState[] mKeyStates;
|
||||
@@ -73,11 +69,6 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setLoaderState(LoaderState loaderState) {
|
||||
this.mLoaderState = loaderState;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setData(List<ImportKeysListEntry> data) {
|
||||
this.mData = data;
|
||||
this.mKeyStates = new KeyState[data.size()];
|
||||
@@ -145,7 +136,7 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
||||
b.importKey.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
getKey(getParcelableKeyRing(entry), false);
|
||||
getKey(entry, false);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -154,7 +145,7 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
||||
public void onClick(View v) {
|
||||
mCurrent = position;
|
||||
if (!showed && !downloaded) {
|
||||
getKey(getParcelableKeyRing(entry), true);
|
||||
getKey(entry, true);
|
||||
} else {
|
||||
changeState(position, !showed);
|
||||
}
|
||||
@@ -179,8 +170,8 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
||||
return mData != null ? mData.size() : 0;
|
||||
}
|
||||
|
||||
public void getKey(ParcelableKeyRing keyRing, boolean skipSave) {
|
||||
ImportKeyringParcel inputParcel = prepareKeyOperation(keyRing, skipSave);
|
||||
public void getKey(ImportKeysListEntry entry, boolean skipSave) {
|
||||
ImportKeyringParcel inputParcel = prepareKeyOperation(entry, skipSave);
|
||||
ImportKeysResultListener listener = skipSave ? this : mListener;
|
||||
ImportKeysOperationCallback cb = new ImportKeysOperationCallback(listener, inputParcel);
|
||||
int message = skipSave ? R.string.progress_downloading : R.string.progress_importing;
|
||||
@@ -188,22 +179,12 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
||||
opHelper.cryptoOperation();
|
||||
}
|
||||
|
||||
private ParcelableKeyRing getParcelableKeyRing(ImportKeysListEntry entry) {
|
||||
ParcelableKeyRing keyRing = null;
|
||||
if (mLoaderState instanceof BytesLoaderState) {
|
||||
keyRing = new ParcelableKeyRing(entry.getEncodedRing());
|
||||
} else if (mLoaderState instanceof CloudLoaderState) {
|
||||
keyRing = new ParcelableKeyRing(entry.getFingerprintHex(), entry.getKeyIdHex(),
|
||||
entry.getKeybaseName(), entry.getFbUsername());
|
||||
}
|
||||
return keyRing;
|
||||
}
|
||||
|
||||
private ImportKeyringParcel prepareKeyOperation(ParcelableKeyRing keyRing, boolean skipSave) {
|
||||
private ImportKeyringParcel prepareKeyOperation(ImportKeysListEntry entry, boolean skipSave) {
|
||||
ArrayList<ParcelableKeyRing> keysList = null;
|
||||
String keyserver = null;
|
||||
|
||||
if (mLoaderState instanceof BytesLoaderState) {
|
||||
ParcelableKeyRing keyRing = entry.getParcelableKeyRing();
|
||||
if (keyRing.mBytes != null) {
|
||||
// instead of giving the entries by Intent extra, cache them into a
|
||||
// file to prevent Java Binder problems on heavy imports
|
||||
// read FileImportCache for more info.
|
||||
@@ -217,10 +198,10 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
||||
Log.e(Constants.TAG, "Problem writing cache file", e);
|
||||
Notify.create(mActivity, "Problem writing cache file!", Notify.Style.ERROR).show();
|
||||
}
|
||||
} else if (mLoaderState instanceof CloudLoaderState) {
|
||||
} else {
|
||||
keysList = new ArrayList<>();
|
||||
keysList.add(keyRing);
|
||||
keyserver = ((CloudLoaderState) mLoaderState).mCloudPrefs.keyserver;
|
||||
keyserver = entry.getKeyserver();
|
||||
}
|
||||
|
||||
return new ImportKeyringParcel(keysList, keyserver, skipSave);
|
||||
|
||||
Reference in New Issue
Block a user