Clean up work profile

This includes
- Dismiss work edu on launcher state change
- Remove work tab flash on first setup
- Make edu bottom sheet adopt theme color
- Fix Work toggle bottom inset


Bug: 149200572
Bug: 149197172
Bug: 149199058
Bug: 149215103
Bug: 149198955
Bug: 145595763
Bug:149481723

Test: Manual
Change-Id: I39a30782b80fd3a66bede55754fa30a940d2caee
This commit is contained in:
Samuel Fufa 2020-02-10 09:26:20 -08:00
parent c7f39fc66d
commit ccebfbe273
18 changed files with 92 additions and 110 deletions

View File

@ -15,5 +15,5 @@
-->
<vector android:height="24dp" android:viewportHeight="24"
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@color/bottom_panel_background" android:pathData="M19 9l1.25-2.75L23 5l-2.75-1.25L19 1l-1.25 2.75L15 5l2.75 1.25L19 9zm-7.5.5L9 4 6.5 9.5 1 12l5.5 2.5L9 20l2.5-5.5L17 12l-5.5-2.5zM19 15l-1.25 2.75L15 19l2.75 1.25L19 23l1.25-2.75L23 19l-2.75-1.25L19 15z"/>
<path android:fillColor="?android:attr/colorAccent" android:pathData="M19 9l1.25-2.75L23 5l-2.75-1.25L19 1l-1.25 2.75L15 5l2.75 1.25L19 9zm-7.5.5L9 4 6.5 9.5 1 12l5.5 2.5L9 20l2.5-5.5L17 12l-5.5-2.5zM19 15l-1.25 2.75L15 19l2.75 1.25L19 23l1.25-2.75L23 19l-2.75-1.25L19 15z"/>
</vector>

View File

@ -24,13 +24,13 @@
<View
android:layout_width="match_parent"
android:layout_height="32dp"
android:backgroundTint="@color/bottom_panel_background"
android:backgroundTint="?android:attr/colorAccent"
android:background="@drawable/bottom_sheet_top_border" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/bottom_panel_background"
android:background="?android:attr/colorAccent"
android:orientation="vertical">
<TextView

View File

@ -34,6 +34,7 @@ import com.android.launcher3.R;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.util.ActivityTracker;
import com.android.launcher3.util.Themes;
import java.util.List;
@ -109,7 +110,7 @@ public class HotseatEduController {
NOTIFICATION_CHANNEL_ID)
.setContentTitle(name)
.setOngoing(true)
.setColor(mLauncher.getColor(R.color.bottom_panel_background))
.setColor(Themes.getColorAccent(mLauncher))
.setContentIntent(PendingIntent.getActivity(mLauncher, 0, intent,
PendingIntent.FLAG_CANCEL_CURRENT))
.setSmallIcon(R.drawable.hotseat_edu_notification_icon)

View File

@ -191,7 +191,7 @@ public class HotseatEduDialog extends AbstractSlideInView implements Insettable
|| predictions.size() < mLauncher.getDeviceProfile().inv.numHotseatIcons) {
return;
}
mLauncher.getDragLayer().addView(this);
attachToContainer();
logOnBoardingSeen();
animateOpen();
for (int i = 0; i < mLauncher.getDeviceProfile().inv.numHotseatIcons; i++) {

View File

@ -53,6 +53,12 @@ public class AllAppsState extends LauncherState {
dispatchWindowStateChanged(launcher);
}
@Override
public void onStateDisabled(Launcher launcher) {
super.onStateDisabled(launcher);
AbstractFloatingView.closeAllOpenViews(launcher);
}
@Override
public String getDescription(Launcher launcher) {
AllAppsContainerView appsView = launcher.getAppsView();

View File

@ -15,9 +15,9 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/allAppsScrimColor"
android:padding="8dp"
android:orientation="vertical"
android:background="?attr/allAppsScrimColor"
android:gravity="center">
<ImageView
@ -38,7 +38,7 @@
android:layout_marginBottom="8dp"
android:text="@string/work_apps_paused_title"
android:textAlignment="center"
android:textSize="24sp" />
android:textSize="20sp" />
<TextView
android:layout_width="wrap_content"

View File

@ -21,22 +21,22 @@
<View
android:layout_width="match_parent"
android:backgroundTint="@color/bottom_panel_background"
android:layout_height="32dp"
android:background="@drawable/bottom_sheet_top_border" />
android:background="@drawable/bottom_sheet_top_border"
android:backgroundTint="?android:attr/colorAccent" />
<LinearLayout
android:id="@+id/view_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/bottom_panel_background"
android:background="?android:attr/colorAccent"
android:orientation="vertical"
android:paddingLeft="@dimen/bottom_sheet_edu_padding"
android:paddingRight="@dimen/bottom_sheet_edu_padding">
<TextView
style="@style/TextHeadline"
android:id="@+id/content_text"
style="@style/TextHeadline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="48dp"
@ -57,5 +57,4 @@
android:textAlignment="center"
android:textColor="@android:color/white" />
</LinearLayout>
</com.android.launcher3.views.WorkEduView>

View File

@ -45,5 +45,4 @@
<color name="back_gesture_tutorial_primary_color">#1A73E8</color> <!-- Blue -->
<color name="bottom_panel_background">#f01A73E8</color>
</resources>

View File

@ -330,7 +330,7 @@
<!--- User onboarding title for personal apps -->
<string name="work_profile_edu_personal_apps">Personal apps are private &amp; can\'t be seen by IT</string>
<!--- User onboarding title for work profile apps -->
<string name="work_profile_edu_work_apps">Work apps are badged and monitored by IT</string>
<string name="work_profile_edu_work_apps">Work apps are badged &amp; visible to IT</string>
<!-- Action label to proceed to the next work profile edu section-->
<string name="work_profile_edu_next">Next</string>
<!-- Action label to finish work profile edu-->

View File

@ -482,7 +482,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
@Override
public void onEnterAnimationComplete() {
super.onEnterAnimationComplete();
mAllAppsController.highlightWorkTabIfNecessary();
mRotationHelper.setCurrentTransitionRequest(REQUEST_NONE);
}

View File

@ -103,6 +103,8 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
private final MultiValueAlpha mMultiValueAlpha;
Rect mInsets = new Rect();
public AllAppsContainerView(Context context) {
this(context, null);
}
@ -320,6 +322,7 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
@Override
public void setInsets(Rect insets) {
mInsets.set(insets);
DeviceProfile grid = mLauncher.getDeviceProfile();
int leftRightPadding = grid.desiredWorkspaceLeftRightMarginPx
+ grid.cellLayoutPaddingLeftRightPx;
@ -411,6 +414,7 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
this.addView(mWorkFooterContainer);
mWorkFooterContainer.setInsets(mInsets);
mWorkFooterContainer.post(() -> mAH[AdapterHolder.WORK].applyPadding());
}
@ -548,17 +552,6 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
return mHeader != null && mHeader.getVisibility() == View.VISIBLE;
}
public void onScrollUpEnd() {
highlightWorkTabIfNecessary();
}
void highlightWorkTabIfNecessary() {
if (mUsingTabs) {
((PersonalWorkSlidingTabStrip) findViewById(R.id.tabs))
.highlightWorkTabIfNecessary();
}
}
/**
* Adds an update listener to {@param animator} that adds springs to the animation.
*/
@ -643,9 +636,9 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
R.layout.work_apps_paused, null);
recyclerView.post(() -> {
int width = recyclerView.getWidth();
int height = recyclerView.getHeight();
pausedOverlay.measure(makeMeasureSpec(width, EXACTLY),
makeMeasureSpec(height, EXACTLY));
int height = recyclerView.getHeight() - mWorkFooterContainer.getHeight();
pausedOverlay.measure(makeMeasureSpec(recyclerView.getWidth(), EXACTLY),
makeMeasureSpec(recyclerView.getHeight(), EXACTLY));
pausedOverlay.layout(0, 0, width, height);
applyPadding();
});

View File

@ -248,18 +248,6 @@ public class AllAppsTransitionController implements StateHandler, OnDeviceProfil
private void onProgressAnimationEnd() {
if (Float.compare(mProgress, 1f) == 0) {
mAppsView.reset(false /* animate */);
} else if (isAllAppsExpanded()) {
mAppsView.onScrollUpEnd();
}
}
private boolean isAllAppsExpanded() {
return Float.compare(mProgress, 0f) == 0;
}
public void highlightWorkTabIfNecessary() {
if (isAllAppsExpanded()) {
mAppsView.highlightWorkTabIfNecessary();
}
}
}

View File

@ -35,7 +35,6 @@ import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherStateManager.StateListener;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.pm.UserCache;
/**
* Abstract base class of floating view responsible for showing discovery bounce animation
@ -144,8 +143,7 @@ public class DiscoveryBounce extends AbstractFloatingView {
private static void showForHomeIfNeeded(Launcher launcher, boolean withDelay) {
if (!launcher.isInState(NORMAL)
|| (launcher.getSharedPrefs().getBoolean(HOME_BOUNCE_SEEN, false)
&& !shouldShowForWorkProfile(launcher))
|| launcher.getSharedPrefs().getBoolean(HOME_BOUNCE_SEEN, false)
|| AbstractFloatingView.getTopOpenView(launcher) != null
|| launcher.getSystemService(UserManager.class).isDemoUser()
|| Utilities.IS_RUNNING_IN_TEST_HARNESS) {
@ -170,8 +168,7 @@ public class DiscoveryBounce extends AbstractFloatingView {
|| !launcher.hasBeenResumed()
|| launcher.isForceInvisible()
|| launcher.getDeviceProfile().isVerticalBarLayout()
|| (launcher.getSharedPrefs().getBoolean(SHELF_BOUNCE_SEEN, false)
&& !shouldShowForWorkProfile(launcher))
|| launcher.getSharedPrefs().getBoolean(SHELF_BOUNCE_SEEN, false)
|| launcher.getSystemService(UserManager.class).isDemoUser()
|| Utilities.IS_RUNNING_IN_TEST_HARNESS) {
return;
@ -213,12 +210,6 @@ public class DiscoveryBounce extends AbstractFloatingView {
}
}
private static boolean shouldShowForWorkProfile(Launcher launcher) {
return !launcher.getSharedPrefs().getBoolean(
PersonalWorkSlidingTabStrip.KEY_SHOWED_PEEK_WORK_TAB, false)
&& UserCache.INSTANCE.get(launcher).hasWorkProfile();
}
private static void incrementShelfBounceCount(Launcher launcher) {
SharedPreferences sharedPrefs = launcher.getSharedPrefs();
int count = sharedPrefs.getInt(SHELF_BOUNCE_COUNT, 0);

View File

@ -63,6 +63,14 @@ public class LauncherAllAppsContainerView extends AllAppsContainerView {
.setScrollRangeDelta(mSearchUiManager.getScrollRangeDelta(insets));
}
@Override
public void setupHeader() {
super.setupHeader();
if (mWorkTabListener != null && !mUsingTabs) {
mLauncher.getStateManager().removeStateListener(mWorkTabListener);
}
}
@Override
public void onTabChanged(int pos) {
super.onTabChanged(pos);

View File

@ -16,7 +16,6 @@
package com.android.launcher3.allapps;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
@ -39,11 +38,8 @@ public class PersonalWorkSlidingTabStrip extends LinearLayout implements PageInd
private static final int POSITION_PERSONAL = 0;
private static final int POSITION_WORK = 1;
public static final String KEY_SHOWED_PEEK_WORK_TAB = "showed_peek_work_tab";
private final Paint mSelectedIndicatorPaint;
private final Paint mDividerPaint;
private final SharedPreferences mSharedPreferences;
private int mSelectedIndicatorHeight;
private int mIndicatorLeft = -1;
@ -72,7 +68,6 @@ public class PersonalWorkSlidingTabStrip extends LinearLayout implements PageInd
mDividerPaint.setStrokeWidth(
getResources().getDimensionPixelSize(R.dimen.all_apps_divider_height));
mSharedPreferences = Utilities.getPrefs(context);
mIsRtl = Utilities.isRtl(getResources());
}
@ -128,25 +123,6 @@ public class PersonalWorkSlidingTabStrip extends LinearLayout implements PageInd
mIndicatorRight, getHeight(), mSelectedIndicatorPaint);
}
public void highlightWorkTabIfNecessary() {
if (mSharedPreferences.getBoolean(KEY_SHOWED_PEEK_WORK_TAB, false)) {
return;
}
if (mLastActivePage != POSITION_PERSONAL) {
return;
}
highlightWorkTab();
mSharedPreferences.edit().putBoolean(KEY_SHOWED_PEEK_WORK_TAB, true).apply();
}
private void highlightWorkTab() {
View v = getChildAt(POSITION_WORK);
v.post(() -> {
v.setPressed(true);
v.setPressed(false);
});
}
@Override
public void setScroll(int currentScroll, int totalScroll) {
float scrollOffset = ((float) currentScroll) / totalScroll;

View File

@ -15,6 +15,8 @@
*/
package com.android.launcher3.views;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static com.android.launcher3.anim.Interpolators.scrollInterpolatorForVelocity;
import android.animation.Animator;
@ -62,6 +64,7 @@ public abstract class AbstractSlideInView extends AbstractFloatingView
protected final ObjectAnimator mOpenCloseAnimator;
protected View mContent;
private final View mColorScrim;
protected Interpolator mScrollInterpolator;
// range [0, 1], 0=> completely open, 1=> completely closed
@ -85,11 +88,30 @@ public abstract class AbstractSlideInView extends AbstractFloatingView
announceAccessibilityChanges();
}
});
int scrimColor = getScrimColor(mLauncher);
mColorScrim = scrimColor != -1 ? createColorScrim(mLauncher, scrimColor) : null;
}
protected void attachToContainer() {
if (mColorScrim != null) {
getPopupContainer().addView(mColorScrim);
}
getPopupContainer().addView(this);
}
/**
* Returns a scrim color for a sliding view. if returned value is -1, no scrim is added.
*/
protected int getScrimColor(Context context) {
return -1;
}
protected void setTranslationShift(float translationShift) {
mTranslationShift = translationShift;
mContent.setTranslationY(mTranslationShift * mContent.getHeight());
if (mColorScrim != null) {
mColorScrim.setAlpha(1 - mTranslationShift);
}
}
@Override
@ -127,7 +149,8 @@ public abstract class AbstractSlideInView extends AbstractFloatingView
/* SingleAxisSwipeDetector.Listener */
@Override
public void onDragStart(boolean start) { }
public void onDragStart(boolean start) {
}
@Override
public boolean onDrag(float displacement) {
@ -185,9 +208,25 @@ public abstract class AbstractSlideInView extends AbstractFloatingView
protected void onCloseComplete() {
mIsOpen = false;
getPopupContainer().removeView(this);
if (mColorScrim != null) {
getPopupContainer().removeView(mColorScrim);
}
}
protected BaseDragLayer getPopupContainer() {
return mLauncher.getDragLayer();
}
protected static View createColorScrim(Context context, int bgColor) {
View view = new View(context);
view.forceHasOverlappingRendering(false);
view.setBackgroundColor(bgColor);
BaseDragLayer.LayoutParams lp = new BaseDragLayer.LayoutParams(MATCH_PARENT, MATCH_PARENT);
lp.ignoreInsets = true;
view.setLayoutParams(lp);
return view;
}
}

View File

@ -52,11 +52,15 @@ public class WorkEduView extends AbstractSlideInView implements Insettable {
private static final int WORK_EDU_PERSONAL_APPS = 1;
private static final int WORK_EDU_WORK_APPS = 2;
protected static final int FINAL_SCRIM_BG_COLOR = 0x88000000;
private Rect mInsets = new Rect();
private View mViewWrapper;
private Button mProceedButton;
private TextView mContentText;
private AllAppsPagedView mAllAppsPagedView;
private int mNextWorkEduStep = WORK_EDU_PERSONAL_APPS;
@ -141,10 +145,15 @@ public class WorkEduView extends AbstractSlideInView implements Insettable {
}
private void show() {
mLauncher.getDragLayer().addView(this);
attachToContainer();
animateOpen();
}
@Override
protected int getScrimColor(Context context) {
return FINAL_SCRIM_BG_COLOR;
}
private void goToFirstPage() {
if (mAllAppsPagedView != null) {
mAllAppsPagedView.snapToPageImmediately(AllAppsContainerView.AdapterHolder.MAIN);

View File

@ -15,8 +15,6 @@
*/
package com.android.launcher3.widget;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound;
import static com.android.launcher3.logging.LoggerUtils.newContainerTarget;
@ -42,7 +40,6 @@ import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
import com.android.launcher3.util.SystemUiController;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.AbstractSlideInView;
import com.android.launcher3.views.BaseDragLayer;
/**
* Base class for various widgets popup
@ -55,11 +52,14 @@ abstract class BaseWidgetSheet extends AbstractSlideInView
/* Touch handling related member variables. */
private Toast mWidgetInstructionToast;
protected final View mColorScrim;
public BaseWidgetSheet(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mColorScrim = createColorScrim(context);
}
protected int getScrimColor(Context context) {
WallpaperColorInfo colors = WallpaperColorInfo.INSTANCE.get(context);
int alpha = context.getResources().getInteger(R.integer.extracted_color_gradient_alpha);
return setColorAlphaBound(colors.getSecondaryColor(), alpha);
}
@Override
@ -98,16 +98,6 @@ abstract class BaseWidgetSheet extends AbstractSlideInView
return true;
}
protected void attachToContainer() {
getPopupContainer().addView(mColorScrim);
getPopupContainer().addView(this);
}
protected void setTranslationShift(float translationShift) {
super.setTranslationShift(translationShift);
mColorScrim.setAlpha(1 - mTranslationShift);
}
private boolean beginDraggingWidget(WidgetCell v) {
// Get the widget preview as the drag representation
WidgetImageView image = v.getWidgetView();
@ -138,7 +128,6 @@ abstract class BaseWidgetSheet extends AbstractSlideInView
protected void onCloseComplete() {
super.onCloseComplete();
getPopupContainer().removeView(mColorScrim);
clearNavBarColor();
}
@ -177,19 +166,4 @@ abstract class BaseWidgetSheet extends AbstractSlideInView
protected SystemUiController getSystemUiController() {
return mLauncher.getSystemUiController();
}
private static View createColorScrim(Context context) {
View view = new View(context);
view.forceHasOverlappingRendering(false);
WallpaperColorInfo colors = WallpaperColorInfo.INSTANCE.get(context);
int alpha = context.getResources().getInteger(R.integer.extracted_color_gradient_alpha);
view.setBackgroundColor(setColorAlphaBound(colors.getSecondaryColor(), alpha));
BaseDragLayer.LayoutParams lp = new BaseDragLayer.LayoutParams(MATCH_PARENT, MATCH_PARENT);
lp.ignoreInsets = true;
view.setLayoutParams(lp);
return view;
}
}