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()) {
|
if (mDeleteAfter.isChecked()) {
|
||||||
// Create and show dialog to delete original file
|
// Create and show dialog to delete original file
|
||||||
DeleteFileDialogFragment deleteFileDialog = DeleteFileDialogFragment
|
DeleteFileDialogFragment deleteFileDialog;
|
||||||
.newInstance(mInputFilename);
|
if (mInputUri != null) {
|
||||||
|
deleteFileDialog = DeleteFileDialogFragment.newInstance(mInputUri);
|
||||||
|
} else {
|
||||||
|
deleteFileDialog = DeleteFileDialogFragment
|
||||||
|
.newInstance(mInputFilename);
|
||||||
|
}
|
||||||
deleteFileDialog.show(getActivity().getSupportFragmentManager(), "deleteDialog");
|
deleteFileDialog.show(getActivity().getSupportFragmentManager(), "deleteDialog");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -350,8 +350,13 @@ public class EncryptFileFragment extends Fragment {
|
||||||
|
|
||||||
if (mDeleteAfter.isChecked()) {
|
if (mDeleteAfter.isChecked()) {
|
||||||
// Create and show dialog to delete original file
|
// Create and show dialog to delete original file
|
||||||
DeleteFileDialogFragment deleteFileDialog = DeleteFileDialogFragment
|
DeleteFileDialogFragment deleteFileDialog;
|
||||||
.newInstance(mInputFilename);
|
if (mInputUri != null) {
|
||||||
|
deleteFileDialog = DeleteFileDialogFragment.newInstance(mInputUri);
|
||||||
|
} else {
|
||||||
|
deleteFileDialog = DeleteFileDialogFragment
|
||||||
|
.newInstance(mInputFilename);
|
||||||
|
}
|
||||||
deleteFileDialog.show(getActivity().getSupportFragmentManager(), "deleteDialog");
|
deleteFileDialog.show(getActivity().getSupportFragmentManager(), "deleteDialog");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,7 +364,11 @@ public class EncryptFileFragment extends Fragment {
|
||||||
// Share encrypted file
|
// Share encrypted file
|
||||||
Intent sendFileIntent = new Intent(Intent.ACTION_SEND);
|
Intent sendFileIntent = new Intent(Intent.ACTION_SEND);
|
||||||
sendFileIntent.setType("*/*");
|
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,
|
startActivity(Intent.createChooser(sendFileIntent,
|
||||||
getString(R.string.title_share_file)));
|
getString(R.string.title_share_file)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,11 @@ import android.app.Dialog;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Messenger;
|
import android.os.Messenger;
|
||||||
|
import android.provider.DocumentsContract;
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
@ -34,6 +36,7 @@ import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
||||||
|
|
||||||
public class DeleteFileDialogFragment extends DialogFragment {
|
public class DeleteFileDialogFragment extends DialogFragment {
|
||||||
private static final String ARG_DELETE_FILE = "delete_file";
|
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
|
* Creates new instance of this delete file dialog fragment
|
||||||
|
@ -49,6 +52,20 @@ public class DeleteFileDialogFragment extends DialogFragment {
|
||||||
return frag;
|
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
|
* Creates dialog
|
||||||
*/
|
*/
|
||||||
|
@ -56,6 +73,7 @@ public class DeleteFileDialogFragment extends DialogFragment {
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
final FragmentActivity activity = getActivity();
|
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);
|
final String deleteFile = getArguments().getString(ARG_DELETE_FILE);
|
||||||
|
|
||||||
CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity);
|
CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity);
|
||||||
|
@ -71,6 +89,12 @@ public class DeleteFileDialogFragment extends DialogFragment {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
dismiss();
|
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
|
// Send all information needed to service to edit key in other thread
|
||||||
Intent intent = new Intent(activity, KeychainIntentService.class);
|
Intent intent = new Intent(activity, KeychainIntentService.class);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue