summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AndroidManifest.xml1
-rw-r--r--res/xml/default_workspace.xml8
-rw-r--r--res/xml/update_workspace.xml37
-rw-r--r--src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java31
-rw-r--r--src/com/cyanogenmod/trebuchet/Hotseat.java42
-rw-r--r--src/com/cyanogenmod/trebuchet/ItemInfo.java14
-rw-r--r--src/com/cyanogenmod/trebuchet/Launcher.java115
-rw-r--r--src/com/cyanogenmod/trebuchet/LauncherAction.java50
-rw-r--r--src/com/cyanogenmod/trebuchet/LauncherActionInfo.java19
-rw-r--r--src/com/cyanogenmod/trebuchet/LauncherModel.java26
-rw-r--r--src/com/cyanogenmod/trebuchet/LauncherProvider.java34
-rw-r--r--src/com/cyanogenmod/trebuchet/PagedViewWidget.java12
-rw-r--r--src/com/cyanogenmod/trebuchet/PendingAddItemInfo.java7
-rw-r--r--src/com/cyanogenmod/trebuchet/Workspace.java22
14 files changed, 286 insertions, 132 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 79b539916..70e76b6f1 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -78,6 +78,7 @@
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
+ <action android:name="com.cyanogenmod.trebuchet.LAUNCHER_ACTION" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.MONKEY"/>
diff --git a/res/xml/default_workspace.xml b/res/xml/default_workspace.xml
index 4c50d8481..2feb09fca 100644
--- a/res/xml/default_workspace.xml
+++ b/res/xml/default_workspace.xml
@@ -74,6 +74,14 @@
launcher:screen="1"
launcher:x="1"
launcher:y="0" />
+ <shortcut
+ launcher:container="-101"
+ launcher:screen="2"
+ launcher:x="2"
+ launcher:y="0"
+ launcher:icon="@drawable/ic_allapps"
+ launcher:title="@string/all_apps_button_label"
+ launcher:uri="#Intent;action=com.cyanogenmod.trebuchet.LAUNCHER_ACTION;category=android.intent.category.HOME;launchFlags=0x10200000;component=com.cyanogenmod.trebuchet/com.cyanogenmod.trebuchet.Launcher;S.android.intent.extra.TEXT=AllApps;end" />
<favorite
launcher:packageName="com.android.mms"
launcher:className="com.android.mms.ui.ConversationList"
diff --git a/res/xml/update_workspace.xml b/res/xml/update_workspace.xml
index 5c2547988..768d3ba6b 100644
--- a/res/xml/update_workspace.xml
+++ b/res/xml/update_workspace.xml
@@ -15,35 +15,14 @@
-->
<favorites xmlns:launcher="http://schemas.android.com/apk/res/com.cyanogenmod.trebuchet">
- <!-- Update the db with new hotseat items. Note that we reference the browser's original
- package name. -->
+ <!-- Update the db with new hotseat all apps button. -->
<!-- Hotseat (We use the screen as the position of the item in the hotseat) -->
- <favorite
- launcher:packageName="com.android.contacts"
- launcher:className="com.android.contacts.activities.DialtactsActivity"
+ <shortcut
launcher:container="-101"
- launcher:screen="0"
- launcher:x="0"
- launcher:y="0" />
- <favorite
- launcher:packageName="com.android.contacts"
- launcher:className="com.android.contacts.activities.PeopleActivity"
- launcher:container="-101"
- launcher:screen="1"
- launcher:x="1"
- launcher:y="0" />
- <favorite
- launcher:packageName="com.android.mms"
- launcher:className="com.android.mms.ui.ConversationList"
- launcher:container="-101"
- launcher:screen="3"
- launcher:x="3"
- launcher:y="0" />
- <favorite
- launcher:packageName="com.android.browser"
- launcher:className="com.android.browser.BrowserActivity"
- launcher:container="-101"
- launcher:screen="4"
- launcher:x="4"
- launcher:y="0" />
+ launcher:screen="2"
+ launcher:x="2"
+ launcher:y="0"
+ launcher:icon="@drawable/ic_allapps"
+ launcher:title="@string/all_apps_button_label"
+ launcher:uri="#Intent;action=com.cyanogenmod.trebuchet.LAUNCHER_ACTION;category=android.intent.category.HOME;launchFlags=0x10200000;component=com.cyanogenmod.trebuchet/com.cyanogenmod.trebuchet.Launcher;S.android.intent.extra.TEXT=AllApps;end" />
</favorites>
diff --git a/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java b/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
index 070bfed0a..e4bb84ab9 100644
--- a/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
+++ b/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
@@ -658,6 +658,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
AppWidgetManager.getInstance(mLauncher).getInstalledProviders();
Intent shortcutsIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
List<ResolveInfo> shortcuts = mPackageManager.queryIntentActivities(shortcutsIntent, 0);
+ List<LauncherActionInfo> launcherActions = LauncherAction.getAllActions(mLauncher);
for (AppWidgetProviderInfo widget : widgets) {
if (widget.minWidth > 0 && widget.minHeight > 0) {
// Ensure that all widgets we show can be added on a workspace of this size
@@ -678,6 +679,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
}
mWidgets.addAll(shortcuts);
+ mWidgets.addAll(launcherActions);
Collections.sort(mWidgets,
new LauncherModel.WidgetAndShortcutNameComparator(mPackageManager));
updatePageCounts();
@@ -1438,9 +1440,21 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
return preview;
}
- private Bitmap getWidgetPreview(ComponentName provider, int previewImage,
- int iconId, int cellHSpan, int cellVSpan, int maxWidth,
- int maxHeight) {
+ private Bitmap getShortcutPreview(LauncherActionInfo info) {
+ int offset = 0;
+ int bitmapSize = mAppIconSize;
+ Bitmap preview = Bitmap.createBitmap(bitmapSize, bitmapSize, Config.ARGB_8888);
+
+ final Resources res = getContext().getResources();
+
+ // Render the icon
+ Drawable icon = res.getDrawable(info.drawable);
+ renderDrawableToBitmap(icon, preview, offset, offset, mAppIconSize, mAppIconSize);
+ return preview;
+ }
+
+ private Bitmap getWidgetPreview(ComponentName provider, int previewImage, int iconId,
+ int cellHSpan, int cellVSpan, int maxWidth, int maxHeight) {
// Load the preview image if possible
String packageName = provider.getPackageName();
if (maxWidth < 0) maxWidth = Integer.MAX_VALUE;
@@ -1611,6 +1625,14 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
info.activityInfo.name);
widget.applyFromResolveInfo(mPackageManager, info);
widget.setTag(createItemInfo);
+ } else if (rawInfo instanceof LauncherActionInfo) {
+ // Fill in the actions information
+ LauncherActionInfo info = (LauncherActionInfo) rawInfo;
+ createItemInfo = new PendingAddActionInfo();
+ ((PendingAddActionInfo)createItemInfo).action = info.action;
+ createItemInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
+ widget.applyFromLauncherActionInfo(info);
+ widget.setTag(createItemInfo);
}
widget.setOnClickListener(this);
widget.setOnLongClickListener(this);
@@ -1699,6 +1721,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// Fill in the shortcuts information
ResolveInfo info = (ResolveInfo) rawInfo;
images.add(getShortcutPreview(info, data.maxImageWidth, data.maxImageHeight));
+ } else if (rawInfo instanceof LauncherActionInfo) {
+ LauncherActionInfo info = (LauncherActionInfo) rawInfo;
+ images.add(getShortcutPreview(info));
}
}
}
diff --git a/src/com/cyanogenmod/trebuchet/Hotseat.java b/src/com/cyanogenmod/trebuchet/Hotseat.java
index 10a76235a..cc287bd41 100644
--- a/src/com/cyanogenmod/trebuchet/Hotseat.java
+++ b/src/com/cyanogenmod/trebuchet/Hotseat.java
@@ -29,9 +29,6 @@ import android.widget.FrameLayout;
import com.cyanogenmod.trebuchet.R;
public class Hotseat extends FrameLayout {
- @SuppressWarnings("unused")
- private static final String TAG = "Trebuchet.Hotseat";
-
private Launcher mLauncher;
private CellLayout mContent;
@@ -92,9 +89,6 @@ public class Hotseat extends FrameLayout {
int getCellYFromOrder(int rank) {
return hasVerticalHotseat() ? (mContent.getCountY() - (rank + 1)) : 0;
}
- public boolean isAllAppsButtonRank(int rank) {
- return rank == mAllAppsButtonRank;
- }
@Override
protected void onFinishInflate() {
@@ -110,41 +104,5 @@ public class Hotseat extends FrameLayout {
void resetLayout() {
mContent.removeAllViewsInLayout();
-
- // Add the Apps button
- Context context = getContext();
- LayoutInflater inflater = LayoutInflater.from(context);
- BubbleTextView allAppsButton = (BubbleTextView)
- inflater.inflate(R.layout.application, mContent, false);
- allAppsButton.setCompoundDrawablesWithIntrinsicBounds(null,
- context.getResources().getDrawable(R.drawable.all_apps_button_icon), null, null);
- allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label));
- allAppsButton.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- if (mLauncher != null &&
- (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
- mLauncher.onTouchDownAllAppsButton(v);
- }
- return false;
- }
- });
-
- allAppsButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(android.view.View v) {
- if (mLauncher != null) {
- mLauncher.onClickAllAppsButton(v);
- }
- }
- });
-
- // Note: We do this to ensure that the hotseat is always laid out in the orientation of
- // the hotseat in order regardless of which orientation they were added
- int x = getCellXFromOrder(mAllAppsButtonRank);
- int y = getCellYFromOrder(mAllAppsButtonRank);
- CellLayout.LayoutParams lp = new CellLayout.LayoutParams(x,y,1,1);
- lp.canReorder = false;
- mContent.addViewToCellLayout(allAppsButton, -1, 0, lp, true);
}
}
diff --git a/src/com/cyanogenmod/trebuchet/ItemInfo.java b/src/com/cyanogenmod/trebuchet/ItemInfo.java
index 34c7364c8..794903ce2 100644
--- a/src/com/cyanogenmod/trebuchet/ItemInfo.java
+++ b/src/com/cyanogenmod/trebuchet/ItemInfo.java
@@ -28,14 +28,14 @@ import java.io.IOException;
* Represents an item in the launcher.
*/
class ItemInfo {
-
+
static final int NO_ID = -1;
-
+
/**
* The id in the settings database for this item
*/
long id = NO_ID;
-
+
/**
* One of {@link LauncherSettings.Favorites#ITEM_TYPE_APPLICATION},
* {@link LauncherSettings.Favorites#ITEM_TYPE_SHORTCUT},
@@ -43,20 +43,20 @@ class ItemInfo {
* {@link LauncherSettings.Favorites#ITEM_TYPE_APPWIDGET}.
*/
int itemType;
-
+
/**
- * The id of the container that holds this item. For the desktop, this will be
+ * The id of the container that holds this item. For the desktop, this will be
* {@link LauncherSettings.Favorites#CONTAINER_DESKTOP}. For the all applications folder it
* will be {@link #NO_ID} (since it is not stored in the settings DB). For user folders
* it will be the id of the folder.
*/
long container = NO_ID;
-
+
/**
* Iindicates the screen in which the shortcut appears.
*/
int screen = -1;
-
+
/**
* Indicates the X position of the associated cell.
*/
diff --git a/src/com/cyanogenmod/trebuchet/Launcher.java b/src/com/cyanogenmod/trebuchet/Launcher.java
index e43029d2f..5446740be 100644
--- a/src/com/cyanogenmod/trebuchet/Launcher.java
+++ b/src/com/cyanogenmod/trebuchet/Launcher.java
@@ -149,6 +149,8 @@ public final class Launcher extends Activity
static final String EXTRA_SHORTCUT_DUPLICATE = "duplicate";
+ static final String ACTION_LAUNCHER = "com.cyanogenmod.trebuchet.LAUNCHER_ACTION";
+
static final int MAX_SCREEN_COUNT = 7;
static final int DEFAULT_SCREEN = 2;
@@ -1248,6 +1250,79 @@ public final class Launcher extends Activity
resetAddInfo();
}
+ private void addAction(LauncherAction.Action action) {
+ int[] cellXY = mPendingAddInfo.dropPos;
+ int cellX = mPendingAddInfo.cellX;
+ int cellY = mPendingAddInfo.cellY;
+ long container = mPendingAddInfo.container;
+ int screen = mPendingAddInfo.screen;
+ CellLayout layout = getCellLayout(container, screen);
+
+ boolean foundCellSpan = false;
+
+ Intent data = createActionIntent(action);
+
+ ShortcutInfo info = mModel.infoFromShortcutIntent(this, data, null);
+ if (info == null) {
+ return;
+ }
+ final View view = createShortcut(info);
+
+ if (cellX >= 0 && cellY >= 0) {
+ if (cellXY == null) {
+ cellXY = new int[2];
+ }
+ cellXY[0] = cellX;
+ cellXY[1] = cellY;
+
+ foundCellSpan = true;
+
+ // If appropriate, either create a folder or add to an existing folder
+ if (mWorkspace.createUserFolderIfNecessary(view, container, layout, cellXY, 0,
+ true, null,null)) {
+ return;
+ }
+ DragObject dragObject = new DragObject();
+ dragObject.dragInfo = info;
+ if (mWorkspace.addToExistingFolderIfNecessary(view, layout, cellXY, 0, dragObject,
+ true)) {
+ return;
+ }
+ } else if (cellXY != null) {
+ // when dragging and dropping, just find the closest free spot
+ int[] result = layout.findNearestVacantArea(cellXY[0], cellXY[1], 1, 1, cellXY);
+ foundCellSpan = (result != null);
+ } else {
+ foundCellSpan = layout.findCellForSpan(cellXY, 1, 1);
+ }
+
+ if (!foundCellSpan) {
+ showOutOfSpaceMessage(isHotseatLayout(layout));
+ return;
+ }
+
+ LauncherModel.addItemToDatabase(this, info, container, screen, cellXY[0], cellXY[1], false);
+
+ if (!mRestoring) {
+ mWorkspace.addInScreen(view, container, screen, cellXY[0], cellXY[1], 1, 1,
+ isWorkspaceLocked());
+ }
+ }
+
+ private Intent createActionIntent(LauncherAction.Action action) {
+ Intent data = new Intent(Intent.ACTION_MAIN);
+ Intent intent = new Intent(ACTION_LAUNCHER);
+ intent.addCategory(Intent.CATEGORY_HOME);
+ intent.setClassName(this, this.getClass().getName());
+ intent.putExtra(Intent.EXTRA_TEXT, action.toString());
+ data.putExtra(Intent.EXTRA_SHORTCUT_NAME,
+ getResources().getString(LauncherAction.Action.getString(action)));
+ data.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
+ data.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
+ Intent.ShortcutIconResource.fromContext(this, LauncherAction.Action.getDrawable(action)));
+ return data;
+ }
+
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@@ -1480,6 +1555,18 @@ public final class Launcher extends Activity
processIntent.run();
}
+ } else if (ACTION_LAUNCHER.equals(intent.getAction())) {
+ Bundle extras = intent.getExtras();
+ if (extras == null) {
+ return;
+ }
+ String actionString = extras.getString(Intent.EXTRA_TEXT);
+ LauncherAction.Action action = LauncherAction.Action.valueOf(actionString);
+ switch (action) {
+ case AllApps:
+ showAllApps(true);
+ break;
+ }
}
}
@@ -1760,6 +1847,30 @@ public final class Launcher extends Activity
}
/**
+ * Process action from drop.
+ *
+ * @param action The launcher action
+ * @param screen The screen where it should be added
+ * @param cell The cell it should be added to, optional
+ * @param position The location on the screen where it was dropped, optional
+ */
+ void processActionFromDrop(LauncherAction.Action action, long container, int screen,
+ int[] cell, int[] loc) {
+ resetAddInfo();
+ mPendingAddInfo.container = container;
+ mPendingAddInfo.screen = screen;
+ mPendingAddInfo.dropPos = loc;
+
+ if (cell != null) {
+ mPendingAddInfo.cellX = cell[0];
+ mPendingAddInfo.cellY = cell[1];
+ }
+
+ addAction(action);
+ exitSpringLoadedDragModeDelayed(true, true, null);
+ }
+
+ /**
* Process a shortcut drop.
*
* @param componentName The name of the component
@@ -2472,10 +2583,6 @@ public final class Launcher extends Activity
return (mState == State.APPS_CUSTOMIZE) || (mOnResumeState == State.APPS_CUSTOMIZE);
}
- public boolean isAllAppsButtonRank(int rank) {
- return mHotseat.isAllAppsButtonRank(rank);
- }
-
/**
* Helper method for the cameraZoomIn/cameraZoomOut animations
* @param view The view being animated
diff --git a/src/com/cyanogenmod/trebuchet/LauncherAction.java b/src/com/cyanogenmod/trebuchet/LauncherAction.java
new file mode 100644
index 000000000..04f9bdfcd
--- /dev/null
+++ b/src/com/cyanogenmod/trebuchet/LauncherAction.java
@@ -0,0 +1,50 @@
+package com.cyanogenmod.trebuchet;
+
+import android.content.Context;
+import android.content.res.Resources;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class LauncherAction {
+
+ public enum Action {
+ AllApps;
+ int getString() {
+ return getString(this);
+ }
+ int getDrawable() {
+ return getDrawable(this);
+ }
+ static int getString(Action action) {
+ switch (action) {
+ case AllApps:
+ return R.string.all_apps_button_label;
+ default:
+ return -1;
+ }
+ }
+ static int getDrawable(Action action) {
+ switch (action) {
+ case AllApps:
+ return R.drawable.ic_allapps;
+ default:
+ return -1;
+ }
+ }
+ }
+
+ public static List<LauncherActionInfo> getAllActions(Context context) {
+ List<LauncherActionInfo> actions = new ArrayList<LauncherActionInfo>();
+
+ final Resources res = context.getResources();
+
+ LauncherActionInfo allAppsAction = new LauncherActionInfo();
+ allAppsAction.action = Action.AllApps;
+ allAppsAction.drawable = Action.getDrawable(Action.AllApps);
+ allAppsAction.title = res.getString(Action.getString(Action.AllApps));
+ actions.add(allAppsAction);
+
+ return actions;
+ }
+}
diff --git a/src/com/cyanogenmod/trebuchet/LauncherActionInfo.java b/src/com/cyanogenmod/trebuchet/LauncherActionInfo.java
new file mode 100644
index 000000000..f808ebe84
--- /dev/null
+++ b/src/com/cyanogenmod/trebuchet/LauncherActionInfo.java
@@ -0,0 +1,19 @@
+package com.cyanogenmod.trebuchet;
+
+class LauncherActionInfo {
+
+ /*
+ * The launcher action
+ */
+ LauncherAction.Action action;
+
+ /*
+ * The drawable for the launcher action
+ */
+ int drawable;
+
+ /*
+ * The title for the launcher action
+ */
+ String title;
+}
diff --git a/src/com/cyanogenmod/trebuchet/LauncherModel.java b/src/com/cyanogenmod/trebuchet/LauncherModel.java
index 8fd446c9e..abdb484fd 100644
--- a/src/com/cyanogenmod/trebuchet/LauncherModel.java
+++ b/src/com/cyanogenmod/trebuchet/LauncherModel.java
@@ -159,7 +159,6 @@ public class LauncherModel extends BroadcastReceiver {
public void bindAppsRemoved(ArrayList<String> packageNames, boolean permanent);
public void bindPackagesUpdated();
public boolean isAllAppsVisible();
- public boolean isAllAppsButtonRank(int rank);
public void bindSearchablesChanged();
public void onPageBoundSynchronously(int page);
}
@@ -1174,11 +1173,6 @@ public class LauncherModel extends BroadcastReceiver {
private boolean checkItemPlacement(ItemInfo occupied[][][], ItemInfo item) {
int containerIndex = item.screen;
if (item.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
- // Return early if we detect that an item is under the hotseat button
- if (mCallbacks == null || mCallbacks.get().isAllAppsButtonRank(item.screen)) {
- return false;
- }
-
// We use the last index to refer to the hotseat and the screen as the rank, so
// test and update the occupied state accordingly
if (occupied[Launcher.MAX_SCREEN_COUNT][item.screen][0] != null) {
@@ -2533,17 +2527,25 @@ public class LauncherModel extends BroadcastReceiver {
if (mLabelCache.containsKey(a)) {
labelA = mLabelCache.get(a);
} else {
- labelA = (a instanceof AppWidgetProviderInfo) ?
- ((AppWidgetProviderInfo) a).label :
- ((ResolveInfo) a).loadLabel(mPackageManager).toString();
+ if (a instanceof AppWidgetProviderInfo) {
+ labelA = ((AppWidgetProviderInfo) a).label;
+ } else if (a instanceof ResolveInfo) {
+ labelA = ((ResolveInfo) a).loadLabel(mPackageManager).toString();
+ } else {
+ labelA = ((LauncherActionInfo) a).title;
+ }
mLabelCache.put(a, labelA);
}
if (mLabelCache.containsKey(b)) {
labelB = mLabelCache.get(b);
} else {
- labelB = (b instanceof AppWidgetProviderInfo) ?
- ((AppWidgetProviderInfo) b).label :
- ((ResolveInfo) b).loadLabel(mPackageManager).toString();
+ if (b instanceof AppWidgetProviderInfo) {
+ labelB = ((AppWidgetProviderInfo) b).label;
+ } else if (b instanceof ResolveInfo) {
+ labelB = ((ResolveInfo) b).loadLabel(mPackageManager).toString();
+ } else {
+ labelB = ((LauncherActionInfo) b).title;
+ }
mLabelCache.put(b, labelB);
}
return mCollator.compare(labelA, labelB);
diff --git a/src/com/cyanogenmod/trebuchet/LauncherProvider.java b/src/com/cyanogenmod/trebuchet/LauncherProvider.java
index 3d90922eb..e4227c3b0 100644
--- a/src/com/cyanogenmod/trebuchet/LauncherProvider.java
+++ b/src/com/cyanogenmod/trebuchet/LauncherProvider.java
@@ -66,7 +66,7 @@ public class LauncherProvider extends ContentProvider {
private static final String DATABASE_NAME = "launcher.db";
- private static final int DATABASE_VERSION = 12;
+ private static final int DATABASE_VERSION = 13;
static final String AUTHORITY = "com.cyanogenmod.trebuchet.settings";
@@ -480,18 +480,6 @@ public class LauncherProvider extends ContentProvider {
version = 8;
}
- if (version < 9) {
- // The max id is not yet set at this point (onUpgrade is triggered in the ctor
- // before it gets a change to get set, so we need to read it here when we use it)
- if (mMaxId == -1) {
- mMaxId = initializeMaxId(db);
- }
-
- // Add default hotseat icons
- loadFavorites(db, R.xml.update_workspace);
- version = 9;
- }
-
// We bumped the version three time during JB, once to update the launch flags, once to
// update the override for the default launch animation and once to set the mimetype
// to improve startup performance
@@ -503,6 +491,18 @@ public class LauncherProvider extends ContentProvider {
version = 12;
}
+ if (version < 13) {
+ // The max id is not yet set at this point (onUpgrade is triggered in the ctor
+ // before it gets a change to get set, so we need to read it here when we use it)
+ if (mMaxId == -1) {
+ mMaxId = initializeMaxId(db);
+ }
+
+ // Add default hotseat icons
+ loadFavorites(db, R.xml.update_workspace);
+ version = 13;
+ }
+
if (version != DATABASE_VERSION) {
Log.w(TAG, "Destroying all old data.");
db.execSQL("DROP TABLE IF EXISTS " + TABLE_FAVORITES);
@@ -825,14 +825,6 @@ public class LauncherProvider extends ContentProvider {
String x = a.getString(R.styleable.Favorite_x);
String y = a.getString(R.styleable.Favorite_y);
- // If we are adding to the hotseat, the screen is used as the position in the
- // hotseat. This screen can't be at position 0 because AllApps is in the
- // zeroth position.
- if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT
- && Integer.valueOf(screen) == allAppsButtonRank) {
- throw new RuntimeException("Invalid screen position for hotseat item");
- }
-
values.clear();
values.put(LauncherSettings.Favorites.CONTAINER, container);
values.put(LauncherSettings.Favorites.SCREEN, screen);
diff --git a/src/com/cyanogenmod/trebuchet/PagedViewWidget.java b/src/com/cyanogenmod/trebuchet/PagedViewWidget.java
index 5f2b80037..b821b6f2d 100644
--- a/src/com/cyanogenmod/trebuchet/PagedViewWidget.java
+++ b/src/com/cyanogenmod/trebuchet/PagedViewWidget.java
@@ -127,6 +127,18 @@ public class PagedViewWidget extends LinearLayout {
}
}
+ public void applyFromLauncherActionInfo(LauncherActionInfo info) {
+ mIsAppWidget = false;
+ final ImageView image = (ImageView) findViewById(R.id.widget_preview);
+ image.setContentDescription(getContext().getResources().getString(info.action.getString()));
+ final TextView name = (TextView) findViewById(R.id.widget_name);
+ name.setText(info.title);
+ final TextView dims = (TextView) findViewById(R.id.widget_dims);
+ if (dims != null) {
+ dims.setText(String.format(mDimensionsFormatString, 1, 1));
+ }
+ }
+
public int[] getPreviewSize() {
final ImageView i = (ImageView) findViewById(R.id.widget_preview);
int[] maxSize = new int[2];
diff --git a/src/com/cyanogenmod/trebuchet/PendingAddItemInfo.java b/src/com/cyanogenmod/trebuchet/PendingAddItemInfo.java
index f0bdeb571..2020c6d97 100644
--- a/src/com/cyanogenmod/trebuchet/PendingAddItemInfo.java
+++ b/src/com/cyanogenmod/trebuchet/PendingAddItemInfo.java
@@ -21,6 +21,7 @@ import android.appwidget.AppWidgetProviderInfo;
import android.content.ComponentName;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
+import android.content.Intent;
import android.os.Parcelable;
/**
@@ -46,6 +47,12 @@ class PendingAddShortcutInfo extends PendingAddItemInfo {
return "Shortcut: " + shortcutActivityInfo.packageName;
}
}
+class PendingAddActionInfo extends PendingAddItemInfo {
+ /**
+ * The launcher action
+ */
+ LauncherAction.Action action;
+}
class PendingAddWidgetInfo extends PendingAddItemInfo {
int minWidth;
diff --git a/src/com/cyanogenmod/trebuchet/Workspace.java b/src/com/cyanogenmod/trebuchet/Workspace.java
index 4219e2bfa..08b0e7af3 100644
--- a/src/com/cyanogenmod/trebuchet/Workspace.java
+++ b/src/com/cyanogenmod/trebuchet/Workspace.java
@@ -2678,18 +2678,7 @@ public class Workspace extends SmoothPagedView
// Don't accept the drop if there's no room for the item
if (!foundCell) {
- // Don't show the message if we are dropping on the AllApps button and the hotseat
- // is full
- boolean isHotseat = mLauncher.isHotseatLayout(dropTargetLayout);
- if (mTargetCell != null && isHotseat) {
- Hotseat hotseat = mLauncher.getHotseat();
- if (hotseat.isAllAppsButtonRank(
- hotseat.getOrderInHotseat(mTargetCell[0], mTargetCell[1]))) {
- return false;
- }
- }
-
- mLauncher.showOutOfSpaceMessage(isHotseat);
+ mLauncher.showOutOfSpaceMessage(mLauncher.isHotseatLayout(dropTargetLayout));
return false;
}
}
@@ -3740,8 +3729,13 @@ public class Workspace extends SmoothPagedView
container, screen, mTargetCell, span, null);
break;
case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
- mLauncher.processShortcutFromDrop(pendingInfo.componentName,
- container, screen, mTargetCell, null);
+ if (pendingInfo instanceof PendingAddActionInfo) {
+ mLauncher.processActionFromDrop(((PendingAddActionInfo)pendingInfo).action,
+ container, screen, mTargetCell, null);
+ } else {
+ mLauncher.processShortcutFromDrop(pendingInfo.componentName,
+ container, screen, mTargetCell, null);
+ }
break;
default:
throw new IllegalStateException("Unknown item type: " +