diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-09-23 10:18:55 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-09-23 10:18:55 +0000 |
commit | 1698bb07deb14aed665fd41021cda8a1065bde63 (patch) | |
tree | 4b7aa94390d45773d70beacbd7e6c47bfc0c6cd1 | |
parent | 68bac44c7e0e2af4e897c8b6e6d36dff28c4dde3 (diff) | |
parent | 450ac483066cefdf74e8c1b50d1946677cd40449 (diff) | |
download | Launcher3-android13-mainline-scheduling-release.tar.gz |
Snap for 9098257 from 450ac483066cefdf74e8c1b50d1946677cd40449 to mainline-scheduling-releaseaml_sch_331113000aml_sch_331111000android13-mainline-scheduling-release
Change-Id: Ib452ab715b36eff89c16549160a86499dd0acc27
11 files changed, 74 insertions, 96 deletions
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; @@ -239,12 +237,6 @@ public class AppsDividerView extends View implements FloatingHeaderRow { } @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 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; @@ -252,12 +251,6 @@ public class PredictionRowView<T extends Context & ActivityContext & DeviceProfi } @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/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index 95da118948..dc2e3b624c 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -147,7 +147,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext { mIsUserSetupComplete = SettingsCache.INSTANCE.get(this).getValue( Settings.Secure.getUriFor(Settings.Secure.USER_SETUP_COMPLETE), 0); mIsNavBarForceVisible = SettingsCache.INSTANCE.get(this).getValue( - Settings.Secure.getUriFor(Settings.Secure.NAV_BAR_FORCE_VISIBLE), 0); + Settings.Secure.getUriFor(Settings.Secure.NAV_BAR_KIDS_MODE), 0); mIsNavBarKidsMode = SettingsCache.INSTANCE.get(this).getValue( Settings.Secure.getUriFor(Settings.Secure.NAV_BAR_KIDS_MODE), 0); diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index d676f7d195..76f7718765 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -166,11 +166,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, if (mActivity != activity) { return; } - if (mTaskAnimationManager != null) { - mTaskAnimationManager.finishRunningRecentsAnimation(true); - } mRecentsView = null; - mActivity.unregisterActivityLifecycleCallbacks(mLifecycleCallbacks); mActivity = null; } }; @@ -1599,6 +1595,9 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, private void reset() { mStateCallback.setStateOnUiThread(STATE_HANDLER_INVALIDATED); + if (mActivity != null) { + mActivity.unregisterActivityLifecycleCallbacks(mLifecycleCallbacks); + } } /** 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 6ecbad24e8..d0331c9266 100644 --- a/src/com/android/launcher3/allapps/FloatingHeaderView.java +++ b/src/com/android/launcher3/allapps/FloatingHeaderView.java @@ -30,7 +30,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; @@ -158,22 +157,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) { @@ -423,15 +406,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; } @@ -443,10 +417,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 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 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; /** @@ -43,9 +41,6 @@ public class PluginHeaderRow implements FloatingHeaderRow { 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..539cff1a37 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 @@ 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 @@ -87,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) { @@ -107,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; } - } diff --git a/src/com/android/launcher3/allapps/WorkModeSwitch.java b/src/com/android/launcher3/allapps/WorkModeSwitch.java index 733577eabf..edb012854a 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 @@ public class WorkModeSwitch extends Button implements Insettable, View.OnClickLi private boolean mWorkEnabled; private boolean mOnWorkTab; - public WorkModeSwitch(Context context) { this(context, null, 0); } @@ -85,15 +87,40 @@ 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 + 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 b70cb13b07..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,24 +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){ - workFabMarginBottom += mAllApps.mActivityContext.getDeviceProfile().getInsets().bottom; - } - lp.bottomMargin = workFabMarginBottom; - int totalScreenWidth = mDeviceProfile.widthPx; - int personalWorkTabWidth = - mAllApps.mActivityContext.getAppsView().getFloatingHeaderView().getTabWidth(); - lp.rightMargin = lp.leftMargin = (totalScreenWidth - personalWorkTabWidth) / 2; if (mWorkModeSwitch.getParent() != mAllApps) { mAllApps.addView(mWorkModeSwitch); } diff --git a/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java b/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java index 11185fb511..49db2a0b5f 100644 --- a/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java +++ b/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java @@ -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. @@ -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. */ |