Skip to content

Commit 58517d1

Browse files
vincetzrTobiGr
authored andcommitted
Added reset button but working as intended for theme.
1 parent aa18471 commit 58517d1

7 files changed

Lines changed: 19 additions & 38 deletions

File tree

app/src/main/java/org/schabi/newpipe/settings/DebugSettingsFragment.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
import org.schabi.newpipe.error.ErrorUtil;
1111
import org.schabi.newpipe.error.UserAction;
1212
import org.schabi.newpipe.local.feed.notifications.NotificationWorker;
13+
import org.schabi.newpipe.util.Constants;
1314
import org.schabi.newpipe.util.PicassoHelper;
15+
import org.schabi.newpipe.util.ThemeHelper;
1416

1517
import java.util.Optional;
1618

@@ -35,6 +37,8 @@ public void onCreatePreferences(final Bundle savedInstanceState, final String ro
3537
findPreference(getString(R.string.show_error_snackbar_key));
3638
final Preference createErrorNotificationPreference =
3739
findPreference(getString(R.string.create_error_notification_key));
40+
final Preference resetSettings =
41+
findPreference(getString(R.string.reset_settings));
3842

3943
assert allowHeapDumpingPreference != null;
4044
assert showMemoryLeaksPreference != null;
@@ -86,6 +90,15 @@ public void onCreatePreferences(final Bundle savedInstanceState, final String ro
8690
new ErrorInfo(new RuntimeException(DUMMY), UserAction.UI_ERROR, DUMMY));
8791
return true;
8892
});
93+
94+
// reset appearance to light theme
95+
resetSettings.setOnPreferenceClickListener(preference -> {
96+
defaultPreferences.edit().putBoolean(Constants.KEY_THEME_CHANGE, true).apply();
97+
defaultPreferences.edit().putString(getString(R.string.theme_key),
98+
getString(R.string.light_theme_key)).apply();
99+
ThemeHelper.setDayNightMode(requireContext(), "light_theme");
100+
return true;
101+
});
89102
}
90103

91104
/**

app/src/main/java/org/schabi/newpipe/settings/ResetSettingsFragment.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

app/src/main/java/org/schabi/newpipe/settings/SettingsResourceRegistry.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public final class SettingsResourceRegistry {
3030

3131
private SettingsResourceRegistry() {
3232
add(MainSettingsFragment.class, R.xml.main_settings).setSearchable(false);
33-
3433
add(AppearanceSettingsFragment.class, R.xml.appearance_settings);
3534
add(ContentSettingsFragment.class, R.xml.content_settings);
3635
add(DebugSettingsFragment.class, R.xml.debug_settings).setSearchable(false);
@@ -41,7 +40,6 @@ private SettingsResourceRegistry() {
4140
add(UpdateSettingsFragment.class, R.xml.update_settings);
4241
add(VideoAudioSettingsFragment.class, R.xml.video_audio_settings);
4342
add(ExoPlayerSettingsFragment.class, R.xml.exoplayer_settings);
44-
add(ResetSettingsFragment.class, R.xml.main_settings);
4543
}
4644

4745
private SettingRegistryEntry add(

app/src/main/res/values/settings_keys.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@
223223
<string name="prefer_descriptive_audio_key">prefer_descriptive_audio</string>
224224
<string name="last_resize_mode">last_resize_mode</string>
225225
<!-- RESET ONLY -->
226-
<string name="reset_pref_screen_key">reset_pref_screen_key</string>
226+
<string name="reset_settings">reset_settings</string>
227227

228228
<!-- DEBUG ONLY -->
229229
<string name="debug_pref_screen_key">debug_pref_screen_key</string>

app/src/main/res/xml/debug_settings.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,9 @@
7171
android:title="@string/create_error_notification"
7272
app:singleLineTitle="false"
7373
app:iconSpaceReserved="false" />
74+
<Preference
75+
android:icon="@drawable/ic_replay"
76+
android:key="@string/reset_settings"
77+
android:title="@string/settings_category_reset_title"
78+
app:iconSpaceReserved="false" />
7479
</PreferenceScreen>

app/src/main/res/xml/main_settings.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,4 @@
5353
android:key="@string/debug_pref_screen_key"
5454
android:title="@string/settings_category_debug_title"
5555
app:iconSpaceReserved="false" />
56-
<PreferenceScreen
57-
android:fragment="org.schabi.newpipe.settings.ResetSettingsFragment"
58-
android:layout_width="wrap_content"
59-
android:layout_height="wrap_content"
60-
android:icon="@drawable/ic_replay"
61-
android:key="@string/reset_pref_screen_key"
62-
android:title="@string/settings_category_reset_title"
63-
app:iconSpaceReserved="false" />
6456
</PreferenceScreen>

app/src/main/res/xml/reset_settings.xml

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)