Merge "Explicitly set X and Y values when offsetting split tasks" into sc-v2-dev
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarUnfoldAnimationController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarUnfoldAnimationController.java
index 43f015c..978bd47 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarUnfoldAnimationController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarUnfoldAnimationController.java
@@ -77,6 +77,7 @@
@Override
public void onTransitionFinished() {
mMoveFromCenterAnimator.onTransitionFinished();
+ mMoveFromCenterAnimator.clearRegisteredViews();
}
@Override
diff --git a/res/xml/default_workspace_splitdisplay_5x5.xml b/res/xml/default_workspace_splitdisplay_5x5.xml
deleted file mode 100644
index 162367b..0000000
--- a/res/xml/default_workspace_splitdisplay_5x5.xml
+++ /dev/null
@@ -1,107 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2009 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.
--->
-
-<favorites xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3">
-
- <!-- Hotseat (We use the screen as the position of the item in the hotseat) -->
- <!-- Dialer, Messaging, [Maps/Music], Browser, Camera -->
- <resolve
- launcher:container="-101"
- launcher:screen="0"
- launcher:x="0"
- launcher:y="0" >
- <favorite launcher:uri="#Intent;action=android.intent.action.DIAL;end" />
- <favorite launcher:uri="tel:123" />
- <favorite launcher:uri="#Intent;action=android.intent.action.CALL_BUTTON;end" />
- </resolve>
-
- <resolve
- launcher:container="-101"
- launcher:screen="1"
- launcher:x="1"
- launcher:y="0" >
- <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_MESSAGING;end" />
- <favorite launcher:uri="sms:" />
- <favorite launcher:uri="smsto:" />
- <favorite launcher:uri="mms:" />
- <favorite launcher:uri="mmsto:" />
- </resolve>
-
- <resolve
- launcher:container="-101"
- launcher:screen="2"
- launcher:x="2"
- launcher:y="0" >
- <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_MAPS;end" />
- <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_MUSIC;end" />
- </resolve>
-
- <resolve
- launcher:container="-101"
- launcher:screen="3"
- launcher:x="3"
- launcher:y="0" >
- <favorite
- launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_BROWSER;end" />
- <favorite launcher:uri="http://www.example.com/" />
- </resolve>
-
- <resolve
- launcher:container="-101"
- launcher:screen="4"
- launcher:x="4"
- launcher:y="0" >
- <favorite launcher:uri="#Intent;action=android.media.action.STILL_IMAGE_CAMERA;end" />
- <favorite launcher:uri="#Intent;action=android.intent.action.CAMERA_BUTTON;end" />
- </resolve>
-
- <!-- Bottom row -->
- <resolve
- launcher:screen="0"
- launcher:x="0"
- launcher:y="-1" >
- <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_EMAIL;end" />
- <favorite launcher:uri="mailto:" />
-
- </resolve>
-
- <resolve
- launcher:screen="0"
- launcher:x="1"
- launcher:y="-1" >
- <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_GALLERY;end" />
- <favorite launcher:uri="#Intent;type=images/*;end" />
-
- </resolve>
-
- <resolve
- launcher:screen="0"
- launcher:x="4"
- launcher:y="-1" >
- <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_MARKET;end" />
- <favorite launcher:uri="market://details?id=com.android.launcher" />
- </resolve>
-
- <!-- Placeholder before we add page pairing in b/196376162 -->
- <resolve
- launcher:screen="1"
- launcher:x="0"
- launcher:y="-4" >
- <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_GALLERY;end" />
- <favorite launcher:uri="#Intent;type=images/*;end" />
- </resolve>
-
-</favorites>
diff --git a/res/xml/device_profiles.xml b/res/xml/device_profiles.xml
index d8ee6f2..256999c 100644
--- a/res/xml/device_profiles.xml
+++ b/res/xml/device_profiles.xml
@@ -105,8 +105,7 @@
launcher:numFolderColumns="4"
launcher:numHotseatIcons="5"
launcher:dbFile="launcher.db"
- launcher:defaultLayoutId="@xml/default_workspace_5x5"
- launcher:defaultSplitDisplayLayoutId="@xml/default_workspace_splitdisplay_5x5" >
+ launcher:defaultLayoutId="@xml/default_workspace_5x5" >
<display-option
launcher:name="Large Phone"
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 2049e21..108091c 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -773,7 +773,8 @@
childStart += primaryDimension + getChildGap();
// This makes sure that the space is added after the page, not after each panel
- if (i % panelCount == panelCount - 1) {
+ int lastPanel = mIsRtl ? 0 : panelCount - 1;
+ if (i % panelCount == lastPanel) {
childStart += mPageSpacing;
}
}
@@ -1575,7 +1576,7 @@
return getDisplacementFromScreenCenter(childIndex, screenCenter);
}
- private int getScreenCenter(int primaryScroll) {
+ protected int getScreenCenter(int primaryScroll) {
float primaryScale = mOrientationHandler.getPrimaryScale(this);
float primaryPivot = mOrientationHandler.getPrimaryValue(getPivotX(), getPivotY());
int pageOrientationSize = mOrientationHandler.getMeasuredSize(this);
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index a21c8e3..54b2c96 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -338,15 +338,17 @@
int paddingBottom = grid.cellLayoutBottomPaddingPx;
int panelCount = getPanelCount();
+ int rightPanelModulus = mIsRtl ? 0 : panelCount - 1;
+ int leftPanelModulus = mIsRtl ? panelCount - 1 : 0;
int numberOfScreens = mScreenOrder.size();
for (int i = 0; i < numberOfScreens; i++) {
int paddingLeft = paddingLeftRight;
int paddingRight = paddingLeftRight;
if (panelCount > 1) {
- if (i % panelCount == 0) { // left side panel
+ if (i % panelCount == leftPanelModulus) {
paddingLeft = paddingLeftRight;
paddingRight = 0;
- } else if (i % panelCount == panelCount - 1) { // right side panel
+ } else if (i % panelCount == rightPanelModulus) {
paddingLeft = 0;
paddingRight = paddingLeftRight;
} else { // middle panel
@@ -857,18 +859,13 @@
mWorkspaceScreens.remove(emptyScreenId);
mScreenOrder.removeValue(emptyScreenId);
- int newScreenId = LauncherSettings.Settings.call(getContext().getContentResolver(),
- LauncherSettings.Settings.METHOD_NEW_SCREEN_ID)
- .getInt(LauncherSettings.Settings.EXTRA_VALUE);
-
-
- // When two panel home is enabled and the last page (the page on the right) doesn't
- // have any items, then Launcher database doesn't know about this page because it was added
- // by Launcher::bindAddScreens but wasn't inserted into the database. LauncherSettings's
- // generate new screen ID method will return the ID for the left page,
- // so we need to increment it.
- if (isTwoPanelEnabled() && emptyScreenId == EXTRA_EMPTY_SCREEN_ID && newScreenId % 2 == 1) {
- newScreenId++;
+ int newScreenId = -1;
+ // Launcher database isn't aware of empty pages that are already bound, so we need to
+ // skip those IDs manually.
+ while (newScreenId == -1 || mWorkspaceScreens.containsKey(newScreenId)) {
+ newScreenId = LauncherSettings.Settings.call(getContext().getContentResolver(),
+ LauncherSettings.Settings.METHOD_NEW_SCREEN_ID)
+ .getInt(LauncherSettings.Settings.EXTRA_VALUE);
}
mWorkspaceScreens.put(newScreenId, cl);
@@ -2453,21 +2450,32 @@
}
int nextPage = getNextPage();
- if (layout == null && !isPageInTransition()) {
- layout = verifyInsidePage(nextPage + (mIsRtl ? 1 : -1), Math.min(centerX, d.x), d.y);
+ IntSet pageIndexesToVerify = IntSet.wrap(nextPage - 1, nextPage + 1);
+ if (isTwoPanelEnabled()) {
+ // If two panel is enabled, users can also drag items to nextPage + 2
+ pageIndexesToVerify.add(nextPage + 2);
}
- if (layout == null && !isPageInTransition()) {
- layout = verifyInsidePage(nextPage + (mIsRtl ? -1 : 1), Math.max(centerX, d.x), d.y);
+ int touchX = (int) Math.min(centerX, d.x);
+ int touchY = d.y;
+
+ // Go through the pages and check if the dragged item is inside one of them
+ for (int pageIndex : pageIndexesToVerify) {
+ if (layout != null || isPageInTransition()) {
+ break;
+ }
+ layout = verifyInsidePage(pageIndex, touchX, touchY);
}
- // If two panel is enabled, users can also drag items to currentPage + 2
- if (isTwoPanelEnabled() && layout == null && !isPageInTransition()) {
- layout = verifyInsidePage(nextPage + (mIsRtl ? -2 : 2), Math.max(centerX, d.x), d.y);
- }
-
- // Always pick the current page.
+ // If the dragged item isn't located in one of the pages above, the icon will stay on the
+ // current screen. For two panel pick the closest panel on the current screen,
+ // on one panel just choose the current page.
if (layout == null && nextPage >= 0 && nextPage < getPageCount()) {
+ if (isTwoPanelEnabled()) {
+ nextPage = getScreenCenter(getScrollX()) > touchX
+ ? (mIsRtl ? nextPage + 1 : nextPage) // left side
+ : (mIsRtl ? nextPage : nextPage + 1); // right side
+ }
layout = (CellLayout) getChildAt(nextPage);
}
if (layout != mDragTargetLayout) {