fix(Instagram - Hide navigation buttons): Constrain patch to last working app target

This commit is contained in:
LisoUseInAIKyrios
2025-11-07 13:25:24 +02:00
parent 5029e979be
commit e030e9c07a
5 changed files with 21 additions and 20 deletions

View File

@@ -18,7 +18,7 @@ val removeShareTargetsPatch = resourcePatch(
document("res/xml/shortcuts.xml")
} catch (_: FileNotFoundException) {
return@execute Logger.getLogger(this::class.java.name).warning(
"The app has no shortcuts. No changes applied.")
"The app has no shortcuts. No changes applied.")
}.use { document ->
val rootNode = document.getNode("shortcuts") as? Element ?: return@use

View File

@@ -4,6 +4,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.booleanOption
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.instagram.misc.extension.sharedExtensionPatch
import app.revanced.patches.shared.PATCH_NAME_HIDE_NAVIGATION_BUTTONS
import app.revanced.util.addInstructionsAtControlFlowLabel
import app.revanced.util.findFreeRegister
import app.revanced.util.getReference
@@ -19,11 +20,11 @@ private const val EXTENSION_CLASS_DESCRIPTOR =
@Suppress("unused")
val hideNavigationButtonsPatch = bytecodePatch(
name = "Hide navigation buttons",
name = PATCH_NAME_HIDE_NAVIGATION_BUTTONS,
description = "Hides navigation bar buttons, such as the Reels and Create button.",
use = false
) {
compatibleWith("com.instagram.android")
compatibleWith("com.instagram.android"("401.0.0.48.79"))
dependsOn(sharedExtensionPatch)

View File

@@ -12,3 +12,5 @@ internal const val PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS = "Removes the track
internal const val PATCH_NAME_CHANGE_LINK_SHARING_DOMAIN = "Change link sharing domain"
internal const val PATCH_DESCRIPTION_CHANGE_LINK_SHARING_DOMAIN = "Replaces the domain name of shared links."
internal const val PATCH_NAME_HIDE_NAVIGATION_BUTTONS = "Hide navigation buttons"

View File

@@ -15,7 +15,7 @@ val disableLicenseCheckPatch = bytecodePatch(
execute {
if (processLicenseResponseFingerprint.methodOrNull == null || validateLicenseResponseFingerprint.methodOrNull == null) {
return@execute Logger.getLogger(this::class.java.name)
.warning("Could not find Pairip licensing check. No changes applied.")
.warning("Could not find Pairip licensing check. No changes applied.")
}
// Set first parameter (responseCode) to 0 (success status).

View File

@@ -3,23 +3,13 @@ package app.revanced.patches.viber.misc.navbar
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.patch.booleanOption
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.shared.PATCH_NAME_HIDE_NAVIGATION_BUTTONS
import java.util.logging.Logger
import kotlin.collections.joinToString
private const val instructionsFooter = """
# If we reach this, it means that this tab has been disabled by user
const/4 v0, 0
return v0 # return false as "This tab is not enabled"
# Proceed with default execution
:continue
nop
"""
@Suppress("unused")
val hideNavigationButtonsPatch = bytecodePatch(
name = "Hide navigation buttons",
name = PATCH_NAME_HIDE_NAVIGATION_BUTTONS,
description = "Permanently hides navigation bar buttons, such as Explore and Marketplace.",
use = false
) {
@@ -40,13 +30,21 @@ val hideNavigationButtonsPatch = bytecodePatch(
if (allowedItems.size == AllowedNavigationItems.entries.size) {
return@execute Logger.getLogger(this::class.java.name).warning(
"No hide navigation buttons options are enabled. No changes made."
"No hide navigation buttons options are enabled. No changes applied."
)
}
val injectionInstructions = allowedItems
.map { it.key.buildAllowInstruction() }
.joinToString("\n") + instructionsFooter
.joinToString("\n") + """
# If we reach this, it means that this tab has been disabled by user
const/4 v0, 0
return v0 # return false as "This tab is not enabled"
# Proceed with default execution
:continue
nop
"""
shouldShowTabIdMethodFingerprint
.method
@@ -78,8 +76,8 @@ private enum class AllowedNavigationItems(
fun buildAllowInstruction(): String =
ids.joinToString("\n") { id ->
"""
const/4 v0, $id # If tabId == $id ($itemName), don't hide it
if-eq p1, v0, :continue
const/4 v0, $id # If tabId == $id ($itemName), don't hide it
if-eq p1, v0, :continue
"""
}
}