1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 00:20:32 +00:00

Added delete xml method inside the yes dialogue.

This commit is contained in:
Vincent Tanumihardja 2022-10-29 09:52:22 +11:00 committed by TobiGr
parent 23de9bf93e
commit 81ad50e82a

View File

@ -1,7 +1,6 @@
package org.schabi.newpipe.settings; package org.schabi.newpipe.settings;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
@ -98,31 +97,27 @@ public class DebugSettingsFragment extends BasePreferenceFragment {
// A dialogue will pop up to confirm if user intends to reset all settings // A dialogue will pop up to confirm if user intends to reset all settings
assert resetSettings != null; assert resetSettings != null;
resetSettings.setOnPreferenceClickListener(preference -> { resetSettings.setOnPreferenceClickListener(preference -> {
// Show Alert Dialogue
final AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setMessage("Resetting all settings will discard " builder.setMessage("Resetting all settings will discard "
+ "all of your preferred settings and restarts the app. " + "all of your preferred settings and restarts the app. "
+ "Are you sure you want to proceed?"); + "Are you sure you want to proceed?");
builder.setCancelable(true); builder.setCancelable(true);
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { builder.setPositiveButton("Yes", (dialogInterface, i) -> {
@Override // Deletes all shared preferences xml files.
public void onClick(final DialogInterface dialogInterface, final int i) {
NavigationHelper.restartApp(getActivity());
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(final DialogInterface dialogInterface, final int i) {
}
});
final AlertDialog alertDialog = builder.create();
alertDialog.show();
// delete all shared preferences xml files.
final SharedPreferences sharedPreferences = final SharedPreferences sharedPreferences =
PreferenceManager.getDefaultSharedPreferences(requireContext()); PreferenceManager.getDefaultSharedPreferences(requireContext());
sharedPreferences.edit().clear().apply(); sharedPreferences.edit().clear().apply();
// Restarts the app
if (getActivity() == null) {
return;
}
NavigationHelper.restartApp(getActivity());
});
builder.setNegativeButton("Cancel", (dialogInterface, i) -> {
});
final AlertDialog alertDialog = builder.create();
alertDialog.show();
return true; return true;
}); });
} }