Merge pull request #252 from nin0-dev/master

Fixed dynamic color on Android 12+
This commit is contained in:
Bnyro 2022-05-19 20:03:57 +02:00 committed by GitHub
commit c366dc9c95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

View File

@ -39,6 +39,7 @@ class MainActivity : AppCompatActivity() {
lateinit var navController : NavController
override fun onCreate(savedInstanceState: Bundle?) {
DynamicColors.applyToActivityIfAvailable(this)
super.onCreate(savedInstanceState)
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
RetrofitInstance.url = sharedPreferences.getString("instance", "https://pipedapi.kavin.rocks/")!!
@ -49,7 +50,7 @@ class MainActivity : AppCompatActivity() {
SponsorBlockSettings.sponsorsEnabled = sharedPreferences.getBoolean("sponsors_category_key", false)
SponsorBlockSettings.outroEnabled = sharedPreferences.getBoolean("outro_category_key", false)
DynamicColors.applyToActivitiesIfAvailable(application)
val languageName = sharedPreferences.getString("language", "sys")
if (languageName != "") {
var locale = if (languageName != "sys" && "$languageName".length < 3 ){

View File

@ -4,6 +4,7 @@ import android.app.Activity
import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import com.google.android.material.color.DynamicColors
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
@ -12,6 +13,7 @@ class Player : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
DynamicColors.applyToActivityIfAvailable(this)
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_player)

View File

@ -19,6 +19,7 @@ import androidx.appcompat.app.AppCompatDelegate
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import com.google.android.material.color.DynamicColors
import androidx.lifecycle.lifecycleScope
import androidx.preference.ListPreference
import androidx.preference.Preference
@ -36,6 +37,7 @@ class SettingsActivity : AppCompatActivity(),
SharedPreferences.OnSharedPreferenceChangeListener{
override fun onCreate(savedInstanceState: Bundle?) {
DynamicColors.applyToActivityIfAvailable(this)
super.onCreate(savedInstanceState)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
overridePendingTransition(50, 50);
@ -352,4 +354,4 @@ class SettingsActivity : AppCompatActivity(),
startActivity(intent)
}
}
}