Separate some elements to set visibility separately

Added entries for:
- All apps header extra content
- Hotseat extra content

Change-Id: I47c4ccfe3b54fd47cbbee88698ed045611e3e92d
This commit is contained in:
Tony Wickham 2018-03-21 08:16:33 -07:00
parent c1b6157398
commit bd6f05e0b6
8 changed files with 44 additions and 24 deletions

View File

@ -24,7 +24,6 @@ import android.view.View;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
import com.android.launcher3.allapps.AllAppsContainerView;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
@ -86,7 +85,7 @@ public class AllAppsState extends LauncherState {
@Override
public int getVisibleElements(Launcher launcher) {
return ALL_APPS_HEADER | ALL_APPS_CONTENT;
return ALL_APPS_HEADER | ALL_APPS_HEADER_EXTRA | ALL_APPS_CONTENT;
}
@Override

View File

@ -111,16 +111,17 @@ public class OverviewState extends LauncherState {
public int getVisibleElements(Launcher launcher) {
if (launcher.getDeviceProfile().isVerticalBarLayout()) {
// TODO: Remove hotseat from overview
return HOTSEAT;
return HOTSEAT_ICONS;
} else {
return launcher.getAppsView().getFloatingHeaderView().hasVisibleContent()
? ALL_APPS_HEADER : HOTSEAT;
? HOTSEAT_EXTRA | ALL_APPS_HEADER_EXTRA : HOTSEAT_ICONS | HOTSEAT_EXTRA;
}
}
@Override
public float getVerticalProgress(Launcher launcher) {
if (getVisibleElements(launcher) == HOTSEAT) {
if ((getVisibleElements(launcher) & ALL_APPS_HEADER_EXTRA) == 0) {
// We have no all apps content, so we're still at the fully down progress.
return super.getVerticalProgress(launcher);
}
return 1 - (getDefaultSwipeHeight(launcher)

View File

@ -17,11 +17,14 @@
package com.android.launcher3.uioverrides;
import android.content.Context;
import android.view.View;
import android.view.View.AccessibilityDelegate;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.Hotseat;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherStateManager.StateHandler;
import com.android.launcher3.R;
import com.android.launcher3.util.TouchController;
import com.android.quickstep.OverviewInteractionState;
import com.android.quickstep.RecentsModel;
@ -84,4 +87,8 @@ public class UiFactory {
model.onTrimMemory(level);
}
}
public static View getHotseatExtraContent(Hotseat hotseat) {
return hotseat.findViewById(R.id.search_container_hotseat);
}
}

View File

@ -46,9 +46,11 @@ public class LauncherState {
* Note that workspace is not included here as in that case, we animate individual pages
*/
public static final int NONE = 0;
public static final int HOTSEAT = 1 << 0;
public static final int ALL_APPS_HEADER = 1 << 1;
public static final int ALL_APPS_CONTENT = 1 << 2;
public static final int HOTSEAT_ICONS = 1 << 0;
public static final int HOTSEAT_EXTRA = 1 << 1; // e.g. a search box
public static final int ALL_APPS_HEADER = 1 << 2;
public static final int ALL_APPS_HEADER_EXTRA = 1 << 3; // e.g. app predictions
public static final int ALL_APPS_CONTENT = 1 << 4;
protected static final int FLAG_SHOW_SCRIM = 1 << 0;
protected static final int FLAG_MULTI_PAGE = 1 << 1;
@ -193,7 +195,10 @@ public class LauncherState {
}
public int getVisibleElements(Launcher launcher) {
return HOTSEAT;
if (launcher.getDeviceProfile().isVerticalBarLayout()) {
return HOTSEAT_ICONS;
}
return HOTSEAT_ICONS | HOTSEAT_EXTRA;
}
/**

View File

@ -18,16 +18,10 @@ package com.android.launcher3;
import static com.android.launcher3.LauncherAnimUtils.DRAWABLE_ALPHA;
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import static com.android.launcher3.LauncherState.HOTSEAT;
import static com.android.launcher3.LauncherState.HOTSEAT_EXTRA;
import static com.android.launcher3.LauncherState.HOTSEAT_ICONS;
import static com.android.launcher3.anim.PropertySetter.NO_ANIM_PROPERTY_SETTER;
import static com.android.launcher3.compat.AccessibilityManagerCompat.isAccessibilityEnabled;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.util.Property;
import android.view.View;
import com.android.launcher3.LauncherState.PageAlphaProvider;
@ -36,6 +30,7 @@ import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.graphics.ViewScrim;
import com.android.launcher3.uioverrides.UiFactory;
/**
* Manages the animations between each of the workspace states.
@ -85,11 +80,14 @@ public class WorkspaceStateTransitionAnimation {
scaleAndTranslation[2], Interpolators.ZOOM_IN);
int elements = state.getVisibleElements(mLauncher);
float hotseatAlpha = (elements & HOTSEAT) != 0 ? 1 : 0;
propertySetter.setViewAlpha(mLauncher.getHotseat(), hotseatAlpha,
float hotseatIconsAlpha = (elements & HOTSEAT_ICONS) != 0 ? 1 : 0;
float hotseatExtraAlpha = (elements & HOTSEAT_EXTRA) != 0 ? 1 : 0;
propertySetter.setViewAlpha(mLauncher.getHotseat().getLayout(), hotseatIconsAlpha,
pageAlphaProvider.interpolator);
propertySetter.setViewAlpha(UiFactory.getHotseatExtraContent(mLauncher.getHotseat()),
hotseatExtraAlpha, pageAlphaProvider.interpolator);
propertySetter.setViewAlpha(mLauncher.getWorkspace().getPageIndicator(),
hotseatAlpha, pageAlphaProvider.interpolator);
hotseatIconsAlpha, pageAlphaProvider.interpolator);
// Set scrim
propertySetter.setFloat(ViewScrim.get(mWorkspace), ViewScrim.PROGRESS,

View File

@ -2,6 +2,7 @@ package com.android.launcher3.allapps;
import static com.android.launcher3.LauncherState.ALL_APPS_CONTENT;
import static com.android.launcher3.LauncherState.ALL_APPS_HEADER;
import static com.android.launcher3.LauncherState.ALL_APPS_HEADER_EXTRA;
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.PropertySetter.NO_ANIM_PROPERTY_SETTER;
@ -179,12 +180,13 @@ public class AllAppsTransitionController
private void setAlphas(LauncherState toState, PropertySetter setter) {
int visibleElements = toState.getVisibleElements(mLauncher);
boolean hasHeader = (visibleElements & ALL_APPS_HEADER) != 0;
boolean hasHeaderExtra = (visibleElements & ALL_APPS_HEADER_EXTRA) != 0;
boolean hasContent = (visibleElements & ALL_APPS_CONTENT) != 0;
setter.setViewAlpha(mAppsView.getSearchView(), hasHeader ? 1 : 0, LINEAR);
setter.setViewAlpha(mAppsView.getContentView(), hasContent ? 1 : 0, LINEAR);
setter.setViewAlpha(mAppsView.getScrollBar(), hasContent ? 1 : 0, LINEAR);
mAppsView.getFloatingHeaderView().setContentVisibility(hasHeader, hasContent, setter);
mAppsView.getFloatingHeaderView().setContentVisibility(hasHeaderExtra, hasContent, setter);
}
public AnimatorListenerAdapter getProgressAnimatorListener() {

View File

@ -32,8 +32,10 @@ public class PropertySetter {
public static final PropertySetter NO_ANIM_PROPERTY_SETTER = new PropertySetter();
public void setViewAlpha(View view, float alpha, TimeInterpolator interpolator) {
view.setAlpha(alpha);
AlphaUpdateListener.updateVisibility(view, isAccessibilityEnabled(view.getContext()));
if (view != null) {
view.setAlpha(alpha);
AlphaUpdateListener.updateVisibility(view, isAccessibilityEnabled(view.getContext()));
}
}
public <T> void setFloat(T target, Property<T, Float> property, float value,
@ -58,7 +60,7 @@ public class PropertySetter {
@Override
public void setViewAlpha(View view, float alpha, TimeInterpolator interpolator) {
if (view.getAlpha() == alpha) {
if (view == null || view.getAlpha() == alpha) {
return;
}
ObjectAnimator anim = ObjectAnimator.ofFloat(view, View.ALPHA, alpha);

View File

@ -16,8 +16,10 @@
package com.android.launcher3.uioverrides;
import android.view.View;
import android.view.View.AccessibilityDelegate;
import com.android.launcher3.Hotseat;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherStateManager.StateHandler;
import com.android.launcher3.util.TouchController;
@ -45,4 +47,8 @@ public class UiFactory {
public static void onStart(Launcher launcher) { }
public static void onTrimMemory(Launcher launcher, int level) { }
public static View getHotseatExtraContent(Hotseat hotseat) {
return null;
}
}