Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mute button inflation problems on API<21 #3283

Merged
merged 1 commit into from
Mar 28, 2020

Conversation

Stypox
Copy link
Member

@Stypox Stypox commented Mar 27, 2020

See https://stackoverflow.com/questions/35819290/invalid-drawable-tag-vector
There was no need to change other ImageButtons because the image was set programmatically only in the mute button

@Stypox
Copy link
Member Author

Stypox commented Mar 27, 2020

@domiuns thanks for the report in #3266. Could you please test if this debug apk fixes your issue?
Debug apk: app-debug_1.zip

Off-topic: sono anch'io italiano ;-D

Copy link
Contributor

@mauriciocolli mauriciocolli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, did you test this in a API 19 emulator?

Anyway, that's not the issue as srcCompat is correctly used in the layout, the issue is that ContextCompat is being used to fetch a vector drawable, which isn't the intended use for it.

AppCompatResources is the correct one.

@Stypox
Copy link
Member Author

Stypox commented Mar 28, 2020

Wait, did you test this in a API 19 emulator?

I did not, as I have a slow internet connection and no time to download a whole emulator.

AppCompatResources is the correct one.

Could you do that, please? I don't know how and where I should use AppCompatResources :-/

@TobiGr
Copy link
Contributor

TobiGr commented Mar 28, 2020

@mauriciocolli is correct. You need to change it here:

muteButton.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), isMuted ? R.drawable.ic_volume_off_white_72dp : R.drawable.ic_volume_up_white_72dp));

Already tested in the emulator. Works 👍

@ghost
Copy link

ghost commented Mar 28, 2020

@Stypox i have test your apk i have this

Exception

  • User Action: ui error
  • Request: App crash, UI failure
  • Content Language: it_IT
  • Service: none
  • Version: 0.19.0
  • OS: Linux Android 4.4.4 - 19
Crash log

android.content.res.Resources$NotFoundException: File res/drawable/ic_volume_up_white_72dp.xml from drawable resource ID #0x7f08015d. If the resource you are trying to use is a vector resource, you may be referencing it in an unsupported way. See AppCompatDelegate.setCompatVectorFromResourcesEnabled() for more info.
	at android.content.res.Resources.loadDrawable(Resources.java:1993)
	at android.content.res.Resources.getDrawable(Resources.java:673)
	at androidx.core.content.ContextCompat.getDrawable(ContextCompat.java:456)
	at org.schabi.newpipe.player.MainVideoPlayer.setMuteButton(MainVideoPlayer.java:407)
	at org.schabi.newpipe.player.MainVideoPlayer$VideoPlayerImpl.onMoreOptionsClicked(MainVideoPlayer.java:799)
	at org.schabi.newpipe.player.MainVideoPlayer$VideoPlayerImpl.onClick(MainVideoPlayer.java:735)
	at android.view.View.performClick(View.java:4211)
	at android.view.View$PerformClick.run(View.java:17446)
	at android.os.Handler.handleCallback(Handler.java:725)
	at android.os.Handler.dispatchMessage(Handler.java:92)
	at android.os.Looper.loop(Looper.java:153)
	at android.app.ActivityThread.main(ActivityThread.java:5297)
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:511)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
	at dalvik.system.NativeStart.main(Native Method)
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #1: invalid drawable tag vector
	at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:881)
	at android.graphics.drawable.Drawable.createFromXml(Drawable.java:822)
	at android.content.res.Resources.loadDrawable(Resources.java:1990)
	... 16 more
org.xmlpull.v1.XmlPullParserException: Binary XML file line #1: invalid drawable tag vector
	at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:881)
	at android.graphics.drawable.Drawable.createFromXml(Drawable.java:822)
	at android.content.res.Resources.loadDrawable(Resources.java:1990)
	at android.content.res.Resources.getDrawable(Resources.java:673)
	at androidx.core.content.ContextCompat.getDrawable(ContextCompat.java:456)
	at org.schabi.newpipe.player.MainVideoPlayer.setMuteButton(MainVideoPlayer.java:407)
	at org.schabi.newpipe.player.MainVideoPlayer$VideoPlayerImpl.onMoreOptionsClicked(MainVideoPlayer.java:799)
	at org.schabi.newpipe.player.MainVideoPlayer$VideoPlayerImpl.onClick(MainVideoPlayer.java:735)
	at android.view.View.performClick(View.java:4211)
	at android.view.View$PerformClick.run(View.java:17446)
	at android.os.Handler.handleCallback(Handler.java:725)
	at android.os.Handler.dispatchMessage(Handler.java:92)
	at android.os.Looper.loop(Looper.java:153)
	at android.app.ActivityThread.main(ActivityThread.java:5297)
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:511)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
	at dalvik.system.NativeStart.main(Native Method)


@TobiGr TobiGr changed the base branch from release_0.19.0 to dev March 28, 2020 17:33
@mauriciocolli
Copy link
Contributor

I did not, as I have a slow internet connection and no time to download a whole emulator.

What do you mean? The emulator should be about ~177MB, that's what, a few minutes of 1080p streaming?

Could you do that, please? I don't know how and where I should use AppCompatResources :-/

Done.

@TobiGr TobiGr changed the title Use AppCompatImageButton to fix inflation problems on API<21 Fix mute button inflation problems on API<21 Mar 28, 2020
@TobiGr TobiGr merged commit 40de014 into TeamNewPipe:dev Mar 28, 2020
This was referenced Mar 29, 2020
@Stypox
Copy link
Member Author

Stypox commented Mar 30, 2020

The emulator should be about ~177MB, that's what, a few minutes of 1080p streaming?

Ok, I will download it, for some reason I remember seeing multiple GB of download a while ago, but who knows what I saw ;-)
Thanks for answering, and sorry for not being active for the last two days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants