-
-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(YouTube): Add
Change start page
patch
- Loading branch information
Showing
5 changed files
with
101 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s/fingerprints/HomeActivityFingerprint.kt → ...d/fingerprints/HomeActivityFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/main/kotlin/app/revanced/patches/youtube/layout/startpage/ChangeStartPagePatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package app.revanced.patches.youtube.layout.startpage | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction | ||
import app.revanced.patcher.patch.BytecodePatch | ||
import app.revanced.patcher.patch.annotation.CompatiblePackage | ||
import app.revanced.patcher.patch.annotation.Patch | ||
import app.revanced.patches.shared.fingerprints.HomeActivityFingerprint | ||
import app.revanced.patches.shared.settings.preference.impl.ArrayResource | ||
import app.revanced.patches.shared.settings.preference.impl.ListPreference | ||
import app.revanced.patches.shared.settings.preference.impl.StringResource | ||
import app.revanced.patches.youtube.layout.startpage.fingerprints.StartActivityFingerprint | ||
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch | ||
import app.revanced.patches.youtube.misc.settings.SettingsPatch | ||
import app.revanced.util.exception | ||
|
||
@Patch( | ||
name = "Change start page", | ||
description = "Changes the start page of the app.", | ||
dependencies = [IntegrationsPatch::class, SettingsPatch::class], | ||
compatiblePackages = [ | ||
CompatiblePackage( | ||
"com.google.android.youtube" | ||
) | ||
] | ||
) | ||
@Suppress("unused") | ||
object ChangeStartPagePatch : BytecodePatch( | ||
setOf(HomeActivityFingerprint) | ||
) { | ||
private const val INTEGRATIONS_CLASS_DESCRIPTOR = | ||
"Lapp/revanced/integrations/patches/ChangeStartPagePatch;" | ||
|
||
override fun execute(context: BytecodeContext) { | ||
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( | ||
ListPreference( | ||
"revanced_start_page", | ||
StringResource( | ||
"revanced_start_page_title", | ||
"Set start page" | ||
), | ||
ArrayResource( | ||
"revanced_start_page_entries", | ||
listOf( | ||
StringResource("revanced_start_page_home_entry_0", "Default"), | ||
StringResource("revanced_start_page_home_entry_1", "Home"), | ||
StringResource("revanced_start_page_search_entry_2", "Search"), | ||
StringResource("revanced_start_page_subscriptions_entry_3", "Subscriptions"), | ||
StringResource("revanced_start_page_explore_entry_4", "Explore"), | ||
StringResource("revanced_start_page_shorts_entry_5", "Shorts"), | ||
) | ||
), | ||
ArrayResource( | ||
"revanced_start_page_values", | ||
listOf( | ||
StringResource("revanced_start_page_home_value_0", ""), | ||
StringResource("revanced_start_page_home_value_1", "MAIN"), | ||
StringResource("revanced_start_page_search_value_2", "open.search"), | ||
StringResource("revanced_start_page_subscriptions_value_3", "open.subscriptions"), | ||
StringResource("revanced_start_page_explore_value_4", "open.explore"), | ||
StringResource("revanced_start_page_shorts_value_5", "open.shorts"), | ||
) | ||
), | ||
default = "" | ||
) | ||
) | ||
|
||
StartActivityFingerprint.resolve( | ||
context, | ||
HomeActivityFingerprint.result?.classDef ?: throw HomeActivityFingerprint.exception | ||
) | ||
|
||
StartActivityFingerprint.result?.mutableMethod?.addInstruction( | ||
0, | ||
"invoke-static { p1 }, $INTEGRATIONS_CLASS_DESCRIPTOR->changeIntent(Landroid/content/Intent;)V" | ||
) ?: throw StartActivityFingerprint.exception | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...in/app/revanced/patches/youtube/layout/startpage/fingerprints/StartActivityFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package app.revanced.patches.youtube.layout.startpage.fingerprints | ||
|
||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
|
||
object StartActivityFingerprint : MethodFingerprint( | ||
parameters = listOf("Landroid/content/Intent;"), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters