Skip to content

Commit

Permalink
Merge pull request #3826 from Stypox/unsupported-url-dialog
Browse files Browse the repository at this point in the history
Show dialog with open options in case of an unsupported url
  • Loading branch information
B0pol authored Sep 12, 2020
2 parents 11d9a03 + eeba9c0 commit 4b7311b
Show file tree
Hide file tree
Showing 61 changed files with 87 additions and 74 deletions.
40 changes: 26 additions & 14 deletions app/src/main/java/org/schabi/newpipe/RouterActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.schabi.newpipe.util.ListHelper;
import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.PermissionHelper;
import org.schabi.newpipe.util.ShareUtils;
import org.schabi.newpipe.util.ThemeHelper;
import org.schabi.newpipe.util.urlfinder.UrlFinder;
import org.schabi.newpipe.views.FocusOverlayView;
Expand Down Expand Up @@ -159,27 +160,36 @@ private void handleUrl(final String url) {
if (result) {
onSuccess();
} else {
onError();
showUnsupportedUrlDialog(url);
}
}, this::handleError));
}, throwable -> handleError(throwable, url)));
}

private void handleError(final Throwable error) {
error.printStackTrace();
private void handleError(final Throwable throwable, final String url) {
throwable.printStackTrace();

if (error instanceof ExtractionException) {
Toast.makeText(this, R.string.url_not_supported_toast, Toast.LENGTH_LONG).show();
if (throwable instanceof ExtractionException) {
showUnsupportedUrlDialog(url);
} else {
ExtractorHelper.handleGeneralException(this, -1, null, error,
ExtractorHelper.handleGeneralException(this, -1, url, throwable,
UserAction.SOMETHING_ELSE, null);
finish();
}

finish();
}

private void onError() {
Toast.makeText(this, R.string.url_not_supported_toast, Toast.LENGTH_LONG).show();
finish();
private void showUnsupportedUrlDialog(final String url) {
final Context context = getThemeWrapperContext();
new AlertDialog.Builder(context)
.setTitle(R.string.unsupported_url)
.setMessage(R.string.unsupported_url_dialog_message)
.setIcon(ThemeHelper.resolveResourceIdFromAttr(context, R.attr.ic_share))
.setPositiveButton(R.string.open_in_browser,
(dialog, which) -> ShareUtils.openUrlInBrowser(this, url))
.setNegativeButton(R.string.share,
(dialog, which) -> ShareUtils.shareUrl(this, "", url)) // no subject
.setNeutralButton(R.string.cancel, null)
.setOnDismissListener(dialog -> finish())
.show();
}

protected void onSuccess() {
Expand Down Expand Up @@ -459,7 +469,7 @@ private void handleChoice(final String selectedChoiceKey) {
startActivity(intent);

finish();
}, this::handleError)
}, throwable -> handleError(throwable, currentUrl))
);
return;
}
Expand Down Expand Up @@ -493,7 +503,9 @@ private void openDownloadDialog() {
downloadDialog.show(fm, "downloadDialog");
fm.executePendingTransactions();
downloadDialog.getDialog().setOnDismissListener(dialog -> finish());
}, (@NonNull Throwable throwable) -> onError());
}, (@NonNull Throwable throwable) -> {
showUnsupportedUrlDialog(currentUrl);
});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ private void search(final String ss, final String[] cf, final String sf) {
getFM().popBackStackImmediate();
activity.startActivity(intent);
}, throwable ->
showError(getString(R.string.url_not_supported_toast), false)));
showError(getString(R.string.unsupported_url), false)));
return;
}
} catch (final Exception ignored) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<string name="show_play_with_kodi_title">عرض خيار التشغيل بواسطة كودي</string>
<string name="theme_title">السمة</string>
<string name="upload_date_text">تم النشر بتاريخ %1$s</string>
<string name="url_not_supported_toast">رابط URL غير معتمد</string>
<string name="unsupported_url">رابط URL غير معتمد</string>
<string name="use_external_audio_player_title">استخدام مشغل صوت خارجي</string>
<string name="use_external_video_player_title">استخدام مشغل فيديو خارجي</string>
<string name="use_tor_summary">(إختبارية) إجراء التنزيلات من خلال استخدام بروكسي Tor لزيادة الخصوصية ( تشغيل الفيديو المباشر غير مدعوم حتى الأن ).</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-b+ast/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@
<string name="playback_tempo">Tempu</string>
<string name="playback_pitch">Tonu</string>
<string name="decline">Refugar</string>
<string name="url_not_supported_toast">La URL nun se sofita</string>
<string name="unsupported_url">La URL nun se sofita</string>
<string name="background_player_playing_toast">Reproduciendo en segundu planu</string>
<string name="popup_playing_toast">Reproduciendo nel mou ventanu</string>
<string name="enable_search_history_summary">Atroxa llocalmente les consultes de gueta</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-b+zh+HANS+CN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<string name="black_theme_title">黑色</string>
<string name="download_dialog_title">下载</string>
<string name="next_video_title">下一个</string>
<string name="url_not_supported_toast">不支持的 URL</string>
<string name="unsupported_url">不支持的 URL</string>
<string name="settings_category_appearance_title">外观</string>
<string name="settings_category_other_title">其他</string>
<string name="all">全部</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-be/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<string name="show_next_and_similar_title">\"Наступнае\" и \"Прапанаванае\" відэа</string>
<string name="show_hold_to_append_title">\"Зацісніце, каб дадаць\"</string>
<string name="show_hold_to_append_summary">Паказаць падказку пры націсканні \"У акне\" ці \"У фоне\" на старонцы звестак аб відэа</string>
<string name="url_not_supported_toast">URL не падтрымліваецца</string>
<string name="unsupported_url">URL не падтрымліваецца</string>
<string name="default_content_country_title">Краіна кантэнту па змаўчанні</string>
<string name="service_title">Сэрвіс</string>
<string name="content_language_title">Мова кантэнту па змаўчанні</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-bg/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<string name="next_video_title">Следващ клип</string>
<string name="show_next_and_similar_title">Показвай „следващ“ и „подобни“</string>
<string name="show_hold_to_append_title">Показвай съвет „задръж за добавяне“</string>
<string name="url_not_supported_toast">Непознат URL</string>
<string name="unsupported_url">Непознат URL</string>
<string name="content_language_title">Език на съдържанието по подразбиране</string>
<string name="settings_category_player_title">Плейър</string>
<string name="settings_category_player_behavior_title">Поведение</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-bn-rBD/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<string name="download_dialog_title">ডাউনলোড</string>
<string name="next_video_title">পরবর্তী ভিডিও</string>
<string name="show_next_and_similar_title">পরবর্তী এবং অনুরূপ ভিডিওগুলি দেখাও</string>
<string name="url_not_supported_toast">URL সমর্থিত নয়</string>
<string name="unsupported_url">URL সমর্থিত নয়</string>
<string name="content_language_title">কন্টেন্ট এর জন্য পছন্দসই ভাষা</string>
<string name="settings_category_video_audio_title">ভিডিও এবং অডিও</string>
<string name="settings_category_popup_title">পপআপ</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-ca/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@
<string name="enable_search_history_summary">Emmagatzema les cerques localment</string>
<string name="enable_watch_history_summary">Crea un historial de vídeos visualitzats</string>
<string name="resume_on_audio_focus_gain_title">Reprèn automàticament</string>
<string name="url_not_supported_toast">Aquest URL no és compatible</string>
<string name="unsupported_url">Aquest URL no és compatible</string>
<string name="error_report_title">Informe d\'error</string>
<string name="later">Més tard</string>
<string name="filter">Filtra</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<string name="download_dialog_title">Stáhnout</string>
<string name="next_video_title">Další</string>
<string name="show_next_and_similar_title">Zobrazovat \'další\' a \'podobná\' videa</string>
<string name="url_not_supported_toast">URL není podporováno</string>
<string name="unsupported_url">URL není podporováno</string>
<string name="content_language_title">Preferovaný jazyk obsahu</string>
<string name="settings_category_video_audio_title">Video a zvuk</string>
<string name="settings_category_appearance_title">Vzhled</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-da/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<string name="show_next_and_similar_title">Vis \'Næste\' og \'Lignende\' videoer</string>
<string name="show_hold_to_append_title">Vis \"Hold for at tilføje\"-tip</string>
<string name="show_hold_to_append_summary">Vis et tip når der trykkes på baggrunds- eller pop op-knappen på siden med videodetaljer</string>
<string name="url_not_supported_toast">Denne webadresse er ikke understøttet</string>
<string name="unsupported_url">Denne webadresse er ikke understøttet</string>
<string name="default_content_country_title">Standardland for indhold</string>
<string name="service_title">Tjeneste</string>
<string name="content_language_title">Standardsprog for indhold</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<string name="download_dialog_title">Herunterladen</string>
<string name="next_video_title">Nächste</string>
<string name="show_next_and_similar_title">„Nächste“ und „Ähnliche“ Videos anzeigen</string>
<string name="url_not_supported_toast">Nicht unterstützte URL</string>
<string name="unsupported_url">Nicht unterstützte URL</string>
<string name="settings_category_video_audio_title">Video &amp; Audio</string>
<string name="content_language_title">Bevorzugte Sprache des Inhalts</string>
<string name="list_thumbnail_view_description">Video-Vorschaubild</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<string name="download_dialog_title">Λήψη</string>
<string name="next_video_title">Επόμενο</string>
<string name="show_next_and_similar_title">Εμφάνιση \"Επόμενου\" και \"Σχετικών\" βίντεο</string>
<string name="url_not_supported_toast">Δεν υποστηρίζεται η διεύθυνση URL</string>
<string name="unsupported_url">Δεν υποστηρίζεται η διεύθυνση URL</string>
<string name="content_language_title">Προεπιλεγμένη γλώσσα περιεχομένου</string>
<string name="settings_category_video_audio_title">Βίντεο &amp; Ήχος</string>
<string name="settings_category_appearance_title">Εμφάνιση</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-eo/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<string name="light_theme_title">Luma</string>
<string name="download_dialog_title">Elŝuti</string>
<string name="next_video_title">Vica filmeto</string>
<string name="url_not_supported_toast">Ligilo ne subtenita</string>
<string name="unsupported_url">Ligilo ne subtenita</string>
<string name="content_language_title">Preferata enhavlingvo</string>
<string name="settings_category_video_audio_title">Filmeto kaj sono</string>
<string name="settings_category_appearance_title">Apero</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<string name="default_audio_format_title">Formato de audio predeterminado</string>
<string name="download_dialog_title">Descargar</string>
<string name="next_video_title">Siguiente</string>
<string name="url_not_supported_toast">No se admite el URL</string>
<string name="unsupported_url">No se admite el URL</string>
<string name="use_external_video_player_title">Usar reproductor de vídeo externo</string>
<string name="use_external_audio_player_title">Usar reproductor de audio externo</string>
<string name="theme_title">Tema</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-et/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<string name="show_next_and_similar_title">Kuva \'järgmine\' ja \'sarnased\' videod</string>
<string name="show_hold_to_append_title">Kuva vihjet \"lisamiseks hoia\"</string>
<string name="show_hold_to_append_summary">Kuva vihje, kui videoandmete lehel vajutatakse tausta või hüpikakna nupule</string>
<string name="url_not_supported_toast">Mitte toetatud URL</string>
<string name="unsupported_url">Mitte toetatud URL</string>
<string name="default_content_country_title">Sisu vaikimisi riik</string>
<string name="service_title">Teenus</string>
<string name="content_language_title">Sisu vaikimisi keel</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-eu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<string name="download_dialog_title">Deskargatu</string>
<string name="next_video_title">Hurrengoa</string>
<string name="show_next_and_similar_title">Erakutsi \'hurrengo\' eta \'antzeko\' bideoak</string>
<string name="url_not_supported_toast">URLak ez du euskarririk</string>
<string name="unsupported_url">URLak ez du euskarririk</string>
<string name="content_language_title">Edukiaren hizkuntz lehenetsia</string>
<string name="settings_category_video_audio_title">Bideoa eta Audioa</string>
<string name="play_btn_text">Erreproduzitu</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-fa/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<string name="download_dialog_title">بارگیری</string>
<string name="next_video_title">بعدی</string>
<string name="show_next_and_similar_title">نماش ویدیوهای «بعدی» و «مشابه»</string>
<string name="url_not_supported_toast">نشانی پشتیبانی نشده</string>
<string name="unsupported_url">نشانی پشتیبانی نشده</string>
<string name="content_language_title">زبان محتوای ترجیحی</string>
<string name="settings_category_video_audio_title">ویدیو و صدا</string>
<string name="settings_category_appearance_title">ظاهر</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-fi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<string name="download_dialog_title">Lataus</string>
<string name="next_video_title">Seuraava</string>
<string name="show_next_and_similar_title">Näytä seuraavia ja samankaltaisia videoita</string>
<string name="url_not_supported_toast">URL ei tuettu</string>
<string name="unsupported_url">URL ei tuettu</string>
<string name="content_language_title">Oletus-sisällon kieli</string>
<string name="settings_category_player_title">Soitin</string>
<string name="settings_category_player_behavior_title">Käyttäytyminen</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<string name="download_dialog_title">Télécharger</string>
<string name="next_video_title">Suivant</string>
<string name="show_next_and_similar_title">Afficher les vidéos « Suivantes » et « Similaires »</string>
<string name="url_not_supported_toast">URL non pris en charge</string>
<string name="unsupported_url">URL non pris en charge</string>
<string name="settings_category_video_audio_title">Vidéo et audio</string>
<string name="settings_category_other_title">Autre</string>
<string name="list_thumbnail_view_description">Miniature d’aperçu vidéo</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-gl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
<string name="show_next_and_similar_title">Mostrar vídeos «seguintes» e «semellantes»</string>
<string name="show_hold_to_append_title">Mostrar a suxestión «Manteña presionado para engadir á cola»</string>
<string name="show_hold_to_append_summary">Mostrar unha suxestión ao premer o botón de segundo plano ou o de popup na páxina de detalles do vídeo</string>
<string name="url_not_supported_toast">Este URL non está soportado</string>
<string name="unsupported_url">Este URL non está soportado</string>
<string name="default_content_country_title">País predeterminado para o contido</string>
<string name="service_title">Servizo</string>
<string name="settings_category_player_title">Reprodutor</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-he/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<string name="download_dialog_title">הורדה</string>
<string name="next_video_title">הבא</string>
<string name="show_next_and_similar_title">להציג סרטונים דומים ובאים בתור</string>
<string name="url_not_supported_toast">כתובת לא נתמכת</string>
<string name="unsupported_url">כתובת לא נתמכת</string>
<string name="content_language_title">שפת התוכן המועדפת</string>
<string name="settings_category_video_audio_title">סרטונים ושמע</string>
<string name="settings_category_popup_title">חלון צף</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-hi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<string name="show_next_and_similar_title">\'अगला\' और \'पहले समान\' वीडियो दिखाए</string>
<string name="show_hold_to_append_title">\"जोड़ने के लिए पकड़ें रहे\" दिखाए</string>
<string name="show_hold_to_append_summary">जब बैकग्राउंड और पॉपअप बटन विडियो के विवरण पन्ने में दबाई जाए तो tip को दिखाए</string>
<string name="url_not_supported_toast">ये वाला URL इसमें नहीं चलेगा</string>
<string name="unsupported_url">ये वाला URL इसमें नहीं चलेगा</string>
<string name="content_language_title">डिफ़ॉल्ट विषय की भाषा</string>
<string name="settings_category_player_title">प्लेयर</string>
<string name="settings_category_player_behavior_title">चाल चलन</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-hr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<string name="download_dialog_title">Preuzmi</string>
<string name="next_video_title">Sljedeće</string>
<string name="show_next_and_similar_title">Prikaži \'Sljedeće\' i \'Slične\' videozapise</string>
<string name="url_not_supported_toast">URL nije podržan</string>
<string name="unsupported_url">URL nije podržan</string>
<string name="content_language_title">Zadani jezik sadržaja</string>
<string name="settings_category_video_audio_title">Video i zvuk</string>
<string name="settings_category_popup_title">Skočni prozor</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-hu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<string name="default_audio_format_title">Alapértelmezett hang formátum</string>
<string name="download_dialog_title">Letöltés</string>
<string name="next_video_title">Következő</string>
<string name="url_not_supported_toast">Nem támogatott webcím</string>
<string name="unsupported_url">Nem támogatott webcím</string>
<string name="use_external_video_player_title">Külső videólejátszó használata</string>
<string name="use_external_audio_player_title">Külső hanglejátszó használata</string>
<string name="download_path_audio_dialog_title">Válaszd ki a hangfájlok letöltési helyét</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-ia/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<string name="next_video_title">Sequente</string>
<string name="autoplay_title">Reproduction automatic</string>
<string name="show_next_and_similar_title">Monstrar le videos sequente e simile</string>
<string name="url_not_supported_toast">URL non supportate</string>
<string name="unsupported_url">URL non supportate</string>
<string name="default_content_country_title">Pais predefinite del contentos</string>
<string name="service_title">Servicio</string>
<string name="content_language_title">Lingua predefinite del contento</string>
Expand Down
Loading

0 comments on commit 4b7311b

Please sign in to comment.