Skip to content

Commit f2d9ad8

Browse files
Fix AboutActivity crash, remove unused themes
1 parent e2f381a commit f2d9ad8

File tree

5 files changed

+16
-50
lines changed

5 files changed

+16
-50
lines changed

app/src/main/java/org/schabi/newpipe/about/AboutActivity.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ import org.schabi.newpipe.R
99
import org.schabi.newpipe.ui.components.common.ScaffoldWithToolbar
1010
import org.schabi.newpipe.ui.screens.AboutScreen
1111
import org.schabi.newpipe.ui.theme.AppTheme
12+
import org.schabi.newpipe.util.ThemeHelper
1213

1314
class AboutActivity : AppCompatActivity() {
1415
override fun onCreate(savedInstanceState: Bundle?) {
16+
setTheme(ThemeHelper.getTheme(this))
1517
enableEdgeToEdge()
1618
super.onCreate(savedInstanceState)
1719

app/src/main/java/org/schabi/newpipe/local/feed/notifications/NotificationWorker.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package org.schabi.newpipe.local.feed.notifications
22

33
import android.content.Context
4-
import android.content.pm.ServiceInfo
5-
import android.os.Build
64
import android.util.Log
75
import androidx.core.app.NotificationCompat
86
import androidx.work.Constraints

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ public class SettingsActivity extends AppCompatActivity implements
8686

8787
@Override
8888
protected void onCreate(final Bundle savedInstanceBundle) {
89-
setTheme(ThemeHelper.getSettingsThemeStyle(this));
90-
89+
setTheme(ThemeHelper.getTheme(this));
9190
super.onCreate(savedInstanceBundle);
91+
9292
Bridge.restoreInstanceState(this, savedInstanceBundle);
9393
final boolean restored = savedInstanceBundle != null;
9494

app/src/main/java/org/schabi/newpipe/util/ThemeHelper.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,35 +158,33 @@ public static int getThemeForService(final Context context, final int serviceId)
158158
}
159159

160160
@StyleRes
161-
public static int getSettingsThemeStyle(final Context context) {
161+
public static int getTheme(@NonNull final Context context) {
162162
final Resources res = context.getResources();
163163
final String lightTheme = res.getString(R.string.light_theme_key);
164164
final String blackTheme = res.getString(R.string.black_theme_key);
165165
final String automaticDeviceTheme = res.getString(R.string.auto_device_theme_key);
166-
167-
168166
final String selectedTheme = getSelectedThemeKey(context);
169167

170168
if (selectedTheme.equals(lightTheme)) {
171-
return R.style.LightSettingsTheme;
169+
return R.style.LightTheme;
172170
} else if (selectedTheme.equals(blackTheme)) {
173-
return R.style.BlackSettingsTheme;
171+
return R.style.BlackTheme;
174172
} else if (selectedTheme.equals(automaticDeviceTheme)) {
175173
if (isDeviceDarkThemeEnabled(context)) {
176174
// use the dark theme variant preferred by the user
177175
final String selectedNightTheme = getSelectedNightThemeKey(context);
178176
if (selectedNightTheme.equals(blackTheme)) {
179-
return R.style.BlackSettingsTheme;
177+
return R.style.BlackTheme;
180178
} else {
181-
return R.style.DarkSettingsTheme;
179+
return R.style.DarkTheme;
182180
}
183181
} else {
184182
// there is only one day theme
185-
return R.style.LightSettingsTheme;
183+
return R.style.LightTheme;
186184
}
187185
} else {
188186
// default to dark theme
189-
return R.style.DarkSettingsTheme;
187+
return R.style.DarkTheme;
190188
}
191189
}
192190

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

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -127,21 +127,14 @@
127127
<item name="android:windowOptOutEdgeToEdgeEnforcement" tools:targetApi="35">true</item>
128128
</style>
129129

130-
<!-- Black Theme -->
131-
<style name="BlackTheme" parent="DarkTheme"> <!-- Inherits from M3 Dark Theme -->
130+
<style name="BlackTheme" parent="DarkTheme">
132131
<item name="android:colorBackground">@color/m3_surface_black</item>
133132
<item name="colorSurface">@color/m3_surface_black</item>
134-
<item name="windowBackground">@color/m3_surface_black</item> <!-- For AppCompat -->
133+
<item name="windowBackground">@color/m3_surface_black</item>
135134

136-
<!-- Override specific custom attributes for true black if needed -->
137-
<item name="contrast_background_color">@color/m3_surface_container_low_dark</item> <!-- A very dark gray -->
138-
<item name="card_item_background_color">@color/m3_surface_black</item> <!-- Cards are also black -->
139-
<item name="card_item_contrast_color">@color/m3_on_surface_dark</item> <!-- Text on black surface -->
140-
141-
<!-- Other dark theme attributes are inherited, including drawables.
142-
If specific black drawables are needed, override them here. e.g.
143-
<item name="dashed_border">@drawable/dashed_border_black</item>
144-
-->
135+
<item name="contrast_background_color">@color/m3_surface_container_low_dark</item>
136+
<item name="card_item_background_color">@color/m3_surface_black</item>
137+
<item name="card_item_contrast_color">@color/m3_on_surface_dark</item>
145138
</style>
146139

147140
<!-- Component Styles -->
@@ -177,31 +170,6 @@
177170
<item name="backgroundTint">?attr/colorSurfaceContainerHigh</item>
178171
</style>
179172

180-
<!-- Retain existing dialog theme names by parenting them -->
181-
<style name="LightDialogTheme" parent="App.MaterialAlertDialog.Light"/>
182-
<style name="DarkDialogTheme" parent="App.MaterialAlertDialog.Dark"/>
183-
<style name="LightDialogMinWidthTheme" parent="App.MaterialAlertDialog.Light"/> <!-- M3 Dialogs handle min width well -->
184-
<style name="DarkDialogMinWidthTheme" parent="App.MaterialAlertDialog.Dark"/>
185-
186-
<!-- Settings Themes -->
187-
<!-- For preferences, M3 components within preferences (like SwitchPreferenceCompat)
188-
will typically use colorControlActivated (mapped to ?attr/colorPrimary)
189-
and other theme colors automatically.
190-
If 'settings_accent_color' was very specific, map it to colorPrimary or colorSecondary here.
191-
-->
192-
<style name="LightSettingsTheme" parent="LightTheme">
193-
<!-- If settings had a truly distinct accent, override colorPrimary or colorSecondary -->
194-
<!-- <item name="colorPrimary">@color/your_specific_m3_settings_accent_light</item> -->
195-
</style>
196-
197-
<style name="DarkSettingsTheme" parent="DarkTheme">
198-
<!-- <item name="colorPrimary">@color/your_specific_m3_settings_accent_dark</item> -->
199-
</style>
200-
201-
<style name="BlackSettingsTheme" parent="BlackTheme">
202-
<!-- <item name="colorPrimary">@color/your_specific_m3_settings_accent_black</item> -->
203-
</style>
204-
205173
<!-- Router Activity Themes -->
206174
<style name="RouterActivityThemeLight" parent="LightTheme">
207175
<item name="android:windowIsTranslucent">true</item>

0 commit comments

Comments
 (0)