From c2b6cec37dec28f0785c4d5268f67662c7f600cd Mon Sep 17 00:00:00 2001 From: Stypox Date: Fri, 15 Jan 2021 14:55:05 +0100 Subject: [PATCH] Hide meta info panel in search when starting a new search --- .../newpipe/fragments/BaseStateFragment.java | 6 ++-- .../fragments/detail/VideoDetailFragment.java | 1 + .../fragments/list/search/SearchFragment.java | 17 +++------ .../main/java/org/schabi/newpipe/ktx/View.kt | 35 +++++++++---------- .../schabi/newpipe/util/ExtractorHelper.java | 7 ++-- 5 files changed, 28 insertions(+), 38 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java index 73f63b131..51f1e55bb 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java @@ -1,11 +1,9 @@ package org.schabi.newpipe.fragments; -import android.content.Context; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.ProgressBar; -import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -138,10 +136,10 @@ public abstract class BaseStateFragment extends BaseFragment implements ViewC isLoading.set(false); InfoCache.getInstance().clearCache(); if (emptyStateView != null) { - animateView(emptyStateView, false, 150); + animate(emptyStateView, false, 150); } if (loadingProgressBar != null) { - animateView(loadingProgressBar, false, 0); + animate(loadingProgressBar, false, 0); } } 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 797aa2a03..96d3906ce 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 @@ -148,6 +148,7 @@ public final class VideoDetailFragment private static final String COMMENTS_TAB_TAG = "COMMENTS"; private static final String RELATED_TAB_TAG = "NEXT VIDEO"; private static final String DESCRIPTION_TAB_TAG = "DESCRIPTION TAB"; + private static final String EMPTY_TAB_TAG = "EMPTY TAB"; // tabs private boolean showComments; diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java index 9acdacd16..12695acf9 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java @@ -161,11 +161,6 @@ public class SearchFragment extends BaseListFragment cannot be bundled without creating some containers metaInfo = new MetaInfo[result.getMetaInfo().size()]; metaInfo = result.getMetaInfo().toArray(metaInfo); - disposables.add(showMetaInfoInTextView(result.getMetaInfo(), metaInfoTextView, - metaInfoSeparator)); + disposables.add(showMetaInfoInTextView(result.getMetaInfo(), + searchBinding.searchMetaInfoTextView, searchBinding.searchMetaInfoSeparator)); handleSearchSuggestion(); diff --git a/app/src/main/java/org/schabi/newpipe/ktx/View.kt b/app/src/main/java/org/schabi/newpipe/ktx/View.kt index fe3ab7112..2fd80703c 100644 --- a/app/src/main/java/org/schabi/newpipe/ktx/View.kt +++ b/app/src/main/java/org/schabi/newpipe/ktx/View.kt @@ -35,11 +35,11 @@ inline var View.backgroundTintListCompat: ColorStateList? */ @JvmOverloads fun View.animate( - enterOrExit: Boolean, - duration: Long, - animationType: AnimationType = AnimationType.ALPHA, - delay: Long = 0, - execOnEnd: Runnable? = null + enterOrExit: Boolean, + duration: Long, + animationType: AnimationType = AnimationType.ALPHA, + delay: Long = 0, + execOnEnd: Runnable? = null ) { if (MainActivity.DEBUG) { val id = try { @@ -48,8 +48,8 @@ fun View.animate( id.toString() } val msg = String.format( - "%8s → [%s:%s] [%s %s:%s] execOnEnd=%s", enterOrExit, - javaClass.simpleName, id, animationType, duration, delay, execOnEnd + "%8s → [%s:%s] [%s %s:%s] execOnEnd=%s", enterOrExit, + javaClass.simpleName, id, animationType, duration, delay, execOnEnd ) Log.d(TAG, "animate(): $msg") } @@ -93,10 +93,10 @@ fun View.animate( fun View.animateBackgroundColor(duration: Long, @ColorInt colorStart: Int, @ColorInt colorEnd: Int) { if (MainActivity.DEBUG) { Log.d( - TAG, - "animateBackgroundColor() called with: " + - "view = [" + this + "], duration = [" + duration + "], " + - "colorStart = [" + colorStart + "], colorEnd = [" + colorEnd + "]" + TAG, + "animateBackgroundColor() called with: " + + "view = [" + this + "], duration = [" + duration + "], " + + "colorStart = [" + colorStart + "], colorEnd = [" + colorEnd + "]" ) } val empty = arrayOf(IntArray(0)) @@ -121,9 +121,9 @@ fun View.animateBackgroundColor(duration: Long, @ColorInt colorStart: Int, @Colo fun View.animateHeight(duration: Long, targetHeight: Int): ValueAnimator { if (MainActivity.DEBUG) { Log.d( - TAG, - "animateHeight: duration = [" + duration + "], " + - "from " + height + " to → " + targetHeight + " in: " + this + TAG, + "animateHeight: duration = [" + duration + "], " + + "from " + height + " to → " + targetHeight + " in: " + this ) } val animator = ValueAnimator.ofFloat(height.toFloat(), targetHeight.toFloat()) @@ -152,9 +152,9 @@ fun View.animateHeight(duration: Long, targetHeight: Int): ValueAnimator { fun View.animateRotation(duration: Long, targetRotation: Int) { if (MainActivity.DEBUG) { Log.d( - TAG, - "animateRotation: duration = [" + duration + "], " + - "from " + rotation + " to → " + targetRotation + " in: " + this + TAG, + "animateRotation: duration = [" + duration + "], " + + "from " + rotation + " to → " + targetRotation + " in: " + this ) } animate().setListener(null).cancel() @@ -319,7 +319,6 @@ fun View.slideUp(duration: Long, delay: Long, @FloatRange(from = 0.0, to = 1.0) .start() } - /** * Instead of hiding normally using [animate], which would make * the recycler view unable to capture touches after being hidden, this just animates the alpha 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 a904f360a..af7cafc15 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java @@ -274,10 +274,9 @@ public final class ExtractorHelper { final TextView metaInfoTextView, final View metaInfoSeparator) { final Context context = metaInfoTextView.getContext(); - final boolean showMetaInfo = PreferenceManager.getDefaultSharedPreferences(context) - .getBoolean(context.getString(R.string.show_meta_info_key), true); - - if (!showMetaInfo || metaInfos == null || metaInfos.isEmpty()) { + if (metaInfos == null || metaInfos.isEmpty() + || !PreferenceManager.getDefaultSharedPreferences(context).getBoolean( + context.getString(R.string.show_meta_info_key), true)) { metaInfoTextView.setVisibility(View.GONE); metaInfoSeparator.setVisibility(View.GONE); return Disposable.empty();