mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-01-08 03:58:01 -05:00
added original message handling to ImportKeysActivity
This commit is contained in:
parent
20354ca393
commit
46d7ca2e36
@ -17,12 +17,10 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.ui;
|
package org.sufficientlysecure.keychain.ui;
|
||||||
|
|
||||||
import android.app.ProgressDialog;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Messenger;
|
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
@ -36,8 +34,6 @@ import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
|||||||
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
|
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainService;
|
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
|
||||||
import org.sufficientlysecure.keychain.ui.base.BaseNfcActivity;
|
import org.sufficientlysecure.keychain.ui.base.BaseNfcActivity;
|
||||||
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
|
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
|
||||||
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper;
|
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper;
|
||||||
@ -90,6 +86,8 @@ public class ImportKeysActivity extends BaseNfcActivity
|
|||||||
private String mKeyserver;
|
private String mKeyserver;
|
||||||
private ArrayList<ParcelableKeyRing> mKeyList;
|
private ArrayList<ParcelableKeyRing> mKeyList;
|
||||||
|
|
||||||
|
private CryptoOperationHelper<ImportKeyringParcel, ImportKeyResult> mOperationHelper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -396,8 +394,7 @@ public class ImportKeysActivity extends BaseNfcActivity
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CryptoOperationHelper<ImportKeyringParcel, ImportKeyResult> operationHelper
|
mOperationHelper = new CryptoOperationHelper<ImportKeyringParcel, ImportKeyResult>(
|
||||||
= new CryptoOperationHelper<ImportKeyringParcel, ImportKeyResult>(
|
|
||||||
this, this, R.string.progress_importing
|
this, this, R.string.progress_importing
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -420,7 +417,7 @@ public class ImportKeysActivity extends BaseNfcActivity
|
|||||||
|
|
||||||
mKeyList = null;
|
mKeyList = null;
|
||||||
mKeyserver = null;
|
mKeyserver = null;
|
||||||
operationHelper.cryptoOperation();
|
mOperationHelper.cryptoOperation();
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(Constants.TAG, "Problem writing cache file", e);
|
Log.e(Constants.TAG, "Problem writing cache file", e);
|
||||||
@ -445,7 +442,7 @@ public class ImportKeysActivity extends BaseNfcActivity
|
|||||||
|
|
||||||
mKeyList = keys;
|
mKeyList = keys;
|
||||||
mKeyserver = sls.mCloudPrefs.keyserver;
|
mKeyserver = sls.mCloudPrefs.keyserver;
|
||||||
operationHelper.cryptoOperation();
|
mOperationHelper.cryptoOperation();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -458,6 +455,32 @@ public class ImportKeysActivity extends BaseNfcActivity
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
if (mOperationHelper == null ||
|
||||||
|
!mOperationHelper.handleActivityResult(requestCode, resultCode, data)) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleResult (ImportKeyResult result) {
|
||||||
|
if (ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT.equals(getIntent().getAction())
|
||||||
|
|| ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN.equals(getIntent().getAction())) {
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.putExtra(ImportKeyResult.EXTRA_RESULT, result);
|
||||||
|
ImportKeysActivity.this.setResult(RESULT_OK, intent);
|
||||||
|
ImportKeysActivity.this.finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_TO_SERVICE.equals(getIntent().getAction())) {
|
||||||
|
ImportKeysActivity.this.setResult(RESULT_OK, mPendingIntentData);
|
||||||
|
ImportKeysActivity.this.finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.createNotify(ImportKeysActivity.this)
|
||||||
|
.show((ViewGroup) findViewById(R.id.import_snackbar));
|
||||||
|
}
|
||||||
// methods from CryptoOperationHelper.Callback
|
// methods from CryptoOperationHelper.Callback
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -467,7 +490,7 @@ public class ImportKeysActivity extends BaseNfcActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCryptoOperationSuccess(ImportKeyResult result) {
|
public void onCryptoOperationSuccess(ImportKeyResult result) {
|
||||||
result.createNotify(this).show();
|
handleResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -477,6 +500,6 @@ public class ImportKeysActivity extends BaseNfcActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCryptoOperationError(ImportKeyResult result) {
|
public void onCryptoOperationError(ImportKeyResult result) {
|
||||||
result.createNotify(this).show();
|
handleResult(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user