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 crash when no default browser is set and improve share dialogs (on some devices) #5187

Merged
merged 3 commits into from
Jan 16, 2021
Merged

Fix crash when no default browser is set and improve share dialogs (on some devices) #5187

merged 3 commits into from
Jan 16, 2021

Conversation

AudricV
Copy link
Member

@AudricV AudricV commented Dec 15, 2020

What is it?

  • Bugfix (user facing)
  • Feature (user facing)
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

General description of the changes

This PR improves sharing content to other apps with the following changes:

  • fix crash when no browser is set on some devices (NewPipe thinks that the system app chooser is a browser because its package ID isn't "android" due to some OEM's system customizations)
  • try to use Android's system share sheet instead of OEM's share sheet (this last is used as a fallback if this first was removed) for:
    • share content in clipboard (playlists, videos, tracks, channels and bug reports)
    • open content in browser (playlists, videos, tracks, channels, report on GitHub in bug reports options and comments, install a player prompts) where there is no default app
    • open a video stream / an audio stream in a external player where there is no default app
  • fix double toast Copied to clipboard shown when copying formatted report in crash report activity

Code changes

  • catch ActivityNotFoundException when opening an URL or a file if it's a chooser
  • add openFileInApp method in ShareUtils to be able to open streams in external app / downloads in default app or in the app chooser
  • edit getDefaultAppPackageName method of ShareUtils to be able to return default app for opening downloads, streams, or URLs
  • use ShareUtils.openFileInApp for downloads / playing streams in external player
  • use ShareUtils.shareUrl for sharing crash report from ErrorActivity to other apps and for sharing a stream in the play queue
  • use ShareUtils.openUrlInBrowser when tap "Install" button from install VLC and install Kore dialogs
  • use an ACTION_CHOOSER intent and putting as an extra intent the ACTION_SEND intent to share downloads
  • add a string open_with in English and French which is used for Android's system chooser title
  • add / edit comments and change JavaDocs for remembering that "android" package isn't returned when no default app on some devices
  • also indent checkstyle-suppressions.xml file

Here is the difference between the original code and my changes (my device is an Honor 9X, running EMUI 10):

Before this PR After this PR
Share panel before Share panel after
Share panel before this PR Share panel after this PR
Open in browser before Open in browser after
Open in browser before this PR Open in browser after this PR
Open a download before Open a download after
Open a download when no default app set before this PR Open a download when no default app set after this PR

What I changed to do this

The trick to do this is to use an ACTION_CHOOSER intent and put the share intent (ACTION_SEND) or the view intent (ACTION_VIEW) as an extra intent.
Note also if Android's system chooser (in the intent ACTION_CHOOSER) has been directly modified by the OEM, this PR will not change it.

A few note about UX

With my changes, we can't choose which app to always open an intent but only choose for once (if there isn't a default app).

Fixes the following issue(s)

Fixes #3925

APK testing

NewPipe share improvements debug apk.zip (based on 92a87a5)

Due diligence

Important note: I am not an Android / Java developer so please be indulgent with me.

@TobiGr TobiGr added the bug Issue is related to a bug label Dec 15, 2020
@AudricV
Copy link
Member Author

AudricV commented Dec 15, 2020

@test2a Can you please test the above APK and let me know if the crash when opening content in browser if you didn't set a default browser is fixed for you and when you share a video or a playlist, all is working? Thank you in advance.

@test2a
Copy link

test2a commented Dec 16, 2020

@TiA4f8R
Screenshot_20201216-104135

the new share screen is not showing for me.

i think the browser thing has been somehow fixed but the issue remains. if i set newpipe to "open links in the app" in settings, then that app is always triggered. i am forced to set to ask everytime and then the above screen shows.

@AudricV
Copy link
Member Author

AudricV commented Dec 16, 2020

@test2a This is intended, that's how Android works. Also, your chooser dialog is from Android system (I have it too on my old Asus Zenfone 4 Max running Android 8.1.0), so all is working when opening content in browser.

About the share screen, can you share a playlist and say me if all is working by posting a screenshot from it?

Moreover, with the informations you provided in #4140, it seems your device isn't running Android 10 and this share sheet is from Android 10. So it's normal.

@test2a
Copy link

test2a commented Dec 16, 2020

@TiA4f8R yeah. i am on 8 i think. anyways, how to share a playlist?? i see no option in bookmarked playlists

@test2a
Copy link

test2a commented Dec 16, 2020

@TiA4f8R okay. got it. this just works
Screenshot_20201216-173829

@test2a
Copy link

test2a commented Dec 16, 2020

Screenshot_20201216-173917

@AudricV
Copy link
Member Author

AudricV commented Dec 16, 2020

@test2a Thanks for testing! All should work.

@B0pol B0pol self-assigned this Dec 16, 2020
@AudricV
Copy link
Member Author

AudricV commented Dec 19, 2020

@TobiGr @B0pol In Android Messages of Google, I can select a date from a SMS but the text selection is different and seems to be the text selection of Android because when I use Share command, it opens Android Share Sheet and not Huawei Share Sheet, contrary to NewPipe. Check the two screenshots below:

Screenshot_20201219_143303.jpg

Android Messages date text selection

Screenshot_20201219_143323.jpg

NewPipe text selection (that's also the case of other apps)

Did you know if we can do something for text selection in NewPipe to get the same result?

@AudricV
Copy link
Member Author

AudricV commented Dec 26, 2020

Can someone help me for the things to do in PR description?

@AudricV
Copy link
Member Author

AudricV commented Dec 29, 2020

@MathJoDE Does the APK in description is working for sharing a video/playlist, opening a video/playlist in a browser, opening a NewPipe download, and a link in comment of a video? Thanks for testing in advance.

@MathJoDE
Copy link

MathJoDE commented Dec 29, 2020

@TiA4f8R Seems to work great!

I tested successful (Huawei P9 lite, Android 7 / EMUI 5.0.3):

  • share a video/playlist/channel
  • open a video/playlist/channel in a browser
  • open a NewPipe download
  • open a link in comment of a video
  • (fixing app crashes on error report via github #5308) on error page: buttons to
    • read privacy policy
    • accept privacy policy to report on Github

@AudricV
Copy link
Member Author

AudricV commented Dec 29, 2020

@MathJoDE Like on my device (Honor 9X, EMUI 10), is Android's system chooser showing on your device instead of Huawei chooser / Huawei Share?
Also when you open a download, does the download open in a video / audio player or did you have a chooser (I want to know if you have or not a default app to open your download to be sure if all my code is working even if I tested on my device)? It will be great if you can post screenshots of all cases if possible.
Thanks for testing!

@MathJoDE
Copy link

@MathJoDE Like on my device (Honor 9X, EMUI 10), is Android's system chooser showing on your device instead of Huawei chooser / Huawei Share?

Yes, for all test cases I mentioned in my post above, now the Android system chooser pops up. (In contrast to current stable version 0.20.8, where the Huawei chooser pops up.) It's exemplary shown in the left screenshot below.

Also when you open a download, does the download open in a video / audio player or did you have a chooser (I want to know if you have or not a default app to open your download to be sure if all my code is working even if I tested on my device)? It will be great if you can post screenshots of all cases if possible.

Also for opening a Download the Android system chooser shows up (right screenshot)

Screenshots:

opening a link in a comment opening a download
show screenshot link-in-comment
show screenshot downloaded-video

For links in video descriptions and also for links in these legal notices by youtube (that something belongs to a public broadcast service, or the COVID notices) below videos, still the Huawei Chooser pops up. (left screenshot below). Also at a channel's rss feed, still the Huawei Chooser is used (right screenshot).

opening link in video description/legal notice opening a channel's rss feed
show screenshot link-in-vid-description-and-legal-hint
show screenshot channels-rss-feed

I assume that's what the ToDos in the PRs opening comment are addressing, in which the RSS feed point seems to miss.


I'm not really experienced with Java, and even less with Android developing, but based on the diff of your changes in this PR I fiddled a bit around[1]. So the following is absolutely untested and just guessed. Maybe it can help, if not, just ignore it ^^

I suppose here the ShareUtils.openUrlInBrowser should be used for also opening the rss feed link with android's default chooser.

[1] using git grep -B 10 -A 2 "startActivity("

@AudricV
Copy link
Member Author

AudricV commented Dec 29, 2020

@MathJoDE Thanks for your searches and your response! I will do in a future commit the trick for RSS feed.

@B0pol
Copy link
Member

B0pol commented Dec 29, 2020

I disagree with last change. We don't want to open RSS feed in browser, but in default app configured to handle RSS or other feeds. It's fine to open RSS feed in your RSS app. On top of that, most popular browsers don't support RSS feeds anymore.

The "why" I introduced this change initially — open in browser instead of open in default app — was because YouTube, PeerTube or other services links would loop in NewPipe if NewPipe is set as default for these links.

@AudricV
Copy link
Member Author

AudricV commented Dec 29, 2020

@B0pol I understand what you mean, but I changed getDefaultAppPackageName to return the default app for an intent passed as an argument and not only for http links. The openUrlInBrowser method just create an intent like as previous for RSS feeds. I just tried with two RSS apps and if I set it to always open the links that they can open it opens the RSS app; if I don't set it, it will open a chooser. This behavior is the same in the original app and my modifications.

Here is a screencast between current behaviour in NewPipe and my changes (please ignore toasts, it was for personal tests):

RSS.feed.debug.vs.release.mp4

@AudricV
Copy link
Member Author

AudricV commented Jan 11, 2021

While debugging my changes in Chrome Developer Tools and opening a YouTube video, this crash happens. How to fix it?

Exception

  • User Action: ui error
  • Request: App crash, UI failure
  • Content Country: FR
  • Content Language: fr
  • App Language: fr_FR
  • Service: none
  • Version: 0.20.8
  • OS: Linux Android 10 - 29
Crash log

io.reactivex.rxjava3.exceptions.OnErrorNotImplementedException: The exception was not handled due to missing onError handler in the subscribe() method call. Further reading: https://github.com/ReactiveX/RxJava/wiki/Error-Handling | java.lang.IllegalStateException
	at io.reactivex.rxjava3.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:717)
	at io.reactivex.rxjava3.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:714)
	at io.reactivex.rxjava3.internal.observers.ConsumerSingleObserver.onError(ConsumerSingleObserver.java:46)
	at io.reactivex.rxjava3.internal.operators.single.SingleObserveOn$ObserveOnSingleObserver.run(SingleObserveOn.java:79)
	at io.reactivex.rxjava3.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:123)
	at android.os.Handler.handleCallback(Handler.java:888)
	at android.os.Handler.dispatchMessage(Handler.java:100)
	at android.os.Looper.loop(Looper.java:213)
	at android.app.ActivityThread.main(ActivityThread.java:8178)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)
Caused by: java.lang.IllegalStateException
	at com.facebook.stetho.common.Util.throwIfNot(Util.java:56)
	at com.facebook.stetho.common.android.HandlerUtil.verifyThreadAccess(HandlerUtil.java:38)
	at com.facebook.stetho.inspector.elements.android.AndroidDocumentProviderFactory.verifyThreadAccess(AndroidDocumentProviderFactory.java:53)
	at com.facebook.stetho.inspector.helper.ThreadBoundProxy.verifyThreadAccess(ThreadBoundProxy.java:36)
	at com.facebook.stetho.inspector.elements.Document$ProviderListener.onAttributeModified(Document.java:725)
	at com.facebook.stetho.inspector.elements.android.AndroidDocumentProvider.onAttributeModified(AndroidDocumentProvider.java:211)
	at com.facebook.stetho.inspector.elements.android.TextViewDescriptor$ElementContext.afterTextChanged(TextViewDescriptor.java:78)
	at android.widget.TextView.sendAfterTextChanged(TextView.java:10634)
	at android.widget.TextView.setText(TextView.java:6335)
	at android.widget.TextView.setText(TextView.java:6154)
	at android.widget.TextView.setText(TextView.java:6106)
	at org.schabi.newpipe.util.LinkHelper.createLinksFromHtmlBlock(LinkHelper.java:40)
	at org.schabi.newpipe.fragments.detail.VideoDetailFragment.lambda$prepareDescription$11$VideoDetailFragment(VideoDetailFragment.java:1233)
	at org.schabi.newpipe.fragments.detail.-$$Lambda$VideoDetailFragment$nQlGpf89J6dlFXrUIggLADRLDEI.apply(Unknown Source:4)
	at io.reactivex.rxjava3.internal.operators.single.SingleMap$MapSingleObserver.onSuccess(SingleMap.java:58)
	at io.reactivex.rxjava3.internal.operators.single.SingleJust.subscribeActual(SingleJust.java:30)
	at io.reactivex.rxjava3.core.Single.subscribe(Single.java:4813)
	at io.reactivex.rxjava3.internal.operators.single.SingleMap.subscribeActual(SingleMap.java:35)
	at io.reactivex.rxjava3.core.Single.subscribe(Single.java:4813)
	at io.reactivex.rxjava3.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run(SingleSubscribeOn.java:89)
	at io.reactivex.rxjava3.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:41)
	at io.reactivex.rxjava3.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:28)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
	at java.lang.Thread.run(Thread.java:929)


@TobiGr
Copy link
Member

TobiGr commented Jan 11, 2021

There is no onError() method implemented in the subscripe method:

disposables.add(Single.just(description.getContent())
.map(descriptionText ->
LinkHelper.createLinksFromHtmlBlock(requireContext(),
descriptionText, videoDescriptionView,
HtmlCompat.FROM_HTML_MODE_LEGACY))
.subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(spanned -> {
videoDescriptionView.setText(spanned);
videoDescriptionView.setVisibility(View.VISIBLE);
}));

@AudricV
Copy link
Member Author

AudricV commented Jan 13, 2021

@TobiGr I removed the use of disposables when preparing HTML descriptions in prepareDescription method of the VideoDetail fragment. I tried to open a YouTube video when debugging the app in Chrome Developer Tools and it opens fine with the description which is successfully shown. Is it ok to remove this use ?

@B0pol B0pol removed their assignment Jan 13, 2021
Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

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

The LinkHelper is a good idea. Thank you!

@AudricV
Copy link
Member Author

AudricV commented Jan 15, 2021

@Stypox Changes requested applied. Please don't merge this now, I want to implement #3253 in this PR after I know how to handle a long click on description and comment links (can someone help me for that?).

@AudricV AudricV requested a review from Stypox January 15, 2021 16:19
@Stypox
Copy link
Member

Stypox commented Jan 15, 2021

@TiA4f8R The changes you pushed are looking good, thanks ;-)

Change text selection "Share" action to use ShareUtils.shareUrl

Since all other apps don't do this, I wouldn't do it here either. Or at least not in this PR, but in a future one.

For links in video description and meta info, I don't know how to do this (it seems that links are generated with an Android library). I need help from a member of NewPipe's team to change the behavior beacuse I am not a developer.

Take a look here, and in particular the last few lines:

/**
* Formats the text contained in the meta info list as HTML and puts it into the text view,
* while also making the separator visible. If the list is null or empty, or the user chose not
* to see meta information, both the text view and the separator are hidden
* @param metaInfos a list of meta information, can be null or empty
* @param metaInfoTextView the text view in which to show the formatted HTML
* @param metaInfoSeparator another view to be shown or hidden accordingly to the text view
*/
public static void showMetaInfoInTextView(@Nullable final List<MetaInfo> metaInfos,
final TextView metaInfoTextView,
final View metaInfoSeparator) {
final Context context = metaInfoTextView.getContext();
final boolean showMetaInfo = PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(context.getString(R.string.show_meta_info_key), true);
if (!showMetaInfo || metaInfos == null || metaInfos.isEmpty()) {
metaInfoTextView.setVisibility(View.GONE);
metaInfoSeparator.setVisibility(View.GONE);
} else {
final StringBuilder stringBuilder = new StringBuilder();
for (final MetaInfo metaInfo : metaInfos) {
if (!isNullOrEmpty(metaInfo.getTitle())) {
stringBuilder.append("<b>").append(metaInfo.getTitle()).append("</b>")
.append(Localization.DOT_SEPARATOR);
}
String content = metaInfo.getContent().getContent().trim();
if (content.endsWith(".")) {
content = content.substring(0, content.length() - 1); // remove . at end
}
stringBuilder.append(content);
for (int i = 0; i < metaInfo.getUrls().size(); i++) {
if (i == 0) {
stringBuilder.append(Localization.DOT_SEPARATOR);
} else {
stringBuilder.append("<br/><br/>");
}
stringBuilder
.append("<a href=\"").append(metaInfo.getUrls().get(i)).append("\">")
.append(capitalizeIfAllUppercase(metaInfo.getUrlTexts().get(i).trim()))
.append("</a>");
}
}
metaInfoTextView.setText(HtmlCompat.fromHtml(stringBuilder.toString(),
HtmlCompat.FROM_HTML_SEPARATOR_LINE_BREAK_HEADING));
metaInfoTextView.setMovementMethod(LinkMovementMethod.getInstance());
metaInfoTextView.setVisibility(View.VISIBLE);
metaInfoSeparator.setVisibility(View.VISIBLE);
}
}

Is it ok to remove this use ?

For big HTMLs it can take a while to build the Spannables, so doing that on the main thread is a bad idea.

I want to implement #3253 in this PR after I know how to handle a long click on description and comment links (can someone help me for that?).

I don't know how this could be achieved, but maybe you can loop through all Spannables and set a long click listener on the link ones?

@AudricV
Copy link
Member Author

AudricV commented Jan 15, 2021

For links in video description and meta info, I don't know how to do this (it seems that links are generated with an Android library). I need help from a member of NewPipe's team to change the behavior beacuse I am not a developer.

Take a look here, and in particular the last few lines:

/**
* Formats the text contained in the meta info list as HTML and puts it into the text view,
* while also making the separator visible. If the list is null or empty, or the user chose not
* to see meta information, both the text view and the separator are hidden
* @param metaInfos a list of meta information, can be null or empty
* @param metaInfoTextView the text view in which to show the formatted HTML
* @param metaInfoSeparator another view to be shown or hidden accordingly to the text view
*/
public static void showMetaInfoInTextView(@Nullable final List<MetaInfo> metaInfos,
final TextView metaInfoTextView,
final View metaInfoSeparator) {
final Context context = metaInfoTextView.getContext();
final boolean showMetaInfo = PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(context.getString(R.string.show_meta_info_key), true);
if (!showMetaInfo || metaInfos == null || metaInfos.isEmpty()) {
metaInfoTextView.setVisibility(View.GONE);
metaInfoSeparator.setVisibility(View.GONE);
} else {
final StringBuilder stringBuilder = new StringBuilder();
for (final MetaInfo metaInfo : metaInfos) {
if (!isNullOrEmpty(metaInfo.getTitle())) {
stringBuilder.append("<b>").append(metaInfo.getTitle()).append("</b>")
.append(Localization.DOT_SEPARATOR);
}
String content = metaInfo.getContent().getContent().trim();
if (content.endsWith(".")) {
content = content.substring(0, content.length() - 1); // remove . at end
}
stringBuilder.append(content);
for (int i = 0; i < metaInfo.getUrls().size(); i++) {
if (i == 0) {
stringBuilder.append(Localization.DOT_SEPARATOR);
} else {
stringBuilder.append("<br/><br/>");
}
stringBuilder
.append("<a href=\"").append(metaInfo.getUrls().get(i)).append("\">")
.append(capitalizeIfAllUppercase(metaInfo.getUrlTexts().get(i).trim()))
.append("</a>");
}
}
metaInfoTextView.setText(HtmlCompat.fromHtml(stringBuilder.toString(),
HtmlCompat.FROM_HTML_SEPARATOR_LINE_BREAK_HEADING));
metaInfoTextView.setMovementMethod(LinkMovementMethod.getInstance());
metaInfoTextView.setVisibility(View.VISIBLE);
metaInfoSeparator.setVisibility(View.VISIBLE);
}
}

I already do this in my first commit :)

@AudricV
Copy link
Member Author

AudricV commented Jan 15, 2021

@Stypox Unformatly, I haven't a big amount of time for the moment and programming knowledges to do something on #3253. So I will not do anything on it :(.

@Stypox
Copy link
Member

Stypox commented Jan 15, 2021

I already do this in my first commit :)

Oh, yeah, sorry ;-)

So I will not do anything on it

That's ok, don't worry, this PR solves many issues just by itself and a new one can still be opened by you or someone else in the future :-)


Could you bring back the use of reactivex disposables, so that the Spannables building process is not done on the main thread? If you need any help feel free to ask, and if you have no time I can do that myself. Thank you :-D

@AudricV
Copy link
Member Author

AudricV commented Jan 15, 2021

@Stypox Can you do it please (note that it was only for HTML descriptions, may be it should be extended to other description types?) and also fix if you can #5187 (comment)? This crash is so annoying... Thank you in advance!

(And also thanks for your review :) )

@Stypox
Copy link
Member

Stypox commented Jan 15, 2021

@TiA4f8R done, what do you think about my changes?

@AudricV
Copy link
Member Author

AudricV commented Jan 15, 2021

@Stypox Looks good (I am not developer and I don't really know Java so you should ask to a real developer :)). Did you test your changes by trying to open a video / a track while debugging the app with Steho on your computer and see if description is showing successfully or if there is a crash?

@Stypox
Copy link
Member

Stypox commented Jan 15, 2021

I am not developer and I don't really know Java

Let me tell you that you did a very good job given that you don't know Java ;-)

debugging the app with Steho

Why should I do that? I have never debugged anything in Stetho, though I have tested that the app works. Anyway, debugging instead of executing normally shouldn't change anything.

@AudricV
Copy link
Member Author

AudricV commented Jan 15, 2021

@Stypox Oh sorry, I talk about Chrome Developer Tools (chrome://inspect#devices) when selecting NewPipe, to inspect network traffic (it's written Powered by Stetho after the app name).

@AudricV
Copy link
Member Author

AudricV commented Jan 16, 2021

@Stypox I just tested while debugging in Chrome Developer Tools and it works, no crash and descriptions are showing! Thanks for your commit!

I have a question about the new app version update notification: currently, NewPipe uses an ACTION_VIEW intent in the notification which launches the Huawei Chooser on EMUI devices if there isn't a default browser. If I use an ACTION_CHOOSER intent and put the ACTION_VIEW intent as an extra intent and if there is a default browser, does the system will open the Android system chooser or it will open the default browser? Thanks in advance for your response.

@Stypox
Copy link
Member

Stypox commented Jan 16, 2021

Thank you for testing. From what I understand from here and here, it should open the Android system chooser.

AudricV and others added 3 commits January 16, 2021 13:23
Improve NewPipe's share on some devices + fix crash when no browser is set on some devices

Catching ActivityNotFoundException when trying to open the default browser
Use an ACTION_CHOOSER intent and put as an extra intent the intent to
open an URI / share an URI when no default app is set.

Add a LinkHelper class which set a custom action when clicking web links
in the description of a content. This class also helps to implement a confirmation dialog when trying to open web links in an external app.
Apply the requested changes, use ShareUtils.shareText to share an stream in the play queue and optimize imports for Java files, using Android Studio functionality.

Apply the requested changes and do little improvements
Apply the requested changes, use ShareUtils.shareText to share an stream in the play queue and optimize imports for Java files, using Android Studio functionality.
Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

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

I rebased and tested more, both on Android 4.4, Android 10 and Android 11. Everything works as expected. Thank you!

@Stypox Stypox merged commit 8c9f2af into TeamNewPipe:dev Jan 16, 2021
@TobiGr
Copy link
Member

TobiGr commented Jan 16, 2021

I get this on Android TV API 27 when trying to open in browser (there is no browser)

Exception

  • User Action: ui error
  • Request: App crash, UI failure
  • Content Country: US
  • Content Language: en-US
  • App Language: en_US
  • Service: none
  • Version: 0.20.8
  • OS: Linux Android 8.1.0 - 27
Crash log

java.lang.NullPointerException: Attempt to read from field 'android.content.pm.ActivityInfo android.content.pm.ResolveInfo.activityInfo' on a null object reference
	at org.schabi.newpipe.util.ShareUtils.getDefaultBrowserPackageName(ShareUtils.java:168)
	at org.schabi.newpipe.util.ShareUtils.openUrlInBrowser(ShareUtils.java:58)
	at org.schabi.newpipe.util.ShareUtils.openUrlInBrowser(ShareUtils.java:91)
	at org.schabi.newpipe.player.Player.onOpenInBrowserClicked(Player.java:3575)
	at org.schabi.newpipe.player.Player.onClick(Player.java:3430)
	at android.view.View.performClick(View.java:6294)
	at android.view.View$PerformClick.run(View.java:24770)
	at android.os.Handler.handleCallback(Handler.java:790)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loop(Looper.java:164)
	at android.app.ActivityThread.main(ActivityThread.java:6494)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)


@opusforlife2 opusforlife2 changed the title Share improvements + fix crash when no default browser is set on some devices Fix crash when no default browser is set on some devices and improve share dialogs Jan 16, 2021
@AudricV AudricV changed the title Fix crash when no default browser is set on some devices and improve share dialogs Fix crash when no default browser is set and improve share dialogs (on some devices) Jan 16, 2021
This was referenced Jan 18, 2021
tossj pushed a commit to tossj/NewPipe-legacy that referenced this pull request Apr 20, 2021
…ements

Share improvements + fix crash when no default browser is set on some devices
@AudricV AudricV mentioned this pull request Mar 18, 2022
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is related to a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error while opening content in browser
6 participants