diff options
author | Joe Onorato <joeo@android.com> | 2009-08-13 21:36:53 -0700 |
---|---|---|
committer | Joe Onorato <joeo@android.com> | 2009-08-16 15:03:36 -0400 |
commit | 7c312c15e33b6cffbda707429e88ade498fc9f5e (patch) | |
tree | fcb170f5031ceca5b978efe02c572696f2f7c804 | |
parent | 49cdb1b18c12a81cac9817c4800e43d5b507e0c4 (diff) | |
download | packages_apps_trebuchet-7c312c15e33b6cffbda707429e88ade498fc9f5e.zip packages_apps_trebuchet-7c312c15e33b6cffbda707429e88ade498fc9f5e.tar.gz packages_apps_trebuchet-7c312c15e33b6cffbda707429e88ade498fc9f5e.tar.bz2 |
Move the all apps view back into the window with the workspace.
-rw-r--r-- | res/layout-land/all_apps.xml | 39 | ||||
-rw-r--r-- | res/layout-land/launcher.xml | 2 | ||||
-rw-r--r-- | res/layout-port/all_apps.xml | 44 | ||||
-rw-r--r-- | res/layout-port/launcher.xml | 23 | ||||
-rw-r--r-- | src/com/android/launcher2/AllAppsGridView.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher2/AllAppsView.java | 28 | ||||
-rw-r--r-- | src/com/android/launcher2/DragController.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 142 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 14 |
9 files changed, 100 insertions, 196 deletions
diff --git a/res/layout-land/all_apps.xml b/res/layout-land/all_apps.xml deleted file mode 100644 index c538062..0000000 --- a/res/layout-land/all_apps.xml +++ /dev/null @@ -1,39 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2007 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. ---> - -<com.android.launcher2.AllAppsView - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher2" - - android:id="@+id/all_apps" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - - android:scrollbarStyle="outsideInset" - android:drawSelectorOnTop="false" - android:listSelector="@drawable/grid_selector" - - android:verticalSpacing="10dip" - android:numColumns="5" /> - -<!-- - android:nextFocusLeft="@id/all_apps" - android:nextFocusDown="@id/content" - android:nextFocusUp="@id/content" - android:nextFocusRight="@id/content" ---> - - diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml index ef16231..fd27bad 100644 --- a/res/layout-land/launcher.xml +++ b/res/layout-land/launcher.xml @@ -37,7 +37,7 @@ </com.android.launcher2.Workspace> <com.android.launcher2.HandleView - android:id="@id/all_apps" + android:id="@+id/all_apps_button" android:layout_width="56dip" android:layout_height="fill_parent" diff --git a/res/layout-port/all_apps.xml b/res/layout-port/all_apps.xml deleted file mode 100644 index d1cbeeb..0000000 --- a/res/layout-port/all_apps.xml +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2007 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. ---> - -<com.android.launcher2.DragLayer - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher2" - - android:id="@+id/drag_layer" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> - - <com.android.launcher2.AllAppsView - android:id="@+id/all_apps" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - - android:scrollbarStyle="outsideInset" - android:drawSelectorOnTop="false" - android:listSelector="@drawable/grid_selector" - - android:verticalSpacing="10dip" - android:numColumns="4" /> - -<!-- - android:nextFocusLeft="@id/content" - android:nextFocusDown="@id/content" - android:nextFocusUp="@id/all_apps" - android:nextFocusRight="@id/content" ---> - -</com.android.launcher2.DragLayer> diff --git a/res/layout-port/launcher.xml b/res/layout-port/launcher.xml index 273403e..d57d3a4 100644 --- a/res/layout-port/launcher.xml +++ b/res/layout-port/launcher.xml @@ -14,18 +14,27 @@ limitations under the License. --> -<FrameLayout +<com.android.launcher2.DragLayer xmlns:android="http://schemas.android.com/apk/res/android" xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher2" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> - -<com.android.launcher2.DragLayer android:id="@+id/drag_layer" android:layout_width="fill_parent" android:layout_height="fill_parent"> + <com.android.launcher2.AllAppsView + android:id="@+id/all_apps_view" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:visibility="gone" + + android:scrollbarStyle="outsideInset" + android:drawSelectorOnTop="false" + android:listSelector="@drawable/grid_selector" + + android:verticalSpacing="10dip" + android:numColumns="4" /> + <!-- The workspace contains 3 screens of cells --> <com.android.launcher2.Workspace android:id="@+id/workspace" @@ -41,7 +50,7 @@ </com.android.launcher2.Workspace> <com.android.launcher2.HandleView - android:id="@id/all_apps" + android:id="@+id/all_apps_button" android:layout_width="fill_parent" android:layout_height="56dip" android:layout_gravity="bottom" @@ -71,5 +80,3 @@ launcher:direction="horizontal" /> </com.android.launcher2.DragLayer> - -</FrameLayout> diff --git a/src/com/android/launcher2/AllAppsGridView.java b/src/com/android/launcher2/AllAppsGridView.java index 711e213..23d4a7a 100644 --- a/src/com/android/launcher2/AllAppsGridView.java +++ b/src/com/android/launcher2/AllAppsGridView.java @@ -66,7 +66,7 @@ public class AllAppsGridView extends GridView implements AdapterView.OnItemClick app = new ApplicationInfo(app); mDragController.startDrag(view, this, app, DragController.DRAG_ACTION_COPY); - mLauncher.showWorkspace(); + mLauncher.closeAllAppsDialog(true); mDraw = false; invalidate(); return true; diff --git a/src/com/android/launcher2/AllAppsView.java b/src/com/android/launcher2/AllAppsView.java index 8c0b83d..755ba65 100644 --- a/src/com/android/launcher2/AllAppsView.java +++ b/src/com/android/launcher2/AllAppsView.java @@ -36,6 +36,7 @@ import android.renderscript.Sampler; import android.content.Context; import android.content.res.Resources; +import android.database.DataSetObserver; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; @@ -65,20 +66,28 @@ public class AllAppsView extends RSSurfaceView { private VelocityTracker mVelocity; private int mLastScrollX; private int mLastMotionX; + private ApplicationsAdapter mAdapter; - public AllAppsView(Context context) { - super(context); + + public AllAppsView(Context context, AttributeSet attrs) { + super(context, attrs); setFocusable(true); getHolder().setFormat(PixelFormat.TRANSLUCENT); mConfig = ViewConfiguration.get(context); } - public AllAppsView(Context context, AttributeSet attrs) { - this(context); + public AllAppsView(Context context, AttributeSet attrs, int defStyle) { + this(context, attrs); } - public AllAppsView(Context context, AttributeSet attrs, int defStyle) { - this(context); + void setAdapter(ApplicationsAdapter adapter) { + if (mAdapter != null) { + mAdapter.unregisterDataSetObserver(mIconObserver); + } + mAdapter = adapter; + if (adapter != null) { + adapter.registerDataSetObserver(mIconObserver); + } } @Override @@ -100,6 +109,7 @@ public class AllAppsView extends RSSurfaceView { @Override public boolean onTouchEvent(MotionEvent ev) { + Log.d(Launcher.LOG_TAG, "onTouchEvent " + ev); int x = (int)ev.getX(); int deltaX; switch (ev.getAction()) { @@ -151,6 +161,12 @@ public class AllAppsView extends RSSurfaceView { return true; } + DataSetObserver mIconObserver = new DataSetObserver() { + public void onChanged() { + Log.d(Launcher.LOG_TAG, "new icons arrived! now have " + mAdapter.getCount()); + } + }; + public class RolloRS { // Allocations ====== diff --git a/src/com/android/launcher2/DragController.java b/src/com/android/launcher2/DragController.java index da2df5c..51cf5e1 100644 --- a/src/com/android/launcher2/DragController.java +++ b/src/com/android/launcher2/DragController.java @@ -273,6 +273,8 @@ public class DragController { * Call this from a drag source view. */ public boolean onInterceptTouchEvent(MotionEvent ev) { + Log.d(Launcher.LOG_TAG, "DragController.onInterceptTouchEvent " + ev + " mDragging=" + + mDragging); final int action = ev.getAction(); final float screenX = ev.getRawX(); diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index b370222..e388ac3 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -55,6 +55,7 @@ import android.text.SpannableStringBuilder; import android.text.TextUtils; import android.text.method.TextKeyListener; import static android.util.Log.*; +import android.util.Log; import android.view.Display; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -117,9 +118,8 @@ public final class Launcher extends Activity implements View.OnClickListener, On static final int NUMBER_CELLS_X = 4; static final int NUMBER_CELLS_Y = 4; - static final int DIALOG_ALL_APPS = 1; - static final int DIALOG_CREATE_SHORTCUT = 2; - static final int DIALOG_RENAME_FOLDER = 3; + static final int DIALOG_CREATE_SHORTCUT = 1; + static final int DIALOG_RENAME_FOLDER = 2; private static final String PREFERENCES = "launcher.preferences"; @@ -173,9 +173,10 @@ public final class Launcher extends Activity implements View.OnClickListener, On private final int[] mCellCoordinates = new int[2]; private FolderInfo mFolderInfo; - private AllAppsDialog mAllAppsDialog; + private DeleteZone mDeleteZone; private HandleView mHandleView; - private AllAppsView mAllAppsGrid; // TODO: put this into AllAppsDialog + private AllAppsView mAllAppsGrid; + private boolean mAllAppsVisible; private boolean mDesktopLocked = true; private Bundle mSavedState; @@ -218,8 +219,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On setContentView(R.layout.launcher); setupViews(); - mAllAppsDialog = new AllAppsDialog(this); - mAllAppsDialog.lock(); + lockAllApps(); registerIntentReceivers(); registerContentObservers(); @@ -527,12 +527,15 @@ public final class Launcher extends Activity implements View.OnClickListener, On DragLayer dragLayer = (DragLayer) findViewById(R.id.drag_layer); dragLayer.setDragController(dragController); + mAllAppsGrid = (AllAppsView)dragLayer.findViewById(R.id.all_apps_view); + mWorkspace = (Workspace) dragLayer.findViewById(R.id.workspace); final Workspace workspace = mWorkspace; - final DeleteZone deleteZone = (DeleteZone) dragLayer.findViewById(R.id.delete_zone); + DeleteZone deleteZone = (DeleteZone) dragLayer.findViewById(R.id.delete_zone); + mDeleteZone = deleteZone; - mHandleView = (HandleView) findViewById(R.id.all_apps); + mHandleView = (HandleView) findViewById(R.id.all_apps_button); mHandleView.setLauncher(this); mHandleView.setOnClickListener(this); TransitionDrawable handleIcon = (TransitionDrawable) mHandleView.getDrawable(); @@ -848,7 +851,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On // When the drawer is opened and we are saving the state because of a // configuration change - if (mAllAppsDialog.isOpen && isConfigurationChange) { + if (mAllAppsVisible && isConfigurationChange) { outState.putBoolean(RUNTIME_STATE_ALL_APPS_FOLDER, true); } @@ -887,7 +890,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On TextKeyListener.getInstance().release(); - // TODO mAllAppsGrid.setAdapter(null); + mAllAppsGrid.setAdapter(null); sModel.unbind(); sModel.abortLoaders(); @@ -1299,7 +1302,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On case KeyEvent.KEYCODE_BACK: if (!event.isCanceled()) { mWorkspace.dispatchKeyEvent(event); - if (mAllAppsDialog.isOpen) { + if (mAllAppsVisible) { closeAllAppsDialog(true); } else { closeFolder(); @@ -1339,7 +1342,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On */ private void onFavoritesChanged() { mDesktopLocked = true; - mAllAppsDialog.lock(); + lockAllApps(); sModel.loadUserItems(false, this, false, false); } @@ -1479,18 +1482,18 @@ public final class Launcher extends Activity implements View.OnClickListener, On } /* TODO - if (mAllAppsDialog.isOpen && !mDrawer.hasFocus()) { + if (mAllAppsVisible && !mDrawer.hasFocus()) { mDrawer.requestFocus(); } */ mDesktopLocked = false; - mAllAppsDialog.unlock(); + unlockAllApps(); } private void bindDrawer(Launcher.DesktopBinder binder, ApplicationsAdapter drawerAdapter) { - // TODO mAllAppsGrid.setAdapter(drawerAdapter); + mAllAppsGrid.setAdapter(drawerAdapter); binder.startBindingAppWidgetsWhenIdle(); } @@ -1541,7 +1544,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On } else if (tag instanceof FolderInfo) { handleFolderClick((FolderInfo) tag); } else if (v == mHandleView) { - if (mAllAppsDialog.isOpen) { + if (mAllAppsVisible) { // TODO how can we be here? } else { showAllAppsDialog(); @@ -1666,8 +1669,8 @@ public final class Launcher extends Activity implements View.OnClickListener, On return mHandleView; } - boolean isDrawerDown() { - return /* TODO !mDrawer.isMoving() && */ !mAllAppsDialog.isOpen; + boolean isDrawerDown() { // TODO rename to isAllAppsVisible() + return /* TODO !mDrawer.isMoving() && */ !mAllAppsVisible; } Workspace getWorkspace() { @@ -1683,8 +1686,6 @@ public final class Launcher extends Activity implements View.OnClickListener, On @Override protected Dialog onCreateDialog(int id) { switch (id) { - case DIALOG_ALL_APPS: - return mAllAppsDialog; case DIALOG_CREATE_SHORTCUT: return new CreateShortcut().createDialog(); case DIALOG_RENAME_FOLDER: @@ -1697,9 +1698,6 @@ public final class Launcher extends Activity implements View.OnClickListener, On @Override protected void onPrepareDialog(int id, Dialog dialog) { switch (id) { - case DIALOG_ALL_APPS: - // TODO mAllAppsGrid.onPrepareDialog(); - break; case DIALOG_CREATE_SHORTCUT: break; case DIALOG_RENAME_FOLDER: @@ -1797,7 +1795,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On LauncherModel.updateItemInDatabase(Launcher.this, mFolderInfo); if (mDesktopLocked) { - mAllAppsDialog.lock(); + lockAllApps(); sModel.loadUserItems(false, Launcher.this, false, false); } else { final FolderIcon folderIcon = (FolderIcon) @@ -1807,7 +1805,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On getWorkspace().requestLayout(); } else { mDesktopLocked = true; - mAllAppsDialog.lock(); + lockAllApps(); sModel.loadUserItems(false, Launcher.this, false, false); } } @@ -1823,89 +1821,43 @@ public final class Launcher extends Activity implements View.OnClickListener, On } } - /** - * Holds the 3d all apps view. - */ - private class AllAppsDialog extends Dialog implements DialogInterface.OnCancelListener, - DialogInterface.OnDismissListener, DialogInterface.OnShowListener { - - boolean isOpen; - - AllAppsDialog(Context context) { - super(context, android.R.style.Theme_Translucent_NoTitleBar); - - setOnCancelListener(this); - setOnDismissListener(this); - setOnShowListener(this); - - setContentView(R.layout.all_apps); - mAllAppsGrid = (AllAppsView) findViewById(R.id.all_apps); - - DragLayer dragLayer = (DragLayer)findViewById(R.id.drag_layer); - dragLayer.setDragController(mDragController); - - // TODO grid.setDragController(mDragController); - // TODO grid.setLauncher(Launcher.this); - } - - public void onCancel(DialogInterface dialog) { - onDestroy(); - } - - public void onDismiss(DialogInterface dialog) { - onDestroy(); - } - - public void onShow(DialogInterface dialog) { - } - - private void onDestroy() { - } - - void lock() { - // TODO - } - - void unlock() { - // TODO - } - - @Override - public boolean onKeyDown(int keyCode, KeyEvent event) { - switch (keyCode) { - case KeyEvent.KEYCODE_BACK: - closeAllAppsDialog(true); - return true; - default: - return super.onKeyDown(keyCode, event); - } - } - } - void showAllAppsDialog() { - mAllAppsDialog.isOpen = true; - showDialog(DIALOG_ALL_APPS); + mAllAppsVisible = true; + mAllAppsGrid.setVisibility(View.VISIBLE); mWorkspace.hide(); - } - - void showWorkspace() { - mWorkspace.show(); + + // TODO: fade these two too + mDeleteZone.setVisibility(View.GONE); + mHandleView.setVisibility(View.GONE); } void closeAllAppsDialog(boolean animated) { - if (mAllAppsDialog.isOpen) { + if (mAllAppsVisible) { + Log.d(LOG_TAG, "closing all apps"); if (animated) { // TODO mDrawer.animateClose(); - mAllAppsDialog.dismiss(); + mAllAppsGrid.setVisibility(View.GONE); } else { - mAllAppsDialog.dismiss(); + mAllAppsGrid.setVisibility(View.GONE); } - mAllAppsDialog.isOpen = false; + mAllAppsVisible = false; mWorkspace.getChildAt(mWorkspace.getCurrentScreen()).requestFocus(); mWorkspace.show(); + + // TODO: fade these two too + mDeleteZone.setVisibility(View.VISIBLE); + mHandleView.setVisibility(View.VISIBLE); } } + void lockAllApps() { + // TODO + } + + void unlockAllApps() { + // TODO + } + /** * Displays the shortcut creation dialog and launches, if necessary, the * appropriate activity. diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index c960412..759deb6 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -26,6 +26,7 @@ import android.graphics.RectF; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.util.AttributeSet; +import android.util.Log; import android.view.MotionEvent; import android.view.VelocityTracker; import android.view.View; @@ -641,8 +642,11 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag @Override public boolean onInterceptTouchEvent(MotionEvent ev) { + Log.d(Launcher.LOG_TAG, "Workspace onIntercept " + ev + " mLocked=" + mLocked + + " mLauncher.isDrawerDown()=" + mLauncher.isDrawerDown()); if (mLocked || !mLauncher.isDrawerDown()) { - return true; + Log.d(Launcher.LOG_TAG, "returning false"); + return false; // We don't want the events. Let them fall through to the all apps view. } /* @@ -751,8 +755,10 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag @Override public boolean onTouchEvent(MotionEvent ev) { + Log.d(Launcher.LOG_TAG, "Workspace onTouchEvent " + ev); + if (mLocked || !mLauncher.isDrawerDown()) { - return true; + return false; // We don't want the events. Let them fall through to the all apps view. } if (mVelocityTracker == null) { @@ -1357,6 +1363,7 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag void show() { mTween.start(true); + setVisibility(VISIBLE); } void hide() { @@ -1378,5 +1385,8 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag // TODO: This conflicts with the cache for drawing. Ref count instead? // TODO: Don't cache all three. clearChildrenCache(); + if (mAlpha == 0) { + setVisibility(GONE); + } } } |