mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-01 15:14:34 +02:00
feat(music): add hide-terms-container
patch
This commit is contained in:
parent
5dab82ffff
commit
63a7d6fbec
@ -0,0 +1,10 @@
|
|||||||
|
package app.revanced.patches.music.account.tos.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch.Companion.TosFooter
|
||||||
|
import app.revanced.util.bytecode.isWideLiteralExists
|
||||||
|
|
||||||
|
object TermsOfServiceFingerprint : MethodFingerprint(
|
||||||
|
returnType = "Landroid/view/View;",
|
||||||
|
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(TosFooter) }
|
||||||
|
)
|
@ -0,0 +1,84 @@
|
|||||||
|
package app.revanced.patches.music.account.tos.patch
|
||||||
|
|
||||||
|
import app.revanced.extensions.exception
|
||||||
|
import app.revanced.patcher.annotation.Description
|
||||||
|
import app.revanced.patcher.annotation.Name
|
||||||
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
|
import app.revanced.patcher.patch.PatchException
|
||||||
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
|
import app.revanced.patches.music.account.tos.fingerprints.TermsOfServiceFingerprint
|
||||||
|
import app.revanced.patches.music.utils.annotations.MusicCompatibility
|
||||||
|
import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch
|
||||||
|
import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch.Companion.TosFooter
|
||||||
|
import app.revanced.patches.music.utils.settings.resource.patch.SettingsPatch
|
||||||
|
import app.revanced.util.bytecode.getWideLiteralIndex
|
||||||
|
import app.revanced.util.enum.CategoryType
|
||||||
|
import app.revanced.util.integrations.Constants.MUSIC_ACCOUNT
|
||||||
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
|
||||||
|
|
||||||
|
@Patch
|
||||||
|
@Name("Hide terms container")
|
||||||
|
@Description("Hides terms of service container at the account menu.")
|
||||||
|
@DependsOn(
|
||||||
|
[
|
||||||
|
SettingsPatch::class,
|
||||||
|
SharedResourceIdPatch::class
|
||||||
|
]
|
||||||
|
)
|
||||||
|
@MusicCompatibility
|
||||||
|
class TermsContainerPatch : BytecodePatch(
|
||||||
|
listOf(TermsOfServiceFingerprint)
|
||||||
|
) {
|
||||||
|
override fun execute(context: BytecodeContext) {
|
||||||
|
|
||||||
|
TermsOfServiceFingerprint.result?.let {
|
||||||
|
it.mutableMethod.apply {
|
||||||
|
val tosIndex = getWideLiteralIndex(TosFooter)
|
||||||
|
var insertIndex = 0
|
||||||
|
|
||||||
|
for (index in tosIndex until implementation!!.instructions.size) {
|
||||||
|
if (getInstruction(index).opcode != Opcode.INVOKE_VIRTUAL) continue
|
||||||
|
|
||||||
|
val targetReference =
|
||||||
|
getInstruction<ReferenceInstruction>(index).reference.toString()
|
||||||
|
|
||||||
|
if (targetReference.endsWith("/PrivacyTosFooter;->setVisibility(I)V")) {
|
||||||
|
insertIndex = index
|
||||||
|
|
||||||
|
val visibilityRegister =
|
||||||
|
getInstruction<Instruction35c>(insertIndex).registerD
|
||||||
|
|
||||||
|
addInstruction(
|
||||||
|
index + 1,
|
||||||
|
"const/4 v$visibilityRegister, 0x0"
|
||||||
|
)
|
||||||
|
addInstructions(
|
||||||
|
index, """
|
||||||
|
invoke-static {}, $MUSIC_ACCOUNT->hideTermsContainer()I
|
||||||
|
move-result v$visibilityRegister
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (insertIndex == 0)
|
||||||
|
throw PatchException("target Instruction not found!")
|
||||||
|
}
|
||||||
|
} ?: throw TermsOfServiceFingerprint.exception
|
||||||
|
|
||||||
|
SettingsPatch.addMusicPreference(
|
||||||
|
CategoryType.ACCOUNT,
|
||||||
|
"revanced_hide_terms_container",
|
||||||
|
"false"
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -31,6 +31,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
|||||||
var QualityTitle: Long = -1
|
var QualityTitle: Long = -1
|
||||||
var Text1: Long = -1
|
var Text1: Long = -1
|
||||||
var ToolTipContentView: Long = -1
|
var ToolTipContentView: Long = -1
|
||||||
|
var TosFooter: Long = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun execute(context: ResourceContext) {
|
override fun execute(context: ResourceContext) {
|
||||||
@ -55,6 +56,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
|||||||
QualityTitle = find(STRING, "quality_title")
|
QualityTitle = find(STRING, "quality_title")
|
||||||
Text1 = find(ID, "text1")
|
Text1 = find(ID, "text1")
|
||||||
ToolTipContentView = find(LAYOUT, "tooltip_content_view")
|
ToolTipContentView = find(LAYOUT, "tooltip_content_view")
|
||||||
|
TosFooter = find(ID, "tos_footer")
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -113,6 +113,8 @@
|
|||||||
<string name="revanced_hide_playlist_card_title">Hide playlist card</string>
|
<string name="revanced_hide_playlist_card_title">Hide playlist card</string>
|
||||||
<string name="revanced_hide_samples_button_summary">Hides the samples button.</string>
|
<string name="revanced_hide_samples_button_summary">Hides the samples button.</string>
|
||||||
<string name="revanced_hide_samples_button_title">Hide samples button</string>
|
<string name="revanced_hide_samples_button_title">Hide samples button</string>
|
||||||
|
<string name="revanced_hide_terms_container_summary">Hides terms of service container.</string>
|
||||||
|
<string name="revanced_hide_terms_container_title">Hide terms container</string>
|
||||||
<string name="revanced_hide_upgrade_button_summary">Hides the upgrade button.</string>
|
<string name="revanced_hide_upgrade_button_summary">Hides the upgrade button.</string>
|
||||||
<string name="revanced_hide_upgrade_button_title">Hide upgrade button</string>
|
<string name="revanced_hide_upgrade_button_title">Hide upgrade button</string>
|
||||||
<string name="revanced_hook_action_bar_download_summary">Replaces the offline download button with an external download button.</string>
|
<string name="revanced_hook_action_bar_download_summary">Replaces the offline download button with an external download button.</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user