Loading src/com/android/launcher3/allapps/WorkEduCard.java +11 −7 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ */ package com.android.launcher3.allapps; import static com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip.getTabWidth; import android.content.Context; import android.util.AttributeSet; import android.view.View; Loading Loading @@ -85,14 +87,10 @@ public class WorkEduCard extends FrameLayout implements } @Override public void onAnimationRepeat(Animation animation) { } public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { } public void onAnimationStart(Animation animation) { } private void removeCard() { if (mPosition == -1) { Loading @@ -105,8 +103,14 @@ public class WorkEduCard extends FrameLayout implements } } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int size = MeasureSpec.getSize(widthMeasureSpec); findViewById(R.id.wrapper).getLayoutParams().width = getTabWidth(getContext(), size); super.onMeasure(widthMeasureSpec, heightMeasureSpec); } public void setPosition(int position) { mPosition = position; } } src/com/android/launcher3/allapps/WorkModeSwitch.java +13 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.launcher3.allapps; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TURN_OFF_WORK_APPS_TAP; import static com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip.getTabWidth; import android.content.Context; import android.graphics.Insets; Loading Loading @@ -96,7 +97,6 @@ public class WorkModeSwitch extends Button implements Insettable, View.OnClickLi } DeviceProfile dp = ActivityContext.lookupContext(getContext()).getDeviceProfile(); lp.rightMargin = lp.leftMargin = dp.allAppsLeftRightPadding; if (!dp.isGestureMode) { if (dp.isTaskbarPresent) { bottomMargin += dp.taskbarSize; Loading @@ -109,6 +109,18 @@ public class WorkModeSwitch extends Button implements Insettable, View.OnClickLi } } @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); DeviceProfile dp = ActivityContext.lookupContext(getContext()).getDeviceProfile(); View parent = (View) getParent(); int size = parent.getWidth() - parent.getPaddingLeft() - parent.getPaddingRight() - 2 * dp.allAppsLeftRightPadding; int tabWidth = getTabWidth(getContext(), size); int shift = (size - tabWidth) / 2 + dp.allAppsLeftRightPadding; setTranslationX(Utilities.isRtl(getResources()) ? shift : -shift); } @Override public void onActivePageChanged(int page) { mOnWorkTab = page == ActivityAllAppsContainerView.AdapterHolder.WORK; Loading src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java +22 −0 Original line number Diff line number Diff line Loading @@ -23,7 +23,9 @@ import android.widget.LinearLayout; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.launcher3.DeviceProfile; import com.android.launcher3.pageindicators.PageIndicator; import com.android.launcher3.views.ActivityContext; /** * Supports two indicator colors, dedicated for personal and work tabs. Loading Loading @@ -72,6 +74,26 @@ public class PersonalWorkSlidingTabStrip extends LinearLayout implements PageInd return false; } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (getPaddingLeft() == 0 && getPaddingRight() == 0) { // If any padding is not specified, restrict the width to emulate padding int size = MeasureSpec.getSize(widthMeasureSpec); size = getTabWidth(getContext(), size); widthMeasureSpec = MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY); } super.onMeasure(widthMeasureSpec, heightMeasureSpec); } /** * Returns distance between left and right app icons */ public static int getTabWidth(Context context, int totalWidth) { DeviceProfile grid = ActivityContext.lookupContext(context).getDeviceProfile(); int iconPadding = totalWidth / grid.numShownAllAppsColumns - grid.allAppsIconSizePx; return totalWidth - iconPadding; } /** * Interface definition for a callback to be invoked when an active page has been changed. */ Loading Loading
src/com/android/launcher3/allapps/WorkEduCard.java +11 −7 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ */ package com.android.launcher3.allapps; import static com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip.getTabWidth; import android.content.Context; import android.util.AttributeSet; import android.view.View; Loading Loading @@ -85,14 +87,10 @@ public class WorkEduCard extends FrameLayout implements } @Override public void onAnimationRepeat(Animation animation) { } public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { } public void onAnimationStart(Animation animation) { } private void removeCard() { if (mPosition == -1) { Loading @@ -105,8 +103,14 @@ public class WorkEduCard extends FrameLayout implements } } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int size = MeasureSpec.getSize(widthMeasureSpec); findViewById(R.id.wrapper).getLayoutParams().width = getTabWidth(getContext(), size); super.onMeasure(widthMeasureSpec, heightMeasureSpec); } public void setPosition(int position) { mPosition = position; } }
src/com/android/launcher3/allapps/WorkModeSwitch.java +13 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.launcher3.allapps; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TURN_OFF_WORK_APPS_TAP; import static com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip.getTabWidth; import android.content.Context; import android.graphics.Insets; Loading Loading @@ -96,7 +97,6 @@ public class WorkModeSwitch extends Button implements Insettable, View.OnClickLi } DeviceProfile dp = ActivityContext.lookupContext(getContext()).getDeviceProfile(); lp.rightMargin = lp.leftMargin = dp.allAppsLeftRightPadding; if (!dp.isGestureMode) { if (dp.isTaskbarPresent) { bottomMargin += dp.taskbarSize; Loading @@ -109,6 +109,18 @@ public class WorkModeSwitch extends Button implements Insettable, View.OnClickLi } } @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); DeviceProfile dp = ActivityContext.lookupContext(getContext()).getDeviceProfile(); View parent = (View) getParent(); int size = parent.getWidth() - parent.getPaddingLeft() - parent.getPaddingRight() - 2 * dp.allAppsLeftRightPadding; int tabWidth = getTabWidth(getContext(), size); int shift = (size - tabWidth) / 2 + dp.allAppsLeftRightPadding; setTranslationX(Utilities.isRtl(getResources()) ? shift : -shift); } @Override public void onActivePageChanged(int page) { mOnWorkTab = page == ActivityAllAppsContainerView.AdapterHolder.WORK; Loading
src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java +22 −0 Original line number Diff line number Diff line Loading @@ -23,7 +23,9 @@ import android.widget.LinearLayout; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.launcher3.DeviceProfile; import com.android.launcher3.pageindicators.PageIndicator; import com.android.launcher3.views.ActivityContext; /** * Supports two indicator colors, dedicated for personal and work tabs. Loading Loading @@ -72,6 +74,26 @@ public class PersonalWorkSlidingTabStrip extends LinearLayout implements PageInd return false; } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (getPaddingLeft() == 0 && getPaddingRight() == 0) { // If any padding is not specified, restrict the width to emulate padding int size = MeasureSpec.getSize(widthMeasureSpec); size = getTabWidth(getContext(), size); widthMeasureSpec = MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY); } super.onMeasure(widthMeasureSpec, heightMeasureSpec); } /** * Returns distance between left and right app icons */ public static int getTabWidth(Context context, int totalWidth) { DeviceProfile grid = ActivityContext.lookupContext(context).getDeviceProfile(); int iconPadding = totalWidth / grid.numShownAllAppsColumns - grid.allAppsIconSizePx; return totalWidth - iconPadding; } /** * Interface definition for a callback to be invoked when an active page has been changed. */ Loading