Support day/night theme in custom tabs
This commit is contained in:
@@ -75,7 +75,7 @@ androidExtensions {
|
||||
dependencies {
|
||||
kapt "androidx.room:room-compiler:$roomVersion"
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation 'androidx.browser:browser:1.0.0'
|
||||
implementation 'androidx.browser:browser:1.2.0-alpha07'
|
||||
implementation 'androidx.core:core-ktx:1.1.0-rc03'
|
||||
implementation 'androidx.emoji:emoji:1.0.0'
|
||||
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion"
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.content.res.Configuration
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.wifi.WifiManager
|
||||
import android.os.Build
|
||||
import androidx.browser.customtabs.CustomTabColorSchemeParams
|
||||
import androidx.browser.customtabs.CustomTabsIntent
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.getSystemService
|
||||
@@ -78,8 +79,14 @@ class App : Application() {
|
||||
|
||||
val hasTouch by lazy { packageManager.hasSystemFeature("android.hardware.faketouch") }
|
||||
val customTabsIntent by lazy {
|
||||
CustomTabsIntent.Builder()
|
||||
.setToolbarColor(ContextCompat.getColor(this, R.color.colorPrimary))
|
||||
.build()
|
||||
CustomTabsIntent.Builder().apply {
|
||||
setColorScheme(CustomTabsIntent.COLOR_SCHEME_SYSTEM)
|
||||
setColorSchemeParams(CustomTabsIntent.COLOR_SCHEME_LIGHT, CustomTabColorSchemeParams.Builder().apply {
|
||||
setToolbarColor(ContextCompat.getColor(app, R.color.light_colorPrimary))
|
||||
}.build())
|
||||
setColorSchemeParams(CustomTabsIntent.COLOR_SCHEME_DARK, CustomTabColorSchemeParams.Builder().apply {
|
||||
setToolbarColor(ContextCompat.getColor(app, R.color.dark_colorPrimary))
|
||||
}.build())
|
||||
}.build()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#2e7d32</color>
|
||||
<color name="colorPrimary">@color/dark_colorPrimary</color>
|
||||
<color name="colorPrimaryDark">#005005</color>
|
||||
<color name="colorSecondary">#AEEA00</color>
|
||||
<!-- This actually takes precedence over v27: https://developer.android.com/guide/topics/resources/providing-resources.html#BestMatch -->
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#4CAF50</color>
|
||||
<color name="light_colorPrimary">#4CAF50</color>
|
||||
<color name="dark_colorPrimary">#2e7d32</color>
|
||||
|
||||
<color name="colorPrimary">@color/light_colorPrimary</color>
|
||||
<color name="colorPrimaryDark">#087f23</color>
|
||||
<color name="colorSecondary">#AEEA00</color>
|
||||
<color name="navigationBarColor">@android:color/black</color>
|
||||
|
||||
Reference in New Issue
Block a user