mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-01-12 05:58:07 -05:00
Delete using Document API (unsafe)
This commit is contained in:
parent
f55bc41682
commit
e106079b90
@ -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");
|
||||
}
|
||||
}
|
||||
|
@ -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)));
|
||||
}
|
||||
|
@ -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
|
||||
@ -49,6 +52,20 @@ public class DeleteFileDialogFragment extends DialogFragment {
|
||||
return frag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
@ -56,6 +73,7 @@ public class DeleteFileDialogFragment extends DialogFragment {
|
||||
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user