diff --git a/app/build.gradle b/app/build.gradle index 87215b38523..5a8689f70e7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -175,7 +175,7 @@ dependencies { // NewPipe dependencies // You can use a local version by uncommenting a few lines in settings.gradle - implementation 'com.github.TeamNewPipe:NewPipeExtractor:b3835bd616ab28b861c83dcefd56e1754c6d20be' + implementation 'com.github.TeamNewPipe:NewPipeExtractor:85fa006214b003f21eacb76c445a167732f19981' implementation "com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751" implementation "org.jsoup:jsoup:1.13.1" diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java index d1a964fb2b5..6fa7eb700b9 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java @@ -11,12 +11,12 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; -import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.content.res.AppCompatResources; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; @@ -26,8 +26,10 @@ import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.ListExtractor; import org.schabi.newpipe.extractor.NewPipe; +import org.schabi.newpipe.extractor.ServiceList; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.playlist.PlaylistInfo; +import org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper; import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.stream.StreamType; import org.schabi.newpipe.fragments.list.BaseListInfoFragment; @@ -44,13 +46,13 @@ import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.ShareUtils; import org.schabi.newpipe.util.StreamDialogEntry; -import org.schabi.newpipe.util.ThemeHelper; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; +import de.hdodenhof.circleimageview.CircleImageView; import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; import io.reactivex.rxjava3.core.Flowable; import io.reactivex.rxjava3.core.Single; @@ -58,6 +60,7 @@ import io.reactivex.rxjava3.disposables.Disposable; import static org.schabi.newpipe.util.AnimationUtils.animateView; +import static org.schabi.newpipe.util.ThemeHelper.resolveResourceIdFromAttr; public class PlaylistFragment extends BaseListInfoFragment { private CompositeDisposable disposables; @@ -74,7 +77,7 @@ public class PlaylistFragment extends BaseListInfoFragment { private TextView headerTitleView; private View headerUploaderLayout; private TextView headerUploaderName; - private ImageView headerUploaderAvatar; + private CircleImageView headerUploaderAvatar; private TextView headerStreamCount; private View playlistCtrl; @@ -301,8 +304,22 @@ public void handleResult(@NonNull final PlaylistInfo result) { playlistCtrl.setVisibility(View.VISIBLE); - IMAGE_LOADER.displayImage(result.getUploaderAvatarUrl(), headerUploaderAvatar, - ImageDisplayConstants.DISPLAY_AVATAR_OPTIONS); + final String avatarUrl = result.getUploaderAvatarUrl(); + if (result.getServiceId() == ServiceList.YouTube.getServiceId() + && (YoutubeParsingHelper.isYoutubeMixId(result.getId()) + || YoutubeParsingHelper.isYoutubeMusicMixId(result.getId()))) { + // this is an auto-generated playlist (e.g. Youtube mix), so a radio is shown + headerUploaderAvatar.setDisableCircularTransformation(true); + headerUploaderAvatar.setBorderColor( + getResources().getColor(R.color.transparent_background_color)); + headerUploaderAvatar.setImageDrawable(AppCompatResources.getDrawable(requireContext(), + resolveResourceIdFromAttr(requireContext(), R.attr.ic_radio))); + + } else { + IMAGE_LOADER.displayImage(avatarUrl, headerUploaderAvatar, + ImageDisplayConstants.DISPLAY_AVATAR_OPTIONS); + } + headerStreamCount.setText(Localization .localizeStreamCount(getContext(), result.getStreamCount())); @@ -476,7 +493,7 @@ private void updateBookmarkButtons() { final int titleRes = playlistEntity == null ? R.string.bookmark_playlist : R.string.unbookmark_playlist; - playlistBookmarkButton.setIcon(ThemeHelper.resolveResourceIdFromAttr(activity, iconAttr)); + playlistBookmarkButton.setIcon(resolveResourceIdFromAttr(activity, iconAttr)); playlistBookmarkButton.setTitle(titleRes); } } diff --git a/app/src/test/java/org/schabi/newpipe/ktx/OffsetDateTimeToCalendarTest.kt b/app/src/test/java/org/schabi/newpipe/ktx/OffsetDateTimeToCalendarTest.kt index c93d36eb597..74da0799883 100644 --- a/app/src/test/java/org/schabi/newpipe/ktx/OffsetDateTimeToCalendarTest.kt +++ b/app/src/test/java/org/schabi/newpipe/ktx/OffsetDateTimeToCalendarTest.kt @@ -4,7 +4,6 @@ import org.junit.Assert.assertEquals import org.junit.Test import java.time.LocalDate import java.time.OffsetDateTime -import java.time.ZoneId import java.time.ZoneOffset import java.util.Calendar import java.util.TimeZone @@ -13,7 +12,7 @@ class OffsetDateTimeToCalendarTest { @Test fun testRelativeTimeWithCurrentOffsetDateTime() { val calendar = LocalDate.of(2020, 1, 1).atStartOfDay().atOffset(ZoneOffset.UTC) - .toCalendar() + .toCalendar() assertEquals(2020, calendar[Calendar.YEAR]) assertEquals(0, calendar[Calendar.MONTH])