Skip to content

Commit 5d101e7

Browse files
vincetzrTobiGr
authored andcommitted
Added reset button but not working as intended.
1 parent e2de831 commit 5d101e7

7 files changed

Lines changed: 50 additions & 5 deletions

File tree

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,22 @@ private void applyThemeChange(final String beginningThemeKey,
8080
ActivityCompat.recreate(getActivity());
8181
}
8282
}
83+
84+
public void resetToDefault() {
85+
final String themeKey = getString(R.string.theme_key);
86+
final String startThemeKey = defaultPreferences
87+
.getString(themeKey, getString(R.string.default_theme_value));
88+
final String autoDeviceThemeKey = getString(R.string.auto_device_theme_key);
89+
if (startThemeKey.equals(autoDeviceThemeKey)) {
90+
applyThemeChange(startThemeKey, themeKey, autoDeviceThemeKey);
91+
} else {
92+
if (startThemeKey.equals(R.string.light_theme_key)) {
93+
removePreference(getString(R.string.light_theme_key));
94+
} else if (startThemeKey.equals(R.string.dark_theme_key)) {
95+
removePreference(getString(R.string.dark_theme_key));
96+
} else {
97+
removePreference(getString(R.string.black_theme_key));
98+
}
99+
}
100+
}
83101
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package org.schabi.newpipe.settings;
2+
3+
import android.os.Bundle;
4+
5+
public class ResetSettingsFragment extends BasePreferenceFragment {
6+
7+
private AppearanceSettingsFragment appearanceSettings;
8+
@Override
9+
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
10+
addPreferencesFromResourceRegistry();
11+
12+
appearanceSettings.resetToDefault();
13+
}
14+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@
222222
<string name="prefer_original_audio_key">prefer_original_audio</string>
223223
<string name="prefer_descriptive_audio_key">prefer_descriptive_audio</string>
224224
<string name="last_resize_mode">last_resize_mode</string>
225+
<!-- RESET ONLY -->
226+
<string name="reset_pref_screen_key">reset_pref_screen_key</string>
225227

226228
<!-- DEBUG ONLY -->
227229
<string name="debug_pref_screen_key">debug_pref_screen_key</string>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@
151151
<string name="settings_category_history_title">History and cache</string>
152152
<string name="settings_category_appearance_title">Appearance</string>
153153
<string name="settings_category_debug_title">Debug</string>
154+
<string name="settings_category_reset_title">Reset All Settings</string>
154155
<string name="settings_category_updates_title">Updates</string>
155156
<string name="settings_category_player_notification_title">Player notification</string>
156157
<string name="settings_category_player_notification_summary">Configure current playing stream notification</string>

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,12 @@
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" />
5664
</PreferenceScreen>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
#Fri Oct 21 13:32:17 AEDT 2022
12
distributionBase=GRADLE_USER_HOME
23
distributionPath=wrapper/dists
34
distributionSha256Sum=e111cb9948407e26351227dabce49822fb88c37ee72f1d1582a69c68af2e702f
45
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
56
networkTimeout=10000
67
zipStoreBase=GRADLE_USER_HOME
78
zipStorePath=wrapper/dists
9+
zipStoreBase=GRADLE_USER_HOME

settings.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ include ':app'
44
// We assume, that NewPipe and NewPipe Extractor have the same parent directory.
55
// If this is not the case, please change the path in includeBuild().
66

7-
//includeBuild('../NewPipeExtractor') {
8-
// dependencySubstitution {
9-
// substitute module('com.github.TeamNewPipe:NewPipeExtractor') using project(':extractor')
10-
// }
11-
//}
7+
includeBuild('../NewPipeExtractor') {
8+
dependencySubstitution {
9+
substitute module('com.github.TeamNewPipe:NewPipeExtractor') using project(':extractor')
10+
}
11+
}

0 commit comments

Comments
 (0)