diff options
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/launcher3/CellLayout.java | 26 | ||||
-rw-r--r-- | src/com/android/launcher3/DynamicGrid.java | 13 | ||||
-rw-r--r-- | src/com/android/launcher3/Hotseat.java | 8 | ||||
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 35 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherModel.java | 5 | ||||
-rw-r--r-- | src/com/android/launcher3/PagedView.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/WallpaperCropActivity.java | 16 | ||||
-rw-r--r-- | src/com/android/launcher3/WallpaperPickerActivity.java | 40 | ||||
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 191 |
9 files changed, 228 insertions, 108 deletions
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index 682c2ed2e..04f4d8154 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -64,6 +64,8 @@ public class CellLayout extends ViewGroup { private Launcher mLauncher; private int mCellWidth; private int mCellHeight; + private int mFixedCellWidth; + private int mFixedCellHeight; private int mCountX; private int mCountY; @@ -193,8 +195,8 @@ public class CellLayout extends ViewGroup { DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CellLayout, defStyle, 0); - mCellWidth = -1; - mCellHeight = -1; + mCellWidth = mCellHeight = -1; + mFixedCellHeight = mFixedCellHeight = -1; mWidthGap = mOriginalWidthGap = 0; mHeightGap = mOriginalHeightGap = 0; mMaxGap = Integer.MAX_VALUE; @@ -310,8 +312,8 @@ public class CellLayout extends ViewGroup { } public void setCellDimensions(int width, int height) { - mCellWidth = width; - mCellHeight = height; + mFixedCellWidth = mCellWidth = width; + mFixedCellHeight = mCellHeight = height; mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap, mCountX, mCountY); } @@ -947,13 +949,15 @@ public class CellLayout extends ViewGroup { int heightSpecMode = MeasureSpec.getMode(heightMeasureSpec); int widthSize = MeasureSpec.getSize(widthMeasureSpec); int heightSize = MeasureSpec.getSize(heightMeasureSpec); - int cw = grid.calculateCellWidth(widthSize, mCountX); - int ch = grid.calculateCellHeight(heightSize, mCountY); - if (cw != mCellWidth || ch != mCellHeight) { - mCellWidth = cw; - mCellHeight = ch; - mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, - mHeightGap, mCountX, mCountY); + if (mFixedCellWidth < 0 || mFixedCellHeight < 0) { + int cw = grid.calculateCellWidth(widthSize, mCountX); + int ch = grid.calculateCellHeight(heightSize, mCountY); + if (cw != mCellWidth || ch != mCellHeight) { + mCellWidth = cw; + mCellHeight = ch; + mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, + mHeightGap, mCountX, mCountY); + } } int newWidth = widthSize; diff --git a/src/com/android/launcher3/DynamicGrid.java b/src/com/android/launcher3/DynamicGrid.java index f43af615f..70f000053 100644 --- a/src/com/android/launcher3/DynamicGrid.java +++ b/src/com/android/launcher3/DynamicGrid.java @@ -223,17 +223,16 @@ class DeviceProfile { availableWidthPx = awPx; availableHeightPx = ahPx; - if (isLandscape) { - allAppsNumRows = (int) numRows - 1; - } else { - allAppsNumRows = (int) numRows + 1; - } Rect padding = getWorkspacePadding(isLandscape ? CellLayout.LANDSCAPE : CellLayout.PORTRAIT); int pageIndicatorOffset = resources.getDimensionPixelSize(R.dimen.apps_customize_page_indicator_offset); - allAppsNumRows = (availableHeightPx - pageIndicatorOffset - 4 * edgeMarginPx) / - (iconSizePx + iconTextSizePx + 2 * edgeMarginPx); + if (isLandscape) { + allAppsNumRows = (availableHeightPx - pageIndicatorOffset - 4 * edgeMarginPx) / + (iconSizePx + iconTextSizePx + 2 * edgeMarginPx); + } else { + allAppsNumRows = (int) numRows + 1; + } allAppsNumCols = (availableWidthPx - padding.left - padding.right - 2 * edgeMarginPx) / (iconSizePx + 2 * edgeMarginPx); } diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java index ec787614d..fbbb09f51 100644 --- a/src/com/android/launcher3/Hotseat.java +++ b/src/com/android/launcher3/Hotseat.java @@ -69,6 +69,14 @@ public class Hotseat extends FrameLayout { CellLayout getLayout() { return mContent; } + + /** + * Registers the specified listener on the cell layout of the hotseat. + */ + @Override + public void setOnLongClickListener(OnLongClickListener l) { + mContent.setOnLongClickListener(l); + } private boolean hasVerticalHotseat() { return (mIsLandscape && mTransposeLayoutWithOrientation); diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 29c4e3eaf..0a92f3563 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -660,9 +660,6 @@ public class Launcher extends Activity completeAddAppWidget(appWidgetId, args.container, args.screenId, null, null); result = true; break; - case REQUEST_PICK_WALLPAPER: - // We just wanted the activity result here so we can clear mWaitingForResult - break; } // Before adding this resetAddInfo(), after a shortcut was added to a workspace screen, // if you turned the screen off and then back while in All Apps, Launcher would not @@ -686,7 +683,13 @@ public class Launcher extends Activity addAppWidgetImpl(appWidgetId, mPendingAddInfo, null, mPendingAddWidgetInfo); } return; + } else if (requestCode == REQUEST_PICK_WALLPAPER) { + if (resultCode == RESULT_OK && mWorkspace.isInOverviewMode()) { + mWorkspace.exitOverviewMode(false); + } + return; } + boolean delayExitSpringLoadedMode = false; boolean isWidgetDrop = (requestCode == REQUEST_PICK_APPWIDGET || requestCode == REQUEST_CREATE_APPWIDGET); @@ -1114,6 +1117,7 @@ public class Launcher extends Activity mHotseat = (Hotseat) findViewById(R.id.hotseat); if (mHotseat != null) { mHotseat.setup(this); + mHotseat.setOnLongClickListener(this); } mOverviewPanel = findViewById(R.id.overview_panel); @@ -1630,10 +1634,7 @@ public class Launcher extends Activity // If we are already on home, then just animate back to the workspace, // otherwise, just wait until onResume to set the state back to Workspace if (alreadyOnHome) { - showWorkspace(true); - if (mWorkspace.isInOverviewMode()) { - mWorkspace.exitOverviewMode(); - } + showWorkspaceAndExitOverviewMode(); } else { mOnResumeState = State.WORKSPACE; } @@ -1667,6 +1668,13 @@ public class Launcher extends Activity } } + protected void showWorkspaceAndExitOverviewMode() { + showWorkspace(true); + if (mWorkspace.isInOverviewMode()) { + mWorkspace.exitOverviewMode(true); + } + } + @Override public void onRestoreInstanceState(Bundle state) { super.onRestoreInstanceState(state); @@ -1940,6 +1948,9 @@ public class Launcher extends Activity } } + protected void moveToCustomContentScreen(boolean animate) { + mWorkspace.moveToCustomContentScreen(animate); + } /** * Process a shortcut drop. * @@ -2120,7 +2131,7 @@ public class Launcher extends Activity if (isAllAppsVisible()) { showWorkspace(true); } else if (mWorkspace.isInOverviewMode()) { - mWorkspace.exitOverviewMode(); + mWorkspace.exitOverviewMode(true); } else if (mWorkspace.getOpenFolder() != null) { Folder openFolder = mWorkspace.getOpenFolder(); if (openFolder.isEditingName()) { @@ -2170,7 +2181,7 @@ public class Launcher extends Activity if (v instanceof CellLayout) { if (mWorkspace.isInOverviewMode()) { - mWorkspace.exitOverviewMode(mWorkspace.indexOfChild(v)); + mWorkspace.exitOverviewMode(mWorkspace.indexOfChild(v), true); } } @@ -3560,8 +3571,10 @@ public class Launcher extends Activity public void bindScreens(ArrayList<Long> orderedScreenIds) { bindAddScreens(orderedScreenIds); - // Create the new empty page - mWorkspace.addExtraEmptyScreen(); + // If there are no screens, we need to have an empty screen + if (orderedScreenIds.size() == 0) { + mWorkspace.addExtraEmptyScreen(); + } // Create the custom content page (this call updates mDefaultScreen which calls // setCurrentPage() so ensure that all pages are added before calling this) diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java index 18e1c85ba..179c8aa76 100644 --- a/src/com/android/launcher3/LauncherModel.java +++ b/src/com/android/launcher3/LauncherModel.java @@ -2428,9 +2428,6 @@ public class LauncherModel extends BroadcastReceiver { private void loadAllApps() { final long loadTime = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0; - // "two variables"? - // Don't use these two variables in any of the callback runnables. - // Otherwise we hold a reference to them. final Callbacks oldCallbacks = mCallbacks.get(); if (oldCallbacks == null) { // This launcher has exited and nobody bothered to tell us. Just bail. @@ -2477,7 +2474,6 @@ public class LauncherModel extends BroadcastReceiver { } // Huh? Shouldn't this be inside the Runnable below? - final Callbacks callbacks = tryGetCallbacks(oldCallbacks); final ArrayList<AppInfo> added = mBgAllAppsList.added; mBgAllAppsList.added = new ArrayList<AppInfo>(); @@ -2485,6 +2481,7 @@ public class LauncherModel extends BroadcastReceiver { mHandler.post(new Runnable() { public void run() { final long bindTime = SystemClock.uptimeMillis(); + final Callbacks callbacks = tryGetCallbacks(oldCallbacks); if (callbacks != null) { callbacks.bindAllApplications(added); if (DEBUG_LOADERS) { diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index bdb0d5819..dcb71d274 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -2718,4 +2718,4 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc public boolean onHoverEvent(android.view.MotionEvent event) { return true; } -}
\ No newline at end of file +} diff --git a/src/com/android/launcher3/WallpaperCropActivity.java b/src/com/android/launcher3/WallpaperCropActivity.java index dee9fe9ad..f5a6b80b3 100644 --- a/src/com/android/launcher3/WallpaperCropActivity.java +++ b/src/com/android/launcher3/WallpaperCropActivity.java @@ -22,6 +22,7 @@ import android.app.WallpaperManager; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; @@ -100,6 +101,10 @@ public class WallpaperCropActivity extends Activity { }); } + public static String getSharedPreferencesKey() { + return WallpaperCropActivity.class.getName(); + } + // As a ratio of screen height, the total distance we want the parallax effect to span // horizontally private static float wallpaperTravelToScreenWidthRatio(int width, int height) { @@ -145,7 +150,7 @@ public class WallpaperCropActivity extends Activity { // for the intended // parallax effects final int defaultWidth, defaultHeight; - if (LauncherAppState.isScreenLarge(res)) { + if (isScreenLarge(res)) { defaultWidth = (int) (maxDim * wallpaperTravelToScreenWidthRatio(maxDim, minDim)); defaultHeight = maxDim; } else { @@ -200,6 +205,11 @@ public class WallpaperCropActivity extends Activity { cropTask.execute(); } + private static boolean isScreenLarge(Resources res) { + Configuration config = res.getConfiguration(); + return config.smallestScreenWidthDp >= 720; + } + protected void cropImageAndSetWallpaper(Uri uri, OnBitmapCroppedHandler onBitmapCroppedHandler, final boolean finishActivityWhenDone) { // Get the crop @@ -216,7 +226,7 @@ public class WallpaperCropActivity extends Activity { int maxDim = Math.max(maxDims.x, maxDims.y); final int minDim = Math.min(minDims.x, minDims.y); int defaultWidth; - if (LauncherAppState.isScreenLarge(getResources())) { + if (isScreenLarge(getResources())) { defaultWidth = (int) (maxDim * wallpaperTravelToScreenWidthRatio(maxDim, minDim)); } else { @@ -564,7 +574,7 @@ public class WallpaperCropActivity extends Activity { } protected void updateWallpaperDimensions(int width, int height) { - String spKey = LauncherAppState.getSharedPreferencesKey(); + String spKey = getSharedPreferencesKey(); SharedPreferences sp = getSharedPreferences(spKey, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sp.edit(); if (width != 0 && height != 0) { diff --git a/src/com/android/launcher3/WallpaperPickerActivity.java b/src/com/android/launcher3/WallpaperPickerActivity.java index a0b9e6e7d..fe7525a00 100644 --- a/src/com/android/launcher3/WallpaperPickerActivity.java +++ b/src/com/android/launcher3/WallpaperPickerActivity.java @@ -306,27 +306,27 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { // Called when the user selects a contextual menu item @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { - switch (item.getItemId()) { - case R.id.menu_delete: - int childCount = mWallpapersView.getChildCount(); - ArrayList<View> viewsToRemove = new ArrayList<View>(); - for (int i = 0; i < childCount; i++) { - CheckableFrameLayout c = - (CheckableFrameLayout) mWallpapersView.getChildAt(i); - if (c.isChecked()) { - ThumbnailMetaData meta = (ThumbnailMetaData) c.getTag(); - mSavedImages.deleteImage(meta.mSavedWallpaperDbId); - viewsToRemove.add(c); - } - } - for (View v : viewsToRemove) { - mWallpapersView.removeView(v); + int itemId = item.getItemId(); + if (itemId == R.id.menu_delete) { + int childCount = mWallpapersView.getChildCount(); + ArrayList<View> viewsToRemove = new ArrayList<View>(); + for (int i = 0; i < childCount; i++) { + CheckableFrameLayout c = + (CheckableFrameLayout) mWallpapersView.getChildAt(i); + if (c.isChecked()) { + ThumbnailMetaData meta = (ThumbnailMetaData) c.getTag(); + mSavedImages.deleteImage(meta.mSavedWallpaperDbId); + viewsToRemove.add(c); } - ///xxxxx DESTROYING - mode.finish(); // Action picked, so close the CAB - return true; - default: - return false; + } + for (View v : viewsToRemove) { + mWallpapersView.removeView(v); + } + ///xxxxx DESTROYING + mode.finish(); // Action picked, so close the CAB + return true; + } else { + return false; } } diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 3f63d743a..1818ade84 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -30,6 +30,7 @@ import android.appwidget.AppWidgetProviderInfo; import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.SharedPreferences; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Bitmap; @@ -51,6 +52,7 @@ import android.view.Display; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import android.view.ViewParent; import android.view.animation.DecelerateInterpolator; import android.view.animation.Interpolator; import android.widget.TextView; @@ -111,6 +113,8 @@ public class Workspace extends SmoothPagedView private int mOriginalDefaultPage; private int mDefaultPage; + private ShortcutAndWidgetContainer mDragSourceInternal; + // 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; @@ -353,7 +357,7 @@ public class Workspace extends SmoothPagedView return r; } - public void onDragStart(DragSource source, Object info, int dragAction) { + public void onDragStart(final DragSource source, Object info, int dragAction) { mIsDragOccuring = true; updateChildrenLayersEnabled(false); mLauncher.lockScreenOrientation(); @@ -361,6 +365,14 @@ public class Workspace extends SmoothPagedView // Prevent any Un/InstallShortcutReceivers from updating the db while we are dragging InstallShortcutReceiver.enableInstallQueue(); UninstallShortcutReceiver.enableUninstallQueue(); + post(new Runnable() { + @Override + public void run() { + if (mIsDragOccuring) { + addExtraEmptyScreenOnDrag(); + } + } + }); } public void onDragEnd() { @@ -371,6 +383,9 @@ public class Workspace extends SmoothPagedView // Re-enable any Un/InstallShortcutReceiver and now process any queued items InstallShortcutReceiver.disableAndFlushInstallQueue(getContext()); UninstallShortcutReceiver.disableAndFlushUninstallQueue(getContext()); + + removeExtraEmptyScreen(); + mDragSourceInternal = null; } /** @@ -489,6 +504,10 @@ public class Workspace extends SmoothPagedView String log = "10249126 - insertNewWorkspaceScreen(" + screenId + ", " + insertIndex + ")"; Launcher.addDumpLog(TAG, log, true); + if (mWorkspaceScreens.containsKey(screenId)) { + throw new RuntimeException("Screen id " + screenId + " already exists!"); + } + CellLayout newScreen = (CellLayout) mLauncher.getLayoutInflater().inflate(R.layout.workspace_screen, null); @@ -539,6 +558,49 @@ public class Workspace extends SmoothPagedView mCustomContentCallbacks = callbacks; } + public void addExtraEmptyScreenOnDrag() { + boolean lastChildOnScreen = false; + boolean childOnFinalScreen = false; + + if (mDragSourceInternal != null) { + if (mDragSourceInternal.getChildCount() == 1) { + lastChildOnScreen = true; + } + CellLayout cl = (CellLayout) mDragSourceInternal.getParent(); + if (indexOfChild(cl) == getChildCount() - 1) { + childOnFinalScreen = true; + } + } + + // If this is the last item on the final screen + if (lastChildOnScreen && childOnFinalScreen) { + return; + } + if (!mWorkspaceScreens.containsKey(EXTRA_EMPTY_SCREEN_ID)) { + insertNewWorkspaceScreen(EXTRA_EMPTY_SCREEN_ID); + } + } + + public boolean addExtraEmptyScreen() { + if (!mWorkspaceScreens.containsKey(EXTRA_EMPTY_SCREEN_ID)) { + insertNewWorkspaceScreen(EXTRA_EMPTY_SCREEN_ID); + return true; + } + return false; + } + + public void removeExtraEmptyScreen() { + int nScreens = getChildCount(); + nScreens = hasCustomContent() ? nScreens - 1 : nScreens; + + if (mWorkspaceScreens.containsKey(EXTRA_EMPTY_SCREEN_ID) && nScreens > 1) { + CellLayout cl = mWorkspaceScreens.get(EXTRA_EMPTY_SCREEN_ID); + mWorkspaceScreens.remove(EXTRA_EMPTY_SCREEN_ID); + mScreenOrder.remove(EXTRA_EMPTY_SCREEN_ID); + removeView(cl); + } + } + public long commitExtraEmptyScreen() { Launcher.addDumpLog(TAG, "10249126 - commitExtraEmptyScreen()", true); @@ -554,17 +616,12 @@ public class Workspace extends SmoothPagedView mWorkspaceScreens.put(newId, cl); mScreenOrder.add(newId); - addExtraEmptyScreen(); - // Update the model for the new screen mLauncher.getModel().updateWorkspaceScreenOrder(mLauncher, mScreenOrder); return newId; } - public void addExtraEmptyScreen() { - insertNewWorkspaceScreen(EXTRA_EMPTY_SCREEN_ID); - } public CellLayout getScreenWithId(long screenId) { Launcher.addDumpLog(TAG, "10249126 - getScreenWithId(" + screenId + ")", true); @@ -629,16 +686,27 @@ public class Workspace extends SmoothPagedView } } + // We enforce at least one page to add new items to. In the case that we remove the last + // such screen, we convert the last screen to the empty screen + int minScreens = hasCustomContent() ? 2 : 1; + int pageShift = 0; for (Long id: removeScreens) { Launcher.addDumpLog(TAG, "10249126 - \tremove(" + id + ")", true); CellLayout cl = mWorkspaceScreens.get(id); mWorkspaceScreens.remove(id); mScreenOrder.remove(id); - if (indexOfChild(cl) < currentPage) { - pageShift++; + + if (getChildCount() > minScreens) { + if (indexOfChild(cl) < currentPage) { + pageShift++; + } + removeView(cl); + } else { + // if this is the last non-custom content screen, convert it to the empty screen + mWorkspaceScreens.put(EXTRA_EMPTY_SCREEN_ID, cl); + mScreenOrder.add(EXTRA_EMPTY_SCREEN_ID); } - removeView(cl); } if (!removeScreens.isEmpty()) { @@ -977,8 +1045,10 @@ public class Workspace extends SmoothPagedView }; protected void setWallpaperDimension() { + String spKey = WallpaperCropActivity.getSharedPreferencesKey(); + SharedPreferences sp = mLauncher.getSharedPreferences(spKey, Context.MODE_PRIVATE); WallpaperPickerActivity.suggestWallpaperDimension(mLauncher.getResources(), - mLauncher.getSharedPrefs(), mLauncher.getWindowManager(), mWallpaperManager); + sp, mLauncher.getWindowManager(), mWallpaperManager); } @@ -1266,9 +1336,10 @@ public class Workspace extends SmoothPagedView } private void updateStateForCustomContent(int screenCenter) { - if (hasCustomContent() && !isSmall() && !isSwitchingState()) { + if (hasCustomContent()) { int index = mScreenOrder.indexOf(CUSTOM_CONTENT_SCREEN_ID); int scrollDelta = getScrollForPage(index + 1) - getScrollX(); + float translationX = Math.max(scrollDelta, 0); float progress = (1.0f * scrollDelta) / (getScrollForPage(index + 1) - getScrollForPage(index)); progress = Math.max(0, progress); @@ -1277,28 +1348,13 @@ public class Workspace extends SmoothPagedView mLastCustomContentScrollProgress = progress; setBackgroundAlpha(progress * 0.8f); - float height = getViewportHeight(); - if (getPageIndicator() != null) { - height -= getPageIndicator().getTop(); - } else if (mLauncher.getHotseat() != null) { - height -= mLauncher.getHotseat().getTop(); - } - float transY = progress * height; if (mLauncher.getHotseat() != null) { - mLauncher.getHotseat().setTranslationY(transY); - mLauncher.getHotseat().setAlpha(1 - progress); + mLauncher.getHotseat().setTranslationX(translationX); } if (getPageIndicator() != null) { - final float alpha = 1 - progress; - final View pi = getPageIndicator(); - getPageIndicator().setAlpha(alpha); - if (alpha < ALPHA_CUTOFF_THRESHOLD && pi.getVisibility() != INVISIBLE) { - pi.setVisibility(INVISIBLE); - } else if (alpha > ALPHA_CUTOFF_THRESHOLD && pi.getVisibility() != VISIBLE) { - pi.setVisibility(VISIBLE); - } + getPageIndicator().setTranslationX(translationX); } if (mCustomContentCallbacks != null) { @@ -1701,35 +1757,37 @@ public class Workspace extends SmoothPagedView } public void enterOverviewMode() { - enableOverviewMode(true, -1); + enableOverviewMode(true, -1, true); } - public void exitOverviewMode() { - exitOverviewMode(-1); + public void exitOverviewMode(boolean animated) { + exitOverviewMode(-1, animated); } - public void exitOverviewMode(int snapPage) { - enableOverviewMode(false, snapPage); + public void exitOverviewMode(int snapPage, boolean animated) { + enableOverviewMode(false, snapPage, animated); } - private void enableOverviewMode(boolean enable, int snapPage) { + private void enableOverviewMode(boolean enable, int snapPage, boolean animated) { State finalState = Workspace.State.OVERVIEW; if (!enable) { finalState = Workspace.State.NORMAL; } - Animator workspaceAnim = getChangeStateAnimation(finalState, true, 0, snapPage); - workspaceAnim.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator arg0) { - mIsSwitchingState = false; - } - @Override - public void onAnimationStart(Animator arg0) { - mIsSwitchingState = true; - } - }); - workspaceAnim.start(); + Animator workspaceAnim = getChangeStateAnimation(finalState, animated, 0, snapPage); + if (workspaceAnim != null) { + workspaceAnim.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator arg0) { + mIsSwitchingState = false; + } + @Override + public void onAnimationStart(Animator arg0) { + mIsSwitchingState = true; + } + }); + workspaceAnim.start(); + } } Animator getChangeStateAnimation(final State state, boolean animated, int delay, int snapPage) { @@ -1877,9 +1935,12 @@ public class Workspace extends SmoothPagedView anim.setStartDelay(delay); } else { mLauncher.getOverviewPanel().setAlpha(finalOverviewPanelAlpha); + AlphaUpdateListener.updateVisibility(mLauncher.getOverviewPanel()); mLauncher.getHotseat().setAlpha(finalHotseatAndPageIndicatorAlpha); + AlphaUpdateListener.updateVisibility(mLauncher.getHotseat()); if (getPageIndicator() != null) { getPageIndicator().setAlpha(finalHotseatAndPageIndicatorAlpha); + AlphaUpdateListener.updateVisibility(getPageIndicator()); } } @@ -1896,7 +1957,7 @@ public class Workspace extends SmoothPagedView return anim; } - class AlphaUpdateListener implements AnimatorUpdateListener { + static class AlphaUpdateListener implements AnimatorUpdateListener { View view; public AlphaUpdateListener(View v) { view = v; @@ -1904,6 +1965,10 @@ public class Workspace extends SmoothPagedView @Override public void onAnimationUpdate(ValueAnimator arg0) { + updateVisibility(view); + } + + public static void updateVisibility(View view) { if (view.getAlpha() < ALPHA_CUTOFF_THRESHOLD && view.getVisibility() != INVISIBLE) { view.setVisibility(INVISIBLE); } else if (view.getAlpha() > ALPHA_CUTOFF_THRESHOLD @@ -2130,6 +2195,11 @@ public class Workspace extends SmoothPagedView mDragController.startDrag(b, dragLayerX, dragLayerY, source, child.getTag(), DragController.DRAG_ACTION_MOVE, dragVisualizeOffset, dragRect, scale); + + if (child.getParent() instanceof ShortcutAndWidgetContainer) { + mDragSourceInternal = (ShortcutAndWidgetContainer) child.getParent(); + } + b.recycle(); } @@ -4069,20 +4139,39 @@ public class Workspace extends SmoothPagedView } } - void moveToDefaultScreen(boolean animate) { + private void moveToScreen(int page, boolean animate) { if (!isSmall()) { if (animate) { - snapToPage(mDefaultPage); + snapToPage(page); } else { - setCurrentPage(mDefaultPage); + setCurrentPage(page); } } - View child = getChildAt(mDefaultPage); + View child = getChildAt(page); if (child != null) { child.requestFocus(); } } + void moveToDefaultScreen(boolean animate) { + moveToScreen(mDefaultPage, animate); + } + + void moveToCustomContentScreen(boolean animate) { + if (hasCustomContent()) { + int ccIndex = getPageIndexForScreenId(CUSTOM_CONTENT_SCREEN_ID); + if (animate) { + snapToPage(ccIndex); + } else { + setCurrentPage(ccIndex); + } + View child = getChildAt(ccIndex); + if (child != null) { + child.requestFocus(); + } + } + } + @Override protected int getPageIndicatorMarker(int pageIndex) { if (getScreenIdForPageIndex(pageIndex) == CUSTOM_CONTENT_SCREEN_ID) { |