Fix AboutActivity crash, remove unused themes
This commit is contained in:
parent
e2f381a134
commit
089c6b8d99
@ -9,9 +9,11 @@ import org.schabi.newpipe.R
|
||||
import org.schabi.newpipe.ui.components.common.ScaffoldWithToolbar
|
||||
import org.schabi.newpipe.ui.screens.AboutScreen
|
||||
import org.schabi.newpipe.ui.theme.AppTheme
|
||||
import org.schabi.newpipe.util.ThemeHelper
|
||||
|
||||
class AboutActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setTheme(ThemeHelper.getTheme(this))
|
||||
enableEdgeToEdge()
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
|
||||
@ -86,9 +86,9 @@ public class SettingsActivity extends AppCompatActivity implements
|
||||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceBundle) {
|
||||
setTheme(ThemeHelper.getSettingsThemeStyle(this));
|
||||
|
||||
setTheme(ThemeHelper.getTheme(this));
|
||||
super.onCreate(savedInstanceBundle);
|
||||
|
||||
Bridge.restoreInstanceState(this, savedInstanceBundle);
|
||||
final boolean restored = savedInstanceBundle != null;
|
||||
|
||||
|
||||
@ -158,35 +158,33 @@ public final class ThemeHelper {
|
||||
}
|
||||
|
||||
@StyleRes
|
||||
public static int getSettingsThemeStyle(final Context context) {
|
||||
public static int getTheme(@NonNull final Context context) {
|
||||
final Resources res = context.getResources();
|
||||
final String lightTheme = res.getString(R.string.light_theme_key);
|
||||
final String blackTheme = res.getString(R.string.black_theme_key);
|
||||
final String automaticDeviceTheme = res.getString(R.string.auto_device_theme_key);
|
||||
|
||||
|
||||
final String selectedTheme = getSelectedThemeKey(context);
|
||||
|
||||
if (selectedTheme.equals(lightTheme)) {
|
||||
return R.style.LightSettingsTheme;
|
||||
return R.style.LightTheme;
|
||||
} else if (selectedTheme.equals(blackTheme)) {
|
||||
return R.style.BlackSettingsTheme;
|
||||
return R.style.BlackTheme;
|
||||
} else if (selectedTheme.equals(automaticDeviceTheme)) {
|
||||
if (isDeviceDarkThemeEnabled(context)) {
|
||||
// use the dark theme variant preferred by the user
|
||||
final String selectedNightTheme = getSelectedNightThemeKey(context);
|
||||
if (selectedNightTheme.equals(blackTheme)) {
|
||||
return R.style.BlackSettingsTheme;
|
||||
return R.style.BlackTheme;
|
||||
} else {
|
||||
return R.style.DarkSettingsTheme;
|
||||
return R.style.DarkTheme;
|
||||
}
|
||||
} else {
|
||||
// there is only one day theme
|
||||
return R.style.LightSettingsTheme;
|
||||
return R.style.LightTheme;
|
||||
}
|
||||
} else {
|
||||
// default to dark theme
|
||||
return R.style.DarkSettingsTheme;
|
||||
return R.style.DarkTheme;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -127,21 +127,14 @@
|
||||
<item name="android:windowOptOutEdgeToEdgeEnforcement" tools:targetApi="35">true</item>
|
||||
</style>
|
||||
|
||||
<!-- Black Theme -->
|
||||
<style name="BlackTheme" parent="DarkTheme"> <!-- Inherits from M3 Dark Theme -->
|
||||
<style name="BlackTheme" parent="DarkTheme">
|
||||
<item name="android:colorBackground">@color/m3_surface_black</item>
|
||||
<item name="colorSurface">@color/m3_surface_black</item>
|
||||
<item name="windowBackground">@color/m3_surface_black</item> <!-- For AppCompat -->
|
||||
<item name="windowBackground">@color/m3_surface_black</item>
|
||||
|
||||
<!-- Override specific custom attributes for true black if needed -->
|
||||
<item name="contrast_background_color">@color/m3_surface_container_low_dark</item> <!-- A very dark gray -->
|
||||
<item name="card_item_background_color">@color/m3_surface_black</item> <!-- Cards are also black -->
|
||||
<item name="card_item_contrast_color">@color/m3_on_surface_dark</item> <!-- Text on black surface -->
|
||||
|
||||
<!-- Other dark theme attributes are inherited, including drawables.
|
||||
If specific black drawables are needed, override them here. e.g.
|
||||
<item name="dashed_border">@drawable/dashed_border_black</item>
|
||||
-->
|
||||
<item name="contrast_background_color">@color/m3_surface_container_low_dark</item>
|
||||
<item name="card_item_background_color">@color/m3_surface_black</item>
|
||||
<item name="card_item_contrast_color">@color/m3_on_surface_dark</item>
|
||||
</style>
|
||||
|
||||
<!-- Component Styles -->
|
||||
@ -177,31 +170,6 @@
|
||||
<item name="backgroundTint">?attr/colorSurfaceContainerHigh</item>
|
||||
</style>
|
||||
|
||||
<!-- Retain existing dialog theme names by parenting them -->
|
||||
<style name="LightDialogTheme" parent="App.MaterialAlertDialog.Light"/>
|
||||
<style name="DarkDialogTheme" parent="App.MaterialAlertDialog.Dark"/>
|
||||
<style name="LightDialogMinWidthTheme" parent="App.MaterialAlertDialog.Light"/> <!-- M3 Dialogs handle min width well -->
|
||||
<style name="DarkDialogMinWidthTheme" parent="App.MaterialAlertDialog.Dark"/>
|
||||
|
||||
<!-- Settings Themes -->
|
||||
<!-- For preferences, M3 components within preferences (like SwitchPreferenceCompat)
|
||||
will typically use colorControlActivated (mapped to ?attr/colorPrimary)
|
||||
and other theme colors automatically.
|
||||
If 'settings_accent_color' was very specific, map it to colorPrimary or colorSecondary here.
|
||||
-->
|
||||
<style name="LightSettingsTheme" parent="LightTheme">
|
||||
<!-- If settings had a truly distinct accent, override colorPrimary or colorSecondary -->
|
||||
<!-- <item name="colorPrimary">@color/your_specific_m3_settings_accent_light</item> -->
|
||||
</style>
|
||||
|
||||
<style name="DarkSettingsTheme" parent="DarkTheme">
|
||||
<!-- <item name="colorPrimary">@color/your_specific_m3_settings_accent_dark</item> -->
|
||||
</style>
|
||||
|
||||
<style name="BlackSettingsTheme" parent="BlackTheme">
|
||||
<!-- <item name="colorPrimary">@color/your_specific_m3_settings_accent_black</item> -->
|
||||
</style>
|
||||
|
||||
<!-- Router Activity Themes -->
|
||||
<style name="RouterActivityThemeLight" parent="LightTheme">
|
||||
<item name="android:windowIsTranslucent">true</item>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user