aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2015-07-08 04:53:43 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2015-07-08 04:53:43 +0200
commitbf2dc8edc3e78ce8279571c2d82253fe5bede1b1 (patch)
tree27ff0bd0d83e263086e04272d64510f1e6416a28 /OpenKeychain
parent5633fcc92f20ecd81e4a4ea7f22416f58d051c49 (diff)
downloadopen-keychain-bf2dc8edc3e78ce8279571c2d82253fe5bede1b1.tar.gz
open-keychain-bf2dc8edc3e78ce8279571c2d82253fe5bede1b1.tar.bz2
open-keychain-bf2dc8edc3e78ce8279571c2d82253fe5bede1b1.zip
multi-decrypt: add cancelled state
Diffstat (limited to 'OpenKeychain')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java51
-rw-r--r--OpenKeychain/src/main/res/layout/decrypt_list_entry.xml20
2 files changed, 69 insertions, 2 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java
index b38968753..0222cc617 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java
@@ -85,6 +85,7 @@ public class DecryptListFragment
public static final String ARG_INPUT_URIS = "input_uris";
public static final String ARG_OUTPUT_URIS = "output_uris";
+ public static final String ARG_CANCELLED_URIS = "cancelled_uris";
public static final String ARG_RESULTS = "results";
private static final int REQUEST_CODE_OUTPUT = 0x00007007;
@@ -92,6 +93,7 @@ public class DecryptListFragment
private ArrayList<Uri> mInputUris;
private HashMap<Uri, Uri> mOutputUris;
private ArrayList<Uri> mPendingInputUris;
+ private ArrayList<Uri> mCancelledInputUris;
private Uri mCurrentInputUri;
@@ -155,6 +157,7 @@ public class DecryptListFragment
outState.putParcelable(ARG_RESULTS, new ParcelableHashMap<>(results));
outState.putParcelable(ARG_OUTPUT_URIS, new ParcelableHashMap<>(mOutputUris));
+ outState.putParcelableArrayList(ARG_CANCELLED_URIS, mCancelledInputUris);
}
@@ -165,25 +168,34 @@ public class DecryptListFragment
Bundle args = savedInstanceState != null ? savedInstanceState : getArguments();
ArrayList<Uri> inputUris = getArguments().getParcelableArrayList(ARG_INPUT_URIS);
+ ArrayList<Uri> cancelledUris = args.getParcelableArrayList(ARG_CANCELLED_URIS);
ParcelableHashMap<Uri,Uri> outputUris = args.getParcelable(ARG_OUTPUT_URIS);
ParcelableHashMap<Uri,DecryptVerifyResult> results = args.getParcelable(ARG_RESULTS);
- displayInputUris(inputUris,
+ displayInputUris(inputUris, cancelledUris,
outputUris != null ? outputUris.getMap() : null,
results != null ? results.getMap() : null
);
}
- private void displayInputUris(ArrayList<Uri> inputUris, HashMap<Uri,Uri> outputUris,
+ private void displayInputUris(ArrayList<Uri> inputUris, ArrayList<Uri> cancelledUris,
+ HashMap<Uri,Uri> outputUris,
HashMap<Uri,DecryptVerifyResult> results) {
mInputUris = inputUris;
mOutputUris = outputUris != null ? outputUris : new HashMap<Uri,Uri>(inputUris.size());
+ mCancelledInputUris = cancelledUris != null ? cancelledUris : new ArrayList<Uri>();
mPendingInputUris = new ArrayList<>();
for (Uri uri : inputUris) {
mAdapter.add(uri);
+
+ if (mCancelledInputUris.contains(uri)) {
+ mAdapter.setCancelled(uri);
+ continue;
+ }
+
if (results != null && results.containsKey(uri)) {
processResult(uri, results.get(uri));
} else {
@@ -247,6 +259,7 @@ public class DecryptListFragment
mAdapter.setProgress(mCurrentInputUri, progress, max, msg);
return true;
}
+
@Override
public void onQueuedOperationError(DecryptVerifyResult result) {
final Uri uri = mCurrentInputUri;
@@ -267,6 +280,20 @@ public class DecryptListFragment
cryptoOperation();
}
+ @Override
+ public void onCryptoOperationCancelled() {
+ super.onCryptoOperationCancelled();
+
+ Uri uri = mCurrentInputUri;
+ mCurrentInputUri = null;
+
+ mCancelledInputUris.add(uri);
+ mAdapter.setCancelled(uri);
+
+ cryptoOperation();
+
+ }
+
private void processResult(final Uri uri, final DecryptVerifyResult result) {
new AsyncTask<Void, Void, Drawable>() {
@@ -528,12 +555,14 @@ public class DecryptListFragment
int mProgress, mMax;
String mProgressMsg;
+ boolean mCancelled;
ViewModel(Context context, Uri uri) {
mContext = context;
mInputUri = uri;
mProgress = 0;
mMax = 100;
+ mCancelled = false;
}
void addResult(DecryptVerifyResult result) {
@@ -553,6 +582,10 @@ public class DecryptListFragment
return mResult != null;
}
+ void setCancelled(boolean cancelled) {
+ mCancelled = cancelled;
+ }
+
void setProgress(int progress, int max, String msg) {
if (msg != null) {
mProgressMsg = msg;
@@ -610,6 +643,13 @@ public class DecryptListFragment
// - replace the contents of the view with that element
final ViewModel model = mDataset.get(position);
+ if (model.mCancelled) {
+ if (holder.vAnimator.getDisplayedChild() != 3) {
+ holder.vAnimator.setDisplayedChild(3);
+ }
+ return;
+ }
+
if (!model.hasResult()) {
bindItemProgress(holder, model);
return;
@@ -738,6 +778,13 @@ public class DecryptListFragment
notifyItemChanged(pos);
}
+ public void setCancelled(Uri uri) {
+ ViewModel newModel = new ViewModel(mContext, uri);
+ int pos = mDataset.indexOf(newModel);
+ mDataset.get(pos).setCancelled(true);
+ notifyItemChanged(pos);
+ }
+
public void addResult(Uri uri, DecryptVerifyResult result, Drawable icon,
OnClickListener onFileClick, OnClickListener onKeyClick) {
diff --git a/OpenKeychain/src/main/res/layout/decrypt_list_entry.xml b/OpenKeychain/src/main/res/layout/decrypt_list_entry.xml
index d58542e62..4c4e75834 100644
--- a/OpenKeychain/src/main/res/layout/decrypt_list_entry.xml
+++ b/OpenKeychain/src/main/res/layout/decrypt_list_entry.xml
@@ -286,6 +286,26 @@
</LinearLayout>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:orientation="horizontal">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="8dp"
+ android:layout_marginStart="8dp"
+ android:layout_gravity="center_vertical"
+ android:drawablePadding="12dp"
+ android:text="@string/msg_cancelled"
+ android:drawableLeft="@drawable/status_signature_invalid_cutout_24dp"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ />
+
+ </LinearLayout>
+
</org.sufficientlysecure.keychain.ui.widget.ToolableViewAnimator>
</android.support.v7.widget.CardView> \ No newline at end of file