From bb0ab20a5bcdd5a7b437e796050ffcf123953dcd Mon Sep 17 00:00:00 2001 From: RSR/ <52901789+RSR1337@users.noreply.github.com> Date: Thu, 12 Mar 2026 02:27:33 +0400 Subject: [PATCH] fix --- common/src/main/assets/lang/ar_AE.json | 4 +- common/src/main/assets/lang/en_US.json | 2 +- .../common/config/impl/UserInterfaceTweaks.kt | 17 ++++- .../core/features/impl/ui/FakeSnapScore.kt | 62 ++++++++++++++++--- 4 files changed, 72 insertions(+), 13 deletions(-) diff --git a/common/src/main/assets/lang/ar_AE.json b/common/src/main/assets/lang/ar_AE.json index 07aa3905..04951e75 100644 --- a/common/src/main/assets/lang/ar_AE.json +++ b/common/src/main/assets/lang/ar_AE.json @@ -1161,8 +1161,8 @@ "description": "تزييف نقاط السناب شات الخاصة بك (محلياً فقط)", "properties": { "custom_snap_score": { - "name": "نقاط مخصصة", - "description": "يتم عرض هذا الرقم كنقاط السناب شات" + "name": "النقاط المخصصة", + "description": "تعيين نقاط السناب شات الوهمية (أقصى عدد هو 9,999,999)" } } } diff --git a/common/src/main/assets/lang/en_US.json b/common/src/main/assets/lang/en_US.json index 3a0964db..b9ce8a8c 100644 --- a/common/src/main/assets/lang/en_US.json +++ b/common/src/main/assets/lang/en_US.json @@ -1203,7 +1203,7 @@ "properties": { "custom_snap_score": { "name": "Custom Snap Score", - "description": "The custom Snap Score to fake" + "description": "The custom Snap Score you want to display (max 9,999,999)" } } } diff --git a/common/src/main/kotlin/me/eternal/purrfectsnap/common/config/impl/UserInterfaceTweaks.kt b/common/src/main/kotlin/me/eternal/purrfectsnap/common/config/impl/UserInterfaceTweaks.kt index c1ebc510..82aa93a2 100644 --- a/common/src/main/kotlin/me/eternal/purrfectsnap/common/config/impl/UserInterfaceTweaks.kt +++ b/common/src/main/kotlin/me/eternal/purrfectsnap/common/config/impl/UserInterfaceTweaks.kt @@ -69,7 +69,22 @@ class UserInterfaceTweaks : ConfigContainer() { inputCheck = { input -> if (input.isEmpty()) true else { - input.replace(Regex("[^0-9]"), "").isNotEmpty() + val digits = input.replace(Regex("[^0-9]"), "") + val isTooLong = digits.isNotEmpty() && (digits.length > 7 || digits.toLong() > 9999999L) + if (isTooLong) { + try { + val context = Class.forName("android.app.ActivityThread").getMethod("currentApplication").invoke(null) as? android.content.Context + context?.let { + val handler = android.os.Handler(android.os.Looper.getMainLooper()) + handler.post { + android.widget.Toast.makeText(it, "The maximum Snap Score limit is 9,999,999", android.widget.Toast.LENGTH_SHORT).show() + } + } + } catch (_: Throwable) {} + false + } else { + digits.isNotEmpty() + } } } } diff --git a/core/src/main/kotlin/me/eternal/purrfectsnap/core/features/impl/ui/FakeSnapScore.kt b/core/src/main/kotlin/me/eternal/purrfectsnap/core/features/impl/ui/FakeSnapScore.kt index c679ec21..9dd5588d 100644 --- a/core/src/main/kotlin/me/eternal/purrfectsnap/core/features/impl/ui/FakeSnapScore.kt +++ b/core/src/main/kotlin/me/eternal/purrfectsnap/core/features/impl/ui/FakeSnapScore.kt @@ -1,5 +1,8 @@ package me.eternal.purrfectsnap.core.features.impl.ui +import android.view.ViewGroup +import android.widget.TextView +import androidx.constraintlayout.widget.ConstraintLayout import me.eternal.purrfectsnap.core.features.Feature import me.eternal.purrfectsnap.core.util.hook.HookStage import me.eternal.purrfectsnap.core.util.hook.hook @@ -8,21 +11,36 @@ class FakeSnapScore : Feature("Fake Snap Score") { override fun init() { if (context.config.userInterface.spoofSnapScore.globalState != true) return - val customScoreRaw = context.config.userInterface.spoofSnapScore.customSnapScore.getNullable()?.trim()?.takeIf { it.isNotBlank() } - ?: return - - val customScore = customScoreRaw.replace(Regex("[^0-9]"), "") - if (customScore.isEmpty()) return + val customScoreRaw = context.config.userInterface.spoofSnapScore.customSnapScore.getNullable()?.trim() ?: return + val customScore = try { + val digitsOnly = customScoreRaw.replace(Regex("[^0-9]"), "") + if (digitsOnly.isNotEmpty()) { + val clampedVal = digitsOnly.toLong().coerceAtMost(9999999L) + val formatted = StringBuilder() + val reversed = clampedVal.toString().reversed() + for (i in reversed.indices) { + formatted.append(reversed[i]) + if ((i + 1) % 3 == 0 && i != reversed.lastIndex) { + formatted.append(",") + } + } + formatted.reverse().toString() + } else { + null + } + } catch (e: Exception) { + null + } ?: return onNextActivityCreate { - android.widget.TextView::class.java.hook("setText", HookStage.BEFORE) { param -> + TextView::class.java.hook("setText", HookStage.BEFORE) { param -> val text = param.argNullable(0)?.toString() ?: return@hook if (text.matches(Regex("^[0-9\\s,.]+$"))) { val digits = text.replace(Regex("[^0-9]"), "") if (digits.length >= 4 || text.contains(",")) { - val textView = param.thisObject() as android.widget.TextView + val textView = param.thisObject() as TextView var parent = textView.parent var isProfile = false @@ -37,8 +55,34 @@ class FakeSnapScore : Feature("Fake Snap Score") { if (isProfile) { param.setArg(0, customScore) - textView.ellipsize = null - textView.setSingleLine(false) + + textView.post { + textView.layoutParams?.let { lp -> + if (lp.width != ViewGroup.LayoutParams.WRAP_CONTENT) { + lp.width = ViewGroup.LayoutParams.WRAP_CONTENT + textView.layoutParams = lp + } + } + + val paint = textView.paint + val textWidth = paint.measureText(customScore).toInt() + textView.paddingLeft + textView.paddingRight + if (textView.minWidth < textWidth) { + textView.minWidth = textWidth + } + + var currentParent = textView.parent + while (currentParent is ViewGroup) { + if (currentParent is ConstraintLayout) { + currentParent.layoutParams?.let { plp -> + if (plp.width != ViewGroup.LayoutParams.WRAP_CONTENT) { + plp.width = ViewGroup.LayoutParams.WRAP_CONTENT + currentParent.layoutParams = plp + } + } + } + currentParent = currentParent.parent + } + } } } }