mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 16:00:31 +05:30
commit
93cdc56e20
@ -47,7 +47,23 @@ class MainActivity : AppCompatActivity() {
|
||||
private var startFragmentId = R.id.homeFragment
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
DynamicColors.applyToActivityIfAvailable(this)
|
||||
/**
|
||||
* apply dynamic colors if enabled
|
||||
*/
|
||||
val materialColorsEnabled = PreferenceHelper
|
||||
.getString(this, "accent_color", "purple") == "my"
|
||||
if (materialColorsEnabled) {
|
||||
// apply dynamic colors to the current activity
|
||||
DynamicColors.applyToActivityIfAvailable(this)
|
||||
// apply dynamic colors to the all other activities
|
||||
DynamicColors.applyToActivitiesIfAvailable(application)
|
||||
}
|
||||
|
||||
// set the theme
|
||||
ThemeHelper.updateTheme(applicationContext)
|
||||
// set the language
|
||||
LocaleHelper.updateLanguage(applicationContext)
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
// start service that gets called on closure
|
||||
@ -69,9 +85,6 @@ class MainActivity : AppCompatActivity() {
|
||||
RetrofitInstance.url
|
||||
}
|
||||
|
||||
ThemeHelper.updateTheme(this)
|
||||
LocaleHelper.updateLanguage(this)
|
||||
|
||||
// show noInternet Activity if no internet available on app startup
|
||||
if (!ConnectionHelper.isNetworkAvailable(this)) {
|
||||
val noInternetIntent = Intent(this, NoInternetActivity::class.java)
|
||||
|
@ -5,6 +5,7 @@ import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.databinding.ActivityNointernetBinding
|
||||
import com.github.libretube.preferences.PreferenceHelper
|
||||
import com.github.libretube.util.ConnectionHelper
|
||||
import com.github.libretube.util.ThemeHelper
|
||||
import com.google.android.material.color.DynamicColors
|
||||
@ -14,8 +15,15 @@ class NoInternetActivity : AppCompatActivity() {
|
||||
private lateinit var binding: ActivityNointernetBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
DynamicColors.applyToActivityIfAvailable(this)
|
||||
ThemeHelper.updateTheme(this)
|
||||
/**
|
||||
* apply dynamic colors if enabled
|
||||
*/
|
||||
val materialColorsEnabled = PreferenceHelper
|
||||
.getString(this, "accent_color", "purple") == "my"
|
||||
if (materialColorsEnabled) {
|
||||
DynamicColors.applyToActivityIfAvailable(this)
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
binding = ActivityNointernetBinding.inflate(layoutInflater)
|
||||
|
@ -22,7 +22,7 @@ object ThemeHelper {
|
||||
|
||||
private fun updateAccentColor(context: Context) {
|
||||
when (PreferenceHelper.getString(context, "accent_color", "purple")) {
|
||||
"my" -> context.setTheme(R.style.Theme_MY)
|
||||
"my" -> context.setTheme(R.style.MaterialYou)
|
||||
"red" -> context.setTheme(R.style.Theme_Red)
|
||||
"blue" -> context.setTheme(R.style.Theme_Blue)
|
||||
"yellow" -> context.setTheme(R.style.Theme_Yellow)
|
||||
|
@ -1,6 +1,6 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<style name="Theme.MY" parent="Theme.Material3.Dark.NoActionBar">
|
||||
<style name="MaterialYou">
|
||||
|
||||
<item name="android:statusBarColor" tools:targetApi="m">@android:color/transparent</item>
|
||||
<item name="android:windowLightStatusBar" tools:targetApi="m">false</item>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<style name="Theme.MY" parent="Theme.Material3.Light.NoActionBar">
|
||||
<style name="MaterialYou">
|
||||
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<item name="android:windowLightStatusBar">true</item>
|
||||
|
@ -1,11 +1,5 @@
|
||||
<resources>
|
||||
|
||||
<style name="Theme.MY" parent="Theme.Material3.Light.NoActionBar">
|
||||
|
||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="Theme.Red" parent="Theme.Material3.Light.NoActionBar">
|
||||
|
||||
<item name="colorPrimary">@color/red_light_accentLight</item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user