From 92a7f22d3cd1585cbd1a0e6af93faa89623ac5ac Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Wed, 19 Jun 2024 10:19:02 +0530 Subject: [PATCH 01/72] Load notification icons using Coil --- app/build.gradle | 1 + .../feed/notifications/NotificationHelper.kt | 53 ++++++------------- 2 files changed, 18 insertions(+), 36 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 4652cf6e5ba..afba5c1c817 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -269,6 +269,7 @@ dependencies { // Image loading //noinspection GradleDependency --> 2.8 is the last version, not 2.71828! implementation "com.squareup.picasso:picasso:2.8" + implementation 'io.coil-kt:coil:2.6.0' // Markdown library for Android implementation "io.noties.markwon:core:${markwonVersion}" diff --git a/app/src/main/java/org/schabi/newpipe/local/feed/notifications/NotificationHelper.kt b/app/src/main/java/org/schabi/newpipe/local/feed/notifications/NotificationHelper.kt index 8ea89368d6b..942094c0c40 100644 --- a/app/src/main/java/org/schabi/newpipe/local/feed/notifications/NotificationHelper.kt +++ b/app/src/main/java/org/schabi/newpipe/local/feed/notifications/NotificationHelper.kt @@ -6,7 +6,6 @@ import android.app.PendingIntent import android.content.Context import android.content.Intent import android.graphics.Bitmap -import android.graphics.drawable.Drawable import android.net.Uri import android.os.Build import android.provider.Settings @@ -15,21 +14,22 @@ import androidx.core.app.NotificationManagerCompat import androidx.core.app.PendingIntentCompat import androidx.core.content.ContextCompat import androidx.core.content.getSystemService +import androidx.core.graphics.drawable.toBitmapOrNull import androidx.preference.PreferenceManager -import com.squareup.picasso.Picasso -import com.squareup.picasso.Target +import coil.executeBlocking +import coil.imageLoader +import coil.request.ImageRequest import org.schabi.newpipe.R import org.schabi.newpipe.extractor.stream.StreamInfoItem import org.schabi.newpipe.local.feed.service.FeedUpdateInfo import org.schabi.newpipe.util.NavigationHelper -import org.schabi.newpipe.util.image.PicassoHelper +import org.schabi.newpipe.util.image.ImageStrategy /** * Helper for everything related to show notifications about new streams to the user. */ class NotificationHelper(val context: Context) { private val manager = NotificationManagerCompat.from(context) - private val iconLoadingTargets = ArrayList() /** * Show notifications for new streams from a single channel. The individual notifications are @@ -80,39 +80,20 @@ class NotificationHelper(val context: Context) { ) ) - // a Target is like a listener for image loading events - val target = object : Target { - override fun onBitmapLoaded(bitmap: Bitmap, from: Picasso.LoadedFrom) { - // set channel icon only if there is actually one (for Android versions < 7.0) - summaryBuilder.setLargeIcon(bitmap) - - // Show individual stream notifications, set channel icon only if there is actually - // one - showStreamNotifications(newStreams, data.serviceId, bitmap) - // Show summary notification - manager.notify(data.pseudoId, summaryBuilder.build()) - - iconLoadingTargets.remove(this) // allow it to be garbage-collected - } - - override fun onBitmapFailed(e: Exception, errorDrawable: Drawable) { - // Show individual stream notifications - showStreamNotifications(newStreams, data.serviceId, null) - // Show summary notification - manager.notify(data.pseudoId, summaryBuilder.build()) - iconLoadingTargets.remove(this) // allow it to be garbage-collected - } - - override fun onPrepareLoad(placeHolderDrawable: Drawable) { - // Nothing to do - } - } + val request = ImageRequest.Builder(context) + .data(data.avatarUrl?.takeIf { ImageStrategy.shouldLoadImages() }) + .placeholder(R.drawable.ic_newpipe_triangle_white) + .error(R.drawable.ic_newpipe_triangle_white) + .build() + val avatarIcon = context.imageLoader.executeBlocking(request).drawable?.toBitmapOrNull() - // add the target to the list to hold a strong reference and prevent it from being garbage - // collected, since Picasso only holds weak references to targets - iconLoadingTargets.add(target) + summaryBuilder.setLargeIcon(avatarIcon) - PicassoHelper.loadNotificationIcon(data.avatarUrl).into(target) + // Show individual stream notifications, set channel icon only if there is actually + // one + showStreamNotifications(newStreams, data.serviceId, avatarIcon) + // Show summary notification + manager.notify(data.pseudoId, summaryBuilder.build()) } private fun showStreamNotifications( From 844b4edf48b81c46acc096677c283cde0b1bca48 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Sat, 22 Jun 2024 08:32:06 +0530 Subject: [PATCH 02/72] Migrate to Coil from Picasso --- app/src/main/java/org/schabi/newpipe/App.java | 32 +++++-- .../fragments/detail/VideoDetailFragment.java | 27 +++--- .../list/channel/ChannelFragment.java | 15 ++- .../list/comments/CommentRepliesFragment.java | 4 +- .../list/playlist/PlaylistFragment.java | 5 +- .../newpipe/info_list/StreamSegmentItem.kt | 44 ++++----- .../holder/ChannelMiniInfoItemHolder.java | 4 +- .../holder/CommentInfoItemHolder.java | 8 +- .../holder/PlaylistMiniInfoItemHolder.java | 4 +- .../holder/StreamMiniInfoItemHolder.java | 4 +- .../newpipe/local/feed/item/StreamItem.kt | 4 +- .../local/holder/LocalPlaylistItemHolder.java | 7 +- .../holder/LocalPlaylistStreamItemHolder.java | 6 +- .../LocalStatisticStreamItemHolder.java | 6 +- .../holder/RemotePlaylistItemHolder.java | 7 +- .../local/subscription/item/ChannelItem.kt | 4 +- .../item/PickerSubscriptionItem.kt | 4 +- .../org/schabi/newpipe/player/Player.java | 6 +- .../playqueue/PlayQueueItemBuilder.java | 4 +- .../SeekbarPreviewThumbnailHolder.java | 7 +- .../settings/ContentSettingsFragment.java | 20 ++-- .../settings/SelectChannelFragment.java | 4 +- .../settings/SelectPlaylistFragment.java | 17 ++-- .../schabi/newpipe/util/image/CoilHelper.kt | 94 +++++++++++++++++++ .../newpipe/util/image/PicassoHelper.java | 62 +----------- 25 files changed, 226 insertions(+), 173 deletions(-) create mode 100644 app/src/main/java/org/schabi/newpipe/util/image/CoilHelper.kt diff --git a/app/src/main/java/org/schabi/newpipe/App.java b/app/src/main/java/org/schabi/newpipe/App.java index d92425d200e..22ee3aa8bd2 100644 --- a/app/src/main/java/org/schabi/newpipe/App.java +++ b/app/src/main/java/org/schabi/newpipe/App.java @@ -20,10 +20,10 @@ import org.schabi.newpipe.ktx.ExceptionUtils; import org.schabi.newpipe.settings.NewPipeSettings; import org.schabi.newpipe.util.Localization; -import org.schabi.newpipe.util.image.ImageStrategy; -import org.schabi.newpipe.util.image.PicassoHelper; import org.schabi.newpipe.util.ServiceHelper; import org.schabi.newpipe.util.StateSaver; +import org.schabi.newpipe.util.image.ImageStrategy; +import org.schabi.newpipe.util.image.PicassoHelper; import org.schabi.newpipe.util.image.PreferredImageQuality; import java.io.IOException; @@ -32,6 +32,11 @@ import java.util.List; import java.util.Objects; +import coil.ImageLoader; +import coil.ImageLoaderFactory; +import coil.disk.DiskCache; +import coil.memory.MemoryCache; +import coil.util.DebugLogger; import io.reactivex.rxjava3.exceptions.CompositeException; import io.reactivex.rxjava3.exceptions.MissingBackpressureException; import io.reactivex.rxjava3.exceptions.OnErrorNotImplementedException; @@ -57,7 +62,7 @@ * along with NewPipe. If not, see . */ -public class App extends Application { +public class App extends Application implements ImageLoaderFactory { public static final String PACKAGE_NAME = BuildConfig.APPLICATION_ID; private static final String TAG = App.class.toString(); @@ -118,10 +123,25 @@ public void onCreate() { configureRxJavaErrorHandler(); } + @NonNull @Override - public void onTerminate() { - super.onTerminate(); - PicassoHelper.terminate(); + public ImageLoader newImageLoader() { + final var builder = new ImageLoader.Builder(this) + .memoryCache(() -> new MemoryCache.Builder(this) + .maxSizeBytes(10 * 1024 * 1024) + .build()) + .diskCache(() -> new DiskCache.Builder() + .maxSizeBytes(50 * 1024 * 1024) + .build()) + .allowRgb565(true); + + final var prefs = PreferenceManager.getDefaultSharedPreferences(this); + if (MainActivity.DEBUG + && prefs.getBoolean(getString(R.string.show_image_indicators_key), false)) { + builder.logger(new DebugLogger()); + } + + return builder.build(); } protected Downloader getDownloader() { diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 95b54f65a70..da4b071c32d 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -116,7 +116,7 @@ import org.schabi.newpipe.util.ThemeHelper; import org.schabi.newpipe.util.external_communication.KoreUtils; import org.schabi.newpipe.util.external_communication.ShareUtils; -import org.schabi.newpipe.util.image.PicassoHelper; +import org.schabi.newpipe.util.image.CoilHelper; import java.util.ArrayList; import java.util.Iterator; @@ -127,6 +127,7 @@ import java.util.concurrent.TimeUnit; import java.util.function.Consumer; +import coil.util.CoilUtils; import icepick.State; import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; import io.reactivex.rxjava3.disposables.CompositeDisposable; @@ -1471,7 +1472,10 @@ public void showLoading() { } } - PicassoHelper.cancelTag(PICASSO_VIDEO_DETAILS_TAG); + CoilUtils.dispose(binding.detailThumbnailImageView); + CoilUtils.dispose(binding.detailSubChannelThumbnailView); + CoilUtils.dispose(binding.overlayThumbnail); + binding.detailThumbnailImageView.setImageBitmap(null); binding.detailSubChannelThumbnailView.setImageBitmap(null); } @@ -1562,8 +1566,8 @@ public void handleResult(@NonNull final StreamInfo info) { binding.detailSecondaryControlPanel.setVisibility(View.GONE); checkUpdateProgressInfo(info); - PicassoHelper.loadDetailsThumbnail(info.getThumbnails()).tag(PICASSO_VIDEO_DETAILS_TAG) - .into(binding.detailThumbnailImageView); + CoilHelper.INSTANCE.loadDetailsThumbnail(binding.detailThumbnailImageView, + info.getThumbnails()); showMetaInfoInTextView(info.getMetaInfo(), binding.detailMetaInfoTextView, binding.detailMetaInfoSeparator, disposables); @@ -1613,8 +1617,8 @@ private void displayUploaderAsSubChannel(final StreamInfo info) { binding.detailUploaderTextView.setVisibility(View.GONE); } - PicassoHelper.loadAvatar(info.getUploaderAvatars()).tag(PICASSO_VIDEO_DETAILS_TAG) - .into(binding.detailSubChannelThumbnailView); + CoilHelper.INSTANCE.loadAvatar(binding.detailSubChannelThumbnailView, + info.getUploaderAvatars()); binding.detailSubChannelThumbnailView.setVisibility(View.VISIBLE); binding.detailUploaderThumbnailView.setVisibility(View.GONE); } @@ -1645,11 +1649,11 @@ private void displayBothUploaderAndSubChannel(final StreamInfo info) { binding.detailUploaderTextView.setVisibility(View.GONE); } - PicassoHelper.loadAvatar(info.getSubChannelAvatars()).tag(PICASSO_VIDEO_DETAILS_TAG) - .into(binding.detailSubChannelThumbnailView); + CoilHelper.INSTANCE.loadAvatar(binding.detailSubChannelThumbnailView, + info.getSubChannelAvatars()); binding.detailSubChannelThumbnailView.setVisibility(View.VISIBLE); - PicassoHelper.loadAvatar(info.getUploaderAvatars()).tag(PICASSO_VIDEO_DETAILS_TAG) - .into(binding.detailUploaderThumbnailView); + CoilHelper.INSTANCE.loadAvatar(binding.detailUploaderThumbnailView, + info.getUploaderAvatars()); binding.detailUploaderThumbnailView.setVisibility(View.VISIBLE); } @@ -2403,8 +2407,7 @@ private void updateOverlayData(@Nullable final String overlayTitle, binding.overlayTitleTextView.setText(isEmpty(overlayTitle) ? "" : overlayTitle); binding.overlayChannelTextView.setText(isEmpty(uploader) ? "" : uploader); binding.overlayThumbnail.setImageDrawable(null); - PicassoHelper.loadDetailsThumbnail(thumbnails).tag(PICASSO_VIDEO_DETAILS_TAG) - .into(binding.overlayThumbnail); + CoilHelper.INSTANCE.loadDetailsThumbnail(binding.overlayThumbnail, thumbnails); } private void setOverlayPlayPauseImage(final boolean playerIsPlaying) { diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java index fd382adbf46..e2001f51213 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java @@ -50,10 +50,11 @@ import org.schabi.newpipe.util.Localization; import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.StateSaver; -import org.schabi.newpipe.util.image.ImageStrategy; -import org.schabi.newpipe.util.image.PicassoHelper; import org.schabi.newpipe.util.ThemeHelper; import org.schabi.newpipe.util.external_communication.ShareUtils; +import org.schabi.newpipe.util.image.CoilHelper; +import org.schabi.newpipe.util.image.ImageStrategy; +import org.schabi.newpipe.util.image.PicassoHelper; import java.util.List; import java.util.Queue; @@ -587,17 +588,15 @@ public void handleResult(@NonNull final ChannelInfo result) { setInitialData(result.getServiceId(), result.getOriginalUrl(), result.getName()); if (ImageStrategy.shouldLoadImages() && !result.getBanners().isEmpty()) { - PicassoHelper.loadBanner(result.getBanners()).tag(PICASSO_CHANNEL_TAG) - .into(binding.channelBannerImage); + CoilHelper.INSTANCE.loadBanner(binding.channelBannerImage, result.getBanners()); } else { // do not waste space for the banner, if the user disabled images or there is not one binding.channelBannerImage.setImageDrawable(null); } - PicassoHelper.loadAvatar(result.getAvatars()).tag(PICASSO_CHANNEL_TAG) - .into(binding.channelAvatarView); - PicassoHelper.loadAvatar(result.getParentChannelAvatars()).tag(PICASSO_CHANNEL_TAG) - .into(binding.subChannelAvatarView); + CoilHelper.INSTANCE.loadAvatar(binding.channelAvatarView, result.getAvatars()); + CoilHelper.INSTANCE.loadAvatar(binding.subChannelAvatarView, + result.getParentChannelAvatars()); binding.channelTitleView.setText(result.getName()); binding.channelSubscriberView.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.java index 304eaf55a18..4eb73520fba 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.java @@ -23,8 +23,8 @@ import org.schabi.newpipe.util.ExtractorHelper; import org.schabi.newpipe.util.Localization; import org.schabi.newpipe.util.NavigationHelper; +import org.schabi.newpipe.util.image.CoilHelper; import org.schabi.newpipe.util.image.ImageStrategy; -import org.schabi.newpipe.util.image.PicassoHelper; import org.schabi.newpipe.util.text.TextLinkifier; import java.util.Queue; @@ -82,7 +82,7 @@ protected Supplier getListHeaderSupplier() { final CommentsInfoItem item = commentsInfoItem; // load the author avatar - PicassoHelper.loadAvatar(item.getUploaderAvatars()).into(binding.authorAvatar); + CoilHelper.INSTANCE.loadAvatar(binding.authorAvatar, item.getUploaderAvatars()); binding.authorAvatar.setVisibility(ImageStrategy.shouldLoadImages() ? View.VISIBLE : View.GONE); 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 6410fb9ee75..09ba3a7366e 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 @@ -53,6 +53,7 @@ import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.PlayButtonHelper; import org.schabi.newpipe.util.external_communication.ShareUtils; +import org.schabi.newpipe.util.image.CoilHelper; import org.schabi.newpipe.util.image.PicassoHelper; import org.schabi.newpipe.util.text.TextEllipsizer; @@ -327,8 +328,8 @@ public void handleResult(@NonNull final PlaylistInfo result) { R.drawable.ic_radio) ); } else { - PicassoHelper.loadAvatar(result.getUploaderAvatars()).tag(PICASSO_PLAYLIST_TAG) - .into(headerBinding.uploaderAvatarView); + CoilHelper.INSTANCE.loadAvatar(headerBinding.uploaderAvatarView, + result.getUploaderAvatars()); } streamCount = result.getStreamCount(); diff --git a/app/src/main/java/org/schabi/newpipe/info_list/StreamSegmentItem.kt b/app/src/main/java/org/schabi/newpipe/info_list/StreamSegmentItem.kt index 1e52d316808..83e0c408289 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/StreamSegmentItem.kt +++ b/app/src/main/java/org/schabi/newpipe/info_list/StreamSegmentItem.kt @@ -1,19 +1,18 @@ package org.schabi.newpipe.info_list import android.view.View -import android.widget.ImageView -import android.widget.TextView -import com.xwray.groupie.GroupieViewHolder -import com.xwray.groupie.Item +import com.xwray.groupie.viewbinding.BindableItem +import com.xwray.groupie.viewbinding.GroupieViewHolder import org.schabi.newpipe.R +import org.schabi.newpipe.databinding.ItemStreamSegmentBinding import org.schabi.newpipe.extractor.stream.StreamSegment import org.schabi.newpipe.util.Localization -import org.schabi.newpipe.util.image.PicassoHelper +import org.schabi.newpipe.util.image.CoilHelper class StreamSegmentItem( private val item: StreamSegment, private val onClick: StreamSegmentAdapter.StreamSegmentListener -) : Item() { +) : BindableItem() { companion object { const val PAYLOAD_SELECT = 1 @@ -21,31 +20,32 @@ class StreamSegmentItem( var isSelected = false - override fun bind(viewHolder: GroupieViewHolder, position: Int) { - item.previewUrl?.let { - PicassoHelper.loadThumbnail(it) - .into(viewHolder.root.findViewById(R.id.previewImage)) - } - viewHolder.root.findViewById(R.id.textViewTitle).text = item.title + override fun bind(viewBinding: ItemStreamSegmentBinding, position: Int) { + CoilHelper.loadThumbnail(viewBinding.previewImage, item.previewUrl) + viewBinding.textViewTitle.text = item.title if (item.channelName == null) { - viewHolder.root.findViewById(R.id.textViewChannel).visibility = View.GONE + viewBinding.textViewChannel.visibility = View.GONE // When the channel name is displayed there is less space // and thus the segment title needs to be only one line height. // But when there is no channel name displayed, the title can be two lines long. // The default maxLines value is set to 1 to display all elements in the AS preview, - viewHolder.root.findViewById(R.id.textViewTitle).maxLines = 2 + viewBinding.textViewTitle.maxLines = 2 } else { - viewHolder.root.findViewById(R.id.textViewChannel).text = item.channelName - viewHolder.root.findViewById(R.id.textViewChannel).visibility = View.VISIBLE + viewBinding.textViewChannel.text = item.channelName + viewBinding.textViewChannel.visibility = View.VISIBLE } - viewHolder.root.findViewById(R.id.textViewStartSeconds).text = + viewBinding.textViewStartSeconds.text = Localization.getDurationString(item.startTimeSeconds.toLong()) - viewHolder.root.setOnClickListener { onClick.onItemClick(this, item.startTimeSeconds) } - viewHolder.root.setOnLongClickListener { onClick.onItemLongClick(this, item.startTimeSeconds); true } - viewHolder.root.isSelected = isSelected + viewBinding.root.setOnClickListener { onClick.onItemClick(this, item.startTimeSeconds) } + viewBinding.root.setOnLongClickListener { onClick.onItemLongClick(this, item.startTimeSeconds); true } + viewBinding.root.isSelected = isSelected } - override fun bind(viewHolder: GroupieViewHolder, position: Int, payloads: MutableList) { + override fun bind( + viewHolder: GroupieViewHolder, + position: Int, + payloads: MutableList + ) { if (payloads.contains(PAYLOAD_SELECT)) { viewHolder.root.isSelected = isSelected return @@ -54,4 +54,6 @@ class StreamSegmentItem( } override fun getLayout() = R.layout.item_stream_segment + + override fun initializeViewBinding(view: View) = ItemStreamSegmentBinding.bind(view) } diff --git a/app/src/main/java/org/schabi/newpipe/info_list/holder/ChannelMiniInfoItemHolder.java b/app/src/main/java/org/schabi/newpipe/info_list/holder/ChannelMiniInfoItemHolder.java index 7afc05c6c25..92a5054e130 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/holder/ChannelMiniInfoItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/holder/ChannelMiniInfoItemHolder.java @@ -13,8 +13,8 @@ import org.schabi.newpipe.extractor.utils.Utils; import org.schabi.newpipe.info_list.InfoItemBuilder; import org.schabi.newpipe.local.history.HistoryRecordManager; -import org.schabi.newpipe.util.image.PicassoHelper; import org.schabi.newpipe.util.Localization; +import org.schabi.newpipe.util.image.CoilHelper; public class ChannelMiniInfoItemHolder extends InfoItemHolder { private final ImageView itemThumbnailView; @@ -56,7 +56,7 @@ public void updateFromItem(final InfoItem infoItem, itemAdditionalDetailView.setText(getDetailLine(item)); } - PicassoHelper.loadAvatar(item.getThumbnails()).into(itemThumbnailView); + CoilHelper.INSTANCE.loadAvatar(itemThumbnailView, item.getThumbnails()); itemView.setOnClickListener(view -> { if (itemBuilder.getOnChannelSelectedListener() != null) { diff --git a/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentInfoItemHolder.java b/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentInfoItemHolder.java index 839aa1813f3..a3316d3fecc 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentInfoItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentInfoItemHolder.java @@ -27,8 +27,8 @@ import org.schabi.newpipe.util.Localization; import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.external_communication.ShareUtils; +import org.schabi.newpipe.util.image.CoilHelper; import org.schabi.newpipe.util.image.ImageStrategy; -import org.schabi.newpipe.util.image.PicassoHelper; import org.schabi.newpipe.util.text.TextEllipsizer; public class CommentInfoItemHolder extends InfoItemHolder { @@ -82,14 +82,12 @@ public CommentInfoItemHolder(final InfoItemBuilder infoItemBuilder, @Override public void updateFromItem(final InfoItem infoItem, final HistoryRecordManager historyRecordManager) { - if (!(infoItem instanceof CommentsInfoItem)) { + if (!(infoItem instanceof CommentsInfoItem item)) { return; } - final CommentsInfoItem item = (CommentsInfoItem) infoItem; - // load the author avatar - PicassoHelper.loadAvatar(item.getUploaderAvatars()).into(itemThumbnailView); + CoilHelper.INSTANCE.loadAvatar(itemThumbnailView, item.getUploaderAvatars()); if (ImageStrategy.shouldLoadImages()) { itemThumbnailView.setVisibility(View.VISIBLE); itemRoot.setPadding(commentVerticalPadding, commentVerticalPadding, diff --git a/app/src/main/java/org/schabi/newpipe/info_list/holder/PlaylistMiniInfoItemHolder.java b/app/src/main/java/org/schabi/newpipe/info_list/holder/PlaylistMiniInfoItemHolder.java index c9216d9a9e5..b7949318d58 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/holder/PlaylistMiniInfoItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/holder/PlaylistMiniInfoItemHolder.java @@ -9,8 +9,8 @@ import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem; import org.schabi.newpipe.info_list.InfoItemBuilder; import org.schabi.newpipe.local.history.HistoryRecordManager; -import org.schabi.newpipe.util.image.PicassoHelper; import org.schabi.newpipe.util.Localization; +import org.schabi.newpipe.util.image.CoilHelper; public class PlaylistMiniInfoItemHolder extends InfoItemHolder { public final ImageView itemThumbnailView; @@ -46,7 +46,7 @@ public void updateFromItem(final InfoItem infoItem, .localizeStreamCountMini(itemStreamCountView.getContext(), item.getStreamCount())); itemUploaderView.setText(item.getUploaderName()); - PicassoHelper.loadPlaylistThumbnail(item.getThumbnails()).into(itemThumbnailView); + CoilHelper.INSTANCE.loadPlaylistThumbnail(itemThumbnailView, item.getThumbnails()); itemView.setOnClickListener(view -> { if (itemBuilder.getOnPlaylistSelectedListener() != null) { diff --git a/app/src/main/java/org/schabi/newpipe/info_list/holder/StreamMiniInfoItemHolder.java b/app/src/main/java/org/schabi/newpipe/info_list/holder/StreamMiniInfoItemHolder.java index 01f3be6b328..32fa8bf608b 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/holder/StreamMiniInfoItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/holder/StreamMiniInfoItemHolder.java @@ -16,8 +16,8 @@ import org.schabi.newpipe.local.history.HistoryRecordManager; import org.schabi.newpipe.util.DependentPreferenceHelper; import org.schabi.newpipe.util.Localization; -import org.schabi.newpipe.util.image.PicassoHelper; import org.schabi.newpipe.util.StreamTypeUtil; +import org.schabi.newpipe.util.image.CoilHelper; import org.schabi.newpipe.views.AnimatedProgressBar; import java.util.concurrent.TimeUnit; @@ -87,7 +87,7 @@ public void updateFromItem(final InfoItem infoItem, } // Default thumbnail is shown on error, while loading and if the url is empty - PicassoHelper.loadThumbnail(item.getThumbnails()).into(itemThumbnailView); + CoilHelper.INSTANCE.loadThumbnail(itemThumbnailView, item.getThumbnails()); itemView.setOnClickListener(view -> { if (itemBuilder.getOnStreamSelectedListener() != null) { diff --git a/app/src/main/java/org/schabi/newpipe/local/feed/item/StreamItem.kt b/app/src/main/java/org/schabi/newpipe/local/feed/item/StreamItem.kt index 4a071d6df75..030bb7a7668 100644 --- a/app/src/main/java/org/schabi/newpipe/local/feed/item/StreamItem.kt +++ b/app/src/main/java/org/schabi/newpipe/local/feed/item/StreamItem.kt @@ -19,7 +19,7 @@ import org.schabi.newpipe.extractor.stream.StreamType.POST_LIVE_STREAM import org.schabi.newpipe.extractor.stream.StreamType.VIDEO_STREAM import org.schabi.newpipe.util.Localization import org.schabi.newpipe.util.StreamTypeUtil -import org.schabi.newpipe.util.image.PicassoHelper +import org.schabi.newpipe.util.image.CoilHelper import java.util.concurrent.TimeUnit import java.util.function.Consumer @@ -101,7 +101,7 @@ data class StreamItem( viewBinding.itemProgressView.visibility = View.GONE } - PicassoHelper.loadThumbnail(stream.thumbnailUrl).into(viewBinding.itemThumbnailView) + CoilHelper.loadThumbnail(viewBinding.itemThumbnailView, stream.thumbnailUrl) if (itemVersion != ItemVersion.MINI) { viewBinding.itemAdditionalDetails.text = diff --git a/app/src/main/java/org/schabi/newpipe/local/holder/LocalPlaylistItemHolder.java b/app/src/main/java/org/schabi/newpipe/local/holder/LocalPlaylistItemHolder.java index 336f5cfe30b..a11438374d1 100644 --- a/app/src/main/java/org/schabi/newpipe/local/holder/LocalPlaylistItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/local/holder/LocalPlaylistItemHolder.java @@ -8,8 +8,8 @@ import org.schabi.newpipe.database.playlist.PlaylistMetadataEntry; import org.schabi.newpipe.local.LocalItemBuilder; import org.schabi.newpipe.local.history.HistoryRecordManager; -import org.schabi.newpipe.util.image.PicassoHelper; import org.schabi.newpipe.util.Localization; +import org.schabi.newpipe.util.image.CoilHelper; import java.time.format.DateTimeFormatter; @@ -30,17 +30,16 @@ public LocalPlaylistItemHolder(final LocalItemBuilder infoItemBuilder, final Vie public void updateFromItem(final LocalItem localItem, final HistoryRecordManager historyRecordManager, final DateTimeFormatter dateTimeFormatter) { - if (!(localItem instanceof PlaylistMetadataEntry)) { + if (!(localItem instanceof PlaylistMetadataEntry item)) { return; } - final PlaylistMetadataEntry item = (PlaylistMetadataEntry) localItem; itemTitleView.setText(item.name); itemStreamCountView.setText(Localization.localizeStreamCountMini( itemStreamCountView.getContext(), item.streamCount)); itemUploaderView.setVisibility(View.INVISIBLE); - PicassoHelper.loadPlaylistThumbnail(item.thumbnailUrl).into(itemThumbnailView); + CoilHelper.INSTANCE.loadPlaylistThumbnail(itemThumbnailView, item.thumbnailUrl); if (item instanceof PlaylistDuplicatesEntry && ((PlaylistDuplicatesEntry) item).timesStreamIsContained > 0) { diff --git a/app/src/main/java/org/schabi/newpipe/local/holder/LocalPlaylistStreamItemHolder.java b/app/src/main/java/org/schabi/newpipe/local/holder/LocalPlaylistStreamItemHolder.java index 89a714fd7f6..7dc71bfb4ac 100644 --- a/app/src/main/java/org/schabi/newpipe/local/holder/LocalPlaylistStreamItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/local/holder/LocalPlaylistStreamItemHolder.java @@ -16,8 +16,8 @@ import org.schabi.newpipe.local.history.HistoryRecordManager; import org.schabi.newpipe.util.DependentPreferenceHelper; import org.schabi.newpipe.util.Localization; -import org.schabi.newpipe.util.image.PicassoHelper; import org.schabi.newpipe.util.ServiceHelper; +import org.schabi.newpipe.util.image.CoilHelper; import org.schabi.newpipe.views.AnimatedProgressBar; import java.time.format.DateTimeFormatter; @@ -83,8 +83,8 @@ public void updateFromItem(final LocalItem localItem, } // Default thumbnail is shown on error, while loading and if the url is empty - PicassoHelper.loadThumbnail(item.getStreamEntity().getThumbnailUrl()) - .into(itemThumbnailView); + CoilHelper.INSTANCE.loadThumbnail(itemThumbnailView, + item.getStreamEntity().getThumbnailUrl()); itemView.setOnClickListener(view -> { if (itemBuilder.getOnItemSelectedListener() != null) { diff --git a/app/src/main/java/org/schabi/newpipe/local/holder/LocalStatisticStreamItemHolder.java b/app/src/main/java/org/schabi/newpipe/local/holder/LocalStatisticStreamItemHolder.java index 150a35eb59c..f26a76ad9f7 100644 --- a/app/src/main/java/org/schabi/newpipe/local/holder/LocalStatisticStreamItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/local/holder/LocalStatisticStreamItemHolder.java @@ -16,8 +16,8 @@ import org.schabi.newpipe.local.history.HistoryRecordManager; import org.schabi.newpipe.util.DependentPreferenceHelper; import org.schabi.newpipe.util.Localization; -import org.schabi.newpipe.util.image.PicassoHelper; import org.schabi.newpipe.util.ServiceHelper; +import org.schabi.newpipe.util.image.CoilHelper; import org.schabi.newpipe.views.AnimatedProgressBar; import java.time.format.DateTimeFormatter; @@ -117,8 +117,8 @@ public void updateFromItem(final LocalItem localItem, } // Default thumbnail is shown on error, while loading and if the url is empty - PicassoHelper.loadThumbnail(item.getStreamEntity().getThumbnailUrl()) - .into(itemThumbnailView); + CoilHelper.INSTANCE.loadThumbnail(itemThumbnailView, + item.getStreamEntity().getThumbnailUrl()); itemView.setOnClickListener(view -> { if (itemBuilder.getOnItemSelectedListener() != null) { diff --git a/app/src/main/java/org/schabi/newpipe/local/holder/RemotePlaylistItemHolder.java b/app/src/main/java/org/schabi/newpipe/local/holder/RemotePlaylistItemHolder.java index 7657320634c..f79f3c78532 100644 --- a/app/src/main/java/org/schabi/newpipe/local/holder/RemotePlaylistItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/local/holder/RemotePlaylistItemHolder.java @@ -8,8 +8,8 @@ import org.schabi.newpipe.local.LocalItemBuilder; import org.schabi.newpipe.local.history.HistoryRecordManager; import org.schabi.newpipe.util.Localization; -import org.schabi.newpipe.util.image.PicassoHelper; import org.schabi.newpipe.util.ServiceHelper; +import org.schabi.newpipe.util.image.CoilHelper; import java.time.format.DateTimeFormatter; @@ -29,10 +29,9 @@ public RemotePlaylistItemHolder(final LocalItemBuilder infoItemBuilder, public void updateFromItem(final LocalItem localItem, final HistoryRecordManager historyRecordManager, final DateTimeFormatter dateTimeFormatter) { - if (!(localItem instanceof PlaylistRemoteEntity)) { + if (!(localItem instanceof PlaylistRemoteEntity item)) { return; } - final PlaylistRemoteEntity item = (PlaylistRemoteEntity) localItem; itemTitleView.setText(item.getName()); itemStreamCountView.setText(Localization.localizeStreamCountMini( @@ -45,7 +44,7 @@ public void updateFromItem(final LocalItem localItem, itemUploaderView.setText(ServiceHelper.getNameOfServiceById(item.getServiceId())); } - PicassoHelper.loadPlaylistThumbnail(item.getThumbnailUrl()).into(itemThumbnailView); + CoilHelper.INSTANCE.loadPlaylistThumbnail(itemThumbnailView, item.getThumbnailUrl()); super.updateFromItem(localItem, historyRecordManager, dateTimeFormatter); } diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/item/ChannelItem.kt b/app/src/main/java/org/schabi/newpipe/local/subscription/item/ChannelItem.kt index bc39dafe632..ca626e704f1 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/item/ChannelItem.kt +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/item/ChannelItem.kt @@ -9,7 +9,7 @@ import org.schabi.newpipe.R import org.schabi.newpipe.extractor.channel.ChannelInfoItem import org.schabi.newpipe.util.Localization import org.schabi.newpipe.util.OnClickGesture -import org.schabi.newpipe.util.image.PicassoHelper +import org.schabi.newpipe.util.image.CoilHelper class ChannelItem( private val infoItem: ChannelInfoItem, @@ -39,7 +39,7 @@ class ChannelItem( itemChannelDescriptionView.text = infoItem.description } - PicassoHelper.loadAvatar(infoItem.thumbnails).into(itemThumbnailView) + CoilHelper.loadAvatar(itemThumbnailView, infoItem.thumbnails) gesturesListener?.run { viewHolder.root.setOnClickListener { selected(infoItem) } diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/item/PickerSubscriptionItem.kt b/app/src/main/java/org/schabi/newpipe/local/subscription/item/PickerSubscriptionItem.kt index 3a4c6e41b99..da35447e38d 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/item/PickerSubscriptionItem.kt +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/item/PickerSubscriptionItem.kt @@ -10,7 +10,7 @@ import org.schabi.newpipe.database.subscription.SubscriptionEntity import org.schabi.newpipe.databinding.PickerSubscriptionItemBinding import org.schabi.newpipe.ktx.AnimationType import org.schabi.newpipe.ktx.animate -import org.schabi.newpipe.util.image.PicassoHelper +import org.schabi.newpipe.util.image.CoilHelper data class PickerSubscriptionItem( val subscriptionEntity: SubscriptionEntity, @@ -21,7 +21,7 @@ data class PickerSubscriptionItem( override fun getSpanSize(spanCount: Int, position: Int): Int = 1 override fun bind(viewBinding: PickerSubscriptionItemBinding, position: Int) { - PicassoHelper.loadAvatar(subscriptionEntity.avatarUrl).into(viewBinding.thumbnailView) + CoilHelper.loadAvatar(viewBinding.thumbnailView, subscriptionEntity.avatarUrl) viewBinding.titleView.text = subscriptionEntity.name viewBinding.selectedHighlight.isVisible = isSelected } diff --git a/app/src/main/java/org/schabi/newpipe/player/Player.java b/app/src/main/java/org/schabi/newpipe/player/Player.java index 49e72328e40..49b1611be31 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -86,8 +86,8 @@ import org.schabi.newpipe.error.ErrorInfo; import org.schabi.newpipe.error.ErrorUtil; import org.schabi.newpipe.error.UserAction; -import org.schabi.newpipe.extractor.stream.AudioStream; import org.schabi.newpipe.extractor.Image; +import org.schabi.newpipe.extractor.stream.AudioStream; import org.schabi.newpipe.extractor.stream.StreamInfo; import org.schabi.newpipe.extractor.stream.StreamType; import org.schabi.newpipe.extractor.stream.VideoStream; @@ -118,9 +118,9 @@ import org.schabi.newpipe.util.DependentPreferenceHelper; import org.schabi.newpipe.util.ListHelper; import org.schabi.newpipe.util.NavigationHelper; -import org.schabi.newpipe.util.image.PicassoHelper; import org.schabi.newpipe.util.SerializedCache; import org.schabi.newpipe.util.StreamTypeUtil; +import org.schabi.newpipe.util.image.PicassoHelper; import java.util.List; import java.util.Optional; @@ -816,7 +816,7 @@ private void loadCurrentThumbnail(final List thumbnails) { cancelLoadingCurrentThumbnail(); // Unset currentThumbnail, since it is now outdated. This ensures it is not used in media - // session metadata while the new thumbnail is being loaded by Picasso. + // session metadata while the new thumbnail is being loaded by Coil. onThumbnailLoaded(null); if (thumbnails.isEmpty()) { return; diff --git a/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueueItemBuilder.java b/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueueItemBuilder.java index 066f92c2607..8994aef79df 100644 --- a/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueueItemBuilder.java +++ b/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueueItemBuilder.java @@ -6,8 +6,8 @@ import android.view.View; import org.schabi.newpipe.util.Localization; -import org.schabi.newpipe.util.image.PicassoHelper; import org.schabi.newpipe.util.ServiceHelper; +import org.schabi.newpipe.util.image.CoilHelper; public class PlayQueueItemBuilder { private static final String TAG = PlayQueueItemBuilder.class.toString(); @@ -33,7 +33,7 @@ public void buildStreamInfoItem(final PlayQueueItemHolder holder, final PlayQueu holder.itemDurationView.setVisibility(View.GONE); } - PicassoHelper.loadThumbnail(item.getThumbnails()).into(holder.itemThumbnailView); + CoilHelper.INSTANCE.loadThumbnail(holder.itemThumbnailView, item.getThumbnails()); holder.itemRoot.setOnClickListener(view -> { if (onItemClickListener != null) { diff --git a/app/src/main/java/org/schabi/newpipe/player/seekbarpreview/SeekbarPreviewThumbnailHolder.java b/app/src/main/java/org/schabi/newpipe/player/seekbarpreview/SeekbarPreviewThumbnailHolder.java index 26065de1572..c7c53b097e6 100644 --- a/app/src/main/java/org/schabi/newpipe/player/seekbarpreview/SeekbarPreviewThumbnailHolder.java +++ b/app/src/main/java/org/schabi/newpipe/player/seekbarpreview/SeekbarPreviewThumbnailHolder.java @@ -13,8 +13,9 @@ import com.google.common.base.Stopwatch; +import org.schabi.newpipe.App; import org.schabi.newpipe.extractor.stream.Frameset; -import org.schabi.newpipe.util.image.PicassoHelper; +import org.schabi.newpipe.util.image.CoilHelper; import java.util.Comparator; import java.util.List; @@ -177,8 +178,8 @@ private Bitmap getBitMapFrom(final String url) { Log.d(TAG, "Downloading bitmap for seekbarPreview from '" + url + "'"); // Gets the bitmap within the timeout of 15 seconds imposed by default by OkHttpClient - // Ensure that your are not running on the main-Thread this will otherwise hang - final Bitmap bitmap = PicassoHelper.loadSeekbarThumbnailPreview(url).get(); + // Ensure that you are not running on the main thread, otherwise this will hang + final var bitmap = CoilHelper.INSTANCE.loadBitmap(App.getApp(), url); if (sw != null) { Log.d(TAG, "Download of bitmap for seekbarPreview from '" + url + "' took " diff --git a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java index ec2bed67a44..4e6830cb9af 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java @@ -13,10 +13,9 @@ import org.schabi.newpipe.extractor.localization.ContentCountry; import org.schabi.newpipe.extractor.localization.Localization; import org.schabi.newpipe.util.image.ImageStrategy; -import org.schabi.newpipe.util.image.PicassoHelper; import org.schabi.newpipe.util.image.PreferredImageQuality; -import java.io.IOException; +import coil.Coil; public class ContentSettingsFragment extends BasePreferenceFragment { private String youtubeRestrictedModeEnabledKey; @@ -42,14 +41,17 @@ public void onCreatePreferences(final Bundle savedInstanceState, final String ro (preference, newValue) -> { ImageStrategy.setPreferredImageQuality(PreferredImageQuality .fromPreferenceKey(requireContext(), (String) newValue)); - try { - PicassoHelper.clearCache(preference.getContext()); - Toast.makeText(preference.getContext(), - R.string.thumbnail_cache_wipe_complete_notice, Toast.LENGTH_SHORT) - .show(); - } catch (final IOException e) { - Log.e(TAG, "Unable to clear Picasso cache", e); + final var loader = Coil.imageLoader(preference.getContext()); + if (loader.getMemoryCache() != null) { + loader.getMemoryCache().clear(); } + if (loader.getDiskCache() != null) { + loader.getDiskCache().clear(); + } + Toast.makeText(preference.getContext(), + R.string.thumbnail_cache_wipe_complete_notice, Toast.LENGTH_SHORT) + .show(); + return true; }); } diff --git a/app/src/main/java/org/schabi/newpipe/settings/SelectChannelFragment.java b/app/src/main/java/org/schabi/newpipe/settings/SelectChannelFragment.java index 37335421d16..c566313e37a 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/SelectChannelFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/SelectChannelFragment.java @@ -19,8 +19,8 @@ import org.schabi.newpipe.database.subscription.SubscriptionEntity; import org.schabi.newpipe.error.ErrorUtil; import org.schabi.newpipe.local.subscription.SubscriptionManager; -import org.schabi.newpipe.util.image.PicassoHelper; import org.schabi.newpipe.util.ThemeHelper; +import org.schabi.newpipe.util.image.CoilHelper; import java.util.List; import java.util.Vector; @@ -190,7 +190,7 @@ public void onBindViewHolder(final SelectChannelItemHolder holder, final int pos final SubscriptionEntity entry = subscriptions.get(position); holder.titleView.setText(entry.getName()); holder.view.setOnClickListener(view -> clickedItem(position)); - PicassoHelper.loadAvatar(entry.getAvatarUrl()).into(holder.thumbnailView); + CoilHelper.INSTANCE.loadAvatar(holder.thumbnailView, entry.getAvatarUrl()); } @Override diff --git a/app/src/main/java/org/schabi/newpipe/settings/SelectPlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/settings/SelectPlaylistFragment.java index 36abef9e5ca..c340dca2231 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/SelectPlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/SelectPlaylistFragment.java @@ -27,7 +27,7 @@ import org.schabi.newpipe.error.UserAction; import org.schabi.newpipe.local.playlist.LocalPlaylistManager; import org.schabi.newpipe.local.playlist.RemotePlaylistManager; -import org.schabi.newpipe.util.image.PicassoHelper; +import org.schabi.newpipe.util.image.CoilHelper; import java.util.List; import java.util.Vector; @@ -154,20 +154,15 @@ public void onBindViewHolder(@NonNull final SelectPlaylistItemHolder holder, final int position) { final PlaylistLocalItem selectedItem = playlists.get(position); - if (selectedItem instanceof PlaylistMetadataEntry) { - final PlaylistMetadataEntry entry = ((PlaylistMetadataEntry) selectedItem); - + if (selectedItem instanceof PlaylistMetadataEntry entry) { holder.titleView.setText(entry.name); holder.view.setOnClickListener(view -> clickedItem(position)); - PicassoHelper.loadPlaylistThumbnail(entry.thumbnailUrl).into(holder.thumbnailView); - - } else if (selectedItem instanceof PlaylistRemoteEntity) { - final PlaylistRemoteEntity entry = ((PlaylistRemoteEntity) selectedItem); - + CoilHelper.INSTANCE.loadPlaylistThumbnail(holder.thumbnailView, entry.thumbnailUrl); + } else if (selectedItem instanceof PlaylistRemoteEntity entry) { holder.titleView.setText(entry.getName()); holder.view.setOnClickListener(view -> clickedItem(position)); - PicassoHelper.loadPlaylistThumbnail(entry.getThumbnailUrl()) - .into(holder.thumbnailView); + CoilHelper.INSTANCE.loadPlaylistThumbnail(holder.thumbnailView, + entry.getThumbnailUrl()); } } diff --git a/app/src/main/java/org/schabi/newpipe/util/image/CoilHelper.kt b/app/src/main/java/org/schabi/newpipe/util/image/CoilHelper.kt new file mode 100644 index 00000000000..ce92341d54e --- /dev/null +++ b/app/src/main/java/org/schabi/newpipe/util/image/CoilHelper.kt @@ -0,0 +1,94 @@ +package org.schabi.newpipe.util.image + +import android.content.Context +import android.graphics.Bitmap +import android.widget.ImageView +import androidx.annotation.DrawableRes +import androidx.core.graphics.drawable.toBitmapOrNull +import coil.executeBlocking +import coil.imageLoader +import coil.request.ImageRequest +import org.schabi.newpipe.R +import org.schabi.newpipe.extractor.Image + +object CoilHelper { + fun loadBitmap(context: Context, url: String): Bitmap? { + val request = ImageRequest.Builder(context) + .data(url) + .build() + return context.imageLoader.executeBlocking(request).drawable?.toBitmapOrNull() + } + + fun loadAvatar(target: ImageView, images: List) { + loadImageDefault(target, images, R.drawable.placeholder_person) + } + + fun loadAvatar(target: ImageView, url: String?) { + loadImageDefault(target, url, R.drawable.placeholder_person) + } + + fun loadThumbnail(target: ImageView, images: List) { + loadImageDefault(target, images, R.drawable.placeholder_thumbnail_video) + } + + fun loadThumbnail(target: ImageView, url: String?) { + loadImageDefault(target, url, R.drawable.placeholder_thumbnail_video) + } + + fun loadDetailsThumbnail(target: ImageView, images: List) { + val url = ImageStrategy.choosePreferredImage(images) + loadImageDefault(target, url, R.drawable.placeholder_thumbnail_video, false) + } + + fun loadBanner(target: ImageView, images: List) { + loadImageDefault(target, images, R.drawable.placeholder_channel_banner) + } + + fun loadPlaylistThumbnail(target: ImageView, images: List) { + loadImageDefault(target, images, R.drawable.placeholder_thumbnail_playlist) + } + + fun loadPlaylistThumbnail(target: ImageView, url: String?) { + loadImageDefault(target, url, R.drawable.placeholder_thumbnail_playlist) + } + + private fun loadImageDefault( + target: ImageView, + images: List, + @DrawableRes placeholderResId: Int + ) { + loadImageDefault(target, ImageStrategy.choosePreferredImage(images), placeholderResId) + } + + private fun loadImageDefault( + target: ImageView, + url: String?, + @DrawableRes placeholderResId: Int, + showPlaceholder: Boolean = true + ) { + val request = getImageRequest(target.context, url, placeholderResId, showPlaceholder) + .build() + target.context.imageLoader.enqueue(request) + } + + private fun getImageRequest( + context: Context, + url: String?, + @DrawableRes placeholderResId: Int, + showPlaceholderWhileLoading: Boolean = true + ): ImageRequest.Builder { + // if the URL was chosen with `choosePreferredImage` it will be null, but check again + // `shouldLoadImages` in case the URL was chosen with `imageListToDbUrl` (which is the case + // for URLs stored in the database) + val takenUrl = url?.takeIf { it.isNotEmpty() && ImageStrategy.shouldLoadImages() } + + return ImageRequest.Builder(context) + .data(takenUrl) + .error(placeholderResId) + .apply { + if (takenUrl != null || showPlaceholderWhileLoading) { + placeholder(placeholderResId) + } + } + } +} diff --git a/app/src/main/java/org/schabi/newpipe/util/image/PicassoHelper.java b/app/src/main/java/org/schabi/newpipe/util/image/PicassoHelper.java index 4b116bdf906..257f36133e8 100644 --- a/app/src/main/java/org/schabi/newpipe/util/image/PicassoHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/image/PicassoHelper.java @@ -25,7 +25,6 @@ import org.schabi.newpipe.extractor.Image; import java.io.File; -import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; @@ -63,26 +62,6 @@ public static void init(final Context context) { .build(); } - public static void terminate() { - picassoCache = null; - picassoDownloaderClient = null; - - if (picassoInstance != null) { - picassoInstance.shutdown(); - picassoInstance = null; - } - } - - public static void clearCache(final Context context) throws IOException { - picassoInstance.shutdown(); - picassoCache.clear(); // clear memory cache - final okhttp3.Cache diskCache = picassoDownloaderClient.cache(); - if (diskCache != null) { - diskCache.delete(); // clear disk cache - } - init(context); - } - public static void cancelTag(final Object tag) { picassoInstance.cancelTag(tag); } @@ -91,53 +70,14 @@ public static void setIndicatorsEnabled(final boolean enabled) { picassoInstance.setIndicatorsEnabled(enabled); // useful for debugging } - - public static RequestCreator loadAvatar(@NonNull final List images) { - return loadImageDefault(images, R.drawable.placeholder_person); - } - - public static RequestCreator loadAvatar(@Nullable final String url) { - return loadImageDefault(url, R.drawable.placeholder_person); - } - public static RequestCreator loadThumbnail(@NonNull final List images) { return loadImageDefault(images, R.drawable.placeholder_thumbnail_video); } - public static RequestCreator loadThumbnail(@Nullable final String url) { - return loadImageDefault(url, R.drawable.placeholder_thumbnail_video); - } - - public static RequestCreator loadDetailsThumbnail(@NonNull final List images) { - return loadImageDefault(choosePreferredImage(images), - R.drawable.placeholder_thumbnail_video, false); - } - - public static RequestCreator loadBanner(@NonNull final List images) { - return loadImageDefault(images, R.drawable.placeholder_channel_banner); - } - - public static RequestCreator loadPlaylistThumbnail(@NonNull final List images) { - return loadImageDefault(images, R.drawable.placeholder_thumbnail_playlist); - } - - public static RequestCreator loadPlaylistThumbnail(@Nullable final String url) { - return loadImageDefault(url, R.drawable.placeholder_thumbnail_playlist); - } - - public static RequestCreator loadSeekbarThumbnailPreview(@Nullable final String url) { - return picassoInstance.load(url); - } - - public static RequestCreator loadNotificationIcon(@Nullable final String url) { - return loadImageDefault(url, R.drawable.ic_newpipe_triangle_white); - } - - public static RequestCreator loadScaledDownThumbnail(final Context context, @NonNull final List images) { // scale down the notification thumbnail for performance - return PicassoHelper.loadThumbnail(images) + return loadThumbnail(images) .transform(new Transformation() { @Override public Bitmap transform(final Bitmap source) { From e6302cc868bae9a6e87863d9b09e9de3490a2154 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Sat, 22 Jun 2024 10:01:00 +0530 Subject: [PATCH 03/72] Clean up Picasso leftovers --- app/build.gradle | 2 - app/src/main/java/org/schabi/newpipe/App.java | 10 +- .../org/schabi/newpipe/about/AboutActivity.kt | 4 +- .../fragments/detail/VideoDetailFragment.java | 2 - .../list/channel/ChannelFragment.java | 7 +- .../list/playlist/PlaylistFragment.java | 6 +- .../java/org/schabi/newpipe/ktx/Bitmap.kt | 13 ++ .../org/schabi/newpipe/player/Player.java | 83 ++++----- .../settings/ContentSettingsFragment.java | 2 +- .../settings/DebugSettingsFragment.java | 9 - .../external_communication/ShareUtils.java | 21 +-- .../schabi/newpipe/util/image/CoilHelper.kt | 48 +++++ .../newpipe/util/image/PicassoHelper.java | 164 ------------------ app/src/main/res/values-ar-rLY/strings.xml | 2 - app/src/main/res/values-ar/strings.xml | 2 - app/src/main/res/values-az/strings.xml | 2 - app/src/main/res/values-be/strings.xml | 2 - app/src/main/res/values-bg/strings.xml | 1 - app/src/main/res/values-bn/strings.xml | 1 - app/src/main/res/values-ca/strings.xml | 2 - app/src/main/res/values-ckb/strings.xml | 2 - app/src/main/res/values-cs/strings.xml | 2 - app/src/main/res/values-da/strings.xml | 2 - app/src/main/res/values-de/strings.xml | 2 - app/src/main/res/values-el/strings.xml | 2 - app/src/main/res/values-es/strings.xml | 2 - app/src/main/res/values-et/strings.xml | 2 - app/src/main/res/values-eu/strings.xml | 2 - app/src/main/res/values-fa/strings.xml | 2 - app/src/main/res/values-fi/strings.xml | 2 - app/src/main/res/values-fr/strings.xml | 2 - app/src/main/res/values-gl/strings.xml | 2 - app/src/main/res/values-he/strings.xml | 2 - app/src/main/res/values-hi/strings.xml | 2 - app/src/main/res/values-hr/strings.xml | 2 - app/src/main/res/values-hu/strings.xml | 2 - app/src/main/res/values-in/strings.xml | 2 - app/src/main/res/values-is/strings.xml | 2 - app/src/main/res/values-it/strings.xml | 2 - app/src/main/res/values-ja/strings.xml | 2 - app/src/main/res/values-ka/strings.xml | 2 - app/src/main/res/values-ko/strings.xml | 2 - app/src/main/res/values-lt/strings.xml | 2 - app/src/main/res/values-lv/strings.xml | 2 - app/src/main/res/values-ml/strings.xml | 2 - app/src/main/res/values-nb-rNO/strings.xml | 2 - app/src/main/res/values-nl-rBE/strings.xml | 1 - app/src/main/res/values-nl/strings.xml | 2 - app/src/main/res/values-nqo/strings.xml | 2 - app/src/main/res/values-or/strings.xml | 2 - app/src/main/res/values-pa/strings.xml | 2 - app/src/main/res/values-pl/strings.xml | 2 - app/src/main/res/values-pt-rBR/strings.xml | 2 - app/src/main/res/values-pt-rPT/strings.xml | 2 - app/src/main/res/values-pt/strings.xml | 2 - app/src/main/res/values-ro/strings.xml | 2 - app/src/main/res/values-ru/strings.xml | 2 - app/src/main/res/values-ryu/strings.xml | 2 - app/src/main/res/values-sat/strings.xml | 2 - app/src/main/res/values-sc/strings.xml | 2 - app/src/main/res/values-sk/strings.xml | 2 - app/src/main/res/values-so/strings.xml | 2 - app/src/main/res/values-sr/strings.xml | 2 - app/src/main/res/values-sv/strings.xml | 2 - app/src/main/res/values-te/strings.xml | 2 - app/src/main/res/values-tr/strings.xml | 2 - app/src/main/res/values-uk/strings.xml | 2 - app/src/main/res/values-vi/strings.xml | 2 - app/src/main/res/values-zh-rCN/strings.xml | 2 - app/src/main/res/values-zh-rHK/strings.xml | 2 - app/src/main/res/values-zh-rTW/strings.xml | 2 - app/src/main/res/values/settings_keys.xml | 1 - app/src/main/res/values/strings.xml | 2 - app/src/main/res/xml/debug_settings.xml | 7 - 74 files changed, 108 insertions(+), 386 deletions(-) create mode 100644 app/src/main/java/org/schabi/newpipe/ktx/Bitmap.kt delete mode 100644 app/src/main/java/org/schabi/newpipe/util/image/PicassoHelper.java diff --git a/app/build.gradle b/app/build.gradle index afba5c1c817..1ba5aca389b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -267,8 +267,6 @@ dependencies { implementation "com.github.lisawray.groupie:groupie-viewbinding:${groupieVersion}" // Image loading - //noinspection GradleDependency --> 2.8 is the last version, not 2.71828! - implementation "com.squareup.picasso:picasso:2.8" implementation 'io.coil-kt:coil:2.6.0' // Markdown library for Android diff --git a/app/src/main/java/org/schabi/newpipe/App.java b/app/src/main/java/org/schabi/newpipe/App.java index 22ee3aa8bd2..5d92e90ac9d 100644 --- a/app/src/main/java/org/schabi/newpipe/App.java +++ b/app/src/main/java/org/schabi/newpipe/App.java @@ -23,9 +23,9 @@ import org.schabi.newpipe.util.ServiceHelper; import org.schabi.newpipe.util.StateSaver; import org.schabi.newpipe.util.image.ImageStrategy; -import org.schabi.newpipe.util.image.PicassoHelper; import org.schabi.newpipe.util.image.PreferredImageQuality; +import java.io.File; import java.io.IOException; import java.io.InterruptedIOException; import java.net.SocketException; @@ -113,12 +113,9 @@ public void onCreate() { // Initialize image loader final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); - PicassoHelper.init(this); ImageStrategy.setPreferredImageQuality(PreferredImageQuality.fromPreferenceKey(this, prefs.getString(getString(R.string.image_quality_key), getString(R.string.image_quality_default)))); - PicassoHelper.setIndicatorsEnabled(MainActivity.DEBUG - && prefs.getBoolean(getString(R.string.show_image_indicators_key), false)); configureRxJavaErrorHandler(); } @@ -131,13 +128,12 @@ public ImageLoader newImageLoader() { .maxSizeBytes(10 * 1024 * 1024) .build()) .diskCache(() -> new DiskCache.Builder() + .directory(new File(getExternalCacheDir(), "coil")) .maxSizeBytes(50 * 1024 * 1024) .build()) .allowRgb565(true); - final var prefs = PreferenceManager.getDefaultSharedPreferences(this); - if (MainActivity.DEBUG - && prefs.getBoolean(getString(R.string.show_image_indicators_key), false)) { + if (MainActivity.DEBUG) { builder.logger(new DebugLogger()); } diff --git a/app/src/main/java/org/schabi/newpipe/about/AboutActivity.kt b/app/src/main/java/org/schabi/newpipe/about/AboutActivity.kt index 7f148e9b5c2..0d0d0d48dd4 100644 --- a/app/src/main/java/org/schabi/newpipe/about/AboutActivity.kt +++ b/app/src/main/java/org/schabi/newpipe/about/AboutActivity.kt @@ -167,8 +167,8 @@ class AboutActivity : AppCompatActivity() { "https://square.github.io/okhttp/", StandardLicenses.APACHE2 ), SoftwareComponent( - "Picasso", "2013", "Square, Inc.", - "https://square.github.io/picasso/", StandardLicenses.APACHE2 + "Coil", "2023", "Coil Contributors", + "https://coil-kt.github.io/coil/", StandardLicenses.APACHE2 ), SoftwareComponent( "PrettyTime", "2012 - 2020", "Lincoln Baxter, III", diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index da4b071c32d..96523321b14 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -160,8 +160,6 @@ public final class VideoDetailFragment private static final String DESCRIPTION_TAB_TAG = "DESCRIPTION TAB"; private static final String EMPTY_TAB_TAG = "EMPTY TAB"; - private static final String PICASSO_VIDEO_DETAILS_TAG = "PICASSO_VIDEO_DETAILS_TAG"; - // tabs private boolean showComments; private boolean showRelatedItems; diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java index e2001f51213..3890e48659d 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java @@ -54,12 +54,12 @@ import org.schabi.newpipe.util.external_communication.ShareUtils; import org.schabi.newpipe.util.image.CoilHelper; import org.schabi.newpipe.util.image.ImageStrategy; -import org.schabi.newpipe.util.image.PicassoHelper; import java.util.List; import java.util.Queue; import java.util.concurrent.TimeUnit; +import coil.util.CoilUtils; import icepick.State; import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; import io.reactivex.rxjava3.core.Observable; @@ -74,7 +74,6 @@ public class ChannelFragment extends BaseStateFragment implements StateSaver.WriteRead { private static final int BUTTON_DEBOUNCE_INTERVAL = 100; - private static final String PICASSO_CHANNEL_TAG = "PICASSO_CHANNEL_TAG"; @State protected int serviceId = Constants.NO_SERVICE_ID; @@ -577,7 +576,9 @@ private void runWorker(final boolean forceLoad) { @Override public void showLoading() { super.showLoading(); - PicassoHelper.cancelTag(PICASSO_CHANNEL_TAG); + CoilUtils.dispose(binding.channelAvatarView); + CoilUtils.dispose(binding.channelBannerImage); + CoilUtils.dispose(binding.subChannelAvatarView); animate(binding.channelSubscribeButton, false, 100); } 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 09ba3a7366e..d4607a9ffb1 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 @@ -54,7 +54,6 @@ import org.schabi.newpipe.util.PlayButtonHelper; import org.schabi.newpipe.util.external_communication.ShareUtils; import org.schabi.newpipe.util.image.CoilHelper; -import org.schabi.newpipe.util.image.PicassoHelper; import org.schabi.newpipe.util.text.TextEllipsizer; import java.util.ArrayList; @@ -63,6 +62,7 @@ import java.util.function.Supplier; import java.util.stream.Collectors; +import coil.util.CoilUtils; import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; import io.reactivex.rxjava3.core.Flowable; import io.reactivex.rxjava3.core.Single; @@ -72,8 +72,6 @@ public class PlaylistFragment extends BaseListInfoFragment implements PlaylistControlViewHolder { - private static final String PICASSO_PLAYLIST_TAG = "PICASSO_PLAYLIST_TAG"; - private CompositeDisposable disposables; private Subscription bookmarkReactor; private AtomicBoolean isBookmarkButtonReady; @@ -277,7 +275,7 @@ public void showLoading() { animate(headerBinding.getRoot(), false, 200); animateHideRecyclerViewAllowingScrolling(itemsList); - PicassoHelper.cancelTag(PICASSO_PLAYLIST_TAG); + CoilUtils.dispose(headerBinding.uploaderAvatarView); animate(headerBinding.uploaderLayout, false, 200); } diff --git a/app/src/main/java/org/schabi/newpipe/ktx/Bitmap.kt b/app/src/main/java/org/schabi/newpipe/ktx/Bitmap.kt new file mode 100644 index 00000000000..4a3c3e071d4 --- /dev/null +++ b/app/src/main/java/org/schabi/newpipe/ktx/Bitmap.kt @@ -0,0 +1,13 @@ +package org.schabi.newpipe.ktx + +import android.graphics.Bitmap +import android.graphics.Rect +import androidx.core.graphics.BitmapCompat + +@Suppress("NOTHING_TO_INLINE") +inline fun Bitmap.scale( + width: Int, + height: Int, + srcRect: Rect? = null, + scaleInLinearSpace: Boolean = true, +) = BitmapCompat.createScaledBitmap(this, width, height, srcRect, scaleInLinearSpace) diff --git a/app/src/main/java/org/schabi/newpipe/player/Player.java b/app/src/main/java/org/schabi/newpipe/player/Player.java index 49b1611be31..40da9139dff 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -60,6 +60,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.core.graphics.drawable.DrawableKt; import androidx.core.math.MathUtils; import androidx.preference.PreferenceManager; @@ -77,8 +78,6 @@ import com.google.android.exoplayer2.trackselection.MappingTrackSelector; import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; import com.google.android.exoplayer2.video.VideoSize; -import com.squareup.picasso.Picasso; -import com.squareup.picasso.Target; import org.schabi.newpipe.MainActivity; import org.schabi.newpipe.R; @@ -120,12 +119,13 @@ import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.SerializedCache; import org.schabi.newpipe.util.StreamTypeUtil; -import org.schabi.newpipe.util.image.PicassoHelper; +import org.schabi.newpipe.util.image.CoilHelper; import java.util.List; import java.util.Optional; import java.util.stream.IntStream; +import coil.target.Target; import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; import io.reactivex.rxjava3.core.Observable; import io.reactivex.rxjava3.disposables.CompositeDisposable; @@ -174,7 +174,6 @@ public final class Player implements PlaybackListener, Listener { //////////////////////////////////////////////////////////////////////////*/ public static final int RENDERER_UNAVAILABLE = -1; - private static final String PICASSO_PLAYER_THUMBNAIL_TAG = "PICASSO_PLAYER_THUMBNAIL_TAG"; /*////////////////////////////////////////////////////////////////////////// // Playback @@ -246,12 +245,6 @@ public final class Player implements PlaybackListener, Listener { @NonNull private final CompositeDisposable databaseUpdateDisposable = new CompositeDisposable(); - // This is the only listener we need for thumbnail loading, since there is always at most only - // one thumbnail being loaded at a time. This field is also here to maintain a strong reference, - // which would otherwise be garbage collected since Picasso holds weak references to targets. - @NonNull - private final Target currentThumbnailTarget; - /*////////////////////////////////////////////////////////////////////////// // Utils //////////////////////////////////////////////////////////////////////////*/ @@ -295,8 +288,6 @@ public Player(@NonNull final PlayerService service) { videoResolver = new VideoPlaybackResolver(context, dataSource, getQualityResolver()); audioResolver = new AudioPlaybackResolver(context, dataSource); - currentThumbnailTarget = getCurrentThumbnailTarget(); - // The UIs added here should always be present. They will be initialized when the player // reaches the initialization step. Make sure the media session ui is before the // notification ui in the UIs list, since the notification depends on the media session in @@ -602,7 +593,6 @@ public void destroy() { databaseUpdateDisposable.clear(); progressUpdateDisposable.set(null); - cancelLoadingCurrentThumbnail(); UIs.destroyAll(Object.class); // destroy every UI: obviously every UI extends Object } @@ -776,45 +766,12 @@ private void unregisterBroadcastReceiver() { //////////////////////////////////////////////////////////////////////////*/ //region Thumbnail loading - private Target getCurrentThumbnailTarget() { - // a Picasso target is just a listener for thumbnail loading events - return new Target() { - @Override - public void onBitmapLoaded(final Bitmap bitmap, final Picasso.LoadedFrom from) { - if (DEBUG) { - Log.d(TAG, "Thumbnail - onBitmapLoaded() called with: bitmap = [" + bitmap - + " -> " + bitmap.getWidth() + "x" + bitmap.getHeight() + "], from = [" - + from + "]"); - } - // there is a new thumbnail, so e.g. the end screen thumbnail needs to change, too. - onThumbnailLoaded(bitmap); - } - - @Override - public void onBitmapFailed(final Exception e, final Drawable errorDrawable) { - Log.e(TAG, "Thumbnail - onBitmapFailed() called", e); - // there is a new thumbnail, so e.g. the end screen thumbnail needs to change, too. - onThumbnailLoaded(null); - } - - @Override - public void onPrepareLoad(final Drawable placeHolderDrawable) { - if (DEBUG) { - Log.d(TAG, "Thumbnail - onPrepareLoad() called"); - } - } - }; - } - private void loadCurrentThumbnail(final List thumbnails) { if (DEBUG) { Log.d(TAG, "Thumbnail - loadCurrentThumbnail() called with thumbnails = [" + thumbnails.size() + "]"); } - // first cancel any previous loading - cancelLoadingCurrentThumbnail(); - // Unset currentThumbnail, since it is now outdated. This ensures it is not used in media // session metadata while the new thumbnail is being loaded by Coil. onThumbnailLoaded(null); @@ -823,20 +780,38 @@ private void loadCurrentThumbnail(final List thumbnails) { } // scale down the notification thumbnail for performance - PicassoHelper.loadScaledDownThumbnail(context, thumbnails) - .tag(PICASSO_PLAYER_THUMBNAIL_TAG) - .into(currentThumbnailTarget); - } + final var target = new Target() { + @Override + public void onError(@Nullable final Drawable error) { + Log.e(TAG, "Thumbnail - onError() called"); + // there is a new thumbnail, so e.g. the end screen thumbnail needs to change, too. + onThumbnailLoaded(null); + } - private void cancelLoadingCurrentThumbnail() { - // cancel the Picasso job associated with the player thumbnail, if any - PicassoHelper.cancelTag(PICASSO_PLAYER_THUMBNAIL_TAG); + @Override + public void onStart(@Nullable final Drawable placeholder) { + if (DEBUG) { + Log.d(TAG, "Thumbnail - onStart() called"); + } + } + + @Override + public void onSuccess(@NonNull final Drawable result) { + if (DEBUG) { + Log.d(TAG, "Thumbnail - onSuccess() called with: drawable = [" + result + "]"); + } + // there is a new thumbnail, so e.g. the end screen thumbnail needs to change, too. + onThumbnailLoaded(DrawableKt.toBitmapOrNull(result, result.getIntrinsicWidth(), + result.getIntrinsicHeight(), null)); + } + }; + CoilHelper.INSTANCE.loadScaledDownThumbnail(context, thumbnails, target); } private void onThumbnailLoaded(@Nullable final Bitmap bitmap) { // Avoid useless thumbnail updates, if the thumbnail has not actually changed. Based on the // thumbnail loading code, this if would be skipped only when both bitmaps are `null`, since - // onThumbnailLoaded won't be called twice with the same nonnull bitmap by Picasso's target. + // onThumbnailLoaded won't be called twice with the same nonnull bitmap by Coil's target. if (currentThumbnail != bitmap) { currentThumbnail = bitmap; UIs.call(playerUi -> playerUi.onThumbnailLoaded(bitmap)); diff --git a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java index 4e6830cb9af..2cda1b4ea2d 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java @@ -49,7 +49,7 @@ public void onCreatePreferences(final Bundle savedInstanceState, final String ro loader.getDiskCache().clear(); } Toast.makeText(preference.getContext(), - R.string.thumbnail_cache_wipe_complete_notice, Toast.LENGTH_SHORT) + R.string.thumbnail_cache_wipe_complete_notice, Toast.LENGTH_SHORT) .show(); return true; diff --git a/app/src/main/java/org/schabi/newpipe/settings/DebugSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/DebugSettingsFragment.java index d78ade49df6..c6abb5405aa 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/DebugSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/DebugSettingsFragment.java @@ -10,7 +10,6 @@ import org.schabi.newpipe.error.ErrorUtil; import org.schabi.newpipe.error.UserAction; import org.schabi.newpipe.local.feed.notifications.NotificationWorker; -import org.schabi.newpipe.util.image.PicassoHelper; import java.util.Optional; @@ -25,8 +24,6 @@ public void onCreatePreferences(final Bundle savedInstanceState, final String ro findPreference(getString(R.string.allow_heap_dumping_key)); final Preference showMemoryLeaksPreference = findPreference(getString(R.string.show_memory_leaks_key)); - final Preference showImageIndicatorsPreference = - findPreference(getString(R.string.show_image_indicators_key)); final Preference checkNewStreamsPreference = findPreference(getString(R.string.check_new_streams_key)); final Preference crashTheAppPreference = @@ -38,7 +35,6 @@ public void onCreatePreferences(final Bundle savedInstanceState, final String ro assert allowHeapDumpingPreference != null; assert showMemoryLeaksPreference != null; - assert showImageIndicatorsPreference != null; assert checkNewStreamsPreference != null; assert crashTheAppPreference != null; assert showErrorSnackbarPreference != null; @@ -61,11 +57,6 @@ public void onCreatePreferences(final Bundle savedInstanceState, final String ro showMemoryLeaksPreference.setSummary(R.string.leak_canary_not_available); } - showImageIndicatorsPreference.setOnPreferenceChangeListener((preference, newValue) -> { - PicassoHelper.setIndicatorsEnabled((Boolean) newValue); - return true; - }); - checkNewStreamsPreference.setOnPreferenceClickListener(preference -> { NotificationWorker.runNow(preference.getContext()); return true; diff --git a/app/src/main/java/org/schabi/newpipe/util/external_communication/ShareUtils.java b/app/src/main/java/org/schabi/newpipe/util/external_communication/ShareUtils.java index 7524e5413c5..3e93abf4db7 100644 --- a/app/src/main/java/org/schabi/newpipe/util/external_communication/ShareUtils.java +++ b/app/src/main/java/org/schabi/newpipe/util/external_communication/ShareUtils.java @@ -24,8 +24,8 @@ import org.schabi.newpipe.BuildConfig; import org.schabi.newpipe.R; import org.schabi.newpipe.extractor.Image; +import org.schabi.newpipe.util.image.CoilHelper; import org.schabi.newpipe.util.image.ImageStrategy; -import org.schabi.newpipe.util.image.PicassoHelper; import java.io.File; import java.io.FileOutputStream; @@ -278,7 +278,7 @@ public static void shareText(@NonNull final Context context, * @param content the content to share * @param images a set of possible {@link Image}s of the subject, among which to choose with * {@link ImageStrategy#choosePreferredImage(List)} since that's likely to - * provide an image that is in Picasso's cache + * provide an image that is in Coil's cache */ public static void shareText(@NonNull final Context context, @NonNull final String title, @@ -335,15 +335,7 @@ public static void copyToClipboard(@NonNull final Context context, final String } /** - * Generate a {@link ClipData} with the image of the content shared, if it's in the app cache. - * - *

- * In order not to worry about network issues (timeouts, DNS issues, low connection speed, ...) - * when sharing a content, only images in the {@link com.squareup.picasso.LruCache LruCache} - * used by the Picasso library inside {@link PicassoHelper} are used as preview images. If the - * thumbnail image is not in the cache, no {@link ClipData} will be generated and {@code null} - * will be returned. - *

+ * Generate a {@link ClipData} with the image of the content shared. * *

* In order to display the image in the content preview of the Android share sheet, an URI of @@ -359,9 +351,8 @@ public static void copyToClipboard(@NonNull final Context context, final String *

* *

- * This method will call {@link PicassoHelper#getImageFromCacheIfPresent(String)} to get the - * thumbnail of the content in the {@link com.squareup.picasso.LruCache LruCache} used by - * the Picasso library inside {@link PicassoHelper}. + * This method will call {@link CoilHelper#loadBitmap(Context, String)} to get the + * thumbnail of the content. *

* *

@@ -378,7 +369,7 @@ private static ClipData generateClipDataForImagePreview( @NonNull final Context context, @NonNull final String thumbnailUrl) { try { - final Bitmap bitmap = PicassoHelper.getImageFromCacheIfPresent(thumbnailUrl); + final var bitmap = CoilHelper.INSTANCE.loadBitmap(context, thumbnailUrl); if (bitmap == null) { return null; } diff --git a/app/src/main/java/org/schabi/newpipe/util/image/CoilHelper.kt b/app/src/main/java/org/schabi/newpipe/util/image/CoilHelper.kt index ce92341d54e..3977212bf60 100644 --- a/app/src/main/java/org/schabi/newpipe/util/image/CoilHelper.kt +++ b/app/src/main/java/org/schabi/newpipe/util/image/CoilHelper.kt @@ -2,16 +2,25 @@ package org.schabi.newpipe.util.image import android.content.Context import android.graphics.Bitmap +import android.util.Log import android.widget.ImageView import androidx.annotation.DrawableRes import androidx.core.graphics.drawable.toBitmapOrNull import coil.executeBlocking import coil.imageLoader import coil.request.ImageRequest +import coil.size.Size +import coil.target.Target +import coil.transform.Transformation +import org.schabi.newpipe.MainActivity import org.schabi.newpipe.R import org.schabi.newpipe.extractor.Image +import org.schabi.newpipe.ktx.scale +import kotlin.math.min object CoilHelper { + private const val TAG = "CoilHelper" + fun loadBitmap(context: Context, url: String): Bitmap? { val request = ImageRequest.Builder(context) .data(url) @@ -35,6 +44,44 @@ object CoilHelper { loadImageDefault(target, url, R.drawable.placeholder_thumbnail_video) } + fun loadScaledDownThumbnail(context: Context, images: List, target: Target) { + val url = ImageStrategy.choosePreferredImage(images) + val request = getImageRequest(context, url, R.drawable.placeholder_thumbnail_video) + .target(target) + .transformations(object : Transformation { + override val cacheKey = "COIL_PLAYER_THUMBNAIL_TRANSFORMATION_KEY" + + override suspend fun transform(input: Bitmap, size: Size): Bitmap { + if (MainActivity.DEBUG) { + Log.d(TAG, "Thumbnail - transform() called") + } + + val notificationThumbnailWidth = min( + context.resources.getDimension(R.dimen.player_notification_thumbnail_width), + input.width.toFloat() + ).toInt() + + var newHeight = input.height / (input.width / notificationThumbnailWidth) + val result = input.scale(notificationThumbnailWidth, newHeight) + + if (result == input || !result.isMutable) { + // create a new mutable bitmap to prevent strange crashes on some + // devices (see #4638) + newHeight = input.height / (input.width / (notificationThumbnailWidth - 1)) + val copied = input.scale(notificationThumbnailWidth, newHeight) + input.recycle() + return copied + } else { + input.recycle() + return result + } + } + }) + .build() + + context.imageLoader.enqueue(request) + } + fun loadDetailsThumbnail(target: ImageView, images: List) { val url = ImageStrategy.choosePreferredImage(images) loadImageDefault(target, url, R.drawable.placeholder_thumbnail_video, false) @@ -67,6 +114,7 @@ object CoilHelper { showPlaceholder: Boolean = true ) { val request = getImageRequest(target.context, url, placeholderResId, showPlaceholder) + .target(target) .build() target.context.imageLoader.enqueue(request) } diff --git a/app/src/main/java/org/schabi/newpipe/util/image/PicassoHelper.java b/app/src/main/java/org/schabi/newpipe/util/image/PicassoHelper.java deleted file mode 100644 index 257f36133e8..00000000000 --- a/app/src/main/java/org/schabi/newpipe/util/image/PicassoHelper.java +++ /dev/null @@ -1,164 +0,0 @@ -package org.schabi.newpipe.util.image; - -import static org.schabi.newpipe.MainActivity.DEBUG; -import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; -import static org.schabi.newpipe.util.image.ImageStrategy.choosePreferredImage; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.graphics.Bitmap; -import android.util.Log; - -import androidx.annotation.DrawableRes; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.core.graphics.BitmapCompat; - -import com.squareup.picasso.Cache; -import com.squareup.picasso.LruCache; -import com.squareup.picasso.OkHttp3Downloader; -import com.squareup.picasso.Picasso; -import com.squareup.picasso.RequestCreator; -import com.squareup.picasso.Transformation; - -import org.schabi.newpipe.R; -import org.schabi.newpipe.extractor.Image; - -import java.io.File; -import java.util.List; -import java.util.concurrent.TimeUnit; - -import okhttp3.OkHttpClient; - -public final class PicassoHelper { - private static final String TAG = PicassoHelper.class.getSimpleName(); - private static final String PLAYER_THUMBNAIL_TRANSFORMATION_KEY = - "PICASSO_PLAYER_THUMBNAIL_TRANSFORMATION_KEY"; - - private PicassoHelper() { - } - - private static Cache picassoCache; - private static OkHttpClient picassoDownloaderClient; - - // suppress because terminate() is called in App.onTerminate(), preventing leaks - @SuppressLint("StaticFieldLeak") - private static Picasso picassoInstance; - - - public static void init(final Context context) { - picassoCache = new LruCache(10 * 1024 * 1024); - picassoDownloaderClient = new OkHttpClient.Builder() - .cache(new okhttp3.Cache(new File(context.getExternalCacheDir(), "picasso"), - 50L * 1024L * 1024L)) - // this should already be the default timeout in OkHttp3, but just to be sure... - .callTimeout(15, TimeUnit.SECONDS) - .build(); - - picassoInstance = new Picasso.Builder(context) - .memoryCache(picassoCache) // memory cache - .downloader(new OkHttp3Downloader(picassoDownloaderClient)) // disk cache - .defaultBitmapConfig(Bitmap.Config.RGB_565) - .build(); - } - - public static void cancelTag(final Object tag) { - picassoInstance.cancelTag(tag); - } - - public static void setIndicatorsEnabled(final boolean enabled) { - picassoInstance.setIndicatorsEnabled(enabled); // useful for debugging - } - - public static RequestCreator loadThumbnail(@NonNull final List images) { - return loadImageDefault(images, R.drawable.placeholder_thumbnail_video); - } - - public static RequestCreator loadScaledDownThumbnail(final Context context, - @NonNull final List images) { - // scale down the notification thumbnail for performance - return loadThumbnail(images) - .transform(new Transformation() { - @Override - public Bitmap transform(final Bitmap source) { - if (DEBUG) { - Log.d(TAG, "Thumbnail - transform() called"); - } - - final float notificationThumbnailWidth = Math.min( - context.getResources() - .getDimension(R.dimen.player_notification_thumbnail_width), - source.getWidth()); - - final Bitmap result = BitmapCompat.createScaledBitmap( - source, - (int) notificationThumbnailWidth, - (int) (source.getHeight() - / (source.getWidth() / notificationThumbnailWidth)), - null, - true); - - if (result == source || !result.isMutable()) { - // create a new mutable bitmap to prevent strange crashes on some - // devices (see #4638) - final Bitmap copied = BitmapCompat.createScaledBitmap( - source, - (int) notificationThumbnailWidth - 1, - (int) (source.getHeight() / (source.getWidth() - / (notificationThumbnailWidth - 1))), - null, - true); - source.recycle(); - return copied; - } else { - source.recycle(); - return result; - } - } - - @Override - public String key() { - return PLAYER_THUMBNAIL_TRANSFORMATION_KEY; - } - }); - } - - @Nullable - public static Bitmap getImageFromCacheIfPresent(@NonNull final String imageUrl) { - // URLs in the internal cache finish with \n so we need to add \n to image URLs - return picassoCache.get(imageUrl + "\n"); - } - - - private static RequestCreator loadImageDefault(@NonNull final List images, - @DrawableRes final int placeholderResId) { - return loadImageDefault(choosePreferredImage(images), placeholderResId); - } - - private static RequestCreator loadImageDefault(@Nullable final String url, - @DrawableRes final int placeholderResId) { - return loadImageDefault(url, placeholderResId, true); - } - - private static RequestCreator loadImageDefault(@Nullable final String url, - @DrawableRes final int placeholderResId, - final boolean showPlaceholderWhileLoading) { - // if the URL was chosen with `choosePreferredImage` it will be null, but check again - // `shouldLoadImages` in case the URL was chosen with `imageListToDbUrl` (which is the case - // for URLs stored in the database) - if (isNullOrEmpty(url) || !ImageStrategy.shouldLoadImages()) { - return picassoInstance - .load((String) null) - .placeholder(placeholderResId) // show placeholder when no image should load - .error(placeholderResId); - } else { - final RequestCreator requestCreator = picassoInstance - .load(url) - .error(placeholderResId); - if (showPlaceholderWhileLoading) { - requestCreator.placeholder(placeholderResId); - } - return requestCreator; - } - } -} diff --git a/app/src/main/res/values-ar-rLY/strings.xml b/app/src/main/res/values-ar-rLY/strings.xml index 077cf1106ca..290d9f6ab01 100644 --- a/app/src/main/res/values-ar-rLY/strings.xml +++ b/app/src/main/res/values-ar-rLY/strings.xml @@ -302,7 +302,6 @@ %s مشارك جلب البيانات الوصفية… - إظهار مؤشرات الصور انقر للتنزيل %s تعطيل الوضع السريع , @@ -830,7 +829,6 @@ لقد اشتركت الآن في هذه القناة بدءًا من Android 10، يتم دعم \"Storage Access Framework\" فقط إنشاء اسم فريد - أظهر أشرطة ملونة لبيكاسو أعلى الصور تشير إلى مصدرها: الأحمر للشبكة والأزرق للقرص والأخضر للذاكرة فشل الاتصال الآمن يتوفر هذا الفيديو فقط لأعضاء YouTube Music Premium، لذلك لا يمكن بثه أو تنزيله من قبل NewPipe. البث السابق diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 82173d75802..902fe8c3a22 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -674,8 +674,6 @@ معاينة مصغرة على شريط التمرير وضع علامة على تمت مشاهدته أُعجب بها منشئ المحتوى - أظهر أشرطة ملونة لبيكاسو أعلى الصور تشير إلى مصدرها: الأحمر للشبكة والأزرق للقرص والأخضر للذاكرة - إظهار مؤشرات الصور اقتراحات البحث عن بعد اقتراحات البحث المحلية اسحب العناصر لإزالتها diff --git a/app/src/main/res/values-az/strings.xml b/app/src/main/res/values-az/strings.xml index 66bfe75dee9..9c9c15c964e 100644 --- a/app/src/main/res/values-az/strings.xml +++ b/app/src/main/res/values-az/strings.xml @@ -505,8 +505,6 @@ Məlumat əldə edilir… Elementlərdə orijinal əvvəlki vaxtı göstər Yaşam dövrəsi xaricindəki xətaları bildir - Şəkil göstəricilərini göstər - Şəkillərin üzərində mənbəsini göstərən Picasso rəngli lentləri göstər: şəbəkə üçün qırmızı, disk üçün mavi və yaddaş üçün yaşıl Bəzi endirmələri dayandırmaq mümkün olmasa da, mobil dataya keçərkən faydalıdır Bağla Fayl silindiyi üçün irəliləyiş itirildi diff --git a/app/src/main/res/values-be/strings.xml b/app/src/main/res/values-be/strings.xml index dceaaf6c560..5ddf30c2a5e 100644 --- a/app/src/main/res/values-be/strings.xml +++ b/app/src/main/res/values-be/strings.xml @@ -630,8 +630,6 @@ Перайсці на вэбсайт Правядзіце пальцам па элементах, каб выдаліць іх Адмяніць пастаянную мініяцюру - Паказаць індыкатары выявы - Паказваць каляровыя стужкі Пікаса на выявах, якія пазначаюць іх крыніцу: чырвоная для сеткі, сіняя для дыска і зялёная для памяці Апрацоўка стужкі… Вам будзе прапанавана, дзе захоўваць кожную спампоўку Загрузка стужкі… diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index bc235446c3d..9b8c06bc581 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -539,7 +539,6 @@ Това видео е с възрастова граница. \n \nВключете „%1$s“ в настройките ако искате да го пуснете. - Показвай цветни Picasso-панделки в горната част на изображенията като индикатор за техния произход (червен – от мрежата, син – от диска и червен – от паметта) Автоматична (тази на устройството) Мащабиране на миниатюрата в известието от 16:9 към 1:1 формат (възможни са изкривявания) Избете плейлист diff --git a/app/src/main/res/values-bn/strings.xml b/app/src/main/res/values-bn/strings.xml index 853b04b64f7..8fe38988a56 100644 --- a/app/src/main/res/values-bn/strings.xml +++ b/app/src/main/res/values-bn/strings.xml @@ -589,7 +589,6 @@ নতুন ধারা কম্পাঙ্ক দেখো পূর্বদর্শন রেখার মাধ্যমে প্রাকদর্শন - ছবিরূপ সূচক দেখাও দেখিও না যেকোনো নেটওয়ার্ক পরেরটা ক্রমে রাখা হয়েছে diff --git a/app/src/main/res/values-ca/strings.xml b/app/src/main/res/values-ca/strings.xml index 871af187b25..dd08e352638 100644 --- a/app/src/main/res/values-ca/strings.xml +++ b/app/src/main/res/values-ca/strings.xml @@ -625,7 +625,6 @@ No mostris Baixa qualitat (més petit) Alta qualitat (més gran) - Mostra indicadors de la imatge Desactiva l\'entunelament del contingut si en els videos hi ha una pantalla negre o tartamudegen Mostra detalls del canal No s\'ha establert una carpeta de descàrregues, selecciona la carpeta per defecte ara @@ -669,7 +668,6 @@ Comentari fixat Mostra \"Força el tancament del reproductor\" Mostra una opció de fallada quan s\'utilitza el reproductor - Mostra les cintes de color Picasso a la part superior de les imatges que indiquen la seva font: vermell per a la xarxa, blau per al disc i verd per a la memòria El LeakCanary no està disponible Comprovant freqüència Es necesita una conexió a Internet diff --git a/app/src/main/res/values-ckb/strings.xml b/app/src/main/res/values-ckb/strings.xml index e6e375a4cc6..d14449cf1cf 100644 --- a/app/src/main/res/values-ckb/strings.xml +++ b/app/src/main/res/values-ckb/strings.xml @@ -631,8 +631,6 @@ پیشان نەدرێت کواڵێتی نزم (بچووکتر) کواڵێتی بەرز (گەورەتر) - پیشاندانی شریتە ڕەنگکراوەکانی پیکاسۆ لەسەرووی وێنەکانەوە بۆ بەدیار خستنی سەرچاوەکانیان : سوور بۆ تۆڕ ، شین بۆ دیسک و سەوز بۆ بیرگە - پیشاندانی دیارخەرەکانی وێنە پێشنیازکراوەکانی گەڕانی ڕیمۆت پێشنیازکراوەکانی گەڕانی نێوخۆیی دیارکردن وەک بینراو diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 34537446cce..e6263f6e021 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -654,8 +654,6 @@ %s stahování dokončena %s stahováních dokončeno - Zobrazit barevné pásky Picasso na obrázcích označujících jejich zdroj: červená pro síť, modrá pro disk a zelená pro paměť - Zobrazit indikátory obrázků Vzdálené návrhy vyhledávání Lokální návrhy vyhledávání Pokud je vypnuté automatické otáčení, nespouštět video v mini přehrávači, ale přepnout se přímo do režimu celé obrazovky. Do mini přehrávače se lze i nadále dostat ukončením režimu celé obrazovky diff --git a/app/src/main/res/values-da/strings.xml b/app/src/main/res/values-da/strings.xml index 601bc37523d..cbb59d591ed 100644 --- a/app/src/main/res/values-da/strings.xml +++ b/app/src/main/res/values-da/strings.xml @@ -516,7 +516,6 @@ Behandler… Det kan tage et øjeblik Vis hukommelseslækager Deaktivér medietunneling - Vis billedindikatorer Netværkskrav Alle netværk Kontrolfrekvens @@ -695,7 +694,6 @@ Ofte stillede spørgsmål Hvis du har problemer med at bruge appen, bør du tjekke disse svar på almindelige spørgsmål! Se på webside - Vis Picasso-farvede bånd oven på billeder, der angiver deres kilde: rød for netværk, blå for disk og grøn for hukommelse Du kører den nyeste version af NewPipe Pga. ExoPlayer-begrænsninger blev søgevarigheden sat til %d sekunder Vis kun ikke-grupperede abonnementer diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index fcc38bf0bc0..028ff86cac5 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -637,8 +637,6 @@ Aus Als gesehen markieren Vom Ersteller mit Herz versehen - Farbige Picasso-Bänder über den Bildern anzeigen, die deren Quelle angeben: rot für Netzwerk, blau für Festplatte und grün für Speicher - Bildindikatoren anzeigen Entfernte Suchvorschläge Lokale Suchvorschläge diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index 6e9525459ae..58a70c270b6 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -634,8 +634,6 @@ Προεπισκόπηση στην μπάρα αναζήτησης Σήμανση ως αναπαραχθέν Επισημάνθηκε από τον δημιουργό - Εμφάνιση χρωματιστής κορδέλας πάνω στις εικόνες, που δείχνει την πηγή τους: κόκκινη για δίκτυο, μπλε για δίσκο και πράσινο για μνήμη - Εμφάνιση δεικτών εικόνων Προτάσεις απομακρυσμένης αναζήτησης Προτάσεις τοπικής αναζήτησης diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index c7b780a1f05..a44c7293785 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -647,8 +647,6 @@ Los comentarios están deshabilitados De corazón por el creador Marcar como visto - Mostrar cintas de colores Picasso encima de las imágenes indicando su origen: rojo para la red, azul para el disco y verde para la memoria - Mostrar indicadores de imagen Sugerencias de búsqueda remota Sugerencias de búsqueda local diff --git a/app/src/main/res/values-et/strings.xml b/app/src/main/res/values-et/strings.xml index 1d3fcdcb8a8..0e6e082c993 100644 --- a/app/src/main/res/values-et/strings.xml +++ b/app/src/main/res/values-et/strings.xml @@ -634,8 +634,6 @@ \n \nNii et valik taandub sellele, mida eelistad: kiirus või täpne teave. Märgi vaadatuks - Näita piltide kohal Picasso värvides riba, mis märgib pildi allikat: punane tähistab võrku, sinine kohalikku andmekandjat ja roheline kohalikku mälu - Näita piltide allikat Kaugotsingu soovitused Kohaliku otsingu soovitused Üksuse eemaldamiseks viipa diff --git a/app/src/main/res/values-eu/strings.xml b/app/src/main/res/values-eu/strings.xml index 6f94a8f625d..076b50d10a0 100644 --- a/app/src/main/res/values-eu/strings.xml +++ b/app/src/main/res/values-eu/strings.xml @@ -641,8 +641,6 @@ Deskarga amaituta %s Deskarga amaituta - Irudien gainean Picasso koloretako zintak erakutsi, jatorria adieraziz: gorria sarerako, urdina diskorako eta berdea memoriarako - Erakutsi irudi-adierazleak Urruneko bilaketaren iradokizunak Tokiko bilaketa-iradokizunak Ikusi gisa markatu diff --git a/app/src/main/res/values-fa/strings.xml b/app/src/main/res/values-fa/strings.xml index 2afeaf286a7..02ac369d744 100644 --- a/app/src/main/res/values-fa/strings.xml +++ b/app/src/main/res/values-fa/strings.xml @@ -597,7 +597,6 @@ رنگی کردن آگاهی گشودن با نشانه به عنوان دیده شده - نمایش روبان‌های رنگی پیکاسو در بالای تصویرها کهنشانگر منبعشان است: قرمز برای شبکه ، آبی برای دیسک و سبز برای حافظه درخواست از اندروید برای سفارشی‌سازی رنگ آگاهی براساس رنگ اصلی در بندانگشتی (توجّه داشته باشید که روی همهٔ افزاره‌ها در دسترس نیست) این ویدیو محدود به سن است. \n @@ -635,7 +634,6 @@ قلب‌شده به دست ایجادگر پیشنهادهای جست‌وجوی محلّی پیشنهادهای جست‌وجوی دوردست - نمایش نشانگرهای تصویر بارگیری پایان یافت %s بارگیری پایان یافتند diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index 67350d7ba2b..d72402e770d 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -634,8 +634,6 @@ Latauskansiota ei vielä asetettu, valitse ensin oletuslatauskansio Kommentit poistettu käytöstä Merkitse katsotuksi - Näytä Picasso-värjätyt nauhat kuvien päällä osoittaakseen lähteen: punainen tarkoittaa verkkoa, sininen tarkoittaa levytilaa ja vihreä tarkoittaa muistia - Näytä kuvailmaisimet Etähakuehdotukset Paikalliset hakuehdotukset Lisää seuraavaksi diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 66418e7cfea..f6a3d62850f 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -646,10 +646,8 @@ Prévisualisation de la barre de progression sur la miniature Marquer comme visionné Apprécié par le créateur - Afficher les indicateurs d’image Suggestions de recherche distante Suggestions de recherche locale - Affiche les rubans colorés de Picasso au-dessus des images indiquant leur source : rouge pour le réseau, bleu pour le disque et vert pour la mémoire %1$s téléchargement supprimé %1$s téléchargements supprimés diff --git a/app/src/main/res/values-gl/strings.xml b/app/src/main/res/values-gl/strings.xml index efe1b7f5ea3..4b087a88200 100644 --- a/app/src/main/res/values-gl/strings.xml +++ b/app/src/main/res/values-gl/strings.xml @@ -627,7 +627,6 @@ %s descargas finalizadas Miniatura na barra de busca - Mostrar indicadores de imaxe Desactive o túnel multimedia se experimentar unha pantalla en negro ou interrupcións na reprodución. Desactivar túnel multimedia Engadido á cola @@ -664,7 +663,6 @@ A partir do Android 10, só o \'Sistema de Acceso ao Almacenamento\' está soportado Procesando... Pode devagar un momento Crear unha notificación de erro - Amosar fitas coloridas de Picasso na cima das imaxes que indican a súa fonte: vermello para a rede, azul para o disco e verde para a memoria Novos elementos Predefinido do ExoPlayer Amosar \"Travar o reprodutor\" diff --git a/app/src/main/res/values-he/strings.xml b/app/src/main/res/values-he/strings.xml index befde2d5316..1da62fc757c 100644 --- a/app/src/main/res/values-he/strings.xml +++ b/app/src/main/res/values-he/strings.xml @@ -654,8 +654,6 @@ תמונה מוקטנת בסרגל הנגינה סומן בלב על ידי היוצר סימון כנצפה - הצגת סרטים בסגנון פיקאסו בראש התמונות לציון המקור שלהם: אדום זה מהרשת, כחול מהכונן וירוק מהזיכרון - הצגת מחווני תמונות הצעות חיפוש מרוחקות הצעות חיפוש מקומיות diff --git a/app/src/main/res/values-hi/strings.xml b/app/src/main/res/values-hi/strings.xml index 51455fafbbd..6e185156d74 100644 --- a/app/src/main/res/values-hi/strings.xml +++ b/app/src/main/res/values-hi/strings.xml @@ -570,7 +570,6 @@ कतारबद्ध हुआ स्ट्रीम विवरण लोड हो रहे हैं… प्रोसेस हो रहा है… कुछ समय लग सकता है - छवि संकेतक दिखाएं प्लेयर का उपयोग करते समय क्रैश विकल्प दिखाता है नई स्ट्रीमों के लिए जांच चलाएं एक त्रुटि स्नैकबार दिखाएं @@ -668,7 +667,6 @@ लीक-कैनरी उपलब्ध नहीं है एक त्रुटी हुई है, नोटीफिकेशन देखें यदि वीडियो प्लेबैक पर आप काली स्क्रीन या रुक-रुक कर वीडियो चलने का अनुभव करते हैं तो मीडिया टनलिंग को अक्षम करें। - छवियों के शीर्ष पर पिकासो रंगीन रिबन दिखाएँ जो उनके स्रोत को दर्शाता है: नेटवर्क के लिए लाल, डिस्क के लिए नीला और मेमोरी के लिए हरा त्रुटी की नोटीफिकेशन बनाएं इस डाउनलोड को पुनर्प्राप्त नहीं किया जा सकता अभी तक कोई डाउनलोड फ़ोल्डर सेट नहीं किया गया है, अब डिफ़ॉल्ट डाउनलोड फ़ोल्डर चुनें diff --git a/app/src/main/res/values-hr/strings.xml b/app/src/main/res/values-hr/strings.xml index 419f4619ed6..3a945bba0ee 100644 --- a/app/src/main/res/values-hr/strings.xml +++ b/app/src/main/res/values-hr/strings.xml @@ -646,7 +646,6 @@ %s pruža ovaj razlog: Obrada u tijeku … Može malo potrajati Za ukljanjanje stavki povuci ih - Prikaži indikatore slike Preuzimanje je gotovo %s preuzimanja su gotova @@ -655,7 +654,6 @@ Pokreni glavni player u cjeloekranskom prikazu Dodaj u popis kao sljedeći Dodano u popis kao sljedeći - Prikaži Picassove vrpce u boji na slikama koje označavaju njihov izvor: crvena za mrežu, plava za disk i zelena za memoriju Izbrisano %1$s preuzimanje Izbrisana %1$s preuzimanja diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 5a402c94c2e..f867041485c 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -570,7 +570,6 @@ Az eltávolítás utáni, fragment vagy activity életcikluson kívüli, nem kézbesíthető Rx kivételek jelentésének kényszerítése Eredeti „ennyi ideje” megjelenítése az elemeken Tiltsa le a médiacsatornázást, ha fekete képernyőt vagy akadozást tapasztal videólejátszáskor. - Picasso színes szalagok megjelenítése a képek fölött, megjelölve a forrásukat: piros a hálózathoz, kék a lemezhez, zöld a memóriához Minden letöltésnél meg fogja kérdezni, hogy hova mentse el Válasszon egy példányt Lista legutóbbi frissítése: %s @@ -657,7 +656,6 @@ \nBiztos benne\? Ez nem vonható vissza! A szolgáltatásokból származó eredeti szövegek láthatók lesznek a közvetítési elemeken Lejátszó összeomlasztása - Képjelölők megjelenítése A „lejátszó összeomlasztása” lehetőség megjelenítése Megjeleníti az összeomlasztási lehetőséget a lejátszó használatakor Hangmagasság megtartása (torzítást okozhat) diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml index 71900400eb3..9a6472692f2 100644 --- a/app/src/main/res/values-in/strings.xml +++ b/app/src/main/res/values-in/strings.xml @@ -631,13 +631,11 @@ Disukai oleh kreator Saran pencarian lokal Saran pencarian remote - Tampilkan indikator gambar Menghapus %1$s unduhan tambahkan ke selanjutnya telah ditambahkan ke selanjutnya - Tampilkan Ribon bewarna Picasso di atas gambar yang mengindikasikan asalnya: merah untuk jaringan, biru untuk disk dan hijau untuk memori Jangan memulai memutar video di mini player, tapi nyalakan langsung di mode layar penuh, jika rotasi otomatis terkunci. Anda tetap dapat mengakses mini player dengan keluar dari layar penuh Memproses… Mungkin butuh waktu sebentar Periksa Pembaruan diff --git a/app/src/main/res/values-is/strings.xml b/app/src/main/res/values-is/strings.xml index ed5ebe99bdb..d921cfac0e0 100644 --- a/app/src/main/res/values-is/strings.xml +++ b/app/src/main/res/values-is/strings.xml @@ -657,8 +657,6 @@ Upprunalegir textar frá þjónustu verða sýnilegir í atriðum Slökkva á fjölmiðlagöngum Slökktu á fjölmiðlagöngum ef þú finnur fyrir svörtum skjá eða stami við spilun myndbandar - Sýna myndvísa - Sýna Picasso litaða borða ofan á myndum sem gefa til kynna uppruna þeirra: rauðan fyrir netið, bláan fyrir disk og grænan fyrir minni Sýna „Hrynja spilara“ Sýna valkost til að hrynja spilara Hrynja forrit diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 2a5ac16d39e..9d1c4bc0b6e 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -644,8 +644,6 @@ Commenti disattivati Apprezzato dall\'autore Segna come visto - Mostra gli indicatori colorati Picasso sopra le immagini, per indicare la loro fonte: rosso per la rete, blu per il disco e verde per la memoria - Mostra indicatori immagine Suggerimenti di ricerca remoti Suggerimenti di ricerca locali diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 74924125a2a..7e7cf83a236 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -634,8 +634,6 @@ %s つのダウンロードが完了しました - ピカソは、画像の上に、画像の出所を識別する色彩記章を表示します: 赤はネットワーク、青はディスク、緑はメモリ - 画像に標識を表示 処理中… 少し時間がかかるかもしれません 新しいバージョンを手動で確認します アップデートを確認中… diff --git a/app/src/main/res/values-ka/strings.xml b/app/src/main/res/values-ka/strings.xml index ecb2a8495b7..4344c245d2c 100644 --- a/app/src/main/res/values-ka/strings.xml +++ b/app/src/main/res/values-ka/strings.xml @@ -384,7 +384,6 @@ ორიგინალური ტექსტები სერვისებიდან ხილული იქნება ნაკადის ერთეულებში მედია გვირაბის გათიშვა გამორთეთ მედია გვირაბი, თუ ვიდეოს დაკვრისას შავი ეკრანი ან ჭუჭყი გაქვთ - გამოსახულების ინდიკატორების ჩვენება აჩვენე \"დამკვრელის დამსხვრევა\" აჩვენებს ავარიის ვარიანტს დამკვრელის გამოყენებისას გაუშვით შემოწმება ახალი ნაკადებისთვის @@ -683,7 +682,6 @@ გამოწერების იმპორტი ვერ მოხერხდა შეატყობინეთ სასიცოცხლო ციკლის შეცდომებს იძულებითი მოხსენება შეუსაბამო Rx გამონაკლისების შესახებ ფრაგმენტის ან აქტივობის სასიცოცხლო ციკლის გარეთ განკარგვის შემდეგ - აჩვენეთ პიკასოს ფერადი ლენტები სურათების თავზე, სადაც მითითებულია მათი წყარო: წითელი ქსელისთვის, ლურჯი დისკისთვის და მწვანე მეხსიერებისთვის სწრაფი კვების რეჟიმი ამაზე მეტ ინფორმაციას არ იძლევა. „%s“-ის არხის ჩატვირთვა ვერ მოხერხდა. ხელმისაწვდომია ზოგიერთ სერვისში, როგორც წესი, ბევრად უფრო სწრაფია, მაგრამ შეიძლება დააბრუნოს შეზღუდული რაოდენობის ელემენტი და ხშირად არასრული ინფორმაცია (მაგ. ხანგრძლივობის გარეშე, ელემენტის ტიპი, არ არის ლაივის სტატუსი) diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 939d97441ba..5d5dfa0239e 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -545,8 +545,6 @@ 미디어 터널링 비활성화 서비스의 원본 텍스트가 스트림 항목에 표시됩니다 동영상 재생 시 검은 화면이 나타나거나 끊김 현상이 발생하면 미디어 터널링을 비활성화하세요. - 이미지 표시기 표시 - 원본을 나타내는 이미지 위에 피카소 컬러 리본 표시: 네트워크는 빨간색, 디스크는 파란색, 메모리는 녹색 \"플레이어 충돌\" 표시 플레이어를 사용할 때 충돌 옵션을 표시합니다 새로운 스트림 확인 실행 diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index c68e49bdd62..2294a357dfe 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -644,8 +644,6 @@ Nerodyti Širdelė nuo kurėjo Pažymėti kaip peržiūrėtą - Rodyti „Picasso“ spalvotas juosteles ant vaizdų, nurodančių jų šaltinį: raudona tinklui, mėlyna diskui ir žalia atmintis - Rodyti vaizdo indikatorius Nuotolinės paieškos pasiūlymai Vietinės paieškos pasiūlymai diff --git a/app/src/main/res/values-lv/strings.xml b/app/src/main/res/values-lv/strings.xml index 58b9a9d7623..a28d3e6073f 100644 --- a/app/src/main/res/values-lv/strings.xml +++ b/app/src/main/res/values-lv/strings.xml @@ -625,12 +625,10 @@ Nesākt video atskaņošanu samazinātā režīmā, bet pilnekrāna režīmā, ja automātiskā rotācija ir izslēgta Izslēgt multivides tuneļošanu Izslēdziet multivides tuneļošanu, ja jums video atskaņošanas laikā parādās melns ekrāns vai aizķeršanās - Rādīt krāsainas lentes virs attēliem, norādot to avotu: sarkana - tīkls, zila - disks, zaļa - atmiņa Ieslēgt teksta atlasīšanu video aprakstā Lejupielādes mape vēl nav iestatīta, izvēlieties noklusējuma lejupielādes mapi Pārvelciet objektus, lai tos noņemtu Lokālie meklēšanas ieteikumi - Rādīt attēlu indikatorus Augstas kvalitātes (lielāks) Pārbaudīt atjauninājumus Manuāli pārbaudīt, vai ir atjauninājumi diff --git a/app/src/main/res/values-ml/strings.xml b/app/src/main/res/values-ml/strings.xml index c439593f7c8..ee4b88a41d3 100644 --- a/app/src/main/res/values-ml/strings.xml +++ b/app/src/main/res/values-ml/strings.xml @@ -595,7 +595,6 @@ രണ്ടാം പ്രവർത്തന ബട്ടൺ ആദ്യ പ്രവർത്തന ബട്ടൺ വീഡിയോ കാണുമ്പോൾ കറുത്ത സ്ക്രീൻ, അവ്യക്തത അനുഭവിക്കുന്നു എങ്കിൽ മീഡിയ ട്യൂൺലിങ് പ്രവർത്തനരഹിതമാക്കുക - ഉറവിടം തിരിച്ചറിയാൻ പിക്കാസോ കളർഡ് റിബൺ ചിത്രങ്ങളുടെ മുകളിൽ കാണിക്കുക: നെറ്റ്‌വർക്കിന് ചുവപ്പ്, ഡിസ്കിനു നീല, മെമ്മറിയിക്ക് പച്ച സീക്ബാർ ചെറുചിത്രം പ്രദർശനം സ്നേഹത്തോടെ സൃഷ്ടാവ് ഡിസ്ക്രിപ്ഷനിലെ ടെക്സ്റ്റ്‌ സെലക്ട്‌ ചെയ്യുവാൻ അനുവദിക്കാതെ ഇരിക്കുക @@ -630,7 +629,6 @@ കാണിക്കരുത് കുറഞ്ഞ നിലവാരം (ചെറുത് ) ഉയർന്ന നിലവാരം (വലിയത് ) - ഇമേജ് ഇൻഡിക്കേറ്ററുകൾ കാണിക്കുക മീഡിയ ട്യൂൺലിങ് പ്രവർത്തനരഹിതമാക്കുക ഡൌൺലോഡ് ഫോൾഡർ ഇത് വരെയും സെറ്റ് ചെയ്തിട്ടില്ല, സ്ഥിര ഡൌൺലോഡ് ഫോൾഡർ ഇപ്പോൾ തിരഞ്ഞെക്കുക അഭിപ്രായങ്ങൾ പ്രവർത്തനരഹിതമായിരിക്കുന്നു diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml index 416ebfd025b..7acf7f4cd78 100644 --- a/app/src/main/res/values-nb-rNO/strings.xml +++ b/app/src/main/res/values-nb-rNO/strings.xml @@ -644,9 +644,7 @@ Lokale søkeforslag Marker som sett Ikke start videoer i minispilleren, men bytt til fullskjermsmodus direkte dersom auto-rotering er låst. Du har fremdeles tilgang til minispilleren ved å avslutte fullskjermsvisningen - Vis Picasso-fargede bånd på toppen av bilder for å indikere kilde: Rød for nettverk, blå for disk, og grønn for minne Hjertemerket av skaperen - Vis bildeindikatorer Dra elementer for å fjerne dem Start hovedspiller i fullskjerm Still i kø neste diff --git a/app/src/main/res/values-nl-rBE/strings.xml b/app/src/main/res/values-nl-rBE/strings.xml index 637eb1751e6..c744de62c25 100644 --- a/app/src/main/res/values-nl-rBE/strings.xml +++ b/app/src/main/res/values-nl-rBE/strings.xml @@ -611,7 +611,6 @@ Geen download map ingesteld, kies nu de standaard download map Niet tonen Reacties zijn uitgeschakeld - Toon afbeeldingsindicatoren Speler melding Configureer actieve stream melding Meldingen diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index b4629a03f62..26e328ed4df 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -632,8 +632,6 @@ Lage kwaliteit (kleiner) Hoge kwaliteit (groter) Zoekbalk miniatuurafbeelding voorbeeld - Toon Picasso-gekleurde linten bovenop afbeeldingen die hun bron aangeven: rood voor netwerk, blauw voor schijf en groen voor geheugen - Afbeeldings­indicatoren tonen Reacties zijn uitgeschakeld Zoeksuggesties op afstand Lokale zoeksuggesties diff --git a/app/src/main/res/values-nqo/strings.xml b/app/src/main/res/values-nqo/strings.xml index 94e7ae2f49b..f1960b980aa 100644 --- a/app/src/main/res/values-nqo/strings.xml +++ b/app/src/main/res/values-nqo/strings.xml @@ -440,8 +440,6 @@ ߗߋߢߊߟߌ ߟߎ߬ ߞߟߏߜߍ߫ ߓߐߛߎ߲ߡߊ ߟߎ߬ ߦߌ߬ߘߊ߬ߕߐ߫ ߟߋ߬ ߟߊ߬ߖߍ߲߬ߛߍ߲߬ߠߌ߲ ߘߐ߫ ߞߋߟߋߞߋߟߋ ߟߊ߫ ߝߊߟߊ߲ߓߍߦߊ ߟߊߛߊ߬ ߞߋߟߋߞߋߟߋ ߟߊ߫ ߝߊߟߊ߲ߓߍߦߊ ߟߊߛߊ߬ ߣߴߌ ߞߊ߬ ߥߊ߲߬ߊߥߊ߲߬ ߝߌ߲ ߦߋ߫ ߥߟߊ߫ ߜߊߘߊ߲ߜߊߘߊ߲ߠߌ߲ ߦߋߡߍ߲ߕߊ ߘߏ߫ ߘߐߛߊߙߌ߫ ߕߎߡߊ - ߞߊ߬ ߖߌ߬ߦߊ߬ߓߍ߫ ߦߌ߬ߘߊ߬ߟߊ߲ ߠߎ߫ ߝߍ߲߬ߛߍ߲߫ - ߏ߬ ߦߋ߫ ߔߌߛߊߞߏ߫ ߟߊ߫ ߡߙߎߝߋ߫ ߞߟߐ߬ߡߊ ߟߎ߫ ߟߋ߬ ߝߍ߲߬ߛߍ߲߬ ߠߊ߫ ߖߌ߬ߦߊ߬ߓߍ ߟߎ߫ ߞߎ߲߬ߘߐ߫ ߞߵߊ߬ߟߎ߬ ߓߐߛߎ߲ ߦߌ߬ߘߊ߬: ߥߎߟߋ߲߬ߡߊ߲ ߦߋ߫ ߞߙߏ߬ߝߏ ߕߊ ߘߌ߫߸ ߓߊ߯ߡߊ ߦߋ߫ ߝߘߍ߬ ߜߍߟߍ߲ ߕߊ ߘߌ߫ ߊ߬ߣߌ߫ ߝߙߌߛߌߡߊ ߦߋ߫ ߦߟߌߕߏߟߊ߲ ߕߊ ߘߌ߫ ߟߊ߬ߓߐ߬ߟߌ ߦߴߌߘߐ߫… ߞߵߊ߬ ߘߊߡߌ߬ߣߊ߬ ߞߊ߲߬ߞߎߡߊ ߟߎ߬ ߟߊߛߊ߬ߣߍ߲ ߠߋ߬ diff --git a/app/src/main/res/values-or/strings.xml b/app/src/main/res/values-or/strings.xml index f9faa8324db..59a6a739abe 100644 --- a/app/src/main/res/values-or/strings.xml +++ b/app/src/main/res/values-or/strings.xml @@ -342,7 +342,6 @@ ସେବାଗୁଡିକରୁ ମୂଳ ଲେଖା ଷ୍ଟ୍ରିମ୍ ଆଇଟମ୍ ଗୁଡିକରେ ଦୃଶ୍ୟମାନ ହେବ ମିଡିଆ ଟନେଲିଂକୁ ଅକ୍ଷମ କରନ୍ତୁ ଯଦି ଆପଣ ଏକ କଳା ପରଦା ଅନୁଭବ କରନ୍ତି କିମ୍ବା ଭିଡିଓ ପ୍ଲେବେକ୍ ଉପରେ ଝୁଣ୍ଟି ପଡ଼ନ୍ତି ତେବେ ମିଡିଆ ଟନେଲିଂକୁ ଅକ୍ଷମ କରନ୍ତୁ । - ଚିତ୍ରଗୁଡ଼ିକର ଉପରେ ପିକାସୋ ରଙ୍ଗୀନ ଫିତା ଦେଖାନ୍ତୁ: ସେମାନଙ୍କର ଉତ୍ସକୁ ସୂଚାଇଥାଏ: ନେଟୱାର୍କ ପାଇଁ ନାଲି, ଡିସ୍କ ପାଇଁ ନୀଳ ଏବଂ ସ୍ମୃତି ପାଇଁ ସବୁଜ ଆମଦାନି କରନ୍ତୁ ଠାରୁ ଆମଦାନୀ କରନ୍ତୁ ଆମଦାନି… @@ -657,7 +656,6 @@ ଅଟୋ-ଜେନେରେଟ୍ (କୌଣସି ଅପଲୋଡର୍ ମିଳିଲା ନାହିଁ) ପୁରଣ କରନ୍ତୁ କ୍ୟାପସନ୍ - ପ୍ରତିଛବି ସୂଚକ ଦେଖାନ୍ତୁ ପ୍ଲେୟାର ବ୍ୟବହାର କରିବା ସମୟରେ ଏକ କ୍ରାସ୍ ବିକଳ୍ପ ଦେଖାଏ ନୂତନ ଷ୍ଟ୍ରିମ୍ ପାଇଁ ଯାଞ୍ଚ ଚଲାନ୍ତୁ ଆପ୍ କ୍ରାସ୍ କରନ୍ତୁ diff --git a/app/src/main/res/values-pa/strings.xml b/app/src/main/res/values-pa/strings.xml index 814cdb8851d..d612ff75b17 100644 --- a/app/src/main/res/values-pa/strings.xml +++ b/app/src/main/res/values-pa/strings.xml @@ -626,8 +626,6 @@ ਨਿਊਪਾਈਪ ਖਾਮੀ ਤੋਂ ਪ੍ਰਭਾਵਤ ਹੋਈ ਹੈ, ਇੱਥੇ ਨੱਪ ਕੇ ਰਿਪੋਰਟ ਕਰੋ ਇੱਕ ਖਾਮੀ ਪ੍ਰਭਾਵੀ ਹੋਈ ਹੈ, ਨੋਟੀਫੀਕੇਸ਼ਨ ਵੇਖੋ ਆਈਟਮਾਂ ਨੂੰ ਇੱਕ ਪਾਸੇ ਖਿੱਚ ਕੇ ਹਟਾਓ - ਦ੍ਰਿਸ਼ ਸੂਚਕ ਵਿਖਾਓ - ਦ੍ਰਿਸ਼ਾਂ ਦੇ ਉੱਪਰ ਉਹਨਾਂ ਦੀ ਸਰੋਤ-ਪਛਾਣ ਲਈ ਪਿਕਾਸੋ ਦੇ ਰੰਗਦਾਰ ਰਿਬਨ ਵਿਖਾਓ : ਨੈੱਟਵਰਕ ਲਈ ਲਾਲ, ਡਿਸਕ ਲਈ ਨੀਲੇ ਤੇ ਮੈਮਰੀ ਲਈ ਹਰੇ ਨਵੀਂ ਸਟ੍ਰੀਮ ਦੇ ਨੋਟੀਫਿਕੇਸ਼ਨ ਪਿੰਨ ਕੀਤੀ ਟਿੱਪਣੀ ਅੱਪਡੇਟ ਦੀ ਉਪਲੱਬਧਤਾ ਪਰਖੀ ਜਾ ਰਹੀ… diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 01f242cd9c7..b7c517ffc86 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -649,8 +649,6 @@ Nie pokazuj Serduszko od twórcy Oznacz jako obejrzane - Pokazuj kolorowe wstążki Picasso nad obrazami wskazujące ich źródło: czerwone dla sieci, niebieskie dla dysku i zielone dla pamięci - Pokazuj wskaźniki obrazu Zdalne podpowiedzi wyszukiwania Lokalne podpowiedzi wyszukiwania diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 5a203e0f25e..3d4b5762111 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -644,7 +644,6 @@ Os comentários estão desabilitados Marcar como assistido Curtido pelo criador - Exibir fitas coloridas no topo das imagens indicando sua fonte: vermelho para rede, azul para disco e verde para memória %1$s download excluído %1$s downloads excluídos @@ -655,7 +654,6 @@ %s downloads concluídos %s downloads concluídos - Mostrar indicadores de imagem Adicionado na próxima posição da fila Enfileira a próxima Deslize os itens para remove-los diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index 498a49a53bb..23310adec64 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -644,8 +644,6 @@ Ainda não foi definida uma pasta de descarregamento, escolha agora a pasta de descarregamento padrão Comentários estão desativados Marcar como visto - Mostrar fitas coloridas de Picasso em cima das imagens que indicam a sua fonte: vermelho para rede, azul para disco e verde para memória - Mostrar indicadores de imagem Sugestões de pesquisa remotas Sugestões de pesquisa locais diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 5534dbf0b54..99e5cbd040c 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -644,8 +644,6 @@ Baixa qualidade (menor) Alta qualidade (maior) Os comentários estão desativados - Mostrar fitas coloridas de Picasso em cima das imagens que indicam a sua fonte: vermelho para rede, azul para disco e verde para memória - Mostrar indicadores de imagem Sugestões de pesquisa remotas Sugestões de pesquisa locais diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index bcef4d9524f..a5eb2114328 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -660,8 +660,6 @@ Calitate scăzută (mai mică) Calitate înaltă (mai mare) Miniatură de previzualizare în bara de derulare - Afișați panglici colorate de Picasso deasupra imaginilor, indicând sursa acestora: roșu pentru rețea, albastru pentru disc și verde pentru memorie - Afișați indicatorii de imagine Dezactivați tunelarea media dacă întâmpinați un ecran negru sau blocaje la redarea video. Procesarea.. Poate dura un moment Verifică dacă există actualizări diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 9e79b165fc8..667e5413dd2 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -652,8 +652,6 @@ Миниатюра над полосой прокрутки Автору видео понравилось это Пометить проигранным - Picasso: указать цветом источник изображений (красный — сеть, синий — диск, зелёный — память) - Цветные метки на изображениях Серверные предложения поиска Локальные предложения поиска diff --git a/app/src/main/res/values-ryu/strings.xml b/app/src/main/res/values-ryu/strings.xml index 5a4f35de5f9..e970950e0a2 100644 --- a/app/src/main/res/values-ryu/strings.xml +++ b/app/src/main/res/values-ryu/strings.xml @@ -646,8 +646,6 @@ %sちぬダウンロードぬかんりょうさびたん %sちぬダウンロードぬかんりょうさびたん - ピカソー、がぞうぬういに、がぞうくとぅどぅくるしーきびちするしきさいきしーょうひょうじさびーん: あかーネットワーク、あおーディスク、みどぅれーメモリ - やしがぞうんかいふぃいょうしきひょうじ しーょりちゅう… くーてーんじがんがかかいんかむしりやびらん みーさるバージョンしーゅどうでぃかくにんさびーん アップデートかくにんちゅう… diff --git a/app/src/main/res/values-sat/strings.xml b/app/src/main/res/values-sat/strings.xml index a5959086e46..9ede53a7691 100644 --- a/app/src/main/res/values-sat/strings.xml +++ b/app/src/main/res/values-sat/strings.xml @@ -270,7 +270,6 @@ LeakCanary ᱵᱟᱭ ᱧᱟᱢᱚᱜ ᱠᱟᱱᱟ ᱢᱮᱢᱚᱨᱤ ᱞᱤᱠᱟᱞ ᱢᱚᱱᱤᱴᱚᱨᱤᱝ ᱦᱤᱯ ᱰᱟᱢᱯᱤᱝ ᱚᱠᱛᱚ ᱨᱮ ᱮᱯᱞᱤᱠᱮᱥᱚᱱ ᱨᱟᱥᱴᱨᱤᱭ ᱦᱩᱭ ᱫᱟᱲᱮᱭᱟᱜ-ᱟ ᱡᱤᱭᱚᱱ ᱪᱤᱠᱤ ᱠᱷᱚᱱ ᱵᱟᱦᱨᱮ ᱨᱮ ᱵᱷᱮᱜᱟᱨ ᱠᱚ ᱚᱱᱚᱞ ᱢᱮ - ᱱᱮᱴᱣᱟᱨᱠ ᱞᱟᱹᱜᱤᱫ red, ᱰᱤᱥᱠ ᱞᱟᱹᱜᱤᱫ blue ᱟᱨ ᱢᱮᱢᱚᱨᱤ ᱞᱟᱹᱜᱤᱫ green ᱯᱞᱮᱭᱟᱨ ᱵᱮᱵᱷᱟᱨ ᱚᱠᱛᱮ ᱨᱮ ᱠᱨᱟᱥ ᱚᱯᱥᱚᱱ ᱧᱮᱞᱚᱜ ᱠᱟᱱᱟ ᱤᱢᱯᱳᱨᱴ ᱤᱢᱯᱚᱨᱴ @@ -540,7 +539,6 @@ ᱡᱤᱱᱤᱥ ᱠᱚᱨᱮᱱᱟᱜ ᱢᱩᱞ ᱚᱠᱛᱚ ᱧᱮᱞ ᱢᱮ ᱥᱮᱵᱟ ᱠᱷᱚᱱ ᱚᱨᱡᱤᱱᱤᱭᱟᱞ ᱴᱮᱠᱥᱴ ᱠᱚ ᱥᱴᱨᱤᱢ ᱤᱴᱮᱢ ᱨᱮ ᱧᱮᱞᱚᱜᱼᱟ ᱡᱩᱫᱤ ᱟᱢ ᱵᱷᱤᱰᱤᱭᱳ ᱯᱞᱮᱭᱚᱯ ᱨᱮ ᱵᱞᱮᱠ ᱥᱠᱨᱤᱱ ᱟᱨᱵᱟᱝ ᱠᱷᱟᱹᱞᱤ ᱥᱴᱮᱴᱞᱤᱝ ᱮᱢ ᱧᱟᱢᱟ ᱮᱱᱠᱷᱟᱱ ᱢᱤᱰᱤᱭᱟ ᱴᱩᱱᱮᱞᱤᱝ ᱵᱚᱫᱚᱞ ᱢᱮ ᱾ - ᱪᱤᱛᱟᱹᱨ ᱪᱤᱱᱦᱟᱹ ᱠᱚ ᱧᱮᱞ ᱢᱮ ᱱᱟᱣᱟ ᱥᱴᱨᱤᱢ ᱞᱟᱹᱜᱤᱫ ᱪᱟᱪᱞᱟᱣ ᱢᱮ ᱢᱤᱫ error notification ᱛᱮᱭᱟᱨ ᱢᱮ ᱥᱮᱞᱮᱫ ᱮᱠᱥᱯᱳᱨᱴ ᱵᱟᱝ ᱦᱩᱭ ᱫᱟᱲᱮᱭᱟᱜ ᱠᱟᱱᱟ diff --git a/app/src/main/res/values-sc/strings.xml b/app/src/main/res/values-sc/strings.xml index 6b89b32c3c1..fce5280e128 100644 --- a/app/src/main/res/values-sc/strings.xml +++ b/app/src/main/res/values-sc/strings.xml @@ -634,8 +634,6 @@ Sos cummentos sunt disabilitados Su creadore b\'at postu unu coro Marca comente pompiadu - Ammustra sos listrones colorados de Picasso in subra de sas immàgines chi indicant sa fonte issoro: ruja pro sa retze, biaita pro su discu e birde pro sa memòria - Ammustra sos indicadores de immàgines Impòsitos de chirca remota Impòsitos de chirca locales diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index e3aa5b6bce3..5c4210b71a9 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -653,8 +653,6 @@ Nízka kvalita (menšie) Vysoká kvalita (väčšie) Náhľad miniatúry pri vyhľadávaní - Zobrazí farebné pásiky Picasso na obrázkoch podľa ich zdroja: červený pre sieť, modrý pre disk a zelený pre pamäť - Zobraziť indikátory obrázka Potiahnutím vymazať Komentáre sú zakázané Ak je automatické otáčanie zablokované, nespustí videá v miniprehrávači, ale prepne sa do celoobrazovkového režimu. Do miniprehrávača sa dostanete po ukončení režimu celej obrazovky diff --git a/app/src/main/res/values-so/strings.xml b/app/src/main/res/values-so/strings.xml index e37c3a36d31..72e661a1b05 100644 --- a/app/src/main/res/values-so/strings.xml +++ b/app/src/main/res/values-so/strings.xml @@ -633,8 +633,6 @@ Fallooyinka waa laxidhay Kahelay soosaaraha Waan daawaday - Soo bandhig shaambado midabka Picasso leh sawirrada dushooda oo tilmaamaya isha laga keenay: guduud waa khadka, buluug waa kaydka gudaha, cagaar waa kaydka K/G - Tus tilmaamayaasha sawirka Soojeedinada raadinta banaanka Soojeedinada raadinta gudaha Cabirka soodaarida udhexeeya diff --git a/app/src/main/res/values-sr/strings.xml b/app/src/main/res/values-sr/strings.xml index 5f14a0e51c2..2300cd92979 100644 --- a/app/src/main/res/values-sr/strings.xml +++ b/app/src/main/res/values-sr/strings.xml @@ -644,7 +644,6 @@ Означи као одгледано Коментари су онемогућени Обрађивање… Може потрајати пар тренутака - Прикажи индикаторе слике Не покрећите видео снимке у мини-плејеру, већ директно пређите на режим целог екрана, ако је аутоматска ротација закључана. И даље можете приступити мини-плејеру тако што ћете изаћи из целог екрана Покрени главни плејер преко целог екрана Срушите плејер @@ -740,7 +739,6 @@ Обавештења за пријаву грешака Увезите или извезите праћења из менија са 3 тачке Аудио снимак - Прикажите Picasso обојене траке на врху слика које указују на њихов извор: црвена за мрежу, плава за диск и зелена за меморију Направите обавештење о грешци Проценат Користите најновију верзију NewPipe-а diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 8cf57f6054f..50948fd571e 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -633,7 +633,6 @@ Du kan välja det natt-tema du föredrar nedan Välj det natt-tema du föredrar — %s Sökradens förhandsvisningsminiatyr - Visa bildindikatorer Lokala sökningsförslag Tog bort %1$s nedladdning @@ -651,7 +650,6 @@ Svep objekt för att ta bort dem Förslag via fjärrsökning Starta inte videor i minispelaren, utan byt till helskärmsläge direkt, om automatisk rotation är låst. Du kan fortfarande komma åt minispelaren genom att gå ut ur helskärmsläge - Visa Picasso färgade band ovanpå bilderna som anger deras källa: rött för nätverk, blått för disk och grönt för minne Sök efter uppdateringar Kolla manuellt efter nya versioner Söker efter uppdateringar… diff --git a/app/src/main/res/values-te/strings.xml b/app/src/main/res/values-te/strings.xml index b2846823c94..90708580a1c 100644 --- a/app/src/main/res/values-te/strings.xml +++ b/app/src/main/res/values-te/strings.xml @@ -442,7 +442,6 @@ ప్లేబ్యాక్ స్పీడ్ నియంత్రణలు ఏమిలేదు మీరు బ్లాక్ స్క్రీన్ లేదా చలనచిత్రం ప్లేబ్యాక్‌లో అంతరాయాన్ని అనుభవిస్తే మీడియా టన్నెలింగ్‌ను నిలిపివేయండి - చిత్రాల మూలాన్ని సూచించే విధంగా వాటి పైభాగంలో పికాసో రంగు రిబ్బన్‌లను చూపండి: నెట్‌వర్క్ కోసం ఎరుపు, డిస్క్ కోసం నీలం మరియు మెమరీ కోసం ఆకుపచ్చ లోపం స్నాక్‌బార్‌ని చూపండి మీరు NewPipe యొక్క తాజా సంస్కరణను అమలు చేస్తున్నారు NewPipe నవీకరణ అందుబాటులో ఉంది! @@ -455,7 +454,6 @@ తక్కువ నాణ్యత (చిన్నది) చూపించవద్దు మీడియా టన్నెలింగ్‌ని నిలిపివేయండి - చిత్ర సూచికలను చూపు కొత్త స్ట్రీమ్‌ల కోసం తనిఖీని అమలు చేయండి ఎర్రర్ నోటిఫికేషన్‌ను సృష్టించండి దిగుమతి diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index adecbf3ffef..29933bdc673 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -633,8 +633,6 @@ Yorumlar devre dışı Yaratıcısınca kalplendi İzlendi olarak işaretle - Resimlerin üzerinde kaynaklarını gösteren Picasso renkli şeritler göster: ağ için kırmızı, disk için mavi ve bellek için yeşil - Resim göstergelerini göster Uzak arama önerileri Yerel arama önerileri diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index c347086093d..86350d40e96 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -646,8 +646,6 @@ Мініатюра з попереднім переглядом на повзунку поступу Вподобано автором Позначити переглянутим - Показувати кольорові стрічки Пікассо поверх зображень із зазначенням їх джерела: червоний для мережі, синій для диска та зелений для пам’яті - Показати індикатори зображень Віддалені пропозиції пошуку Локальні пошукові пропозиції diff --git a/app/src/main/res/values-vi/strings.xml b/app/src/main/res/values-vi/strings.xml index 0d71173afbc..15f5a86d472 100644 --- a/app/src/main/res/values-vi/strings.xml +++ b/app/src/main/res/values-vi/strings.xml @@ -624,8 +624,6 @@ Bình luận đã bị tắt Đã được chủ kênh thả \"thính\" Đánh dấu là đã xem - Hiển thị các dải băng màu Picasso trên đầu các hình ảnh cho biết nguồn của chúng: màu đỏ cho mạng, màu lam cho đĩa và màu lục cho bộ nhớ - Hiện dấu chỉ hình ảnh Đề xuất tìm kiếm trên mạng Đề xuất tìm kiếm cục bộ diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index fa8d31022cf..7b303621b9c 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -624,8 +624,6 @@ 高品质(较大) 被创作者喜爱 标记为已观看 - 在图像顶部显示毕加索彩带,指示其来源:红色代表网络,蓝色代表磁盘,绿色代表内存 - 显示图像指示器 远程搜索建议 本地搜索建议 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 518a1290fc5..9f581b43f59 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -668,9 +668,7 @@ 你係咪要刪除呢個谷? 淨係顯示未成谷嘅訂閱 - 啲圖都要騷 Picasso 三色碼顯示源頭:紅碼係網絡上高落嚟,藍碼係儲存喺磁碟本地,綠碼係潛伏喺記憶體中 服務原本嘅字會騷返喺串流項目上面 - 影像要推三色碼 若果播片嘅時候窒下窒下或者黑畫面,就停用多媒體隧道啦。 點樣用 Google 匯出嚟匯入 YouTube 訂閱: \n diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index c404edeca2b..a4ad3578f82 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -624,8 +624,6 @@ 拖動列縮圖預覽 被創作者加心號 標記為已觀看 - 在圖片頂部顯示畢卡索彩色絲帶,指示其來源:紅色代表網路、藍色代表磁碟、綠色代表記憶體 - 顯示圖片指示器 遠端搜尋建議 本機搜尋建議 diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index fb68a464d5a..e31cebb92ac 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -241,7 +241,6 @@ show_memory_leaks_key allow_disposed_exceptions_key show_original_time_ago_key - show_image_indicators_key show_crash_the_player_key check_new_streams crash_the_app_key diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 56140441cd0..bff35e5d9ea 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -486,8 +486,6 @@ Disable media tunneling Disable media tunneling if you experience a black screen or stuttering on video playback. Media tunneling was disabled by default on your device because your device model is known to not support it. - Show image indicators - Show Picasso colored ribbons on top of images indicating their source: red for network, blue for disk and green for memory Show \"Crash the player\" Shows a crash option when using the player Run check for new streams diff --git a/app/src/main/res/xml/debug_settings.xml b/app/src/main/res/xml/debug_settings.xml index 84bb281f31e..d97c5aa1a2b 100644 --- a/app/src/main/res/xml/debug_settings.xml +++ b/app/src/main/res/xml/debug_settings.xml @@ -34,13 +34,6 @@ app:singleLineTitle="false" app:iconSpaceReserved="false" /> - - Date: Sat, 22 Jun 2024 10:45:04 +0530 Subject: [PATCH 04/72] Enable RGB-565 for low-end devices --- app/src/main/java/org/schabi/newpipe/App.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/App.java b/app/src/main/java/org/schabi/newpipe/App.java index 5d92e90ac9d..68ae0ca53fa 100644 --- a/app/src/main/java/org/schabi/newpipe/App.java +++ b/app/src/main/java/org/schabi/newpipe/App.java @@ -1,5 +1,6 @@ package org.schabi.newpipe; +import android.app.ActivityManager; import android.app.Application; import android.content.Context; import android.content.SharedPreferences; @@ -8,6 +9,7 @@ import androidx.annotation.NonNull; import androidx.core.app.NotificationChannelCompat; import androidx.core.app.NotificationManagerCompat; +import androidx.core.content.ContextCompat; import androidx.preference.PreferenceManager; import com.jakewharton.processphoenix.ProcessPhoenix; @@ -123,6 +125,8 @@ public void onCreate() { @NonNull @Override public ImageLoader newImageLoader() { + final var isLowRamDevice = ContextCompat.getSystemService(this, ActivityManager.class) + .isLowRamDevice(); final var builder = new ImageLoader.Builder(this) .memoryCache(() -> new MemoryCache.Builder(this) .maxSizeBytes(10 * 1024 * 1024) @@ -131,7 +135,7 @@ public ImageLoader newImageLoader() { .directory(new File(getExternalCacheDir(), "coil")) .maxSizeBytes(50 * 1024 * 1024) .build()) - .allowRgb565(true); + .allowRgb565(isLowRamDevice); if (MainActivity.DEBUG) { builder.logger(new DebugLogger()); From f74402bc946407197b67092bdf09f00f29419bb3 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Sat, 22 Jun 2024 18:32:03 +0530 Subject: [PATCH 05/72] Added Coil helper method --- .../feed/notifications/NotificationHelper.kt | 27 +++++-------------- .../SeekbarPreviewThumbnailHolder.java | 2 +- .../external_communication/ShareUtils.java | 2 +- .../schabi/newpipe/util/image/CoilHelper.kt | 13 +++++---- 4 files changed, 17 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/feed/notifications/NotificationHelper.kt b/app/src/main/java/org/schabi/newpipe/local/feed/notifications/NotificationHelper.kt index 942094c0c40..659088ef2fd 100644 --- a/app/src/main/java/org/schabi/newpipe/local/feed/notifications/NotificationHelper.kt +++ b/app/src/main/java/org/schabi/newpipe/local/feed/notifications/NotificationHelper.kt @@ -14,16 +14,12 @@ import androidx.core.app.NotificationManagerCompat import androidx.core.app.PendingIntentCompat import androidx.core.content.ContextCompat import androidx.core.content.getSystemService -import androidx.core.graphics.drawable.toBitmapOrNull import androidx.preference.PreferenceManager -import coil.executeBlocking -import coil.imageLoader -import coil.request.ImageRequest import org.schabi.newpipe.R import org.schabi.newpipe.extractor.stream.StreamInfoItem import org.schabi.newpipe.local.feed.service.FeedUpdateInfo import org.schabi.newpipe.util.NavigationHelper -import org.schabi.newpipe.util.image.ImageStrategy +import org.schabi.newpipe.util.image.CoilHelper /** * Helper for everything related to show notifications about new streams to the user. @@ -68,24 +64,15 @@ class NotificationHelper(val context: Context) { summaryBuilder.setStyle(style) // open the channel page when clicking on the summary notification + val intent = NavigationHelper + .getChannelIntent(context, data.serviceId, data.url) + .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) summaryBuilder.setContentIntent( - PendingIntentCompat.getActivity( - context, - data.pseudoId, - NavigationHelper - .getChannelIntent(context, data.serviceId, data.url) - .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK), - 0, - false - ) + PendingIntentCompat.getActivity(context, data.pseudoId, intent, 0, false) ) - val request = ImageRequest.Builder(context) - .data(data.avatarUrl?.takeIf { ImageStrategy.shouldLoadImages() }) - .placeholder(R.drawable.ic_newpipe_triangle_white) - .error(R.drawable.ic_newpipe_triangle_white) - .build() - val avatarIcon = context.imageLoader.executeBlocking(request).drawable?.toBitmapOrNull() + val avatarIcon = + CoilHelper.loadBitmapBlocking(context, data.avatarUrl, R.drawable.ic_newpipe_triangle_white) summaryBuilder.setLargeIcon(avatarIcon) diff --git a/app/src/main/java/org/schabi/newpipe/player/seekbarpreview/SeekbarPreviewThumbnailHolder.java b/app/src/main/java/org/schabi/newpipe/player/seekbarpreview/SeekbarPreviewThumbnailHolder.java index c7c53b097e6..d09664aeb40 100644 --- a/app/src/main/java/org/schabi/newpipe/player/seekbarpreview/SeekbarPreviewThumbnailHolder.java +++ b/app/src/main/java/org/schabi/newpipe/player/seekbarpreview/SeekbarPreviewThumbnailHolder.java @@ -179,7 +179,7 @@ private Bitmap getBitMapFrom(final String url) { // Gets the bitmap within the timeout of 15 seconds imposed by default by OkHttpClient // Ensure that you are not running on the main thread, otherwise this will hang - final var bitmap = CoilHelper.INSTANCE.loadBitmap(App.getApp(), url); + final var bitmap = CoilHelper.INSTANCE.loadBitmapBlocking(App.getApp(), url); if (sw != null) { Log.d(TAG, "Download of bitmap for seekbarPreview from '" + url + "' took " diff --git a/app/src/main/java/org/schabi/newpipe/util/external_communication/ShareUtils.java b/app/src/main/java/org/schabi/newpipe/util/external_communication/ShareUtils.java index 3e93abf4db7..087345af51f 100644 --- a/app/src/main/java/org/schabi/newpipe/util/external_communication/ShareUtils.java +++ b/app/src/main/java/org/schabi/newpipe/util/external_communication/ShareUtils.java @@ -369,7 +369,7 @@ private static ClipData generateClipDataForImagePreview( @NonNull final Context context, @NonNull final String thumbnailUrl) { try { - final var bitmap = CoilHelper.INSTANCE.loadBitmap(context, thumbnailUrl); + final var bitmap = CoilHelper.INSTANCE.loadBitmapBlocking(context, thumbnailUrl); if (bitmap == null) { return null; } diff --git a/app/src/main/java/org/schabi/newpipe/util/image/CoilHelper.kt b/app/src/main/java/org/schabi/newpipe/util/image/CoilHelper.kt index 3977212bf60..62c60c92ebb 100644 --- a/app/src/main/java/org/schabi/newpipe/util/image/CoilHelper.kt +++ b/app/src/main/java/org/schabi/newpipe/util/image/CoilHelper.kt @@ -19,12 +19,15 @@ import org.schabi.newpipe.ktx.scale import kotlin.math.min object CoilHelper { - private const val TAG = "CoilHelper" + private val TAG = CoilHelper::class.java.simpleName - fun loadBitmap(context: Context, url: String): Bitmap? { - val request = ImageRequest.Builder(context) - .data(url) - .build() + @JvmOverloads + fun loadBitmapBlocking( + context: Context, + url: String?, + placeholderResId: Int = 0 + ): Bitmap? { + val request = getImageRequest(context, url, placeholderResId).build() return context.imageLoader.executeBlocking(request).drawable?.toBitmapOrNull() } From e3b7bf467e7c4205a4af76518a68c4d54a75b776 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Wed, 26 Jun 2024 09:45:56 +0530 Subject: [PATCH 06/72] Add annotation --- app/src/main/java/org/schabi/newpipe/util/image/CoilHelper.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/util/image/CoilHelper.kt b/app/src/main/java/org/schabi/newpipe/util/image/CoilHelper.kt index 62c60c92ebb..1f49a4a4fd7 100644 --- a/app/src/main/java/org/schabi/newpipe/util/image/CoilHelper.kt +++ b/app/src/main/java/org/schabi/newpipe/util/image/CoilHelper.kt @@ -25,7 +25,7 @@ object CoilHelper { fun loadBitmapBlocking( context: Context, url: String?, - placeholderResId: Int = 0 + @DrawableRes placeholderResId: Int = 0 ): Bitmap? { val request = getImageRequest(context, url, placeholderResId).build() return context.imageLoader.executeBlocking(request).drawable?.toBitmapOrNull() From 8aa2590fd36fd0be291d93b6f88182328ea378a9 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Wed, 26 Jun 2024 09:57:44 +0530 Subject: [PATCH 07/72] Simplify newImageLoader implementation --- app/src/main/java/org/schabi/newpipe/App.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/App.java b/app/src/main/java/org/schabi/newpipe/App.java index 68ae0ca53fa..216a5b19f13 100644 --- a/app/src/main/java/org/schabi/newpipe/App.java +++ b/app/src/main/java/org/schabi/newpipe/App.java @@ -125,9 +125,7 @@ public void onCreate() { @NonNull @Override public ImageLoader newImageLoader() { - final var isLowRamDevice = ContextCompat.getSystemService(this, ActivityManager.class) - .isLowRamDevice(); - final var builder = new ImageLoader.Builder(this) + return new ImageLoader.Builder(this) .memoryCache(() -> new MemoryCache.Builder(this) .maxSizeBytes(10 * 1024 * 1024) .build()) @@ -135,13 +133,10 @@ public ImageLoader newImageLoader() { .directory(new File(getExternalCacheDir(), "coil")) .maxSizeBytes(50 * 1024 * 1024) .build()) - .allowRgb565(isLowRamDevice); - - if (MainActivity.DEBUG) { - builder.logger(new DebugLogger()); - } - - return builder.build(); + .allowRgb565(ContextCompat.getSystemService(this, ActivityManager.class) + .isLowRamDevice()) + .logger(BuildConfig.DEBUG ? new DebugLogger() : null) + .build(); } protected Downloader getDownloader() { From 71361de8ee0d0c94f6594423b2cd15f52f710442 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Wed, 26 Jun 2024 10:07:46 +0530 Subject: [PATCH 08/72] Use Coil's default disk and memory cache config --- app/src/main/java/org/schabi/newpipe/App.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/App.java b/app/src/main/java/org/schabi/newpipe/App.java index 216a5b19f13..63684723fd1 100644 --- a/app/src/main/java/org/schabi/newpipe/App.java +++ b/app/src/main/java/org/schabi/newpipe/App.java @@ -27,7 +27,6 @@ import org.schabi.newpipe.util.image.ImageStrategy; import org.schabi.newpipe.util.image.PreferredImageQuality; -import java.io.File; import java.io.IOException; import java.io.InterruptedIOException; import java.net.SocketException; @@ -36,8 +35,6 @@ import coil.ImageLoader; import coil.ImageLoaderFactory; -import coil.disk.DiskCache; -import coil.memory.MemoryCache; import coil.util.DebugLogger; import io.reactivex.rxjava3.exceptions.CompositeException; import io.reactivex.rxjava3.exceptions.MissingBackpressureException; @@ -126,13 +123,6 @@ public void onCreate() { @Override public ImageLoader newImageLoader() { return new ImageLoader.Builder(this) - .memoryCache(() -> new MemoryCache.Builder(this) - .maxSizeBytes(10 * 1024 * 1024) - .build()) - .diskCache(() -> new DiskCache.Builder() - .directory(new File(getExternalCacheDir(), "coil")) - .maxSizeBytes(50 * 1024 * 1024) - .build()) .allowRgb565(ContextCompat.getSystemService(this, ActivityManager.class) .isLowRamDevice()) .logger(BuildConfig.DEBUG ? new DebugLogger() : null) From 39d0691c7e974ff89f6328325c2b78c7e907901e Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Thu, 27 Jun 2024 18:08:21 +0530 Subject: [PATCH 09/72] Enable crossfade animation --- app/src/main/java/org/schabi/newpipe/App.java | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/org/schabi/newpipe/App.java b/app/src/main/java/org/schabi/newpipe/App.java index 63684723fd1..a47e0f2fdd4 100644 --- a/app/src/main/java/org/schabi/newpipe/App.java +++ b/app/src/main/java/org/schabi/newpipe/App.java @@ -126,6 +126,7 @@ public ImageLoader newImageLoader() { .allowRgb565(ContextCompat.getSystemService(this, ActivityManager.class) .isLowRamDevice()) .logger(BuildConfig.DEBUG ? new DebugLogger() : null) + .crossfade(true) .build(); } From c4ada7ff6ed945e0858e7c0c5810a44561b28bca Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Wed, 3 Jul 2024 09:30:47 +0530 Subject: [PATCH 10/72] Correct method name --- .../schabi/newpipe/util/external_communication/ShareUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/util/external_communication/ShareUtils.java b/app/src/main/java/org/schabi/newpipe/util/external_communication/ShareUtils.java index 087345af51f..21a4b117562 100644 --- a/app/src/main/java/org/schabi/newpipe/util/external_communication/ShareUtils.java +++ b/app/src/main/java/org/schabi/newpipe/util/external_communication/ShareUtils.java @@ -351,7 +351,7 @@ public static void copyToClipboard(@NonNull final Context context, final String *

* *

- * This method will call {@link CoilHelper#loadBitmap(Context, String)} to get the + * This method will call {@link CoilHelper#loadBitmapBlocking(Context, String)} to get the * thumbnail of the content. *

* From 348a79f91dbe9c442d64bc2914258aa955c9d868 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Wed, 3 Jul 2024 14:41:32 +0530 Subject: [PATCH 11/72] Fix thumbnail not being displayed in media notification --- .../java/org/schabi/newpipe/util/image/CoilHelper.kt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/util/image/CoilHelper.kt b/app/src/main/java/org/schabi/newpipe/util/image/CoilHelper.kt index 1f49a4a4fd7..ab7cd79a895 100644 --- a/app/src/main/java/org/schabi/newpipe/util/image/CoilHelper.kt +++ b/app/src/main/java/org/schabi/newpipe/util/image/CoilHelper.kt @@ -67,16 +67,13 @@ object CoilHelper { var newHeight = input.height / (input.width / notificationThumbnailWidth) val result = input.scale(notificationThumbnailWidth, newHeight) - if (result == input || !result.isMutable) { + return if (result == input || !result.isMutable) { // create a new mutable bitmap to prevent strange crashes on some // devices (see #4638) newHeight = input.height / (input.width / (notificationThumbnailWidth - 1)) - val copied = input.scale(notificationThumbnailWidth, newHeight) - input.recycle() - return copied + input.scale(notificationThumbnailWidth, newHeight) } else { - input.recycle() - return result + result } } }) From da836463032a2643ed4c928095a896f90e632076 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Mon, 22 Jul 2024 08:12:37 +0530 Subject: [PATCH 12/72] Update Coil --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 1ba5aca389b..dba278efc17 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -203,7 +203,7 @@ dependencies { // name and the commit hash with the commit hash of the (pushed) commit you want to test // This works thanks to JitPack: https://jitpack.io/ implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751' - implementation 'com.github.TeamNewPipe:NewPipeExtractor:v0.24.0' + implementation 'com.github.TeamNewPipe:NewPipeExtractor:v0.24.1' implementation 'com.github.TeamNewPipe:NoNonsense-FilePicker:5.0.0' /** Checkstyle **/ @@ -267,7 +267,7 @@ dependencies { implementation "com.github.lisawray.groupie:groupie-viewbinding:${groupieVersion}" // Image loading - implementation 'io.coil-kt:coil:2.6.0' + implementation 'io.coil-kt:coil:2.7.0' // Markdown library for Android implementation "io.noties.markwon:core:${markwonVersion}" From 4ec75321262680dbb72e8629f1e9edbf9e644e69 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Mon, 22 Jul 2024 09:41:07 +0530 Subject: [PATCH 13/72] Addressed code review comments --- .../fragments/detail/VideoDetailFragment.java | 1 + .../feed/notifications/NotificationHelper.kt | 3 +- .../org/schabi/newpipe/player/Player.java | 12 +++- .../settings/ContentSettingsFragment.java | 8 +-- .../external_communication/ShareUtils.java | 64 ++++++++++++------- .../schabi/newpipe/util/image/CoilHelper.kt | 7 +- 6 files changed, 60 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 96523321b14..11a315d691f 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -1473,6 +1473,7 @@ public void showLoading() { CoilUtils.dispose(binding.detailThumbnailImageView); CoilUtils.dispose(binding.detailSubChannelThumbnailView); CoilUtils.dispose(binding.overlayThumbnail); + CoilUtils.dispose(binding.detailUploaderThumbnailView); binding.detailThumbnailImageView.setImageBitmap(null); binding.detailSubChannelThumbnailView.setImageBitmap(null); diff --git a/app/src/main/java/org/schabi/newpipe/local/feed/notifications/NotificationHelper.kt b/app/src/main/java/org/schabi/newpipe/local/feed/notifications/NotificationHelper.kt index 659088ef2fd..4f70cee50e2 100644 --- a/app/src/main/java/org/schabi/newpipe/local/feed/notifications/NotificationHelper.kt +++ b/app/src/main/java/org/schabi/newpipe/local/feed/notifications/NotificationHelper.kt @@ -76,8 +76,7 @@ class NotificationHelper(val context: Context) { summaryBuilder.setLargeIcon(avatarIcon) - // Show individual stream notifications, set channel icon only if there is actually - // one + // Show individual stream notifications, set channel icon only if there is actually one showStreamNotifications(newStreams, data.serviceId, avatarIcon) // Show summary notification manager.notify(data.pseudoId, summaryBuilder.build()) diff --git a/app/src/main/java/org/schabi/newpipe/player/Player.java b/app/src/main/java/org/schabi/newpipe/player/Player.java index 40da9139dff..74d35cf31e6 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -192,6 +192,8 @@ public final class Player implements PlaybackListener, Listener { private MediaItemTag currentMetadata; @Nullable private Bitmap currentThumbnail; + @Nullable + private coil.request.Disposable thumbnailDisposable; /*////////////////////////////////////////////////////////////////////////// // Player @@ -772,6 +774,11 @@ private void loadCurrentThumbnail(final List thumbnails) { + thumbnails.size() + "]"); } + // Cancel any ongoing image loading + if (thumbnailDisposable != null) { + thumbnailDisposable.dispose(); + } + // Unset currentThumbnail, since it is now outdated. This ensures it is not used in media // session metadata while the new thumbnail is being loaded by Coil. onThumbnailLoaded(null); @@ -780,7 +787,7 @@ private void loadCurrentThumbnail(final List thumbnails) { } // scale down the notification thumbnail for performance - final var target = new Target() { + final var thumbnailTarget = new Target() { @Override public void onError(@Nullable final Drawable error) { Log.e(TAG, "Thumbnail - onError() called"); @@ -805,7 +812,8 @@ public void onSuccess(@NonNull final Drawable result) { result.getIntrinsicHeight(), null)); } }; - CoilHelper.INSTANCE.loadScaledDownThumbnail(context, thumbnails, target); + thumbnailDisposable = CoilHelper.INSTANCE + .loadScaledDownThumbnail(context, thumbnails, thumbnailTarget); } private void onThumbnailLoaded(@Nullable final Bitmap bitmap) { diff --git a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java index 2cda1b4ea2d..c47abb93065 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java @@ -42,12 +42,8 @@ public void onCreatePreferences(final Bundle savedInstanceState, final String ro ImageStrategy.setPreferredImageQuality(PreferredImageQuality .fromPreferenceKey(requireContext(), (String) newValue)); final var loader = Coil.imageLoader(preference.getContext()); - if (loader.getMemoryCache() != null) { - loader.getMemoryCache().clear(); - } - if (loader.getDiskCache() != null) { - loader.getDiskCache().clear(); - } + loader.getMemoryCache().clear(); + loader.getDiskCache().clear(); Toast.makeText(preference.getContext(), R.string.thumbnail_cache_wipe_complete_notice, Toast.LENGTH_SHORT) .show(); diff --git a/app/src/main/java/org/schabi/newpipe/util/external_communication/ShareUtils.java b/app/src/main/java/org/schabi/newpipe/util/external_communication/ShareUtils.java index 21a4b117562..9008a213deb 100644 --- a/app/src/main/java/org/schabi/newpipe/util/external_communication/ShareUtils.java +++ b/app/src/main/java/org/schabi/newpipe/util/external_communication/ShareUtils.java @@ -10,6 +10,7 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.net.Uri; import android.os.Build; import android.text.TextUtils; @@ -24,13 +25,16 @@ import org.schabi.newpipe.BuildConfig; import org.schabi.newpipe.R; import org.schabi.newpipe.extractor.Image; -import org.schabi.newpipe.util.image.CoilHelper; import org.schabi.newpipe.util.image.ImageStrategy; -import java.io.File; -import java.io.FileOutputStream; +import java.nio.file.Files; +import java.util.Collections; import java.util.List; +import coil.Coil; +import coil.disk.DiskCache; +import coil.memory.MemoryCache; + public final class ShareUtils { private static final String TAG = ShareUtils.class.getSimpleName(); @@ -335,7 +339,13 @@ public static void copyToClipboard(@NonNull final Context context, final String } /** - * Generate a {@link ClipData} with the image of the content shared. + * Generate a {@link ClipData} with the image of the content shared, if it's in the app cache. + * + *

+ * In order not to worry about network issues (timeouts, DNS issues, low connection speed, ...) + * when sharing a content, only images in the {@link MemoryCache} or {@link DiskCache} + * used by the Coil library are used as preview images. If the thumbnail image is not in the + * cache, no {@link ClipData} will be generated and {@code null} will be returned. * *

* In order to display the image in the content preview of the Android share sheet, an URI of @@ -351,11 +361,6 @@ public static void copyToClipboard(@NonNull final Context context, final String *

* *

- * This method will call {@link CoilHelper#loadBitmapBlocking(Context, String)} to get the - * thumbnail of the content. - *

- * - *

* Using the result of this method when sharing has only an effect on the system share sheet (if * OEMs didn't change Android system standard behavior) on Android API 29 and higher. *

@@ -369,33 +374,46 @@ private static ClipData generateClipDataForImagePreview( @NonNull final Context context, @NonNull final String thumbnailUrl) { try { - final var bitmap = CoilHelper.INSTANCE.loadBitmapBlocking(context, thumbnailUrl); - if (bitmap == null) { - return null; - } - // Save the image in memory to the application's cache because we need a URI to the // image to generate a ClipData which will show the share sheet, and so an image file final Context applicationContext = context.getApplicationContext(); - final String appFolder = applicationContext.getCacheDir().getAbsolutePath(); - final File thumbnailPreviewFile = new File(appFolder - + "/android_share_sheet_image_preview.jpg"); + final var loader = Coil.imageLoader(context); + final var value = loader.getMemoryCache() + .get(new MemoryCache.Key(thumbnailUrl, Collections.emptyMap())); + + final Bitmap cachedBitmap; + if (value != null) { + cachedBitmap = value.getBitmap(); + } else { + try (var snapshot = loader.getDiskCache().openSnapshot(thumbnailUrl)) { + if (snapshot != null) { + cachedBitmap = BitmapFactory.decodeFile(snapshot.getData().toString()); + } else { + cachedBitmap = null; + } + } + } + + if (cachedBitmap == null) { + return null; + } - // Any existing file will be overwritten with FileOutputStream - final FileOutputStream fileOutputStream = new FileOutputStream(thumbnailPreviewFile); - bitmap.compress(Bitmap.CompressFormat.JPEG, 90, fileOutputStream); - fileOutputStream.close(); + final var path = applicationContext.getCacheDir().toPath() + .resolve("android_share_sheet_image_preview.jpg"); + // Any existing file will be overwritten + try (var outputStream = Files.newOutputStream(path)) { + cachedBitmap.compress(Bitmap.CompressFormat.JPEG, 90, outputStream); + } final ClipData clipData = ClipData.newUri(applicationContext.getContentResolver(), "", FileProvider.getUriForFile(applicationContext, BuildConfig.APPLICATION_ID + ".provider", - thumbnailPreviewFile)); + path.toFile())); if (DEBUG) { Log.d(TAG, "ClipData successfully generated for Android share sheet: " + clipData); } return clipData; - } catch (final Exception e) { Log.w(TAG, "Error when setting preview image for share sheet", e); return null; diff --git a/app/src/main/java/org/schabi/newpipe/util/image/CoilHelper.kt b/app/src/main/java/org/schabi/newpipe/util/image/CoilHelper.kt index ab7cd79a895..2608090dc95 100644 --- a/app/src/main/java/org/schabi/newpipe/util/image/CoilHelper.kt +++ b/app/src/main/java/org/schabi/newpipe/util/image/CoilHelper.kt @@ -8,6 +8,7 @@ import androidx.annotation.DrawableRes import androidx.core.graphics.drawable.toBitmapOrNull import coil.executeBlocking import coil.imageLoader +import coil.request.Disposable import coil.request.ImageRequest import coil.size.Size import coil.target.Target @@ -47,7 +48,7 @@ object CoilHelper { loadImageDefault(target, url, R.drawable.placeholder_thumbnail_video) } - fun loadScaledDownThumbnail(context: Context, images: List, target: Target) { + fun loadScaledDownThumbnail(context: Context, images: List, target: Target): Disposable { val url = ImageStrategy.choosePreferredImage(images) val request = getImageRequest(context, url, R.drawable.placeholder_thumbnail_video) .target(target) @@ -79,7 +80,7 @@ object CoilHelper { }) .build() - context.imageLoader.enqueue(request) + return context.imageLoader.enqueue(request) } fun loadDetailsThumbnail(target: ImageView, images: List) { @@ -133,6 +134,8 @@ object CoilHelper { return ImageRequest.Builder(context) .data(takenUrl) .error(placeholderResId) + .memoryCacheKey(takenUrl) + .diskCacheKey(takenUrl) .apply { if (takenUrl != null || showPlaceholderWhileLoading) { placeholder(placeholderResId) From 08f0338e866d47966d8469478d622a7beb54375c Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Sun, 12 May 2024 08:21:13 +0530 Subject: [PATCH 14/72] Convert comment replies views to Jetpack Compose --- app/build.gradle | 6 +- .../fragments/list/comments/Comment.kt | 84 ++++++++++++ .../list/comments/CommentRepliesHeader.kt | 121 ++++++++++++++++++ build.gradle | 2 +- 4 files changed, 209 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt create mode 100644 app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt diff --git a/app/build.gradle b/app/build.gradle index dba278efc17..5022c7266e4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -106,7 +106,7 @@ android { } composeOptions { - kotlinCompilerExtensionVersion = "1.5.3" + kotlinCompilerExtensionVersion = "1.5.13" } } @@ -267,7 +267,7 @@ dependencies { implementation "com.github.lisawray.groupie:groupie-viewbinding:${groupieVersion}" // Image loading - implementation 'io.coil-kt:coil:2.7.0' + implementation 'io.coil-kt:coil-compose:2.7.0' // Markdown library for Android implementation "io.noties.markwon:core:${markwonVersion}" @@ -289,7 +289,7 @@ dependencies { implementation "org.ocpsoft.prettytime:prettytime:5.0.8.Final" // Jetpack Compose - implementation(platform('androidx.compose:compose-bom:2024.02.01')) + implementation(platform('androidx.compose:compose-bom:2024.05.00')) implementation 'androidx.compose.material3:material3' implementation 'androidx.activity:activity-compose' implementation 'androidx.compose.ui:ui-tooling-preview' diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt new file mode 100644 index 00000000000..c622aa18dc4 --- /dev/null +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt @@ -0,0 +1,84 @@ +package org.schabi.newpipe.fragments.list.comments + +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.fragment.app.FragmentActivity +import coil.compose.AsyncImage +import org.schabi.newpipe.R +import org.schabi.newpipe.extractor.comments.CommentsInfoItem +import org.schabi.newpipe.extractor.stream.Description +import org.schabi.newpipe.util.NavigationHelper +import org.schabi.newpipe.util.image.ImageStrategy + +@Composable +fun Comment(comment: CommentsInfoItem) { + val context = LocalContext.current + + Row(modifier = Modifier.padding(all = 8.dp)) { + if (ImageStrategy.shouldLoadImages()) { + AsyncImage( + model = ImageStrategy.choosePreferredImage(comment.uploaderAvatars), + contentDescription = null, + placeholder = painterResource(R.drawable.placeholder_person), + error = painterResource(R.drawable.placeholder_person), + modifier = Modifier + .size(42.dp) + .clip(CircleShape) + .clickable { + NavigationHelper.openCommentAuthorIfPresent(context as FragmentActivity, comment) + } + ) + } + + Spacer(modifier = Modifier.width(8.dp)) + + var isExpanded by rememberSaveable { mutableStateOf(false) } + + Column(modifier = Modifier.clickable { isExpanded = !isExpanded }) { + Text( + text = comment.uploaderName, + color = MaterialTheme.colors.secondary + ) + + Spacer(modifier = Modifier.height(4.dp)) + + Text( + text = comment.commentText.content, + // If the comment is expanded, we display all its content + // otherwise we only display the first line + maxLines = if (isExpanded) Int.MAX_VALUE else 1, + style = MaterialTheme.typography.body2 + ) + } + } +} + +@Preview +@Composable +fun CommentPreview() { + val comment = CommentsInfoItem(1, "", "") + comment.commentText = Description("Hello world!", Description.PLAIN_TEXT) + comment.uploaderName = "Test" + + Comment(comment) +} diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt new file mode 100644 index 00000000000..243d887cdf1 --- /dev/null +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt @@ -0,0 +1,121 @@ +package org.schabi.newpipe.fragments.list.comments + +import android.widget.TextView +import androidx.compose.foundation.Image +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.compose.ui.viewinterop.AndroidView +import androidx.core.text.HtmlCompat +import androidx.core.text.method.LinkMovementMethodCompat +import androidx.fragment.app.FragmentActivity +import coil.compose.AsyncImage +import io.reactivex.rxjava3.disposables.CompositeDisposable +import org.schabi.newpipe.R +import org.schabi.newpipe.extractor.comments.CommentsInfoItem +import org.schabi.newpipe.extractor.stream.Description +import org.schabi.newpipe.util.Localization +import org.schabi.newpipe.util.NavigationHelper +import org.schabi.newpipe.util.ServiceHelper +import org.schabi.newpipe.util.image.ImageStrategy +import org.schabi.newpipe.util.text.TextLinkifier + +@Composable +fun CommentRepliesHeader(comment: CommentsInfoItem, disposables: CompositeDisposable) { + val context = LocalContext.current + + Column(modifier = Modifier.padding(all = 8.dp)) { + Row { + Row( + modifier = Modifier + .padding(all = 8.dp) + .clickable { + NavigationHelper.openCommentAuthorIfPresent( + context as FragmentActivity, + comment + ) + } + ) { + if (ImageStrategy.shouldLoadImages()) { + AsyncImage( + model = ImageStrategy.choosePreferredImage(comment.uploaderAvatars), + contentDescription = null, + placeholder = painterResource(R.drawable.placeholder_person), + error = painterResource(R.drawable.placeholder_person), + modifier = Modifier + .size(42.dp) + .clip(CircleShape) + ) + } + + Spacer(modifier = Modifier.width(8.dp)) + + Column { + Text(text = comment.uploaderName) + + Text( + text = Localization.relativeTimeOrTextual( + context, comment.uploadDate, comment.textualUploadDate + ) + ) + } + } + + if (comment.isHeartedByUploader) { + Image( + painter = painterResource(R.drawable.ic_heart), + contentDescription = stringResource(R.string.detail_heart_img_view_description) + ) + } + + if (comment.isPinned) { + Image( + painter = painterResource(R.drawable.ic_pin), + contentDescription = stringResource(R.string.detail_pinned_comment_view_description) + ) + } + } + + AndroidView( + factory = { context -> + TextView(context).apply { + movementMethod = LinkMovementMethodCompat.getInstance() + } + }, + update = { view -> + // setup comment content + TextLinkifier.fromDescription(view, comment.commentText, + HtmlCompat.FROM_HTML_MODE_LEGACY, + ServiceHelper.getServiceById(comment.serviceId), comment.url, disposables, + null + ) + } + ) + } +} + +@Preview +@Composable +fun CommentRepliesHeaderPreview() { + val disposables = CompositeDisposable() + val comment = CommentsInfoItem(1, "", "") + comment.commentText = Description("Hello world!", Description.PLAIN_TEXT) + comment.uploaderName = "Test" + comment.textualUploadDate = "5 months ago" + + CommentRepliesHeader(comment, disposables) +} diff --git a/build.gradle b/build.gradle index 6d19a6f8a84..5a1ae1945de 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.9.10' + ext.kotlin_version = '1.9.23' repositories { google() mavenCentral() From c429deb0aa3e4ceb41b5025c129e6cc329c77441 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Sun, 12 May 2024 08:49:14 +0530 Subject: [PATCH 15/72] Rename .java to .kt --- .../{CommentRepliesFragment.java => CommentRepliesFragment.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/src/main/java/org/schabi/newpipe/fragments/list/comments/{CommentRepliesFragment.java => CommentRepliesFragment.kt} (100%) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt similarity index 100% rename from app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.java rename to app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt From e1932653e605bad03315988593d4cab6c5584ead Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Sun, 12 May 2024 08:49:15 +0530 Subject: [PATCH 16/72] Use reply header composable in fragment --- .../java/org/schabi/newpipe/MainActivity.java | 2 +- .../list/comments/CommentRepliesFragment.kt | 210 ++++++------------ .../list/comments/CommentRepliesHeader.kt | 4 +- .../res/layout/comment_replies_header.xml | 137 ------------ 4 files changed, 75 insertions(+), 278 deletions(-) delete mode 100644 app/src/main/res/layout/comment_replies_header.xml diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index 17569412572..43b01c70d69 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -871,7 +871,7 @@ private void openDetailFragmentFromCommentReplies( @Nullable final CommentRepliesFragment repliesFragment = (CommentRepliesFragment) fm.findFragmentByTag(CommentRepliesFragment.TAG); @Nullable final CommentsInfoItem rootComment = - repliesFragment == null ? null : repliesFragment.getCommentsInfoItem(); + repliesFragment == null ? null : repliesFragment.commentsInfoItem; // sometimes this function pops the backstack, other times it's handled by the system if (popBackStack) { diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt index 4eb73520fba..4bfb04d6e98 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt @@ -1,170 +1,104 @@ -package org.schabi.newpipe.fragments.list.comments; - -import static org.schabi.newpipe.util.ServiceHelper.getServiceById; - -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.constraintlayout.widget.ConstraintLayout; -import androidx.core.text.HtmlCompat; - -import org.schabi.newpipe.R; -import org.schabi.newpipe.databinding.CommentRepliesHeaderBinding; -import org.schabi.newpipe.error.UserAction; -import org.schabi.newpipe.extractor.ListExtractor; -import org.schabi.newpipe.extractor.comments.CommentsInfoItem; -import org.schabi.newpipe.fragments.list.BaseListInfoFragment; -import org.schabi.newpipe.info_list.ItemViewMode; -import org.schabi.newpipe.util.DeviceUtils; -import org.schabi.newpipe.util.ExtractorHelper; -import org.schabi.newpipe.util.Localization; -import org.schabi.newpipe.util.NavigationHelper; -import org.schabi.newpipe.util.image.CoilHelper; -import org.schabi.newpipe.util.image.ImageStrategy; -import org.schabi.newpipe.util.text.TextLinkifier; - -import java.util.Queue; -import java.util.function.Supplier; - -import icepick.State; -import io.reactivex.rxjava3.core.Single; -import io.reactivex.rxjava3.disposables.CompositeDisposable; - -public final class CommentRepliesFragment - extends BaseListInfoFragment { - - public static final String TAG = CommentRepliesFragment.class.getSimpleName(); - +package org.schabi.newpipe.fragments.list.comments + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.compose.ui.platform.ComposeView +import icepick.State +import io.reactivex.rxjava3.core.Single +import io.reactivex.rxjava3.disposables.CompositeDisposable +import org.schabi.newpipe.R +import org.schabi.newpipe.error.UserAction +import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage +import org.schabi.newpipe.extractor.comments.CommentsInfoItem +import org.schabi.newpipe.fragments.list.BaseListInfoFragment +import org.schabi.newpipe.info_list.ItemViewMode +import org.schabi.newpipe.util.ExtractorHelper +import org.schabi.newpipe.util.Localization +import java.util.Queue +import java.util.function.Supplier + +class CommentRepliesFragment() : BaseListInfoFragment(UserAction.REQUESTED_COMMENT_REPLIES) { + /** + * @return the comment to which the replies are shown + */ @State - CommentsInfoItem commentsInfoItem; // the comment to show replies of - private final CompositeDisposable disposables = new CompositeDisposable(); + lateinit var commentsInfoItem: CommentsInfoItem // the comment to show replies of + private val disposables = CompositeDisposable() - - /*////////////////////////////////////////////////////////////////////////// - // Constructors and lifecycle - //////////////////////////////////////////////////////////////////////////*/ - - // only called by the Android framework, after which readFrom is called and restores all data - public CommentRepliesFragment() { - super(UserAction.REQUESTED_COMMENT_REPLIES); - } - - public CommentRepliesFragment(@NonNull final CommentsInfoItem commentsInfoItem) { - this(); - this.commentsInfoItem = commentsInfoItem; + constructor(commentsInfoItem: CommentsInfoItem) : this() { + this.commentsInfoItem = commentsInfoItem // setting "" as title since the title will be properly set right after - setInitialData(commentsInfoItem.getServiceId(), commentsInfoItem.getUrl(), ""); + setInitialData(commentsInfoItem.serviceId, commentsInfoItem.url, "") } - @Nullable - @Override - public View onCreateView(@NonNull final LayoutInflater inflater, - @Nullable final ViewGroup container, - @Nullable final Bundle savedInstanceState) { - return inflater.inflate(R.layout.fragment_comments, container, false); + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + return inflater.inflate(R.layout.fragment_comments, container, false) } - @Override - public void onDestroyView() { - disposables.clear(); - super.onDestroyView(); + override fun onDestroyView() { + disposables.clear() + super.onDestroyView() } - @Override - protected Supplier getListHeaderSupplier() { - return () -> { - final CommentRepliesHeaderBinding binding = CommentRepliesHeaderBinding - .inflate(activity.getLayoutInflater(), itemsList, false); - final CommentsInfoItem item = commentsInfoItem; - - // load the author avatar - CoilHelper.INSTANCE.loadAvatar(binding.authorAvatar, item.getUploaderAvatars()); - binding.authorAvatar.setVisibility(ImageStrategy.shouldLoadImages() - ? View.VISIBLE : View.GONE); - - // setup author name and comment date - binding.authorName.setText(item.getUploaderName()); - binding.uploadDate.setText(Localization.relativeTimeOrTextual( - getContext(), item.getUploadDate(), item.getTextualUploadDate())); - binding.authorTouchArea.setOnClickListener( - v -> NavigationHelper.openCommentAuthorIfPresent(requireActivity(), item)); - - // setup like count, hearted and pinned - binding.thumbsUpCount.setText( - Localization.likeCount(requireContext(), item.getLikeCount())); - // for heartImage goneMarginEnd was used, but there is no way to tell ConstraintLayout - // not to use a different margin only when both the next two views are gone - ((ConstraintLayout.LayoutParams) binding.thumbsUpCount.getLayoutParams()) - .setMarginEnd(DeviceUtils.dpToPx( - (item.isHeartedByUploader() || item.isPinned() ? 8 : 16), - requireContext())); - binding.heartImage.setVisibility(item.isHeartedByUploader() ? View.VISIBLE : View.GONE); - binding.pinnedImage.setVisibility(item.isPinned() ? View.VISIBLE : View.GONE); - - // setup comment content - TextLinkifier.fromDescription(binding.commentContent, item.getCommentText(), - HtmlCompat.FROM_HTML_MODE_LEGACY, getServiceById(item.getServiceId()), - item.getUrl(), disposables, null); - - return binding.getRoot(); - }; + override fun getListHeaderSupplier(): Supplier { + return Supplier { + ComposeView(requireContext()).apply { + setContent { + CommentRepliesHeader(commentsInfoItem, disposables) + } + } + } } - /*////////////////////////////////////////////////////////////////////////// // State saving - //////////////////////////////////////////////////////////////////////////*/ - - @Override - public void writeTo(final Queue objectsToSave) { - super.writeTo(objectsToSave); - objectsToSave.add(commentsInfoItem); + ////////////////////////////////////////////////////////////////////////// */ + override fun writeTo(objectsToSave: Queue) { + super.writeTo(objectsToSave) + objectsToSave.add(commentsInfoItem) } - @Override - public void readFrom(@NonNull final Queue savedObjects) throws Exception { - super.readFrom(savedObjects); - commentsInfoItem = (CommentsInfoItem) savedObjects.poll(); + @Throws(Exception::class) + override fun readFrom(savedObjects: Queue) { + super.readFrom(savedObjects) + commentsInfoItem = savedObjects.poll() as CommentsInfoItem } - /*////////////////////////////////////////////////////////////////////////// // Data loading - //////////////////////////////////////////////////////////////////////////*/ - - @Override - protected Single loadResult(final boolean forceLoad) { - return Single.fromCallable(() -> new CommentRepliesInfo(commentsInfoItem, - // the reply count string will be shown as the activity title - Localization.replyCount(requireContext(), commentsInfoItem.getReplyCount()))); + ////////////////////////////////////////////////////////////////////////// */ + override fun loadResult(forceLoad: Boolean): Single { + return Single.fromCallable { + CommentRepliesInfo( + commentsInfoItem, // the reply count string will be shown as the activity title + Localization.replyCount(requireContext(), commentsInfoItem.replyCount) + ) + } } - @Override - protected Single> loadMoreItemsLogic() { + override fun loadMoreItemsLogic(): Single>? { // commentsInfoItem.getUrl() should contain the url of the original // ListInfo, which should be the stream url return ExtractorHelper.getMoreCommentItems( - serviceId, commentsInfoItem.getUrl(), currentNextPage); + serviceId, commentsInfoItem.url, currentNextPage + ) } - /*////////////////////////////////////////////////////////////////////////// // Utils - //////////////////////////////////////////////////////////////////////////*/ - - @Override - protected ItemViewMode getItemViewMode() { - return ItemViewMode.LIST; + ////////////////////////////////////////////////////////////////////////// */ + override fun getItemViewMode(): ItemViewMode { + return ItemViewMode.LIST } - /** - * @return the comment to which the replies are shown - */ - public CommentsInfoItem getCommentsInfoItem() { - return commentsInfoItem; + companion object { + @JvmField + val TAG: String = CommentRepliesFragment::class.java.simpleName } } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt index 243d887cdf1..89f6985a3e4 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt @@ -98,8 +98,8 @@ fun CommentRepliesHeader(comment: CommentsInfoItem, disposables: CompositeDispos }, update = { view -> // setup comment content - TextLinkifier.fromDescription(view, comment.commentText, - HtmlCompat.FROM_HTML_MODE_LEGACY, + TextLinkifier.fromDescription( + view, comment.commentText, HtmlCompat.FROM_HTML_MODE_LEGACY, ServiceHelper.getServiceById(comment.serviceId), comment.url, disposables, null ) diff --git a/app/src/main/res/layout/comment_replies_header.xml b/app/src/main/res/layout/comment_replies_header.xml deleted file mode 100644 index ed5ba1a1084..00000000000 --- a/app/src/main/res/layout/comment_replies_header.xml +++ /dev/null @@ -1,137 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From fc8a7480388ed4304e1d6873ce3425973d06205b Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Sun, 12 May 2024 18:09:16 +0530 Subject: [PATCH 17/72] Added like count --- .../list/comments/CommentRepliesHeader.kt | 47 ++++++++++++++----- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt index 89f6985a3e4..cbd0a8f1bd5 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt @@ -3,15 +3,18 @@ package org.schabi.newpipe.fragments.list.comments import android.widget.TextView import androidx.compose.foundation.Image import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.CircleShape import androidx.compose.material.Text import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.platform.LocalContext @@ -39,16 +42,20 @@ fun CommentRepliesHeader(comment: CommentsInfoItem, disposables: CompositeDispos val context = LocalContext.current Column(modifier = Modifier.padding(all = 8.dp)) { - Row { + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically + ) { Row( modifier = Modifier - .padding(all = 8.dp) + .padding(top = 8.dp, bottom = 8.dp, end = 8.dp) .clickable { NavigationHelper.openCommentAuthorIfPresent( context as FragmentActivity, comment ) - } + }, + verticalAlignment = Alignment.CenterVertically ) { if (ImageStrategy.shouldLoadImages()) { AsyncImage( @@ -75,18 +82,31 @@ fun CommentRepliesHeader(comment: CommentsInfoItem, disposables: CompositeDispos } } - if (comment.isHeartedByUploader) { - Image( - painter = painterResource(R.drawable.ic_heart), - contentDescription = stringResource(R.string.detail_heart_img_view_description) - ) - } + Spacer(modifier = Modifier.weight(1f)) - if (comment.isPinned) { + Row( + horizontalArrangement = Arrangement.spacedBy(8.dp), + verticalAlignment = Alignment.CenterVertically + ) { Image( - painter = painterResource(R.drawable.ic_pin), - contentDescription = stringResource(R.string.detail_pinned_comment_view_description) + painter = painterResource(R.drawable.ic_thumb_up), + contentDescription = stringResource(R.string.detail_likes_img_view_description) ) + Text(text = comment.likeCount.toString()) + + if (comment.isHeartedByUploader) { + Image( + painter = painterResource(R.drawable.ic_heart), + contentDescription = stringResource(R.string.detail_heart_img_view_description) + ) + } + + if (comment.isPinned) { + Image( + painter = painterResource(R.drawable.ic_pin), + contentDescription = stringResource(R.string.detail_pinned_comment_view_description) + ) + } } } @@ -116,6 +136,9 @@ fun CommentRepliesHeaderPreview() { comment.commentText = Description("Hello world!", Description.PLAIN_TEXT) comment.uploaderName = "Test" comment.textualUploadDate = "5 months ago" + comment.likeCount = 100 + comment.isPinned = true + comment.isHeartedByUploader = true CommentRepliesHeader(comment, disposables) } From b302c1b5c2cf050bf3765f9ade2e1b7bc6380e8a Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Fri, 17 May 2024 10:17:09 +0530 Subject: [PATCH 18/72] Added missing comment features, fixed theming --- .../java/org/schabi/newpipe/MainActivity.java | 2 +- .../fragments/list/comments/Comment.kt | 117 +++++++++---- .../list/comments/CommentRepliesFragment.kt | 5 +- .../list/comments/CommentRepliesHeader.kt | 157 ++++++++++-------- 4 files changed, 174 insertions(+), 107 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index 43b01c70d69..17569412572 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -871,7 +871,7 @@ private void openDetailFragmentFromCommentReplies( @Nullable final CommentRepliesFragment repliesFragment = (CommentRepliesFragment) fm.findFragmentByTag(CommentRepliesFragment.TAG); @Nullable final CommentsInfoItem rootComment = - repliesFragment == null ? null : repliesFragment.commentsInfoItem; + repliesFragment == null ? null : repliesFragment.getCommentsInfoItem(); // sometimes this function pops the backstack, other times it's handled by the system if (popBackStack) { diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt index c622aa18dc4..b293adedc36 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt @@ -1,16 +1,19 @@ package org.schabi.newpipe.fragments.list.comments +import android.content.res.Configuration +import androidx.compose.foundation.Image import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -20,6 +23,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.fragment.app.FragmentActivity @@ -27,6 +31,7 @@ import coil.compose.AsyncImage import org.schabi.newpipe.R import org.schabi.newpipe.extractor.comments.CommentsInfoItem import org.schabi.newpipe.extractor.stream.Description +import org.schabi.newpipe.ui.theme.AppTheme import org.schabi.newpipe.util.NavigationHelper import org.schabi.newpipe.util.image.ImageStrategy @@ -34,51 +39,93 @@ import org.schabi.newpipe.util.image.ImageStrategy fun Comment(comment: CommentsInfoItem) { val context = LocalContext.current - Row(modifier = Modifier.padding(all = 8.dp)) { - if (ImageStrategy.shouldLoadImages()) { - AsyncImage( - model = ImageStrategy.choosePreferredImage(comment.uploaderAvatars), - contentDescription = null, - placeholder = painterResource(R.drawable.placeholder_person), - error = painterResource(R.drawable.placeholder_person), - modifier = Modifier - .size(42.dp) - .clip(CircleShape) - .clickable { - NavigationHelper.openCommentAuthorIfPresent(context as FragmentActivity, comment) - } - ) - } + Surface(color = MaterialTheme.colorScheme.background) { + Row(modifier = Modifier.padding(all = 8.dp)) { + if (ImageStrategy.shouldLoadImages()) { + AsyncImage( + model = ImageStrategy.choosePreferredImage(comment.uploaderAvatars), + contentDescription = null, + placeholder = painterResource(R.drawable.placeholder_person), + error = painterResource(R.drawable.placeholder_person), + modifier = Modifier + .size(42.dp) + .clip(CircleShape) + .clickable { + NavigationHelper.openCommentAuthorIfPresent( + context as FragmentActivity, + comment + ) + } + ) + } + + Spacer(modifier = Modifier.width(8.dp)) + + var isExpanded by rememberSaveable { mutableStateOf(false) } - Spacer(modifier = Modifier.width(8.dp)) + Column( + modifier = Modifier.clickable { isExpanded = !isExpanded }, + verticalArrangement = Arrangement.spacedBy(4.dp) + ) { + Text( + text = comment.uploaderName, + color = MaterialTheme.colorScheme.secondary + ) - var isExpanded by rememberSaveable { mutableStateOf(false) } + Text( + text = comment.commentText.content, + // If the comment is expanded, we display all its content + // otherwise we only display the first two lines + maxLines = if (isExpanded) Int.MAX_VALUE else 2, + style = MaterialTheme.typography.bodyMedium + ) - Column(modifier = Modifier.clickable { isExpanded = !isExpanded }) { - Text( - text = comment.uploaderName, - color = MaterialTheme.colors.secondary - ) + Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { + Image( + painter = painterResource(R.drawable.ic_thumb_up), + contentDescription = stringResource(R.string.detail_likes_img_view_description) + ) + Text(text = comment.likeCount.toString()) - Spacer(modifier = Modifier.height(4.dp)) + if (comment.isHeartedByUploader) { + Image( + painter = painterResource(R.drawable.ic_heart), + contentDescription = stringResource(R.string.detail_heart_img_view_description) + ) + } - Text( - text = comment.commentText.content, - // If the comment is expanded, we display all its content - // otherwise we only display the first line - maxLines = if (isExpanded) Int.MAX_VALUE else 1, - style = MaterialTheme.typography.body2 - ) + if (comment.isPinned) { + Image( + painter = painterResource(R.drawable.ic_pin), + contentDescription = stringResource(R.string.detail_pinned_comment_view_description) + ) + } + } + } } + + // TODO: Add support for comment replies } } -@Preview +@Preview( + name = "Light mode", + uiMode = Configuration.UI_MODE_NIGHT_NO +) +@Preview( + name = "Dark mode", + uiMode = Configuration.UI_MODE_NIGHT_YES +) @Composable fun CommentPreview() { val comment = CommentsInfoItem(1, "", "") comment.commentText = Description("Hello world!", Description.PLAIN_TEXT) comment.uploaderName = "Test" + comment.likeCount = 100 + comment.isHeartedByUploader = true + comment.isPinned = true - Comment(comment) + AppTheme { + Comment(comment) + } } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt index 4bfb04d6e98..1847d7d31d4 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt @@ -14,6 +14,7 @@ import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage import org.schabi.newpipe.extractor.comments.CommentsInfoItem import org.schabi.newpipe.fragments.list.BaseListInfoFragment import org.schabi.newpipe.info_list.ItemViewMode +import org.schabi.newpipe.ui.theme.AppTheme import org.schabi.newpipe.util.ExtractorHelper import org.schabi.newpipe.util.Localization import java.util.Queue @@ -50,7 +51,9 @@ class CommentRepliesFragment() : BaseListInfoFragment - TextView(context).apply { - movementMethod = LinkMovementMethodCompat.getInstance() + AndroidView( + factory = { context -> + TextView(context).apply { + movementMethod = LinkMovementMethodCompat.getInstance() + } + }, + update = { view -> + // setup comment content + TextLinkifier.fromDescription( + view, comment.commentText, HtmlCompat.FROM_HTML_MODE_LEGACY, + ServiceHelper.getServiceById(comment.serviceId), comment.url, disposables, + null + ) } - }, - update = { view -> - // setup comment content - TextLinkifier.fromDescription( - view, comment.commentText, HtmlCompat.FROM_HTML_MODE_LEGACY, - ServiceHelper.getServiceById(comment.serviceId), comment.url, disposables, - null - ) - } - ) + ) + } } } -@Preview +@Preview( + name = "Light mode", + uiMode = Configuration.UI_MODE_NIGHT_NO +) +@Preview( + name = "Dark mode", + uiMode = Configuration.UI_MODE_NIGHT_YES +) @Composable fun CommentRepliesHeaderPreview() { val disposables = CompositeDisposable() @@ -140,5 +155,7 @@ fun CommentRepliesHeaderPreview() { comment.isPinned = true comment.isHeartedByUploader = true - CommentRepliesHeader(comment, disposables) + AppTheme { + CommentRepliesHeader(comment, disposables) + } } From b14da3ad5efec062c6794515ee21c03d4b874186 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Sun, 16 Jun 2024 18:29:29 +0530 Subject: [PATCH 19/72] Add comment ellipsis --- .../newpipe/fragments/list/comments/Comment.kt | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt index b293adedc36..8b1726ffff1 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt @@ -24,6 +24,7 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.fragment.app.FragmentActivity @@ -77,6 +78,7 @@ fun Comment(comment: CommentsInfoItem) { // If the comment is expanded, we display all its content // otherwise we only display the first two lines maxLines = if (isExpanded) Int.MAX_VALUE else 2, + overflow = TextOverflow.Ellipsis, style = MaterialTheme.typography.bodyMedium ) @@ -108,18 +110,12 @@ fun Comment(comment: CommentsInfoItem) { } } -@Preview( - name = "Light mode", - uiMode = Configuration.UI_MODE_NIGHT_NO -) -@Preview( - name = "Dark mode", - uiMode = Configuration.UI_MODE_NIGHT_YES -) +@Preview(name = "Light mode", uiMode = Configuration.UI_MODE_NIGHT_NO) +@Preview(name = "Dark mode", uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable fun CommentPreview() { val comment = CommentsInfoItem(1, "", "") - comment.commentText = Description("Hello world!", Description.PLAIN_TEXT) + comment.commentText = Description("Hello world!\n\nThis line should be hidden by default.", Description.PLAIN_TEXT) comment.uploaderName = "Test" comment.likeCount = 100 comment.isHeartedByUploader = true From 65fce6e054635dfc5ec2c2ab7a49ef82b7f70301 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Tue, 18 Jun 2024 07:59:24 +0530 Subject: [PATCH 20/72] Update replies fragment to use the comment composable as well --- app/build.gradle | 8 +- .../java/org/schabi/newpipe/MainActivity.java | 8 +- .../fragments/list/comments/Comment.kt | 32 ++++-- .../fragments/list/comments/CommentReplies.kt | 60 +++++++++++ .../list/comments/CommentRepliesFragment.kt | 100 ++++-------------- .../list/comments/CommentRepliesHeader.kt | 10 +- .../list/comments/CommentRepliesInfo.java | 22 ---- .../list/comments/CommentRepliesSource.kt | 22 ++++ .../java/org/schabi/newpipe/ktx/Bundle.kt | 16 +++ .../schabi/newpipe/util/NavigationHelper.java | 6 +- build.gradle | 2 +- 11 files changed, 163 insertions(+), 123 deletions(-) create mode 100644 app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentReplies.kt delete mode 100644 app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesInfo.java create mode 100644 app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesSource.kt diff --git a/app/build.gradle b/app/build.gradle index 5022c7266e4..361d99595bd 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -106,7 +106,7 @@ android { } composeOptions { - kotlinCompilerExtensionVersion = "1.5.13" + kotlinCompilerExtensionVersion = "1.5.14" } } @@ -289,11 +289,15 @@ dependencies { implementation "org.ocpsoft.prettytime:prettytime:5.0.8.Final" // Jetpack Compose - implementation(platform('androidx.compose:compose-bom:2024.05.00')) + implementation(platform('androidx.compose:compose-bom:2024.06.00')) implementation 'androidx.compose.material3:material3' implementation 'androidx.activity:activity-compose' implementation 'androidx.compose.ui:ui-tooling-preview' + // Paging + implementation 'androidx.paging:paging-rxjava3:3.3.0' + implementation 'androidx.paging:paging-compose:3.3.0' + /** Debugging **/ // Memory leak detection debugImplementation "com.squareup.leakcanary:leakcanary-object-watcher-android:${leakCanaryVersion}" diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index 17569412572..d288ab4c65b 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -66,7 +66,6 @@ import org.schabi.newpipe.error.ErrorUtil; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.StreamingService; -import org.schabi.newpipe.extractor.comments.CommentsInfoItem; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.services.peertube.PeertubeInstance; import org.schabi.newpipe.fragments.BackPressable; @@ -868,10 +867,9 @@ private void openDetailFragmentFromCommentReplies( } // the root comment is the comment for which the user opened the replies page - @Nullable final CommentRepliesFragment repliesFragment = - (CommentRepliesFragment) fm.findFragmentByTag(CommentRepliesFragment.TAG); - @Nullable final CommentsInfoItem rootComment = - repliesFragment == null ? null : repliesFragment.getCommentsInfoItem(); + final var repliesFragment = (CommentRepliesFragment) + fm.findFragmentByTag(CommentRepliesFragment.TAG); + final var rootComment = repliesFragment == null ? null : repliesFragment.getComment(); // sometimes this function pops the backstack, other times it's handled by the system if (popBackStack) { diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt index 8b1726ffff1..bdffa856177 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt @@ -73,6 +73,7 @@ fun Comment(comment: CommentsInfoItem) { color = MaterialTheme.colorScheme.secondary ) + // TODO: Handle HTML and Markdown formats. Text( text = comment.commentText.content, // If the comment is expanded, we display all its content @@ -110,16 +111,33 @@ fun Comment(comment: CommentsInfoItem) { } } +fun CommentsInfoItem( + serviceId: Int = 1, + url: String = "", + name: String = "", + commentText: Description, + uploaderName: String, + textualUploadDate: String = "5 months ago", + likeCount: Int = 100, + isHeartedByUploader: Boolean = true, + isPinned: Boolean = true, +) = CommentsInfoItem(serviceId, url, name).apply { + this.commentText = commentText + this.uploaderName = uploaderName + this.textualUploadDate = textualUploadDate + this.likeCount = likeCount + this.isHeartedByUploader = isHeartedByUploader + this.isPinned = isPinned +} + @Preview(name = "Light mode", uiMode = Configuration.UI_MODE_NIGHT_NO) @Preview(name = "Dark mode", uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -fun CommentPreview() { - val comment = CommentsInfoItem(1, "", "") - comment.commentText = Description("Hello world!\n\nThis line should be hidden by default.", Description.PLAIN_TEXT) - comment.uploaderName = "Test" - comment.likeCount = 100 - comment.isHeartedByUploader = true - comment.isPinned = true +private fun CommentPreview() { + val comment = CommentsInfoItem( + commentText = Description("Hello world!\n\nThis line should be hidden by default.", Description.PLAIN_TEXT), + uploaderName = "Test", + ) AppTheme { Comment(comment) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentReplies.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentReplies.kt new file mode 100644 index 00000000000..05a6d1c3bb4 --- /dev/null +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentReplies.kt @@ -0,0 +1,60 @@ +package org.schabi.newpipe.fragments.list.comments + +import android.content.res.Configuration +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.material3.HorizontalDivider +import androidx.compose.runtime.Composable +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.paging.PagingData +import androidx.paging.compose.collectAsLazyPagingItems +import io.reactivex.rxjava3.disposables.CompositeDisposable +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flowOf +import org.schabi.newpipe.extractor.comments.CommentsInfoItem +import org.schabi.newpipe.extractor.stream.Description +import org.schabi.newpipe.ui.theme.AppTheme + +@Composable +fun CommentReplies( + comment: CommentsInfoItem, + flow: Flow>, + disposables: CompositeDisposable +) { + val replies = flow.collectAsLazyPagingItems() + + Column { + CommentRepliesHeader(comment = comment, disposables = disposables) + HorizontalDivider(thickness = 1.dp) + LazyColumn { + items(replies.itemCount) { + Comment(comment = replies[it]!!) + } + } + } +} + +@Preview(name = "Light mode", uiMode = Configuration.UI_MODE_NIGHT_NO) +@Preview(name = "Dark mode", uiMode = Configuration.UI_MODE_NIGHT_YES) +@Composable +private fun CommentRepliesPreview() { + val comment = CommentsInfoItem( + commentText = Description("Hello world!", Description.PLAIN_TEXT), + uploaderName = "Test", + ) + + val reply1 = CommentsInfoItem( + commentText = Description("This is a reply", Description.PLAIN_TEXT), + uploaderName = "Test 2", + ) + val reply2 = CommentsInfoItem( + commentText = Description("This is another reply.
This is another line.", Description.HTML), + uploaderName = "Test 3", + ) + val flow = flowOf(PagingData.from(listOf(reply1, reply2))) + + AppTheme { + CommentReplies(comment = comment, flow = flow, disposables = CompositeDisposable()) + } +} diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt index 1847d7d31d4..6afbc7e20eb 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt @@ -4,104 +4,50 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.compose.runtime.remember import androidx.compose.ui.platform.ComposeView -import icepick.State -import io.reactivex.rxjava3.core.Single +import androidx.fragment.app.Fragment +import androidx.paging.Pager +import androidx.paging.PagingConfig import io.reactivex.rxjava3.disposables.CompositeDisposable -import org.schabi.newpipe.R -import org.schabi.newpipe.error.UserAction -import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage import org.schabi.newpipe.extractor.comments.CommentsInfoItem -import org.schabi.newpipe.fragments.list.BaseListInfoFragment -import org.schabi.newpipe.info_list.ItemViewMode +import org.schabi.newpipe.ktx.serializable import org.schabi.newpipe.ui.theme.AppTheme -import org.schabi.newpipe.util.ExtractorHelper -import org.schabi.newpipe.util.Localization -import java.util.Queue -import java.util.function.Supplier -class CommentRepliesFragment() : BaseListInfoFragment(UserAction.REQUESTED_COMMENT_REPLIES) { - /** - * @return the comment to which the replies are shown - */ - @State - lateinit var commentsInfoItem: CommentsInfoItem // the comment to show replies of +class CommentRepliesFragment : Fragment() { private val disposables = CompositeDisposable() - - constructor(commentsInfoItem: CommentsInfoItem) : this() { - this.commentsInfoItem = commentsInfoItem - // setting "" as title since the title will be properly set right after - setInitialData(commentsInfoItem.serviceId, commentsInfoItem.url, "") - } + lateinit var comment: CommentsInfoItem override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { - return inflater.inflate(R.layout.fragment_comments, container, false) - } - - override fun onDestroyView() { - disposables.clear() - super.onDestroyView() - } + comment = requireArguments().serializable(COMMENT_KEY)!! + return ComposeView(requireContext()).apply { + setContent { + val flow = remember(comment) { + Pager(PagingConfig(pageSize = 20, enablePlaceholders = false)) { + CommentRepliesSource(comment) + }.flow + } - override fun getListHeaderSupplier(): Supplier { - return Supplier { - ComposeView(requireContext()).apply { - setContent { - AppTheme { - CommentRepliesHeader(commentsInfoItem, disposables) - } + AppTheme { + CommentReplies(comment = comment, flow = flow, disposables = disposables) } } } } - /*////////////////////////////////////////////////////////////////////////// - // State saving - ////////////////////////////////////////////////////////////////////////// */ - override fun writeTo(objectsToSave: Queue) { - super.writeTo(objectsToSave) - objectsToSave.add(commentsInfoItem) - } - - @Throws(Exception::class) - override fun readFrom(savedObjects: Queue) { - super.readFrom(savedObjects) - commentsInfoItem = savedObjects.poll() as CommentsInfoItem - } - - /*////////////////////////////////////////////////////////////////////////// - // Data loading - ////////////////////////////////////////////////////////////////////////// */ - override fun loadResult(forceLoad: Boolean): Single { - return Single.fromCallable { - CommentRepliesInfo( - commentsInfoItem, // the reply count string will be shown as the activity title - Localization.replyCount(requireContext(), commentsInfoItem.replyCount) - ) - } - } - - override fun loadMoreItemsLogic(): Single>? { - // commentsInfoItem.getUrl() should contain the url of the original - // ListInfo, which should be the stream url - return ExtractorHelper.getMoreCommentItems( - serviceId, commentsInfoItem.url, currentNextPage - ) - } - - /*////////////////////////////////////////////////////////////////////////// - // Utils - ////////////////////////////////////////////////////////////////////////// */ - override fun getItemViewMode(): ItemViewMode { - return ItemViewMode.LIST + override fun onDestroyView() { + super.onDestroyView() + disposables.clear() } companion object { @JvmField - val TAG: String = CommentRepliesFragment::class.java.simpleName + val TAG = CommentRepliesFragment::class.simpleName!! + + const val COMMENT_KEY = "comment" } } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt index 4c4dc53b332..5a2a3ede0dc 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt @@ -136,14 +136,8 @@ fun CommentRepliesHeader(comment: CommentsInfoItem, disposables: CompositeDispos } } -@Preview( - name = "Light mode", - uiMode = Configuration.UI_MODE_NIGHT_NO -) -@Preview( - name = "Dark mode", - uiMode = Configuration.UI_MODE_NIGHT_YES -) +@Preview(name = "Light mode", uiMode = Configuration.UI_MODE_NIGHT_NO) +@Preview(name = "Dark mode", uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable fun CommentRepliesHeaderPreview() { val disposables = CompositeDisposable() diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesInfo.java b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesInfo.java deleted file mode 100644 index cc160c39538..00000000000 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesInfo.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.schabi.newpipe.fragments.list.comments; - -import org.schabi.newpipe.extractor.ListInfo; -import org.schabi.newpipe.extractor.comments.CommentsInfoItem; -import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; - -import java.util.Collections; - -public final class CommentRepliesInfo extends ListInfo { - /** - * This class is used to wrap the comment replies page into a ListInfo object. - * - * @param comment the comment from which to get replies - * @param name will be shown as the fragment title - */ - public CommentRepliesInfo(final CommentsInfoItem comment, final String name) { - super(comment.getServiceId(), - new ListLinkHandler("", "", "", Collections.emptyList(), null), name); - setNextPage(comment.getReplies()); - setRelatedItems(Collections.emptyList()); // since it must be non-null - } -} diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesSource.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesSource.kt new file mode 100644 index 00000000000..ed602d91789 --- /dev/null +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesSource.kt @@ -0,0 +1,22 @@ +package org.schabi.newpipe.fragments.list.comments + +import androidx.paging.PagingState +import androidx.paging.rxjava3.RxPagingSource +import io.reactivex.rxjava3.core.Single +import io.reactivex.rxjava3.schedulers.Schedulers +import org.schabi.newpipe.extractor.Page +import org.schabi.newpipe.extractor.comments.CommentsInfoItem +import org.schabi.newpipe.util.ExtractorHelper + +class CommentRepliesSource( + private val commentsInfoItem: CommentsInfoItem, +) : RxPagingSource() { + override fun loadSingle(params: LoadParams): Single> { + val nextPage = params.key ?: commentsInfoItem.replies + return ExtractorHelper.getMoreCommentItems(commentsInfoItem.serviceId, commentsInfoItem.url, nextPage) + .subscribeOn(Schedulers.io()) + .map { LoadResult.Page(it.items, null, it.nextPage) } + } + + override fun getRefreshKey(state: PagingState) = null +} diff --git a/app/src/main/java/org/schabi/newpipe/ktx/Bundle.kt b/app/src/main/java/org/schabi/newpipe/ktx/Bundle.kt index 61721d5467c..e01cf620e43 100644 --- a/app/src/main/java/org/schabi/newpipe/ktx/Bundle.kt +++ b/app/src/main/java/org/schabi/newpipe/ktx/Bundle.kt @@ -1,9 +1,25 @@ package org.schabi.newpipe.ktx +import android.os.Build import android.os.Bundle import android.os.Parcelable import androidx.core.os.BundleCompat +import java.io.Serializable +import kotlin.reflect.safeCast inline fun Bundle.parcelableArrayList(key: String?): ArrayList? { return BundleCompat.getParcelableArrayList(this, key, T::class.java) } + +inline fun Bundle.serializable(key: String?): T? { + return getSerializable(this, key, T::class.java) +} + +fun getSerializable(bundle: Bundle, key: String?, clazz: Class): T? { + return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { + bundle.getSerializable(key, clazz) + } else { + @Suppress("DEPRECATION") + clazz.kotlin.safeCast(bundle.getSerializable(key)) + } +} diff --git a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java index 5dee32371b5..9accf22a5cc 100644 --- a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java @@ -9,6 +9,7 @@ import android.content.Intent; import android.net.Uri; import android.os.Build; +import android.os.Bundle; import android.util.Log; import android.widget.Toast; @@ -503,8 +504,11 @@ public static void openCommentAuthorIfPresent(@NonNull final FragmentActivity ac public static void openCommentRepliesFragment(@NonNull final FragmentActivity activity, @NonNull final CommentsInfoItem comment) { + final var bundle = new Bundle(); + bundle.putSerializable(CommentRepliesFragment.COMMENT_KEY, comment); + defaultTransaction(activity.getSupportFragmentManager()) - .replace(R.id.fragment_holder, new CommentRepliesFragment(comment), + .replace(R.id.fragment_holder, CommentRepliesFragment.class, bundle, CommentRepliesFragment.TAG) .addToBackStack(CommentRepliesFragment.TAG) .commit(); diff --git a/build.gradle b/build.gradle index 5a1ae1945de..49de9865968 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.9.23' + ext.kotlin_version = '1.9.24' repositories { google() mavenCentral() From f056edd7ae7de4ec00bebc212c6afba17e2e60fa Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Tue, 18 Jun 2024 09:34:12 +0530 Subject: [PATCH 21/72] Improve previews, display date of comment --- .../newpipe/fragments/list/comments/Comment.kt | 15 +++++++++++---- .../fragments/list/comments/CommentReplies.kt | 3 +++ .../list/comments/CommentRepliesHeader.kt | 17 ++++++++--------- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt index bdffa856177..78c9f88f476 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt @@ -33,6 +33,7 @@ import org.schabi.newpipe.R import org.schabi.newpipe.extractor.comments.CommentsInfoItem import org.schabi.newpipe.extractor.stream.Description import org.schabi.newpipe.ui.theme.AppTheme +import org.schabi.newpipe.util.Localization import org.schabi.newpipe.util.NavigationHelper import org.schabi.newpipe.util.image.ImageStrategy @@ -68,8 +69,11 @@ fun Comment(comment: CommentsInfoItem) { modifier = Modifier.clickable { isExpanded = !isExpanded }, verticalArrangement = Arrangement.spacedBy(4.dp) ) { + val date = Localization.relativeTimeOrTextual( + context, comment.uploadDate, comment.textualUploadDate + ) Text( - text = comment.uploaderName, + text = Localization.concatenateStrings(comment.uploaderName, date), color = MaterialTheme.colorScheme.secondary ) @@ -118,9 +122,9 @@ fun CommentsInfoItem( commentText: Description, uploaderName: String, textualUploadDate: String = "5 months ago", - likeCount: Int = 100, - isHeartedByUploader: Boolean = true, - isPinned: Boolean = true, + likeCount: Int = 0, + isHeartedByUploader: Boolean = false, + isPinned: Boolean = false, ) = CommentsInfoItem(serviceId, url, name).apply { this.commentText = commentText this.uploaderName = uploaderName @@ -137,6 +141,9 @@ private fun CommentPreview() { val comment = CommentsInfoItem( commentText = Description("Hello world!\n\nThis line should be hidden by default.", Description.PLAIN_TEXT), uploaderName = "Test", + likeCount = 100, + isPinned = true, + isHeartedByUploader = true ) AppTheme { diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentReplies.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentReplies.kt index 05a6d1c3bb4..42813f08753 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentReplies.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentReplies.kt @@ -42,6 +42,9 @@ private fun CommentRepliesPreview() { val comment = CommentsInfoItem( commentText = Description("Hello world!", Description.PLAIN_TEXT), uploaderName = "Test", + likeCount = 100, + isPinned = true, + isHeartedByUploader = true ) val reply1 = CommentsInfoItem( diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt index 5a2a3ede0dc..1853a134bb5 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt @@ -140,16 +140,15 @@ fun CommentRepliesHeader(comment: CommentsInfoItem, disposables: CompositeDispos @Preview(name = "Dark mode", uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable fun CommentRepliesHeaderPreview() { - val disposables = CompositeDisposable() - val comment = CommentsInfoItem(1, "", "") - comment.commentText = Description("Hello world!", Description.PLAIN_TEXT) - comment.uploaderName = "Test" - comment.textualUploadDate = "5 months ago" - comment.likeCount = 100 - comment.isPinned = true - comment.isHeartedByUploader = true + val comment = CommentsInfoItem( + commentText = Description("Hello world!", Description.PLAIN_TEXT), + uploaderName = "Test", + likeCount = 100, + isPinned = true, + isHeartedByUploader = true + ) AppTheme { - CommentRepliesHeader(comment, disposables) + CommentRepliesHeader(comment, CompositeDisposable()) } } From e75eb2d5449119e1aa5ab7996678bc39abe971c2 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Tue, 18 Jun 2024 16:13:20 +0530 Subject: [PATCH 22/72] Fixed some comment issues --- .../fragments/list/comments/Comment.kt | 44 ++++++++++--------- .../fragments/list/comments/CommentReplies.kt | 16 +++---- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt index 78c9f88f476..bde37ac9551 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt @@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width @@ -40,9 +41,15 @@ import org.schabi.newpipe.util.image.ImageStrategy @Composable fun Comment(comment: CommentsInfoItem) { val context = LocalContext.current + var isExpanded by rememberSaveable { mutableStateOf(false) } Surface(color = MaterialTheme.colorScheme.background) { - Row(modifier = Modifier.padding(all = 8.dp)) { + Row( + modifier = Modifier + .fillMaxWidth() + .clickable { isExpanded = !isExpanded } + .padding(all = 8.dp) + ) { if (ImageStrategy.shouldLoadImages()) { AsyncImage( model = ImageStrategy.choosePreferredImage(comment.uploaderAvatars), @@ -63,19 +70,23 @@ fun Comment(comment: CommentsInfoItem) { Spacer(modifier = Modifier.width(8.dp)) - var isExpanded by rememberSaveable { mutableStateOf(false) } + Column(verticalArrangement = Arrangement.spacedBy(4.dp)) { + Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) { + if (comment.isPinned) { + Image( + painter = painterResource(R.drawable.ic_pin), + contentDescription = stringResource(R.string.detail_pinned_comment_view_description) + ) + } - Column( - modifier = Modifier.clickable { isExpanded = !isExpanded }, - verticalArrangement = Arrangement.spacedBy(4.dp) - ) { - val date = Localization.relativeTimeOrTextual( - context, comment.uploadDate, comment.textualUploadDate - ) - Text( - text = Localization.concatenateStrings(comment.uploaderName, date), - color = MaterialTheme.colorScheme.secondary - ) + val date = Localization.relativeTimeOrTextual( + context, comment.uploadDate, comment.textualUploadDate + ) + Text( + text = Localization.concatenateStrings(comment.uploaderName, date), + color = MaterialTheme.colorScheme.secondary + ) + } // TODO: Handle HTML and Markdown formats. Text( @@ -100,13 +111,6 @@ fun Comment(comment: CommentsInfoItem) { contentDescription = stringResource(R.string.detail_heart_img_view_description) ) } - - if (comment.isPinned) { - Image( - painter = painterResource(R.drawable.ic_pin), - contentDescription = stringResource(R.string.detail_pinned_comment_view_description) - ) - } } } } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentReplies.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentReplies.kt index 42813f08753..dcabedb48ea 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentReplies.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentReplies.kt @@ -1,7 +1,6 @@ package org.schabi.newpipe.fragments.list.comments import android.content.res.Configuration -import androidx.compose.foundation.layout.Column import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material3.HorizontalDivider import androidx.compose.runtime.Composable @@ -24,13 +23,14 @@ fun CommentReplies( ) { val replies = flow.collectAsLazyPagingItems() - Column { - CommentRepliesHeader(comment = comment, disposables = disposables) - HorizontalDivider(thickness = 1.dp) - LazyColumn { - items(replies.itemCount) { - Comment(comment = replies[it]!!) - } + LazyColumn { + item { + CommentRepliesHeader(comment = comment, disposables = disposables) + HorizontalDivider(thickness = 1.dp) + } + + items(replies.itemCount) { + Comment(comment = replies[it]!!) } } } From c29fa7008057212143666fb857ffba23b5d0b084 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Wed, 19 Jun 2024 12:40:49 +0530 Subject: [PATCH 23/72] Use AnnotatedString to handle HTML parsing --- app/build.gradle | 1 + .../fragments/list/comments/Comment.kt | 50 ++++++++++++++----- .../fragments/list/comments/CommentReplies.kt | 8 ++- .../list/comments/CommentRepliesFragment.kt | 9 +--- .../list/comments/CommentRepliesHeader.kt | 28 ++--------- 5 files changed, 48 insertions(+), 48 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 361d99595bd..0739cb2976c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -293,6 +293,7 @@ dependencies { implementation 'androidx.compose.material3:material3' implementation 'androidx.activity:activity-compose' implementation 'androidx.compose.ui:ui-tooling-preview' + implementation 'androidx.compose.ui:ui-text:1.7.0-beta03' // Needed for parsing HTML to AnnotatedString // Paging implementation 'androidx.paging:paging-rxjava3:3.3.0' diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt index bde37ac9551..0f597287960 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt @@ -18,6 +18,7 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier @@ -25,8 +26,13 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.AnnotatedString +import androidx.compose.ui.text.ParagraphStyle +import androidx.compose.ui.text.fromHtml import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.tooling.preview.PreviewParameter +import androidx.compose.ui.tooling.preview.PreviewParameterProvider import androidx.compose.ui.unit.dp import androidx.fragment.app.FragmentActivity import coil.compose.AsyncImage @@ -38,6 +44,18 @@ import org.schabi.newpipe.util.Localization import org.schabi.newpipe.util.NavigationHelper import org.schabi.newpipe.util.image.ImageStrategy +@Composable +fun rememberParsedText(commentText: Description): AnnotatedString { + // TODO: Handle links and hashtags, Markdown. + return remember(commentText) { + if (commentText.type == Description.HTML) { + AnnotatedString.fromHtml(commentText.content) + } else { + AnnotatedString(commentText.content, ParagraphStyle()) + } + } +} + @Composable fun Comment(comment: CommentsInfoItem) { val context = LocalContext.current @@ -79,23 +97,22 @@ fun Comment(comment: CommentsInfoItem) { ) } - val date = Localization.relativeTimeOrTextual( - context, comment.uploadDate, comment.textualUploadDate - ) - Text( - text = Localization.concatenateStrings(comment.uploaderName, date), - color = MaterialTheme.colorScheme.secondary - ) + val nameAndDate = remember(comment) { + val date = Localization.relativeTimeOrTextual( + context, comment.uploadDate, comment.textualUploadDate + ) + Localization.concatenateStrings(comment.uploaderName, date) + } + Text(text = nameAndDate, color = MaterialTheme.colorScheme.secondary) } - // TODO: Handle HTML and Markdown formats. Text( - text = comment.commentText.content, + text = rememberParsedText(comment.commentText), // If the comment is expanded, we display all its content // otherwise we only display the first two lines maxLines = if (isExpanded) Int.MAX_VALUE else 2, overflow = TextOverflow.Ellipsis, - style = MaterialTheme.typography.bodyMedium + style = MaterialTheme.typography.bodyMedium, ) Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { @@ -138,12 +155,21 @@ fun CommentsInfoItem( this.isPinned = isPinned } +class DescriptionPreviewProvider : PreviewParameterProvider { + override val values = sequenceOf( + Description("Hello world!

This line should be hidden by default.", Description.HTML), + Description("Hello world!\n\nThis line should be hidden by default.", Description.PLAIN_TEXT), + ) +} + @Preview(name = "Light mode", uiMode = Configuration.UI_MODE_NIGHT_NO) @Preview(name = "Dark mode", uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun CommentPreview() { +private fun CommentPreview( + @PreviewParameter(DescriptionPreviewProvider::class) description: Description +) { val comment = CommentsInfoItem( - commentText = Description("Hello world!\n\nThis line should be hidden by default.", Description.PLAIN_TEXT), + commentText = description, uploaderName = "Test", likeCount = 100, isPinned = true, diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentReplies.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentReplies.kt index dcabedb48ea..53a4fa4bfe5 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentReplies.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentReplies.kt @@ -8,7 +8,6 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.paging.PagingData import androidx.paging.compose.collectAsLazyPagingItems -import io.reactivex.rxjava3.disposables.CompositeDisposable import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOf import org.schabi.newpipe.extractor.comments.CommentsInfoItem @@ -18,14 +17,13 @@ import org.schabi.newpipe.ui.theme.AppTheme @Composable fun CommentReplies( comment: CommentsInfoItem, - flow: Flow>, - disposables: CompositeDisposable + flow: Flow> ) { val replies = flow.collectAsLazyPagingItems() LazyColumn { item { - CommentRepliesHeader(comment = comment, disposables = disposables) + CommentRepliesHeader(comment = comment) HorizontalDivider(thickness = 1.dp) } @@ -58,6 +56,6 @@ private fun CommentRepliesPreview() { val flow = flowOf(PagingData.from(listOf(reply1, reply2))) AppTheme { - CommentReplies(comment = comment, flow = flow, disposables = CompositeDisposable()) + CommentReplies(comment = comment, flow = flow) } } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt index 6afbc7e20eb..e1ed3041e64 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt @@ -9,13 +9,11 @@ import androidx.compose.ui.platform.ComposeView import androidx.fragment.app.Fragment import androidx.paging.Pager import androidx.paging.PagingConfig -import io.reactivex.rxjava3.disposables.CompositeDisposable import org.schabi.newpipe.extractor.comments.CommentsInfoItem import org.schabi.newpipe.ktx.serializable import org.schabi.newpipe.ui.theme.AppTheme class CommentRepliesFragment : Fragment() { - private val disposables = CompositeDisposable() lateinit var comment: CommentsInfoItem override fun onCreateView( @@ -33,17 +31,12 @@ class CommentRepliesFragment : Fragment() { } AppTheme { - CommentReplies(comment = comment, flow = flow, disposables = disposables) + CommentReplies(comment = comment, flow = flow) } } } } - override fun onDestroyView() { - super.onDestroyView() - disposables.clear() - } - companion object { @JvmField val TAG = CommentRepliesFragment::class.simpleName!! diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt index 1853a134bb5..2c93999e8d7 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt @@ -1,7 +1,6 @@ package org.schabi.newpipe.fragments.list.comments import android.content.res.Configuration -import android.widget.TextView import androidx.compose.foundation.Image import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement @@ -25,24 +24,18 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import androidx.compose.ui.viewinterop.AndroidView -import androidx.core.text.HtmlCompat -import androidx.core.text.method.LinkMovementMethodCompat import androidx.fragment.app.FragmentActivity import coil.compose.AsyncImage -import io.reactivex.rxjava3.disposables.CompositeDisposable import org.schabi.newpipe.R import org.schabi.newpipe.extractor.comments.CommentsInfoItem import org.schabi.newpipe.extractor.stream.Description import org.schabi.newpipe.ui.theme.AppTheme import org.schabi.newpipe.util.Localization import org.schabi.newpipe.util.NavigationHelper -import org.schabi.newpipe.util.ServiceHelper import org.schabi.newpipe.util.image.ImageStrategy -import org.schabi.newpipe.util.text.TextLinkifier @Composable -fun CommentRepliesHeader(comment: CommentsInfoItem, disposables: CompositeDisposable) { +fun CommentRepliesHeader(comment: CommentsInfoItem) { val context = LocalContext.current Surface(color = MaterialTheme.colorScheme.background) { @@ -117,20 +110,9 @@ fun CommentRepliesHeader(comment: CommentsInfoItem, disposables: CompositeDispos } } - AndroidView( - factory = { context -> - TextView(context).apply { - movementMethod = LinkMovementMethodCompat.getInstance() - } - }, - update = { view -> - // setup comment content - TextLinkifier.fromDescription( - view, comment.commentText, HtmlCompat.FROM_HTML_MODE_LEGACY, - ServiceHelper.getServiceById(comment.serviceId), comment.url, disposables, - null - ) - } + Text( + text = rememberParsedText(comment.commentText), + style = MaterialTheme.typography.bodyMedium ) } } @@ -149,6 +131,6 @@ fun CommentRepliesHeaderPreview() { ) AppTheme { - CommentRepliesHeader(comment, CompositeDisposable()) + CommentRepliesHeader(comment) } } From e71fc38fe7d40c7bda91222384060de370231816 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Wed, 19 Jun 2024 12:59:19 +0530 Subject: [PATCH 24/72] Add replies button --- .../fragments/list/comments/Comment.kt | 50 ++++++++++++++----- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt index 0f597287960..d7595f9fadf 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt @@ -15,16 +15,19 @@ import androidx.compose.foundation.shape.CircleShape import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text +import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.ParagraphStyle @@ -37,6 +40,7 @@ import androidx.compose.ui.unit.dp import androidx.fragment.app.FragmentActivity import coil.compose.AsyncImage import org.schabi.newpipe.R +import org.schabi.newpipe.extractor.Page import org.schabi.newpipe.extractor.comments.CommentsInfoItem import org.schabi.newpipe.extractor.stream.Description import org.schabi.newpipe.ui.theme.AppTheme @@ -115,24 +119,38 @@ fun Comment(comment: CommentsInfoItem) { style = MaterialTheme.typography.bodyMedium, ) - Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { - Image( - painter = painterResource(R.drawable.ic_thumb_up), - contentDescription = stringResource(R.string.detail_likes_img_view_description) - ) - Text(text = comment.likeCount.toString()) - - if (comment.isHeartedByUploader) { + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.SpaceBetween, + verticalAlignment = Alignment.CenterVertically + ) { + Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { Image( - painter = painterResource(R.drawable.ic_heart), - contentDescription = stringResource(R.string.detail_heart_img_view_description) + painter = painterResource(R.drawable.ic_thumb_up), + contentDescription = stringResource(R.string.detail_likes_img_view_description) ) + Text(text = comment.likeCount.toString()) + + if (comment.isHeartedByUploader) { + Image( + painter = painterResource(R.drawable.ic_heart), + contentDescription = stringResource(R.string.detail_heart_img_view_description) + ) + } + } + + if (comment.replies != null) { + TextButton(onClick = { /*TODO*/ }) { + Text( + text = pluralStringResource( + R.plurals.replies, comment.replyCount, comment.replyCount.toString() + ) + ) + } } } } } - - // TODO: Add support for comment replies } } @@ -146,6 +164,8 @@ fun CommentsInfoItem( likeCount: Int = 0, isHeartedByUploader: Boolean = false, isPinned: Boolean = false, + replies: Page? = null, + replyCount: Int = 0, ) = CommentsInfoItem(serviceId, url, name).apply { this.commentText = commentText this.uploaderName = uploaderName @@ -153,6 +173,8 @@ fun CommentsInfoItem( this.likeCount = likeCount this.isHeartedByUploader = isHeartedByUploader this.isPinned = isPinned + this.replies = replies + this.replyCount = replyCount } class DescriptionPreviewProvider : PreviewParameterProvider { @@ -173,7 +195,9 @@ private fun CommentPreview( uploaderName = "Test", likeCount = 100, isPinned = true, - isHeartedByUploader = true + isHeartedByUploader = true, + replies = Page(""), + replyCount = 10 ) AppTheme { From b6a0f5d9c276aeacde76e2d7b3158b5f8d7d7f96 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Thu, 20 Jun 2024 07:08:12 +0530 Subject: [PATCH 25/72] Set view strategy --- .../newpipe/fragments/list/comments/CommentRepliesFragment.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt index e1ed3041e64..555d1e58df0 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt @@ -6,6 +6,7 @@ import android.view.View import android.view.ViewGroup import androidx.compose.runtime.remember import androidx.compose.ui.platform.ComposeView +import androidx.compose.ui.platform.ViewCompositionStrategy import androidx.fragment.app.Fragment import androidx.paging.Pager import androidx.paging.PagingConfig @@ -23,6 +24,7 @@ class CommentRepliesFragment : Fragment() { ): View { comment = requireArguments().serializable(COMMENT_KEY)!! return ComposeView(requireContext()).apply { + setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) setContent { val flow = remember(comment) { Pager(PagingConfig(pageSize = 20, enablePlaceholders = false)) { From 552ea502e1fee7beadb1cd746b92784432a177eb Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Thu, 20 Jun 2024 09:12:40 +0530 Subject: [PATCH 26/72] Fixed like count display --- .../org/schabi/newpipe/fragments/list/comments/Comment.kt | 2 +- .../newpipe/fragments/list/comments/CommentRepliesHeader.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt index d7595f9fadf..36e7aebf6a2 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt @@ -129,7 +129,7 @@ fun Comment(comment: CommentsInfoItem) { painter = painterResource(R.drawable.ic_thumb_up), contentDescription = stringResource(R.string.detail_likes_img_view_description) ) - Text(text = comment.likeCount.toString()) + Text(text = Localization.likeCount(context, comment.likeCount)) if (comment.isHeartedByUploader) { Image( diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt index 2c93999e8d7..e3f5295be30 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt @@ -92,7 +92,7 @@ fun CommentRepliesHeader(comment: CommentsInfoItem) { painter = painterResource(R.drawable.ic_thumb_up), contentDescription = stringResource(R.string.detail_likes_img_view_description) ) - Text(text = comment.likeCount.toString()) + Text(text = Localization.likeCount(context, comment.likeCount)) if (comment.isHeartedByUploader) { Image( @@ -125,7 +125,7 @@ fun CommentRepliesHeaderPreview() { val comment = CommentsInfoItem( commentText = Description("Hello world!", Description.PLAIN_TEXT), uploaderName = "Test", - likeCount = 100, + likeCount = 1000, isPinned = true, isHeartedByUploader = true ) From cf3fb0b91a7b5107d9a2b9e4bbd85aff4002123c Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Fri, 21 Jun 2024 08:28:26 +0530 Subject: [PATCH 27/72] Fixed fragment title --- .../fragments/list/comments/CommentRepliesFragment.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt index 555d1e58df0..4a362b8f8aa 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt @@ -4,6 +4,7 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.appcompat.app.AppCompatActivity import androidx.compose.runtime.remember import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.platform.ViewCompositionStrategy @@ -13,6 +14,7 @@ import androidx.paging.PagingConfig import org.schabi.newpipe.extractor.comments.CommentsInfoItem import org.schabi.newpipe.ktx.serializable import org.schabi.newpipe.ui.theme.AppTheme +import org.schabi.newpipe.util.Localization class CommentRepliesFragment : Fragment() { lateinit var comment: CommentsInfoItem @@ -23,6 +25,12 @@ class CommentRepliesFragment : Fragment() { savedInstanceState: Bundle? ): View { comment = requireArguments().serializable(COMMENT_KEY)!! + + val activity = requireActivity() as AppCompatActivity + val bar = activity.supportActionBar!! + bar.setDisplayShowTitleEnabled(true) + bar.title = Localization.replyCount(activity, comment.replyCount) + return ComposeView(requireContext()).apply { setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) setContent { From f27273ef33104b133372af586e39b08ad36e6fca Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Fri, 21 Jun 2024 16:05:44 +0530 Subject: [PATCH 28/72] Rename .java to .kt --- .../list/comments/{CommentsFragment.java => CommentsFragment.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/src/main/java/org/schabi/newpipe/fragments/list/comments/{CommentsFragment.java => CommentsFragment.kt} (100%) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentsFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentsFragment.kt similarity index 100% rename from app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentsFragment.java rename to app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentsFragment.kt From 03bc4e2e8878351b9532dc9e556dc1e2496462b1 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Fri, 21 Jun 2024 16:05:45 +0530 Subject: [PATCH 29/72] Migrate comments fragment to Jetpack Compose --- .../fragments/detail/VideoDetailFragment.java | 17 +- .../fragments/list/comments/Comment.kt | 9 +- .../list/comments/CommentRepliesFragment.kt | 6 +- .../list/comments/CommentRepliesSource.kt | 22 -- .../{CommentReplies.kt => CommentSection.kt} | 35 ++- .../list/comments/CommentsFragment.kt | 166 +++++--------- .../fragments/list/comments/CommentsSource.kt | 36 +++ .../newpipe/info_list/InfoItemBuilder.java | 26 +-- .../newpipe/info_list/InfoListAdapter.java | 61 ++--- .../holder/CommentInfoItemHolder.java | 208 ------------------ .../schabi/newpipe/util/ExtractorHelper.java | 9 - app/src/main/res/layout/fragment_comments.xml | 71 ------ app/src/main/res/layout/list_comment_item.xml | 104 --------- 13 files changed, 163 insertions(+), 607 deletions(-) delete mode 100644 app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesSource.kt rename app/src/main/java/org/schabi/newpipe/fragments/list/comments/{CommentReplies.kt => CommentSection.kt} (62%) create mode 100644 app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentsSource.kt delete mode 100644 app/src/main/java/org/schabi/newpipe/info_list/holder/CommentInfoItemHolder.java delete mode 100644 app/src/main/res/layout/fragment_comments.xml delete mode 100644 app/src/main/res/layout/list_comment_item.xml diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 11a315d691f..a364c42cda6 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -882,7 +882,7 @@ private void initTabs() { if (shouldShowComments()) { pageAdapter.addFragment( - CommentsFragment.getInstance(serviceId, url, title), COMMENTS_TAB_TAG); + CommentsFragment.getInstance(serviceId, url), COMMENTS_TAB_TAG); tabIcons.add(R.drawable.ic_comment); tabContentDescriptions.add(R.string.comments_tab_description); } @@ -1014,16 +1014,15 @@ public void scrollToTop() { public void scrollToComment(final CommentsInfoItem comment) { final int commentsTabPos = pageAdapter.getItemPositionByTitle(COMMENTS_TAB_TAG); - final Fragment fragment = pageAdapter.getItem(commentsTabPos); - if (!(fragment instanceof CommentsFragment)) { - return; - } + final var fragment = pageAdapter.getItem(commentsTabPos); + // TODO: Implement the scrolling with Compose. // unexpand the app bar only if scrolling to the comment succeeded - if (((CommentsFragment) fragment).scrollToComment(comment)) { - binding.appBarLayout.setExpanded(false, false); - binding.viewPager.setCurrentItem(commentsTabPos, false); - } +// if (fragment instanceof CommentsFragment commentsFragment && +// commentsFragment.scrollToComment(comment)) { +// binding.appBarLayout.setExpanded(false, false); +// binding.viewPager.setCurrentItem(commentsTabPos, false); +// } } /*////////////////////////////////////////////////////////////////////////// diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt index 36e7aebf6a2..ac254a5b37c 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt @@ -83,8 +83,7 @@ fun Comment(comment: CommentsInfoItem) { .clip(CircleShape) .clickable { NavigationHelper.openCommentAuthorIfPresent( - context as FragmentActivity, - comment + context as FragmentActivity, comment ) } ) @@ -140,7 +139,11 @@ fun Comment(comment: CommentsInfoItem) { } if (comment.replies != null) { - TextButton(onClick = { /*TODO*/ }) { + TextButton(onClick = { + NavigationHelper.openCommentRepliesFragment( + context as FragmentActivity, comment + ) + }) { Text( text = pluralStringResource( R.plurals.replies, comment.replyCount, comment.replyCount.toString() diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt index 4a362b8f8aa..e25b3a9609f 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.kt @@ -31,17 +31,17 @@ class CommentRepliesFragment : Fragment() { bar.setDisplayShowTitleEnabled(true) bar.title = Localization.replyCount(activity, comment.replyCount) - return ComposeView(requireContext()).apply { + return ComposeView(activity).apply { setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) setContent { val flow = remember(comment) { Pager(PagingConfig(pageSize = 20, enablePlaceholders = false)) { - CommentRepliesSource(comment) + CommentsSource(comment.serviceId, comment.url, comment.replies) }.flow } AppTheme { - CommentReplies(comment = comment, flow = flow) + CommentSection(parentComment = comment, flow = flow) } } } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesSource.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesSource.kt deleted file mode 100644 index ed602d91789..00000000000 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesSource.kt +++ /dev/null @@ -1,22 +0,0 @@ -package org.schabi.newpipe.fragments.list.comments - -import androidx.paging.PagingState -import androidx.paging.rxjava3.RxPagingSource -import io.reactivex.rxjava3.core.Single -import io.reactivex.rxjava3.schedulers.Schedulers -import org.schabi.newpipe.extractor.Page -import org.schabi.newpipe.extractor.comments.CommentsInfoItem -import org.schabi.newpipe.util.ExtractorHelper - -class CommentRepliesSource( - private val commentsInfoItem: CommentsInfoItem, -) : RxPagingSource() { - override fun loadSingle(params: LoadParams): Single> { - val nextPage = params.key ?: commentsInfoItem.replies - return ExtractorHelper.getMoreCommentItems(commentsInfoItem.serviceId, commentsInfoItem.url, nextPage) - .subscribeOn(Schedulers.io()) - .map { LoadResult.Page(it.items, null, it.nextPage) } - } - - override fun getRefreshKey(state: PagingState) = null -} diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentReplies.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentSection.kt similarity index 62% rename from app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentReplies.kt rename to app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentSection.kt index 53a4fa4bfe5..45a8b5e72ab 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentReplies.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentSection.kt @@ -15,16 +15,18 @@ import org.schabi.newpipe.extractor.stream.Description import org.schabi.newpipe.ui.theme.AppTheme @Composable -fun CommentReplies( - comment: CommentsInfoItem, - flow: Flow> +fun CommentSection( + flow: Flow>, + parentComment: CommentsInfoItem? = null, ) { val replies = flow.collectAsLazyPagingItems() LazyColumn { - item { - CommentRepliesHeader(comment = comment) - HorizontalDivider(thickness = 1.dp) + if (parentComment != null) { + item { + CommentRepliesHeader(comment = parentComment) + HorizontalDivider(thickness = 1.dp) + } } items(replies.itemCount) { @@ -33,6 +35,25 @@ fun CommentReplies( } } +@Preview(name = "Light mode", uiMode = Configuration.UI_MODE_NIGHT_NO) +@Preview(name = "Dark mode", uiMode = Configuration.UI_MODE_NIGHT_YES) +@Composable +private fun CommentSectionPreview() { + val comment1 = CommentsInfoItem( + commentText = Description("This is a comment", Description.PLAIN_TEXT), + uploaderName = "Test", + ) + val comment2 = CommentsInfoItem( + commentText = Description("This is another comment.
This is another line.", Description.HTML), + uploaderName = "Test 2", + ) + val flow = flowOf(PagingData.from(listOf(comment1, comment2))) + + AppTheme { + CommentSection(flow = flow) + } +} + @Preview(name = "Light mode", uiMode = Configuration.UI_MODE_NIGHT_NO) @Preview(name = "Dark mode", uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable @@ -56,6 +77,6 @@ private fun CommentRepliesPreview() { val flow = flowOf(PagingData.from(listOf(reply1, reply2))) AppTheme { - CommentReplies(comment = comment, flow = flow) + CommentSection(parentComment = comment, flow = flow) } } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentsFragment.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentsFragment.kt index e25e02794f1..decd9391cf3 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentsFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentsFragment.kt @@ -1,123 +1,55 @@ -package org.schabi.newpipe.fragments.list.comments; - -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -import org.schabi.newpipe.R; -import org.schabi.newpipe.error.UserAction; -import org.schabi.newpipe.extractor.ListExtractor; -import org.schabi.newpipe.extractor.comments.CommentsInfo; -import org.schabi.newpipe.extractor.comments.CommentsInfoItem; -import org.schabi.newpipe.fragments.list.BaseListInfoFragment; -import org.schabi.newpipe.info_list.ItemViewMode; -import org.schabi.newpipe.ktx.ViewUtils; -import org.schabi.newpipe.util.ExtractorHelper; - -import io.reactivex.rxjava3.core.Single; -import io.reactivex.rxjava3.disposables.CompositeDisposable; - -public class CommentsFragment extends BaseListInfoFragment { - private final CompositeDisposable disposables = new CompositeDisposable(); - - private TextView emptyStateDesc; - - public static CommentsFragment getInstance(final int serviceId, final String url, - final String name) { - final CommentsFragment instance = new CommentsFragment(); - instance.setInitialData(serviceId, url, name); - return instance; - } - - public CommentsFragment() { - super(UserAction.REQUESTED_COMMENTS); - } - - @Override - protected void initViews(final View rootView, final Bundle savedInstanceState) { - super.initViews(rootView, savedInstanceState); - - emptyStateDesc = rootView.findViewById(R.id.empty_state_desc); - } - - /*////////////////////////////////////////////////////////////////////////// - // LifeCycle - //////////////////////////////////////////////////////////////////////////*/ - - @Override - public View onCreateView(@NonNull final LayoutInflater inflater, - @Nullable final ViewGroup container, - @Nullable final Bundle savedInstanceState) { - return inflater.inflate(R.layout.fragment_comments, container, false); - } - - @Override - public void onDestroy() { - super.onDestroy(); - disposables.clear(); - } - - /*////////////////////////////////////////////////////////////////////////// - // Load and handle - //////////////////////////////////////////////////////////////////////////*/ - - @Override - protected Single> loadMoreItemsLogic() { - return ExtractorHelper.getMoreCommentItems(serviceId, currentInfo, currentNextPage); - } - - @Override - protected Single loadResult(final boolean forceLoad) { - return ExtractorHelper.getCommentsInfo(serviceId, url, forceLoad); - } - - /*////////////////////////////////////////////////////////////////////////// - // Contract - //////////////////////////////////////////////////////////////////////////*/ - - @Override - public void handleResult(@NonNull final CommentsInfo result) { - super.handleResult(result); - - emptyStateDesc.setText( - result.isCommentsDisabled() - ? R.string.comments_are_disabled - : R.string.no_comments); - - ViewUtils.slideUp(requireView(), 120, 150, 0.06f); - disposables.clear(); +package org.schabi.newpipe.fragments.list.comments + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.compose.runtime.remember +import androidx.compose.ui.platform.ComposeView +import androidx.compose.ui.platform.ViewCompositionStrategy +import androidx.core.os.bundleOf +import androidx.fragment.app.Fragment +import androidx.paging.Pager +import androidx.paging.PagingConfig +import org.schabi.newpipe.ui.theme.AppTheme +import org.schabi.newpipe.util.NO_SERVICE_ID + +class CommentsFragment : Fragment() { + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + val arguments = requireArguments() + val serviceId = arguments.getInt(SERVICE_ID, NO_SERVICE_ID) + val url = arguments.getString(URL) + + return ComposeView(requireContext()).apply { + setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) + setContent { + val flow = remember(serviceId, url) { + Pager(PagingConfig(pageSize = 20, enablePlaceholders = false)) { + CommentsSource(serviceId, url, null) + }.flow + } + + AppTheme { + CommentSection(flow = flow) + } + } + } } - /*////////////////////////////////////////////////////////////////////////// - // Utils - //////////////////////////////////////////////////////////////////////////*/ - - @Override - public void setTitle(final String title) { } + companion object { + private const val SERVICE_ID = "serviceId" + private const val URL = "url" - @Override - public void onCreateOptionsMenu(@NonNull final Menu menu, - @NonNull final MenuInflater inflater) { } - - @Override - protected ItemViewMode getItemViewMode() { - return ItemViewMode.LIST; - } - - public boolean scrollToComment(final CommentsInfoItem comment) { - final int position = infoListAdapter.getItemsList().indexOf(comment); - if (position < 0) { - return false; + @JvmStatic + fun getInstance(serviceId: Int, url: String?) = CommentsFragment().apply { + arguments = bundleOf( + SERVICE_ID to serviceId, + URL to url + ) } - - itemsList.scrollToPosition(position); - return true; } } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentsSource.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentsSource.kt new file mode 100644 index 00000000000..6288efaeca6 --- /dev/null +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentsSource.kt @@ -0,0 +1,36 @@ +package org.schabi.newpipe.fragments.list.comments + +import androidx.paging.PagingState +import androidx.paging.rxjava3.RxPagingSource +import io.reactivex.rxjava3.core.Single +import io.reactivex.rxjava3.schedulers.Schedulers +import org.schabi.newpipe.extractor.Page +import org.schabi.newpipe.extractor.comments.CommentsInfoItem +import org.schabi.newpipe.util.ExtractorHelper + +class CommentsSource( + private val serviceId: Int, + private val url: String?, + private val repliesPage: Page? +) : RxPagingSource() { + override fun loadSingle(params: LoadParams): Single> { + // repliesPage is non-null only when used to load the comment replies + val nextKey = params.key ?: repliesPage + + return nextKey?.let { + ExtractorHelper.getMoreCommentItems(serviceId, url, it) + .subscribeOn(Schedulers.io()) + .map { LoadResult.Page(it.items, null, it.nextPage) } + } ?: ExtractorHelper.getCommentsInfo(serviceId, url, false) + .subscribeOn(Schedulers.io()) + .map { + if (it.isCommentsDisabled) { + LoadResult.Invalid() + } else { + LoadResult.Page(it.relatedItems, null, it.nextPage) + } + } + } + + override fun getRefreshKey(state: PagingState) = null +} diff --git a/app/src/main/java/org/schabi/newpipe/info_list/InfoItemBuilder.java b/app/src/main/java/org/schabi/newpipe/info_list/InfoItemBuilder.java index d959c63277c..a1526af2894 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/InfoItemBuilder.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/InfoItemBuilder.java @@ -13,7 +13,6 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.info_list.holder.ChannelInfoItemHolder; import org.schabi.newpipe.info_list.holder.ChannelMiniInfoItemHolder; -import org.schabi.newpipe.info_list.holder.CommentInfoItemHolder; import org.schabi.newpipe.info_list.holder.InfoItemHolder; import org.schabi.newpipe.info_list.holder.PlaylistInfoItemHolder; import org.schabi.newpipe.info_list.holder.PlaylistMiniInfoItemHolder; @@ -75,21 +74,16 @@ public View buildView(@NonNull final ViewGroup parent, @NonNull final InfoItem i private InfoItemHolder holderFromInfoType(@NonNull final ViewGroup parent, @NonNull final InfoItem.InfoType infoType, final boolean useMiniVariant) { - switch (infoType) { - case STREAM: - return useMiniVariant ? new StreamMiniInfoItemHolder(this, parent) - : new StreamInfoItemHolder(this, parent); - case CHANNEL: - return useMiniVariant ? new ChannelMiniInfoItemHolder(this, parent) - : new ChannelInfoItemHolder(this, parent); - case PLAYLIST: - return useMiniVariant ? new PlaylistMiniInfoItemHolder(this, parent) - : new PlaylistInfoItemHolder(this, parent); - case COMMENT: - return new CommentInfoItemHolder(this, parent); - default: - throw new RuntimeException("InfoType not expected = " + infoType.name()); - } + return switch (infoType) { + case STREAM -> useMiniVariant ? new StreamMiniInfoItemHolder(this, parent) + : new StreamInfoItemHolder(this, parent); + case CHANNEL -> useMiniVariant ? new ChannelMiniInfoItemHolder(this, parent) + : new ChannelInfoItemHolder(this, parent); + case PLAYLIST -> useMiniVariant ? new PlaylistMiniInfoItemHolder(this, parent) + : new PlaylistInfoItemHolder(this, parent); + case COMMENT -> + throw new IllegalArgumentException("Comments should be rendered using Compose"); + }; } public Context getContext() { diff --git a/app/src/main/java/org/schabi/newpipe/info_list/InfoListAdapter.java b/app/src/main/java/org/schabi/newpipe/info_list/InfoListAdapter.java index 575568c00f9..e7cf9ba9a9e 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/InfoListAdapter.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/InfoListAdapter.java @@ -21,7 +21,6 @@ import org.schabi.newpipe.info_list.holder.ChannelGridInfoItemHolder; import org.schabi.newpipe.info_list.holder.ChannelInfoItemHolder; import org.schabi.newpipe.info_list.holder.ChannelMiniInfoItemHolder; -import org.schabi.newpipe.info_list.holder.CommentInfoItemHolder; import org.schabi.newpipe.info_list.holder.InfoItemHolder; import org.schabi.newpipe.info_list.holder.PlaylistCardInfoItemHolder; import org.schabi.newpipe.info_list.holder.PlaylistGridInfoItemHolder; @@ -283,46 +282,32 @@ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull final ViewGroup paren Log.d(TAG, "onCreateViewHolder() called with: " + "parent = [" + parent + "], type = [" + type + "]"); } - switch (type) { + return switch (type) { // #4475 and #3368 // Always create a new instance otherwise the same instance // is sometimes reused which causes a crash - case HEADER_TYPE: - return new HFHolder(headerSupplier.get()); - case FOOTER_TYPE: - return new HFHolder(PignateFooterBinding - .inflate(layoutInflater, parent, false) - .getRoot() - ); - case MINI_STREAM_HOLDER_TYPE: - return new StreamMiniInfoItemHolder(infoItemBuilder, parent); - case STREAM_HOLDER_TYPE: - return new StreamInfoItemHolder(infoItemBuilder, parent); - case GRID_STREAM_HOLDER_TYPE: - return new StreamGridInfoItemHolder(infoItemBuilder, parent); - case CARD_STREAM_HOLDER_TYPE: - return new StreamCardInfoItemHolder(infoItemBuilder, parent); - case MINI_CHANNEL_HOLDER_TYPE: - return new ChannelMiniInfoItemHolder(infoItemBuilder, parent); - case CHANNEL_HOLDER_TYPE: - return new ChannelInfoItemHolder(infoItemBuilder, parent); - case CARD_CHANNEL_HOLDER_TYPE: - return new ChannelCardInfoItemHolder(infoItemBuilder, parent); - case GRID_CHANNEL_HOLDER_TYPE: - return new ChannelGridInfoItemHolder(infoItemBuilder, parent); - case MINI_PLAYLIST_HOLDER_TYPE: - return new PlaylistMiniInfoItemHolder(infoItemBuilder, parent); - case PLAYLIST_HOLDER_TYPE: - return new PlaylistInfoItemHolder(infoItemBuilder, parent); - case GRID_PLAYLIST_HOLDER_TYPE: - return new PlaylistGridInfoItemHolder(infoItemBuilder, parent); - case CARD_PLAYLIST_HOLDER_TYPE: - return new PlaylistCardInfoItemHolder(infoItemBuilder, parent); - case COMMENT_HOLDER_TYPE: - return new CommentInfoItemHolder(infoItemBuilder, parent); - default: - return new FallbackViewHolder(new View(parent.getContext())); - } + case HEADER_TYPE -> new HFHolder(headerSupplier.get()); + case FOOTER_TYPE -> new HFHolder(PignateFooterBinding + .inflate(layoutInflater, parent, false) + .getRoot() + ); + case MINI_STREAM_HOLDER_TYPE -> new StreamMiniInfoItemHolder(infoItemBuilder, parent); + case STREAM_HOLDER_TYPE -> new StreamInfoItemHolder(infoItemBuilder, parent); + case GRID_STREAM_HOLDER_TYPE -> new StreamGridInfoItemHolder(infoItemBuilder, parent); + case CARD_STREAM_HOLDER_TYPE -> new StreamCardInfoItemHolder(infoItemBuilder, parent); + case MINI_CHANNEL_HOLDER_TYPE -> new ChannelMiniInfoItemHolder(infoItemBuilder, parent); + case CHANNEL_HOLDER_TYPE -> new ChannelInfoItemHolder(infoItemBuilder, parent); + case CARD_CHANNEL_HOLDER_TYPE -> new ChannelCardInfoItemHolder(infoItemBuilder, parent); + case GRID_CHANNEL_HOLDER_TYPE -> new ChannelGridInfoItemHolder(infoItemBuilder, parent); + case MINI_PLAYLIST_HOLDER_TYPE -> + new PlaylistMiniInfoItemHolder(infoItemBuilder, parent); + case PLAYLIST_HOLDER_TYPE -> new PlaylistInfoItemHolder(infoItemBuilder, parent); + case GRID_PLAYLIST_HOLDER_TYPE -> + new PlaylistGridInfoItemHolder(infoItemBuilder, parent); + case CARD_PLAYLIST_HOLDER_TYPE -> + new PlaylistCardInfoItemHolder(infoItemBuilder, parent); + default -> new FallbackViewHolder(new View(parent.getContext())); + }; } @Override diff --git a/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentInfoItemHolder.java b/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentInfoItemHolder.java deleted file mode 100644 index a3316d3fecc..00000000000 --- a/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentInfoItemHolder.java +++ /dev/null @@ -1,208 +0,0 @@ -package org.schabi.newpipe.info_list.holder; - -import static org.schabi.newpipe.util.ServiceHelper.getServiceById; -import static org.schabi.newpipe.util.text.TouchUtils.getOffsetForHorizontalLine; - -import android.text.Spanned; -import android.text.method.LinkMovementMethod; -import android.text.style.ClickableSpan; -import android.text.style.URLSpan; -import android.view.MotionEvent; -import android.view.View; -import android.view.ViewGroup; -import android.widget.Button; -import android.widget.ImageView; -import android.widget.RelativeLayout; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.fragment.app.FragmentActivity; - -import org.schabi.newpipe.R; -import org.schabi.newpipe.extractor.InfoItem; -import org.schabi.newpipe.extractor.comments.CommentsInfoItem; -import org.schabi.newpipe.info_list.InfoItemBuilder; -import org.schabi.newpipe.local.history.HistoryRecordManager; -import org.schabi.newpipe.util.DeviceUtils; -import org.schabi.newpipe.util.Localization; -import org.schabi.newpipe.util.NavigationHelper; -import org.schabi.newpipe.util.external_communication.ShareUtils; -import org.schabi.newpipe.util.image.CoilHelper; -import org.schabi.newpipe.util.image.ImageStrategy; -import org.schabi.newpipe.util.text.TextEllipsizer; - -public class CommentInfoItemHolder extends InfoItemHolder { - - private static final int COMMENT_DEFAULT_LINES = 2; - private final int commentHorizontalPadding; - private final int commentVerticalPadding; - - private final RelativeLayout itemRoot; - private final ImageView itemThumbnailView; - private final TextView itemContentView; - private final ImageView itemThumbsUpView; - private final TextView itemLikesCountView; - private final TextView itemTitleView; - private final ImageView itemHeartView; - private final ImageView itemPinnedView; - private final Button repliesButton; - - @NonNull - private final TextEllipsizer textEllipsizer; - - public CommentInfoItemHolder(final InfoItemBuilder infoItemBuilder, - final ViewGroup parent) { - super(infoItemBuilder, R.layout.list_comment_item, parent); - - itemRoot = itemView.findViewById(R.id.itemRoot); - itemThumbnailView = itemView.findViewById(R.id.itemThumbnailView); - itemContentView = itemView.findViewById(R.id.itemCommentContentView); - itemThumbsUpView = itemView.findViewById(R.id.detail_thumbs_up_img_view); - itemLikesCountView = itemView.findViewById(R.id.detail_thumbs_up_count_view); - itemTitleView = itemView.findViewById(R.id.itemTitleView); - itemHeartView = itemView.findViewById(R.id.detail_heart_image_view); - itemPinnedView = itemView.findViewById(R.id.detail_pinned_view); - repliesButton = itemView.findViewById(R.id.replies_button); - - commentHorizontalPadding = (int) infoItemBuilder.getContext() - .getResources().getDimension(R.dimen.comments_horizontal_padding); - commentVerticalPadding = (int) infoItemBuilder.getContext() - .getResources().getDimension(R.dimen.comments_vertical_padding); - - textEllipsizer = new TextEllipsizer(itemContentView, COMMENT_DEFAULT_LINES, null); - textEllipsizer.setStateChangeListener(isEllipsized -> { - if (Boolean.TRUE.equals(isEllipsized)) { - denyLinkFocus(); - } else { - determineMovementMethod(); - } - }); - } - - @Override - public void updateFromItem(final InfoItem infoItem, - final HistoryRecordManager historyRecordManager) { - if (!(infoItem instanceof CommentsInfoItem item)) { - return; - } - - // load the author avatar - CoilHelper.INSTANCE.loadAvatar(itemThumbnailView, item.getUploaderAvatars()); - if (ImageStrategy.shouldLoadImages()) { - itemThumbnailView.setVisibility(View.VISIBLE); - itemRoot.setPadding(commentVerticalPadding, commentVerticalPadding, - commentVerticalPadding, commentVerticalPadding); - } else { - itemThumbnailView.setVisibility(View.GONE); - itemRoot.setPadding(commentHorizontalPadding, commentVerticalPadding, - commentHorizontalPadding, commentVerticalPadding); - } - itemThumbnailView.setOnClickListener(view -> openCommentAuthor(item)); - - - // setup the top row, with pinned icon, author name and comment date - itemPinnedView.setVisibility(item.isPinned() ? View.VISIBLE : View.GONE); - itemTitleView.setText(Localization.concatenateStrings(item.getUploaderName(), - Localization.relativeTimeOrTextual(itemBuilder.getContext(), item.getUploadDate(), - item.getTextualUploadDate()))); - - - // setup bottom row, with likes, heart and replies button - itemLikesCountView.setText( - Localization.likeCount(itemBuilder.getContext(), item.getLikeCount())); - - itemHeartView.setVisibility(item.isHeartedByUploader() ? View.VISIBLE : View.GONE); - - final boolean hasReplies = item.getReplies() != null; - repliesButton.setOnClickListener(hasReplies ? v -> openCommentReplies(item) : null); - repliesButton.setVisibility(hasReplies ? View.VISIBLE : View.GONE); - repliesButton.setText(hasReplies - ? Localization.replyCount(itemBuilder.getContext(), item.getReplyCount()) : ""); - ((RelativeLayout.LayoutParams) itemThumbsUpView.getLayoutParams()).topMargin = - hasReplies ? 0 : DeviceUtils.dpToPx(6, itemBuilder.getContext()); - - - // setup comment content and click listeners to expand/ellipsize it - textEllipsizer.setStreamingService(getServiceById(item.getServiceId())); - textEllipsizer.setStreamUrl(item.getUrl()); - textEllipsizer.setContent(item.getCommentText()); - textEllipsizer.ellipsize(); - - //noinspection ClickableViewAccessibility - itemContentView.setOnTouchListener((v, event) -> { - final CharSequence text = itemContentView.getText(); - if (text instanceof Spanned buffer) { - final int action = event.getAction(); - - if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_DOWN) { - final int offset = getOffsetForHorizontalLine(itemContentView, event); - final var links = buffer.getSpans(offset, offset, ClickableSpan.class); - - if (links.length != 0) { - if (action == MotionEvent.ACTION_UP) { - links[0].onClick(itemContentView); - } - // we handle events that intersect links, so return true - return true; - } - } - } - return false; - }); - - itemView.setOnClickListener(view -> { - textEllipsizer.toggle(); - if (itemBuilder.getOnCommentsSelectedListener() != null) { - itemBuilder.getOnCommentsSelectedListener().selected(item); - } - }); - - itemView.setOnLongClickListener(view -> { - if (DeviceUtils.isTv(itemBuilder.getContext())) { - openCommentAuthor(item); - } else { - final CharSequence text = itemContentView.getText(); - if (text != null) { - ShareUtils.copyToClipboard(itemBuilder.getContext(), text.toString()); - } - } - return true; - }); - } - - private void openCommentAuthor(@NonNull final CommentsInfoItem item) { - NavigationHelper.openCommentAuthorIfPresent((FragmentActivity) itemBuilder.getContext(), - item); - } - - private void openCommentReplies(@NonNull final CommentsInfoItem item) { - NavigationHelper.openCommentRepliesFragment((FragmentActivity) itemBuilder.getContext(), - item); - } - - private void allowLinkFocus() { - itemContentView.setMovementMethod(LinkMovementMethod.getInstance()); - } - - private void denyLinkFocus() { - itemContentView.setMovementMethod(null); - } - - private boolean shouldFocusLinks() { - if (itemView.isInTouchMode()) { - return false; - } - - final URLSpan[] urls = itemContentView.getUrls(); - - return urls != null && urls.length != 0; - } - - private void determineMovementMethod() { - if (shouldFocusLinks()) { - allowLinkFocus(); - } else { - denyLinkFocus(); - } - } -} diff --git a/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java b/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java index 066d5f57047..abf8d24c158 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java @@ -155,15 +155,6 @@ public static Single getCommentsInfo(final int serviceId, CommentsInfo.getInfo(NewPipe.getService(serviceId), url))); } - public static Single> getMoreCommentItems( - final int serviceId, - final CommentsInfo info, - final Page nextPage) { - checkServiceId(serviceId); - return Single.fromCallable(() -> - CommentsInfo.getMoreItems(NewPipe.getService(serviceId), info, nextPage)); - } - public static Single> getMoreCommentItems( final int serviceId, final String url, diff --git a/app/src/main/res/layout/fragment_comments.xml b/app/src/main/res/layout/fragment_comments.xml deleted file mode 100644 index 2a8c747cd63..00000000000 --- a/app/src/main/res/layout/fragment_comments.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/list_comment_item.xml b/app/src/main/res/layout/list_comment_item.xml deleted file mode 100644 index 631ab204b3f..00000000000 --- a/app/src/main/res/layout/list_comment_item.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - - - - - - - - - - - -