mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-28 12:50:19 +02:00
feat(music): add start-page
patch
This commit is contained in:
parent
81ceb4e598
commit
97f1143d51
@ -0,0 +1,18 @@
|
||||
package app.revanced.patches.music.general.startpage.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object ColdStartUpFingerprint : MethodFingerprint(
|
||||
returnType = "Ljava/lang/String;",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = emptyList(),
|
||||
opcodes = listOf(
|
||||
Opcode.GOTO,
|
||||
Opcode.CONST_STRING,
|
||||
Opcode.RETURN_OBJECT
|
||||
),
|
||||
strings = listOf("FEmusic_library_sideloaded_tracks", "FEmusic_home")
|
||||
)
|
@ -0,0 +1,65 @@
|
||||
package app.revanced.patches.music.general.startpage.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.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.music.general.startpage.fingerprints.ColdStartUpFingerprint
|
||||
import app.revanced.patches.music.utils.annotations.MusicCompatibility
|
||||
import app.revanced.patches.music.utils.intenthook.patch.IntentHookPatch
|
||||
import app.revanced.patches.music.utils.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.patches.music.utils.settings.resource.patch.SettingsPatch.Companion.contexts
|
||||
import app.revanced.util.enum.CategoryType
|
||||
import app.revanced.util.integrations.Constants.MUSIC_GENERAL
|
||||
import app.revanced.util.resources.ResourceUtils.copyXmlNode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Patch
|
||||
@Name("Start page")
|
||||
@Description("Set the default start page.")
|
||||
@DependsOn(
|
||||
[
|
||||
IntentHookPatch::class,
|
||||
SettingsPatch::class
|
||||
]
|
||||
)
|
||||
@MusicCompatibility
|
||||
class StartPagePatch : BytecodePatch(
|
||||
listOf(ColdStartUpFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
ColdStartUpFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
targetIndex + 1, """
|
||||
invoke-static {v$targetRegister}, $MUSIC_GENERAL->setStartPage(Ljava/lang/String;)Ljava/lang/String;
|
||||
move-result-object v$targetRegister
|
||||
return-object v$targetRegister
|
||||
"""
|
||||
)
|
||||
removeInstruction(targetIndex)
|
||||
}
|
||||
} ?: throw ColdStartUpFingerprint.exception
|
||||
|
||||
/**
|
||||
* Copy arrays
|
||||
*/
|
||||
contexts.copyXmlNode("music/startpage/host", "values/arrays.xml", "resources")
|
||||
|
||||
SettingsPatch.addMusicPreferenceWithIntent(
|
||||
CategoryType.GENERAL,
|
||||
"revanced_start_page"
|
||||
)
|
||||
|
||||
}
|
||||
}
|
@ -145,6 +145,13 @@
|
||||
<string name="revanced_save_video_quality_wifi">Changing default Wi-Fi quality to:</string>
|
||||
<string name="revanced_spoof_app_version_summary">Trick the YouTube Music version to v4.27.53 for Canadian users.</string>
|
||||
<string name="revanced_spoof_app_version_title">Spoof app version</string>
|
||||
<string name="revanced_start_page_entry_chart">Chart</string>
|
||||
<string name="revanced_start_page_entry_explore">Explore</string>
|
||||
<string name="revanced_start_page_entry_home">Home</string>
|
||||
<string name="revanced_start_page_entry_library">Library</string>
|
||||
<string name="revanced_start_page_entry_subscription">Subscription</string>
|
||||
<string name="revanced_start_page_summary">Set the start page.</string>
|
||||
<string name="revanced_start_page_title">Start page</string>
|
||||
|
||||
<string name="sb_enabled">Enable SponsorBlock</string>
|
||||
<string name="sb_enabled_sum">SponsorBlock is a crowd-sourced system for skipping annoying parts of YouTube videos.</string>
|
||||
|
17
src/main/resources/music/startpage/host/values/arrays.xml
Normal file
17
src/main/resources/music/startpage/host/values/arrays.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string-array name="revanced_start_page_entry">
|
||||
<item>@string/revanced_start_page_entry_chart</item>
|
||||
<item>@string/revanced_start_page_entry_explore</item>
|
||||
<item>@string/revanced_start_page_entry_home</item>
|
||||
<item>@string/revanced_start_page_entry_library</item>
|
||||
<item>@string/revanced_start_page_entry_subscription</item>
|
||||
</string-array>
|
||||
<string-array name="revanced_start_page_entry_value">
|
||||
<item>FEmusic_charts</item>
|
||||
<item>FEmusic_explore</item>
|
||||
<item>FEmusic_home</item>
|
||||
<item>FEmusic_library_landing</item>
|
||||
<item>FEmusic_library_corpus_artists</item>
|
||||
</string-array>
|
||||
</resources>
|
Loading…
x
Reference in New Issue
Block a user