Show dialog if root access was denied

This commit is contained in:
Dominik Schürmann 2014-04-27 20:11:36 +02:00
parent 36b269cd19
commit fbc47c1428
2 changed files with 11 additions and 1 deletions

View File

@ -238,5 +238,7 @@
<string name="requesting_root_access_title">Root access</string> <string name="requesting_root_access_title">Root access</string>
<string name="requesting_root_access_body">Requesting root access…</string> <string name="requesting_root_access_body">Requesting root access…</string>
<string name="root_access_denied_title">Root access denied</string>
<string name="root_access_denied_body">Either your Android device is not rooted or you have denied root access for F-Droid.</string>
</resources> </resources>

View File

@ -25,6 +25,8 @@ import android.preference.PreferenceActivity;
import android.preference.CheckBoxPreference; import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference; import android.preference.EditTextPreference;
import android.preference.ListPreference; import android.preference.ListPreference;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.view.MenuItem; import android.view.MenuItem;
@ -186,11 +188,17 @@ public class PreferencesActivity extends PreferenceActivity implements
editor.commit(); editor.commit();
pref.setChecked(true); pref.setChecked(true);
} else { } else {
// root access disallowed // root access denied
SharedPreferences.Editor editor = pref.getSharedPreferences().edit(); SharedPreferences.Editor editor = pref.getSharedPreferences().edit();
editor.putBoolean(Preferences.PREF_ROOT_INSTALLER, false); editor.putBoolean(Preferences.PREF_ROOT_INSTALLER, false);
editor.commit(); editor.commit();
pref.setChecked(false); pref.setChecked(false);
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(PreferencesActivity.this);
alertBuilder.setTitle(R.string.root_access_denied_title);
alertBuilder.setMessage(PreferencesActivity.this.getString(R.string.root_access_denied_body));
alertBuilder.setNeutralButton(android.R.string.ok, null);
alertBuilder.create().show();
} }
} }
}); });