aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'OpenKeychain/src/main/java/org')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java12
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java31
2 files changed, 19 insertions, 24 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java
index 881190ae2..4f3f6cc6e 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java
@@ -82,6 +82,9 @@ public class DecryptActivity extends BaseActivity {
return;
}
+ // depending on the data source, we may or may not be able to delete the original file
+ boolean canDelete = false;
+
try {
switch (action) {
@@ -152,8 +155,9 @@ public class DecryptActivity extends BaseActivity {
}
// for everything else, just work on the intent data
- case OpenKeychainIntents.DECRYPT_DATA:
case Intent.ACTION_VIEW:
+ canDelete = true;
+ case OpenKeychainIntents.DECRYPT_DATA:
default:
uris.add(intent.getData());
@@ -173,7 +177,7 @@ public class DecryptActivity extends BaseActivity {
return;
}
- displayListFragment(uris);
+ displayListFragment(uris, canDelete);
}
@@ -193,9 +197,9 @@ public class DecryptActivity extends BaseActivity {
return tempFile;
}
- public void displayListFragment(ArrayList<Uri> inputUris) {
+ public void displayListFragment(ArrayList<Uri> inputUris, boolean canDelete) {
- DecryptListFragment frag = DecryptListFragment.newInstance(inputUris);
+ DecryptListFragment frag = DecryptListFragment.newInstance(inputUris, canDelete);
FragmentManager fragMan = getSupportFragmentManager();
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 af1108488..5d6bc5e21 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java
@@ -88,6 +88,7 @@ public class DecryptListFragment
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";
+ public static final String ARG_CAN_DELETE = "can_delete";
private static final int REQUEST_CODE_OUTPUT = 0x00007007;
public static final String ARG_CURRENT_URI = "current_uri";
@@ -98,6 +99,7 @@ public class DecryptListFragment
private ArrayList<Uri> mCancelledInputUris;
private Uri mCurrentInputUri;
+ private boolean mCanDelete;
private DecryptFilesAdapter mAdapter;
private Uri mCurrentSaveFileUri;
@@ -105,11 +107,12 @@ public class DecryptListFragment
/**
* Creates new instance of this fragment
*/
- public static DecryptListFragment newInstance(ArrayList<Uri> uris) {
+ public static DecryptListFragment newInstance(ArrayList<Uri> uris, boolean canDelete) {
DecryptListFragment frag = new DecryptListFragment();
Bundle args = new Bundle();
args.putParcelableArrayList(ARG_INPUT_URIS, uris);
+ args.putBoolean(ARG_CAN_DELETE, canDelete);
frag.setArguments(args);
return frag;
@@ -135,7 +138,7 @@ public class DecryptListFragment
vFilesList.setLayoutManager(new LinearLayoutManager(getActivity()));
vFilesList.setItemAnimator(new DefaultItemAnimator());
- mAdapter = new DecryptFilesAdapter(this);
+ mAdapter = new DecryptFilesAdapter();
vFilesList.setAdapter(mAdapter);
return view;
@@ -162,6 +165,7 @@ public class DecryptListFragment
outState.putParcelable(ARG_OUTPUT_URIS, new ParcelableHashMap<>(mInputDataResults));
outState.putParcelableArrayList(ARG_CANCELLED_URIS, mCancelledInputUris);
outState.putParcelable(ARG_CURRENT_URI, mCurrentInputUri);
+ outState.putBoolean(ARG_CAN_DELETE, mCanDelete);
}
@@ -176,6 +180,8 @@ public class DecryptListFragment
ParcelableHashMap<Uri,InputDataResult> results = args.getParcelable(ARG_RESULTS);
Uri currentInputUri = args.getParcelable(ARG_CURRENT_URI);
+ mCanDelete = args.getBoolean(ARG_CAN_DELETE, false);
+
displayInputUris(inputUris, currentInputUri, cancelledUris,
results != null ? results.getMap() : null
);
@@ -543,20 +549,6 @@ public class DecryptListFragment
case R.id.decrypt_delete:
deleteFile(activity, model.mInputUri);
return true;
- /*
- case R.id.decrypt_share:
- displayWithViewIntent(model.mResult, 0, true);
- return true;
- case R.id.decrypt_save:
- OpenPgpMetadata metadata = model.mResult.mDecryptVerifyResult.getDecryptionMetadata();
- if (metadata == null) {
- return true;
- }
- mCurrentInputUri = model.mInputUri;
- FileHelper.saveDocument(this, metadata.getFilename(), model.mInputUri, metadata.getMimeType(),
- R.string.title_decrypt_to_file, R.string.specify_file_to_decrypt_to, REQUEST_CODE_OUTPUT);
- return true;
- */
}
return false;
}
@@ -594,7 +586,6 @@ public class DecryptListFragment
public class DecryptFilesAdapter extends RecyclerView.Adapter<ViewHolder> {
private ArrayList<ViewModel> mDataset;
- private OnMenuItemClickListener mMenuItemClickListener;
private ViewModel mMenuClickedModel;
public class ViewModel {
@@ -659,8 +650,7 @@ public class DecryptListFragment
}
// Provide a suitable constructor (depends on the kind of dataset)
- public DecryptFilesAdapter(OnMenuItemClickListener menuItemClickListener) {
- mMenuItemClickListener = menuItemClickListener;
+ public DecryptFilesAdapter() {
mDataset = new ArrayList<>();
}
@@ -812,13 +802,14 @@ public class DecryptListFragment
mMenuClickedModel = model;
PopupMenu menu = new PopupMenu(activity, view);
menu.inflate(R.menu.decrypt_item_context_menu);
- menu.setOnMenuItemClickListener(mMenuItemClickListener);
+ menu.setOnMenuItemClickListener(DecryptListFragment.this);
menu.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(PopupMenu popupMenu) {
mMenuClickedModel = null;
}
});
+ menu.getMenu().findItem(R.id.decrypt_delete).setEnabled(mCanDelete);
menu.show();
}
});