aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2015-07-08 05:15:52 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2015-07-08 05:15:52 +0200
commit9eee9acba28cea2e97d0de653e5f6c07e01b12b6 (patch)
treeff80f00718e7ea66abd69e47daf740413b289bbd /OpenKeychain
parentbf2dc8edc3e78ce8279571c2d82253fe5bede1b1 (diff)
downloadopen-keychain-9eee9acba28cea2e97d0de653e5f6c07e01b12b6.tar.gz
open-keychain-9eee9acba28cea2e97d0de653e5f6c07e01b12b6.tar.bz2
open-keychain-9eee9acba28cea2e97d0de653e5f6c07e01b12b6.zip
multi-decrypt: add retry mechanism
Diffstat (limited to 'OpenKeychain')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java64
-rw-r--r--OpenKeychain/src/main/res/layout/decrypt_list_entry.xml14
2 files changed, 63 insertions, 15 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 0222cc617..3d0e51a85 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java
@@ -188,11 +188,16 @@ public class DecryptListFragment
mPendingInputUris = new ArrayList<>();
- for (Uri uri : inputUris) {
+ for (final Uri uri : inputUris) {
mAdapter.add(uri);
if (mCancelledInputUris.contains(uri)) {
- mAdapter.setCancelled(uri);
+ mAdapter.setCancelled(uri, new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ retryUri(uri);
+ }
+ });
continue;
}
@@ -284,11 +289,16 @@ public class DecryptListFragment
public void onCryptoOperationCancelled() {
super.onCryptoOperationCancelled();
- Uri uri = mCurrentInputUri;
+ final Uri uri = mCurrentInputUri;
mCurrentInputUri = null;
mCancelledInputUris.add(uri);
- mAdapter.setCancelled(uri);
+ mAdapter.setCancelled(uri, new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ retryUri(uri);
+ }
+ });
cryptoOperation();
@@ -377,6 +387,22 @@ public class DecryptListFragment
}
+ public void retryUri(Uri uri) {
+
+ // never interrupt running operations!
+ if (mCurrentInputUri != null) {
+ return;
+ }
+
+ // un-cancel this one
+ mCancelledInputUris.remove(uri);
+ mPendingInputUris.add(uri);
+ mAdapter.setCancelled(uri, null);
+
+ cryptoOperation();
+
+ }
+
public void displayWithViewIntent(final Uri uri) {
Activity activity = getActivity();
if (activity == null || mCurrentInputUri != null) {
@@ -555,14 +581,14 @@ public class DecryptListFragment
int mProgress, mMax;
String mProgressMsg;
- boolean mCancelled;
+ OnClickListener mCancelled;
ViewModel(Context context, Uri uri) {
mContext = context;
mInputUri = uri;
mProgress = 0;
mMax = 100;
- mCancelled = false;
+ mCancelled = null;
}
void addResult(DecryptVerifyResult result) {
@@ -582,8 +608,8 @@ public class DecryptListFragment
return mResult != null;
}
- void setCancelled(boolean cancelled) {
- mCancelled = cancelled;
+ void setCancelled(OnClickListener retryListener) {
+ mCancelled = retryListener;
}
void setProgress(int progress, int max, String msg) {
@@ -643,10 +669,8 @@ 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);
- }
+ if (model.mCancelled != null) {
+ bindItemCancelled(holder, model);
return;
}
@@ -663,6 +687,14 @@ public class DecryptListFragment
}
+ private void bindItemCancelled(ViewHolder holder, ViewModel model) {
+ if (holder.vAnimator.getDisplayedChild() != 3) {
+ holder.vAnimator.setDisplayedChild(3);
+ }
+
+ holder.vCancelledRetry.setOnClickListener(model.mCancelled);
+ }
+
private void bindItemProgress(ViewHolder holder, ViewModel model) {
if (holder.vAnimator.getDisplayedChild() != 0) {
holder.vAnimator.setDisplayedChild(0);
@@ -778,10 +810,10 @@ public class DecryptListFragment
notifyItemChanged(pos);
}
- public void setCancelled(Uri uri) {
+ public void setCancelled(Uri uri, OnClickListener retryListener) {
ViewModel newModel = new ViewModel(mContext, uri);
int pos = mDataset.indexOf(newModel);
- mDataset.get(pos).setCancelled(true);
+ mDataset.get(pos).setCancelled(retryListener);
notifyItemChanged(pos);
}
@@ -832,6 +864,8 @@ public class DecryptListFragment
public TextView vErrorMsg;
public ImageView vErrorViewLog;
+ public ImageView vCancelledRetry;
+
public ViewHolder(View itemView) {
super(itemView);
@@ -860,6 +894,8 @@ public class DecryptListFragment
vErrorMsg = (TextView) itemView.findViewById(R.id.result_error_msg);
vErrorViewLog = (ImageView) itemView.findViewById(R.id.result_error_log);
+ vCancelledRetry = (ImageView) itemView.findViewById(R.id.cancel_retry);
+
}
@Override
diff --git a/OpenKeychain/src/main/res/layout/decrypt_list_entry.xml b/OpenKeychain/src/main/res/layout/decrypt_list_entry.xml
index 4c4e75834..92f366eda 100644
--- a/OpenKeychain/src/main/res/layout/decrypt_list_entry.xml
+++ b/OpenKeychain/src/main/res/layout/decrypt_list_entry.xml
@@ -293,8 +293,9 @@
android:orientation="horizontal">
<TextView
- android:layout_width="match_parent"
+ android:layout_width="0dp"
android:layout_height="wrap_content"
+ android:layout_weight="1"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_gravity="center_vertical"
@@ -304,6 +305,17 @@
android:textAppearance="?android:attr/textAppearanceMedium"
/>
+ <ImageView
+ android:id="@+id/cancel_retry"
+ android:scaleType="center"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:clickable="true"
+ android:padding="6dp"
+ android:background="?android:selectableItemBackground"
+ android:src="@drawable/ic_repeat_grey_24dp"
+ android:layout_gravity="center_vertical" />
+
</LinearLayout>
</org.sufficientlysecure.keychain.ui.widget.ToolableViewAnimator>