forked from inotia00/revanced-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(YouTube/YT Music): add
Return YouTube Username
patch
- Loading branch information
Showing
13 changed files
with
179 additions
and
3 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
40 changes: 40 additions & 0 deletions
40
...tlin/app/revanced/patches/music/utils/returnyoutubeusername/ReturnYouTubeUsernamePatch.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,40 @@ | ||
package app.revanced.patches.music.utils.returnyoutubeusername | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patches.music.utils.compatibility.Constants.COMPATIBLE_PACKAGE | ||
import app.revanced.patches.music.utils.settings.CategoryType | ||
import app.revanced.patches.music.utils.settings.SettingsPatch | ||
import app.revanced.patches.shared.returnyoutubeusername.BaseReturnYouTubeUsernamePatch | ||
import app.revanced.util.patch.BaseBytecodePatch | ||
|
||
@Suppress("unused") | ||
object ReturnYouTubeUsernamePatch : BaseBytecodePatch( | ||
name = "Return YouTube Username", | ||
description = "Adds option to replace YouTube Handle with Username in comments using YouTube Data API v3.", | ||
dependencies = setOf( | ||
BaseReturnYouTubeUsernamePatch::class, | ||
SettingsPatch::class, | ||
), | ||
compatiblePackages = COMPATIBLE_PACKAGE, | ||
use = false | ||
) { | ||
override fun execute(context: BytecodeContext) { | ||
|
||
SettingsPatch.addSwitchPreference( | ||
CategoryType.RETURN_YOUTUBE_USERNAME, | ||
"revanced_return_youtube_username_enabled", | ||
"false" | ||
) | ||
SettingsPatch.addPreferenceWithIntent( | ||
CategoryType.RETURN_YOUTUBE_USERNAME, | ||
"revanced_return_youtube_username_youtube_data_api_v3_developer_key", | ||
"revanced_return_youtube_username_enabled" | ||
) | ||
if (SettingsPatch.upward0627) { | ||
SettingsPatch.addPreferenceWithIntent( | ||
CategoryType.RETURN_YOUTUBE_USERNAME, | ||
"revanced_return_youtube_username_youtube_data_api_v3_about" | ||
) | ||
} | ||
} | ||
} |
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
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
19 changes: 19 additions & 0 deletions
19
...otlin/app/revanced/patches/shared/returnyoutubeusername/BaseReturnYouTubeUsernamePatch.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,19 @@ | ||
package app.revanced.patches.shared.returnyoutubeusername | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.patch.BytecodePatch | ||
import app.revanced.patcher.patch.annotation.Patch | ||
import app.revanced.patches.shared.integrations.Constants.PATCHES_PATH | ||
import app.revanced.patches.shared.textcomponent.TextComponentPatch | ||
|
||
@Patch(dependencies = [TextComponentPatch::class]) | ||
object BaseReturnYouTubeUsernamePatch : BytecodePatch(emptySet()) { | ||
private const val INTEGRATIONS_CLASS_DESCRIPTOR = | ||
"$PATCHES_PATH/ReturnYouTubeUsernamePatch;" | ||
|
||
override fun execute(context: BytecodeContext) { | ||
TextComponentPatch.hookSpannableString(INTEGRATIONS_CLASS_DESCRIPTOR, "preFetchLithoText") | ||
TextComponentPatch.hookTextComponent(INTEGRATIONS_CLASS_DESCRIPTOR) | ||
} | ||
} | ||
|
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
34 changes: 34 additions & 0 deletions
34
...in/app/revanced/patches/youtube/utils/returnyoutubeusername/ReturnYouTubeUsernamePatch.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,34 @@ | ||
package app.revanced.patches.youtube.utils.returnyoutubeusername | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patches.shared.returnyoutubeusername.BaseReturnYouTubeUsernamePatch | ||
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE | ||
import app.revanced.patches.youtube.utils.settings.SettingsPatch | ||
import app.revanced.util.patch.BaseBytecodePatch | ||
|
||
@Suppress("unused") | ||
object ReturnYouTubeUsernamePatch : BaseBytecodePatch( | ||
name = "Return YouTube Username", | ||
description = "Adds option to replace YouTube Handle with Username in comments using YouTube Data API v3.", | ||
dependencies = setOf( | ||
BaseReturnYouTubeUsernamePatch::class, | ||
SettingsPatch::class, | ||
), | ||
compatiblePackages = COMPATIBLE_PACKAGE, | ||
use = false | ||
) { | ||
override fun execute(context: BytecodeContext) { | ||
|
||
/** | ||
* Add settings | ||
*/ | ||
SettingsPatch.addPreference( | ||
arrayOf( | ||
"PREFERENCE_SCREEN: RETURN_YOUTUBE_USERNAME" | ||
) | ||
) | ||
|
||
SettingsPatch.updatePatchStatus(this) | ||
|
||
} | ||
} |
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
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
18 changes: 18 additions & 0 deletions
18
.../music/visual/shared/drawable/revanced_preference_screen_return_youtube_username_icon.xml
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,18 @@ | ||
<vector | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:name="vector" | ||
android:width="48dp" | ||
android:height="48dp" | ||
android:viewportWidth="960" | ||
android:viewportHeight="960"> | ||
<group | ||
android:scaleX="0.5" | ||
android:scaleY="0.5" | ||
android:pivotX="300" | ||
android:pivotY="480"> | ||
<path | ||
android:name="path" | ||
android:pathData="M 349.504 315.587 L 610.497 315.587 L 610.497 368.835 L 349.504 368.835 L 349.504 315.587 Z M 755.994 135.465 L 755.994 824.535 L 584.287 652.829 L 204.007 652.829 L 204.007 135.465 L 755.994 135.465 Z M 236.631 169.09 L 236.631 621.204 L 236.631 620.204 L 597.654 620.204 L 597.947 620.497 L 607.403 629.952 L 721.662 744.211 L 723.369 745.918 L 725.076 747.625 L 723.369 745.918 L 723.369 748.332 L 723.369 167.09 L 723.369 168.09 L 237.631 168.09 M 349.504 454.083 L 506.624 454.083 L 506.624 507.332 L 349.504 507.332 L 349.504 454.083 Z" | ||
android:fillColor="@android:color/white" /> | ||
</group> | ||
</vector> |
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
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
18 changes: 18 additions & 0 deletions
18
...outube/visual/shared/drawable/revanced_preference_screen_return_youtube_username_icon.xml
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,18 @@ | ||
<vector | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:name="vector" | ||
android:width="48dp" | ||
android:height="48dp" | ||
android:viewportWidth="960" | ||
android:viewportHeight="960"> | ||
<group | ||
android:scaleX="0.5" | ||
android:scaleY="0.5" | ||
android:pivotX="480" | ||
android:pivotY="480"> | ||
<path | ||
android:name="path" | ||
android:pathData="M 840 803.077 L 716.923 680 L 175.384 680 Q 152.327 680 136.163 663.837 Q 120 647.673 120 624.616 L 120 175.384 Q 120 152.327 136.163 136.163 Q 152.327 120 175.384 120 L 784.616 120 Q 807.673 120 823.837 136.163 Q 840 152.327 840 175.384 L 840 803.077 Z M 175.384 649.231 L 730.615 649.231 L 809.231 730.769 L 809.231 175.384 Q 809.231 166.154 801.539 158.461 Q 793.846 150.769 784.616 150.769 L 175.384 150.769 Q 166.154 150.769 158.461 158.461 Q 150.769 166.154 150.769 175.384 L 150.769 624.616 Q 150.769 633.846 158.461 641.539 Q 166.154 649.231 175.384 649.231 Z M 150.769 649.231 L 150.769 150.769 L 150.769 649.231 Z" | ||
android:fillColor="?ytTextPrimary" /> | ||
</group> | ||
</vector> |