Skip to content
This repository has been archived by the owner on Dec 8, 2024. It is now read-only.

feat(YouTube Music): add support version 6.20.51 #57

Merged
merged 7 commits into from
Sep 14, 2024

Conversation

kitadai31
Copy link

@kitadai31 kitadai31 commented Sep 9, 2024

Integrations for inotia00/revanced-patches#81

* Downgrade minSdk to 21
* fix(Player components): `Hide audio video switch toggle` causes a crash on 6.20
* fix(Player components): Play button turns black on Android 5.x if `Restore old player background` is applied but disabled

Downgrade minSdk to 21

Rewrote code that uses unsupported APIs.
Most of the changes are just wrapping the existing code in if statements, so you can easily revert back the changes when you drop 6.20.51 again.
For files related to YouTube or Reddit, the only change is adding the @TargetApi(26) annotation to suppress warnings.
Because both YouTube 18.29.38 and Reddit 2023.12.0 are minSdk=26.

Hide audio video switch toggle causes a crash on 6.20

Added a new method that uses setVisibility(View.INVISIBLE) in PlayerPatch for 6.20
By the way, View.INVISIBLE also works for the latest YT Music. Perhaps just replacing the viewGroup.removeView(view) in existing method might be enough?

Fix play button turns black on Android 5.x

Android 5.x have a different design for play button.
This difference causes a black play button if new background is applied by Restore old player background.

Android5.x_old_backround.png
Android5.x_new_background_black_play_button.png

v6.20.51 have a old background originally, but if Restore old player background patch is applied, new background is forced by default.
So disable the functionality of this patch on Android 5.x.

* Downgrade minSdk to 21
* fix(Player components): `Hide audio video switch toggle` causes a crash on 6.20
* fix(Player components): Play button turns black on Android 5.x if `Restore old player background` is disabled
@inotia00
Copy link
Owner

Unfortunately I don't have an Android 5 device so I haven't been able to test the refectored commits

Can you test this?

@kitadai31
Copy link
Author

kitadai31 commented Sep 12, 2024

There was one problem

FATAL EXCEPTION: main
Process: app.rvx62051.android.apps.youtube.music, PID: 2567
java.lang.NoSuchMethodError: No virtual method close()V in class Landroid/content/ContentProviderClient; or its super classes (declaration of 'android.content.ContentProviderClient' appears in /system/framework/framework.jar)
	at app.revanced.integrations.shared.patches.GmsCoreSupport.contentProviderClientUnAvailable(GmsCoreSupport.java:140)
	at app.revanced.integrations.shared.patches.GmsCoreSupport.checkGmsCore(GmsCoreSupport.java:109)
	at com.google.android.apps.youtube.music.activities.MusicActivity.onCreate(PG)
	at android.app.Activity.performCreate(Activity.java:5937)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
	at android.app.ActivityThread.access$800(ActivityThread.java:144)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:135)
	at android.app.ActivityThread.main(ActivityThread.java:5221)
	at java.lang.reflect.Method.invoke(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:372)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

Apparently, if the minSdk is before 24, the compiler makes this try-with-resources statement uses release() instead of close() method (Added in API level 24).
However, if minSdk is 24, it uses close(), so crashed.
I pushed the fix now, please refactor if needed.

Apart from this it works perfectly. Thank you.
(I didn't know how to avoid the compiler optimizations that remove code for older OSes when I set minSdk to 24.)

@kitadai31

This comment was marked as resolved.

@kitadai31
Copy link
Author

There was one other problem
Dialog text disappears

image

Can you restore AlertDialog.THEME_DEVICE_DEFAULT_DARK for SDK 21?
This is the legitimate predecessor of android.R.style.Theme_DeviceDefault_Dialog_Alert.

This constant was deprecated in API level 23.
Use R.style.Theme_DeviceDefault_Dialog_Alert.

https://developer.android.com/reference/android/app/AlertDialog#THEME_DEVICE_DEFAULT_DARK

@inotia00
Copy link
Owner

Please test the suggestion on Android 5.0
If it works, please push it

Co-authored-by: inotia00 <108592928+inotia00@users.noreply.github.com>
@kitadai31
Copy link
Author

kitadai31 commented Sep 12, 2024

I noticed that you also changed some YouTube code to compatible with SDK 21
What is this change?

The minSdkVersion has been upgraded to 24, so there should be no warnings when using new APIs in YouTube class
So this change should be not necessary, right?

@inotia00
Copy link
Owner

For classes related to the SpoofStreamingData patch, compatibility for Android 6.0 should be maintained to ensure operation on YouTube 17.34.36

No SDK check is required for other classes
(I plan to lint after the merge)

@kitadai31
Copy link
Author

I see.
But don't worry about 17.34.36!
It is the change that should be made in my fork

As you said above, it would require too many unnecessary changes
Among the apps supported by RVX, the only one that targets SDK 23 is YT Music 6.20.51
It is better for you to add the minimum changes, so that your repository is kept clean

I bookmarked the commit ref in my browser.
https://github.com/inotia00/revanced-integrations/tree/a7e2f9f8e16556e06678f83505aa1a21ef8980a2
By doing this, I can borrow your Android 6.0 supported SpoofStreamingData code permanently, even if you reverted the changes for 17.34.36 support, or I deleted the PR branch.

@inotia00
Copy link
Owner

Instead of using Build.VERSION.SDK_INT in all classes, I implemented a method isSDKAbove(int) in the Utils class to check the SDK version

The SDK version check has been used not only by YouTube Music but also by YouTube, so it is valid to apply the change to YouTube's class as well

@inotia00 inotia00 merged commit 356eed3 into inotia00:dev Sep 14, 2024
@kitadai31 kitadai31 deleted the music branch September 28, 2024 16:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants