mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-31 15:23:00 +00:00 
			
		
		
		
	Added reset button but slightly working as intended.
This commit is contained in:
		 Vincent Tanumihardja
					Vincent Tanumihardja
				
			
				
					committed by
					
						 TobiGr
						TobiGr
					
				
			
			
				
	
			
			
			 TobiGr
						TobiGr
					
				
			
						parent
						
							5d101e7b88
						
					
				
				
					commit
					aa1847189b
				
			| @@ -80,22 +80,4 @@ public class AppearanceSettingsFragment extends BasePreferenceFragment { | |||||||
|             ActivityCompat.recreate(getActivity()); |             ActivityCompat.recreate(getActivity()); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void resetToDefault() { |  | ||||||
|         final String themeKey = getString(R.string.theme_key); |  | ||||||
|         final String startThemeKey = defaultPreferences |  | ||||||
|                 .getString(themeKey, getString(R.string.default_theme_value)); |  | ||||||
|         final String autoDeviceThemeKey = getString(R.string.auto_device_theme_key); |  | ||||||
|         if (startThemeKey.equals(autoDeviceThemeKey)) { |  | ||||||
|             applyThemeChange(startThemeKey, themeKey, autoDeviceThemeKey); |  | ||||||
|             } else { |  | ||||||
|             if (startThemeKey.equals(R.string.light_theme_key)) { |  | ||||||
|                 removePreference(getString(R.string.light_theme_key)); |  | ||||||
|             } else if (startThemeKey.equals(R.string.dark_theme_key)) { |  | ||||||
|                 removePreference(getString(R.string.dark_theme_key)); |  | ||||||
|             } else { |  | ||||||
|                 removePreference(getString(R.string.black_theme_key)); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -2,13 +2,22 @@ package org.schabi.newpipe.settings; | |||||||
|  |  | ||||||
| import android.os.Bundle; | 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 { | public class ResetSettingsFragment extends BasePreferenceFragment { | ||||||
|  |  | ||||||
|     private AppearanceSettingsFragment appearanceSettings; |  | ||||||
|     @Override |     @Override | ||||||
|     public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) { |     public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) { | ||||||
|         addPreferencesFromResourceRegistry(); |         addPreferencesFromResourceRegistry(); | ||||||
|  |  | ||||||
|         appearanceSettings.resetToDefault(); |         // 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"); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -41,6 +41,7 @@ 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( | ||||||
|   | |||||||
							
								
								
									
										4
									
								
								app/src/main/res/xml/reset_settings.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								app/src/main/res/xml/reset_settings.xml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | |||||||
|  | <?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