Skip to content

Commit

Permalink
Shade: Reload app drawer search bar elevation controller on view change
Browse files Browse the repository at this point in the history
  • Loading branch information
amirzaidi committed Jun 5, 2020
1 parent 1b3a70b commit 9339b5c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
5 changes: 5 additions & 0 deletions shade/src/amirz/shade/allapps/AllAppsView.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.android.launcher3.Utilities;
import com.android.launcher3.allapps.AllAppsContainerView;

import amirz.shade.search.AllAppsSearchBackground;
import amirz.shade.search.EditText;
import amirz.shade.util.AppReloader;

Expand Down Expand Up @@ -102,5 +103,9 @@ protected EdgeEffect createEdgeEffect(@NonNull RecyclerView view, int direction)
public void setupHeader() {
super.setupHeader();
getFloatingHeaderView().reset(false);

AllAppsSearchBackground bg = findViewById(R.id.fallback_search_view);
bg.setShadowAlpha(0);
addElevationController(bg.getElevationController());
}
}
3 changes: 0 additions & 3 deletions shade/src/amirz/shade/search/AllAppsQsb.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,6 @@ public void initialize(AllAppsContainerView appsView) {
mSearchBarController.initialize(
new HiddenAppsSearchAlgorithm(mLauncher, appsView.getAppsStore()),
mFallbackSearchViewText, mLauncher, this);

appsView.setRecyclerViewVerticalFadingEdgeEnabled(true);
appsView.addElevationController(mFallbackSearchView.getAlphaUpdater());
}

@Override
Expand Down
19 changes: 10 additions & 9 deletions shade/src/amirz/shade/search/AllAppsSearchBackground.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ public class AllAppsSearchBackground extends FrameLayout implements View.OnClick
private int mColor;
private int mShadowAlpha;

private RecyclerView.OnScrollListener mOnScrollListener = new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
setShadowAlpha(((BaseRecyclerView) recyclerView).getCurrentScrollY());
}
};

public AllAppsSearchBackground(@NonNull Context context) {
this(context, null);
}
Expand Down Expand Up @@ -176,17 +183,11 @@ public void setRadius(float radius) {
}
}

public RecyclerView.OnScrollListener getAlphaUpdater() {
setAlpha(0);
return new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
setAlpha(((BaseRecyclerView) recyclerView).getCurrentScrollY());
}
};
public RecyclerView.OnScrollListener getElevationController() {
return mOnScrollListener;
}

private void setAlpha(int newAlpha) {
public void setShadowAlpha(int newAlpha) {
int normalizedAlpha = Utilities.boundToRange(newAlpha, 0, 255);
if (mShadowAlpha != normalizedAlpha) {
mShadowAlpha = normalizedAlpha;
Expand Down

0 comments on commit 9339b5c

Please sign in to comment.