Move the all apps view back into the window with the workspace.

This commit is contained in:
Joe Onorato
2009-08-13 21:36:53 -07:00
parent 49cdb1b18c
commit 7c312c15e3
9 changed files with 100 additions and 196 deletions
-39
View File
@@ -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"
-->
+1 -1
View File
@@ -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"
-44
View File
@@ -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>
+15 -8
View File
@@ -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>
@@ -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;
+22 -6
View File
@@ -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 ======
@@ -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();
+47 -95
View File
@@ -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.
+12 -2
View File
@@ -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);
}
}
}