feat: loop media playback

- refactor mappings wrapper
This commit is contained in:
rhunk
2024-01-01 21:41:12 +01:00
parent 1b566db184
commit f1b0bc41f2
13 changed files with 121 additions and 23 deletions

View File

@ -378,6 +378,10 @@
"name": "Unlimited Snap View Time",
"description": "Removes the Time Limit for viewing Snaps"
},
"loop_media_playback": {
"name": "Loop Media Playback",
"description": "Loops media playback when viewing Snaps / Stories"
},
"disable_replay_in_ff": {
"name": "Disable Replay in FF",
"description": "Disables the ability to replay with a long press from the Friend Feed"

View File

@ -31,6 +31,7 @@ class MappingsWrapper : FileLoaderWrapper(BridgeFileType.MAPPINGS, "{}".toByteAr
FriendRelationshipChangerMapper::class,
ViewBinderMapper::class,
FriendingDataSourcesMapper::class,
OperaViewerParamsMapper::class,
)
}
@ -115,29 +116,22 @@ class MappingsWrapper : FileLoaderWrapper(BridgeFileType.MAPPINGS, "{}".toByteAr
return mappings[key]
}
fun getMappedClass(className: String): Class<*> {
return context.classLoader.loadClass(getMappedObject(className) as String)
fun getMappedClass(className: String): Class<*>? {
return runCatching {
context.classLoader.loadClass(getMappedObject(className) as? String)
}.getOrNull()
}
fun getMappedClass(key: String, subKey: String): Class<*> {
return context.classLoader.loadClass(getMappedValue(key, subKey))
}
fun getMappedValue(key: String): String {
return getMappedObject(key) as String
fun getMappedValue(key: String, subKey: String): String? {
return getMappedMap(key)?.get(subKey) as? String
}
@Suppress("UNCHECKED_CAST")
fun <T : Any> getMappedList(key: String): List<T> {
return listOf(getMappedObject(key) as List<T>).flatten()
}
fun getMappedValue(key: String, subKey: String): String {
return getMappedMap(key)[subKey] as String
}
@Suppress("UNCHECKED_CAST")
fun getMappedMap(key: String): Map<String, *> {
return getMappedObject(key) as Map<String, *>
fun getMappedMap(key: String): Map<String, *>? {
return getMappedObjectNullable(key) as? Map<String, *>
}
}

View File

@ -55,6 +55,7 @@ class MessagingTweaks : ConfigContainer() {
val hideBitmojiPresence = boolean("hide_bitmoji_presence")
val hideTypingNotifications = boolean("hide_typing_notifications")
val unlimitedSnapViewTime = boolean("unlimited_snap_view_time")
val loopMediaPlayback = boolean("loop_media_playback") { requireRestart() }
val disableReplayInFF = boolean("disable_replay_in_ff")
val halfSwipeNotifier = container("half_swipe_notifier", HalfSwipeNotifierConfig()) { requireRestart()}
val messagePreviewLength = integer("message_preview_length", defaultValue = 20)