mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-05-28 12:30:12 +02:00
feat(better_location): battery level in map focus view
This commit is contained in:
parent
9817843c0e
commit
7c5658b0da
@ -26,8 +26,10 @@ import me.rhunk.snapenhance.core.event.events.impl.AddViewEvent
|
||||
import me.rhunk.snapenhance.core.event.events.impl.UnaryCallEvent
|
||||
import me.rhunk.snapenhance.core.features.Feature
|
||||
import me.rhunk.snapenhance.core.util.RandomWalking
|
||||
import me.rhunk.snapenhance.core.util.dataBuilder
|
||||
import me.rhunk.snapenhance.core.util.hook.HookStage
|
||||
import me.rhunk.snapenhance.core.util.hook.hook
|
||||
import me.rhunk.snapenhance.core.util.hook.hookConstructor
|
||||
import me.rhunk.snapenhance.core.util.ktx.getId
|
||||
import me.rhunk.snapenhance.core.util.ktx.getObjectField
|
||||
import me.rhunk.snapenhance.core.util.ktx.isDarkTheme
|
||||
@ -191,6 +193,17 @@ class BetterLocation : Feature("Better Location") {
|
||||
val batteryLevel = locationHistory[userId]?.batteryLevel?.takeIf { it > -1F } ?: return@hook
|
||||
param.setArg(0, param.arg<String>(0) + " (${(batteryLevel * 100).toInt()}%)")
|
||||
}
|
||||
|
||||
findClass("com.snap.map_friend_focus_view.MapFocusViewFriendSectionDataModel").hookConstructor(HookStage.AFTER) { param ->
|
||||
val instance = param.thisObject<Any>()
|
||||
val userId = instance.getObjectField("_userId") as? String ?: return@hookConstructor
|
||||
val batteryLevel = locationHistory[userId]?.batteryLevel?.takeIf { it > -1F } ?: return@hookConstructor
|
||||
|
||||
param.thisObject<Any>().dataBuilder {
|
||||
val prevText = get<String?>("_lastSeen")?.let { " - $it" } ?: ""
|
||||
set("_lastSeen", "(${(batteryLevel * 100).toInt()}%)$prevText")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
context.event.subscribe(AddViewEvent::class) { event ->
|
||||
|
Loading…
x
Reference in New Issue
Block a user