First cut at new home screen customization for xlarge displays.

- Add new layout for xlarge, removing hotseat, next/prev page, etc.
- Add a "+" button in top right which switches to customization mode
- Add a widget chooser which slides up from bottom of screen
- Initial support for dragging widgets onto home screen

Change-Id: I14e2e013ccceff4066fcb7c4492b4f6bef6595e7
This commit is contained in:
Michael Jurka
2010-06-10 17:01:57 -07:00
parent ff68ed0595
commit af44209bfa
10 changed files with 488 additions and 118 deletions
+30 -18
View File
@@ -16,8 +16,7 @@
package com.android.launcher2;
import java.util.ArrayList;
import java.util.HashSet;
import com.android.launcher.R;
import android.app.WallpaperManager;
import android.appwidget.AppWidgetManager;
@@ -47,7 +46,8 @@ import android.view.animation.Interpolator;
import android.widget.Scroller;
import android.widget.TextView;
import com.android.launcher.R;
import java.util.ArrayList;
import java.util.HashSet;
/**
* The workspace is a wide area with a wallpaper and a finite number of screens. Each
@@ -450,8 +450,10 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
postInvalidate();
} else if (mNextScreen != INVALID_SCREEN) {
mCurrentScreen = Math.max(0, Math.min(mNextScreen, getChildCount() - 1));
mPreviousIndicator.setLevel(mCurrentScreen);
mNextIndicator.setLevel(mCurrentScreen);
if (mPreviousIndicator != null) {
mPreviousIndicator.setLevel(mCurrentScreen);
mNextIndicator.setLevel(mCurrentScreen);
}
Launcher.setScreen(mCurrentScreen);
mNextScreen = INVALID_SCREEN;
clearChildrenCache();
@@ -963,8 +965,10 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
mNextScreen = whichScreen;
if (mPreviousIndicator != null) {
mPreviousIndicator.setLevel(mNextScreen);
mNextIndicator.setLevel(mNextScreen);
}
View focusedChild = getFocusedChild();
if (focusedChild != null && whichScreen != mCurrentScreen &&
@@ -1098,7 +1102,7 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
// Drag from somewhere else
ItemInfo info = (ItemInfo) dragInfo;
View view;
View view = null;
switch (info.itemType) {
case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
@@ -1113,23 +1117,31 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
view = FolderIcon.fromXml(R.layout.folder_icon, mLauncher,
(ViewGroup) getChildAt(mCurrentScreen), ((UserFolderInfo) info));
break;
case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
cellLayout.setTagToCellInfoForPoint(x, y);
mLauncher.addAppWidgetFromDrop(((LauncherAppWidgetInfo)dragInfo).providerName, cellLayout.getTag());
break;
default:
throw new IllegalStateException("Unknown item type: " + info.itemType);
}
cellLayout.addView(view, insertAtFirst ? 0 : -1);
view.setHapticFeedbackEnabled(false);
view.setOnLongClickListener(mLongClickListener);
if (view instanceof DropTarget) {
mDragController.addDropTarget((DropTarget) view);
// addAppWidgetFromDrop already took care of attaching the widget view to the appropriate cell
// TODO why aren't we calling addInScreen here?
if (info.itemType != LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET) {
cellLayout.addView(view, insertAtFirst ? 0 : -1);
view.setHapticFeedbackEnabled(false);
view.setOnLongClickListener(mLongClickListener);
if (view instanceof DropTarget) {
mDragController.addDropTarget((DropTarget) view);
}
mTargetCell = estimateDropCell(x, y, 1, 1, view, cellLayout, mTargetCell);
cellLayout.onDropChild(view, mTargetCell);
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) view.getLayoutParams();
LauncherModel.addOrMoveItemInDatabase(mLauncher, info,
LauncherSettings.Favorites.CONTAINER_DESKTOP, mCurrentScreen, lp.cellX, lp.cellY);
}
mTargetCell = estimateDropCell(x, y, 1, 1, view, cellLayout, mTargetCell);
cellLayout.onDropChild(view, mTargetCell);
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) view.getLayoutParams();
LauncherModel.addOrMoveItemInDatabase(mLauncher, info,
LauncherSettings.Favorites.CONTAINER_DESKTOP, mCurrentScreen, lp.cellX, lp.cellY);
}
/**