Skip to content

Commit

Permalink
Show radio instead of Youtube logo in mixes
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
Stypox committed Mar 22, 2020
1 parent 9f7bc2b commit 48f17ff
Showing 1 changed file with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
Expand All @@ -14,9 +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 org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
import org.schabi.newpipe.NewPipeDatabase;
Expand All @@ -26,7 +26,6 @@
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
import org.schabi.newpipe.extractor.playlist.PlaylistInfo;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.extractor.stream.StreamType;
Expand All @@ -49,6 +48,7 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

import de.hdodenhof.circleimageview.CircleImageView;
import io.reactivex.Flowable;
import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers;
Expand All @@ -74,7 +74,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;

Expand Down Expand Up @@ -284,9 +284,21 @@ public void handleResult(@NonNull final PlaylistInfo result) {

playlistCtrl.setVisibility(View.VISIBLE);

imageLoader.displayImage(result.getUploaderAvatarUrl(), headerUploaderAvatar,
ImageDisplayConstants.DISPLAY_AVATAR_OPTIONS);
headerStreamCount.setText(Localization.localizeStreamCount(getContext(), result.getStreamCount()));
String avatarUrl = result.getUploaderAvatarUrl();
if (avatarUrl.contains("upload.wikimedia.org")) {
// this is an auto-generated playlist (e.g. Youtube mixes) with an avatar
// that could be a trademark and thus not be safe to use
headerUploaderAvatar.setImageResource(
ThemeHelper.resolveResourceIdFromAttr(requireContext(), R.attr.ic_radio));
headerUploaderAvatar.setBorderColor(
getResources().getColor(R.color.transparent_background_color));
} else {
imageLoader.displayImage(avatarUrl, headerUploaderAvatar,
ImageDisplayConstants.DISPLAY_AVATAR_OPTIONS);
}

headerStreamCount.setText(Localization.localizeStreamCount(getContext(),
result.getStreamCount()));

if (!result.getErrors().isEmpty()) {
showSnackBarError(result.getErrors(), UserAction.REQUESTED_PLAYLIST, NewPipe.getNameOfService(result.getServiceId()), result.getUrl(), 0);
Expand Down

0 comments on commit 48f17ff

Please sign in to comment.