Skip to content

Commit

Permalink
Implement useMorePreciseDistanceDisplay
Browse files Browse the repository at this point in the history
  • Loading branch information
ElJaviLuki committed Jan 29, 2024
1 parent 332a303 commit 0534767
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/com/grindrplus/Hooker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class Hooker : IXposedHookLoadPackage {
Hooks.dontSendChatMarkers()
Hooks.makeMessagesAlwaysRemovable()
Hooks.modifyProfileDetails()
Hooks.useMorePreciseDistanceDisplay()
// Hooks.allowSomeExperiments()
} catch (e: Exception) {
e.message?.let { Logger.xLog("Error in post-onCreate hook: $it") }
Expand Down
33 changes: 33 additions & 0 deletions app/src/main/java/com/grindrplus/core/Hooks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1262,4 +1262,37 @@ object Hooks {
)
}
}

fun useMorePreciseDistanceDisplay() {
findAndHookMethod(
"com.grindrapp.android.utils.DistanceUtils",
Hooker.pkgParam.classLoader,
"b",
Boolean::class.javaPrimitiveType,
Double::class.javaPrimitiveType,
Boolean::class.javaPrimitiveType,
object : XC_MethodReplacement() {
override fun replaceHookedMethod(param: MethodHookParam): Any {
val distance = param.args[1] as Double
val isFeet = param.args[2] as Boolean

return if(isFeet){
val feet = (distance * 3.280839895).roundToInt()
if(feet < 5280) {
String.format("%d feet", feet)
} else {
String.format("%d miles %d feet", feet / 5280, feet % 5280)
}
} else {
val meters = distance.roundToInt()
if(meters < 1000) {
String.format("%d meters", meters)
} else {
String.format("%d km %d m", meters / 1000, meters % 1000)
}
}
}
}
)
}
}

0 comments on commit 0534767

Please sign in to comment.