Merge "Add DisplayController in PreviewContext's allowed objects" into tm-dev
diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java
index 2ca59eb..53dc9dd 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java
@@ -27,6 +27,7 @@
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.scrollInterpolatorForVelocity;
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME;
+import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_QUICKSWITCH_RIGHT;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_UNKNOWN_SWIPEDOWN;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_UNKNOWN_SWIPEUP;
import static com.android.launcher3.logging.StatsLogManager.getLauncherAtomEvent;
@@ -451,9 +452,11 @@
.withSrcState(LAUNCHER_STATE_HOME)
.withDstState(targetState.statsLogOrdinal)
.log(getLauncherAtomEvent(mStartState.statsLogOrdinal, targetState.statsLogOrdinal,
- targetState.ordinal > mStartState.ordinal
- ? LAUNCHER_UNKNOWN_SWIPEUP
- : LAUNCHER_UNKNOWN_SWIPEDOWN));
+ targetState == QUICK_SWITCH
+ ? LAUNCHER_QUICKSWITCH_RIGHT
+ : targetState.ordinal > mStartState.ordinal
+ ? LAUNCHER_UNKNOWN_SWIPEUP
+ : LAUNCHER_UNKNOWN_SWIPEDOWN));
mLauncher.getStateManager().goToState(targetState, false, forEndCallback(this::clearState));
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java
index 1504c12..dbee9c1 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java
@@ -261,7 +261,7 @@
@Override
protected void onReachedFinalState(LauncherState toState) {
- super.onReinitToState(toState);
+ super.onReachedFinalState(toState);
if (toState == ALL_APPS) {
InteractionJankMonitorWrapper.end(InteractionJankMonitorWrapper.CUJ_OPEN_ALL_APPS);
}
diff --git a/res/drawable/rounded_action_button.xml b/res/drawable/rounded_action_button.xml
index b9942c0..81e94f7 100644
--- a/res/drawable/rounded_action_button.xml
+++ b/res/drawable/rounded_action_button.xml
@@ -18,10 +18,11 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:shape="rectangle">
+ <solid android:color="?androidprv:attr/colorSurfaceVariant" />
<corners android:radius="@dimen/rounded_button_radius" />
<stroke
android:width="1dp"
- android:color="?androidprv:attr/colorAccentPrimaryVariant" />
+ android:color="?androidprv:attr/colorSurfaceVariant" />
<padding
android:left="@dimen/rounded_button_padding"
android:right="@dimen/rounded_button_padding" />
diff --git a/res/layout/work_apps_edu.xml b/res/layout/work_apps_edu.xml
index 73200de..f3b3053 100644
--- a/res/layout/work_apps_edu.xml
+++ b/res/layout/work_apps_edu.xml
@@ -16,9 +16,9 @@
<com.android.launcher3.allapps.WorkEduCard xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="8dp"
+ android:layout_marginTop="@dimen/work_edu_card_margin"
+ android:layout_marginBottom="@dimen/work_edu_card_bottom_margin"
android:gravity="center">
-
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -36,30 +36,29 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/work_card_margin"
- android:layout_marginRight="@dimen/work_card_margin"
+ android:layout_marginEnd="@dimen/work_card_margin"
android:text="@string/work_profile_edu_work_apps"
+ android:textDirection="locale"
android:textSize="18sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="@dimen/padded_rounded_button_height"
- android:orientation="horizontal"
- >
+ android:orientation="horizontal">
<FrameLayout
android:layout_width="@dimen/rounded_button_width"
android:layout_height="@dimen/rounded_button_width"
+ android:layout_alignParentEnd="true"
android:background="@drawable/rounded_action_button"
- android:padding="@dimen/rounded_button_padding"
- android:layout_alignParentRight="true">
+ android:padding="@dimen/rounded_button_padding">
<ImageButton
+ android:id="@+id/action_btn"
android:layout_width="@dimen/x_icon_size"
android:layout_height="@dimen/x_icon_size"
- android:id="@+id/action_btn"
- android:src="@drawable/ic_remove_no_shadow"
android:layout_gravity="center"
- android:padding="@dimen/x_icon_padding" />
+ android:padding="@dimen/x_icon_padding"
+ android:src="@drawable/ic_remove_no_shadow" />
</FrameLayout>
</RelativeLayout>
-
</RelativeLayout>
diff --git a/res/layout/work_mode_fab.xml b/res/layout/work_mode_fab.xml
index c536d77..d2fa5fa 100644
--- a/res/layout/work_mode_fab.xml
+++ b/res/layout/work_mode_fab.xml
@@ -21,14 +21,14 @@
android:layout_width="wrap_content"
android:gravity="center"
android:includeFontPadding="false"
+ android:textDirection="locale"
android:drawableTint="@color/all_apps_tab_text"
android:textColor="@color/all_apps_tab_text"
android:textSize="14sp"
android:background="@drawable/work_apps_toggle_background"
android:drawablePadding="8dp"
android:drawableStart="@drawable/ic_corp_off"
- android:layout_marginBottom="@dimen/work_fab_margin"
- android:layout_marginEnd="@dimen/work_fab_margin"
+ android:layout_marginBottom="@dimen/work_fab_margin_bottom"
android:paddingLeft="@dimen/work_mode_fab_padding"
android:paddingRight="@dimen/work_mode_fab_padding"
android:text="@string/work_apps_pause_btn_text" />
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 2c3f5ed..a8ee721 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -129,6 +129,7 @@
<dimen name="all_apps_height_extra">6dp</dimen>
<dimen name="all_apps_bottom_sheet_horizontal_padding">0dp</dimen>
<dimen name="all_apps_paged_view_top_padding">40dp</dimen>
+ <dimen name="all_apps_personal_work_tabs_vertical_margin">16dp</dimen>
<!-- The size of corner radius of the arrow in the arrow toast. -->
<dimen name="arrow_toast_corner_radius">2dp</dimen>
@@ -148,10 +149,12 @@
<dimen name="work_card_padding_horizontal">10dp</dimen>
<dimen name="work_card_button_height">52dp</dimen>
<dimen name="work_fab_margin">16dp</dimen>
+ <dimen name="work_fab_margin_bottom">20dp</dimen>
<dimen name="work_mode_fab_padding">16dp</dimen>
<dimen name="work_profile_footer_padding">20dp</dimen>
<dimen name="work_edu_card_margin">16dp</dimen>
<dimen name="work_edu_card_radius">16dp</dimen>
+ <dimen name="work_edu_card_bottom_margin">26dp</dimen>
<dimen name="work_card_margin">24dp</dimen>
<!-- (x) icon button inside work edu card -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ffa1e3f..ee5e024 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -428,7 +428,7 @@
<string name="work_apps_paused_edu_accept">Got it</string>
<!-- button string shown pause work profile -->
- <string name="work_apps_pause_btn_text">Turn off work apps</string>
+ <string name="work_apps_pause_btn_text">Pause work apps</string>
<!-- button string shown enable work profile -->
<string name="work_apps_enable_btn_text">Turn on work apps</string>
diff --git a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
index 4390b51..5bbc67e 100644
--- a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
@@ -142,7 +142,7 @@
mWorkManager = new WorkProfileManager(
mActivityContext.getSystemService(UserManager.class),
this,
- Utilities.getPrefs(mActivityContext));
+ Utilities.getPrefs(mActivityContext), mActivityContext.getDeviceProfile());
mAH = Arrays.asList(null, null);
mAH.set(AdapterHolder.MAIN, new AdapterHolder(false /* isWork */));
mAH.set(AdapterHolder.WORK, new AdapterHolder(true /* isWork */));
diff --git a/src/com/android/launcher3/allapps/WorkProfileManager.java b/src/com/android/launcher3/allapps/WorkProfileManager.java
index c5b02dd..dc9f18c 100644
--- a/src/com/android/launcher3/allapps/WorkProfileManager.java
+++ b/src/com/android/launcher3/allapps/WorkProfileManager.java
@@ -32,6 +32,7 @@
import androidx.annotation.Nullable;
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;
@@ -73,15 +74,17 @@
private final Predicate<ItemInfo> mMatcher;
private WorkModeSwitch mWorkModeSwitch;
+ private final DeviceProfile mDeviceProfile;
@WorkProfileState
private int mCurrentState;
public WorkProfileManager(UserManager userManager, BaseAllAppsContainerView<?> allApps,
- SharedPreferences preferences) {
+ SharedPreferences preferences, DeviceProfile deviceProfile) {
mUserManager = userManager;
mAllApps = allApps;
+ mDeviceProfile = deviceProfile;
mAdapterProvider = new WorkAdapterProvider(allApps.mActivityContext, preferences);
mMatcher = mAllApps.mPersonalMatcher.negate();
}
@@ -141,8 +144,11 @@
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);
+ 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 +=
@@ -151,8 +157,11 @@
if (!mAllApps.mActivityContext.getDeviceProfile().isGestureMode){
workFabMarginBottom += mAllApps.mActivityContext.getDeviceProfile().getInsets().bottom;
}
- ((ViewGroup.MarginLayoutParams) mWorkModeSwitch.getLayoutParams()).bottomMargin =
- workFabMarginBottom;
+ lp.bottomMargin = workFabMarginBottom;
+ int totalScreenWidth = mDeviceProfile.widthPx;
+ int personalWorkTabWidth =
+ mAllApps.mActivityContext.getAppsView().getActiveRecyclerView().getTabWidth();
+ lp.rightMargin = lp.leftMargin = (totalScreenWidth - personalWorkTabWidth) / 2;
if (mWorkModeSwitch.getParent() != mAllApps) {
mAllApps.addView(mWorkModeSwitch);
}
diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
index a125fbe..09b8228 100644
--- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
+++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
@@ -21,6 +21,7 @@
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
+import static com.android.launcher3.anim.AnimatorListeners.forEndCallback;
import static com.android.launcher3.anim.Interpolators.scrollInterpolatorForVelocity;
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_ALLAPPS;
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME;
@@ -330,9 +331,6 @@
Math.min(progress, 1) - endProgress) * durationMultiplier;
}
}
- if (targetState != mStartState) {
- logReachedState(targetState);
- }
mCurrentAnimation.setEndAction(() -> onSwipeInteractionCompleted(targetState));
ValueAnimator anim = mCurrentAnimation.getAnimationPlayer();
anim.setFloatValues(startProgress, endProgress);
@@ -361,6 +359,8 @@
boolean shouldGoToTargetState = mGoingBetweenStates || (mToState != targetState);
if (shouldGoToTargetState) {
goToTargetState(targetState);
+ } else {
+ logReachedState(mToState);
}
}
@@ -368,13 +368,19 @@
if (!mLauncher.isInState(targetState)) {
// If we're already in the target state, don't jump to it at the end of the animation in
// case the user started interacting with it before the animation finished.
- mLauncher.getStateManager().goToState(targetState, false /* animated */);
+ mLauncher.getStateManager().goToState(targetState, false /* animated */,
+ forEndCallback(() -> logReachedState(targetState)));
+ } else {
+ logReachedState(targetState);
}
mLauncher.getRootView().getSysUiScrim().createSysuiMultiplierAnim(
1f).setDuration(0).start();
}
private void logReachedState(LauncherState targetState) {
+ if (mStartState == targetState) {
+ return;
+ }
// Transition complete. log the action
mLauncher.getStatsLogManager().logger()
.withSrcState(mStartState.statsLogOrdinal)