summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanesh M <daneshm90@gmail.com>2014-06-06 19:48:54 -0700
committerDanesh M <daneshm90@gmail.com>2014-06-06 22:54:26 -0700
commit8480544bc9dee83fd0ce3a5f0b78bf5fdae3d9af (patch)
treeb45193cd98d6f17a5d3553a3a1f5183d41255279
parent0c33cc73fe358a82873a5321319e503b5f8fbeaf (diff)
downloadandroid_packages_apps_Trebuchet-8480544bc9dee83fd0ce3a5f0b78bf5fdae3d9af.tar.gz
android_packages_apps_Trebuchet-8480544bc9dee83fd0ce3a5f0b78bf5fdae3d9af.tar.bz2
android_packages_apps_Trebuchet-8480544bc9dee83fd0ce3a5f0b78bf5fdae3d9af.zip
Revert "Workspace: Extra empty screen both left and right"
This reverts commit d4c825cc639bceae57de6dec2c82d6a7633977f7. Change-Id: I53e036ee56bf7bcd817a01ebc18520021e2b4202
-rw-r--r--src/com/android/launcher3/Launcher.java6
-rw-r--r--src/com/android/launcher3/Workspace.java163
2 files changed, 74 insertions, 95 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 9fd831514..0dad0f4f8 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -2240,6 +2240,10 @@ public class Launcher extends Activity
return mWorkspaceLoading || mWaitingForResult;
}
+ public boolean isWorkspaceLoading() {
+ return mWorkspaceLoading;
+ }
+
private void resetAddInfo() {
mPendingAddInfo.container = ItemInfo.NO_ID;
mPendingAddInfo.screenId = -1;
@@ -4004,7 +4008,7 @@ public class Launcher extends Activity
}
// Remove the extra empty screen
- mWorkspace.removeExtraEmptyScreens();
+ mWorkspace.removeExtraEmptyScreen(false, null);
if (!LauncherAppState.isDisableAllApps() &&
addedApps != null && mAppsCustomizeContent != null) {
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 0d0e5af0e..91f93dd14 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -126,9 +126,8 @@ public class Workspace extends SmoothPagedView
private ShortcutAndWidgetContainer mDragSourceInternal;
private static boolean sAccessibilityEnabled;
- // The screen ids used for the empty screens always present to the left/right.
- private final static long EXTRA_EMPTY_SCREEN_LEFT_ID = -201;
- private final static long EXTRA_EMPTY_SCREEN_RIGHT_ID = -202;
+ // The screen id used for the empty screen always present to the right.
+ private final static long EXTRA_EMPTY_SCREEN_ID = -201;
private final static long CUSTOM_CONTENT_SCREEN_ID = -301;
private HashMap<Long, CellLayout> mWorkspaceScreens = new HashMap<Long, CellLayout>();
@@ -416,7 +415,7 @@ public class Workspace extends SmoothPagedView
@Override
public void run() {
if (mIsDragOccuring) {
- addExtraEmptyScreensOnDrag();
+ addExtraEmptyScreenOnDrag();
}
}
});
@@ -431,12 +430,6 @@ public class Workspace extends SmoothPagedView
InstallShortcutReceiver.disableAndFlushInstallQueue(getContext());
UninstallShortcutReceiver.disableAndFlushUninstallQueue(getContext());
- // Disable all layout transitions before removing left extra pages to ensure that we don't get
- // the transition animations competing with us changing the scroll when we remove it
- disableLayoutTransitions();
- removeExtraEmptyScreens();
- enableLayoutTransitions();
-
mDragSourceInternal = null;
mLauncher.onInteractionEnd();
}
@@ -569,7 +562,7 @@ public class Workspace extends SmoothPagedView
public long insertNewWorkspaceScreenBeforeEmptyScreen(long screenId) {
// Find the index to insert this view into. If the empty screen exists, then
// insert it before that.
- int insertIndex = mScreenOrder.indexOf(EXTRA_EMPTY_SCREEN_RIGHT_ID);
+ int insertIndex = mScreenOrder.indexOf(EXTRA_EMPTY_SCREEN_ID);
if (insertIndex < 0) {
insertIndex = mScreenOrder.size();
}
@@ -685,29 +678,32 @@ public class Workspace extends SmoothPagedView
mCustomContentCallbacks = callbacks;
}
- public void addExtraEmptyScreensOnDrag() {
+ public void addExtraEmptyScreenOnDrag() {
// Log to disk
Launcher.addDumpLog(TAG, "11683562 - addExtraEmptyScreenOnDrag()", true);
- boolean addLeftScreen = true;
- boolean addRightScreen = true;
+
+ boolean lastChildOnScreen = false;
+ boolean childOnFinalScreen = false;
// Cancel any pending removal of empty screen
mRemoveEmptyScreenRunnable = null;
if (mDragSourceInternal != null) {
if (mDragSourceInternal.getChildCount() == 1) {
- CellLayout cl = (CellLayout) mDragSourceInternal.getParent();
- addLeftScreen = indexOfChild(cl) != 0;
- addRightScreen = indexOfChild(cl) != getChildCount() - 1;
+ lastChildOnScreen = true;
+ }
+ CellLayout cl = (CellLayout) mDragSourceInternal.getParent();
+ if (indexOfChild(cl) == getChildCount() - 1) {
+ childOnFinalScreen = true;
}
}
- if (addLeftScreen && !mWorkspaceScreens.containsKey(EXTRA_EMPTY_SCREEN_LEFT_ID)) {
- insertNewWorkspaceScreen(EXTRA_EMPTY_SCREEN_LEFT_ID, 0);
- setCurrentPage(getCurrentPage() + 1);
+ // If this is the last item on the final screen
+ if (lastChildOnScreen && childOnFinalScreen) {
+ return;
}
- if (addRightScreen && !mWorkspaceScreens.containsKey(EXTRA_EMPTY_SCREEN_RIGHT_ID)) {
- insertNewWorkspaceScreen(EXTRA_EMPTY_SCREEN_RIGHT_ID);
+ if (!mWorkspaceScreens.containsKey(EXTRA_EMPTY_SCREEN_ID)) {
+ insertNewWorkspaceScreen(EXTRA_EMPTY_SCREEN_ID);
}
}
@@ -715,28 +711,18 @@ public class Workspace extends SmoothPagedView
// Log to disk
Launcher.addDumpLog(TAG, "11683562 - addExtraEmptyScreen()", true);
- if (!mWorkspaceScreens.containsKey(EXTRA_EMPTY_SCREEN_RIGHT_ID)) {
- insertNewWorkspaceScreen(EXTRA_EMPTY_SCREEN_RIGHT_ID);
+ if (!mWorkspaceScreens.containsKey(EXTRA_EMPTY_SCREEN_ID)) {
+ insertNewWorkspaceScreen(EXTRA_EMPTY_SCREEN_ID);
return true;
}
return false;
}
- public void removeExtraEmptyScreenLeft() {
- if (hasExtraEmptyScreenLeft()) {
- CellLayout cl = mWorkspaceScreens.get(EXTRA_EMPTY_SCREEN_LEFT_ID);
- mWorkspaceScreens.remove(EXTRA_EMPTY_SCREEN_LEFT_ID);
- mScreenOrder.remove(EXTRA_EMPTY_SCREEN_LEFT_ID);
- setCurrentPage(mCurrentPage - 1);
- removeView(cl);
- }
- }
-
private void convertFinalScreenToEmptyScreenIfNecessary() {
// Log to disk
Launcher.addDumpLog(TAG, "11683562 - convertFinalScreenToEmptyScreenIfNecessary()", true);
- if (hasExtraEmptyScreens() || mScreenOrder.size() == 0) return;
+ if (hasExtraEmptyScreen() || mScreenOrder.size() == 0) return;
long finalScreenId = mScreenOrder.get(mScreenOrder.size() - 1);
if (finalScreenId == CUSTOM_CONTENT_SCREEN_ID) return;
@@ -749,8 +735,8 @@ public class Workspace extends SmoothPagedView
mScreenOrder.remove(finalScreenId);
// if this is the last non-custom content screen, convert it to the empty screen
- mWorkspaceScreens.put(EXTRA_EMPTY_SCREEN_LEFT_ID, finalScreen);
- mScreenOrder.add(EXTRA_EMPTY_SCREEN_LEFT_ID);
+ mWorkspaceScreens.put(EXTRA_EMPTY_SCREEN_ID, finalScreen);
+ mScreenOrder.add(EXTRA_EMPTY_SCREEN_ID);
// Update the model if we have changed any screens
mLauncher.getModel().updateWorkspaceScreenOrder(mLauncher, mScreenOrder);
@@ -778,8 +764,8 @@ public class Workspace extends SmoothPagedView
}
convertFinalScreenToEmptyScreenIfNecessary();
- if (hasExtraEmptyScreens()) {
- int emptyIndex = mScreenOrder.indexOf(EXTRA_EMPTY_SCREEN_LEFT_ID);
+ if (hasExtraEmptyScreen()) {
+ int emptyIndex = mScreenOrder.indexOf(EXTRA_EMPTY_SCREEN_ID);
if (getNextPage() == emptyIndex) {
snapToPage(getNextPage() - 1, SNAP_OFF_EMPTY_SCREEN_DURATION);
fadeAndRemoveEmptyScreen(SNAP_OFF_EMPTY_SCREEN_DURATION, FADE_EMPTY_SCREEN_DURATION,
@@ -808,14 +794,14 @@ public class Workspace extends SmoothPagedView
PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0f);
PropertyValuesHolder bgAlpha = PropertyValuesHolder.ofFloat("backgroundAlpha", 0f);
- final CellLayout cl = mWorkspaceScreens.get(EXTRA_EMPTY_SCREEN_LEFT_ID);
+ final CellLayout cl = mWorkspaceScreens.get(EXTRA_EMPTY_SCREEN_ID);
mRemoveEmptyScreenRunnable = new Runnable() {
@Override
public void run() {
- if (hasExtraEmptyScreens()) {
- mWorkspaceScreens.remove(EXTRA_EMPTY_SCREEN_LEFT_ID);
- mScreenOrder.remove(EXTRA_EMPTY_SCREEN_LEFT_ID);
+ if (hasExtraEmptyScreen()) {
+ mWorkspaceScreens.remove(EXTRA_EMPTY_SCREEN_ID);
+ mScreenOrder.remove(EXTRA_EMPTY_SCREEN_ID);
removeView(cl);
if (stripEmptyScreens) {
stripEmptyScreens();
@@ -841,53 +827,23 @@ public class Workspace extends SmoothPagedView
oa.start();
}
- public void removeExtraEmptyScreenRight() {
- if (hasExtraEmptyScreenRight()) {
- CellLayout cl = mWorkspaceScreens.get(EXTRA_EMPTY_SCREEN_RIGHT_ID);
- mWorkspaceScreens.remove(EXTRA_EMPTY_SCREEN_RIGHT_ID);
- mScreenOrder.remove(EXTRA_EMPTY_SCREEN_RIGHT_ID);
- removeView(cl);
- }
+ public boolean hasExtraEmptyScreen() {
+ int nScreens = getChildCount();
+ nScreens = nScreens - numCustomPages();
+ return mWorkspaceScreens.containsKey(EXTRA_EMPTY_SCREEN_ID) && nScreens > 1;
}
- public void removeExtraEmptyScreens() {
- removeExtraEmptyScreenLeft();
- removeExtraEmptyScreenRight();
- }
-
- public boolean hasExtraEmptyScreenLeft() {
- return mWorkspaceScreens.containsKey(EXTRA_EMPTY_SCREEN_LEFT_ID) && getChildCount() - numCustomPages() > 1;
- }
-
- public boolean hasExtraEmptyScreenRight() {
- return mWorkspaceScreens.containsKey(EXTRA_EMPTY_SCREEN_RIGHT_ID) && getChildCount() - numCustomPages() > 1;
- }
-
- public boolean hasExtraEmptyScreens() {
- return hasExtraEmptyScreenLeft() || hasExtraEmptyScreenRight();
- }
-
- public int numExtraEmptyScreens() {
- return (hasExtraEmptyScreenLeft() ? 1 : 0) + (hasExtraEmptyScreenRight() ? 1 : 0);
- }
-
- public long commitExtraEmptyScreen(long screenId) {
+ public long commitExtraEmptyScreen() {
// Log to disk
Launcher.addDumpLog(TAG, "11683562 - commitExtraEmptyScreen()", true);
-
- int index = getPageIndexForScreenId(screenId);
- CellLayout cl = mWorkspaceScreens.get(screenId);
- mWorkspaceScreens.remove(screenId);
- mScreenOrder.remove(screenId);
+ int index = getPageIndexForScreenId(EXTRA_EMPTY_SCREEN_ID);
+ CellLayout cl = mWorkspaceScreens.get(EXTRA_EMPTY_SCREEN_ID);
+ mWorkspaceScreens.remove(EXTRA_EMPTY_SCREEN_ID);
+ mScreenOrder.remove(EXTRA_EMPTY_SCREEN_ID);
long newId = LauncherAppState.getLauncherProvider().generateNewScreenId();
mWorkspaceScreens.put(newId, cl);
-
- if (screenId == EXTRA_EMPTY_SCREEN_LEFT_ID) {
- mScreenOrder.add(numCustomPages(), newId);
- } else {
- mScreenOrder.add(newId);
- }
+ mScreenOrder.add(newId);
// Update the page indicator marker
if (getPageIndicator() != null) {
@@ -935,6 +891,11 @@ public class Workspace extends SmoothPagedView
// Log to disk
Launcher.addDumpLog(TAG, "11683562 - stripEmptyScreens()", true);
+ if (mLauncher.isWorkspaceLoading()) {
+ // Don't strip empty screens if the workspace is still loading
+ Launcher.addDumpLog(TAG, " - workspace loading, skip", true);
+ return;
+ }
if (isPageMoving()) {
mStripScreensOnPageStopMoving = true;
return;
@@ -967,9 +928,9 @@ public class Workspace extends SmoothPagedView
removeView(cl);
} else {
// if this is the last non-custom content screen, convert it to the empty screen
- mWorkspaceScreens.put(EXTRA_EMPTY_SCREEN_RIGHT_ID, cl);
- mScreenOrder.add(EXTRA_EMPTY_SCREEN_RIGHT_ID);
mRemoveEmptyScreenRunnable = null;
+ mWorkspaceScreens.put(EXTRA_EMPTY_SCREEN_ID, cl);
+ mScreenOrder.add(EXTRA_EMPTY_SCREEN_ID);
}
}
@@ -1029,7 +990,7 @@ public class Workspace extends SmoothPagedView
return;
}
}
- if (screenId == EXTRA_EMPTY_SCREEN_LEFT_ID || screenId == EXTRA_EMPTY_SCREEN_RIGHT_ID) {
+ if (screenId == EXTRA_EMPTY_SCREEN_ID) {
// This should never happen
throw new RuntimeException("Screen id should not be EXTRA_EMPTY_SCREEN_ID");
}
@@ -1274,6 +1235,10 @@ public class Workspace extends SmoothPagedView
mDelayedResizeRunnable = null;
}
+ if (mDelayedSnapToPageRunnable != null) {
+ mDelayedSnapToPageRunnable.run();
+ mDelayedSnapToPageRunnable = null;
+ }
if (mStripScreensOnPageStopMoving) {
stripEmptyScreens();
mStripScreensOnPageStopMoving = false;
@@ -1405,9 +1370,10 @@ public class Workspace extends SmoothPagedView
}
// Exclude the leftmost page
- int firstIndex = numCustomPages() + (hasExtraEmptyScreenLeft() ? 1 : 0);
- // Exclude the last extra empty screen
- int lastIndex = getChildCount() - 1 - (hasExtraEmptyScreenRight() ? 1 : 0);
+ int emptyExtraPages = numEmptyScreensToIgnore();
+ int firstIndex = numCustomPages();
+ // Exclude the last extra empty screen (if we have > MIN_PARALLAX_PAGE_SPAN pages)
+ int lastIndex = getChildCount() - 1 - emptyExtraPages;
if (isLayoutRtl()) {
int temp = firstIndex;
firstIndex = lastIndex;
@@ -1437,8 +1403,17 @@ public class Workspace extends SmoothPagedView
}
}
+ private int numEmptyScreensToIgnore() {
+ int numScrollingPages = getChildCount() - numCustomPages();
+ if (numScrollingPages >= MIN_PARALLAX_PAGE_SPAN && hasExtraEmptyScreen()) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+
private int getNumScreensExcludingEmptyAndCustom() {
- int numScrollingPages = getChildCount() - numExtraEmptyScreens() - numCustomPages();
+ int numScrollingPages = getChildCount() - numEmptyScreensToIgnore() - numCustomPages();
return numScrollingPages;
}
@@ -2879,8 +2854,8 @@ public class Workspace extends SmoothPagedView
}
long screenId = getIdForScreen(dropTargetLayout);
- if (screenId == EXTRA_EMPTY_SCREEN_LEFT_ID || screenId == EXTRA_EMPTY_SCREEN_RIGHT_ID) {
- commitExtraEmptyScreen(screenId);
+ if (screenId == EXTRA_EMPTY_SCREEN_ID) {
+ commitExtraEmptyScreen();
}
return true;
@@ -4149,7 +4124,7 @@ public class Workspace extends SmoothPagedView
}
public int getCurrentPageOffsetFromCustomContent() {
- return getNextPage() - numCustomPages() - (hasExtraEmptyScreenLeft() ? 1 : 0);
+ return getNextPage() - numCustomPages();
}
/**
@@ -4830,7 +4805,7 @@ public class Workspace extends SmoothPagedView
@Override
protected PageIndicator.PageMarkerResources getPageIndicatorMarker(int pageIndex) {
long screenId = getScreenIdForPageIndex(pageIndex);
- if (screenId == EXTRA_EMPTY_SCREEN_LEFT_ID || screenId == EXTRA_EMPTY_SCREEN_RIGHT_ID) {
+ if (screenId == EXTRA_EMPTY_SCREEN_ID) {
int count = mScreenOrder.size() - numCustomPages();
if (count > 1) {
return new PageIndicator.PageMarkerResources(R.drawable.ic_pageindicator_current,