use of de.mkrtchyan.recoverytools.ReportDialog in project Rashr by DsLNeXuS.
the class SettingsFragment method onCreatePreferences.
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.preferences);
EditTextPreference recovery_path = (EditTextPreference) findPreference(App.PREF_KEY_RECOVERY_PATH);
recovery_path.setText(App.Preferences.getString(App.PREF_KEY_RECOVERY_PATH, null));
EditTextPreference kernel_path = (EditTextPreference) findPreference(App.PREF_KEY_KERNEL_PATH);
kernel_path.setText(App.Preferences.getString(App.PREF_KEY_KERNEL_PATH, null));
EditTextPreference device_name = (EditTextPreference) findPreference(App.PREF_KEY_DEVICE_NAME);
device_name.setText(App.Device.getName());
device_name.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
View v = getView();
if (v == null)
return true;
if (!newValue.toString().equals("")) {
Snackbar.make(v, R.string.please_restart, Snackbar.LENGTH_INDEFINITE).show();
}
return true;
}
});
Preference changelog = findPreference(App.PREF_KEY_CHANGELOG);
changelog.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
showChangelog(getContext());
return false;
}
});
Preference showlogs = findPreference(App.PREF_KEY_SHOW_LOGS);
showlogs.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
showLogs();
return false;
}
});
Preference report = findPreference(App.PREF_KEY_REPORT);
report.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
new ReportDialog(getActivity(), "").show();
return false;
}
});
Preference licenses = findPreference(App.PREF_KEY_LICENSES);
licenses.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
new LicensesDialog.Builder(getContext()).setNotices(R.raw.licenses_notice).setIncludeOwnLicense(true).build().show();
return false;
}
});
Preference reset = findPreference(App.PREF_KEY_RESET_APP);
reset.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
PreferenceManager.setDefaultValues(getActivity(), R.xml.preferences, true);
return true;
}
});
Preference clearCache = findPreference(App.PREF_KEY_CLEAR_CACHE);
clearCache.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
final AlertDialog.Builder ConfirmationDialog = new AlertDialog.Builder(getContext());
ConfirmationDialog.setTitle(R.string.warning);
ConfirmationDialog.setMessage(R.string.delete_confirmation);
ConfirmationDialog.setPositiveButton(R.string.positive, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (!Common.deleteFolder(App.PathToCWM, false) || !Common.deleteFolder(App.PathToTWRP, false) || !Common.deleteFolder(App.PathToPhilz, false) || !Common.deleteFolder(App.PathToCM, false) || !Common.deleteFolder(App.PathToPhilz, false) || !Common.deleteFolder(App.PathToStockRecovery, false) || !Common.deleteFolder(App.PathToStockKernel, false)) {
Toast.makeText(getActivity(), R.string.delete_failed, Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getActivity(), R.string.files_deleted, Toast.LENGTH_SHORT).show();
}
}
});
ConfirmationDialog.setNegativeButton(R.string.negative, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
ConfirmationDialog.show();
return false;
}
});
}
Aggregations