refactor: colors (#972)

* refactor: colors

* refactor: sent & received
This commit is contained in:
Jacob Thomas
2024-04-28 13:33:22 +01:00
committed by GitHub
parent 3586a892c3
commit 475326dd48
3 changed files with 30 additions and 30 deletions

View File

@@ -366,27 +366,27 @@
"name": "Colors",
"description": "Customize Snapchats Colors",
"properties": {
"text_colour": {
"text_color": {
"name": "Text Color",
"description": "Changes Snapchats text color\nInput hex color code"
},
"chat_colour": {
"name": "Sent & Received Color",
"send_and_received_text_color": {
"name": "Sent & Received Text Color",
"description": "Changes Snapchats Sent and Received text color on the friend feed\nInput a hex color code"
},
"background_colour": {
"background_color": {
"name": "Background Color",
"description": "Changes Snapchats background color\nInput a hex color code"
},
"background_colour_surface": {
"background_color_surface": {
"name": "Background Surface Color",
"description": "Changes Snapchats background surface color\nInput a hex color code"
},
"action_menu_background_colour": {
"action_menu_background_color": {
"name": "Action Menu Background Color",
"description": "Changes Snapchats chat action menu background color\nInput a hex color code"
},
"action_menu_round_background_colour": {
"action_menu_round_background_color": {
"name": "Action Menu Round Background Color",
"description": "Changes Snapchats chat action menu round background color\nInput a hex color code"
}

View File

@@ -23,12 +23,12 @@ class UserInterfaceTweaks : ConfigContainer() {
private val checkInputColor = { value: String ->
value.isEmpty() || runCatching { Color.parseColor(value) }.isSuccess
}
val textColour = string("text_colour") { inputCheck = checkInputColor }
val backgroundColour = string("background_colour") { inputCheck = checkInputColor }
val backgroundColourSurface = string("background_colour_surface") { inputCheck = checkInputColor }
val actionMenuBackgroundColour = string("action_menu_background_colour") { inputCheck = checkInputColor }
val actionMenuRoundBackgroundColour = string("action_menu_round_background_colour") { inputCheck = checkInputColor }
val chatColour = string("chat_colour") { inputCheck = checkInputColor }
val textColor = string("text_color") { inputCheck = checkInputColor }
val sendAndReceivedTextColor = string("send_and_received_text_color") { inputCheck = checkInputColor }
val backgroundColor = string("background_color") { inputCheck = checkInputColor }
val backgroundColorSurface = string("background_color_surface") { inputCheck = checkInputColor }
val actionMenuBackgroundColor = string("action_menu_background_color") { inputCheck = checkInputColor }
val actionMenuRoundBackgroundColor = string("action_menu_round_background_color") { inputCheck = checkInputColor }
}
val friendFeedMenuButtons = multiple(

View File

@@ -25,13 +25,13 @@ class CustomizeUI: Feature("Customize UI", loadParams = FeatureLoadParams.ACTIVI
//TODO: color picker
val customizeUIConfig = context.config.userInterface.customizeUi
val effectiveTextColour by lazy { parseColor(customizeUIConfig.textColour.get()) }
val effectiveBackgroundColour by lazy { parseColor(customizeUIConfig.backgroundColour.get()) }
val effectiveBackgroundColourSurface by lazy { parseColor(customizeUIConfig.backgroundColourSurface.get()) }
val effectiveActionMenuBackgroundColour by lazy { parseColor(customizeUIConfig.actionMenuBackgroundColour.get()) }
val effectiveActionMenuRoundBackgroundColour by lazy { parseColor(customizeUIConfig.actionMenuRoundBackgroundColour.get()) }
val effectiveChatColour by lazy { parseColor(customizeUIConfig.chatColour.get()) }
val effectiveTextColor by lazy { parseColor(customizeUIConfig.textColor.get()) }
val effectivesendAndReceivedTextColor by lazy { parseColor(customizeUIConfig.sendAndReceivedTextColor.get()) }
val effectiveBackgroundColor by lazy { parseColor(customizeUIConfig.backgroundColor.get()) }
val effectiveBackgroundColorSurface by lazy { parseColor(customizeUIConfig.backgroundColorSurface.get()) }
val effectiveActionMenuBackgroundColor by lazy { parseColor(customizeUIConfig.actionMenuBackgroundColor.get()) }
val effectiveActionMenuRoundBackgroundColor by lazy { parseColor(customizeUIConfig.actionMenuRoundBackgroundColor.get()) }
val attributeCache = mutableMapOf<String, Int>()
fun getAttribute(name: String): Int {
@@ -69,38 +69,38 @@ class CustomizeUI: Feature("Customize UI", loadParams = FeatureLoadParams.ACTIVI
if (isCustomizeUI) {
when (array[0]) {
getAttribute("sigColorTextPrimary") -> {
ephemeralHook("getColor", effectiveTextColour ?: return@hook)
ephemeralHook("getColor", effectiveTextColor ?: return@hook)
}
getAttribute("sigColorBackgroundMain") -> {
ephemeralHook("getColor", effectiveBackgroundColour ?: return@hook)
ephemeralHook("getColor", effectiveBackgroundColor ?: return@hook)
}
getAttribute("sigColorBackgroundSurface") -> {
ephemeralHook("getColor", effectiveBackgroundColourSurface ?: return@hook)
ephemeralHook("getColor", effectiveBackgroundColorSurface ?: return@hook)
}
getAttribute("actionSheetBackgroundDrawable") -> {
ephemeralHook("getDrawable", ColorDrawable(effectiveActionMenuBackgroundColour ?: return@hook))
ephemeralHook("getDrawable", ColorDrawable(effectiveActionMenuBackgroundColor ?: return@hook))
}
getAttribute("actionSheetRoundedBackgroundDrawable") -> {
ephemeralHook("getDrawable", ColorDrawable(effectiveActionMenuRoundBackgroundColour ?: return@hook))
ephemeralHook("getDrawable", ColorDrawable(effectiveActionMenuRoundBackgroundColor ?: return@hook))
}
getAttribute("sigColorChatActivity") -> {
ephemeralHook("getColor", effectiveChatColour ?: return@hook)
ephemeralHook("getColor", effectivesendAndReceivedTextColor ?: return@hook)
}
getAttribute("sigColorChatChat") -> {
ephemeralHook("getColor", effectiveChatColour ?: return@hook)
ephemeralHook("getColor", effectivesendAndReceivedTextColor ?: return@hook)
}
getAttribute("sigColorChatPendingSending") -> {
ephemeralHook("getColor", effectiveChatColour ?: return@hook)
ephemeralHook("getColor", effectivesendAndReceivedTextColor ?: return@hook)
}
getAttribute("sigColorChatSnapWithSound") -> {
ephemeralHook("getColor", effectiveChatColour ?: return@hook)
ephemeralHook("getColor", effectivesendAndReceivedTextColor ?: return@hook)
}
getAttribute("sigColorChatSnapWithoutSound") -> {
ephemeralHook("getColor", effectiveChatColour ?: return@hook)
ephemeralHook("getColor", effectivesendAndReceivedTextColor ?: return@hook)
}
}
}