implement deletion of files

This commit is contained in:
Vincent Breitmoser
2015-06-23 17:07:59 +02:00
parent 6a5bd6509b
commit f9dea31300
21 changed files with 45 additions and 28 deletions

View File

@@ -300,7 +300,7 @@ public class AsymmetricFileOperationTests {
onView(withText(R.string.btn_delete_original)).check(doesNotExist());
// check if log looks ok
onView(withText(R.string.view_log)).perform(click());
onView(withText(R.string.snackbar_details)).perform(click());
onView(withText(R.string.msg_dc_clear_signature_ok)).check(matches(isDisplayed()));
pressBack();

View File

@@ -198,7 +198,7 @@ public class AsymmetricTextOperationTests {
onView(withText(R.string.btn_delete_original)).check(doesNotExist());
// check if log looks ok
onView(withText(R.string.view_log)).perform(click());
onView(withText(R.string.snackbar_details)).perform(click());
onView(withText(R.string.msg_dc_clear_signature_ok)).check(matches(isDisplayed()));
pressBack();

View File

@@ -132,7 +132,7 @@ public class CertifyResult extends InputPendingResult {
intent.putExtra(LogDisplayFragment.EXTRA_RESULT, CertifyResult.this);
activity.startActivity(intent);
}
}, R.string.view_log);
}, R.string.snackbar_details);
}

View File

@@ -124,7 +124,7 @@ public class DeleteResult extends OperationResult {
intent.putExtra(LogDisplayFragment.EXTRA_RESULT, DeleteResult.this);
activity.startActivity(intent);
}
}, R.string.view_log);
}, R.string.snackbar_details);
}

View File

@@ -190,7 +190,7 @@ public class ImportKeyResult extends OperationResult {
intent.putExtra(LogDisplayFragment.EXTRA_RESULT, ImportKeyResult.this);
activity.startActivity(intent);
}
}, R.string.view_log);
}, R.string.snackbar_details);
}

View File

@@ -253,7 +253,7 @@ public abstract class OperationResult implements Parcelable {
intent.putExtra(LogDisplayFragment.EXTRA_RESULT, OperationResult.this);
activity.startActivity(intent);
}
}, R.string.view_log);
}, R.string.snackbar_details);
}

View File

@@ -491,12 +491,28 @@ public class DecryptListFragment
askForOutputFilename(model.mInputUri, metadata.getFilename(), metadata.getMimeType());
return true;
case R.id.decrypt_delete:
Notify.create(activity, "decrypt/delete not yet implemented", Style.ERROR).show(this);
deleteFile(activity, model.mInputUri);
return true;
}
return false;
}
private void deleteFile(Activity activity, Uri uri) {
try {
int deleted = activity.getContentResolver().delete(uri, null, null);
if (deleted > 0) {
Notify.create(activity, R.string.file_delete_ok, Style.OK).show();
} else {
Notify.create(activity, R.string.file_delete_none, Style.WARN).show();
}
} catch (Exception e) {
Log.e(Constants.TAG, "exception deleting file", e);
Notify.create(activity, R.string.file_delete_exception, Style.ERROR).show();
}
}
public static class DecryptFilesAdapter extends RecyclerView.Adapter<ViewHolder> {
private Context mContext;
private ArrayList<ViewModel> mDataset;
@@ -664,9 +680,6 @@ public class DecryptListFragment
mMenuClickedModel = model;
PopupMenu menu = new PopupMenu(mContext, view);
menu.inflate(R.menu.decrypt_item_context_menu);
if (!"file".equals(model.mInputUri.getScheme())) {
menu.getMenu().findItem(R.id.decrypt_delete).setVisible(false);
}
menu.setOnMenuItemClickListener(mMenuItemClickListener);
menu.setOnDismissListener(new OnDismissListener() {
@Override

View File

@@ -3,7 +3,7 @@
<item
android:id="@+id/view_log"
android:title="@string/view_log"
android:title="@string/btn_view_log"
android:icon="@drawable/ic_view_list_grey_24dp"
/>

View File

@@ -363,7 +363,7 @@
<string name="import_qr_code_button">QR-Code scannen</string>
<string name="import_qr_code_text">Halte deine Kamera über den QR-Code!</string>
<!--Generic result toast-->
<string name="view_log">Details</string>
<string name="snackbar_details">Details</string>
<string name="with_warnings">, mit Warnungen</string>
<string name="with_cancelled">. bis abgebrochen wurde</string>
<!--Import result toast-->

View File

@@ -363,7 +363,7 @@
<string name="import_qr_code_button">Escanear código QR</string>
<string name="import_qr_code_text">¡Sitúe su cámara sobre el código QR!</string>
<!--Generic result toast-->
<string name="view_log">Detalles</string>
<string name="snackbar_details">Detalles</string>
<string name="with_warnings">, con advertencias</string>
<string name="with_cancelled">, hasta que sea cancelado</string>
<!--Import result toast-->

View File

@@ -304,7 +304,7 @@
<string name="import_qr_code_button">Eskaneatu QR Kodea</string>
<string name="import_qr_code_text">Jarri zure kamera QR Kodearen gainean!</string>
<!--Generic result toast-->
<string name="view_log">Xehetasunak</string>
<string name="snackbar_details">Xehetasunak</string>
<string name="with_warnings">, kontuz oharrekin</string>
<!--Import result toast-->
<string name="import_error_nothing">Ez dago ezer inportatzeko.</string>

View File

@@ -363,7 +363,7 @@
<string name="import_qr_code_button">Balayer le code QR</string>
<string name="import_qr_code_text">Placez votre appareil photo au-dessus du code QR !</string>
<!--Generic result toast-->
<string name="view_log">Détails</string>
<string name="snackbar_details">Détails</string>
<string name="with_warnings">, avec des avertissements</string>
<string name="with_cancelled">, jusqu\'à l\'annulation</string>
<!--Import result toast-->

View File

@@ -364,7 +364,7 @@
<string name="import_qr_code_button">QCコードのスキャン</string>
<string name="import_qr_code_text">カメラをQRコードにかざしてください!</string>
<!--Generic result toast-->
<string name="view_log">概要</string>
<string name="snackbar_details">概要</string>
<string name="with_warnings">、とワーニング</string>
<string name="with_cancelled">、キャンセルされるまで</string>
<!--Import result toast-->

View File

@@ -363,7 +363,7 @@
<string name="import_qr_code_button">QR code scannen</string>
<string name="import_qr_code_text">Plaats je camera voor de QR-code!</string>
<!--Generic result toast-->
<string name="view_log">Details</string>
<string name="snackbar_details">Details</string>
<string name="with_warnings">, met waarschuwingen</string>
<string name="with_cancelled">, tot annulatie</string>
<!--Import result toast-->

View File

@@ -308,7 +308,7 @@
<string name="import_qr_code_button">Skanuj kod QR</string>
<string name="import_qr_code_text">Umieść kod QR przed kamerą!</string>
<!--Generic result toast-->
<string name="view_log">Szczegóły</string>
<string name="snackbar_details">Szczegóły</string>
<string name="with_warnings">, z ostrzeżeniami</string>
<string name="with_cancelled">, aż anulowano</string>
<!--Import result toast-->

View File

@@ -332,7 +332,7 @@
<string name="import_qr_code_button">Сканировать QR код...</string>
<string name="import_qr_code_text">Расположите вашу камеру над QR кодом!</string>
<!--Generic result toast-->
<string name="view_log">Сведения</string>
<string name="snackbar_details">Сведения</string>
<string name="with_warnings">, с предупреждениями</string>
<string name="with_cancelled">, до отмены</string>
<!--Import result toast-->

View File

@@ -371,7 +371,7 @@
<string name="import_qr_code_button">Skeniraj kodo QR</string>
<string name="import_qr_code_text">Zajamite kodo QR s kamero!</string>
<!--Generic result toast-->
<string name="view_log">Podrobnosti</string>
<string name="snackbar_details">Podrobnosti</string>
<string name="with_warnings">, z opozorili</string>
<string name="with_cancelled">, do preklica</string>
<!--Import result toast-->

View File

@@ -370,7 +370,7 @@
<string name="import_qr_code_button">Очитај бар-код</string>
<string name="import_qr_code_text">Усмерите камеру на бар-код!</string>
<!--Generic result toast-->
<string name="view_log">Детаљи</string>
<string name="snackbar_details">Детаљи</string>
<string name="with_warnings">, са упозорењима</string>
<string name="with_cancelled">, док није отказано</string>
<!--Import result toast-->

View File

@@ -350,7 +350,7 @@
<string name="import_qr_code_button">Skanna QR-kod</string>
<string name="import_qr_code_text">Håll din kamera över QR-koden!</string>
<!--Generic result toast-->
<string name="view_log">Detaljer</string>
<string name="snackbar_details">Detaljer</string>
<string name="with_warnings">, med varningar</string>
<string name="with_cancelled">, tills det avbryts</string>
<!--Import result toast-->

View File

@@ -348,7 +348,7 @@
<string name="import_qr_code_button">掃描二維條碼</string>
<string name="import_qr_code_text">將您的相機對準 QR Code !</string>
<!--Generic result toast-->
<string name="view_log">詳細</string>
<string name="snackbar_details">詳細</string>
<string name="with_warnings">,包含警告</string>
<string name="with_cancelled">,直到被取消</string>
<!--Import result toast-->

View File

@@ -63,7 +63,8 @@
<string name="btn_decrypt_verify_file">"Decrypt, verify, and save file"</string>
<string name="btn_encrypt_share_file">"Encrypt and share file"</string>
<string name="btn_encrypt_save_file">"Encrypt and save file"</string>
<string name="btn_save">"Save"</string>
<string name="btn_save">"Save file"</string>
<string name="btn_view_log">"View log"</string>
<string name="btn_do_not_save">"Cancel"</string>
<string name="btn_delete">"Delete"</string>
<string name="btn_no_date">"No Expiry"</string>
@@ -420,7 +421,7 @@
<string name="import_url_warn_no_search_parameter">"No search query defined. You can still manually search on this keyserver."</string>
<!-- Generic result toast -->
<string name="view_log">"Details"</string>
<string name="snackbar_details">"Details"</string>
<string name="with_warnings">", with warnings"</string>
<string name="with_cancelled">", until cancelled"</string>
@@ -1341,8 +1342,11 @@
<string name="view_internal">"View in OpenKeychain"</string>
<string name="error_preparing_data">"Error preparing data!"</string>
<string name="label_clip_title">"Encrypted Data"</string>
<string name="progress_processing">Processing…</string>
<string name="error_saving_file">Error saving file!</string>
<string name="file_saved">File saved!</string>
<string name="progress_processing">"Processing…"</string>
<string name="error_saving_file">"Error saving file!"</string>
<string name="file_saved">"File saved!"</string>
<string name="file_delete_ok">"Original file deleted."</string>
<string name="file_delete_none">"No file deleted! (Already deleted?)"</string>
<string name="file_delete_exception">"Could not delete original file!"</string>
</resources>