mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 16:26:47 +00:00
Fixing search behavior in Launcher3
> Showing no-result found only when there are no results > Removing unnecessary view inflation in RecyclerViewPool for various search vide types > Removing unused market-search link and no-empty-result illustration Bug: 240343082 Bug: 207573083 Test: Verified Launcher3 Change-Id: Ia44799cd2385ea5dc837ef25732ca237975abde7
This commit is contained in:
@@ -24,13 +24,10 @@ import static com.android.launcher3.util.LogConfig.SEARCH_LOGGING;
|
||||
import static com.android.launcher3.util.UiThreadHelper.hideKeyboardAsync;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.util.SparseIntArray;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
@@ -39,7 +36,6 @@ import com.android.launcher3.FastScrollRecyclerView;
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.logging.StatsLogManager;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
import com.android.launcher3.views.RecyclerViewFastScroller;
|
||||
@@ -89,10 +85,6 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView {
|
||||
}
|
||||
};
|
||||
|
||||
// The empty-search result background
|
||||
protected AllAppsBackgroundDrawable mEmptySearchBackground;
|
||||
protected int mEmptySearchBackgroundTopOffset;
|
||||
|
||||
public AllAppsRecyclerView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
@@ -108,9 +100,6 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView {
|
||||
public AllAppsRecyclerView(Context context, AttributeSet attrs, int defStyleAttr,
|
||||
int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
Resources res = getResources();
|
||||
mEmptySearchBackgroundTopOffset = res.getDimensionPixelSize(
|
||||
R.dimen.all_apps_empty_search_bg_top_offset);
|
||||
mNumAppsPerRow = LauncherAppState.getIDP(context).numColumns;
|
||||
mFastScrollHelper = new AllAppsFastScrollHelper(this);
|
||||
}
|
||||
@@ -132,7 +121,6 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView {
|
||||
int approxRows = (int) Math.ceil(grid.availableHeightPx / grid.allAppsIconSizePx);
|
||||
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_EMPTY_SEARCH, 1);
|
||||
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_ALL_APPS_DIVIDER, 1);
|
||||
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_SEARCH_MARKET, 1);
|
||||
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_ICON, approxRows
|
||||
* (mNumAppsPerRow + 1));
|
||||
|
||||
@@ -143,10 +131,6 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView {
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas c) {
|
||||
// Draw the background
|
||||
if (mEmptySearchBackground != null && mEmptySearchBackground.getAlpha() > 0) {
|
||||
mEmptySearchBackground.draw(c);
|
||||
}
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "onDraw at = " + System.currentTimeMillis());
|
||||
}
|
||||
@@ -157,34 +141,14 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView {
|
||||
super.onDraw(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean verifyDrawable(Drawable who) {
|
||||
return who == mEmptySearchBackground || super.verifyDrawable(who);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
updateEmptySearchBackgroundBounds();
|
||||
updatePoolSize();
|
||||
}
|
||||
|
||||
public void onSearchResultsChanged() {
|
||||
// Always scroll the view to the top so the user can see the changed results
|
||||
scrollToTop();
|
||||
|
||||
if (mApps.hasNoFilteredResults() && !FeatureFlags.ENABLE_DEVICE_SEARCH.get()) {
|
||||
if (mEmptySearchBackground == null) {
|
||||
mEmptySearchBackground = new AllAppsBackgroundDrawable(getContext());
|
||||
mEmptySearchBackground.setAlpha(0);
|
||||
mEmptySearchBackground.setCallback(this);
|
||||
updateEmptySearchBackgroundBounds();
|
||||
}
|
||||
mEmptySearchBackground.animateBgAlpha(1f, 150);
|
||||
} else if (mEmptySearchBackground != null) {
|
||||
// For the time being, we just immediately hide the background to ensure that it does
|
||||
// not overlap with the results
|
||||
mEmptySearchBackground.setBgAlpha(0f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -208,16 +172,6 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent e) {
|
||||
boolean result = super.onInterceptTouchEvent(e);
|
||||
if (!result && e.getAction() == MotionEvent.ACTION_DOWN
|
||||
&& mEmptySearchBackground != null && mEmptySearchBackground.getAlpha() > 0) {
|
||||
mEmptySearchBackground.setHotspot(e.getX(), e.getY());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps the touch (from 0..1) to the adapter position that should be visible.
|
||||
*/
|
||||
@@ -393,22 +347,6 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView {
|
||||
return mScrollbar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the bounds of the empty search background.
|
||||
*/
|
||||
private void updateEmptySearchBackgroundBounds() {
|
||||
if (mEmptySearchBackground == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Center the empty search background on this new view bounds
|
||||
int x = (getMeasuredWidth() - mEmptySearchBackground.getIntrinsicWidth()) / 2;
|
||||
int y = mEmptySearchBackgroundTopOffset;
|
||||
mEmptySearchBackground.setBounds(x, y,
|
||||
x + mEmptySearchBackground.getIntrinsicWidth(),
|
||||
y + mEmptySearchBackground.getIntrinsicHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverlappingRendering() {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user