Merge pull request #706 from Bnyro/master

fix material you
This commit is contained in:
Bnyro 2022-07-06 16:58:30 +02:00 committed by GitHub
commit 93cdc56e20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 15 deletions

View File

@ -47,7 +47,23 @@ class MainActivity : AppCompatActivity() {
private var startFragmentId = R.id.homeFragment
override fun onCreate(savedInstanceState: Bundle?) {
/**
* 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)

View File

@ -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?) {
/**
* apply dynamic colors if enabled
*/
val materialColorsEnabled = PreferenceHelper
.getString(this, "accent_color", "purple") == "my"
if (materialColorsEnabled) {
DynamicColors.applyToActivityIfAvailable(this)
ThemeHelper.updateTheme(this)
}
super.onCreate(savedInstanceState)
binding = ActivityNointernetBinding.inflate(layoutInflater)

View File

@ -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)

View File

@ -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>

View File

@ -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>

View File

@ -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>