mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-05 00:54:32 +02:00
fix(YouTube/Hide suggestions shelf): when the You
tab is not applied on tablets, empty space lefts
This commit is contained in:
parent
ee2c84bef8
commit
8ad7f3c47d
@ -14,8 +14,15 @@ import app.revanced.patches.youtube.general.suggestions.fingerprints.BreakingNew
|
||||
import app.revanced.patches.youtube.general.suggestions.fingerprints.SuggestionContentsBuilderFingerprint
|
||||
import app.revanced.patches.youtube.general.suggestions.fingerprints.SuggestionContentsBuilderLegacyFingerprint
|
||||
import app.revanced.patches.youtube.utils.litho.LithoFilterPatch
|
||||
import app.revanced.patches.youtube.utils.navigationbuttons.NavigationButtonHookPatch
|
||||
import app.revanced.patches.youtube.utils.navigationbuttons.NavigationButtonHookPatch.PivotBarMethod
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.AvatarImageWithTextTab
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.bytecode.getWideLiteralIndex
|
||||
import app.revanced.util.integrations.Constants.COMPONENTS_PATH
|
||||
import app.revanced.util.pivotbar.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT
|
||||
import app.revanced.util.pivotbar.InjectionUtils.injectHook
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Patch(
|
||||
@ -23,6 +30,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
description = "Hides the suggestions shelf.",
|
||||
dependencies = [
|
||||
LithoFilterPatch::class,
|
||||
NavigationButtonHookPatch::class,
|
||||
SettingsPatch::class
|
||||
],
|
||||
compatiblePackages = [
|
||||
@ -93,6 +101,17 @@ object SuggestionsShelfPatch : BytecodePatch(
|
||||
}
|
||||
}
|
||||
|
||||
PivotBarMethod.apply {
|
||||
val insertIndex = implementation!!.instructions.let {
|
||||
val scanStart = getWideLiteralIndex(AvatarImageWithTextTab)
|
||||
|
||||
scanStart + it.subList(scanStart, it.size - 1).indexOfFirst { instruction ->
|
||||
instruction.opcode == Opcode.INVOKE_VIRTUAL
|
||||
}
|
||||
} + 2
|
||||
injectHook(YOU_BUTTON_HOOK, insertIndex)
|
||||
}
|
||||
|
||||
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
|
||||
|
||||
|
||||
@ -112,4 +131,9 @@ object SuggestionsShelfPatch : BytecodePatch(
|
||||
|
||||
private const val FILTER_CLASS_DESCRIPTOR =
|
||||
"$COMPONENTS_PATH/SuggestionsShelfFilter;"
|
||||
|
||||
private const val YOU_BUTTON_HOOK =
|
||||
"invoke-static { v${REGISTER_TEMPLATE_REPLACEMENT} }, $FILTER_CLASS_DESCRIPTOR" +
|
||||
"->" +
|
||||
"isYouButtonEnabled(Landroid/view/View;)V"
|
||||
}
|
||||
|
@ -10,8 +10,9 @@ import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.youtube.navigation.navigationbuttons.fingerprints.AutoMotiveFingerprint
|
||||
import app.revanced.patches.youtube.navigation.navigationbuttons.fingerprints.PivotBarEnumFingerprint
|
||||
import app.revanced.patches.youtube.navigation.navigationbuttons.fingerprints.PivotBarShortsButtonViewFingerprint
|
||||
import app.revanced.patches.youtube.utils.fingerprints.PivotBarCreateButtonViewFingerprint
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.navigationbuttons.NavigationButtonHookPatch
|
||||
import app.revanced.patches.youtube.utils.navigationbuttons.NavigationButtonHookPatch.PivotBarMethod
|
||||
import app.revanced.patches.youtube.utils.navigationbuttons.NavigationButtonHookPatch.PivotBarResult
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.AvatarImageWithTextTab
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ImageOnlyTab
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
@ -26,8 +27,8 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
name = "Hide navigation buttons",
|
||||
description = "Adds options to hide or change navigation buttons.",
|
||||
dependencies = [
|
||||
SettingsPatch::class,
|
||||
SharedResourceIdPatch::class
|
||||
NavigationButtonHookPatch::class,
|
||||
SettingsPatch::class
|
||||
],
|
||||
compatiblePackages = [
|
||||
CompatiblePackage(
|
||||
@ -54,66 +55,52 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
)
|
||||
@Suppress("unused")
|
||||
object NavigationButtonsPatch : BytecodePatch(
|
||||
setOf(
|
||||
AutoMotiveFingerprint,
|
||||
PivotBarCreateButtonViewFingerprint
|
||||
)
|
||||
setOf(AutoMotiveFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
PivotBarCreateButtonViewFingerprint.result?.let { parentResult ->
|
||||
|
||||
/**
|
||||
* Home, Shorts, Subscriptions Button
|
||||
*/
|
||||
with(
|
||||
arrayOf(
|
||||
PivotBarEnumFingerprint,
|
||||
PivotBarShortsButtonViewFingerprint
|
||||
).onEach {
|
||||
it.resolve(
|
||||
context,
|
||||
parentResult.mutableMethod,
|
||||
parentResult.mutableClass
|
||||
)
|
||||
}.map {
|
||||
it.result?.scanResult?.patternScanResult ?: throw it.exception
|
||||
}
|
||||
) {
|
||||
val enumScanResult = this[0]
|
||||
val buttonViewResult = this[1]
|
||||
|
||||
val enumHookInsertIndex = enumScanResult.startIndex + 2
|
||||
val buttonHookInsertIndex = buttonViewResult.endIndex
|
||||
|
||||
mapOf(
|
||||
BUTTON_HOOK to buttonHookInsertIndex,
|
||||
ENUM_HOOK to enumHookInsertIndex
|
||||
).forEach { (hook, insertIndex) ->
|
||||
parentResult.mutableMethod.injectHook(hook, insertIndex)
|
||||
}
|
||||
val pivotBarList =
|
||||
arrayOf(
|
||||
PivotBarEnumFingerprint,
|
||||
PivotBarShortsButtonViewFingerprint
|
||||
).onEach {
|
||||
it.resolve(
|
||||
context,
|
||||
PivotBarResult.classDef
|
||||
)
|
||||
}.map { fingerprint ->
|
||||
fingerprint.result?.scanResult?.patternScanResult
|
||||
?: throw fingerprint.exception
|
||||
}
|
||||
|
||||
/**
|
||||
* Create, You Button
|
||||
*/
|
||||
parentResult.mutableMethod.apply {
|
||||
mapOf(
|
||||
CREATE_BUTTON_HOOK to ImageOnlyTab,
|
||||
YOU_BUTTON_HOOK to AvatarImageWithTextTab
|
||||
).forEach { (hook, resourceId) ->
|
||||
val insertIndex = implementation!!.instructions.let {
|
||||
val scanStart = getWideLiteralIndex(resourceId)
|
||||
PivotBarMethod.apply {
|
||||
val enumScanResult = pivotBarList[0]
|
||||
val buttonViewResult = pivotBarList[1]
|
||||
|
||||
scanStart + it.subList(scanStart, it.size - 1).indexOfFirst { instruction ->
|
||||
instruction.opcode == Opcode.INVOKE_VIRTUAL
|
||||
}
|
||||
} + 2
|
||||
injectHook(hook, insertIndex)
|
||||
}
|
||||
val enumHookInsertIndex = enumScanResult.startIndex + 2
|
||||
val buttonHookInsertIndex = buttonViewResult.endIndex
|
||||
|
||||
mapOf(
|
||||
BUTTON_HOOK to buttonHookInsertIndex,
|
||||
ENUM_HOOK to enumHookInsertIndex
|
||||
).forEach { (hook, insertIndex) ->
|
||||
injectHook(hook, insertIndex)
|
||||
}
|
||||
|
||||
} ?: throw PivotBarCreateButtonViewFingerprint.exception
|
||||
mapOf(
|
||||
CREATE_BUTTON_HOOK to ImageOnlyTab,
|
||||
YOU_BUTTON_HOOK to AvatarImageWithTextTab
|
||||
).forEach { (hook, resourceId) ->
|
||||
val insertIndex = implementation!!.instructions.let {
|
||||
val scanStart = getWideLiteralIndex(resourceId)
|
||||
|
||||
scanStart + it.subList(scanStart, it.size - 1).indexOfFirst { instruction ->
|
||||
instruction.opcode == Opcode.INVOKE_VIRTUAL
|
||||
}
|
||||
} + 2
|
||||
injectHook(hook, insertIndex)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch create button with notifications button
|
||||
|
@ -0,0 +1,25 @@
|
||||
package app.revanced.patches.youtube.utils.navigationbuttons
|
||||
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprintResult
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patches.youtube.utils.fingerprints.PivotBarCreateButtonViewFingerprint
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
|
||||
@Patch(dependencies = [SharedResourceIdPatch::class])
|
||||
object NavigationButtonHookPatch : BytecodePatch(
|
||||
setOf(PivotBarCreateButtonViewFingerprint)
|
||||
) {
|
||||
internal lateinit var PivotBarResult: MethodFingerprintResult
|
||||
internal lateinit var PivotBarMethod: MutableMethod
|
||||
|
||||
override fun execute(context: BytecodeContext) {
|
||||
PivotBarResult = PivotBarCreateButtonViewFingerprint.result
|
||||
?: throw PivotBarCreateButtonViewFingerprint.exception
|
||||
|
||||
PivotBarMethod = PivotBarResult.mutableMethod
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user