Introduce transparency in all apps for OnDeviceSearch

Bug: 165999272

Change-Id: Ic4adf11d030328db47a5b0d1cd915b40902c12de
This commit is contained in:
Hyunyoung Song 2020-08-22 23:05:58 -07:00
parent ec50c06c99
commit d9d340c879
6 changed files with 24 additions and 14 deletions

View File

@ -35,9 +35,6 @@
<color name="icon_background">#E0E0E0</color> <!-- Gray 300 -->
<color name="all_apps_section_fill">#32c0c0c0</color>
<color name="all_apps_section_focused_item">#40c0c0c0</color>
<color name="gesture_tutorial_ripple_color">#A0C2F9</color> <!-- Light Blue -->
<color name="gesture_tutorial_fake_task_view_color">#6DA1FF</color> <!-- Light Blue -->
<color name="gesture_tutorial_action_button_label_color">#FFFFFFFF</color>

View File

@ -22,6 +22,7 @@ import android.graphics.RectF;
import android.view.View;
import androidx.annotation.Nullable;
import androidx.core.graphics.ColorUtils;
import androidx.recyclerview.widget.RecyclerView;
import com.android.launcher3.R;
@ -100,6 +101,9 @@ public class AllAppsSectionDecorator extends RecyclerView.ItemDecoration {
* Handles grouping and drawing of items in the same all apps sections.
*/
public static class SectionDecorationHandler {
private static final int FILL_ALPHA = (int) (.3f * 255);
private static final int FOCUS_ALPHA = (int) (.8f * 255);
protected RectF mBounds = new RectF();
private final boolean mIsFullWidth;
private final float mRadius;
@ -111,8 +115,9 @@ public class AllAppsSectionDecorator extends RecyclerView.ItemDecoration {
public SectionDecorationHandler(Context context, boolean isFullWidth) {
mIsFullWidth = isFullWidth;
mFillcolor = context.getColor(R.color.all_apps_section_fill);
mFocusColor = context.getColor(R.color.all_apps_section_focused_item);
int endScrim = Themes.getAttrColor(context, R.attr.allAppsScrimColor);
mFillcolor = ColorUtils.setAlphaComponent(endScrim, FILL_ALPHA);
mFocusColor = ColorUtils.setAlphaComponent(endScrim, FOCUS_ALPHA);
mRadius = Themes.getDialogCornerRadius(context);
}

View File

@ -139,8 +139,8 @@ public class AppsSearchContainerLayout extends ExtendedEditText
mApps = appsView.getApps();
mAppsView = appsView;
mSearchBarController.initialize(
new DefaultAppSearchAlgorithm(LauncherAppState.getInstance(mLauncher)), this,
mLauncher, this, this);
new DefaultAppSearchAlgorithm(mLauncher, LauncherAppState.getInstance(mLauncher)),
this, mLauncher, this, this);
}
@Override

View File

@ -53,15 +53,16 @@ public class AppsSearchPipeline implements SearchPipeline {
private final LauncherAppState mLauncherAppState;
private final boolean mHeroSectionSupported;
public AppsSearchPipeline(LauncherAppState launcherAppState) {
this(launcherAppState, true);
public AppsSearchPipeline(Context context, LauncherAppState launcherAppState) {
this(context, launcherAppState, true);
}
public AppsSearchPipeline(LauncherAppState launcherAppState, boolean supportsHeroView) {
public AppsSearchPipeline(Context context, LauncherAppState launcherAppState,
boolean supportsHeroView) {
mLauncherAppState = launcherAppState;
mSearchSectionInfo = new SearchSectionInfo();
mSearchSectionInfo.setDecorationHandler(
new SectionDecorationHandler(launcherAppState.getContext(), true));
new SectionDecorationHandler(context, true));
mHeroSectionSupported = supportsHeroView;
}

View File

@ -15,6 +15,7 @@
*/
package com.android.launcher3.allapps.search;
import android.content.Context;
import android.os.Handler;
import com.android.launcher3.LauncherAppState;
@ -30,9 +31,9 @@ public class DefaultAppSearchAlgorithm implements SearchAlgorithm {
protected final Handler mResultHandler;
private final AppsSearchPipeline mAppsSearchPipeline;
public DefaultAppSearchAlgorithm(LauncherAppState launcherAppState) {
public DefaultAppSearchAlgorithm(Context context, LauncherAppState launcherAppState) {
mResultHandler = new Handler();
mAppsSearchPipeline = new AppsSearchPipeline(launcherAppState, false);
mAppsSearchPipeline = new AppsSearchPipeline(context, launcherAppState, false);
}
@Override

View File

@ -32,6 +32,7 @@ import androidx.core.graphics.ColorUtils;
import com.android.launcher3.Insettable;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.uioverrides.WallpaperColorInfo;
import com.android.launcher3.uioverrides.WallpaperColorInfo.OnChangeListener;
import com.android.launcher3.util.Themes;
@ -41,6 +42,7 @@ import com.android.launcher3.util.Themes;
*/
public class ScrimView<T extends Launcher> extends View implements Insettable, OnChangeListener {
private static final float SCRIM_ALPHA = .75f;
protected final T mLauncher;
private final WallpaperColorInfo mWallpaperColorInfo;
protected final int mEndScrim;
@ -59,7 +61,11 @@ public class ScrimView<T extends Launcher> extends View implements Insettable, O
super(context, attrs);
mLauncher = Launcher.cast(Launcher.getLauncher(context));
mWallpaperColorInfo = WallpaperColorInfo.INSTANCE.get(context);
mEndScrim = Themes.getAttrColor(context, R.attr.allAppsScrimColor);
int endScrim = Themes.getAttrColor(context, R.attr.allAppsScrimColor);
if (FeatureFlags.ENABLE_DEVICE_SEARCH.get()) {
endScrim = ColorUtils.setAlphaComponent(endScrim, (int) (255 * SCRIM_ALPHA));
}
mEndScrim = endScrim;
mIsScrimDark = ColorUtils.calculateLuminance(mEndScrim) < 0.5f;
mMaxScrimAlpha = 0.7f;