Merge "Adding support for continously capturing view hierarcy in Launcher" into tm-qpr-dev
diff --git a/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java b/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java
index 0284ae4..f42b39f 100644
--- a/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java
+++ b/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java
@@ -21,7 +21,6 @@
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
-import android.graphics.Rect;
import android.graphics.Typeface;
import android.os.Build;
import android.text.Layout;
@@ -33,7 +32,6 @@
import androidx.annotation.ColorInt;
import androidx.core.content.ContextCompat;
-import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.launcher3.allapps.FloatingHeaderRow;
import com.android.launcher3.allapps.FloatingHeaderView;
@@ -239,12 +237,6 @@
}
@Override
- public void setInsets(Rect insets, DeviceProfile grid) {
- int leftRightPadding = grid.allAppsLeftRightPadding;
- setPadding(leftRightPadding, getPaddingTop(), leftRightPadding, getPaddingBottom());
- }
-
- @Override
public void setVerticalScroll(int scroll, boolean isScrolledOut) {
setTranslationY(scroll);
mIsScrolledOut = isScrolledOut;
diff --git a/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java b/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java
index 1dec737..351a3bc 100644
--- a/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java
+++ b/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java
@@ -19,7 +19,6 @@
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
-import android.graphics.Rect;
import android.os.Build;
import android.util.AttributeSet;
import android.view.LayoutInflater;
@@ -252,12 +251,6 @@
}
@Override
- public void setInsets(Rect insets, DeviceProfile grid) {
- int leftRightPadding = grid.allAppsLeftRightPadding;
- setPadding(leftRightPadding, getPaddingTop(), leftRightPadding, getPaddingBottom());
- }
-
- @Override
public Class<PredictionRowView> getTypeClass() {
return PredictionRowView.class;
}
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 9dbfa83..9eb4d62 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -58,6 +58,7 @@
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.ActivityManager;
+import android.app.WindowConfiguration;
import android.content.Context;
import android.content.Intent;
import android.graphics.Matrix;
@@ -1421,6 +1422,16 @@
runningTaskTarget.taskInfo.pictureInPictureParams,
homeRotation,
mDp.hotseatBarSizePx);
+ final Rect appBounds = new Rect();
+ final WindowConfiguration winConfig = taskInfo.configuration.windowConfiguration;
+ // Adjust the appBounds for TaskBar by using the calculated window crop Rect
+ // from TaskViewSimulator and fallback to the bounds in TaskInfo when it's originated
+ // from windowing modes other than full-screen.
+ if (winConfig.getWindowingMode() == WindowConfiguration.WINDOWING_MODE_FULLSCREEN) {
+ mRemoteTargetHandles[0].getTaskViewSimulator().getCurrentCropRect().round(appBounds);
+ } else {
+ appBounds.set(winConfig.getBounds());
+ }
final SwipePipToHomeAnimator.Builder builder = new SwipePipToHomeAnimator.Builder()
.setContext(mContext)
.setTaskId(runningTaskTarget.taskId)
@@ -1428,7 +1439,7 @@
.setLeash(runningTaskTarget.leash)
.setSourceRectHint(
runningTaskTarget.taskInfo.pictureInPictureParams.getSourceRectHint())
- .setAppBounds(taskInfo.configuration.windowConfiguration.getBounds())
+ .setAppBounds(appBounds)
.setHomeToWindowPositionMap(homeToWindowPositionMap)
.setStartBounds(startRect)
.setDestinationBounds(destinationBounds)
diff --git a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java
index 14190b3..f2fcd06 100644
--- a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java
+++ b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java
@@ -221,8 +221,7 @@
private boolean updateHandler() {
mRecentsActivityRotation = inferRecentsActivityRotation(mDisplayRotation);
- if (mRecentsActivityRotation == mTouchRotation || (isRecentsActivityRotationAllowed()
- && (mFlags & FLAG_SWIPE_UP_NOT_RUNNING) != 0)) {
+ if (mRecentsActivityRotation == mTouchRotation || isRecentsActivityRotationAllowed()) {
mOrientationHandler = PagedOrientationHandler.PORTRAIT;
} else if (mTouchRotation == ROTATION_90) {
mOrientationHandler = PagedOrientationHandler.LANDSCAPE;
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index ba5cdcb..274a691 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -4014,7 +4014,8 @@
stagePosition);
mSplitHiddenTaskViewIndex = indexOfChild(taskView);
if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
- finishRecentsAnimation(true, null);
+ finishRecentsAnimation(true /* toRecents */, false /* shouldPip */,
+ null /* onFinishComplete */);
}
}
@@ -4873,10 +4874,10 @@
}
private void updateEnabledOverlays() {
- int overlayEnabledPage = mOverlayEnabled ? getNextPage() : -1;
int taskCount = getTaskViewCount();
for (int i = 0; i < taskCount; i++) {
- requireTaskViewAt(i).setOverlayEnabled(i == overlayEnabledPage);
+ TaskView taskView = requireTaskViewAt(i);
+ taskView.setOverlayEnabled(mOverlayEnabled && isTaskViewFullyVisible(taskView));
}
}
diff --git a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
index 1629bb7..32dc4d8 100644
--- a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
@@ -560,33 +560,16 @@
thumbnailScale = targetW / (croppedWidth * scale);
}
- Rect splitScreenInsets = dp.getInsets();
if (!isRotated) {
- // No Rotation
- mClippedInsets.offsetTo(thumbnailClipHint.left * scale,
- thumbnailClipHint.top * scale);
mMatrix.setTranslate(
-thumbnailClipHint.left * scale,
-thumbnailClipHint.top * scale);
} else {
- setThumbnailRotation(deltaRotate, thumbnailClipHint, scale, thumbnailBounds, dp);
+ setThumbnailRotation(deltaRotate, thumbnailBounds);
}
- final float widthWithInsets;
- final float heightWithInsets;
- if (isOrientationDifferent) {
- widthWithInsets = thumbnailBounds.height() * thumbnailScale;
- heightWithInsets = thumbnailBounds.width() * thumbnailScale;
- } else {
- widthWithInsets = thumbnailBounds.width() * thumbnailScale;
- heightWithInsets = thumbnailBounds.height() * thumbnailScale;
- }
- mClippedInsets.left *= thumbnailScale;
- mClippedInsets.top *= thumbnailScale;
- mClippedInsets.right = Math.max(0,
- widthWithInsets - mClippedInsets.left - canvasWidth);
- mClippedInsets.bottom = Math.max(0,
- heightWithInsets - mClippedInsets.top - canvasHeight);
+ float canvasScreenRatio = canvasWidth / (float) dp.widthPx;
+ mClippedInsets.set(0, 0, 0, dp.taskbarSize * canvasScreenRatio);
mMatrix.postScale(thumbnailScale, thumbnailScale);
mIsOrientationChanged = isOrientationDifferent;
@@ -607,44 +590,32 @@
return deltaRotation == Surface.ROTATION_90 || deltaRotation == Surface.ROTATION_270;
}
- private void setThumbnailRotation(int deltaRotate, RectF thumbnailInsets, float scale,
- Rect thumbnailPosition, DeviceProfile dp) {
- float newLeftInset = 0;
- float newTopInset = 0;
+ private void setThumbnailRotation(int deltaRotate, Rect thumbnailPosition) {
float translateX = 0;
float translateY = 0;
mMatrix.setRotate(90 * deltaRotate);
switch (deltaRotate) { /* Counter-clockwise */
case Surface.ROTATION_90:
- newLeftInset = thumbnailInsets.bottom;
- newTopInset = thumbnailInsets.left;
translateX = thumbnailPosition.height();
break;
case Surface.ROTATION_270:
- newLeftInset = thumbnailInsets.top;
- newTopInset = thumbnailInsets.right;
translateY = thumbnailPosition.width();
break;
case Surface.ROTATION_180:
- newLeftInset = -thumbnailInsets.top;
- newTopInset = -thumbnailInsets.left;
translateX = thumbnailPosition.width();
translateY = thumbnailPosition.height();
break;
}
- mClippedInsets.offsetTo(newLeftInset * scale, newTopInset * scale);
mMatrix.postTranslate(translateX, translateY);
- if (TaskView.useFullThumbnail(dp)) {
- mMatrix.postTranslate(-mClippedInsets.left, -mClippedInsets.top);
- }
}
/**
* Insets to used for clipping the thumbnail (in case it is drawing outside its own space)
*/
public RectF getInsetsToDrawInFullscreen(DeviceProfile dp) {
- return TaskView.useFullThumbnail(dp) ? mClippedInsets : EMPTY_RECT_F;
+ return dp.isTaskbarPresent && !dp.isTaskbarPresentInApps
+ ? mClippedInsets : EMPTY_RECT_F;
}
}
}
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index 723701d..68e9f5a 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -164,13 +164,6 @@
return deviceProfile.isTablet;
}
- /**
- * Should the TaskView scale down to fit whole thumbnail in fullscreen.
- */
- public static boolean useFullThumbnail(DeviceProfile deviceProfile) {
- return deviceProfile.isTablet && !deviceProfile.isTaskbarPresentInApps;
- }
-
private static final float EDGE_SCALE_DOWN_FACTOR_CAROUSEL = 0.03f;
private static final float EDGE_SCALE_DOWN_FACTOR_GRID = 0.00f;
@@ -1576,13 +1569,11 @@
RectF insets = pph.getInsetsToDrawInFullscreen(dp);
float currentInsetsLeft = insets.left * fullscreenProgress;
+ float currentInsetsTop = insets.top * fullscreenProgress;
float currentInsetsRight = insets.right * fullscreenProgress;
- float insetsBottom = insets.bottom;
- if (dp.isTaskbarPresentInApps) {
- insetsBottom = Math.max(0, insetsBottom - dp.taskbarSize);
- }
- mCurrentDrawnInsets.set(currentInsetsLeft, insets.top * fullscreenProgress,
- currentInsetsRight, insetsBottom * fullscreenProgress);
+ float currentInsetsBottom = insets.bottom * fullscreenProgress;
+ mCurrentDrawnInsets.set(
+ currentInsetsLeft, currentInsetsTop, currentInsetsRight, currentInsetsBottom);
mCurrentDrawnCornerRadius =
Utilities.mapRange(fullscreenProgress, mCornerRadius, mWindowCornerRadius)
diff --git a/res/drawable/bg_work_apps_paused_action_button.xml b/res/drawable/bg_work_apps_paused_action_button.xml
new file mode 100644
index 0000000..74d4693
--- /dev/null
+++ b/res/drawable/bg_work_apps_paused_action_button.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2022 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+ android:color="@color/accent_ripple_color">
+ <item android:id="@android:id/mask">
+ <shape android:shape="rectangle">
+ <corners android:radius="@dimen/rounded_button_radius" />
+ <solid android:color="@android:color/white" />
+ </shape>
+ </item>
+
+ <item android:id="@android:id/background">
+ <shape android:shape="rectangle">
+ <solid android:color="?android:attr/colorControlHighlight" />
+ <corners android:radius="@dimen/rounded_button_radius" />
+ </shape>
+ </item>
+</ripple>
\ No newline at end of file
diff --git a/res/drawable/work_apps_toggle_background.xml b/res/drawable/work_apps_toggle_background.xml
index a47c8fe..6ad6c82 100644
--- a/res/drawable/work_apps_toggle_background.xml
+++ b/res/drawable/work_apps_toggle_background.xml
@@ -13,16 +13,8 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_enabled="false">
- <shape android:shape="rectangle">
- <corners android:radius="@dimen/work_fab_radius" />
- <solid android:color="?android:attr/colorControlHighlight" />
- <padding
- android:left="@dimen/work_profile_footer_padding"
- android:right="@dimen/work_profile_footer_padding" />
- </shape>
- </item>
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+ android:color="@color/accent_ripple_color">
<item>
<shape android:shape="rectangle">
<corners android:radius="@dimen/work_fab_radius" />
@@ -32,4 +24,4 @@
android:right="@dimen/work_profile_footer_padding" />
</shape>
</item>
-</selector>
+</ripple>
diff --git a/res/layout/work_apps_paused.xml b/res/layout/work_apps_paused.xml
index 79bce70..f614d9b 100644
--- a/res/layout/work_apps_paused.xml
+++ b/res/layout/work_apps_paused.xml
@@ -48,7 +48,7 @@
android:textColor="?attr/workProfileOverlayTextColor"
android:text="@string/work_apps_enable_btn_text"
android:textAlignment="center"
- android:background="@drawable/rounded_action_button"
+ android:background="@drawable/bg_work_apps_paused_action_button"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:textSize="14sp" />
diff --git a/src/com/android/launcher3/allapps/FloatingHeaderRow.java b/src/com/android/launcher3/allapps/FloatingHeaderRow.java
index 6ff2132..75e527a 100644
--- a/src/com/android/launcher3/allapps/FloatingHeaderRow.java
+++ b/src/com/android/launcher3/allapps/FloatingHeaderRow.java
@@ -15,11 +15,8 @@
*/
package com.android.launcher3.allapps;
-import android.graphics.Rect;
import android.view.View;
-import com.android.launcher3.DeviceProfile;
-
/**
* A abstract representation of a row in all-apps view
*/
@@ -29,8 +26,6 @@
void setup(FloatingHeaderView parent, FloatingHeaderRow[] allRows, boolean tabsHidden);
- void setInsets(Rect insets, DeviceProfile grid);
-
int getExpectedHeight();
/**
diff --git a/src/com/android/launcher3/allapps/FloatingHeaderView.java b/src/com/android/launcher3/allapps/FloatingHeaderView.java
index 02655b7..c5bdb69 100644
--- a/src/com/android/launcher3/allapps/FloatingHeaderView.java
+++ b/src/com/android/launcher3/allapps/FloatingHeaderView.java
@@ -31,7 +31,6 @@
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
-import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Insettable;
import com.android.launcher3.R;
import com.android.launcher3.allapps.BaseAllAppsContainerView.AdapterHolder;
@@ -164,22 +163,6 @@
PluginManagerWrapper.INSTANCE.get(getContext()).removePluginListener(this);
}
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- mTabLayout.getLayoutParams().width = getTabWidth();
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- }
-
- /**
- * Returns distance between left and right app icons
- */
- public int getTabWidth() {
- DeviceProfile grid = ActivityContext.lookupContext(getContext()).getDeviceProfile();
- int totalWidth = getMeasuredWidth() - getPaddingLeft() - getPaddingRight();
- int iconPadding = totalWidth / grid.numShownAllAppsColumns - grid.allAppsIconSizePx;
- return totalWidth - iconPadding - grid.allAppsIconDrawablePaddingPx;
- }
-
private void recreateAllRowsArray() {
int pluginCount = mPluginRows.size();
if (pluginCount == 0) {
@@ -429,15 +412,6 @@
p.y = getTop() - mCurrentRV.getTop() - ((ViewGroup) mCurrentRV.getParent()).getTop();
}
- public boolean hasVisibleContent() {
- for (FloatingHeaderRow row : mAllRows) {
- if (row.hasVisibleContent()) {
- return true;
- }
- }
- return false;
- }
-
public boolean isHeaderProtectionSupported() {
return mHeaderProtectionSupported;
}
@@ -449,10 +423,9 @@
@Override
public void setInsets(Rect insets) {
- DeviceProfile grid = ActivityContext.lookupContext(getContext()).getDeviceProfile();
- for (FloatingHeaderRow row : mAllRows) {
- row.setInsets(insets, grid);
- }
+ int leftRightPadding = ActivityContext.lookupContext(getContext())
+ .getDeviceProfile().allAppsLeftRightPadding;
+ setPadding(leftRightPadding, getPaddingTop(), leftRightPadding, getPaddingBottom());
}
public <T extends FloatingHeaderRow> T findFixedRowByType(Class<T> type) {
diff --git a/src/com/android/launcher3/allapps/PluginHeaderRow.java b/src/com/android/launcher3/allapps/PluginHeaderRow.java
index 5b5fbb7..a9d36d1 100644
--- a/src/com/android/launcher3/allapps/PluginHeaderRow.java
+++ b/src/com/android/launcher3/allapps/PluginHeaderRow.java
@@ -18,10 +18,8 @@
import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;
-import android.graphics.Rect;
import android.view.View;
-import com.android.launcher3.DeviceProfile;
import com.android.systemui.plugins.AllAppsRow;
/**
@@ -43,9 +41,6 @@
boolean tabsHidden) { }
@Override
- public void setInsets(Rect insets, DeviceProfile grid) { }
-
- @Override
public int getExpectedHeight() {
return mPlugin.getExpectedHeight();
}
diff --git a/src/com/android/launcher3/allapps/WorkEduCard.java b/src/com/android/launcher3/allapps/WorkEduCard.java
index 836cd5a..539cff1 100644
--- a/src/com/android/launcher3/allapps/WorkEduCard.java
+++ b/src/com/android/launcher3/allapps/WorkEduCard.java
@@ -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;
@@ -70,8 +72,6 @@
protected void onFinishInflate() {
super.onFinishInflate();
findViewById(R.id.action_btn).setOnClickListener(this);
- MarginLayoutParams lp = ((MarginLayoutParams) findViewById(R.id.wrapper).getLayoutParams());
- lp.width = mActivityContext.getAppsView().getFloatingHeaderView().getTabWidth();
}
@Override
@@ -87,14 +87,10 @@
}
@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) {
@@ -107,8 +103,14 @@
}
}
+ @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;
}
-
}
diff --git a/src/com/android/launcher3/allapps/WorkModeSwitch.java b/src/com/android/launcher3/allapps/WorkModeSwitch.java
index 733577e..aee7c4c 100644
--- a/src/com/android/launcher3/allapps/WorkModeSwitch.java
+++ b/src/com/android/launcher3/allapps/WorkModeSwitch.java
@@ -16,20 +16,23 @@
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;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
-import android.view.ViewGroup;
+import android.view.ViewGroup.MarginLayoutParams;
import android.view.WindowInsets;
import android.widget.Button;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Insettable;
+import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.KeyboardInsetAnimationCallback;
+import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.model.StringCache;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip;
@@ -50,7 +53,6 @@
private boolean mWorkEnabled;
private boolean mOnWorkTab;
-
public WorkModeSwitch(Context context) {
this(context, null, 0);
}
@@ -85,15 +87,39 @@
@Override
public void setInsets(Rect insets) {
- int bottomInset = insets.bottom - mInsets.bottom;
mInsets.set(insets);
- ViewGroup.MarginLayoutParams marginLayoutParams =
- (ViewGroup.MarginLayoutParams) getLayoutParams();
- if (marginLayoutParams != null) {
- marginLayoutParams.bottomMargin = bottomInset + marginLayoutParams.bottomMargin;
+ MarginLayoutParams lp = (MarginLayoutParams) getLayoutParams();
+ if (lp != null) {
+ int bottomMargin = getResources().getDimensionPixelSize(R.dimen.work_fab_margin_bottom);
+ if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
+ bottomMargin <<= 1; // Double margin to add space above search bar.
+ bottomMargin += getResources().getDimensionPixelSize(R.dimen.qsb_widget_height);
+ }
+
+ DeviceProfile dp = ActivityContext.lookupContext(getContext()).getDeviceProfile();
+ if (!dp.isGestureMode) {
+ if (dp.isTaskbarPresent) {
+ bottomMargin += dp.taskbarSize;
+ } else {
+ bottomMargin += insets.bottom;
+ }
+ }
+
+ lp.bottomMargin = bottomMargin;
}
}
+ @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) {
diff --git a/src/com/android/launcher3/allapps/WorkProfileManager.java b/src/com/android/launcher3/allapps/WorkProfileManager.java
index 5edd431..2f5b7a2 100644
--- a/src/com/android/launcher3/allapps/WorkProfileManager.java
+++ b/src/com/android/launcher3/allapps/WorkProfileManager.java
@@ -26,7 +26,6 @@
import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;
-import android.view.ViewGroup;
import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
@@ -34,7 +33,6 @@
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
-import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip;
@@ -144,29 +142,6 @@
mWorkModeSwitch = (WorkModeSwitch) mAllApps.getLayoutInflater().inflate(
R.layout.work_mode_fab, mAllApps, false);
}
- ViewGroup.MarginLayoutParams lp =
- (ViewGroup.MarginLayoutParams) mWorkModeSwitch.getLayoutParams();
- int workFabMarginBottom =
- mWorkModeSwitch.getResources().getDimensionPixelSize(
- R.dimen.work_fab_margin_bottom);
- if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
- workFabMarginBottom <<= 1; // Double margin to add space above search bar.
- workFabMarginBottom +=
- mWorkModeSwitch.getResources().getDimensionPixelSize(R.dimen.qsb_widget_height);
- }
- if (!mAllApps.mActivityContext.getDeviceProfile().isGestureMode){
- if (mDeviceProfile.isTaskbarPresent){
- workFabMarginBottom += mDeviceProfile.taskbarSize;
- } else {
- workFabMarginBottom +=
- mAllApps.mActivityContext.getDeviceProfile().getInsets().bottom;
- }
- }
- lp.bottomMargin = workFabMarginBottom;
- int allAppsContainerWidth = mAllApps.getVisibleContainerView().getWidth();
- int personalWorkTabWidth =
- mAllApps.mActivityContext.getAppsView().getFloatingHeaderView().getTabWidth();
- lp.rightMargin = lp.leftMargin = (allAppsContainerWidth - personalWorkTabWidth) / 2;
if (mWorkModeSwitch.getParent() != mAllApps) {
mAllApps.addView(mWorkModeSwitch);
}
diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java
index 7f444d6..0334b96 100644
--- a/src/com/android/launcher3/testing/TestInformationHandler.java
+++ b/src/com/android/launcher3/testing/TestInformationHandler.java
@@ -206,7 +206,7 @@
/* spanX= */ 1, /* spanY= */ 1);
// TODO(b/234322284): return the real center point.
return new Point(cellRect.left + (cellRect.right - cellRect.left) / 3,
- cellRect.centerY());
+ cellRect.top + (cellRect.bottom - cellRect.top) / 3);
});
}
diff --git a/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java b/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
index 11185fb..49db2a0 100644
--- a/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
+++ b/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
@@ -23,7 +23,9 @@
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.
@@ -72,6 +74,26 @@
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.
*/