auto import from //branches/cupcake/...@137873

This commit is contained in:
The Android Open Source Project 2009-03-11 12:11:58 -07:00
parent bc219c3c12
commit 7376faefbb
17 changed files with 300 additions and 244 deletions

View File

Before

Width:  |  Height:  |  Size: 918 B

After

Width:  |  Height:  |  Size: 918 B

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

@ -22,8 +22,8 @@
android:paddingLeft="20dip"
android:paddingRight="20dip"
android:gravity="center"
android:background="@drawable/bg_gadget_error"
android:background="@drawable/bg_appwidget_error"
android:textAppearance="?android:attr/textAppearanceMediumInverse"
android:textColor="@color/gadget_error_color"
android:textColor="@color/appwidget_error_color"
android:text="@string/gadget_error_text"
/>

View File

@ -23,5 +23,5 @@
<color name="bubble_dark_background">#B2191919</color>
<color name="delete_color_filter">#A5FF0000</color>
<color name="gadget_error_color">#fccc</color>
<color name="appwidget_error_color">#fccc</color>
</resources>

View File

@ -40,7 +40,7 @@ public class AddAdapter extends BaseAdapter {
public static final int ITEM_APPLICATION = 0;
public static final int ITEM_SHORTCUT = 1;
public static final int ITEM_SEARCH = 2;
public static final int ITEM_GADGET = 3;
public static final int ITEM_APPWIDGET = 3;
public static final int ITEM_LIVE_FOLDER = 4;
public static final int ITEM_FOLDER = 5;
public static final int ITEM_WALLPAPER = 6;
@ -80,10 +80,10 @@ public class AddAdapter extends BaseAdapter {
R.drawable.ic_launcher_empty, ITEM_SHORTCUT));
mItems.add(new ListItem(res, R.string.group_search,
R.drawable.ic_search_gadget, ITEM_SEARCH));
R.drawable.ic_search_widget, ITEM_SEARCH));
mItems.add(new ListItem(res, R.string.group_widgets,
R.drawable.ic_launcher_gadget, ITEM_GADGET));
R.drawable.ic_launcher_appwidget, ITEM_APPWIDGET));
mItems.add(new ListItem(res, R.string.group_live_folders,
R.drawable.ic_launcher_empty, ITEM_LIVE_FOLDER));

View File

@ -85,8 +85,8 @@ public class DeleteZone extends ImageView implements DropTarget, DragController.
final LauncherModel model = Launcher.getModel();
if (item.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
if (item instanceof LauncherGadgetInfo) {
model.removeDesktopGadget((LauncherGadgetInfo) item);
if (item instanceof LauncherAppWidgetInfo) {
model.removeDesktopAppWidget((LauncherAppWidgetInfo) item);
} else {
model.removeDesktopItem(item);
}
@ -101,11 +101,11 @@ public class DeleteZone extends ImageView implements DropTarget, DragController.
final UserFolderInfo userFolderInfo = (UserFolderInfo)item;
LauncherModel.deleteUserFolderContentsFromDatabase(mLauncher, userFolderInfo);
model.removeUserFolder(userFolderInfo);
} else if (item instanceof LauncherGadgetInfo) {
final LauncherGadgetInfo launcherGadgetInfo = (LauncherGadgetInfo)item;
final LauncherGadgetHost gadgetHost = mLauncher.getGadgetHost();
if (gadgetHost != null) {
gadgetHost.deleteGadgetId(launcherGadgetInfo.gadgetId);
} else if (item instanceof LauncherAppWidgetInfo) {
final LauncherAppWidgetInfo launcherAppWidgetInfo = (LauncherAppWidgetInfo) item;
final LauncherAppWidgetHost appWidgetHost = mLauncher.getAppWidgetHost();
if (appWidgetHost != null) {
appWidgetHost.deleteAppWidgetId(launcherAppWidgetInfo.appWidgetId);
}
}
LauncherModel.deleteItemFromDatabase(mLauncher, item);

View File

@ -39,7 +39,7 @@ class ItemInfo {
* One of {@link LauncherSettings.Favorites#ITEM_TYPE_APPLICATION},
* {@link LauncherSettings.Favorites#ITEM_TYPE_SHORTCUT},
* {@link LauncherSettings.Favorites#ITEM_TYPE_USER_FOLDER}, or
* {@link LauncherSettings.Favorites#ITEM_TYPE_GADGET}.
* {@link LauncherSettings.Favorites#ITEM_TYPE_APPWIDGET}.
*/
int itemType;

View File

@ -37,8 +37,6 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.content.res.Configuration;
import android.database.ContentObserver;
import android.gadget.GadgetProviderInfo;
import android.gadget.GadgetManager;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
@ -78,6 +76,8 @@ import android.widget.Toast;
import android.widget.GridView;
import android.widget.SlidingDrawer;
import android.app.IWallpaperService;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
@ -90,6 +90,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On
static final boolean LOGD = false;
private static final boolean PROFILE_STARTUP = false;
private static final boolean PROFILE_DRAWER = false;
private static final boolean DEBUG_USER_INTERFACE = false;
private static final int WALLPAPER_SCREENS_SPAN = 2;
@ -103,11 +104,11 @@ public final class Launcher extends Activity implements View.OnClickListener, On
private static final int REQUEST_CREATE_SHORTCUT = 1;
private static final int REQUEST_CREATE_LIVE_FOLDER = 4;
private static final int REQUEST_CREATE_GADGET = 5;
private static final int REQUEST_CREATE_APPWIDGET = 5;
private static final int REQUEST_PICK_APPLICATION = 6;
private static final int REQUEST_PICK_SHORTCUT = 7;
private static final int REQUEST_PICK_LIVE_FOLDER = 8;
private static final int REQUEST_PICK_GADGET = 9;
private static final int REQUEST_PICK_APPWIDGET = 9;
static final String EXTRA_SHORTCUT_DUPLICATE = "duplicate";
@ -168,10 +169,10 @@ public final class Launcher extends Activity implements View.OnClickListener, On
private DragLayer mDragLayer;
private Workspace mWorkspace;
private GadgetManager mGadgetManager;
private LauncherGadgetHost mGadgetHost;
private AppWidgetManager mAppWidgetManager;
private LauncherAppWidgetHost mAppWidgetHost;
static final int GADGET_HOST_ID = 1024;
static final int APPWIDGET_HOST_ID = 1024;
private CellLayout.CellInfo mAddItemCellInfo;
private CellLayout.CellInfo mMenuAddInfo;
@ -180,6 +181,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On
private SlidingDrawer mDrawer;
private TransitionDrawable mHandleIcon;
private HandleView mHandleView;
private AllAppsGridView mAllAppsGrid;
private boolean mDesktopLocked = true;
@ -200,10 +202,10 @@ public final class Launcher extends Activity implements View.OnClickListener, On
super.onCreate(savedInstanceState);
mInflater = getLayoutInflater();
mGadgetManager = GadgetManager.getInstance(this);
mAppWidgetManager = AppWidgetManager.getInstance(this);
mGadgetHost = new LauncherGadgetHost(this, GADGET_HOST_ID);
mGadgetHost.startListening();
mAppWidgetHost = new LauncherAppWidgetHost(this, APPWIDGET_HOST_ID);
mAppWidgetHost.startListening();
if (PROFILE_STARTUP) {
android.os.Debug.startMethodTracing("/sdcard/launcher");
@ -317,19 +319,19 @@ public final class Launcher extends Activity implements View.OnClickListener, On
case REQUEST_CREATE_LIVE_FOLDER:
completeAddLiveFolder(data, mAddItemCellInfo, !mDesktopLocked);
break;
case REQUEST_PICK_GADGET:
addGadget(data);
case REQUEST_PICK_APPWIDGET:
addAppWidget(data);
break;
case REQUEST_CREATE_GADGET:
completeAddGadget(data, mAddItemCellInfo, !mDesktopLocked);
case REQUEST_CREATE_APPWIDGET:
completeAddAppWidget(data, mAddItemCellInfo, !mDesktopLocked);
break;
}
} else if (requestCode == REQUEST_PICK_GADGET &&
} else if (requestCode == REQUEST_PICK_APPWIDGET &&
resultCode == RESULT_CANCELED && data != null) {
// Clean up the gadgetId if we canceled
int gadgetId = data.getIntExtra(GadgetManager.EXTRA_GADGET_ID, -1);
if (gadgetId != -1) {
mGadgetHost.deleteGadgetId(gadgetId);
// Clean up the appWidgetId if we canceled
int appWidgetId = data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
if (appWidgetId != -1) {
mAppWidgetHost.deleteAppWidgetId(appWidgetId);
}
}
mWaitingForResult = false;
@ -344,6 +346,12 @@ public final class Launcher extends Activity implements View.OnClickListener, On
}
}
@Override
protected void onPause() {
super.onPause();
closeDrawer(false);
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
boolean handled = super.onKeyUp(keyCode, event);
@ -463,9 +471,9 @@ public final class Launcher extends Activity implements View.OnClickListener, On
final DeleteZone deleteZone = (DeleteZone) dragLayer.findViewById(R.id.delete_zone);
final HandleView handleIcon = (HandleView) drawer.findViewById(R.id.all_apps);
handleIcon.setLauncher(this);
mHandleIcon = (TransitionDrawable) handleIcon.getDrawable();
mHandleView = (HandleView) drawer.findViewById(R.id.all_apps);
mHandleView.setLauncher(this);
mHandleIcon = (TransitionDrawable) mHandleView.getDrawable();
mHandleIcon.setCrossFadeEnabled(true);
drawer.lock();
@ -485,7 +493,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On
deleteZone.setLauncher(this);
deleteZone.setDragController(dragLayer);
deleteZone.setHandle(handleIcon);
deleteZone.setHandle(mHandleView);
dragLayer.setIgnoredDropTarget(grid);
dragLayer.setDragScoller(workspace);
@ -593,32 +601,31 @@ public final class Launcher extends Activity implements View.OnClickListener, On
/**
* Add a gadget to the workspace.
* Add a widget to the workspace.
*
* @param data The intent describing the gadgetId.
* @param cellInfo The position on screen where to create the shortcut.
* @param insertAtFirst
* @param data The intent describing the appWidgetId.
* @param cellInfo The position on screen where to create the widget.
*/
private void completeAddGadget(Intent data, CellLayout.CellInfo cellInfo,
private void completeAddAppWidget(Intent data, CellLayout.CellInfo cellInfo,
boolean insertAtFirst) {
Bundle extras = data.getExtras();
int gadgetId = extras.getInt(GadgetManager.EXTRA_GADGET_ID, -1);
int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
Log.d(LOG_TAG, "dumping extras content="+extras.toString());
GadgetProviderInfo gadgetInfo = mGadgetManager.getGadgetInfo(gadgetId);
AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appWidgetId);
// Calculate the grid spans needed to fit this gadget
// Calculate the grid spans needed to fit this widget
CellLayout layout = (CellLayout) mWorkspace.getChildAt(cellInfo.screen);
int[] spans = layout.rectToCell(gadgetInfo.minWidth, gadgetInfo.minHeight);
int[] spans = layout.rectToCell(appWidgetInfo.minWidth, appWidgetInfo.minHeight);
// Try finding open space on Launcher screen
final int[] xy = mCellCoordinates;
if (!findSlot(cellInfo, xy, spans[0], spans[1])) return;
// Build Launcher-specific Gadget info and save to database
LauncherGadgetInfo launcherInfo = new LauncherGadgetInfo(gadgetId);
// Build Launcher-specific widget info and save to database
LauncherAppWidgetInfo launcherInfo = new LauncherAppWidgetInfo(appWidgetId);
launcherInfo.spanX = spans[0];
launcherInfo.spanY = spans[1];
@ -627,23 +634,23 @@ public final class Launcher extends Activity implements View.OnClickListener, On
mWorkspace.getCurrentScreen(), xy[0], xy[1], false);
if (!mRestoring) {
sModel.addDesktopGadget(launcherInfo);
sModel.addDesktopAppWidget(launcherInfo);
// Perform actual inflation because we're live
launcherInfo.hostView = mGadgetHost.createView(this, gadgetId, gadgetInfo);
launcherInfo.hostView = mAppWidgetHost.createView(this, appWidgetId, appWidgetInfo);
launcherInfo.hostView.setGadget(gadgetId, gadgetInfo);
launcherInfo.hostView.setAppWidget(appWidgetId, appWidgetInfo);
launcherInfo.hostView.setTag(launcherInfo);
mWorkspace.addInCurrentScreen(launcherInfo.hostView, xy[0], xy[1],
launcherInfo.spanX, launcherInfo.spanY, insertAtFirst);
} else if (sModel.isDesktopLoaded()) {
sModel.addDesktopGadget(launcherInfo);
sModel.addDesktopAppWidget(launcherInfo);
}
}
public LauncherGadgetHost getGadgetHost() {
return mGadgetHost;
public LauncherAppWidgetHost getAppWidgetHost() {
return mAppWidgetHost;
}
static ApplicationInfo addShortcut(Context context, Intent data,
@ -794,9 +801,9 @@ public final class Launcher extends Activity implements View.OnClickListener, On
super.onDestroy();
try {
mGadgetHost.stopListening();
mAppWidgetHost.stopListening();
} catch (NullPointerException ex) {
Log.w(LOG_TAG, "problem while stopping GadgetHost during Launcher destruction", ex);
Log.w(LOG_TAG, "problem while stopping AppWidgetHost during Launcher destruction", ex);
}
TextKeyListener.getInstance().release();
@ -876,9 +883,9 @@ public final class Launcher extends Activity implements View.OnClickListener, On
return true;
case MENU_SEARCH:
if (mWorkspace.snapToSearch()) {
closeDrawer(true); // search gadget: get drawer out of the way
closeDrawer(true); // search widget: get drawer out of the way
} else {
onSearchRequested(); // no search gadget: use system search UI
onSearchRequested(); // no search widget: use system search UI
}
return true;
case MENU_NOTIFICATIONS:
@ -899,21 +906,21 @@ public final class Launcher extends Activity implements View.OnClickListener, On
}
}
void addGadget(Intent data) {
// TODO: catch bad gadget exception when sent
int gadgetId = data.getIntExtra(GadgetManager.EXTRA_GADGET_ID, -1);
GadgetProviderInfo gadget = mGadgetManager.getGadgetInfo(gadgetId);
void addAppWidget(Intent data) {
// TODO: catch bad widget exception when sent
int appWidgetId = data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
AppWidgetProviderInfo appWidget = mAppWidgetManager.getAppWidgetInfo(appWidgetId);
if (gadget.configure != null) {
// Launch over to configure gadget, if needed
Intent intent = new Intent(GadgetManager.ACTION_GADGET_CONFIGURE);
intent.setComponent(gadget.configure);
intent.putExtra(GadgetManager.EXTRA_GADGET_ID, gadgetId);
if (appWidget.configure != null) {
// Launch over to configure widget, if needed
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
intent.setComponent(appWidget.configure);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
startActivityForResult(intent, REQUEST_CREATE_GADGET);
startActivityForResult(intent, REQUEST_CREATE_APPWIDGET);
} else {
// Otherwise just add it
onActivityResult(REQUEST_CREATE_GADGET, Activity.RESULT_OK, data);
onActivityResult(REQUEST_CREATE_APPWIDGET, Activity.RESULT_OK, data);
}
}
@ -1169,8 +1176,8 @@ public final class Launcher extends Activity implements View.OnClickListener, On
*/
private void bindDesktopItems() {
final ArrayList<ItemInfo> shortcuts = sModel.getDesktopItems();
final ArrayList<LauncherGadgetInfo> gadgets = sModel.getDesktopGadgets();
if (shortcuts == null || gadgets == null) {
final ArrayList<LauncherAppWidgetInfo> appWidgets = sModel.getDesktopAppWidgets();
if (shortcuts == null || appWidgets == null) {
return;
}
@ -1192,7 +1199,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On
});
}
final DesktopBinder binder = new DesktopBinder(this, shortcuts, gadgets);
final DesktopBinder binder = new DesktopBinder(this, shortcuts, appWidgets);
binder.startBindingItems();
}
@ -1246,7 +1253,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On
if (end >= count) {
finishBindDesktopItems();
binder.startBindingGadgets();
binder.startBindingAppWidgets();
} else {
binder.obtainMessage(DesktopBinder.MESSAGE_BIND_ITEMS, i, count).sendToTarget();
}
@ -1293,25 +1300,25 @@ public final class Launcher extends Activity implements View.OnClickListener, On
mDrawer.unlock();
}
private void bindGadgets(Launcher.DesktopBinder binder,
ArrayList<LauncherGadgetInfo> gadgets, int start, int count) {
private void bindAppWidgets(Launcher.DesktopBinder binder,
ArrayList<LauncherAppWidgetInfo> appWidgets, int start, int count) {
final Workspace workspace = mWorkspace;
final boolean desktopLocked = mDesktopLocked;
final int end = Math.min(start + DesktopBinder.GADGETS_COUNT, count);
final int end = Math.min(start + DesktopBinder.APPWIDGETS_COUNT, count);
int i = start;
for ( ; i < end; i++) {
final LauncherGadgetInfo item = gadgets.get(i);
final LauncherAppWidgetInfo item = appWidgets.get(i);
final int gadgetId = item.gadgetId;
final GadgetProviderInfo gadgetInfo = mGadgetManager.getGadgetInfo(gadgetId);
item.hostView = mGadgetHost.createView(this, gadgetId, gadgetInfo);
final int appWidgetId = item.appWidgetId;
final AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appWidgetId);
item.hostView = mAppWidgetHost.createView(this, appWidgetId, appWidgetInfo);
if (LOGD) Log.d(LOG_TAG, String.format("about to setGadget for id=%d, info=%s", gadgetId, gadgetInfo));
if (LOGD) Log.d(LOG_TAG, String.format("about to setAppWidget for id=%d, info=%s", appWidgetId, appWidgetInfo));
item.hostView.setGadget(gadgetId, gadgetInfo);
item.hostView.setAppWidget(appWidgetId, appWidgetInfo);
item.hostView.setTag(item);
workspace.addInScreen(item.hostView, item.screen, item.cellX,
@ -1321,13 +1328,13 @@ public final class Launcher extends Activity implements View.OnClickListener, On
workspace.requestLayout();
if (end >= count) {
finishBindDesktopGadgets();
finishBindDesktopAppWidgets();
} else {
binder.obtainMessage(DesktopBinder.MESSAGE_BIND_GADGETS, i, count).sendToTarget();
binder.obtainMessage(DesktopBinder.MESSAGE_BIND_APPWIDGETS, i, count).sendToTarget();
}
}
private void finishBindDesktopGadgets() {
private void finishBindDesktopAppWidgets() {
}
DragController getDragController() {
@ -1480,6 +1487,10 @@ public final class Launcher extends Activity implements View.OnClickListener, On
mDrawer.close();
}
View getDrawerHandle() {
return mHandleView;
}
boolean isDrawerDown() {
return !mDrawer.isMoving() && !mDrawer.isOpened();
}
@ -1488,6 +1499,10 @@ public final class Launcher extends Activity implements View.OnClickListener, On
return mDrawer.isOpened() && !mDrawer.isMoving();
}
boolean isDrawerMoving() {
return mDrawer.isMoving();
}
Workspace getWorkspace() {
return mWorkspace;
}
@ -1686,12 +1701,12 @@ public final class Launcher extends Activity implements View.OnClickListener, On
break;
}
case AddAdapter.ITEM_GADGET: {
int gadgetId = Launcher.this.mGadgetHost.allocateGadgetId();
case AddAdapter.ITEM_APPWIDGET: {
int appWidgetId = Launcher.this.mAppWidgetHost.allocateAppWidgetId();
Intent pickIntent = new Intent(GadgetManager.ACTION_GADGET_PICK);
pickIntent.putExtra(GadgetManager.EXTRA_GADGET_ID, gadgetId);
startActivityForResult(pickIntent, REQUEST_PICK_GADGET);
Intent pickIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_PICK);
pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
startActivityForResult(pickIntent, REQUEST_PICK_APPWIDGET);
break;
}
@ -1805,18 +1820,21 @@ public final class Launcher extends Activity implements View.OnClickListener, On
public void onDrawerOpened() {
if (!mOpen) {
mHandleIcon.reverseTransition(150);
final Rect bounds = mWorkspace.mDrawerBounds;
View view = mAllAppsGrid;
final Rect bounds = mWorkspace.mDrawerBounds;
offsetBoundsToDragLayer(bounds, mAllAppsGrid);
mOpen = true;
}
}
private void offsetBoundsToDragLayer(Rect bounds, View view) {
view.getDrawingRect(bounds);
while (view != mDragLayer) {
bounds.offset(view.getLeft(), view.getTop());
view = (View) view.getParent();
}
mOpen = true;
}
}
public void onDrawerClosed() {
@ -1825,42 +1843,52 @@ public final class Launcher extends Activity implements View.OnClickListener, On
mWorkspace.mDrawerBounds.setEmpty();
mOpen = false;
}
mAllAppsGrid.setSelection(0);
mAllAppsGrid.clearTextFilter();
}
public void onScrollStarted() {
if (PROFILE_DRAWER) {
android.os.Debug.startMethodTracing("/sdcard/launcher-drawer");
}
mWorkspace.mDrawerContentWidth = mAllAppsGrid.getWidth();
mWorkspace.mDrawerContentHeight = mAllAppsGrid.getHeight();
}
public void onScrollEnded() {
if (PROFILE_DRAWER) {
android.os.Debug.stopMethodTracing();
}
}
}
private static class DesktopBinder extends Handler {
static final int MESSAGE_BIND_ITEMS = 0x1;
static final int MESSAGE_BIND_GADGETS = 0x2;
static final int MESSAGE_BIND_APPWIDGETS = 0x2;
// Number of items to bind in every pass
static final int ITEMS_COUNT = 6;
static final int GADGETS_COUNT = 1;
static final int APPWIDGETS_COUNT = 1;
private final ArrayList<ItemInfo> mShortcuts;
private final ArrayList<LauncherGadgetInfo> mGadgets;
private final ArrayList<LauncherAppWidgetInfo> mAppWidgets;
private final WeakReference<Launcher> mLauncher;
DesktopBinder(Launcher launcher, ArrayList<ItemInfo> shortcuts,
ArrayList<LauncherGadgetInfo> gadgets) {
ArrayList<LauncherAppWidgetInfo> appWidgets) {
mLauncher = new WeakReference<Launcher>(launcher);
mShortcuts = shortcuts;
mGadgets = gadgets;
mAppWidgets = appWidgets;
}
public void startBindingItems() {
obtainMessage(MESSAGE_BIND_ITEMS, 0, mShortcuts.size()).sendToTarget();
}
public void startBindingGadgets() {
obtainMessage(MESSAGE_BIND_GADGETS, 0, mGadgets.size()).sendToTarget();
public void startBindingAppWidgets() {
obtainMessage(MESSAGE_BIND_APPWIDGETS, 0, mAppWidgets.size()).sendToTarget();
}
@Override
@ -1875,8 +1903,8 @@ public final class Launcher extends Activity implements View.OnClickListener, On
launcher.bindItems(this, mShortcuts, msg.arg1, msg.arg2);
break;
}
case MESSAGE_BIND_GADGETS: {
launcher.bindGadgets(this, mGadgets, msg.arg1, msg.arg2);
case MESSAGE_BIND_APPWIDGETS: {
launcher.bindAppWidgets(this, mAppWidgets, msg.arg1, msg.arg2);
break;
}
}

View File

@ -16,23 +16,24 @@
package com.android.launcher;
import android.appwidget.AppWidgetHost;
import android.appwidget.AppWidgetHostView;
import android.appwidget.AppWidgetProviderInfo;
import android.content.Context;
import android.gadget.GadgetHost;
import android.gadget.GadgetHostView;
import android.gadget.GadgetProviderInfo;
/**
* Specific {@link GadgetHost} that creates our {@link LauncherGadgetHostView}
* Specific {@link AppWidgetHost} that creates our {@link LauncherAppWidgetHostView}
* which correctly captures all long-press events. This ensures that users can
* always pick up and move gadgets.
* always pick up and move widgets.
*/
public class LauncherGadgetHost extends GadgetHost {
public LauncherGadgetHost(Context context, int hostId) {
public class LauncherAppWidgetHost extends AppWidgetHost {
public LauncherAppWidgetHost(Context context, int hostId) {
super(context, hostId);
}
protected GadgetHostView onCreateView(Context context, int gadgetId,
GadgetProviderInfo gadget) {
return new LauncherGadgetHostView(context);
@Override
protected AppWidgetHostView onCreateView(Context context, int appWidgetId,
AppWidgetProviderInfo appWidget) {
return new LauncherAppWidgetHostView(context);
}
}

View File

@ -16,8 +16,8 @@
package com.android.launcher;
import android.appwidget.AppWidgetHostView;
import android.content.Context;
import android.gadget.GadgetHostView;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
@ -26,21 +26,21 @@ import android.view.ViewConfiguration;
/**
* {@inheritDoc}
*/
public class LauncherGadgetHostView extends GadgetHostView {
public class LauncherAppWidgetHostView extends AppWidgetHostView {
private boolean mHasPerformedLongPress;
private CheckForLongPress mPendingCheckForLongPress;
private LayoutInflater mInflater;
public LauncherGadgetHostView(Context context) {
public LauncherAppWidgetHostView(Context context) {
super(context);
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
protected View getErrorView() {
return mInflater.inflate(R.layout.gadget_error, this, false);
return mInflater.inflate(R.layout.appwidget_error, this, false);
}
public boolean onInterceptTouchEvent(MotionEvent ev) {
@ -51,7 +51,7 @@ public class LauncherGadgetHostView extends GadgetHostView {
}
// Watch for longpress events at this level to make sure
// users can always pick up this Gadget
// users can always pick up this widget
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN: {
postCheckForLongClick();

View File

@ -16,38 +16,38 @@
package com.android.launcher;
import android.appwidget.AppWidgetHostView;
import android.content.ContentValues;
import android.gadget.GadgetHostView;
/**
* Represents a gadget, which just contains an identifier.
* Represents a widget, which just contains an identifier.
*/
class LauncherGadgetInfo extends ItemInfo {
class LauncherAppWidgetInfo extends ItemInfo {
/**
* Identifier for this gadget when talking with {@link GadgetManager} for updates.
* Identifier for this widget when talking with {@link AppWidgetManager} for updates.
*/
int gadgetId;
int appWidgetId;
/**
* View that holds this gadget after it's been created. This view isn't created
* View that holds this widget after it's been created. This view isn't created
* until Launcher knows it's needed.
*/
GadgetHostView hostView = null;
AppWidgetHostView hostView = null;
LauncherGadgetInfo(int gadgetId) {
itemType = LauncherSettings.Favorites.ITEM_TYPE_GADGET;
this.gadgetId = gadgetId;
LauncherAppWidgetInfo(int appWidgetId) {
itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET;
this.appWidgetId = appWidgetId;
}
@Override
void onAddToDatabase(ContentValues values) {
super.onAddToDatabase(values);
values.put(LauncherSettings.Favorites.GADGET_ID, gadgetId);
values.put(LauncherSettings.Favorites.APPWIDGET_ID, appWidgetId);
}
@Override
public String toString() {
return Integer.toString(gadgetId);
return Integer.toString(appWidgetId);
}
}

View File

@ -28,13 +28,11 @@ import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.util.Log;
import android.os.Process;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Comparator;
@ -55,13 +53,13 @@ public class LauncherModel {
private static final boolean DEBUG = false;
private final Collator sCollator = Collator.getInstance();
private static final Collator sCollator = Collator.getInstance();
private boolean mApplicationsLoaded;
private boolean mDesktopItemsLoaded;
private ArrayList<ItemInfo> mDesktopItems;
private ArrayList<LauncherGadgetInfo> mDesktopGadgets;
private ArrayList<LauncherAppWidgetInfo> mDesktopAppWidgets;
private HashMap<Long, FolderInfo> mFolders;
private ArrayList<ApplicationInfo> mApplications;
@ -170,14 +168,15 @@ public class LauncherModel {
final int count = apps.size();
final ApplicationsAdapter applicationList = mApplicationsAdapter;
ChangeNotifier action = new ChangeNotifier(applicationList);
final ChangeNotifier action = new ChangeNotifier(applicationList, launcher);
final HashMap<ComponentName, ApplicationInfo> appInfoCache = mAppInfoCache;
for (int i = 0; i < count && !mStopped; i++) {
ResolveInfo info = apps.get(i);
ComponentName componentName = new ComponentName(
info.activityInfo.applicationInfo.packageName,
info.activityInfo.name);
ApplicationInfo application = mAppInfoCache.get(componentName);
ApplicationInfo application = appInfoCache.get(componentName);
if (application == null) {
application = new ApplicationInfo();
application.title = info.loadLabel(manager);
@ -192,21 +191,11 @@ public class LauncherModel {
if (DEBUG) {
Log.d(Launcher.LOG_TAG, "Loaded ApplicationInfo for " + componentName);
}
mAppInfoCache.put(componentName, application);
appInfoCache.put(componentName, application);
}
action.add(application);
}
action.sort(new Comparator<ApplicationInfo>() {
public final int compare(ApplicationInfo a, ApplicationInfo b) {
return sCollator.compare(a.title.toString(), b.title.toString());
}
});
if (!mStopped) {
launcher.runOnUiThread(action);
}
}
if (!mStopped) {
@ -216,42 +205,62 @@ public class LauncherModel {
}
}
private static class ChangeNotifier implements Runnable {
private static class ChangeNotifier implements Runnable, Comparator<ApplicationInfo> {
private final ApplicationsAdapter mApplicationList;
private final Launcher mLauncher;
private final ArrayList<ApplicationInfo> mBuffer;
private final Object mLock = new Object();
ChangeNotifier(ApplicationsAdapter applicationList) {
private boolean mFirst = true;
ChangeNotifier(ApplicationsAdapter applicationList, Launcher launcher) {
mApplicationList = applicationList;
mLauncher = launcher;
mBuffer = new ArrayList<ApplicationInfo>(UI_NOTIFICATION_RATE);
}
public void run() {
final ArrayList<ApplicationInfo> buffer = mBuffer;
final ApplicationsAdapter applicationList = mApplicationList;
final int count = buffer.size();
if (mFirst) {
applicationList.setNotifyOnChange(false);
applicationList.clear();
mFirst = false;
}
synchronized (mLock) {
final ArrayList<ApplicationInfo> buffer = mBuffer;
final int count = buffer.size();
for (int i = 0; i < count; i++) {
applicationList.setNotifyOnChange(false);
applicationList.add(buffer.get(i));
}
applicationList.notifyDataSetChanged();
buffer.clear();
}
void add(ApplicationInfo application) {
mBuffer.add(application);
applicationList.sort(this);
applicationList.notifyDataSetChanged();
}
void sort(Comparator<ApplicationInfo> comparator) {
Collections.sort(mBuffer, comparator);
synchronized void add(ApplicationInfo application) {
synchronized (mLock) {
final ArrayList<ApplicationInfo> buffer = mBuffer;
buffer.add(application);
if (buffer.size() >= UI_NOTIFICATION_RATE) {
mLauncher.runOnUiThread(this);
}
}
}
public final int compare(ApplicationInfo a, ApplicationInfo b) {
return sCollator.compare(a.title.toString(), b.title.toString());
}
}
boolean isDesktopLoaded() {
return mDesktopItems != null && mDesktopGadgets != null && mDesktopItemsLoaded;
return mDesktopItems != null && mDesktopAppWidgets != null && mDesktopItemsLoaded;
}
/**
@ -387,11 +396,11 @@ public class LauncherModel {
}
mDesktopItems = new ArrayList<ItemInfo>();
mDesktopGadgets = new ArrayList<LauncherGadgetInfo>();
mDesktopAppWidgets = new ArrayList<LauncherAppWidgetInfo>();
mFolders = new HashMap<Long, FolderInfo>();
final ArrayList<ItemInfo> desktopItems = mDesktopItems;
final ArrayList<LauncherGadgetInfo> desktopGadgets = mDesktopGadgets;
final ArrayList<LauncherAppWidgetInfo> desktopAppWidgets = mDesktopAppWidgets;
final Cursor c = contentResolver.query(
LauncherSettings.Favorites.CONTENT_URI, null, null, null, null);
@ -406,7 +415,7 @@ public class LauncherModel {
final int iconResourceIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.ICON_RESOURCE);
final int containerIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CONTAINER);
final int itemTypeIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.ITEM_TYPE);
final int gadgetIdIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.GADGET_ID);
final int appWidgetIdIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.APPWIDGET_ID);
final int screenIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.SCREEN);
final int cellXIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CELLX);
final int cellYIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CELLY);
@ -418,7 +427,7 @@ public class LauncherModel {
ApplicationInfo info;
String intentDescription;
Widget widgetInfo;
LauncherGadgetInfo gadgetInfo;
LauncherAppWidgetInfo appWidgetInfo;
int container;
long id;
Intent intent;
@ -548,26 +557,26 @@ public class LauncherModel {
desktopItems.add(widgetInfo);
break;
case LauncherSettings.Favorites.ITEM_TYPE_GADGET:
// Read all Launcher-specific gadget details
int gadgetId = c.getInt(gadgetIdIndex);
gadgetInfo = new LauncherGadgetInfo(gadgetId);
gadgetInfo.id = c.getLong(idIndex);
gadgetInfo.screen = c.getInt(screenIndex);
gadgetInfo.cellX = c.getInt(cellXIndex);
gadgetInfo.cellY = c.getInt(cellYIndex);
gadgetInfo.spanX = c.getInt(spanXIndex);
gadgetInfo.spanY = c.getInt(spanYIndex);
case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
// Read all Launcher-specific widget details
int appWidgetId = c.getInt(appWidgetIdIndex);
appWidgetInfo = new LauncherAppWidgetInfo(appWidgetId);
appWidgetInfo.id = c.getLong(idIndex);
appWidgetInfo.screen = c.getInt(screenIndex);
appWidgetInfo.cellX = c.getInt(cellXIndex);
appWidgetInfo.cellY = c.getInt(cellYIndex);
appWidgetInfo.spanX = c.getInt(spanXIndex);
appWidgetInfo.spanY = c.getInt(spanYIndex);
container = c.getInt(containerIndex);
if (container != LauncherSettings.Favorites.CONTAINER_DESKTOP) {
Log.e(Launcher.LOG_TAG, "Gadget found where container "
Log.e(Launcher.LOG_TAG, "Widget found where container "
+ "!= CONTAINER_DESKTOP -- ignoring!");
continue;
}
gadgetInfo.container = c.getInt(containerIndex);
appWidgetInfo.container = c.getInt(containerIndex);
desktopGadgets.add(gadgetInfo);
desktopAppWidgets.add(appWidgetInfo);
break;
}
} catch (Exception e) {
@ -674,7 +683,7 @@ public class LauncherModel {
mApplicationsAdapter = null;
unbindAppDrawables(mApplications);
unbindDrawables(mDesktopItems);
unbindGadgetHostViews(mDesktopGadgets);
unbindAppWidgetHostViews(mDesktopAppWidgets);
unbindCachedIconDrawables();
}
@ -711,13 +720,13 @@ public class LauncherModel {
}
/**
* Remove any {@link LauncherGadgetHostView} references in our gadgets.
* Remove any {@link LauncherAppWidgetHostView} references in our widgets.
*/
private void unbindGadgetHostViews(ArrayList<LauncherGadgetInfo> gadgets) {
if (gadgets != null) {
final int count = gadgets.size();
private void unbindAppWidgetHostViews(ArrayList<LauncherAppWidgetInfo> appWidgets) {
if (appWidgets != null) {
final int count = appWidgets.size();
for (int i = 0; i < count; i++) {
LauncherGadgetInfo launcherInfo = gadgets.get(i);
LauncherAppWidgetInfo launcherInfo = appWidgets.get(i);
launcherInfo.hostView = null;
}
}
@ -757,8 +766,8 @@ public class LauncherModel {
/**
* @return The current list of desktop items
*/
public ArrayList<LauncherGadgetInfo> getDesktopGadgets() {
return mDesktopGadgets;
public ArrayList<LauncherAppWidgetInfo> getDesktopAppWidgets() {
return mDesktopAppWidgets;
}
/**
@ -780,17 +789,17 @@ public class LauncherModel {
}
/**
* Add a gadget to the desktop
* Add a widget to the desktop
*/
public void addDesktopGadget(LauncherGadgetInfo info) {
mDesktopGadgets.add(info);
public void addDesktopAppWidget(LauncherAppWidgetInfo info) {
mDesktopAppWidgets.add(info);
}
/**
* Remove a gadget from the desktop
* Remove a widget from the desktop
*/
public void removeDesktopGadget(LauncherGadgetInfo info) {
mDesktopGadgets.remove(info);
public void removeDesktopAppWidget(LauncherAppWidgetInfo info) {
mDesktopAppWidgets.remove(info);
}
/**

View File

@ -16,6 +16,7 @@
package com.android.launcher;
import android.appwidget.AppWidgetHost;
import android.content.ContentProvider;
import android.content.Context;
import android.content.ContentValues;
@ -30,7 +31,6 @@ import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteQueryBuilder;
import android.database.Cursor;
import android.database.SQLException;
import android.gadget.GadgetHost;
import android.util.Log;
import android.util.Xml;
import android.net.Uri;
@ -177,12 +177,12 @@ public class LauncherProvider extends ContentProvider {
private static final String ATTRIBUTE_Y = "y";
private final Context mContext;
private final GadgetHost mGadgetHost;
private final AppWidgetHost mAppWidgetHost;
DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
mContext = context;
mGadgetHost = new GadgetHost(context, Launcher.GADGET_HOST_ID);
mAppWidgetHost = new AppWidgetHost(context, Launcher.APPWIDGET_HOST_ID);
}
@Override
@ -210,9 +210,9 @@ public class LauncherProvider extends ContentProvider {
"displayMode INTEGER" +
");");
// Database was just created, so wipe any previous gadgets
if (mGadgetHost != null) {
mGadgetHost.deleteHost();
// Database was just created, so wipe any previous widgets
if (mAppWidgetHost != null) {
mAppWidgetHost.deleteHost();
}
if (!convertDatabase(db)) {
@ -250,7 +250,7 @@ public class LauncherProvider extends ContentProvider {
}
if (converted) {
// Convert widgets from this import into gadgets
// Convert widgets from this import into widgets
if (LOGD) Log.d(LOG_TAG, "converted and now triggering widget upgrade");
convertWidgets(db);
}
@ -287,7 +287,7 @@ public class LauncherProvider extends ContentProvider {
values.put(LauncherSettings.Favorites.ICON_RESOURCE, c.getString(iconResourceIndex));
values.put(LauncherSettings.Favorites.CONTAINER, c.getInt(containerIndex));
values.put(LauncherSettings.Favorites.ITEM_TYPE, c.getInt(itemTypeIndex));
values.put(LauncherSettings.Favorites.GADGET_ID, -1);
values.put(LauncherSettings.Favorites.APPWIDGET_ID, -1);
values.put(LauncherSettings.Favorites.SCREEN, c.getInt(screenIndex));
values.put(LauncherSettings.Favorites.CELLX, c.getInt(cellXIndex));
values.put(LauncherSettings.Favorites.CELLY, c.getInt(cellYIndex));
@ -321,10 +321,10 @@ public class LauncherProvider extends ContentProvider {
int version = oldVersion;
if (version == 1) {
// upgrade 1 -> 2 added gadgetId column
// upgrade 1 -> 2 added appWidgetId column
db.beginTransaction();
try {
// Insert new column for holding gadgetIds
// Insert new column for holding appWidgetIds
db.execSQL("ALTER TABLE favorites " +
"ADD COLUMN gadgetId INTEGER NOT NULL DEFAULT -1;");
db.setTransactionSuccessful();
@ -350,9 +350,9 @@ public class LauncherProvider extends ContentProvider {
}
/**
* Upgrade existing clock and photo frame widgets into their new gadget
* equivalents. This method allocates gadgetIds, and then hands off to
* LauncherGadgetBinder to finish the actual binding.
* Upgrade existing clock and photo frame widgets into their new widget
* equivalents. This method allocates appWidgetIds, and then hands off to
* LauncherAppWidgetBinder to finish the actual binding.
*/
private void convertWidgets(SQLiteDatabase db) {
final int[] bindSources = new int[] {
@ -362,14 +362,14 @@ public class LauncherProvider extends ContentProvider {
final ArrayList<ComponentName> bindTargets = new ArrayList<ComponentName>();
bindTargets.add(new ComponentName("com.android.alarmclock",
"com.android.alarmclock.AnalogGadgetProvider"));
"com.android.alarmclock.AnalogAppWidgetProvider"));
bindTargets.add(new ComponentName("com.android.camera",
"com.android.camera.PhotoGadgetProvider"));
"com.android.camera.PhotoAppWidgetProvider"));
final String selectWhere = buildOrWhereString(Favorites.ITEM_TYPE, bindSources);
Cursor c = null;
boolean allocatedGadgets = false;
boolean allocatedAppWidgets = false;
db.beginTransaction();
try {
@ -383,14 +383,14 @@ public class LauncherProvider extends ContentProvider {
while (c != null && c.moveToNext()) {
long favoriteId = c.getLong(0);
// Allocate and update database with new gadgetId
// Allocate and update database with new appWidgetId
try {
int gadgetId = mGadgetHost.allocateGadgetId();
int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
if (LOGD) Log.d(LOG_TAG, "allocated gadgetId="+gadgetId+" for favoriteId="+favoriteId);
if (LOGD) Log.d(LOG_TAG, "allocated appWidgetId="+appWidgetId+" for favoriteId="+favoriteId);
values.clear();
values.put(LauncherSettings.Favorites.GADGET_ID, gadgetId);
values.put(LauncherSettings.Favorites.APPWIDGET_ID, appWidgetId);
// Original widgets might not have valid spans when upgrading
values.put(LauncherSettings.Favorites.SPANX, 2);
@ -399,15 +399,15 @@ public class LauncherProvider extends ContentProvider {
String updateWhere = Favorites._ID + "=" + favoriteId;
db.update(TABLE_FAVORITES, values, updateWhere, null);
allocatedGadgets = true;
allocatedAppWidgets = true;
} catch (RuntimeException ex) {
Log.e(LOG_TAG, "Problem allocating gadgetId", ex);
Log.e(LOG_TAG, "Problem allocating appWidgetId", ex);
}
}
db.setTransactionSuccessful();
} catch (SQLException ex) {
Log.w(LOG_TAG, "Problem while allocating gadgetIds for existing widgets", ex);
Log.w(LOG_TAG, "Problem while allocating appWidgetIds for existing widgets", ex);
} finally {
db.endTransaction();
if (c != null) {
@ -415,22 +415,22 @@ public class LauncherProvider extends ContentProvider {
}
}
// If any gadgetIds allocated, then launch over to binder
if (allocatedGadgets) {
launchGadgetBinder(bindSources, bindTargets);
// If any appWidgetIds allocated, then launch over to binder
if (allocatedAppWidgets) {
launchAppWidgetBinder(bindSources, bindTargets);
}
}
/**
* Launch the gadget binder that walks through the Launcher database,
* Launch the widget binder that walks through the Launcher database,
* binding any matching widgets to the corresponding targets. We can't
* bind ourselves because our parent process can't obtain the
* BIND_GADGET permission.
* BIND_APPWIDGET permission.
*/
private void launchGadgetBinder(int[] bindSources, ArrayList<ComponentName> bindTargets) {
private void launchAppWidgetBinder(int[] bindSources, ArrayList<ComponentName> bindTargets) {
final Intent intent = new Intent();
intent.setComponent(new ComponentName("com.android.settings",
"com.android.settings.LauncherGadgetBinder"));
"com.android.settings.LauncherAppWidgetBinder"));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
final Bundle extras = new Bundle();
@ -533,13 +533,13 @@ public class LauncherProvider extends ContentProvider {
final ArrayList<ComponentName> bindTargets = new ArrayList<ComponentName>();
bindTargets.add(new ComponentName("com.android.alarmclock",
"com.android.alarmclock.AnalogGadgetProvider"));
"com.android.alarmclock.AnalogAppWidgetProvider"));
boolean allocatedGadgets = false;
boolean allocatedAppWidgets = false;
// Try binding to an analog clock gadget
// Try binding to an analog clock widget
try {
int gadgetId = mGadgetHost.allocateGadgetId();
int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
values.clear();
values.put(LauncherSettings.Favorites.CONTAINER,
@ -551,17 +551,17 @@ public class LauncherProvider extends ContentProvider {
values.put(LauncherSettings.Favorites.CELLY, 0);
values.put(LauncherSettings.Favorites.SPANX, 2);
values.put(LauncherSettings.Favorites.SPANY, 2);
values.put(LauncherSettings.Favorites.GADGET_ID, gadgetId);
values.put(LauncherSettings.Favorites.APPWIDGET_ID, appWidgetId);
db.insert(TABLE_FAVORITES, null, values);
allocatedGadgets = true;
allocatedAppWidgets = true;
} catch (RuntimeException ex) {
Log.e(LOG_TAG, "Problem allocating gadgetId", ex);
Log.e(LOG_TAG, "Problem allocating appWidgetId", ex);
}
// If any gadgetIds allocated, then launch over to binder
if (allocatedGadgets) {
launchGadgetBinder(bindSources, bindTargets);
// If any appWidgetIds allocated, then launch over to binder
if (allocatedAppWidgets) {
launchAppWidgetBinder(bindSources, bindTargets);
}
return i;

View File

@ -25,7 +25,7 @@ import android.net.Uri;
class LauncherSettings {
/**
* Favorites. When changing these values, be sure to update
* {@link com.android.settings.LauncherGadgetBinder} as needed.
* {@link com.android.settings.LauncherAppWidgetBinder} as needed.
*/
static final class Favorites implements BaseColumns {
/**
@ -148,9 +148,9 @@ class LauncherSettings {
static final int ITEM_TYPE_LIVE_FOLDER = 3;
/**
* The favorite is a gadget
* The favorite is a widget
*/
static final int ITEM_TYPE_GADGET = 4;
static final int ITEM_TYPE_APPWIDGET = 4;
/**
* The favorite is a clock
@ -168,11 +168,11 @@ class LauncherSettings {
static final int ITEM_TYPE_WIDGET_PHOTO_FRAME = 1002;
/**
* The gadgetId of the gadget
* The appWidgetId of the widget
*
* <P>Type: INTEGER</P>
*/
static final String GADGET_ID = "gadgetId";
static final String APPWIDGET_ID = "gadgetId";
/**
* Indicates whether this favorite is an application-created shortcut or not.

View File

@ -60,7 +60,7 @@ import android.widget.AdapterView.OnItemSelectedListener;
public class Search extends LinearLayout implements OnClickListener, OnKeyListener,
OnLongClickListener, TextWatcher, OnItemClickListener, OnItemSelectedListener {
private final String TAG = "SearchGadget";
private final String TAG = "SearchWidget";
private AutoCompleteTextView mSearchText;
private ImageButton mGoButton;

View File

@ -25,6 +25,7 @@ import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Rect;
import android.graphics.Region;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.VelocityTracker;
@ -95,6 +96,8 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
final Rect mDrawerBounds = new Rect();
final Rect mClipBounds = new Rect();
int mDrawerContentHeight;
int mDrawerContentWidth;
/**
* Used to inflate the Workspace from XML.
@ -442,6 +445,8 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
@Override
protected void dispatchDraw(Canvas canvas) {
boolean restore = false;
// If the all apps drawer is open and the drawing region for the workspace
// is contained within the drawer's bounds, we skip the drawing. This requires
// the drawer to be fully opaque.
@ -452,6 +457,15 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
if (mDrawerBounds.contains(clipBounds)) {
return;
}
} else if (mLauncher.isDrawerMoving()) {
restore = true;
canvas.save(Canvas.CLIP_SAVE_FLAG);
final View view = mLauncher.getDrawerHandle();
final int top = view.getTop() + view.getHeight();
canvas.clipRect(mScrollX, top, mScrollX + mDrawerContentWidth,
top + mDrawerContentHeight, Region.Op.DIFFERENCE);
}
float x = mScrollX * mWallpaperOffset;
@ -485,6 +499,10 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
}
}
}
if (restore) {
canvas.restore();
}
}
@Override
@ -1215,8 +1233,8 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
}
}
// TODO: remove gadgets when gadgetmanager tells us they're gone
// void removeGadgetsForProvider() {
// TODO: remove widgets when appwidgetmanager tells us they're gone
// void removeAppWidgetsForProvider() {
// }
void moveToDefaultScreen() {