summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick Dubroy <dubroy@google.com>2010-09-07 17:49:27 -0700
committerPatrick Dubroy <dubroy@google.com>2010-09-08 10:38:54 -0700
commit2b9ff37edb3f5965559b3ff7d37e418b4a2917a1 (patch)
tree8bf504b523b7ad28307e306bd57a52a002afe4c5 /src
parentb1254a6bdb11024042fb6c27e179210c1bbd6e1c (diff)
downloadandroid_packages_apps_Trebuchet-2b9ff37edb3f5965559b3ff7d37e418b4a2917a1.tar.gz
android_packages_apps_Trebuchet-2b9ff37edb3f5965559b3ff7d37e418b4a2917a1.tar.bz2
android_packages_apps_Trebuchet-2b9ff37edb3f5965559b3ff7d37e418b4a2917a1.zip
When an app is chosen in All Apps, tapping a workspace screen adds it to that screen.
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/AllAppsPagedView.java1
-rw-r--r--src/com/android/launcher2/Launcher.java41
-rw-r--r--src/com/android/launcher2/PagedView.java10
-rw-r--r--src/com/android/launcher2/Workspace.java23
4 files changed, 64 insertions, 11 deletions
diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java
index 074a0985e..b1275b808 100644
--- a/src/com/android/launcher2/AllAppsPagedView.java
+++ b/src/com/android/launcher2/AllAppsPagedView.java
@@ -93,6 +93,7 @@ public class AllAppsPagedView extends PagedView
@Override
public void setLauncher(Launcher launcher) {
mLauncher = launcher;
+ mLauncher.setAllAppsPagedView(this);
}
@Override
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 53661fabc..a6f0a0e01 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -213,7 +213,9 @@ public final class Launcher extends Activity
private HandleView mHandleView;
private AllAppsView mAllAppsGrid;
private TabHost mHomeCustomizationDrawer;
- private CustomizePagedView mCustomizePagedView;
+
+ private PagedView mAllAppsPagedView = null;
+ private CustomizePagedView mCustomizePagedView = null;
private Bundle mSavedState;
@@ -2404,6 +2406,9 @@ public final class Launcher extends Activity
final View fromView =
(fromState == State.ALL_APPS) ? (View) mAllAppsGrid : mHomeCustomizationDrawer;
+ mCustomizePagedView.endChoiceMode();
+ mAllAppsPagedView.endChoiceMode();
+
setPivotsForZoom(fromView, fromState, scaleFactor);
mWorkspace.unshrink(animated);
@@ -2461,6 +2466,9 @@ public final class Launcher extends Activity
final float toViewStartY = fromAllApps ? workspaceHeight * 2 : -toView.getHeight() * 2;
final float toViewEndY = fromAllApps ? workspaceHeight - toView.getHeight() : 0.0f;
+ mCustomizePagedView.endChoiceMode();
+ mAllAppsPagedView.endChoiceMode();
+
if (toState == State.ALL_APPS) {
mWorkspace.shrinkToBottom(animated);
} else {
@@ -2603,13 +2611,28 @@ public final class Launcher extends Activity
}
}
- void onWorkspaceUnshrink() {
- final boolean animated = true;
- if (isAllAppsVisible()) {
- closeAllApps(animated);
+ void onWorkspaceClick(CellLayout layout) {
+ Object itemInfo = mAllAppsPagedView.getChosenItem();
+ if (itemInfo == null) {
+ itemInfo = mCustomizePagedView.getChosenItem();
}
- if (isCustomizationDrawerVisible()) {
- hideCustomizationDrawer(animated);
+
+ if (itemInfo == null) {
+ // No items are chosen in All Apps or Customize, so just zoom into the workspace
+ mWorkspace.unshrink(layout);
+ if (isAllAppsVisible()) {
+ closeAllApps(true);
+ } else if (isCustomizationDrawerVisible()) {
+ hideCustomizationDrawer(true);
+ }
+ } else {
+ // Act as if the chosen item was dropped on the given CellLayout
+ if (mWorkspace.addExternalItemToScreen(itemInfo, layout)) {
+ mAllAppsPagedView.endChoiceMode();
+ mCustomizePagedView.endChoiceMode();
+ } else {
+ Toast.makeText(this, getString(R.string.out_of_space), Toast.LENGTH_SHORT).show();
+ }
}
}
@@ -2800,6 +2823,10 @@ public final class Launcher extends Activity
}
}
+ void setAllAppsPagedView(PagedView view) {
+ mAllAppsPagedView = view;
+ }
+
/**
* Refreshes the shortcuts shown on the workspace.
*
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index df3f0ccad..c63811957 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -1009,7 +1009,7 @@ public abstract class PagedView extends ViewGroup {
mChoiceMode = mode;
}
- protected void endChoiceMode() {
+ public void endChoiceMode() {
if (!isChoiceMode(CHOICE_MODE_NONE)) {
mChoiceMode = CHOICE_MODE_NONE;
resetCheckedGrandchildren();
@@ -1059,6 +1059,14 @@ public abstract class PagedView extends ViewGroup {
return null;
}
+ public Object getChosenItem() {
+ View checkedView = (View) getSingleCheckedGrandchild();
+ if (checkedView != null) {
+ return checkedView.getTag();
+ }
+ return null;
+ }
+
protected void resetCheckedGrandchildren() {
// loop through children, and set all of their children to _not_ be checked
final ArrayList<Checkable> checked = getCheckedGrandchildren();
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index bb63c0877..e0761ff39 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -368,8 +368,7 @@ public class Workspace extends SmoothPagedView
public boolean onTouch(View v, MotionEvent event) {
// this is an intercepted event being forwarded from a cell layout
if (mIsSmall) {
- unshrink((CellLayout)v);
- mLauncher.onWorkspaceUnshrink();
+ mLauncher.onWorkspaceClick((CellLayout) v);
return true;
}
return false;
@@ -630,7 +629,7 @@ public class Workspace extends SmoothPagedView
}
// We call this when we trigger an unshrink by clicking on the CellLayout cl
- private void unshrink(CellLayout clThatWasClicked) {
+ public void unshrink(CellLayout clThatWasClicked) {
int newCurrentPage = mCurrentPage;
final int screenCount = getChildCount();
for (int i = 0; i < screenCount; i++) {
@@ -974,6 +973,24 @@ public class Workspace extends SmoothPagedView
onDropExternal(x, y, dragInfo, cellLayout, false);
}
+ /**
+ * Add the item specified by dragInfo to the given layout.
+ * This is basically the equivalent of onDropExternal, except it's not initiated
+ * by drag and drop.
+ * @return true if successful
+ */
+ public boolean addExternalItemToScreen(Object dragInfo, View layout) {
+ CellLayout cl = (CellLayout) layout;
+ ItemInfo info = (ItemInfo) dragInfo;
+
+ final CellLayout.CellInfo cellInfo = cl.updateOccupiedCells(null, null);
+ if (cellInfo.findCellForSpan(mTempEstimate, info.spanX, info.spanY)) {
+ onDropExternal(0, 0, dragInfo, cl, false);
+ return true;
+ }
+ return false;
+ }
+
private void onDropExternal(int x, int y, Object dragInfo,
CellLayout cellLayout, boolean insertAtFirst) {
// Drag from somewhere else