Support gray hotseat background in all apps transition

b/30201515

Change-Id: Ie4b8442ac804b4df94e9673608129e6ffc0c3360
This commit is contained in:
Hyunyoung Song
2016-07-18 16:35:10 -07:00
parent 77ba6b9cad
commit e4be3b3fdb
5 changed files with 43 additions and 26 deletions
+9 -8
View File
@@ -4,16 +4,16 @@
** **
** Copyright 2008, The Android Open Source Project ** Copyright 2008, The Android Open Source Project
** **
** Licensed under the Apache License, Version 2.0 (the "License"); ** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License. ** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at ** You may obtain a copy of the License at
** **
** http://www.apache.org/licenses/LICENSE-2.0 ** http://www.apache.org/licenses/LICENSE-2.0
** **
** Unless required by applicable law or agreed to in writing, software ** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS, ** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and ** See the License for the specific language governing permissions and
** limitations under the License. ** limitations under the License.
*/ */
--> -->
@@ -37,6 +37,7 @@
<color name="outline_color">#FFFFFFFF</color> <color name="outline_color">#FFFFFFFF</color>
<color name="all_apps_divider_color">#1E000000</color> <color name="all_apps_divider_color">#1E000000</color>
<color name="all_apps_caret_color">#FFFFFFFF</color> <color name="all_apps_caret_color">#FFFFFFFF</color>
<color name="all_apps_container_color">#FFF2F2F2</color>
<color name="spring_loaded_panel_color">#40FFFFFF</color> <color name="spring_loaded_panel_color">#40FFFFFF</color>
<color name="spring_loaded_highlighted_panel_border_color">#FFF</color> <color name="spring_loaded_highlighted_panel_border_color">#FFF</color>
@@ -36,7 +36,8 @@ public abstract class BaseContainerView extends FrameLayout {
protected final int mHorizontalPadding; protected final int mHorizontalPadding;
private final Drawable mRevealDrawable; private final InsetDrawable mRevealDrawable;
private final ColorDrawable mDrawable;
private View mRevealView; private View mRevealView;
private View mContent; private View mContent;
@@ -63,14 +64,16 @@ public abstract class BaseContainerView extends FrameLayout {
} }
if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP && this instanceof AllAppsContainerView) { if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP && this instanceof AllAppsContainerView) {
mRevealDrawable = new InsetDrawable(new ColorDrawable(Color.WHITE), mHorizontalPadding, mDrawable = new ColorDrawable();
0, mHorizontalPadding, 0); mRevealDrawable = new InsetDrawable(mDrawable,
mHorizontalPadding, 0, mHorizontalPadding, 0);
} else { } else {
TypedArray a = context.obtainStyledAttributes(attrs, TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.BaseContainerView, defStyleAttr, 0); R.styleable.BaseContainerView, defStyleAttr, 0);
mRevealDrawable = new InsetDrawable( mRevealDrawable = new InsetDrawable(
a.getDrawable(R.styleable.BaseContainerView_revealBackground), a.getDrawable(R.styleable.BaseContainerView_revealBackground),
mHorizontalPadding, 0, mHorizontalPadding, 0); mHorizontalPadding, 0, mHorizontalPadding, 0);
mDrawable = null;
a.recycle(); a.recycle();
} }
} }
@@ -82,8 +85,12 @@ public abstract class BaseContainerView extends FrameLayout {
mContent = findViewById(R.id.main_content); mContent = findViewById(R.id.main_content);
mRevealView = findViewById(R.id.reveal_view); mRevealView = findViewById(R.id.reveal_view);
mRevealView.setBackground(mRevealDrawable.getConstantState().newDrawable()); if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP && this instanceof AllAppsContainerView) {
mContent.setBackground(mRevealDrawable); mRevealView.setBackground(mRevealDrawable);
} else {
mRevealView.setBackground(mRevealDrawable.getConstantState().newDrawable());
mContent.setBackground(mRevealDrawable);
}
// We let the content have a intent background, but still have full width. // We let the content have a intent background, but still have full width.
// This allows the scroll bar to be used responsive outside the background bounds as well. // This allows the scroll bar to be used responsive outside the background bounds as well.
@@ -97,4 +104,8 @@ public abstract class BaseContainerView extends FrameLayout {
public final View getRevealView() { public final View getRevealView() {
return mRevealView; return mRevealView;
} }
public void setRevealDrawableColor(int color) {
mDrawable.setColor(color);
}
} }
+6 -3
View File
@@ -23,6 +23,7 @@ import android.graphics.Color;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.support.v4.graphics.ColorUtils;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
@@ -67,7 +68,9 @@ public class Hotseat extends FrameLayout
super(context, attrs, defStyle); super(context, attrs, defStyle);
mLauncher = (Launcher) context; mLauncher = (Launcher) context;
mHasVerticalHotseat = mLauncher.getDeviceProfile().isVerticalBarLayout(); mHasVerticalHotseat = mLauncher.getDeviceProfile().isVerticalBarLayout();
mBackground = new ColorDrawable(); mBackgroundColor = ColorUtils.setAlphaComponent(
context.getColor(R.color.all_apps_container_color), 0);
mBackground = new ColorDrawable(mBackgroundColor);
setBackground(mBackground); setBackground(mBackground);
} }
@@ -227,7 +230,7 @@ public class Hotseat extends FrameLayout
} }
} }
public int getBackgroundDrawableAlpha() { public int getBackgroundDrawableColor() {
return Color.alpha(mBackgroundColor); return mBackgroundColor;
} }
} }
@@ -366,9 +366,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
// TODO(hyunyoungs): clean up setting the content and the reveal view. // TODO(hyunyoungs): clean up setting the content and the reveal view.
if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) { if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) {
getContentView().setBackground(null);
getRevealView().setVisibility(View.VISIBLE); getRevealView().setVisibility(View.VISIBLE);
getRevealView().setAlpha(AllAppsTransitionController.ALL_APPS_FINAL_ALPHA);
} }
} }
@@ -3,7 +3,9 @@ package com.android.launcher3.allapps;
import android.animation.Animator; import android.animation.Animator;
import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet; import android.animation.AnimatorSet;
import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.graphics.Color;
import android.util.Log; import android.util.Log;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
@@ -43,14 +45,14 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
private final Interpolator mDecelInterpolator = new DecelerateInterpolator(1f); private final Interpolator mDecelInterpolator = new DecelerateInterpolator(1f);
private static final float ANIMATION_DURATION = 1200; private static final float ANIMATION_DURATION = 1200;
public static final float ALL_APPS_FINAL_ALPHA = .9f;
private static final float PARALLAX_COEFFICIENT = .125f; private static final float PARALLAX_COEFFICIENT = .125f;
private AllAppsContainerView mAppsView; private AllAppsContainerView mAppsView;
private int mAllAppsBackgroundColor;
private Workspace mWorkspace; private Workspace mWorkspace;
private Hotseat mHotseat; private Hotseat mHotseat;
private float mHotseatBackgroundAlpha; private int mHotseatBackgroundColor;
private ObjectAnimator mCaretAnimator; private ObjectAnimator mCaretAnimator;
private final long mCaretAnimationDuration; private final long mCaretAnimationDuration;
@@ -60,6 +62,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
private final Launcher mLauncher; private final Launcher mLauncher;
private final VerticalPullDetector mDetector; private final VerticalPullDetector mDetector;
private final ArgbEvaluator mEvaluator;
// Animation in this class is controlled by a single variable {@link mShiftCurrent}. // Animation in this class is controlled by a single variable {@link mShiftCurrent}.
// Visually, it represents top y coordinate of the all apps container. Using the // Visually, it represents top y coordinate of the all apps container. Using the
@@ -95,6 +98,8 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
R.integer.config_caretAnimationDuration); R.integer.config_caretAnimationDuration);
mCaretInterpolator = AnimationUtils.loadInterpolator(launcher, mCaretInterpolator = AnimationUtils.loadInterpolator(launcher,
R.interpolator.caret_animation_interpolator); R.interpolator.caret_animation_interpolator);
mEvaluator = new ArgbEvaluator();
mAllAppsBackgroundColor = launcher.getColor(R.color.all_apps_container_color);
} }
@Override @Override
@@ -248,17 +253,15 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
mStatusBarHeight = mLauncher.getDragLayer().getInsets().top; mStatusBarHeight = mLauncher.getDragLayer().getInsets().top;
mHotseat.setVisibility(View.VISIBLE); mHotseat.setVisibility(View.VISIBLE);
mHotseat.bringToFront(); mHotseat.bringToFront();
if (!mLauncher.isAllAppsVisible()) { if (!mLauncher.isAllAppsVisible()) {
mLauncher.tryAndUpdatePredictedApps(); mLauncher.tryAndUpdatePredictedApps();
mHotseatBackgroundColor = mHotseat.getBackgroundDrawableColor();
mHotseatBackgroundAlpha = mHotseat.getBackgroundDrawableAlpha() / 255f;
mHotseat.setBackgroundTransparent(true /* transparent */); mHotseat.setBackgroundTransparent(true /* transparent */);
mAppsView.setVisibility(View.VISIBLE); mAppsView.setVisibility(View.VISIBLE);
mAppsView.getContentView().setVisibility(View.VISIBLE); mAppsView.getContentView().setVisibility(View.VISIBLE);
mAppsView.getContentView().setBackground(null); mAppsView.getContentView().setBackground(null);
mAppsView.getRevealView().setVisibility(View.VISIBLE); mAppsView.getRevealView().setVisibility(View.VISIBLE);
mAppsView.getRevealView().setAlpha(mHotseatBackgroundAlpha); mAppsView.setRevealDrawableColor(mHotseatBackgroundColor);
} }
} else { } else {
setProgress(mShiftCurrent); setProgress(mShiftCurrent);
@@ -297,8 +300,9 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
float alpha = calcAlphaAllApps(progress); float alpha = calcAlphaAllApps(progress);
float workspaceHotseatAlpha = 1 - alpha; float workspaceHotseatAlpha = 1 - alpha;
mAppsView.getRevealView().setAlpha(Math.min(ALL_APPS_FINAL_ALPHA, Math.max(mHotseatBackgroundAlpha, int color = (Integer) mEvaluator.evaluate(mDecelInterpolator.getInterpolation(alpha),
mDecelInterpolator.getInterpolation(alpha)))); mHotseatBackgroundColor, mAllAppsBackgroundColor);
mAppsView.setRevealDrawableColor(color);
mAppsView.getContentView().setAlpha(alpha); mAppsView.getContentView().setAlpha(alpha);
mAppsView.setTranslationY(progress); mAppsView.setTranslationY(progress);
mWorkspace.setWorkspaceYTranslationAndAlpha( mWorkspace.setWorkspaceYTranslationAndAlpha(