mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 17:43:06 +02:00
Re-initialize PreferenceFragment, when sharedpreferences were reset.
This commit is contained in:
@@ -5,6 +5,7 @@ import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.preference.DialogPreference;
|
||||
import androidx.preference.PreferenceDialogFragmentCompat;
|
||||
|
||||
@@ -17,6 +18,10 @@ public class ResetDialogPreference extends DialogPreference {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
interface ResetCallback {
|
||||
void onReset();
|
||||
}
|
||||
|
||||
public static class ResetPreferenceDialog extends PreferenceDialogFragmentCompat {
|
||||
|
||||
static PreferenceDialogFragmentCompat newInstance(String preferenceKey) {
|
||||
@@ -31,9 +36,14 @@ public class ResetDialogPreference extends DialogPreference {
|
||||
@Override
|
||||
public void onDialogClosed(boolean positiveResult) {
|
||||
if (positiveResult) {
|
||||
PreferencesUtils.resetPreferences(getActivity(), true);
|
||||
FragmentActivity activity = getActivity();
|
||||
|
||||
Toast.makeText(getActivity(), R.string.settings_reset_done, Toast.LENGTH_SHORT).show();
|
||||
PreferencesUtils.resetPreferences(activity, true);
|
||||
Toast.makeText(activity, R.string.settings_reset_done, Toast.LENGTH_SHORT).show();
|
||||
|
||||
if (activity instanceof ResetCallback) {
|
||||
((ResetCallback) activity).onReset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user