Added delete confirm dialog

This commit is contained in:
PeratX 2017-05-13 09:57:56 +08:00
parent 184fe5c5bd
commit 62791ed5f9
3 changed files with 22 additions and 2 deletions

View File

@ -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;
}

View File

@ -68,4 +68,7 @@
<string name="settings_use_dnsmasq">使用 DNSMasq 替代 Hosts</string>
<string name="button_text_download_dnsmasq">下载 DNSMasq 配置文件</string>
<string name="dnsmasq_path">本地 DNSMasq 配置路径:</string>
<string name="notice_delete_confirm_prompt">您确定要删除此 DNS 服务器?</string>
<string name="yes"></string>
<string name="no"></string>
</resources>

View File

@ -68,4 +68,7 @@
<string name="settings_use_dnsmasq">Use DNSMasq instead of Hosts</string>
<string name="button_text_download_dnsmasq">Download DNSMasq configuration</string>
<string name="dnsmasq_path">Local DNSMasq configurations path:</string>
<string name="notice_delete_confirm_prompt">Are you sure you want to remove this DNS server?</string>
<string name="yes">Yes</string>
<string name="no">No</string>
</resources>