aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt22
1 files changed, 13 insertions, 9 deletions
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 d9542cba..cd13eede 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt
@@ -6,6 +6,7 @@ import ca.allanwang.kau.kotlin.lazyContext
import ca.allanwang.kau.utils.*
import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.Prefs
+import java.io.BufferedReader
import java.io.FileNotFoundException
import java.util.*
@@ -21,24 +22,27 @@ enum class CssAssets(val folder: String = "themes") : InjectorContract {
var file = "${name.toLowerCase(Locale.CANADA)}.css"
var injector = lazyContext {
try {
- var content = it.assets.open("css/$folder/$file").bufferedReader().use { it.readText() }
+ var content = it.assets.open("css/$folder/$file").bufferedReader().use(BufferedReader::readText)
if (this == CUSTOM) {
- val bt: String
- if (Color.alpha(Prefs.bgColor) == 255) {
- bt = Prefs.bgColor.toRgbaString()
- } else {
- bt = "transparent"
- }
+ val bt = if (Color.alpha(Prefs.bgColor) == 255)
+ Prefs.bgColor.toRgbaString()
+ else
+ "transparent"
+
+ val bb = Prefs.bgColor.colorToForeground(0.35f)
+
content = content
.replace("\$T\$", Prefs.textColor.toRgbaString())
.replace("\$TT\$", Prefs.textColor.colorToBackground(0.05f).toRgbaString())
.replace("\$A\$", Prefs.accentColor.toRgbaString())
.replace("\$B\$", Prefs.bgColor.toRgbaString())
.replace("\$BT\$", bt)
- .replace("\$BBT\$", Prefs.bgColor.withAlpha(51).colorToForeground(0.35f).toRgbaString())
+ .replace("\$BBT\$", bb.withAlpha(51).toRgbaString())
.replace("\$O\$", Prefs.bgColor.withAlpha(255).toRgbaString())
- .replace("\$OO\$", Prefs.bgColor.withAlpha(255).colorToForeground(0.35f).toRgbaString())
+ .replace("\$OO\$", bb.withAlpha(255).toRgbaString())
.replace("\$D\$", Prefs.textColor.adjustAlpha(0.3f).toRgbaString())
+ .replace("\$TI\$", bb.withAlpha(60).toRgbaString())
+ .replace("\$C\$", bt)
}
JsBuilder().css(content).build()
} catch (e: FileNotFoundException) {