Hide meta info panel in search when starting a new search
This commit is contained in:
parent
b265cabc22
commit
c2b6cec37d
5 changed files with 28 additions and 38 deletions
|
@ -1,11 +1,9 @@
|
||||||
package org.schabi.newpipe.fragments;
|
package org.schabi.newpipe.fragments;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
@ -138,10 +136,10 @@ public abstract class BaseStateFragment<I> extends BaseFragment implements ViewC
|
||||||
isLoading.set(false);
|
isLoading.set(false);
|
||||||
InfoCache.getInstance().clearCache();
|
InfoCache.getInstance().clearCache();
|
||||||
if (emptyStateView != null) {
|
if (emptyStateView != null) {
|
||||||
animateView(emptyStateView, false, 150);
|
animate(emptyStateView, false, 150);
|
||||||
}
|
}
|
||||||
if (loadingProgressBar != null) {
|
if (loadingProgressBar != null) {
|
||||||
animateView(loadingProgressBar, false, 0);
|
animate(loadingProgressBar, false, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,6 +148,7 @@ public final class VideoDetailFragment
|
||||||
private static final String COMMENTS_TAB_TAG = "COMMENTS";
|
private static final String COMMENTS_TAB_TAG = "COMMENTS";
|
||||||
private static final String RELATED_TAB_TAG = "NEXT VIDEO";
|
private static final String RELATED_TAB_TAG = "NEXT VIDEO";
|
||||||
private static final String DESCRIPTION_TAB_TAG = "DESCRIPTION TAB";
|
private static final String DESCRIPTION_TAB_TAG = "DESCRIPTION TAB";
|
||||||
|
private static final String EMPTY_TAB_TAG = "EMPTY TAB";
|
||||||
|
|
||||||
// tabs
|
// tabs
|
||||||
private boolean showComments;
|
private boolean showComments;
|
||||||
|
|
|
@ -161,11 +161,6 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
||||||
private EditText searchEditText;
|
private EditText searchEditText;
|
||||||
private View searchClear;
|
private View searchClear;
|
||||||
|
|
||||||
private TextView correctSuggestion;
|
|
||||||
private TextView metaInfoTextView;
|
|
||||||
private View metaInfoSeparator;
|
|
||||||
|
|
||||||
private View suggestionsPanel;
|
|
||||||
private boolean suggestionsPanelVisible = false;
|
private boolean suggestionsPanelVisible = false;
|
||||||
|
|
||||||
/*////////////////////////////////////////////////////////////////////////*/
|
/*////////////////////////////////////////////////////////////////////////*/
|
||||||
|
@ -277,7 +272,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
||||||
handleSearchSuggestion();
|
handleSearchSuggestion();
|
||||||
|
|
||||||
disposables.add(showMetaInfoInTextView(metaInfo == null ? null : Arrays.asList(metaInfo),
|
disposables.add(showMetaInfoInTextView(metaInfo == null ? null : Arrays.asList(metaInfo),
|
||||||
metaInfoTextView, metaInfoSeparator));
|
searchBinding.searchMetaInfoTextView, searchBinding.searchMetaInfoSeparator));
|
||||||
|
|
||||||
if (suggestionDisposable == null || suggestionDisposable.isDisposed()) {
|
if (suggestionDisposable == null || suggestionDisposable.isDisposed()) {
|
||||||
initSuggestionObserver();
|
initSuggestionObserver();
|
||||||
|
@ -363,10 +358,6 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
||||||
searchToolbarContainer = activity.findViewById(R.id.toolbar_search_container);
|
searchToolbarContainer = activity.findViewById(R.id.toolbar_search_container);
|
||||||
searchEditText = searchToolbarContainer.findViewById(R.id.toolbar_search_edit_text);
|
searchEditText = searchToolbarContainer.findViewById(R.id.toolbar_search_edit_text);
|
||||||
searchClear = searchToolbarContainer.findViewById(R.id.toolbar_search_clear);
|
searchClear = searchToolbarContainer.findViewById(R.id.toolbar_search_clear);
|
||||||
|
|
||||||
correctSuggestion = rootView.findViewById(R.id.correct_suggestion);
|
|
||||||
metaInfoTextView = rootView.findViewById(R.id.search_meta_info_text_view);
|
|
||||||
metaInfoSeparator = rootView.findViewById(R.id.search_meta_info_separator);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -839,6 +830,8 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
||||||
this.searchString = theSearchString;
|
this.searchString = theSearchString;
|
||||||
infoListAdapter.clearStreamItemList();
|
infoListAdapter.clearStreamItemList();
|
||||||
hideSuggestionsPanel();
|
hideSuggestionsPanel();
|
||||||
|
showMetaInfoInTextView(null, searchBinding.searchMetaInfoTextView,
|
||||||
|
searchBinding.searchMetaInfoSeparator);
|
||||||
hideKeyboardSearch();
|
hideKeyboardSearch();
|
||||||
|
|
||||||
disposables.add(historyRecordManager.onSearched(serviceId, theSearchString)
|
disposables.add(historyRecordManager.onSearched(serviceId, theSearchString)
|
||||||
|
@ -983,8 +976,8 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
||||||
// List<MetaInfo> cannot be bundled without creating some containers
|
// List<MetaInfo> cannot be bundled without creating some containers
|
||||||
metaInfo = new MetaInfo[result.getMetaInfo().size()];
|
metaInfo = new MetaInfo[result.getMetaInfo().size()];
|
||||||
metaInfo = result.getMetaInfo().toArray(metaInfo);
|
metaInfo = result.getMetaInfo().toArray(metaInfo);
|
||||||
disposables.add(showMetaInfoInTextView(result.getMetaInfo(), metaInfoTextView,
|
disposables.add(showMetaInfoInTextView(result.getMetaInfo(),
|
||||||
metaInfoSeparator));
|
searchBinding.searchMetaInfoTextView, searchBinding.searchMetaInfoSeparator));
|
||||||
|
|
||||||
handleSearchSuggestion();
|
handleSearchSuggestion();
|
||||||
|
|
||||||
|
|
|
@ -35,11 +35,11 @@ inline var View.backgroundTintListCompat: ColorStateList?
|
||||||
*/
|
*/
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun View.animate(
|
fun View.animate(
|
||||||
enterOrExit: Boolean,
|
enterOrExit: Boolean,
|
||||||
duration: Long,
|
duration: Long,
|
||||||
animationType: AnimationType = AnimationType.ALPHA,
|
animationType: AnimationType = AnimationType.ALPHA,
|
||||||
delay: Long = 0,
|
delay: Long = 0,
|
||||||
execOnEnd: Runnable? = null
|
execOnEnd: Runnable? = null
|
||||||
) {
|
) {
|
||||||
if (MainActivity.DEBUG) {
|
if (MainActivity.DEBUG) {
|
||||||
val id = try {
|
val id = try {
|
||||||
|
@ -48,8 +48,8 @@ fun View.animate(
|
||||||
id.toString()
|
id.toString()
|
||||||
}
|
}
|
||||||
val msg = String.format(
|
val msg = String.format(
|
||||||
"%8s → [%s:%s] [%s %s:%s] execOnEnd=%s", enterOrExit,
|
"%8s → [%s:%s] [%s %s:%s] execOnEnd=%s", enterOrExit,
|
||||||
javaClass.simpleName, id, animationType, duration, delay, execOnEnd
|
javaClass.simpleName, id, animationType, duration, delay, execOnEnd
|
||||||
)
|
)
|
||||||
Log.d(TAG, "animate(): $msg")
|
Log.d(TAG, "animate(): $msg")
|
||||||
}
|
}
|
||||||
|
@ -93,10 +93,10 @@ fun View.animate(
|
||||||
fun View.animateBackgroundColor(duration: Long, @ColorInt colorStart: Int, @ColorInt colorEnd: Int) {
|
fun View.animateBackgroundColor(duration: Long, @ColorInt colorStart: Int, @ColorInt colorEnd: Int) {
|
||||||
if (MainActivity.DEBUG) {
|
if (MainActivity.DEBUG) {
|
||||||
Log.d(
|
Log.d(
|
||||||
TAG,
|
TAG,
|
||||||
"animateBackgroundColor() called with: " +
|
"animateBackgroundColor() called with: " +
|
||||||
"view = [" + this + "], duration = [" + duration + "], " +
|
"view = [" + this + "], duration = [" + duration + "], " +
|
||||||
"colorStart = [" + colorStart + "], colorEnd = [" + colorEnd + "]"
|
"colorStart = [" + colorStart + "], colorEnd = [" + colorEnd + "]"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
val empty = arrayOf(IntArray(0))
|
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 {
|
fun View.animateHeight(duration: Long, targetHeight: Int): ValueAnimator {
|
||||||
if (MainActivity.DEBUG) {
|
if (MainActivity.DEBUG) {
|
||||||
Log.d(
|
Log.d(
|
||||||
TAG,
|
TAG,
|
||||||
"animateHeight: duration = [" + duration + "], " +
|
"animateHeight: duration = [" + duration + "], " +
|
||||||
"from " + height + " to → " + targetHeight + " in: " + this
|
"from " + height + " to → " + targetHeight + " in: " + this
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
val animator = ValueAnimator.ofFloat(height.toFloat(), targetHeight.toFloat())
|
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) {
|
fun View.animateRotation(duration: Long, targetRotation: Int) {
|
||||||
if (MainActivity.DEBUG) {
|
if (MainActivity.DEBUG) {
|
||||||
Log.d(
|
Log.d(
|
||||||
TAG,
|
TAG,
|
||||||
"animateRotation: duration = [" + duration + "], " +
|
"animateRotation: duration = [" + duration + "], " +
|
||||||
"from " + rotation + " to → " + targetRotation + " in: " + this
|
"from " + rotation + " to → " + targetRotation + " in: " + this
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
animate().setListener(null).cancel()
|
animate().setListener(null).cancel()
|
||||||
|
@ -319,7 +319,6 @@ fun View.slideUp(duration: Long, delay: Long, @FloatRange(from = 0.0, to = 1.0)
|
||||||
.start()
|
.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instead of hiding normally using [animate], which would make
|
* Instead of hiding normally using [animate], which would make
|
||||||
* the recycler view unable to capture touches after being hidden, this just animates the alpha
|
* the recycler view unable to capture touches after being hidden, this just animates the alpha
|
||||||
|
|
|
@ -274,10 +274,9 @@ public final class ExtractorHelper {
|
||||||
final TextView metaInfoTextView,
|
final TextView metaInfoTextView,
|
||||||
final View metaInfoSeparator) {
|
final View metaInfoSeparator) {
|
||||||
final Context context = metaInfoTextView.getContext();
|
final Context context = metaInfoTextView.getContext();
|
||||||
final boolean showMetaInfo = PreferenceManager.getDefaultSharedPreferences(context)
|
if (metaInfos == null || metaInfos.isEmpty()
|
||||||
.getBoolean(context.getString(R.string.show_meta_info_key), true);
|
|| !PreferenceManager.getDefaultSharedPreferences(context).getBoolean(
|
||||||
|
context.getString(R.string.show_meta_info_key), true)) {
|
||||||
if (!showMetaInfo || metaInfos == null || metaInfos.isEmpty()) {
|
|
||||||
metaInfoTextView.setVisibility(View.GONE);
|
metaInfoTextView.setVisibility(View.GONE);
|
||||||
metaInfoSeparator.setVisibility(View.GONE);
|
metaInfoSeparator.setVisibility(View.GONE);
|
||||||
return Disposable.empty();
|
return Disposable.empty();
|
||||||
|
|
Loading…
Reference in a new issue