Merge branch 'refs/heads/refactor_ex' into refactor

This commit is contained in:
rhunk
2024-07-17 12:55:25 +02:00
43 changed files with 2290 additions and 490 deletions

View File

@@ -36,6 +36,9 @@
"friend_tracker": "Friend Tracker",
"edit_rule": "Edit Rule",
"file_imports": "File Imports",
"theming": "Theming",
"edit_theme": "Edit Theme",
"manage_repos": "Manage Repositories",
"social": "Social",
"manage_scope": "Manage Scope",
"messaging_preview": "Preview",
@@ -168,6 +171,9 @@
"search_bar": "Search",
"no_friends_map": "No friends on the map",
"no_friends_found": "No friends found"
},
"theming": {
"no_themes_hint": "No themes found"
}
},
"dialogs": {
@@ -293,6 +299,10 @@
"name": "Change Language",
"description": "Change the language of SnapEnhance"
},
"security_features": {
"name": "Security Features",
"description": "Access security features"
},
"file_imports": {
"name": "File Imports",
"description": "Import files for use in Snapchat"
@@ -304,6 +314,10 @@
"logger_history": {
"name": "Logger History",
"description": "View the history of logged messages"
},
"theming": {
"name": "Theming",
"description": "Customize the look and feel of Snapchat"
}
},
@@ -415,65 +429,9 @@
"name": "Enable App Appearance Settings",
"description": "Enables the hidden App Appearance Setting\nMay not be required on newer Snapchat versions"
},
"customize_ui": {
"name": "Colors",
"description": "Customize Snapchats Colors",
"properties": {
"theme_picker": {
"name": "Theme Picker",
"description": "Preset Snapchat Themes"
},
"colors": {
"name": "Custom Colors",
"description": "Customize Individual colors\nNote: Select Custom Colors on Theme Picker to use",
"properties": {
"text_color": {
"name": "Main Text Color",
"description": "Changes Snapchats main text color"
},
"chat_chat_text_color": {
"name": "Main Friend Feed Text Color",
"description": "Changes the text color of ( New Chat / New Snap And Chats / Typing / Calling / Missed call / Speaking / New Voice Note ) on the friend feed"
},
"pending_sending_text_color": {
"name": "Secondary Friend Feed Text Color",
"description": "Changes the text color of ( Delivered / Received / Sending / Opened / Tap To Chat / Hold To Replay / Replayed / Saved In Chat / Called ) on the friend feed"
},
"snap_with_sound_text_color": {
"name": "Snaps With Sound Text Color",
"description": "Changes the text color of ( New Snap ) on the friend feed\nNote: Video Snaps Only"
},
"snap_without_sound_text_color": {
"name": "Snaps Without Sound Text Color",
"description": "Changes the text color of ( New Snap ) on the friend feed\nNote: Video Snaps Only"
},
"background_color": {
"name": "Background Color",
"description": "Changes Snapchats background color"
},
"background_color_surface": {
"name": "Background Surface Color",
"description": "Changes Snapchats background surface color"
},
"friend_feed_conversations_line_color": {
"name": "Conversations Line Color",
"description": "Changes the line divider color that splits Conversations on the friend feed "
},
"action_menu_background_color": {
"name": "Action Menu Background Color",
"description": "Changes Snapchats chat action menu background color"
},
"action_menu_round_background_color": {
"name": "Action Menu Round Background Color",
"description": "Changes Snapchats chat action menu round background color"
},
"camera_grid_lines": {
"name": "Camera Gridlines Color",
"description": "Changes Snapchats Gridlines color on the Camera Preview\nNote: Enable the grid on the my camera settings"
}
}
}
}
"custom_theme": {
"name": "Custom Theme",
"description": "Customize Snapchat's Colors\nNote: if you choose a dark theme (like Amoled), you may need to enable the dark mode in Snapchat settings for better results"
},
"friend_feed_message_preview": {
"name": "Friend Feed Message Preview",
@@ -1201,20 +1159,11 @@
"always_light": "Always Light",
"always_dark": "Always Dark"
},
"theme_picker": {
"amoled_dark_mode": "AMOLED Dark Mode",
"custom": "Custom Colors",
"custom_theme": {
"amoled_dark_mode": "Amoled Dark Mode",
"custom": "Custom Themes (Use the Quick Actions to manage themes)",
"material_you_light": "Material You Light (Android 12+)",
"material_you_dark": "Material You Dark (Android 12+)",
"light_blue": "Light Blue",
"dark_blue": "Dark Blue",
"earthy_autumn": "Earthy Autumn",
"mint_chocolate": "Mint Chocolate",
"ginger_snap": "Ginger Snap",
"lemon_meringue": "Lemon Meringue",
"lava_flow": "Lava Flow",
"ocean_fog": "Ocean Fog",
"alien_landscape": "Alien Landscape"
"material_you_dark": "Material You Dark (Android 12+)"
},
"friend_feed_menu_buttons": {
"auto_download": "\u2B07\uFE0F Auto Download",
@@ -1681,5 +1630,48 @@
"date_input_invalid_year_range": "Invalid year",
"date_input_invalid_not_allowed": "Invalid date",
"date_range_input_invalid_range_input": "Invalid date range"
},
"theming_attributes": {
"sigColorTextPrimary": "Main Text Color",
"sigColorChatChat": "Main Friend Feed Text Color",
"sigColorBackgroundSurface": "Background Surface Color",
"sigColorChatPendingSending": "Secondary Friend Feed Text Color",
"sigColorChatSnapWithSound": "Snaps With Sound Text Color",
"sigColorChatSnapWithoutSound": "Snaps Without Sound Text Color",
"actionSheetDescriptionTextColor": "Action Menu Description Text Color",
"sigColorBackgroundMain": "Background Color",
"listBackgroundDrawable": "Conversation list Background",
"sigColorChatConversationsLine": "Conversations Line Color",
"actionSheetBackgroundDrawable": "Action Menu Background Color",
"actionSheetRoundedBackgroundDrawable": "Action Menu Round Background Color",
"sigColorIconPrimary": "Action Menu Icon Color",
"sigExceptionColorCameraGridLines": "Camera Gridlines Color",
"listDivider": "List Divider Color",
"sigColorIconSecondary": "Secondary Icon Color",
"itemShapeFillColor": "Item Shape Fill Color",
"ringColor": "Ring Color",
"ringStartColor": "Ring Start Color",
"sigColorLayoutPlaceholder": "Layout Placeholder Color",
"scButtonColor": "Snapchat Button Color",
"recipientPillBackgroundDrawable": "Recipient Pill Background",
"boxBackgroundColor": "Box Background Color",
"editTextColor": "Edit Text Color",
"chipBackgroundColor": "Chip Background Color",
"recipientInputStyle": "Recipient Input Style",
"rangeFillColor": "Range Fill Color",
"pstsIndicatorColor": "PSTS Indicator Color",
"pstsTabBackground": "PSTS Tab Background",
"pstsDividerColor": "PSTS Divider Color",
"tabTextColor": "Tab Text Color",
"statusBarForeground": "Status Bar Foreground Color",
"statusBarBackground": "Status Bar Background Color",
"strokeColor": "Stroke Color",
"storyReplayViewRingColor": "Story Replay View Ring Color",
"sigColorButtonPrimary": "Primary Button Color",
"sigColorBaseAppYellow": "Base App Yellow Color",
"sigColorBackgroundSurfaceTranslucent": "Translucent Background Surface Color",
"sigColorStoryRingFriendsFeedStoryRing": "Story Ring Friends Feed Story Ring Color",
"sigColorStoryRingDiscoverTabThumbnailStoryRing": "Story Ring Discover Tab Thumbnail Story Ring Color"
}
}

View File

@@ -16,7 +16,8 @@ enum class FileHandleScope(
INTERNAL("internal"),
LOCALE("locale"),
USER_IMPORT("user_import"),
COMPOSER("composer");
COMPOSER("composer"),
THEME("theme");
companion object {
fun fromValue(name: String): FileHandleScope? = entries.find { it.key == name }
@@ -31,8 +32,8 @@ enum class InternalFileHandleType(
CONFIG("config", "config.json"),
MAPPINGS("mappings", "mappings.json"),
MESSAGE_LOGGER("message_logger", "message_logger.db", isDatabase = true),
PINNED_BEST_FRIEND("pinned_best_friend", "pinned_best_friend.txt");
PINNED_BEST_FRIEND("pinned_best_friend", "pinned_best_friend.txt"),
SIF("sif", "libsif.so");
fun resolve(context: Context): File = if (isDatabase) {
context.getDatabasePath(fileName)

View File

@@ -39,7 +39,7 @@ class ConversationInfo(
val usernames: List<String>
)
class TrackerLog(
data class TrackerLog(
val id: Int,
val timestamp: Long,
val conversationId: String,

View File

@@ -31,7 +31,7 @@ class Experimental : ConfigContainer() {
val composerLogs = boolean("composer_logs")
}
class NativeHooks : ConfigContainer(hasGlobalState = true) {
class NativeHooks : ConfigContainer() {
val composerHooks = container("composer_hooks", ComposerHooksConfig()) { requireRestart() }
val disableBitmoji = boolean("disable_bitmoji")
val customEmojiFont = string("custom_emoji_font") {
@@ -40,7 +40,6 @@ class Experimental : ConfigContainer() {
addFlags(ConfigFlag.USER_IMPORT)
filenameFilter = { it.endsWith(".ttf") }
}
val remapExecutable = boolean("remap_executable") { requireRestart(); addNotices(FeatureNotice.INTERNAL_BEHAVIOR, FeatureNotice.UNSTABLE) }
}
class E2EEConfig : ConfigContainer(hasGlobalState = true) {

View File

@@ -19,46 +19,18 @@ class UserInterfaceTweaks : ConfigContainer() {
}
class ColorsConfig : ConfigContainer() {
val textColor = color("text_color")
val chatChatTextColor = color("chat_chat_text_color")
val pendingSendingTextColor = color("pending_sending_text_color")
val snapWithSoundTextColor = color("snap_with_sound_text_color")
val snapWithoutSoundTextColor = color("snap_without_sound_text_color")
val backgroundColor = color("background_color")
val backgroundColorSurface = color("background_color_surface")
val friendFeedConversationsLineColor = color("friend_feed_conversations_line_color")
val actionMenuBackgroundColor = color("action_menu_background_color")
val actionMenuRoundBackgroundColor = color("action_menu_round_background_color")
val cameraGridLines = color("camera_grid_lines")
}
inner class CustomizeUIConfig : ConfigContainer() {
val themePicker = unique("theme_picker",
"custom",
"amoled_dark_mode",
"material_you_light",
"material_you_dark",
"light_blue",
"dark_blue",
"earthy_autumn",
"mint_chocolate",
"ginger_snap",
"lemon_meringue",
"lava_flow",
"ocean_fog",
"alien_landscape",
)
val colors = container("colors", ColorsConfig()) { requireRestart() }
}
val friendFeedMenuButtons = multiple(
"friend_feed_menu_buttons","conversation_info", "mark_snaps_as_seen", "mark_stories_as_seen_locally", *MessagingRuleType.entries.filter { it.showInFriendMenu }.map { it.key }.toTypedArray()
).apply {
set(mutableListOf("conversation_info", MessagingRuleType.STEALTH.key))
}
val autoCloseFriendFeedMenu = boolean("auto_close_friend_feed_menu")
val customizeUi = container("customize_ui", CustomizeUIConfig()) { addNotices(FeatureNotice.UNSTABLE); requireRestart() }
val customTheme = unique("custom_theme",
"amoled_dark_mode",
"material_you_light",
"material_you_dark",
"custom",
) { addNotices(FeatureNotice.UNSTABLE); requireRestart() }
val friendFeedMessagePreview = container("friend_feed_message_preview", FriendFeedMessagePreview()) { requireRestart() }
val snapPreview = boolean("snap_preview") { addNotices(FeatureNotice.UNSTABLE); requireRestart() }
val bootstrapOverride = container("bootstrap_override", BootstrapOverride()) { requireRestart() }

View File

@@ -0,0 +1,120 @@
package me.rhunk.snapenhance.common.data
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize
@Parcelize
data class ThemeColorEntry(
@SerializedName("key")
val key: String,
@SerializedName("value")
var value: Int,
): Parcelable
@Parcelize
data class DatabaseThemeContent(
@SerializedName("colors")
val colors: List<ThemeColorEntry> = emptyList(),
): Parcelable
data class DatabaseTheme(
val id: Int,
val enabled: Boolean,
val name: String,
val description: String?,
val version: String?,
val author: String?,
val updateUrl: String?,
) {
fun toExportedTheme(content: DatabaseThemeContent): ExportedTheme {
return ExportedTheme(
name = name,
description = description,
version = version,
author = author,
content = content,
)
}
}
data class ExportedTheme(
val name: String,
val description: String?,
val version: String?,
val author: String?,
val content: DatabaseThemeContent,
) {
fun toDatabaseTheme(id: Int = -1, updateUrl: String? = null, enabled: Boolean = false): DatabaseTheme {
return DatabaseTheme(
id = id,
enabled = enabled,
name = name,
description = description,
version = version,
author = author,
updateUrl = updateUrl,
)
}
}
data class RepositoryThemeManifest(
val name: String,
val author: String?,
val description: String?,
val version: String?,
val filepath: String,
)
data class RepositoryIndex(
val themes: List<RepositoryThemeManifest> = emptyList(),
)
enum class ThemingAttributeType {
COLOR
}
val AvailableThemingAttributes = mapOf(
ThemingAttributeType.COLOR to listOf(
"sigColorTextPrimary",
"sigColorBackgroundSurface",
"sigColorBackgroundMain",
"actionSheetBackgroundDrawable",
"actionSheetRoundedBackgroundDrawable",
"sigColorChatChat",
"sigColorChatPendingSending",
"sigColorChatSnapWithSound",
"sigColorChatSnapWithoutSound",
"sigExceptionColorCameraGridLines",
"listDivider",
"listBackgroundDrawable",
"sigColorIconPrimary",
"actionSheetDescriptionTextColor",
"ringColor",
"sigColorIconSecondary",
"itemShapeFillColor",
"ringStartColor",
"sigColorLayoutPlaceholder",
"scButtonColor",
"recipientPillBackgroundDrawable",
"boxBackgroundColor",
"editTextColor",
"chipBackgroundColor",
"recipientInputStyle",
"rangeFillColor",
"pstsIndicatorColor",
"pstsTabBackground",
"pstsDividerColor",
"tabTextColor",
"statusBarForeground",
"statusBarBackground",
"strokeColor",
"storyReplayViewRingColor",
"sigColorButtonPrimary",
"sigColorBaseAppYellow",
"sigColorBackgroundSurfaceTranslucent",
"sigColorStoryRingFriendsFeedStoryRing",
"sigColorStoryRingDiscoverTabThumbnailStoryRing",
)
)

View File

@@ -0,0 +1,17 @@
package me.rhunk.snapenhance.common.ui
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
@Composable
fun transparentTextFieldColors() = TextFieldDefaults.colors(
unfocusedContainerColor = MaterialTheme.colorScheme.surface,
focusedContainerColor = MaterialTheme.colorScheme.surface,
focusedIndicatorColor = Color.Transparent,
unfocusedIndicatorColor = Color.Transparent,
disabledIndicatorColor = Color.Transparent,
cursorColor = MaterialTheme.colorScheme.primary
)

View File

@@ -20,8 +20,23 @@ fun PackageManager.getApplicationInfoCompat(packageName: String, flags: Int) =
}
fun Context.copyToClipboard(data: String, label: String = "Copied Text") {
getSystemService(android.content.ClipboardManager::class.java).setPrimaryClip(
ClipData.newPlainText(label, data))
runCatching {
getSystemService(android.content.ClipboardManager::class.java).setPrimaryClip(
ClipData.newPlainText(label, data))
}
}
fun Context.getTextFromClipboard(): String? {
return runCatching {
getSystemService(android.content.ClipboardManager::class.java).primaryClip
?.takeIf { it.itemCount > 0 }
?.getItemAt(0)
?.text?.toString()
}.getOrNull()
}
fun Context.getUrlFromClipboard(): String? {
return getTextFromClipboard()?.takeIf { it.startsWith("http") }
}
fun InputStream.toParcelFileDescriptor(coroutineScope: CoroutineScope): ParcelFileDescriptor {