diff options
Diffstat (limited to 'OpenKeychain/src/main/java')
3 files changed, 43 insertions, 5 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java index d3910c11e..170f21c31 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java @@ -236,8 +236,13 @@ public class DecryptFileFragment extends DecryptFragment { if (mDeleteAfter.isChecked()) { // Create and show dialog to delete original file - DeleteFileDialogFragment deleteFileDialog = DeleteFileDialogFragment - .newInstance(mInputFilename); + DeleteFileDialogFragment deleteFileDialog; + if (mInputUri != null) { + deleteFileDialog = DeleteFileDialogFragment.newInstance(mInputUri); + } else { + deleteFileDialog = DeleteFileDialogFragment + .newInstance(mInputFilename); + } deleteFileDialog.show(getActivity().getSupportFragmentManager(), "deleteDialog"); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java index a3fb8fbd5..2671e0d40 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java @@ -350,8 +350,13 @@ public class EncryptFileFragment extends Fragment { if (mDeleteAfter.isChecked()) { // Create and show dialog to delete original file - DeleteFileDialogFragment deleteFileDialog = DeleteFileDialogFragment - .newInstance(mInputFilename); + DeleteFileDialogFragment deleteFileDialog; + if (mInputUri != null) { + deleteFileDialog = DeleteFileDialogFragment.newInstance(mInputUri); + } else { + deleteFileDialog = DeleteFileDialogFragment + .newInstance(mInputFilename); + } deleteFileDialog.show(getActivity().getSupportFragmentManager(), "deleteDialog"); } @@ -359,7 +364,11 @@ public class EncryptFileFragment extends Fragment { // Share encrypted file Intent sendFileIntent = new Intent(Intent.ACTION_SEND); sendFileIntent.setType("*/*"); - sendFileIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(mOutputFilename)); + if (mOutputUri != null) { + sendFileIntent.putExtra(Intent.EXTRA_STREAM, mOutputUri); + } else { + sendFileIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(mOutputFilename)); + } startActivity(Intent.createChooser(sendFileIntent, getString(R.string.title_share_file))); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java index b42a79993..cae6cf043 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java @@ -21,9 +21,11 @@ import android.app.Dialog; import android.app.ProgressDialog; import android.content.DialogInterface; import android.content.Intent; +import android.net.Uri; import android.os.Bundle; import android.os.Message; import android.os.Messenger; +import android.provider.DocumentsContract; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentActivity; import android.widget.Toast; @@ -34,6 +36,7 @@ import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; public class DeleteFileDialogFragment extends DialogFragment { private static final String ARG_DELETE_FILE = "delete_file"; + private static final String ARG_DELETE_URI = "delete_uri"; /** * Creates new instance of this delete file dialog fragment @@ -50,12 +53,27 @@ public class DeleteFileDialogFragment extends DialogFragment { } /** + * Creates new instance of this delete file dialog fragment + */ + public static DeleteFileDialogFragment newInstance(Uri deleteUri) { + DeleteFileDialogFragment frag = new DeleteFileDialogFragment(); + Bundle args = new Bundle(); + + args.putParcelable(ARG_DELETE_URI, deleteUri); + + frag.setArguments(args); + + return frag; + } + + /** * Creates dialog */ @Override public Dialog onCreateDialog(Bundle savedInstanceState) { final FragmentActivity activity = getActivity(); + final Uri deleteUri = getArguments().containsKey(ARG_DELETE_URI) ? getArguments().<Uri>getParcelable(ARG_DELETE_URI) : null; final String deleteFile = getArguments().getString(ARG_DELETE_FILE); CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity); @@ -71,6 +89,12 @@ public class DeleteFileDialogFragment extends DialogFragment { public void onClick(DialogInterface dialog, int id) { dismiss(); + if (deleteUri != null) { + // We can not securely delete Documents, so just use usual delete on them + DocumentsContract.deleteDocument(getActivity().getContentResolver(), deleteUri); + return; + } + // Send all information needed to service to edit key in other thread Intent intent = new Intent(activity, KeychainIntentService.class); |