mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-01-03 14:00:32 +00:00
Added alert dialogue and restarts the app when resetting settings.
This commit is contained in:
parent
2103a04092
commit
076e9eee01
@ -1,5 +1,7 @@
|
|||||||
package org.schabi.newpipe.settings;
|
package org.schabi.newpipe.settings;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
@ -10,9 +12,8 @@ import org.schabi.newpipe.error.ErrorInfo;
|
|||||||
import org.schabi.newpipe.error.ErrorUtil;
|
import org.schabi.newpipe.error.ErrorUtil;
|
||||||
import org.schabi.newpipe.error.UserAction;
|
import org.schabi.newpipe.error.UserAction;
|
||||||
import org.schabi.newpipe.local.feed.notifications.NotificationWorker;
|
import org.schabi.newpipe.local.feed.notifications.NotificationWorker;
|
||||||
import org.schabi.newpipe.util.Constants;
|
import org.schabi.newpipe.util.NavigationHelper;
|
||||||
import org.schabi.newpipe.util.PicassoHelper;
|
import org.schabi.newpipe.util.PicassoHelper;
|
||||||
import org.schabi.newpipe.util.ThemeHelper;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@ -91,12 +92,30 @@ public class DebugSettingsFragment extends BasePreferenceFragment {
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
// reset appearance to light theme
|
// Resets all settings by deleting shared preference and restarting the app
|
||||||
|
// A dialogue will pop up to confirm if user intends to reset all settings
|
||||||
resetSettings.setOnPreferenceClickListener(preference -> {
|
resetSettings.setOnPreferenceClickListener(preference -> {
|
||||||
defaultPreferences.edit().putBoolean(Constants.KEY_THEME_CHANGE, true).apply();
|
final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||||
defaultPreferences.edit().putString(getString(R.string.theme_key),
|
builder.setMessage("Resetting all settings will discard "
|
||||||
getString(R.string.light_theme_key)).apply();
|
+ "all of your preferred settings and restarts the app. "
|
||||||
ThemeHelper.setDayNightMode(requireContext(), "light_theme");
|
+ "Are you sure you want to do this?");
|
||||||
|
builder.setCancelable(true);
|
||||||
|
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
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();
|
||||||
|
// SharedPreferences sharedPreferences =
|
||||||
|
// PreferenceManager.getDefaultSharedPreferences(requireContext());
|
||||||
|
// sharedPreferences = null;
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user