Commit 2ca9b6d8 authored by Mygod's avatar Mygod

Supply day/night colors in custom tabs

parent a8b01b66
...@@ -60,7 +60,7 @@ androidExtensions { ...@@ -60,7 +60,7 @@ androidExtensions {
dependencies { dependencies {
implementation project(':core') implementation project(':core')
implementation 'androidx.browser:browser:1.0.0' implementation 'androidx.browser:browser:1.2.0-alpha07'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2' implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
implementation 'com.google.android.gms:play-services-vision:18.0.0' implementation 'com.google.android.gms:play-services-vision:18.0.0'
implementation 'com.google.firebase:firebase-ads:18.1.1' implementation 'com.google.firebase:firebase-ads:18.1.1'
......
...@@ -33,6 +33,7 @@ import android.view.KeyCharacterMap ...@@ -33,6 +33,7 @@ import android.view.KeyCharacterMap
import android.view.KeyEvent import android.view.KeyEvent
import android.view.MenuItem import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.browser.customtabs.CustomTabColorSchemeParams
import androidx.browser.customtabs.CustomTabsIntent import androidx.browser.customtabs.CustomTabsIntent
import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
...@@ -76,9 +77,15 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Callback, OnPref ...@@ -76,9 +77,15 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Callback, OnPref
} }
private val customTabsIntent by lazy { private val customTabsIntent by lazy {
CustomTabsIntent.Builder() CustomTabsIntent.Builder().apply {
.setToolbarColor(ContextCompat.getColor(this, R.color.color_primary)) setColorScheme(CustomTabsIntent.COLOR_SCHEME_SYSTEM)
.build() setColorSchemeParams(CustomTabsIntent.COLOR_SCHEME_LIGHT, CustomTabColorSchemeParams.Builder().apply {
setToolbarColor(ContextCompat.getColor(this@MainActivity, R.color.light_color_primary))
}.build())
setColorSchemeParams(CustomTabsIntent.COLOR_SCHEME_DARK, CustomTabColorSchemeParams.Builder().apply {
setToolbarColor(ContextCompat.getColor(this@MainActivity, R.color.dark_color_primary))
}.build())
}.build()
} }
fun launchUrl(uri: String) = try { fun launchUrl(uri: String) = try {
customTabsIntent.launchUrl(this, uri.toUri()) customTabsIntent.launchUrl(this, uri.toUri())
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="color_primary">@color/dark_color_primary</color>
<color name="color_primary">@color/material_primary_800</color> <color name="color_primary_dark">@color/dark_color_primary_dark</color>
<color name="color_primary_dark">@color/material_primary_900</color> <color name="color_primary_text">@color/dark_color_primary_text</color>
<color name="color_primary_text">@color/material_primary_300</color> </resources>
</resources>
\ No newline at end of file
...@@ -18,8 +18,15 @@ ...@@ -18,8 +18,15 @@
<color name="material_primary_900">@color/material_blue_grey_900</color> <color name="material_primary_900">@color/material_blue_grey_900</color>
<color name="material_accent_200">@color/material_green_a700</color> <color name="material_accent_200">@color/material_green_a700</color>
<color name="color_primary">@color/material_primary_500</color> <color name="light_color_primary">@color/material_primary_500</color>
<color name="color_primary_dark">@color/material_primary_700</color> <color name="light_color_primary_dark">@color/material_primary_700</color>
<color name="color_primary_text">@color/material_primary_500</color> <color name="light_color_primary_text">@color/material_primary_500</color>
<color name="dark_color_primary">@color/material_primary_800</color>
<color name="dark_color_primary_dark">@color/material_primary_900</color>
<color name="dark_color_primary_text">@color/material_primary_300</color>
<color name="color_primary">@color/light_color_primary</color>
<color name="color_primary_dark">@color/light_color_primary_dark</color>
<color name="color_primary_text">@color/light_color_primary_text</color>
</resources> </resources>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment