From 62791ed5f94920018a923d76664b12fc608be2a0 Mon Sep 17 00:00:00 2001
From: PeratX <1215714524@qq.com>
Date: Sat, 13 May 2017 09:57:56 +0800
Subject: [PATCH] Added delete confirm dialog
---
.../fragment/DnsServerConfigFragment.java | 18 ++++++++++++++++--
app/src/main/res/values-zh/strings.xml | 3 +++
app/src/main/res/values/strings.xml | 3 +++
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/app/src/main/java/org/itxtech/daedalus/fragment/DnsServerConfigFragment.java b/app/src/main/java/org/itxtech/daedalus/fragment/DnsServerConfigFragment.java
index d7ad6fe..41dbc80 100644
--- a/app/src/main/java/org/itxtech/daedalus/fragment/DnsServerConfigFragment.java
+++ b/app/src/main/java/org/itxtech/daedalus/fragment/DnsServerConfigFragment.java
@@ -1,5 +1,7 @@
package org.itxtech.daedalus.fragment;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.preference.EditTextPreference;
@@ -130,9 +132,21 @@ public class DnsServerConfigFragment extends PreferenceFragment implements Toolb
break;
case R.id.action_delete:
if (index != DnsServerConfigActivity.CUSTOM_DNS_SERVER_ID_NONE) {
- Daedalus.configurations.getCustomDnsServers().remove(index);
+ new AlertDialog.Builder(getActivity())
+ .setTitle(R.string.notice_delete_confirm_prompt)
+ .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Daedalus.configurations.getCustomDnsServers().remove(index);
+ getActivity().finish();
+ }
+ })
+ .setNegativeButton(R.string.no, null)
+ .create()
+ .show();
+ } else {
+ getActivity().finish();
}
- getActivity().finish();
break;
}
diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml
index 1faed48..6568c06 100644
--- a/app/src/main/res/values-zh/strings.xml
+++ b/app/src/main/res/values-zh/strings.xml
@@ -68,4 +68,7 @@
使用 DNSMasq 替代 Hosts
下载 DNSMasq 配置文件
本地 DNSMasq 配置路径:
+ 您确定要删除此 DNS 服务器?
+ 是
+ 否
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 4d29dbd..e440a8c 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -68,4 +68,7 @@
Use DNSMasq instead of Hosts
Download DNSMasq configuration
Local DNSMasq configurations path:
+ Are you sure you want to remove this DNS server?
+ Yes
+ No