diff --git a/app/src/main/java/ryey/easer/core/ui/edit/AbstractEditDataActivity.java b/app/src/main/java/ryey/easer/core/ui/edit/AbstractEditDataActivity.java
index dba3a180..8e3d1db3 100644
--- a/app/src/main/java/ryey/easer/core/ui/edit/AbstractEditDataActivity.java
+++ b/app/src/main/java/ryey/easer/core/ui/edit/AbstractEditDataActivity.java
@@ -138,9 +138,17 @@ protected void onDestroy() {
protected boolean persistChange() {
try {
boolean success;
- if (purpose == EditDataProto.Purpose.delete)
+ if (purpose == EditDataProto.Purpose.delete) {
success = storage.delete(oldName);
- else {
+ if (success) {
+ setResult(RESULT_OK);
+ Logger.d("Successfully deleted " + TAG_DATA_TYPE);
+ finish();
+ } else {
+ Logger.e("Failed to delete " + TAG_DATA_TYPE);
+ Toast.makeText(this, getString(R.string.prompt_delete_failed), Toast.LENGTH_SHORT).show();
+ }
+ } else {
try {
T newData = saveToData();
if (newData == null || !newData.isValid()) {
@@ -162,14 +170,14 @@ protected boolean persistChange() {
Toast.makeText(this, getString(R.string.prompt_data_illegal), Toast.LENGTH_LONG).show();
return false;
}
- }
- if (success) {
- setResult(RESULT_OK);
- Logger.d("Successfully altered " + TAG_DATA_TYPE);
- finish();
- } else {
- Logger.e("Failed to alter " + TAG_DATA_TYPE);
- Toast.makeText(this, getString(R.string.prompt_save_failed), Toast.LENGTH_SHORT).show();
+ if (success) {
+ setResult(RESULT_OK);
+ Logger.d("Successfully saved " + TAG_DATA_TYPE);
+ finish();
+ } else {
+ Logger.e("Failed to save " + TAG_DATA_TYPE);
+ Toast.makeText(this, getString(R.string.prompt_save_failed), Toast.LENGTH_SHORT).show();
+ }
}
return success;
} catch (IOException e) {
diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml
index 6cabc891..a591682c 100644
--- a/app/src/main/res/values-zh/strings.xml
+++ b/app/src/main/res/values-zh/strings.xml
@@ -99,5 +99,6 @@
狀況名
使用狀況
更新後自動重啓服務
+ 刪除失敗。請檢查此物是否被使用。
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index a78bb3c5..9a719f5d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -66,6 +66,7 @@
Failed to save
Are you sure to delete: %s
+ Failed to delete. Check if this item is being used.
Prevented saving data with invalid field(s). Please recheck your choices / inputs.
Easer needs permission <%s> for this function.