mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
some bugfixes for new CryptoOperationFragment
This commit is contained in:
parent
244f92ed57
commit
5d652e4c41
@ -18,7 +18,6 @@
|
|||||||
package org.sufficientlysecure.keychain.ui;
|
package org.sufficientlysecure.keychain.ui;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ProgressDialog;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
@ -26,8 +25,6 @@ import android.graphics.Point;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Message;
|
|
||||||
import android.os.Messenger;
|
|
||||||
import android.support.v7.widget.DefaultItemAnimator;
|
import android.support.v7.widget.DefaultItemAnimator;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
@ -49,10 +46,6 @@ import org.sufficientlysecure.keychain.pgp.KeyRing;
|
|||||||
import org.sufficientlysecure.keychain.pgp.PgpConstants;
|
import org.sufficientlysecure.keychain.pgp.PgpConstants;
|
||||||
import org.sufficientlysecure.keychain.pgp.SignEncryptParcel;
|
import org.sufficientlysecure.keychain.pgp.SignEncryptParcel;
|
||||||
import org.sufficientlysecure.keychain.provider.TemporaryStorageProvider;
|
import org.sufficientlysecure.keychain.provider.TemporaryStorageProvider;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainNewService;
|
|
||||||
import org.sufficientlysecure.keychain.service.KeychainService;
|
|
||||||
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
|
|
||||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.SpacesItemDecoration;
|
import org.sufficientlysecure.keychain.ui.adapter.SpacesItemDecoration;
|
||||||
import org.sufficientlysecure.keychain.ui.base.CachingCryptoOperationFragment;
|
import org.sufficientlysecure.keychain.ui.base.CachingCryptoOperationFragment;
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.DeleteFileDialogFragment;
|
import org.sufficientlysecure.keychain.ui.dialog.DeleteFileDialogFragment;
|
||||||
|
@ -1,19 +1,10 @@
|
|||||||
package org.sufficientlysecure.keychain.ui.base;
|
package org.sufficientlysecure.keychain.ui.base;
|
||||||
|
|
||||||
|
|
||||||
import android.app.ProgressDialog;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Message;
|
|
||||||
import android.os.Messenger;
|
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainNewService;
|
|
||||||
import org.sufficientlysecure.keychain.service.KeychainService;
|
|
||||||
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
|
|
||||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
|
||||||
|
|
||||||
|
|
||||||
public abstract class CachingCryptoOperationFragment <T extends Parcelable, S extends OperationResult>
|
public abstract class CachingCryptoOperationFragment <T extends Parcelable, S extends OperationResult>
|
||||||
@ -47,59 +38,6 @@ public abstract class CachingCryptoOperationFragment <T extends Parcelable, S ex
|
|||||||
|
|
||||||
protected abstract T createOperationInput();
|
protected abstract T createOperationInput();
|
||||||
|
|
||||||
protected void cryptoOperation(CryptoInputParcel cryptoInput) {
|
|
||||||
|
|
||||||
if (mCachedActionsParcel == null) {
|
|
||||||
|
|
||||||
mCachedActionsParcel = createOperationInput();
|
|
||||||
// this is null if invalid, just return in that case
|
|
||||||
if (mCachedActionsParcel == null) {
|
|
||||||
// Notify was created by createCryptoInput.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send all information needed to service to edit key in other thread
|
|
||||||
Intent intent = new Intent(getActivity(), KeychainNewService.class);
|
|
||||||
|
|
||||||
intent.putExtra(KeychainNewService.EXTRA_OPERATION_INPUT, mCachedActionsParcel);
|
|
||||||
intent.putExtra(KeychainNewService.EXTRA_CRYPTO_INPUT, cryptoInput);
|
|
||||||
|
|
||||||
ServiceProgressHandler saveHandler = new ServiceProgressHandler(getActivity()) {
|
|
||||||
@Override
|
|
||||||
public void handleMessage(Message message) {
|
|
||||||
// handle messages by standard KeychainIntentServiceHandler first
|
|
||||||
super.handleMessage(message);
|
|
||||||
|
|
||||||
if (message.arg1 == MessageStatus.OKAY.ordinal()) {
|
|
||||||
|
|
||||||
// get returned data bundle
|
|
||||||
Bundle returnData = message.getData();
|
|
||||||
if (returnData == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final OperationResult result =
|
|
||||||
returnData.getParcelable(OperationResult.EXTRA_RESULT);
|
|
||||||
|
|
||||||
onHandleResult(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Create a new Messenger for the communication back
|
|
||||||
Messenger messenger = new Messenger(saveHandler);
|
|
||||||
intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);
|
|
||||||
|
|
||||||
saveHandler.showProgressDialog(
|
|
||||||
getString(R.string.progress_building_key),
|
|
||||||
ProgressDialog.STYLE_HORIZONTAL, false);
|
|
||||||
|
|
||||||
getActivity().startService(intent);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected T getCachedActionsParcel() {
|
protected T getCachedActionsParcel() {
|
||||||
return mCachedActionsParcel;
|
return mCachedActionsParcel;
|
||||||
}
|
}
|
||||||
|
@ -184,7 +184,7 @@ public abstract class CryptoOperationFragment <T extends Parcelable, S extends O
|
|||||||
abstract protected void onCryptoOperationSuccess(S result);
|
abstract protected void onCryptoOperationSuccess(S result);
|
||||||
|
|
||||||
protected void onCryptoOperationError(S result) {
|
protected void onCryptoOperationError(S result) {
|
||||||
result.createNotify(getActivity()).show(this);
|
result.createNotify(getActivity()).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onCryptoOperationCancelled() {
|
protected void onCryptoOperationCancelled() {
|
||||||
|
Loading…
Reference in New Issue
Block a user