Show radio instead of Youtube logo in mixes

YouTube mixes have YouTube as a creator, though YouTube's logo is not safe to use as it is a trademark (better safe than sorry)
This commit is contained in:
Stypox 2020-03-17 18:41:39 +01:00
parent 0ced9ba799
commit c2210330b6
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
3 changed files with 25 additions and 9 deletions

View File

@ -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"

View File

@ -11,12 +11,12 @@ import android.view.MenuInflater;
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.database.playlist.model.PlaylistRemoteEntity;
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.Localization;
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.CompositeDisposable;
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<PlaylistInfo> {
private CompositeDisposable disposables;
@ -74,7 +77,7 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
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 class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
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 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
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);
}
}

View File

@ -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])