From f8a31428350e8991d0714aed8528337e40edf59b Mon Sep 17 00:00:00 2001 From: h Date: Fri, 24 Apr 2026 10:30:00 +0200 Subject: [PATCH] Remove unused bullet comments code --- .../MovieBulletCommentsPlayer.java | 194 --------- .../BulletCommentsSettingsFragment.java | 87 ---- .../settings/SettingsResourceRegistry.java | 1 - .../schabi/newpipe/util/ExtractorHelper.java | 10 - .../org/schabi/newpipe/util/InfoCache.java | 3 +- .../newpipe/views/BulletCommentsView.java | 384 ------------------ .../res/layout/bullet_comments_player.xml | 33 -- app/src/main/res/values/settings_keys.xml | 10 - app/src/main/res/values/strings.xml | 14 - .../main/res/xml/bullet_comments_settings.xml | 65 --- app/src/main/res/xml/main_settings.xml | 7 - 11 files changed, 1 insertion(+), 807 deletions(-) delete mode 100644 app/src/main/java/org/schabi/newpipe/player/bulletComments/MovieBulletCommentsPlayer.java delete mode 100644 app/src/main/java/org/schabi/newpipe/settings/BulletCommentsSettingsFragment.java delete mode 100644 app/src/main/java/org/schabi/newpipe/views/BulletCommentsView.java delete mode 100644 app/src/main/res/layout/bullet_comments_player.xml delete mode 100644 app/src/main/res/xml/bullet_comments_settings.xml diff --git a/app/src/main/java/org/schabi/newpipe/player/bulletComments/MovieBulletCommentsPlayer.java b/app/src/main/java/org/schabi/newpipe/player/bulletComments/MovieBulletCommentsPlayer.java deleted file mode 100644 index d7a0b7b1e..000000000 --- a/app/src/main/java/org/schabi/newpipe/player/bulletComments/MovieBulletCommentsPlayer.java +++ /dev/null @@ -1,194 +0,0 @@ -package org.schabi.newpipe.player.bulletComments; - -import android.annotation.SuppressLint; -import android.util.Log; - -import org.schabi.newpipe.extractor.bulletComments.BulletCommentsExtractor; -import org.schabi.newpipe.extractor.bulletComments.BulletCommentsInfo; -import org.schabi.newpipe.extractor.bulletComments.BulletCommentsInfoItem; -import org.schabi.newpipe.extractor.exceptions.ParsingException; -import org.schabi.newpipe.util.ExtractorHelper; -import org.schabi.newpipe.views.BulletCommentsView; - -import java.time.Duration; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; - -import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; -import io.reactivex.rxjava3.schedulers.Schedulers; - -public class MovieBulletCommentsPlayer { - public MovieBulletCommentsPlayer(final BulletCommentsView bulletCommentsView) { - super(); - this.bulletCommentsView = bulletCommentsView; - } - - private final String TAG = "MovieBCPlayer"; - protected int serviceId; - protected String url; - protected final BulletCommentsView bulletCommentsView; - protected List commentsInfoItems; - private BulletCommentsExtractor extractor; - public boolean isRoundPlayStream = false; - - /** - * Set data. Call before init(). - * - * @param newServiceId Service id. - * @param newUrl Url. - */ - public void setInitialData(final int newServiceId, final String newUrl) { - Log.d(TAG, "setInitialData() serviceId=" + newServiceId + " url=" + newUrl); - this.serviceId = newServiceId; - this.url = newUrl; - } - - public final Duration interval = Duration.ofMillis(50); - protected boolean isLoading = false; - - /** - * Fetch comments and init. Call after setInitialData(). - */ - @SuppressLint("CheckResult") - public void init() { - Log.d(TAG, "init() called for url=" + this.url); - this.bulletCommentsView.clearComments(); - isLoading = true; - try { - ExtractorHelper.getBulletCommentsInfo(this.serviceId, this.url, false) - .filter(Objects::nonNull) - .map((BulletCommentsInfo commentsInfo) -> { - extractor = commentsInfo.getBulletCommentsExtractor(); - extractor.reconnect(); - return commentsInfo.getRelatedItems(); - } - ) - .filter(Objects::nonNull) - .map(s -> s.stream().toArray(BulletCommentsInfoItem[]::new)) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe((BulletCommentsInfoItem[] newCommentsInfoItems) -> { - this.commentsInfoItems = Arrays.asList(newCommentsInfoItems); - Log.d(TAG, "init() success: got " - + newCommentsInfoItems.length - + " initial comments for " + this.url); - if (extractor != null) { - Log.d(TAG, "init() extractor isLive=" + extractor.isLive() - + " isDisabled=" + extractor.isDisabled()); - } - isLoading = false; - }, - throwable -> Log.e(TAG, Log.getStackTraceString(throwable)) - ); - } catch (final Exception e) { - Log.e(TAG, Log.getStackTraceString(e)); - } - } - - protected Duration lastPosition = Duration.ZERO; - - /** - * Draw all comments which duration is between last - * drawUntilPosition and current drawUntilPosition. - * - * @param drawUntilPosition Duration to draw comments until. - */ - public void drawComments(final Duration drawUntilPosition) { - if (isLoading) { - return; - } - Log.v(TAG, "drawComments() position=" + drawUntilPosition.toMillis() - + "ms extractor=" + (extractor != null ? "yes" : "null")); - final BulletCommentsInfoItem[] nextCommentsInfoItems; - if (extractor.isDisabled()) { - return; - } - if (extractor != null && extractor.isLive()) { - // have to put all messages we get to the pool as they only appear once - try { - nextCommentsInfoItems = extractor.getLiveMessages() - .stream().toArray(BulletCommentsInfoItem[]::new); - if (drawUntilPosition.compareTo(Duration.ofSeconds(Long.MAX_VALUE)) != 0) { - extractor.setCurrentPlayPosition(drawUntilPosition.toMillis()); - } - } catch (final ParsingException e) { - Log.e(TAG, "drawComments() getLiveMessages failed", e); - throw new RuntimeException(e); - } - } else { // we can filter the messages because we have the full list - if (drawUntilPosition.toString().equals("PT0.049S")) { - return; - } - nextCommentsInfoItems = commentsInfoItems - .stream() - .filter(item -> { - final Duration d = item.getDuration(); - return d.compareTo(lastPosition) >= 0 - && d.compareTo(drawUntilPosition) < 0; - } - ) - .toArray(BulletCommentsInfoItem[]::new); - } - Log.v(TAG, "drawComments() drawing " + nextCommentsInfoItems.length + " comments"); - bulletCommentsView.drawComments(nextCommentsInfoItems, drawUntilPosition); - this.lastPosition = drawUntilPosition; - } - - /** - * Resume comments. (Avoids drawing massive comments after skipping.) - * - * @param currentPosition Current position. - */ - public void start(final Duration currentPosition) { - Log.d(TAG, "start() position=" + currentPosition.toMillis() + "ms"); - this.lastPosition = currentPosition; - bulletCommentsView.resumeComments(); - } - - /** - * Pause comments. - */ - public void pause() { - Log.d(TAG, "pause() called"); - bulletCommentsView.pauseComments(); - } - - /** - * Clear comments. - */ - public void clear() { - Log.d(TAG, "clear() called"); - bulletCommentsView.clearComments(); - } - - public void disconnect() { - Log.d(TAG, "disconnect() called"); - if (extractor != null && extractor.isLive()) { - extractor.disconnect(); - } - } - - /** - * Draw all comments after max(movieDuration - interval, lastPosition). - * - * @param movieDuration The duration of the movie, used to avoid drawing too many comments. - */ - public void complete(final Duration movieDuration) { - Log.d(TAG, "complete() called"); - if (lastPosition == null) { - return; //is actually finished - } - final Duration minimumLastPosition = movieDuration.minus(interval); - if (minimumLastPosition.compareTo(lastPosition) >= 0) { - lastPosition = minimumLastPosition; - } - - //Show all comments. - drawComments(Duration.ofSeconds(Long.MAX_VALUE)); - } - - public String getUrl() { - return url; - } -} diff --git a/app/src/main/java/org/schabi/newpipe/settings/BulletCommentsSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/BulletCommentsSettingsFragment.java deleted file mode 100644 index 674320e07..000000000 --- a/app/src/main/java/org/schabi/newpipe/settings/BulletCommentsSettingsFragment.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.schabi.newpipe.settings; - -import android.content.SharedPreferences; -import android.os.Bundle; -import androidx.preference.SeekBarPreference; -import org.schabi.newpipe.R; - -public class BulletCommentsSettingsFragment extends BasePreferenceFragment { - - private SharedPreferences.OnSharedPreferenceChangeListener listener; - - @Override - public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) { - addPreferencesFromResourceRegistry(); - - listener = (sharedPreferences, s) -> { - if (s.equals(getString(R.string.top_bottom_bullet_comments_duration_key))) { - final int newSetting = sharedPreferences.getInt(s, 8); - final SeekBarPreference topBottomBulletCommentsDuration = findPreference(s); - if (topBottomBulletCommentsDuration != null) { - topBottomBulletCommentsDuration.setSummary(newSetting + " seconds"); - } - } else if (s.equals(getString(R.string.regular_bullet_comments_duration_key))) { - final int newSetting = sharedPreferences.getInt(s, 8); - final SeekBarPreference regularBulletCommentsDuration = findPreference(s); - if (regularBulletCommentsDuration != null) { - regularBulletCommentsDuration.setSummary(newSetting + " seconds"); - } - } else if (s.equals(getString(R.string.max_bullet_comments_rows_top_key)) - || s.equals(getString(R.string.max_bullet_comments_rows_bottom_key)) - || s.equals(getString(R.string.max_bullet_comments_rows_regular_key))) { - final int newSetting = sharedPreferences.getInt(s, 15); - final SeekBarPreference rowsPref = findPreference(s); - if (rowsPref != null) { - rowsPref.setSummary(String.valueOf(newSetting)); - } - } - }; - - final SeekBarPreference regularBulletCommentsDuration = - findPreference(getString(R.string.regular_bullet_comments_duration_key)); - if (regularBulletCommentsDuration != null) { - regularBulletCommentsDuration.setMin(5); - } - final SeekBarPreference topBottomBulletCommentsDuration = - findPreference(getString(R.string.top_bottom_bullet_comments_duration_key)); - if (topBottomBulletCommentsDuration != null) { - topBottomBulletCommentsDuration.setMin(5); - } - - final SeekBarPreference topRowsPref = - findPreference(getString(R.string.max_bullet_comments_rows_top_key)); - final SeekBarPreference bottomRowsPref = - findPreference(getString(R.string.max_bullet_comments_rows_bottom_key)); - final SeekBarPreference regularRowsPref = - findPreference(getString(R.string.max_bullet_comments_rows_regular_key)); - - final SharedPreferences sharedPreferences = - getPreferenceManager().getSharedPreferences(); - if (topRowsPref != null) { - topRowsPref.setSummary(String.valueOf(sharedPreferences.getInt( - getString(R.string.max_bullet_comments_rows_top_key), 15))); - } - if (bottomRowsPref != null) { - bottomRowsPref.setSummary(String.valueOf(sharedPreferences.getInt( - getString(R.string.max_bullet_comments_rows_bottom_key), 15))); - } - if (regularRowsPref != null) { - regularRowsPref.setSummary(String.valueOf(sharedPreferences.getInt( - getString(R.string.max_bullet_comments_rows_regular_key), 15))); - } - } - - @Override - public void onResume() { - super.onResume(); - getPreferenceManager().getSharedPreferences() - .registerOnSharedPreferenceChangeListener(listener); - } - - @Override - public void onPause() { - super.onPause(); - getPreferenceManager().getSharedPreferences() - .unregisterOnSharedPreferenceChangeListener(listener); - } -} diff --git a/app/src/main/java/org/schabi/newpipe/settings/SettingsResourceRegistry.java b/app/src/main/java/org/schabi/newpipe/settings/SettingsResourceRegistry.java index 18fb60173..06e0a7c1e 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/SettingsResourceRegistry.java +++ b/app/src/main/java/org/schabi/newpipe/settings/SettingsResourceRegistry.java @@ -41,7 +41,6 @@ public final class SettingsResourceRegistry { add(UpdateSettingsFragment.class, R.xml.update_settings); add(VideoAudioSettingsFragment.class, R.xml.video_audio_settings); add(ExoPlayerSettingsFragment.class, R.xml.exoplayer_settings); - add(BulletCommentsSettingsFragment.class, R.xml.bullet_comments_settings); add(BackupRestoreSettingsFragment.class, R.xml.backup_restore_settings); } 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 e4d73bcaf..09f6e1312 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java @@ -40,7 +40,6 @@ import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage; import org.schabi.newpipe.extractor.MetaInfo; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.Page; -import org.schabi.newpipe.extractor.bulletComments.BulletCommentsInfo; import org.schabi.newpipe.extractor.channel.ChannelInfo; import org.schabi.newpipe.extractor.channel.tabs.ChannelTabInfo; import org.schabi.newpipe.extractor.kiosk.KioskInfo; @@ -169,15 +168,6 @@ public final class ExtractorHelper { Single.fromCallable(() -> KioskInfo.getInfo(NewPipe.getService(serviceId), url))); } - public static Single getBulletCommentsInfo(final int serviceId, - final String url, - final boolean forceLoad) { - checkServiceId(serviceId); - return checkCache(forceLoad, serviceId, url, InfoCache.Type.BULLET_COMMENTS, - Single.fromCallable(() -> - BulletCommentsInfo.getInfo(NewPipe.getService(serviceId), url))); - } - public static Single> getMoreKioskItems(final int serviceId, final String url, final Page nextPage) { diff --git a/app/src/main/java/org/schabi/newpipe/util/InfoCache.java b/app/src/main/java/org/schabi/newpipe/util/InfoCache.java index 7aa23b3cf..a268c7d64 100644 --- a/app/src/main/java/org/schabi/newpipe/util/InfoCache.java +++ b/app/src/main/java/org/schabi/newpipe/util/InfoCache.java @@ -55,9 +55,8 @@ public final class InfoCache { CHANNEL, CHANNEL_TAB, COMMENTS, - BULLET_COMMENTS, PLAYLIST, - KIOSK, + KIOSK } public static InfoCache getInstance() { diff --git a/app/src/main/java/org/schabi/newpipe/views/BulletCommentsView.java b/app/src/main/java/org/schabi/newpipe/views/BulletCommentsView.java deleted file mode 100644 index 4ac51e21d..000000000 --- a/app/src/main/java/org/schabi/newpipe/views/BulletCommentsView.java +++ /dev/null @@ -1,384 +0,0 @@ -package org.schabi.newpipe.views; - -import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; -import android.animation.ObjectAnimator; -import android.content.Context; -import android.content.SharedPreferences; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Typeface; -import android.os.Build; -import android.util.AttributeSet; -import android.util.Log; -import android.util.TypedValue; -import android.view.LayoutInflater; -import android.view.View; -import android.view.Gravity; -import android.view.animation.LinearInterpolator; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.constraintlayout.widget.ConstraintLayout; - -import androidx.preference.PreferenceManager; -import org.schabi.newpipe.R; -import org.schabi.newpipe.databinding.BulletCommentsPlayerBinding; -import org.schabi.newpipe.extractor.bulletComments.BulletCommentsInfoItem; - -import java.time.Duration; -import java.util.AbstractMap; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.PriorityQueue; -import java.util.stream.Collectors; - -public final class BulletCommentsView extends ConstraintLayout { - private final String TAG = "BulletCommentsView"; - private SharedPreferences prefs; - - /** - * Tuple of TextView and ObjectAnimator. - */ - private static class AnimatedTextView { - AnimatedTextView(final TextView textView, final ObjectAnimator animator) { - this.textView = textView; - this.animator = animator; - } - - public final TextView textView; - public final ObjectAnimator animator; - } - - public BulletCommentsView(final Context context) { - super(context); - setClipChildren(false); - init(context); - } - - public BulletCommentsView(final Context context, - final AttributeSet attrs) { - super(context, attrs); - setClipChildren(false); - init(context); - } - - public BulletCommentsView(final Context context, - final AttributeSet attrs, - final int defStyleAttr) { - super(context, attrs, defStyleAttr); - setClipChildren(false); - init(context); - } - - private void init(final Context context) { - final View layout = LayoutInflater.from(context) - .inflate(R.layout.bullet_comments_player, this); - prefs = PreferenceManager.getDefaultSharedPreferences(context); - commentsDuration = prefs.getInt( - context.getString(R.string.top_bottom_bullet_comments_duration_key), 8); - durationFactor = (float) prefs.getInt( - context.getString(R.string.regular_bullet_comments_duration_key), 8) - / (float) commentsDuration; - outlineRadius = prefs.getInt( - context.getString(R.string.bullet_comments_outline_radius_key), 2); - - final boolean limitMaxRows = prefs.getBoolean( - context.getString(R.string.enable_max_rows_customization_key), false); - if (limitMaxRows) { - maxRowsTop = prefs.getInt( - context.getString(R.string.max_bullet_comments_rows_top_key), 15); - maxRowsBottom = prefs.getInt( - context.getString(R.string.max_bullet_comments_rows_bottom_key), 15); - maxRowsRegular = prefs.getInt( - context.getString(R.string.max_bullet_comments_rows_regular_key), 15); - } - - font = prefs.getString(context.getString(R.string.bullet_comments_font_key), "default"); - opacity = prefs.getInt(context.getString(R.string.bullet_comments_opacity_key), 0xFF); - binding = BulletCommentsPlayerBinding.bind(this); - } - - private boolean layoutSet = false; - - private void setLayout() { - final int additionalWidth = additionalSpaceRelative * getWidth(); - binding.bottomRight.getLayoutParams().width = additionalWidth; - requestLayout(); - Log.i(TAG, "Additional width: " + additionalWidth - + ", container width: " + binding.bulletCommentsContainer.getWidth()); - } - - private BulletCommentsPlayerBinding binding; - private final int additionalSpaceRelative = 4; - - private final int commentsRowsCount = 11; - private int lastCalculatedCommentsRowsCount = 11; - private List rows = Collections.synchronizedList(new ArrayList()); - private List> rowsRegular = - Collections.synchronizedList(new ArrayList<>()); - private final double commentRelativeTextSize = 1 / 13.5; - private PriorityQueue bulletCommentsInfoItemRegularPool = - new PriorityQueue<>(); - private PriorityQueue bulletCommentsInfoItemFixedPool = - new PriorityQueue<>(); - - private int commentsDuration; - private float durationFactor; - private int outlineRadius; - private String font; - private int opacity; // 0~255, 0: hide - private final List animatedTextViews = new ArrayList<>(); - - private int maxRowsTop = 1000000; - private int maxRowsBottom = 1000000; - private int maxRowsRegular = 1000000; - - public void clearComments() { - Log.d(TAG, "clearComments() called, animatedViews=" + animatedTextViews.size()); - animatedTextViews.clear(); - if (binding != null) { - binding.bulletCommentsContainer.removeAllViews(); - } - } - - public void setPauseComments(final boolean pause) { - if (pause) { - pauseComments(); - } else { - resumeComments(); - } - } - - public void pauseComments() { - animatedTextViews.stream().forEach(s -> s.animator.pause()); - } - - public void resumeComments() { - animatedTextViews.stream().forEach(s -> s.animator.resume()); - } - - public void drawComments(@NonNull final BulletCommentsInfoItem[] items, - final Duration drawUntilPosition) { - Log.v(TAG, "drawComments() items=" + items.length - + " position=" + drawUntilPosition.toMillis() + "ms"); - if (binding == null || getWidth() == 0 || getHeight() == 0) { - Log.w(TAG, "drawComments() skipped: view not ready"); - return; - } - if (!layoutSet) { - setLayout(); - layoutSet = true; - } - bulletCommentsInfoItemRegularPool.addAll( - Arrays.asList(items).stream() - .filter(x -> x.getPosition() == BulletCommentsInfoItem.Position.REGULAR) - .collect(Collectors.toList())); - bulletCommentsInfoItemFixedPool.addAll( - Arrays.asList(items).stream() - .filter(x -> x.getPosition() != BulletCommentsInfoItem.Position.REGULAR) - .collect(Collectors.toList())); - final int height = getHeight(); - final int width = getWidth(); - final int calculatedCommentRowsCount = - height / Math.min(height, width) * commentsRowsCount; - if (calculatedCommentRowsCount != lastCalculatedCommentsRowsCount) { - lastCalculatedCommentsRowsCount = calculatedCommentRowsCount; - rows.clear(); - rowsRegular.clear(); - } - while (rowsRegular.size() < calculatedCommentRowsCount) { - rowsRegular.add(new AbstractMap.SimpleEntry<>(0L, 0)); - } - while (rows.size() < calculatedCommentRowsCount) { - rows.add(0L); - } - drawCommentsByPool(bulletCommentsInfoItemRegularPool, drawUntilPosition, - height, width, calculatedCommentRowsCount); - drawCommentsByPool(bulletCommentsInfoItemFixedPool, drawUntilPosition, - height, width, calculatedCommentRowsCount); - Log.v(TAG, "drawComments() done, containerChildCount=" - + binding.bulletCommentsContainer.getChildCount()); - } - - public int tryToDrawComment(final BulletCommentsInfoItem item, - final int calculatedCommentRowsCount, - final int width, - final boolean reallyDo) { - final long current = new Date().getTime(); - int row = -1; - final int comparedDuration = (int) (commentsDuration * 1000); - if (item.getPosition().equals(BulletCommentsInfoItem.Position.TOP) - || item.getPosition().equals(BulletCommentsInfoItem.Position.SUPERCHAT)) { - for (int i = 0; i < Math.min(maxRowsTop, calculatedCommentRowsCount); i++) { - final long last = rows.get(i); - if (current - last >= comparedDuration) { - if (reallyDo) { - rows.set(i, current); - } - row = i; - break; - } - } - } else if (item.getPosition().equals(BulletCommentsInfoItem.Position.REGULAR)) { - for (int i = 0; i < Math.min(maxRowsRegular, calculatedCommentRowsCount); i++) { - final long lastTime = rowsRegular.get(i).getKey(); - final long lastLength = rowsRegular.get(i).getValue(); - final long t = current - lastTime; - final double tAll = comparedDuration * durationFactor; - final double lx = (lastLength / 25.0 + 1) * width; - final double ly = (item.getCommentText().length() / 25.0 + 1) * width; - final double vx = lx / tAll; - final double vy = ly / tAll; - if ((vy - vx) * (tAll - t) < t * vx - (lastLength / 25.0) * width - && t * vx - (lastLength / 25.0) * width > 0) { - if (reallyDo) { - rowsRegular.set(i, - new AbstractMap.SimpleEntry<>(current, - item.getCommentText().length())); - } - row = i; - break; - } - } - } else { - for (int i = calculatedCommentRowsCount - 1; - i >= Math.max(0, calculatedCommentRowsCount - maxRowsBottom); i--) { - final long last = rows.get(i); - if (current - last >= comparedDuration) { - if (reallyDo) { - rows.set(i, current); - } - row = i; - break; - } - } - } - return row; - } - - private void drawCommentsByPool(final PriorityQueue pool, - final Duration drawUntilPosition, - final int height, - final int width, - final int calculatedCommentRowsCount) { - if (binding == null) { - return; - } - final Context context = binding.bulletCommentsContainer.getContext(); - int drawn = 0; - while (!pool.isEmpty() - && (drawUntilPosition.compareTo(Duration.ofSeconds(Long.MAX_VALUE)) == 0 - || pool.peek().getDuration().toMillis() < drawUntilPosition.toMillis())) { - final BulletCommentsInfoItem item = pool.peek(); - if (item.isLive() - && tryToDrawComment(item, calculatedCommentRowsCount, width, false) == -1) { - Log.v(TAG, "drawCommentsByPool() row collision, skipping item"); - pool.poll(); // skip this item instead of aborting all - continue; - } - pool.poll(); - final TextView textView = new TextView(context); - final Typeface fontToBeUsed; - switch (font) { - case "serif": - fontToBeUsed = Typeface.SERIF; - break; - case "monospace": - fontToBeUsed = Typeface.MONOSPACE; - break; - case "sans-serif": - fontToBeUsed = Typeface.SANS_SERIF; - break; - default: - fontToBeUsed = Typeface.DEFAULT; - break; - } - textView.setGravity(Gravity.CENTER); - int color = item.getArgbColor(); - if (opacity != 0xFF) { - color &= 0x00FFFFFF; - color |= ((opacity & 0xFF) << 24); - } - textView.setTextColor(color); - final String commentText = item.getCommentText(); - Log.v(TAG, "drawCommentsByPool() text=[" + commentText + "] color=" - + String.format("0x%08X", color) + " pos=" + item.getPosition()); - if (commentText.length() == 0) { - Log.v(TAG, "drawCommentsByPool() skipping empty text"); - continue; - } - textView.setText(commentText); - textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, - (float) (Math.min(height, width) * commentRelativeTextSize - * item.getRelativeFontSize())); - textView.setMaxLines(1); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - textView.setTypeface(Typeface.create(fontToBeUsed, Typeface.BOLD, - item.getPosition().equals(BulletCommentsInfoItem.Position.SUPERCHAT))); - } else { - textView.setTypeface(Typeface.create(fontToBeUsed, Typeface.BOLD)); - } - final Paint paint = textView.getPaint(); - int shadowColor = Color.BLACK & 0x00FFFFFF; - shadowColor |= ((opacity & 0xFF) << 24); - paint.setShadowLayer(outlineRadius, 0, 0, shadowColor); - textView.setLayerType(View.LAYER_TYPE_SOFTWARE, paint); - - final int row = tryToDrawComment(item, calculatedCommentRowsCount, width, true); - if (row == -1) { - continue; - } - textView.setX(width); - textView.post(() -> { - final int textWidth = textView.getWidth(); - final int textHeight = textView.getHeight(); - final ObjectAnimator animator; - if (!item.getPosition().equals(BulletCommentsInfoItem.Position.REGULAR)) { - animator = ObjectAnimator.ofFloat( - textView, - View.TRANSLATION_X, - (float) ((width - textWidth) / 2.0), - (float) ((width - textWidth) / 2.0) - ); - } else { - animator = ObjectAnimator.ofFloat( - textView, - View.TRANSLATION_X, - width, - -textWidth - ); - } - textView.setY((float) (height * (0.5 + row) / calculatedCommentRowsCount - - textHeight / 2)); - - final AnimatedTextView animatedTextView = new AnimatedTextView( - textView, animator); - animatedTextViews.add(animatedTextView); - animator.setFrameDelay(1); - animator.setInterpolator(new LinearInterpolator()); - animator.setDuration(item.getLastingTime() != -1 - ? item.getLastingTime() - : (long) (commentsDuration * 1000 - * (item.getPosition().equals(BulletCommentsInfoItem.Position.REGULAR) - ? durationFactor : 1))); - animator.addListener(new AnimatorListenerAdapter() { - public void onAnimationEnd(final Animator animation) { - binding.bulletCommentsContainer.removeView(textView); - animatedTextViews.remove(animatedTextView); - } - }); - animator.start(); - }); - binding.bulletCommentsContainer.addView(textView); - drawn++; - } - if (drawn > 0) { - Log.v(TAG, "drawCommentsByPool() drawn=" + drawn); - } - } -} diff --git a/app/src/main/res/layout/bullet_comments_player.xml b/app/src/main/res/layout/bullet_comments_player.xml deleted file mode 100644 index a42a76925..000000000 --- a/app/src/main/res/layout/bullet_comments_player.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index 2df941b23..b561f794e 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -1515,14 +1515,4 @@ @string/image_quality_high_key - - top_bottom_bullet_comments_duration_key - regular_bullet_comments_duration_key - bullet_comments_outline_radius_key - bullet_comments_font_key - bullet_comments_opacity_key - enable_max_rows_customization_key - max_bullet_comments_rows_top_key - max_bullet_comments_rows_bottom_key - max_bullet_comments_rows_regular_key diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ba3a1f296..53d261b50 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -924,18 +924,4 @@ Unfortunately NewPipe depends on a few libraries that dropped support for Android 5.0 and 5.1. The next NewPipe release will therefore only work on devices with Android 6 or higher, sadly. Read more in the blogpost. Blogpost - - Bullet comments - Configure live chat overlay - Regular comments duration - Duration of scrolling comments in seconds - Top/bottom comments duration - Duration of fixed comments in seconds - Outline radius - Font - Opacity - Limit max rows - Max top rows - Max bottom rows - Max regular rows diff --git a/app/src/main/res/xml/bullet_comments_settings.xml b/app/src/main/res/xml/bullet_comments_settings.xml deleted file mode 100644 index 9db909539..000000000 --- a/app/src/main/res/xml/bullet_comments_settings.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/xml/main_settings.xml b/app/src/main/res/xml/main_settings.xml index d08c4e6b7..5f96989f9 100644 --- a/app/src/main/res/xml/main_settings.xml +++ b/app/src/main/res/xml/main_settings.xml @@ -10,13 +10,6 @@ android:title="@string/settings_category_video_audio_title" app:iconSpaceReserved="false" /> - -