diff --git a/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java b/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java index 0284ae4803..f42b39fb2d 100644 --- a/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java +++ b/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java @@ -21,7 +21,6 @@ import static com.android.launcher3.util.OnboardingPrefs.ALL_APPS_VISITED_COUNT; 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 android.view.View; 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; @@ -238,12 +236,6 @@ public class AppsDividerView extends View implements FloatingHeaderRow { getPaddingBottom() + getPaddingTop()); } - @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); diff --git a/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java b/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java index 1dec73721c..351a3bc164 100644 --- a/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java +++ b/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java @@ -19,7 +19,6 @@ package com.android.launcher3.appprediction; 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; @@ -251,12 +250,6 @@ public class PredictionRowView getTypeClass() { return PredictionRowView.class; diff --git a/src/com/android/launcher3/allapps/FloatingHeaderRow.java b/src/com/android/launcher3/allapps/FloatingHeaderRow.java index 6ff2132286..75e527aaa8 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 @@ public interface FloatingHeaderRow { 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 02655b7eb8..c5bdb690b9 100644 --- a/src/com/android/launcher3/allapps/FloatingHeaderView.java +++ b/src/com/android/launcher3/allapps/FloatingHeaderView.java @@ -31,7 +31,6 @@ import androidx.annotation.NonNull; 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 @@ public class FloatingHeaderView extends LinearLayout implements 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 @@ public class FloatingHeaderView extends LinearLayout implements 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 @@ public class FloatingHeaderView extends LinearLayout implements @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 findFixedRowByType(Class type) { diff --git a/src/com/android/launcher3/allapps/PluginHeaderRow.java b/src/com/android/launcher3/allapps/PluginHeaderRow.java index 5b5fbb7ff9..a9d36d1909 100644 --- a/src/com/android/launcher3/allapps/PluginHeaderRow.java +++ b/src/com/android/launcher3/allapps/PluginHeaderRow.java @@ -18,10 +18,8 @@ package com.android.launcher3.allapps; 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; /** @@ -42,9 +40,6 @@ public class PluginHeaderRow implements FloatingHeaderRow { public void setup(FloatingHeaderView parent, FloatingHeaderRow[] allRows, 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 836cd5af93..4feeabb41a 100644 --- a/src/com/android/launcher3/allapps/WorkEduCard.java +++ b/src/com/android/launcher3/allapps/WorkEduCard.java @@ -70,8 +70,6 @@ public class WorkEduCard extends FrameLayout implements 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 diff --git a/src/com/android/launcher3/allapps/WorkModeSwitch.java b/src/com/android/launcher3/allapps/WorkModeSwitch.java index 733577eabf..bd24b77c58 100644 --- a/src/com/android/launcher3/allapps/WorkModeSwitch.java +++ b/src/com/android/launcher3/allapps/WorkModeSwitch.java @@ -22,14 +22,16 @@ 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 +52,6 @@ public class WorkModeSwitch extends Button implements Insettable, View.OnClickLi private boolean mWorkEnabled; private boolean mOnWorkTab; - public WorkModeSwitch(Context context) { this(context, null, 0); } @@ -85,16 +86,29 @@ public class WorkModeSwitch extends Button implements Insettable, View.OnClickLi @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(); + lp.rightMargin = lp.leftMargin = dp.allAppsLeftRightPadding; + if (!dp.isGestureMode) { + if (dp.isTaskbarPresent) { + bottomMargin += dp.taskbarSize; + } else { + bottomMargin += insets.bottom; + } + } + + lp.bottomMargin = bottomMargin; } } - @Override public void onActivePageChanged(int page) { mOnWorkTab = page == ActivityAllAppsContainerView.AdapterHolder.WORK; diff --git a/src/com/android/launcher3/allapps/WorkProfileManager.java b/src/com/android/launcher3/allapps/WorkProfileManager.java index 5edd431107..2f5b7a2dd3 100644 --- a/src/com/android/launcher3/allapps/WorkProfileManager.java +++ b/src/com/android/launcher3/allapps/WorkProfileManager.java @@ -26,7 +26,6 @@ import android.os.Process; 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 androidx.annotation.RequiresApi; 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 @@ public class WorkProfileManager implements PersonalWorkSlidingTabStrip.OnActiveP 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); }