Skip to content
Merged

Fixes #634

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,45 @@ import crimera.patches.twitter.misc.settings.fingerprints.SettingsStatusLoadFing

object CustomiseSideBarFingerprint : MethodFingerprint(
returnType = "Ljava/lang/Object",
strings = listOf(
"android_global_navigation_top_level_monetization_enabled",
),
strings =
listOf(
"android_global_navigation_top_level_monetization_enabled",
),
customFingerprint = { it, _ ->
it.name == "invoke"
}
},
)

@Patch(
name = "Customize side bar items",
dependencies = [SettingsPatch::class],
compatiblePackages = [CompatiblePackage("com.twitter.android")],
)
@Suppress("unused")
object CustomiseSideBarPatch : BytecodePatch(
setOf(CustomiseSideBarFingerprint,SettingsStatusLoadFingerprint)
){
setOf(CustomiseSideBarFingerprint, SettingsStatusLoadFingerprint),
) {

override fun execute(context: BytecodeContext) {
val result = CustomiseSideBarFingerprint.result
?: throw PatchException("CustomiseSideBarFingerprint not found")
val result =
CustomiseSideBarFingerprint.result
?: throw PatchException("CustomiseSideBarFingerprint not found")

val method = result.mutableMethod

val instructions = method.getInstructions()

val return_obj = instructions.last { it.opcode == Opcode.RETURN_OBJECT }.location.index
var filledNewArrIndex = instructions.last { it.opcode == Opcode.FILLED_NEW_ARRAY_RANGE }.location.index
val return_obj = instructions.first { it.opcode == Opcode.RETURN_OBJECT && it.location.index > filledNewArrIndex }.location.index
val r0 = method.getInstruction<OneRegisterInstruction>(return_obj).registerA

val METHOD = """
val METHOD =
"""
invoke-static {v$r0}, ${SettingsPatch.CUSTOMISE_DESCRIPTOR};->sideBar(Ljava/util/List;)Ljava/util/List;
move-result-object v$r0
""".trimIndent()
""".trimIndent()

method.addInstructionsWithLabels(return_obj,METHOD)
method.addInstructionsWithLabels(return_obj, METHOD)

SettingsStatusLoadFingerprint.enableSettings("sideBarCustomisation")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ import crimera.patches.twitter.misc.integrations.IntegrationsPatch
import crimera.patches.twitter.misc.settings.fingerprints.AuthorizeAppActivity
import crimera.patches.twitter.misc.settings.fingerprints.SettingsFingerprint
import crimera.patches.twitter.misc.settings.fingerprints.UrlInterpreterActivity
import crimera.patches.twitter.premium.redirectBMNavBar.RedirectBMTab

@Patch(
description = "Adds settings",
requiresIntegrations = true,
dependencies = [SettingsResourcePatch::class, IntegrationsPatch::class],
dependencies = [SettingsResourcePatch::class, IntegrationsPatch::class, RedirectBMTab::class],
compatiblePackages = [CompatiblePackage("com.twitter.android")],
)
object SettingsPatch : BytecodePatch(
Expand Down Expand Up @@ -78,14 +79,18 @@ object SettingsPatch : BytecodePatch(
.first { it.opcode == Opcode.CONST_4 }
.location.index

val igetObjLoc = prefCLickedMethod.getInstructions().first { it.opcode == Opcode.IGET_OBJECT }.location.index
val igetObjLoc =
prefCLickedMethod
.getInstructions()
.first { it.opcode == Opcode.IGET_OBJECT }
.location.index
val objFieldName = (prefCLickedMethod.getInstruction<ReferenceInstruction>(igetObjLoc).reference as FieldReference).name
prefCLickedMethod.removeInstruction(igetObjLoc)

prefCLickedMethod.addInstructionsWithLabels(
0,
"""
iget-object p1, p1, Landroidx/preference/Preference;->${objFieldName}:Ljava/lang/String;
iget-object p1, p1, Landroidx/preference/Preference;->$objFieldName:Ljava/lang/String;
const-string v1, "pref_mod"
invoke-virtual {p1, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ object CustomiseAppIconFingerprint : MethodFingerprint(
listOf(
"current_app_icon_id",
),
returnType = "V",
)

@Patch(
name = "Enable app icons",
dependencies = [SettingsPatch::class, RedirectBMTab::class],
dependencies = [SettingsPatch::class],
compatiblePackages = [CompatiblePackage("com.twitter.android")],
use = true,
requiresIntegrations = true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package crimera.patches.twitter.premium.customAppIcon
package crimera.patches.twitter.premium.redirectBMNavBar

import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
Expand All @@ -10,20 +10,20 @@ import app.revanced.patcher.util.smali.ExternalLabel
import com.android.tools.smali.dexlib2.Opcode
import crimera.patches.twitter.misc.settings.SettingsPatch.PREF_DESCRIPTOR


//thanks to @Ouxyl
object TabLayoutFingerprint:MethodFingerprint(
customFingerprint = {it,_->
// thanks to @Ouxyl
object TabLayoutFingerprint : MethodFingerprint(
customFingerprint = { it, _ ->
it.definingClass == "Lcom/google/android/material/tabs/TabLayout;" && it.name == "q"
}
},
)

object RedirectBMTab:BytecodePatch(
setOf(TabLayoutFingerprint)
object RedirectBMTab : BytecodePatch(
setOf(TabLayoutFingerprint),
) {
override fun execute(context: BytecodeContext) {
val result = TabLayoutFingerprint.result
?:throw PatchException("TabLayoutFingerprint not found")
val result =
TabLayoutFingerprint.result
?: throw PatchException("TabLayoutFingerprint not found")

val method = result.mutableMethod
val instructions = method.getInstructions()
Expand All @@ -32,15 +32,17 @@ object RedirectBMTab:BytecodePatch(

val M = "invoke-static {p1}, ${PREF_DESCRIPTOR};->redirect(Lcom/google/android/material/tabs/TabLayout\$g;)Z"

method.addInstructionsWithLabels(0,"""
method.addInstructionsWithLabels(
0,
"""
$M
move-result v0
if-eqz v0, :cond_1212
return-void
""".trimIndent(),
ExternalLabel("cond_1212", first_line)
""".trimIndent(),
ExternalLabel("cond_1212", first_line),
)

//end
// end
}
}
}
9 changes: 7 additions & 2 deletions src/main/resources/twitter/settings/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,25 @@
<item>@string/drawer_profile_title</item>
<item>@string/subscriptions_drawer_menu_title</item>
<item>@string/grok_tab_title</item>
<item>@string/drawer_money_title</item>
<item>@string/x_chat_tab_title</item>
<item>@string/drawer_direct_messages_title</item>
<item>@string/drawer_communities_title</item>
<item>@string/video_tab_title</item>
<item>@string/bookmarks_title</item>
<item>@string/drawer_jobs_title</item>
<item>@string/drawer_lists</item>
<item>@string/news_top_articles_title</item>
<item>@string/drawer_birdwatch_title</item>
<item>@string/spaces_grid_tab</item>
<item>@string/video_chat_conference</item>
<item>@string/profile_followers</item>
<item>@string/monetization_drawer_menu_title</item>
<item>@string/subscriptions_drawer_menu_group_analytics</item>
<item>@string/drawer_professional_tools_header_title</item>
<item>@string/drawer_settings_title</item>
<item>@string/drawer_media_transparency_title</item>
<item>@string/drawer_imprint_title</item>
<item>@string/drawer_settings_title</item>
<item>@string/drawer_jobs_title</item>
</string-array>

<string-array name="piko_array_navbar">
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/twitter/settings/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,6 @@
<string name="piko_pref_search_type_ahead_events">Events</string>
<string name="piko_pref_search_type_ahead_ordered_section">Ordered section</string>

<string name="piko_settings_supported_links">Open supported links</string>

</resources>
Loading