android: Improve changing web theme (#402)
This commit is contained in:
parent
3178a7f5ca
commit
775b63bc77
|
|
@ -33,6 +33,37 @@ html.light {
|
|||
--band: #f2f5f7;
|
||||
}
|
||||
|
||||
@property --bg {
|
||||
syntax: "<color>";
|
||||
inherits: true;
|
||||
initial-value: #ffffff;
|
||||
}
|
||||
@property --text {
|
||||
syntax: "<color>";
|
||||
inherits: true;
|
||||
initial-value: #111111;
|
||||
}
|
||||
@property --muted {
|
||||
syntax: "<color>";
|
||||
inherits: true;
|
||||
initial-value: #4a555c;
|
||||
}
|
||||
@property --line {
|
||||
syntax: "<color>";
|
||||
inherits: true;
|
||||
initial-value: rgba(128, 128, 128, 0.2);
|
||||
}
|
||||
@property --card {
|
||||
syntax: "<color>";
|
||||
inherits: true;
|
||||
initial-value: rgba(128, 128, 128, 0.1);
|
||||
}
|
||||
@property --band {
|
||||
syntax: "<color>";
|
||||
inherits: true;
|
||||
initial-value: #f2f5f7;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
|
|
|
|||
|
|
@ -52,6 +52,9 @@ open class MainActivity : ComponentActivity() {
|
|||
}
|
||||
private val settingChangedForwarder: (String) -> Unit = { setting ->
|
||||
runOnUiThread {
|
||||
if (setting == NXUISetting.ThemeMode) {
|
||||
applyWebViewTheme()
|
||||
}
|
||||
webView.evaluateJavascript(
|
||||
"onSettingChanged('${setting.replace("'", "\\'")}')",
|
||||
null
|
||||
|
|
@ -175,6 +178,7 @@ open class MainActivity : ComponentActivity() {
|
|||
emulationLaunchPending = false
|
||||
InputHandler.updateControllerData()
|
||||
inputManager()?.registerInputDeviceListener(inputDeviceListener, null)
|
||||
applyWebViewTheme()
|
||||
refreshConnectedControllers()
|
||||
resumeRunningGame()
|
||||
}
|
||||
|
|
@ -359,6 +363,12 @@ open class MainActivity : ComponentActivity() {
|
|||
|
||||
fun editOverlayLayout() {
|
||||
startActivity(Intent(this, OverlayLayoutActivity::class.java))
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||
overrideActivityTransition(Activity.OVERRIDE_TRANSITION_OPEN, 0, 0)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
overridePendingTransition(0, 0)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
|
@ -389,6 +399,15 @@ open class MainActivity : ComponentActivity() {
|
|||
)
|
||||
}
|
||||
|
||||
private fun applyWebViewTheme() {
|
||||
if (!::webView.isInitialized) {
|
||||
return
|
||||
}
|
||||
webView.setBackgroundColor(ThemeHelper.backgroundColor(this))
|
||||
ThemeHelper.applySystemBars(this)
|
||||
webView.evaluateJavascript("typeof applyTheme==='function'&&applyTheme()", null)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val STICK_REPEAT_MS = 220L
|
||||
private const val STICK_DEADZONE = 0.5f
|
||||
|
|
|
|||
Loading…
Reference in New Issue