diff --git a/res/values/strings.xml b/res/values/strings.xml
index ed8d22a..87e901b 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -33,6 +33,11 @@
Delete
Toggle
+
+ Error
+ Can\'t edit hosts, make sure your device is rooted.\nThe app should be allowed to request super user access.
+ OK
+
Delete
diff --git a/src/com/nilhcem/hostseditor/list/ListHostsFragment.java b/src/com/nilhcem/hostseditor/list/ListHostsFragment.java
index 7ac0617..83b928c 100644
--- a/src/com/nilhcem/hostseditor/list/ListHostsFragment.java
+++ b/src/com/nilhcem/hostseditor/list/ListHostsFragment.java
@@ -117,8 +117,7 @@ public void onTaskFinished(TaskCompletedEvent task) {
if (task.isSuccessful()) {
refreshHosts(false);
} else {
- // Display error message
- // Force reload
+ displayErrorDialog();
}
}
@@ -247,6 +246,27 @@ public void onClick(DialogInterface dialog, int which) {
mDisplayedDialog.show();
}
+ private void displayErrorDialog() {
+ mBus.post(new LoadingEvent(false));
+ mDisplayedDialog = new AlertDialog.Builder(mActivity)
+ .setTitle(R.string.list_error_title)
+ .setMessage(R.string.list_error_content)
+ .setNeutralButton(R.string.list_error_ok, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ refreshHosts(true);
+ }
+ })
+ .setOnCancelListener(new DialogInterface.OnCancelListener() {
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ refreshHosts(true);
+ }
+ })
+ .create();
+ mDisplayedDialog.show();
+ }
+
private void runGenericTask(Class extends GenericTaskAsync> clazz, Host[] hosts) {
runGenericTask(clazz, hosts, hosts.length == 1);
}