From f6ae04c42c7e2fabcd4de10290d7e6b5ea83b368 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Fri, 30 Jun 2017 20:46:54 -0700 Subject: Mimic template themes when opaque --- .../kotlin/com/pitchedapps/frost/injectors/CssAssets.kt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'app/src/main/kotlin') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt index 47f7d325..35acdcb3 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt @@ -1,8 +1,8 @@ package com.pitchedapps.frost.injectors +import android.graphics.Color import android.webkit.WebView import ca.allanwang.kau.utils.* -import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.Prefs /** @@ -21,11 +21,21 @@ enum class CssAssets(val folder: String = "themes") : InjectorContract { if (injector == null) { var content = webView.context.assets.open("css/$folder/$file").bufferedReader().use { it.readText() } if (this == CUSTOM) { + var bbt = Prefs.bgColor + val bt: String + if (Color.alpha(bbt) == 255) { + bbt = bbt.adjustAlpha(0.2f).colorToForeground(0.35f) + bt = Prefs.bgColor.toRgbaString() + } else { + bbt = bbt.adjustAlpha(0.05f).colorToForeground(0.5f) + bt = "transparent" + } content = content .replace("\$T\$", Prefs.textColor.toRgbaString()) .replace("\$TT\$", Prefs.textColor.colorToBackground(0.05f).toRgbaString()) .replace("\$B\$", Prefs.bgColor.toRgbaString()) - .replace("\$BBT\$", Prefs.bgColor.adjustAlpha(0.2f).colorToForeground(0.35f).toRgbaString()) + .replace("\$BT\$", bt) + .replace("\$BBT\$", bbt.toRgbaString()) .replace("\$O\$", Prefs.bgColor.withAlpha(255).toRgbaString()) .replace("\$D\$", Prefs.textColor.adjustAlpha(0.3f).toRgbaString()) } -- cgit v1.2.3