mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-31 15:23:00 +00:00 
			
		
		
		
	Added reset button but working as intended for theme.
This commit is contained in:
		 Vincent Tanumihardja
					Vincent Tanumihardja
				
			
				
					committed by
					
						 TobiGr
						TobiGr
					
				
			
			
				
	
			
			
			 TobiGr
						TobiGr
					
				
			
						parent
						
							aa1847189b
						
					
				
				
					commit
					58517d1d27
				
			| @@ -10,7 +10,9 @@ 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.PicassoHelper; | import org.schabi.newpipe.util.PicassoHelper; | ||||||
|  | import org.schabi.newpipe.util.ThemeHelper; | ||||||
|  |  | ||||||
| import java.util.Optional; | import java.util.Optional; | ||||||
|  |  | ||||||
| @@ -35,6 +37,8 @@ public class DebugSettingsFragment extends BasePreferenceFragment { | |||||||
|                 findPreference(getString(R.string.show_error_snackbar_key)); |                 findPreference(getString(R.string.show_error_snackbar_key)); | ||||||
|         final Preference createErrorNotificationPreference = |         final Preference createErrorNotificationPreference = | ||||||
|                 findPreference(getString(R.string.create_error_notification_key)); |                 findPreference(getString(R.string.create_error_notification_key)); | ||||||
|  |         final Preference resetSettings = | ||||||
|  |                 findPreference(getString(R.string.reset_settings)); | ||||||
|  |  | ||||||
|         assert allowHeapDumpingPreference != null; |         assert allowHeapDumpingPreference != null; | ||||||
|         assert showMemoryLeaksPreference != null; |         assert showMemoryLeaksPreference != null; | ||||||
| @@ -86,6 +90,15 @@ public class DebugSettingsFragment extends BasePreferenceFragment { | |||||||
|                     new ErrorInfo(new RuntimeException(DUMMY), UserAction.UI_ERROR, DUMMY)); |                     new ErrorInfo(new RuntimeException(DUMMY), UserAction.UI_ERROR, DUMMY)); | ||||||
|             return true; |             return true; | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|  |         // reset appearance to light theme | ||||||
|  |         resetSettings.setOnPreferenceClickListener(preference -> { | ||||||
|  |             defaultPreferences.edit().putBoolean(Constants.KEY_THEME_CHANGE, true).apply(); | ||||||
|  |             defaultPreferences.edit().putString(getString(R.string.theme_key), | ||||||
|  |                     getString(R.string.light_theme_key)).apply(); | ||||||
|  |             ThemeHelper.setDayNightMode(requireContext(), "light_theme"); | ||||||
|  |             return true; | ||||||
|  |         }); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -1,23 +0,0 @@ | |||||||
| package org.schabi.newpipe.settings; |  | ||||||
|  |  | ||||||
| import android.os.Bundle; |  | ||||||
|  |  | ||||||
| import androidx.core.app.ActivityCompat; |  | ||||||
|  |  | ||||||
| import org.schabi.newpipe.R; |  | ||||||
| import org.schabi.newpipe.util.Constants; |  | ||||||
| import org.schabi.newpipe.util.ThemeHelper; |  | ||||||
|  |  | ||||||
| public class ResetSettingsFragment extends BasePreferenceFragment { |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) { |  | ||||||
|         addPreferencesFromResourceRegistry(); |  | ||||||
|  |  | ||||||
|         // reset appearance to light theme |  | ||||||
|         defaultPreferences.edit().putBoolean(Constants.KEY_THEME_CHANGE, true).apply(); |  | ||||||
|         defaultPreferences.edit().putString(getString(R.string.theme_key), |  | ||||||
|                 getString(R.string.light_theme_key)).apply(); |  | ||||||
|         ThemeHelper.setDayNightMode(requireContext(), "light_theme"); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -30,7 +30,6 @@ public final class SettingsResourceRegistry { | |||||||
|  |  | ||||||
|     private SettingsResourceRegistry() { |     private SettingsResourceRegistry() { | ||||||
|         add(MainSettingsFragment.class, R.xml.main_settings).setSearchable(false); |         add(MainSettingsFragment.class, R.xml.main_settings).setSearchable(false); | ||||||
|  |  | ||||||
|         add(AppearanceSettingsFragment.class, R.xml.appearance_settings); |         add(AppearanceSettingsFragment.class, R.xml.appearance_settings); | ||||||
|         add(ContentSettingsFragment.class, R.xml.content_settings); |         add(ContentSettingsFragment.class, R.xml.content_settings); | ||||||
|         add(DebugSettingsFragment.class, R.xml.debug_settings).setSearchable(false); |         add(DebugSettingsFragment.class, R.xml.debug_settings).setSearchable(false); | ||||||
| @@ -41,7 +40,6 @@ public final class SettingsResourceRegistry { | |||||||
|         add(UpdateSettingsFragment.class, R.xml.update_settings); |         add(UpdateSettingsFragment.class, R.xml.update_settings); | ||||||
|         add(VideoAudioSettingsFragment.class, R.xml.video_audio_settings); |         add(VideoAudioSettingsFragment.class, R.xml.video_audio_settings); | ||||||
|         add(ExoPlayerSettingsFragment.class, R.xml.exoplayer_settings); |         add(ExoPlayerSettingsFragment.class, R.xml.exoplayer_settings); | ||||||
|         add(ResetSettingsFragment.class, R.xml.main_settings); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private SettingRegistryEntry add( |     private SettingRegistryEntry add( | ||||||
|   | |||||||
| @@ -223,7 +223,7 @@ | |||||||
|     <string name="prefer_descriptive_audio_key">prefer_descriptive_audio</string> |     <string name="prefer_descriptive_audio_key">prefer_descriptive_audio</string> | ||||||
|     <string name="last_resize_mode">last_resize_mode</string> |     <string name="last_resize_mode">last_resize_mode</string> | ||||||
|     <!-- RESET ONLY --> |     <!-- RESET ONLY --> | ||||||
|     <string name="reset_pref_screen_key">reset_pref_screen_key</string> |     <string name="reset_settings">reset_settings</string> | ||||||
|  |  | ||||||
|     <!-- DEBUG ONLY --> |     <!-- DEBUG ONLY --> | ||||||
|     <string name="debug_pref_screen_key">debug_pref_screen_key</string> |     <string name="debug_pref_screen_key">debug_pref_screen_key</string> | ||||||
|   | |||||||
| @@ -71,4 +71,9 @@ | |||||||
|         android:title="@string/create_error_notification" |         android:title="@string/create_error_notification" | ||||||
|         app:singleLineTitle="false" |         app:singleLineTitle="false" | ||||||
|         app:iconSpaceReserved="false" /> |         app:iconSpaceReserved="false" /> | ||||||
|  |     <Preference | ||||||
|  |         android:icon="@drawable/ic_replay" | ||||||
|  |         android:key="@string/reset_settings" | ||||||
|  |         android:title="@string/settings_category_reset_title" | ||||||
|  |         app:iconSpaceReserved="false" /> | ||||||
| </PreferenceScreen> | </PreferenceScreen> | ||||||
|   | |||||||
| @@ -53,12 +53,4 @@ | |||||||
|         android:key="@string/debug_pref_screen_key" |         android:key="@string/debug_pref_screen_key" | ||||||
|         android:title="@string/settings_category_debug_title" |         android:title="@string/settings_category_debug_title" | ||||||
|         app:iconSpaceReserved="false" /> |         app:iconSpaceReserved="false" /> | ||||||
|     <PreferenceScreen |  | ||||||
|         android:fragment="org.schabi.newpipe.settings.ResetSettingsFragment" |  | ||||||
|         android:layout_width="wrap_content" |  | ||||||
|         android:layout_height="wrap_content" |  | ||||||
|         android:icon="@drawable/ic_replay" |  | ||||||
|         android:key="@string/reset_pref_screen_key" |  | ||||||
|         android:title="@string/settings_category_reset_title" |  | ||||||
|         app:iconSpaceReserved="false" /> |  | ||||||
| </PreferenceScreen> | </PreferenceScreen> | ||||||
|   | |||||||
| @@ -1,4 +0,0 @@ | |||||||
| <?xml version="1.0" encoding="utf-8"?> |  | ||||||
| <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> |  | ||||||
|  |  | ||||||
| </PreferenceScreen> |  | ||||||
		Reference in New Issue
	
	Block a user