Snap for 8644138 from 08355d9a65 to udc-release

Change-Id: Ifd72d508cd2b073edaee158f05d0a533cc7e2082
This commit is contained in:
Android Build Coastguard Worker committed 2022-05-26 03:25:19 +00:00
commit 7c67bcf41d
24 files changed
+218 -122

No files matched your search

@@ -19,7 +19,6 @@ import android.content.Context;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DeviceProfile.DeviceProfileListenable;
import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
import com.android.launcher3.util.Themes;
@@ -36,8 +35,6 @@ public abstract class BaseTaskbarContext extends ContextThemeWrapper implements
protected final LayoutInflater mLayoutInflater;
private final List<OnDeviceProfileChangeListener> mDPChangeListeners = new ArrayList<>();
protected DeviceProfile mDeviceProfile;
public BaseTaskbarContext(Context windowContext) {
super(windowContext, Themes.getActivityThemeRes(windowContext));
mLayoutInflater = LayoutInflater.from(this).cloneInContext(this);
@@ -48,19 +45,11 @@ public abstract class BaseTaskbarContext extends ContextThemeWrapper implements
return mLayoutInflater;
}
@Override
public final DeviceProfile getDeviceProfile() {
return mDeviceProfile;
}
@Override
public final List<OnDeviceProfileChangeListener> getOnDeviceProfileChangeListeners() {
return mDPChangeListeners;
}
/** Updates the {@link DeviceProfile} instance to the latest representation of the screen. */
public abstract void updateDeviceProfile(DeviceProfile dp);
/** Callback invoked when a drag is initiated within this context. */
public abstract void onDragStart();
@@ -528,7 +528,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
if (button.getVisibility() == View.VISIBLE) {
parent.getDescendantRectRelativeToSelf(button, mTempRect);
if (mHitboxExtender.extendedHitboxEnabled()) {
mTempRect.bottom += mContext.mDeviceProfile.getTaskbarOffsetY();
mTempRect.bottom += mContext.getDeviceProfile().getTaskbarOffsetY();
}
outRegion.op(mTempRect, Op.UNION);
}
@@ -111,6 +111,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
private final WindowManager mWindowManager;
private final @Nullable RoundedCorner mLeftCorner, mRightCorner;
private DeviceProfile mDeviceProfile;
private WindowManager.LayoutParams mWindowLayoutParams;
private boolean mIsFullscreen;
// The size we should return to when we call setTaskbarWindowFullscreen(false)
@@ -135,7 +136,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
TaskbarNavButtonController buttonController, ScopedUnfoldTransitionProgressProvider
unfoldTransitionProgressProvider) {
super(windowContext);
mDeviceProfile = dp;
mDeviceProfile = dp.copy(this);
final Resources resources = getResources();
@@ -200,7 +201,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
new TaskbarAutohideSuspendController(this),
new TaskbarPopupController(this),
new TaskbarForceVisibleImmersiveController(this),
new TaskbarAllAppsController(this),
new TaskbarAllAppsController(this, dp),
isDesktopMode
? new DesktopTaskbarRecentAppsController(this)
: TaskbarRecentAppsController.DEFAULT,
@@ -219,8 +220,14 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
}
@Override
public DeviceProfile getDeviceProfile() {
return mDeviceProfile;
}
/** Updates {@link DeviceProfile} instances for any Taskbar windows. */
public void updateDeviceProfile(DeviceProfile dp) {
mDeviceProfile = dp;
mControllers.taskbarAllAppsController.updateDeviceProfile(dp);
mDeviceProfile = dp.copy(this);
updateIconSize(getResources());
AbstractFloatingView.closeAllOpenViewsExcept(this, false, TYPE_REBIND_SAFE);
@@ -235,7 +242,6 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
mDeviceProfile.updateIconSize(1, resources);
float iconScale = taskbarIconSize / mDeviceProfile.iconSizePx;
mDeviceProfile.updateIconSize(iconScale, resources);
mDeviceProfile.updateAllAppsIconSize(1, resources); // Leave all apps unscaled.
}
@VisibleForTesting
@@ -148,7 +148,7 @@ public class TaskbarManager {
// Config change might be handled without re-creating the taskbar
if (mTaskbarActivityContext != null) {
if (dp != null && dp.isTaskbarPresent) {
mTaskbarActivityContext.updateDeviceProfile(dp.copy(mContext));
mTaskbarActivityContext.updateDeviceProfile(dp);
}
mTaskbarActivityContext.onConfigurationChanged(configDiff);
}
@@ -274,8 +274,8 @@ public class TaskbarManager {
return;
}
mTaskbarActivityContext = new TaskbarActivityContext(mContext, dp.copy(mContext),
mNavButtonController, mUnfoldProgressProvider);
mTaskbarActivityContext = new TaskbarActivityContext(mContext, dp, mNavButtonController,
mUnfoldProgressProvider);
mTaskbarActivityContext.init(mSharedState);
if (mActivity != null) {
@@ -19,7 +19,6 @@ import static android.view.KeyEvent.ACTION_UP;
import static android.view.KeyEvent.KEYCODE_BACK;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
import static com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE;
import static com.android.systemui.shared.system.ViewTreeObserverWrapper.InsetsInfo.TOUCHABLE_INSETS_REGION;
import android.content.Context;
@@ -78,14 +77,13 @@ class TaskbarAllAppsContext extends BaseTaskbarContext {
TaskbarStashController taskbarStashController) {
super(taskbarContext.createWindowContext(TYPE_APPLICATION_OVERLAY, null));
mTaskbarContext = taskbarContext;
mDeviceProfile = taskbarContext.getDeviceProfile();
mWindowController = windowController;
mDragController = new TaskbarDragController(this);
mOnboardingPrefs = new OnboardingPrefs<>(this, Utilities.getPrefs(this));
mDragLayer = new TaskbarAllAppsDragLayer(this);
TaskbarAllAppsSlideInView slideInView = (TaskbarAllAppsSlideInView) mLayoutInflater.inflate(
R.layout.taskbar_all_apps, mDragLayer, false);
mWindowController = windowController;
mAllAppsViewController = new TaskbarAllAppsViewController(
this,
slideInView,
@@ -101,6 +99,11 @@ class TaskbarAllAppsContext extends BaseTaskbarContext {
return mAllAppsViewController;
}
@Override
public DeviceProfile getDeviceProfile() {
return mWindowController.getDeviceProfile();
}
@Override
public TaskbarDragController getDragController() {
return mDragController;
@@ -141,15 +144,6 @@ class TaskbarAllAppsContext extends BaseTaskbarContext {
return mTaskbarContext.getDotInfoForItem(info);
}
@Override
public void updateDeviceProfile(DeviceProfile dp) {
mDeviceProfile = dp;
AbstractFloatingView.closeAllOpenViewsExcept(this, false, TYPE_REBIND_SAFE);
dispatchDeviceProfileChanged();
}
@Override
public void onDragStart() {}
@@ -19,6 +19,7 @@ import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_M
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
import static com.android.launcher3.AbstractFloatingView.TYPE_ALL;
import static com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE;
import android.content.Context;
import android.graphics.PixelFormat;
@@ -31,7 +32,6 @@ import androidx.annotation.Nullable;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
import com.android.launcher3.appprediction.PredictionRowView;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.model.data.AppInfo;
@@ -55,7 +55,7 @@ import java.util.Optional;
* Application data may be bound while the window does not exist, so this controller will store
* the models for the next all apps session.
*/
public final class TaskbarAllAppsController implements OnDeviceProfileChangeListener {
public final class TaskbarAllAppsController {
private static final String WINDOW_TITLE = "Taskbar All Apps";
@@ -70,6 +70,7 @@ public final class TaskbarAllAppsController implements OnDeviceProfileChangeList
}
};
private DeviceProfile mDeviceProfile;
private TaskbarControllers mControllers;
/** Window context for all apps if it is open. */
private @Nullable TaskbarAllAppsContext mAllAppsContext;
@@ -79,7 +80,8 @@ public final class TaskbarAllAppsController implements OnDeviceProfileChangeList
private int mAppsModelFlags;
private List<ItemInfo> mPredictedApps;
public TaskbarAllAppsController(TaskbarActivityContext context) {
public TaskbarAllAppsController(TaskbarActivityContext context, DeviceProfile dp) {
mDeviceProfile = dp;
mTaskbarContext = context;
mProxyView = new TaskbarAllAppsProxyView(mTaskbarContext);
mLayoutParams = createLayoutParams();
@@ -146,7 +148,6 @@ public final class TaskbarAllAppsController implements OnDeviceProfileChangeList
this,
mControllers.taskbarStashController);
mAllAppsContext.getDragController().init(mControllers);
mTaskbarContext.addOnDeviceProfileChangeListener(this);
TaskStackChangeListeners.getInstance().registerTaskStackListener(mTaskStackListener);
Optional.ofNullable(mAllAppsContext.getSystemService(WindowManager.class))
.ifPresent(m -> m.addView(mAllAppsContext.getDragLayer(), mLayoutParams));
@@ -184,13 +185,25 @@ public final class TaskbarAllAppsController implements OnDeviceProfileChangeList
/** Destroys the controller and any All Apps window if present. */
public void onDestroy() {
TaskStackChangeListeners.getInstance().unregisterTaskStackListener(mTaskStackListener);
mTaskbarContext.removeOnDeviceProfileChangeListener(this);
Optional.ofNullable(mAllAppsContext)
.map(c -> c.getSystemService(WindowManager.class))
.ifPresent(m -> m.removeView(mAllAppsContext.getDragLayer()));
mAllAppsContext = null;
}
/** Updates {@link DeviceProfile} instance for Taskbar's All Apps window. */
public void updateDeviceProfile(DeviceProfile dp) {
mDeviceProfile = dp;
Optional.ofNullable(mAllAppsContext).ifPresent(c -> {
AbstractFloatingView.closeAllOpenViewsExcept(c, false, TYPE_REBIND_SAFE);
c.dispatchDeviceProfileChanged();
});
}
DeviceProfile getDeviceProfile() {
return mDeviceProfile;
}
private LayoutParams createLayoutParams() {
LayoutParams layoutParams = new LayoutParams(
TYPE_APPLICATION_OVERLAY,
@@ -205,11 +218,6 @@ public final class TaskbarAllAppsController implements OnDeviceProfileChangeList
return layoutParams;
}
@Override
public void onDeviceProfileChanged(DeviceProfile dp) {
Optional.ofNullable(mAllAppsContext).ifPresent(c -> c.updateDeviceProfile(dp));
}
/**
* Proxy view connecting taskbar drag layer to the all apps window.
* <p>
@@ -268,6 +268,16 @@ public class TouchInteractionService extends Service
MAIN_EXECUTOR.execute(ProxyScreenStatusProvider.INSTANCE::onScreenTurnedOn);
}
/**
* Preloads the Overview activity.
*
* This method should only be used when the All Set page of the SUW is reached to safely
* preload the Launcher for the SUW first reveal.
*/
public void preloadOverviewForSUWAllSet() {
preloadOverview(false, true);
}
@Override
public void onRotationProposal(int rotation, boolean isValid) {
executeForTaskbarManager(() -> mTaskbarManager.onRotationProposal(rotation, isValid));
@@ -883,6 +893,10 @@ public class TouchInteractionService extends Service
}
private void preloadOverview(boolean fromInit) {
preloadOverview(fromInit, false);
}
private void preloadOverview(boolean fromInit, boolean forSUWAllSet) {
if (!mDeviceState.isUserUnlocked()) {
return;
}
@@ -892,7 +906,8 @@ public class TouchInteractionService extends Service
return;
}
if (RestoreDbTask.isPending(this) || !mDeviceState.isUserSetupComplete()) {
if ((RestoreDbTask.isPending(this) && !forSUWAllSet)
|| !mDeviceState.isUserSetupComplete()) {
// Preloading while a restore is pending may cause launcher to start the restore
// too early.
return;
@@ -149,45 +149,50 @@ public class AllSetActivity extends Activity {
}
private void startBackgroundAnimation() {
if (Utilities.ATLEAST_S && mVibrator != null && mVibrator.areAllPrimitivesSupported(
VibrationEffect.Composition.PRIMITIVE_THUD)) {
if (mBackgroundAnimatorListener == null) {
mBackgroundAnimatorListener =
new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
runOnUiHelperThread(() -> mVibrator.vibrate(getVibrationEffect()));
}
@Override
public void onAnimationRepeat(Animator animation) {
runOnUiHelperThread(() -> mVibrator.vibrate(getVibrationEffect()));
}
@Override
public void onAnimationEnd(Animator animation) {
runOnUiHelperThread(mVibrator::cancel);
}
@Override
public void onAnimationCancel(Animator animation) {
runOnUiHelperThread(mVibrator::cancel);
}
};
}
mAnimatedBackground.addAnimatorListener(mBackgroundAnimatorListener);
if (!Utilities.ATLEAST_S || mVibrator == null) {
return;
}
mAnimatedBackground.playAnimation();
}
boolean supportsThud = mVibrator.areAllPrimitivesSupported(
VibrationEffect.Composition.PRIMITIVE_THUD);
/**
* Sets up the vibration effect for the next round of animation. The parameters vary between
* different illustrations.
*/
private VibrationEffect getVibrationEffect() {
return VibrationEffect.startComposition()
.addPrimitive(VibrationEffect.Composition.PRIMITIVE_THUD, 1.0f, 50)
.compose();
if (!supportsThud && !mVibrator.areAllPrimitivesSupported(
VibrationEffect.Composition.PRIMITIVE_TICK)) {
return;
}
if (mBackgroundAnimatorListener == null) {
VibrationEffect vibrationEffect = VibrationEffect.startComposition()
.addPrimitive(supportsThud
? VibrationEffect.Composition.PRIMITIVE_THUD
: VibrationEffect.Composition.PRIMITIVE_TICK,
/* scale= */ 1.0f,
/* delay= */ 50)
.compose();
mBackgroundAnimatorListener =
new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
runOnUiHelperThread(() -> mVibrator.vibrate(vibrationEffect));
}
@Override
public void onAnimationRepeat(Animator animation) {
runOnUiHelperThread(() -> mVibrator.vibrate(vibrationEffect));
}
@Override
public void onAnimationEnd(Animator animation) {
runOnUiHelperThread(mVibrator::cancel);
}
@Override
public void onAnimationCancel(Animator animation) {
runOnUiHelperThread(mVibrator::cancel);
}
};
}
mAnimatedBackground.addAnimatorListener(mBackgroundAnimatorListener);
mAnimatedBackground.playAnimation();
}
@Override
@@ -203,6 +208,7 @@ public class AllSetActivity extends Activity {
mBinder = binder;
mBinder.getTaskbarManager().setSetupUIVisible(isResumed());
mBinder.setSwipeUpProxy(isResumed() ? this::createSwipeUpProxy : null);
mBinder.preloadOverviewForSUWAllSet();
}
@Override
@@ -1,5 +1,6 @@
package com.android.quickstep.views;
import static com.android.launcher3.AbstractFloatingView.TYPE_TASK_MENU;
import static com.android.launcher3.anim.Interpolators.ACCEL;
import static com.android.launcher3.anim.Interpolators.DEACCEL_3;
import static com.android.launcher3.anim.Interpolators.LINEAR;
@@ -19,6 +20,7 @@ import android.widget.FrameLayout;
import androidx.annotation.Nullable;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.BaseActivity;
import com.android.launcher3.InsettableFrameLayout;
import com.android.launcher3.LauncherAnimUtils;
@@ -110,13 +112,19 @@ public class FloatingTaskView extends FrameLayout {
*/
public static FloatingTaskView getFloatingTaskView(StatefulActivity launcher,
View originalView, @Nullable Bitmap thumbnail, Drawable icon, RectF positionOut) {
final BaseDragLayer dragLayer = launcher.getDragLayer();
ViewGroup parent = (ViewGroup) dragLayer.getParent();
final ViewGroup dragLayer = launcher.getDragLayer();
final FloatingTaskView floatingView = (FloatingTaskView) launcher.getLayoutInflater()
.inflate(R.layout.floating_split_select_view, parent, false);
.inflate(R.layout.floating_split_select_view, dragLayer, false);
floatingView.init(launcher, originalView, thumbnail, icon, positionOut);
parent.addView(floatingView);
// Add this animating view underneath the existing open task menu view (if there is one)
View openTaskView = AbstractFloatingView.getOpenView(launcher, TYPE_TASK_MENU);
int openTaskViewIndex = dragLayer.indexOfChild(openTaskView);
if (openTaskViewIndex == -1) {
// Add to top if not
openTaskViewIndex = dragLayer.getChildCount();
}
dragLayer.addView(floatingView, openTaskViewIndex - 1);
return floatingView;
}
@@ -125,7 +133,7 @@ public class FloatingTaskView extends FrameLayout {
Utilities.getBoundsForViewInDragLayer(mActivity.getDragLayer(), originalView, viewBounds,
false /* ignoreTransform */, null /* recycle */,
mStartingPosition);
final InsettableFrameLayout.LayoutParams lp = new InsettableFrameLayout.LayoutParams(
final BaseDragLayer.LayoutParams lp = new BaseDragLayer.LayoutParams(
Math.round(mStartingPosition.width()),
Math.round(mStartingPosition.height()));
initPosition(mStartingPosition, lp);
@@ -34,6 +34,7 @@ import static com.android.launcher3.Utilities.squaredTouchSlop;
import static com.android.launcher3.anim.Interpolators.ACCEL;
import static com.android.launcher3.anim.Interpolators.ACCEL_0_75;
import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL;
import static com.android.launcher3.anim.Interpolators.DEACCEL_2;
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
import static com.android.launcher3.anim.Interpolators.FINAL_FRAME;
import static com.android.launcher3.anim.Interpolators.LINEAR;
@@ -4097,6 +4098,10 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
mSecondSplitHiddenView.setVisibility(INVISIBLE);
InteractionJankMonitorWrapper.begin(this,
InteractionJankMonitorWrapper.CUJ_SPLIT_SCREEN_ENTER, "Second tile selected");
// Fade out all other views underneath placeholders
ObjectAnimator tvFade = ObjectAnimator.ofFloat(this, RecentsView.CONTENT_ALPHA,1, 0);
pendingAnimation.add(tvFade, DEACCEL_2, SpringProperty.DEFAULT);
pendingAnimation.buildAnim().start();
return true;
}
@@ -4110,11 +4115,11 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
mSplitInstructionsView = null;
}
if (mFirstFloatingTaskView != null) {
mActivity.getRootView().removeView(mFirstFloatingTaskView);
mActivity.getDragLayer().removeView(mFirstFloatingTaskView);
mFirstFloatingTaskView = null;
}
if (mSecondFloatingTaskView != null) {
mActivity.getRootView().removeView(mSecondFloatingTaskView);
mActivity.getDragLayer().removeView(mSecondFloatingTaskView);
mSecondFloatingTaskView = null;
mSecondSplitHiddenView.setVisibility(VISIBLE);
mSecondSplitHiddenView = null;
@@ -1537,7 +1537,6 @@ public class TaskView extends FrameLayout implements Reusable {
}
public void initiateSplitSelect(SplitPositionOption splitPositionOption) {
AbstractFloatingView.closeOpenViews(mActivity, false, TYPE_TASK_MENU);
getRecentsView().initiateSplitSelect(this, splitPositionOption.stagePosition);
}
@@ -26,6 +26,7 @@ import androidx.test.runner.AndroidJUnit4;
import com.android.launcher3.tapl.Taskbar;
import com.android.launcher3.ui.TaplTestsLauncher3;
import com.android.launcher3.util.rule.ScreenRecordRule.ScreenRecord;
import org.junit.After;
import org.junit.Assume;
@@ -85,6 +86,7 @@ public class TaplTestsTaskbar extends AbstractQuickStepTest {
}
@Test
@ScreenRecord // b/231615831
@PortraitLandscape
public void testLaunchAppInSplitscreen() throws Exception {
getTaskbar().getAppIcon(TEST_APP_NAME).dragToSplitscreen(
@@ -92,6 +94,7 @@ public class TaplTestsTaskbar extends AbstractQuickStepTest {
}
@Test
@ScreenRecord // b/231615831
@PortraitLandscape
public void testLaunchShortcutInSplitscreen() throws Exception {
getTaskbar().getAppIcon(TEST_APP_NAME)
@@ -120,6 +123,7 @@ public class TaplTestsTaskbar extends AbstractQuickStepTest {
}
@Test
@ScreenRecord // b/231615831
@PortraitLandscape
public void testLaunchAppInSplitscreen_FromTaskbarAllApps() throws Exception {
getTaskbar().openAllApps()
@@ -128,6 +132,7 @@ public class TaplTestsTaskbar extends AbstractQuickStepTest {
}
@Test
@ScreenRecord // b/231615831
@PortraitLandscape
public void testLaunchShortcutInSplitscreen_FromTaskbarAllApps() throws Exception {
getTaskbar().openAllApps()
+1
View File
@@ -31,6 +31,7 @@
<dimen name="drop_target_button_drawable_horizontal_padding">24dp</dimen>
<dimen name="drop_target_button_drawable_vertical_padding">20dp</dimen>
<dimen name="drop_target_button_gap">32dp</dimen>
<dimen name="drop_target_button_workspace_edge_gap">32dp</dimen>
<dimen name="drop_target_top_margin">110dp</dimen>
<dimen name="drop_target_bottom_margin">48dp</dimen>
+1
View File
@@ -241,6 +241,7 @@
<dimen name="drop_target_button_drawable_horizontal_padding">16dp</dimen>
<dimen name="drop_target_button_drawable_vertical_padding">8dp</dimen>
<dimen name="drop_target_button_gap">28dp</dimen>
<dimen name="drop_target_button_workspace_edge_gap">0dp</dimen>
<!-- the distance an icon must be dragged before button drop targets accept it -->
<dimen name="drag_distanceThreshold">30dp</dimen>
@@ -93,6 +93,7 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch
public static final int TYPE_WIDGETS_EDUCATION_DIALOG = 1 << 15;
public static final int TYPE_TASKBAR_EDUCATION_DIALOG = 1 << 16;
public static final int TYPE_TASKBAR_ALL_APPS = 1 << 17;
public static final int TYPE_ADD_TO_HOME_CONFIRMATION = 1 << 18;
public static final int TYPE_ALL = TYPE_FOLDER | TYPE_ACTION_POPUP
| TYPE_WIDGETS_BOTTOM_SHEET | TYPE_WIDGET_RESIZE_FRAME | TYPE_WIDGETS_FULL_SHEET
@@ -100,7 +101,7 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch
| TYPE_OPTIONS_POPUP | TYPE_SNACKBAR | TYPE_LISTENER | TYPE_ALL_APPS_EDU
| TYPE_ICON_SURFACE | TYPE_DRAG_DROP_POPUP | TYPE_PIN_WIDGET_FROM_EXTERNAL_POPUP
| TYPE_WIDGETS_EDUCATION_DIALOG | TYPE_TASKBAR_EDUCATION_DIALOG | TYPE_TASKBAR_ALL_APPS
| TYPE_OPTIONS_POPUP_DIALOG;
| TYPE_OPTIONS_POPUP_DIALOG | TYPE_ADD_TO_HOME_CONFIRMATION;
// Type of popups which should be kept open during launcher rebind
public static final int TYPE_REBIND_SAFE = TYPE_WIDGETS_FULL_SHEET
@@ -179,7 +179,12 @@ public abstract class ButtonDropTarget extends TextView
@Override
public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) {
mActive = !options.isKeyboardDrag && supportsDrop(dragObject.dragInfo);
if (options.isKeyboardDrag) {
mActive = false;
} else {
setupItemInfo(dragObject.dragInfo);
mActive = supportsDrop(dragObject.dragInfo);
}
setVisibility(mActive ? View.VISIBLE : View.GONE);
mAccessibleDrag = options.isAccessibleDrag;
@@ -191,6 +196,11 @@ public abstract class ButtonDropTarget extends TextView
return supportsDrop(dragObject.dragInfo);
}
/**
* Setups button for the specified ItemInfo.
*/
protected abstract void setupItemInfo(ItemInfo info);
protected abstract boolean supportsDrop(ItemInfo info);
public abstract boolean supportsAccessibilityDrop(ItemInfo info, View view);
@@ -84,6 +84,9 @@ public class DeleteDropTarget extends ButtonDropTarget {
return LauncherAccessibilityDelegate.REMOVE;
}
@Override
protected void setupItemInfo(ItemInfo info) {}
@Override
protected boolean supportsDrop(ItemInfo info) {
return true;
+4 -1
View File
@@ -217,6 +217,7 @@ public class DeviceProfile {
public int dropTargetHorizontalPaddingPx;
public int dropTargetVerticalPaddingPx;
public int dropTargetGapPx;
public int dropTargetButtonWorkspaceEdgeGapPx;
// Insets
private final Rect mInsets = new Rect();
@@ -348,6 +349,8 @@ public class DeviceProfile {
dropTargetVerticalPaddingPx = res.getDimensionPixelSize(
R.dimen.drop_target_button_drawable_vertical_padding);
dropTargetGapPx = res.getDimensionPixelSize(R.dimen.drop_target_button_gap);
dropTargetButtonWorkspaceEdgeGapPx = res.getDimensionPixelSize(
R.dimen.drop_target_button_workspace_edge_gap);
workspaceSpringLoadedBottomSpace =
res.getDimensionPixelSize(R.dimen.dynamic_grid_min_spring_loaded_space);
@@ -789,7 +792,7 @@ public class DeviceProfile {
/**
* Updates the iconSize for allApps* variants.
*/
public void updateAllAppsIconSize(float scale, Resources res) {
private void updateAllAppsIconSize(float scale, Resources res) {
allAppsBorderSpacePx = new Point(
pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].x, mMetrics, scale),
pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].y, mMetrics, scale));
+35 -11
View File
@@ -186,14 +186,13 @@ public class DropTargetBar extends FrameLayout
availableWidth = scaledPanelWidth - halfButtonGap / 2;
} else {
// Both buttons plus the button gap do not display past the edge of the scaled
// workspace.
availableWidth = (scaledPanelWidth - dp.dropTargetGapPx) / 2;
// workspace, less a pre-defined gap from the edge of the workspace.
availableWidth = scaledPanelWidth - dp.dropTargetGapPx
- 2 * dp.dropTargetButtonWorkspaceEdgeGapPx;
}
int widthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST);
firstButton.measure(widthSpec, heightSpec);
secondButton.measure(widthSpec, heightSpec);
if (!mIsVertical) {
// Remove icons and put the button's text on two lines if text is truncated.
if (firstButton.isTextTruncated(availableWidth)) {
@@ -202,6 +201,14 @@ public class DropTargetBar extends FrameLayout
firstButton.setPadding(horizontalPadding, verticalPadding / 2,
horizontalPadding, verticalPadding / 2);
}
}
if (!dp.isTwoPanels) {
availableWidth -= firstButton.getMeasuredWidth() + dp.dropTargetGapPx;
widthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST);
}
secondButton.measure(widthSpec, heightSpec);
if (!mIsVertical) {
if (secondButton.isTextTruncated(availableWidth)) {
secondButton.setIconVisible(false);
secondButton.setTextMultiLine(true);
@@ -243,13 +250,30 @@ public class DropTargetBar extends FrameLayout
int buttonGap = dp.dropTargetGapPx;
ButtonDropTarget leftButton = mTempTargets[0];
leftButton.layout(barCenter - leftButton.getMeasuredWidth() - (buttonGap / 2), 0,
barCenter - (buttonGap / 2), leftButton.getMeasuredHeight());
ButtonDropTarget rightButton = mTempTargets[1];
rightButton.layout(barCenter + (buttonGap / 2), 0,
barCenter + (buttonGap / 2) + rightButton.getMeasuredWidth(),
rightButton.getMeasuredHeight());
if (dp.isTwoPanels) {
leftButton.layout(barCenter - leftButton.getMeasuredWidth() - (buttonGap / 2), 0,
barCenter - (buttonGap / 2), leftButton.getMeasuredHeight());
rightButton.layout(barCenter + (buttonGap / 2), 0,
barCenter + (buttonGap / 2) + rightButton.getMeasuredWidth(),
rightButton.getMeasuredHeight());
} else {
int scaledPanelWidth = (int) (dp.getCellLayoutWidth() * scale);
int leftButtonWidth = leftButton.getMeasuredWidth();
int rightButtonWidth = rightButton.getMeasuredWidth();
int extraSpace = scaledPanelWidth - leftButtonWidth - rightButtonWidth - buttonGap;
int leftButtonStart = barCenter - (scaledPanelWidth / 2) + extraSpace / 2;
int leftButtonEnd = leftButtonStart + leftButtonWidth;
int rightButtonStart = leftButtonEnd + buttonGap;
int rightButtonEnd = rightButtonStart + rightButtonWidth;
leftButton.layout(leftButtonStart, 0, leftButtonEnd,
leftButton.getMeasuredHeight());
rightButton.layout(rightButtonStart, 0, rightButtonEnd,
rightButton.getMeasuredHeight());
}
}
}
@@ -318,7 +342,7 @@ public class DropTargetBar extends FrameLayout
}
public ButtonDropTarget[] getDropTargets() {
return mDropTargets;
return getVisibility() == View.VISIBLE ? mDropTargets : new ButtonDropTarget[0];
}
@Override
@@ -6,6 +6,7 @@ import static android.appwidget.AppWidgetProviderInfo.WIDGET_FEATURE_RECONFIGURA
import static com.android.launcher3.Launcher.REQUEST_RECONFIGURE_APPWIDGET;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP;
import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.DISMISS_PREDICTION;
import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.INVALID;
import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.RECONFIGURE;
import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.UNINSTALL;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_DISMISS_PREDICTION_UNDO;
@@ -69,6 +70,7 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList
private boolean mHadPendingAlarm;
protected int mCurrentAccessibilityAction = -1;
public SecondaryDropTarget(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
@@ -133,25 +135,34 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList
return mCurrentAccessibilityAction;
}
@Override
protected void setupItemInfo(ItemInfo info) {
int buttonType = getButtonType(info, getViewUnderDrag(info));
if (buttonType != INVALID) {
setupUi(buttonType);
}
}
@Override
protected boolean supportsDrop(ItemInfo info) {
return supportsAccessibilityDrop(info, getViewUnderDrag(info));
return getButtonType(info, getViewUnderDrag(info)) != INVALID;
}
@Override
public boolean supportsAccessibilityDrop(ItemInfo info, View view) {
return getButtonType(info, view) != INVALID;
}
private int getButtonType(ItemInfo info, View view) {
if (view instanceof AppWidgetHostView) {
if (getReconfigurableWidgetId(view) != INVALID_APPWIDGET_ID) {
setupUi(RECONFIGURE);
return true;
return RECONFIGURE;
}
return false;
return INVALID;
} else if (FeatureFlags.ENABLE_PREDICTION_DISMISS.get() && info.isPredictedItem()) {
setupUi(DISMISS_PREDICTION);
return true;
return DISMISS_PREDICTION;
}
setupUi(UNINSTALL);
Boolean uninstallDisabled = mUninstallDisabledCache.get(info.user);
if (uninstallDisabled == null) {
UserManager userManager =
@@ -165,16 +176,20 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList
mCacheExpireAlarm.setAlarm(CACHE_EXPIRE_TIMEOUT);
mCacheExpireAlarm.setOnAlarmListener(this);
if (uninstallDisabled) {
return false;
return INVALID;
}
if (info instanceof ItemInfoWithIcon) {
ItemInfoWithIcon iconInfo = (ItemInfoWithIcon) info;
if ((iconInfo.runtimeStatusFlags & FLAG_SYSTEM_MASK) != 0) {
return (iconInfo.runtimeStatusFlags & FLAG_SYSTEM_NO) != 0;
if ((iconInfo.runtimeStatusFlags & FLAG_SYSTEM_MASK) != 0
&& (iconInfo.runtimeStatusFlags & FLAG_SYSTEM_NO) == 0) {
return INVALID;
}
}
return getUninstallTarget(info) != null;
if (getUninstallTarget(info) == null) {
return INVALID;
}
return UNINSTALL;
}
/**
@@ -60,6 +60,7 @@ public class LauncherAccessibilityDelegate extends BaseAccessibilityDelegate<Lau
public static final int DISMISS_PREDICTION = R.id.action_dismiss_prediction;
public static final int PIN_PREDICTION = R.id.action_pin_prediction;
public static final int RECONFIGURE = R.id.action_reconfigure;
public static final int INVALID = -1;
protected static final int ADD_TO_WORKSPACE = R.id.action_add_to_workspace;
protected static final int MOVE = R.id.action_move;
protected static final int MOVE_TO_WORKSPACE = R.id.action_move_to_workspace;
@@ -246,7 +246,7 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
*/
public boolean shouldContainerScroll(MotionEvent ev) {
// Scroll if not within the container view (e.g. over large-screen scrim).
if (!mActivityContext.getDragLayer().isEventOverView(this, ev)) {
if (!mActivityContext.getDragLayer().isEventOverView(getVisibleContainerView(), ev)) {
return true;
}
if (mActivityContext.getDragLayer().isEventOverView(mBottomSheetHandleArea, ev)) {
@@ -66,20 +66,19 @@ public abstract class Launchable {
"want to launch an app from " + launchableType())) {
LauncherInstrumentation.log("Launchable.launch before click "
+ mObject.getVisibleCenter() + " in " + mLauncher.getVisibleBounds(mObject));
final String label = mObject.getText();
mLauncher.clickLauncherObject(mObject);
try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("clicked")) {
expectActivityStartEvents();
return assertAppLaunched(label, selector);
return assertAppLaunched(selector);
}
}
}
protected LaunchedAppState assertAppLaunched(String label, BySelector selector) {
protected LaunchedAppState assertAppLaunched(BySelector selector) {
mLauncher.assertTrue(
"App didn't start: " + label + " (" + selector + ")",
"App didn't start: (" + selector + ")",
mLauncher.getDevice().wait(Until.hasObject(selector),
LauncherInstrumentation.WAIT_TIME_MS));
return new LaunchedAppState(mLauncher);
@@ -97,12 +97,16 @@ public final class LaunchedAppState extends Background {
}
static void dragToSplitscreen(
LauncherInstrumentation launcher, Launchable launchable, String expectedNewPackageName,
LauncherInstrumentation launcher,
Launchable launchable,
String expectedNewPackageName,
String expectedExistingPackageName) {
try (LauncherInstrumentation.Closable c1 = launcher.addContextLayer(
"want to drag taskbar item to splitscreen")) {
final Point displaySize = launcher.getRealDisplaySize();
final Point endPoint = new Point(displaySize.x / 4, 3 * displaySize.y / 4);
// Drag to the center of the top-left quadrant of the screen, this point will work in
// both portrait and landscape.
final Point endPoint = new Point(displaySize.x / 4, displaySize.y / 4);
final long downTime = SystemClock.uptimeMillis();
// Use mObject before starting drag since the system drag and drop moves the original
// view.
@@ -142,9 +146,8 @@ public final class LaunchedAppState extends Background {
try (LauncherInstrumentation.Closable c4 = launcher.addContextLayer(
"dropped item")) {
launchable.assertAppLaunched(itemLabel, By.pkg(expectedNewPackageName));
launchable.assertAppLaunched(
itemLabel, By.pkg(expectedExistingPackageName));
launchable.assertAppLaunched(By.pkg(expectedNewPackageName));
launchable.assertAppLaunched(By.pkg(expectedExistingPackageName));
}
}
}