Skip to content

Commit

Permalink
Display all thumbnails in description tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Stypox committed May 2, 2023
1 parent 0d92c37 commit ae7f369
Show file tree
Hide file tree
Showing 56 changed files with 86 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
import static org.schabi.newpipe.util.Localization.getAppLocale;
import static org.schabi.newpipe.util.text.TextLinkifier.SET_LINK_MOVEMENT_METHOD;

import android.graphics.Typeface;
import android.os.Bundle;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.text.style.StyleSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -25,14 +31,17 @@
import org.schabi.newpipe.databinding.FragmentDescriptionBinding;
import org.schabi.newpipe.databinding.ItemMetadataBinding;
import org.schabi.newpipe.databinding.ItemMetadataTagsBinding;
import org.schabi.newpipe.extractor.Image;
import org.schabi.newpipe.extractor.stream.Description;
import org.schabi.newpipe.extractor.stream.StreamInfo;
import org.schabi.newpipe.util.Localization;
import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.image.ImageStrategy;
import org.schabi.newpipe.util.external_communication.ShareUtils;
import org.schabi.newpipe.util.image.ImageStrategy;
import org.schabi.newpipe.util.text.TextLinkifier;

import java.util.List;

import icepick.State;
import io.reactivex.rxjava3.disposables.CompositeDisposable;

Expand Down Expand Up @@ -152,8 +161,12 @@ private void setupMetadata(final LayoutInflater inflater,
streamInfo.getSupportInfo());
addMetadataItem(inflater, layout, true, R.string.metadata_host,
streamInfo.getHost());
addMetadataItem(inflater, layout, true, R.string.metadata_thumbnail_url,
ImageStrategy.choosePreferredImage(streamInfo.getThumbnails()));
addImagesMetadataItem(inflater, layout, R.string.metadata_thumbnails,
streamInfo.getThumbnails());
addImagesMetadataItem(inflater, layout, R.string.metadata_uploader_avatars,
streamInfo.getUploaderAvatars());
addImagesMetadataItem(inflater, layout, R.string.metadata_subchannel_avatars,
streamInfo.getSubChannelAvatars());

addTagsMetadataItem(inflater, layout);
}
Expand Down Expand Up @@ -188,6 +201,73 @@ private void addMetadataItem(final LayoutInflater inflater,
layout.addView(itemBinding.getRoot());
}

private String imageSizeToText(final int heightOrWidth) {
if (heightOrWidth < 0) {
return "?";
} else {
return String.valueOf(heightOrWidth);
}
}

private void addImagesMetadataItem(final LayoutInflater inflater,
final LinearLayout layout,
@StringRes final int type,
final List<Image> images) {
final String preferredImageUrl = ImageStrategy.choosePreferredImage(images);
if (preferredImageUrl == null) {
return; // null will be returned in case there is no image
}

final ItemMetadataBinding itemBinding =
ItemMetadataBinding.inflate(inflater, layout, false);
itemBinding.metadataTypeView.setText(type);

final SpannableStringBuilder urls = new SpannableStringBuilder();
for (final Image image : images) {
if (urls.length() != 0) {
urls.append(", ");
}
final int entryBegin = urls.length();

if (image.getHeight() != Image.HEIGHT_UNKNOWN
|| image.getWidth() != Image.WIDTH_UNKNOWN
// if even the resolution level is unknown, ?x? will be shown
|| image.getEstimatedResolutionLevel() == Image.ResolutionLevel.UNKNOWN) {
urls.append(imageSizeToText(image.getHeight()));
urls.append('x');
urls.append(imageSizeToText(image.getWidth()));
} else {
switch (image.getEstimatedResolutionLevel()) {
case LOW:
urls.append(getString(R.string.image_quality_low));
break;
case MEDIUM:
urls.append(getString(R.string.image_quality_medium));
break;
case HIGH:
urls.append(getString(R.string.image_quality_high));
break;
}
}

urls.setSpan(new ClickableSpan() {
@Override
public void onClick(@NonNull final View widget) {
ShareUtils.openUrlInBrowser(requireContext(), image.getUrl());
}
}, entryBegin, urls.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

if (preferredImageUrl.equals(image.getUrl())) {
urls.setSpan(new StyleSpan(Typeface.BOLD), entryBegin, urls.length(),
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}

itemBinding.metadataContentView.setText(urls);
itemBinding.metadataContentView.setMovementMethod(LinkMovementMethod.getInstance());
layout.addView(itemBinding.getRoot());
}

private void addTagsMetadataItem(final LayoutInflater inflater, final LinearLayout layout) {
if (streamInfo.getTags() != null && !streamInfo.getTags().isEmpty()) {
final var itemBinding = ItemMetadataTagsBinding.inflate(inflater, layout, false);
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,6 @@
<string name="metadata_privacy_private">خاص</string>
<string name="metadata_privacy_unlisted">غير مدرج</string>
<string name="metadata_privacy_public">عامة</string>
<string name="metadata_thumbnail_url">رابط الصورة المصغرة</string>
<string name="metadata_host">المضيف</string>
<string name="metadata_support">الدعم</string>
<string name="metadata_language">اللغة</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-az/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,6 @@
<string name="metadata_host">Sahib</string>
<string name="metadata_privacy_unlisted">Siyahıdan kənar</string>
<string name="metadata_privacy_private">Şəxsi</string>
<string name="metadata_thumbnail_url">Miniatür URL</string>
<string name="metadata_age_limit">Yaş həddi</string>
<string name="metadata_language">Dil</string>
<string name="metadata_privacy_public">İctimai</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-be/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,6 @@
<string name="metadata_tags">Тэгі</string>
<string name="metadata_licence">Ліцэнзія</string>
<string name="metadata_host">Хост</string>
<string name="metadata_thumbnail_url">URL мініяцюры</string>
<string name="metadata_privacy_unlisted">Не ў спісе</string>
<string name="metadata_privacy_private">Прыватная</string>
<string name="enumeration_comma">,</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-bg/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@
<string name="metadata_support">Поддръжка</string>
<string name="metadata_host">Сървър</string>
<string name="metadata_privacy_public">Публичен</string>
<string name="metadata_thumbnail_url">Миниатюра линк</string>
<string name="app_language_title">Език на интерфейса</string>
<string name="mute">Спри звука</string>
<string name="post_processing">пост-обработката</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-bn/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,6 @@
<string name="feed_load_error">প্রক্রিয়াকরণ ফিডে ত্রুটি</string>
<string name="open_website_license">ওয়েবসাইট খুলুন</string>
<string name="account_terminated">অ্যাকাউন্ট ধ্বংসকৃত</string>
<string name="metadata_thumbnail_url">প্রতিচ্ছবি সংযোগ</string>
<string name="metadata_age_limit">বয়সসীমা</string>
<string name="metadata_privacy_internal">অভ্যন্তরীণ</string>
<string name="metadata_privacy_private">ব্যক্তিগত</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-ca/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,6 @@
<string name="metadata_privacy_private">Privat</string>
<string name="metadata_privacy_unlisted">Descatalogat</string>
<string name="metadata_privacy_public">Públic</string>
<string name="metadata_thumbnail_url">URL de la miniatura</string>
<string name="metadata_host">Amfitrió</string>
<string name="metadata_support">Suport</string>
<string name="metadata_language">Idioma</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-ckb/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,6 @@
<string name="metadata_privacy_private">تایبەتی</string>
<string name="metadata_privacy_unlisted">خشتەنەکراو</string>
<string name="metadata_privacy_public">گشتی</string>
<string name="metadata_thumbnail_url">بەستەری وێنۆچکە</string>
<string name="metadata_host">هۆست</string>
<string name="metadata_support">پشتگیری</string>
<string name="metadata_language">زمان</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,6 @@
<string name="metadata_privacy_private">Soukromé</string>
<string name="metadata_privacy_unlisted">Neuvedeno v seznamu</string>
<string name="metadata_privacy_public">Veřejné</string>
<string name="metadata_thumbnail_url">URL miniatury</string>
<string name="metadata_host">Server</string>
<string name="metadata_support">Podpora</string>
<string name="metadata_language">Jazyk</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-da/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,6 @@
\nAktiver systemet mappevælger (SAF), hvis du vil downloade til et eksternt SD-kort</string>
<string name="show_original_time_ago_summary">Originaltekster fra tjenester vil være synlige i stream-emner</string>
<string name="no_video_streams_available_for_external_players">Ingen videostreams er tilgængelige for eksterne afspillere</string>
<string name="metadata_thumbnail_url">URL til miniaturebillede</string>
<string name="off">Fra</string>
<string name="tablet_mode_title">Tablet-tilstand</string>
<string name="feed_toggle_hide_future_items">Skjul fremtidige elementer</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,6 @@
<string name="metadata_tags">Schlagwörter</string>
<string name="metadata_category">Kategorie</string>
<string name="metadata_privacy_unlisted">Nicht gelistet</string>
<string name="metadata_thumbnail_url">Vorschaubild-URL</string>
<string name="metadata_host">Server</string>
<string name="metadata_support">Unterstützung</string>
<string name="description_select_disable">Auswählen von Text in der Beschreibung deaktivieren</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,6 @@
<string name="metadata_privacy_private">Ιδιωτικό</string>
<string name="metadata_privacy_unlisted">Εκτός λίστας</string>
<string name="metadata_privacy_public">Δημόσιο</string>
<string name="metadata_thumbnail_url">URL εικονιδίου</string>
<string name="metadata_support">Υποστήριξη</string>
<string name="metadata_language">Γλώσσα</string>
<string name="metadata_age_limit">Όριο ηλικίας</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,6 @@
<string name="metadata_privacy_private">Privado</string>
<string name="metadata_privacy_unlisted">No listado</string>
<string name="metadata_privacy_public">Público</string>
<string name="metadata_thumbnail_url">URL de la miniatura</string>
<string name="metadata_support">Soporte</string>
<string name="metadata_language">Lenguaje</string>
<string name="metadata_age_limit">Límite de edad</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-et/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,6 @@
<string name="metadata_privacy_internal">Sisemine</string>
<string name="metadata_privacy_private">Privaatne</string>
<string name="metadata_privacy_public">Avalik</string>
<string name="metadata_thumbnail_url">Pisipildi URL</string>
<string name="metadata_support">Kasutajatugi</string>
<string name="metadata_language">Keel</string>
<string name="metadata_age_limit">Vanusepiir</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-eu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,6 @@
<string name="feed_toggle_show_played_items">Bistako elementuak erakustea</string>
<string name="feed_load_error_fast_unknown">Jario azkarrak ez du honi buruz informazio gehiagorik ematen.</string>
<string name="metadata_age_limit">Adin muga</string>
<string name="metadata_thumbnail_url">Miniaturaren URL-a</string>
<string name="metadata_privacy_internal">Barnekoa</string>
<string name="metadata_privacy_unlisted">Zerrendatu gabea</string>
<string name="metadata_host">Ostalaria</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-fa/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,6 @@
<string name="tablet_mode_title">حالت رایانک</string>
<string name="open_website_license">گشودن پایگاه وب</string>
<string name="account_terminated">حساب از بین رفت</string>
<string name="metadata_thumbnail_url">نشانی بندانگشتی</string>
<string name="metadata_age_limit">کرانهٔ عمر</string>
<string name="related_items_tab_description">موارد مرتبط</string>
<string name="show_description_title">نمایش شرح</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-fi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,6 @@
<string name="restricted_video_no_stream">Tämä video on ikärajoitettu.
\nYouTuben uusien ikärajoitusperiaatteiden mukaisesti NewPipella ei ole pääsyä videoon eikä sitä voida toistaa.</string>
<string name="night_theme_title">Yöteema</string>
<string name="metadata_thumbnail_url">Pienoiskuvakkeen osoite</string>
<string name="description_select_disable">Poista käytöstä tekstinvalinta kuvauskentän sisältä</string>
<string name="description_select_note">Voit nyt valita tekstin kuvauskentän sisältä. Huomioithan, että valintatilan aikana sivu voi vilkkua ja linkit eivät ehkä ole klikattavia.</string>
<string name="service_provides_reason">%s tuo tämän syyn:</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-fil/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@
<string name="metadata_licence">Lisensya</string>
<string name="metadata_language">Wika</string>
<string name="metadata_privacy_private">Pribado</string>
<string name="metadata_thumbnail_url">URL ng Thumbnail</string>
<string name="metadata_privacy_unlisted">Hindi nakalista</string>
<string name="off">Nakapatay</string>
<string name="new_and_hot">Bago at patok</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,6 @@
<string name="metadata_privacy_private">Privé</string>
<string name="metadata_privacy_unlisted">Non répertorié</string>
<string name="metadata_privacy_public">Public</string>
<string name="metadata_thumbnail_url">URL de la miniature</string>
<string name="metadata_host">Hôte</string>
<string name="metadata_support">Support</string>
<string name="metadata_language">Langue</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-gl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,6 @@
<string name="metadata_privacy_internal">Interno</string>
<string name="metadata_privacy_private">Privado</string>
<string name="metadata_privacy_public">Público</string>
<string name="metadata_thumbnail_url">URL da miniatura</string>
<string name="metadata_support">Apoio</string>
<string name="metadata_language">Idioma</string>
<string name="metadata_age_limit">Límite de idade</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-he/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,6 @@
<string name="metadata_privacy_private">פרטי</string>
<string name="metadata_privacy_unlisted">לא מופיע ברשימות</string>
<string name="metadata_privacy_public">ציבורי</string>
<string name="metadata_thumbnail_url">כתובת תמונה ממוזערת</string>
<string name="metadata_host">אירוח</string>
<string name="metadata_support">תמיכה</string>
<string name="metadata_language">שפה</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-hi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,6 @@
<string name="metadata_category">श्रेणी</string>
<string name="downloads_storage_ask_summary_no_saf_notice">आपसे पूछा जाएगा कि प्रत्येक डाउनलोड को कहां सहेजना है</string>
<string name="feed_toggle_show_played_items">देखे गए आइटम दिखाएं</string>
<string name="metadata_thumbnail_url">थंमनेल यूआरएल</string>
<string name="off">ऑफ़</string>
<string name="feed_update_threshold_option_always_update">हमेशा अपडेट करें</string>
<string name="description_select_disable">विवरण में पाठ का चयन अक्षम करें</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-hr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,6 @@
<string name="metadata_privacy_private">Privatno</string>
<string name="metadata_privacy_unlisted">Nenavedeno</string>
<string name="metadata_privacy_public">Javno</string>
<string name="metadata_thumbnail_url">URL sličice</string>
<string name="metadata_host">Poslužitelj</string>
<string name="metadata_support">Podrška</string>
<string name="metadata_language">Jezik</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-hu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,6 @@
<string name="metadata_licence">Licenc</string>
<string name="metadata_age_limit">Korhatár</string>
<string name="metadata_host">Kiszolgáló</string>
<string name="metadata_thumbnail_url">Bélyegkép URL</string>
<string name="metadata_privacy_public">Nyilvános</string>
<string name="metadata_privacy_unlisted">Nem listázott</string>
<string name="off">Ki</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-in/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,6 @@
<string name="metadata_privacy_private">Privasi</string>
<string name="metadata_privacy_unlisted">Tidak didaftar</string>
<string name="metadata_privacy_public">Publik</string>
<string name="metadata_thumbnail_url">Alamat URL gambar mini/thumbnail</string>
<string name="metadata_host">Host</string>
<string name="metadata_support">Dukungan</string>
<string name="metadata_language">Bahasa</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-is/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,6 @@
<string name="video_detail_by">Frá %s</string>
<string name="account_terminated">Reikningi lokað</string>
<string name="metadata_age_limit">Aldurstakmark</string>
<string name="metadata_thumbnail_url">Vefslóð smámyndar</string>
<string name="detail_pinned_comment_view_description">Fest ummæli</string>
<string name="tablet_mode_title">Spjaldtölvuhamur</string>
<string name="on">Virkt</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,6 @@
<string name="metadata_privacy_private">Privato</string>
<string name="metadata_privacy_unlisted">Non in elenco</string>
<string name="metadata_privacy_public">Pubblico</string>
<string name="metadata_thumbnail_url">URL copertina</string>
<string name="metadata_host">Host</string>
<string name="metadata_support">Supporto</string>
<string name="metadata_language">Lingua</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,6 @@
<string name="metadata_language">言語</string>
<string name="metadata_support">サポート</string>
<string name="metadata_host">ホスト</string>
<string name="metadata_thumbnail_url">サムネイルの URL</string>
<string name="open_website_license">ウェブサイトを開く</string>
<string name="downloads_storage_ask_summary_no_saf_notice">ダウンロードのたびに保存する場所を尋ねます</string>
<string name="no_dir_yet">ダウンロードフォルダーがまだ設定されていません。今すぐデフォルトのフォルダーを選択してください</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-ka/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,6 @@
<string name="metadata_age_limit">Ასაკობრივი შეზღუდვა</string>
<string name="metadata_language">Ენა</string>
<string name="metadata_host">მასპინძელი</string>
<string name="metadata_thumbnail_url">მინიატურების URL</string>
<string name="metadata_privacy_public">საჯარო</string>
<string name="metadata_privacy_unlisted">დამალული</string>
<string name="metadata_privacy_private">პირადი</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-ko/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,6 @@
<string name="detail_heart_img_view_description">창작자의 마음</string>
<string name="metadata_privacy_private">개인</string>
<string name="metadata_privacy_unlisted">비공개</string>
<string name="metadata_thumbnail_url">썸네일 URL</string>
<string name="metadata_host">호스트</string>
<string name="you_successfully_subscribed">이제 이 채널을 구독했습니다</string>
<string name="get_notified">알림 받기</string>
Expand Down
Loading

0 comments on commit ae7f369

Please sign in to comment.