summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2011-08-02 16:00:04 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-08-02 16:00:04 -0700
commit0a7c914be6929f63dab74d420348d21970143ee2 (patch)
tree17b60058fc2f65bfc5d12d81b77ea8cf4f4fc10c /src
parent592be39d85a86011b267be2f64a9e6d9f5d3c3f9 (diff)
parent6a3fd3f042c8bfa7d83e29c1eeadff21323ab089 (diff)
downloadandroid_packages_apps_Trebuchet-0a7c914be6929f63dab74d420348d21970143ee2.tar.gz
android_packages_apps_Trebuchet-0a7c914be6929f63dab74d420348d21970143ee2.tar.bz2
android_packages_apps_Trebuchet-0a7c914be6929f63dab74d420348d21970143ee2.zip
Merge "Multitude of launcher behaviour changes."
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/AddAdapter.java8
-rw-r--r--src/com/android/launcher2/AppsCustomizePagedView.java67
-rw-r--r--src/com/android/launcher2/AppsCustomizeTabHost.java6
-rw-r--r--src/com/android/launcher2/Launcher.java62
-rw-r--r--src/com/android/launcher2/Workspace.java2
5 files changed, 27 insertions, 118 deletions
diff --git a/src/com/android/launcher2/AddAdapter.java b/src/com/android/launcher2/AddAdapter.java
index 5b7e92cb1..c2a424b00 100644
--- a/src/com/android/launcher2/AddAdapter.java
+++ b/src/com/android/launcher2/AddAdapter.java
@@ -70,16 +70,8 @@ public class AddAdapter extends BaseAdapter {
// Create default actions
Resources res = launcher.getResources();
- mItems.add(new ListItem(res, R.string.group_applications,
- R.drawable.ic_launcher_application, ITEM_APPLICATION));
-
- mItems.add(new ListItem(res, R.string.group_widgets,
- R.drawable.ic_launcher_appwidget, ITEM_APPWIDGET));
- mItems.add(new ListItem(res, R.string.group_shortcuts,
- R.drawable.ic_launcher_application, ITEM_SHORTCUT));
mItems.add(new ListItem(res, R.string.group_wallpapers,
R.drawable.ic_launcher_wallpaper, ITEM_WALLPAPER));
-
}
public View getView(int position, View convertView, ViewGroup parent) {
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index cb60034ac..e9c22ff07 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -167,7 +167,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
private ContentType mContentType;
private ArrayList<ApplicationInfo> mApps;
private ArrayList<Object> mWidgets;
- private ArrayList<Object> mShortcuts;
// Caching
private Canvas mCanvas;
@@ -180,9 +179,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
private int mMaxWidgetSpan, mMinWidgetSpan;
private int mWidgetCountX, mWidgetCountY;
private int mWidgetWidthGap, mWidgetHeightGap;
- private int mShortcutCountX, mShortcutCountY;
- private int mShortcutWidthGap, mShortcutHeightGap;
- private int mNumWidgetPages, mNumShortcutPages;
private final int mWidgetPreviewIconPaddedDimension;
private final float sWidgetPreviewIconPaddingPercentage = 0.25f;
private PagedViewCellLayout mWidgetSpacingLayout;
@@ -198,7 +194,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
mContentType = ContentType.Applications;
mApps = new ArrayList<ApplicationInfo>();
mWidgets = new ArrayList<Object>();
- mShortcuts = new ArrayList<Object>();
mIconCache = ((LauncherApplication) context.getApplicationContext()).getIconCache();
mHolographicOutlineHelper = new HolographicOutlineHelper();
mCanvas = new Canvas();
@@ -286,13 +281,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
mCellCountY = mWidgetSpacingLayout.getCellCountY();
mWidgetCountX = Math.max(1, (int) Math.round(mCellCountX / 2f));
mWidgetCountY = Math.max(1, (int) Math.round(mCellCountY / 3f));
- mShortcutCountX = Math.max(1, (int) Math.round(mCellCountX / 2f));
- mShortcutCountY = Math.max(1, (int) Math.round(mCellCountY / 2f));
-
- mNumWidgetPages = (int) Math.ceil(mWidgets.size() /
- (float) (mWidgetCountX * mWidgetCountY));
- mNumShortcutPages = (int) Math.ceil(mShortcuts.size() /
- (float) (mShortcutCountX * mShortcutCountY));
// Force a measure to update recalculate the gaps
int widthSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.AT_MOST);
@@ -335,19 +323,16 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
public void onPackagesUpdated() {
// Get the list of widgets and shortcuts
- boolean wasEmpty = mWidgets.isEmpty() && mShortcuts.isEmpty();
+ boolean wasEmpty = mWidgets.isEmpty();
mWidgets.clear();
- mShortcuts.clear();
List<AppWidgetProviderInfo> widgets =
AppWidgetManager.getInstance(mLauncher).getInstalledProviders();
- Collections.sort(widgets,
- new LauncherModel.WidgetAndShortcutNameComparator(mPackageManager));
Intent shortcutsIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
List<ResolveInfo> shortcuts = mPackageManager.queryIntentActivities(shortcutsIntent, 0);
- Collections.sort(shortcuts,
- new LauncherModel.WidgetAndShortcutNameComparator(mPackageManager));
mWidgets.addAll(widgets);
- mShortcuts.addAll(shortcuts);
+ mWidgets.addAll(shortcuts);
+ Collections.sort(mWidgets,
+ new LauncherModel.WidgetAndShortcutNameComparator(mPackageManager));
if (wasEmpty) {
// The next layout pass will trigger data-ready if both widgets and apps are set, so request
@@ -511,9 +496,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
public void setCurrentPageToWidgets() {
invalidatePageData(0);
}
- public void setCurrentPageToShortcuts() {
- invalidatePageData(mNumWidgetPages);
- }
/*
* Apps PagedView implementation
@@ -858,45 +840,33 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
public void syncWidgetPages() {
// Ensure that we have the right number of pages
Context context = getContext();
- int[] countX = { mWidgetCountX, mShortcutCountX };
- int[] countY = { mWidgetCountY, mShortcutCountY };
- int[] numPages = { mNumWidgetPages, mNumShortcutPages };
- for (int i = 0; i < 2; ++i) {
- for (int j = 0; j < numPages[i]; ++j) {
- PagedViewGridLayout layout = new PagedViewGridLayout(context, countX[i], countY[i]);
- setupPage(layout);
- addView(layout);
- }
+ int numPages = (int) Math.ceil(mWidgets.size() /
+ (float) (mWidgetCountX * mWidgetCountY));
+ for (int j = 0; j < numPages; ++j) {
+ PagedViewGridLayout layout = new PagedViewGridLayout(context, mWidgetCountX,
+ mWidgetCountY);
+ setupPage(layout);
+ addView(layout);
}
}
public void syncWidgetPageItems(int page) {
- int[] countX = { mWidgetCountX, mShortcutCountX };
- int[] countY = { mWidgetCountY, mShortcutCountY };
- int[] widthGap = { mWidgetWidthGap, mWidgetWidthGap };
- int[] heightGap = { mWidgetHeightGap, mWidgetHeightGap };
- int[] numItemsPerPage = { mWidgetCountX * mWidgetCountY,
- mShortcutCountX * mShortcutCountY };
- Object[] collection = { mWidgets, mShortcuts };
+ int numItemsPerPage = mWidgetCountX * mWidgetCountY;
int contentWidth = mWidgetSpacingLayout.getContentWidth();
int contentHeight = mWidgetSpacingLayout.getContentHeight();
- int numWidgetPages = (int) Math.ceil(mWidgets.size() / (float) numItemsPerPage[0]);
- int[] offsets = { page * numItemsPerPage[0], (page - numWidgetPages) * numItemsPerPage[1] };
- int index = (page < numWidgetPages ? 0 : 1);
// Calculate the dimensions of each cell we are giving to each widget
- ArrayList<Object> list = (ArrayList<Object>) collection[index];
ArrayList<Object> items = new ArrayList<Object>();
int cellWidth = ((contentWidth - mPageLayoutPaddingLeft - mPageLayoutPaddingRight
- - ((countX[index] - 1) * widthGap[index])) / countX[index]);
+ - ((mWidgetCountX - 1) * mWidgetWidthGap)) / mWidgetCountX);
int cellHeight = ((contentHeight - mPageLayoutPaddingTop - mPageLayoutPaddingBottom
- - ((countY[index] - 1) * heightGap[index])) / countY[index]);
+ - ((mWidgetCountY - 1) * mWidgetHeightGap)) / mWidgetCountY);
- int offset = offsets[index];
- for (int i = offset; i < Math.min(offset + numItemsPerPage[index], list.size()); ++i) {
- items.add(list.get(i));
+ int offset = page * numItemsPerPage;
+ for (int i = offset; i < Math.min(offset + numItemsPerPage, mWidgets.size()); ++i) {
+ items.add(mWidgets.get(i));
}
- prepareLoadWidgetPreviewsTask(page, items, cellWidth, cellHeight, countX[index]);
+ prepareLoadWidgetPreviewsTask(page, items, cellWidth, cellHeight, mWidgetCountX);
}
private void onSyncWidgetPageItems(AsyncTaskPageData data) {
int page = data.page;
@@ -1149,7 +1119,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// TODO: Dump information related to current list of Applications, Widgets, etc.
ApplicationInfo.dumpApplicationInfoList(LOG_TAG, "mApps", mApps);
dumpAppWidgetProviderInfoList(LOG_TAG, "mWidgets", mWidgets);
- dumpAppWidgetProviderInfoList(LOG_TAG, "mShortcuts", mShortcuts);
}
private void dumpAppWidgetProviderInfoList(String tag, String label,
ArrayList<Object> list) {
diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java
index b6bc5dc52..2f5cc4074 100644
--- a/src/com/android/launcher2/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher2/AppsCustomizeTabHost.java
@@ -71,12 +71,6 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
setCurrentTabByTag(WIDGETS_TAB_TAG);
}
- void selectShortcutsTab() {
- setContentTypeImmediate(AppsCustomizePagedView.ContentType.Widgets);
- mAppsCustomizePane.setCurrentPageToShortcuts();
-
- setCurrentTabByTag(WIDGETS_TAB_TAG);
- }
/**
* Setup the tab host and create all necessary tabs.
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 34cbf1a73..a8782ba81 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -500,7 +500,7 @@ public final class Launcher extends Activity
}
// Exit spring loaded mode if necessary after cancelling the configuration of a widget
- exitSpringLoadedDragModeDelayed(delayExitSpringLoadedMode);
+ exitSpringLoadedDragModeDelayed((resultCode != RESULT_CANCELED), delayExitSpringLoadedMode);
}
@Override
@@ -1197,36 +1197,7 @@ public final class Launcher extends Activity
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- if (isWorkspaceLocked()) {
- return false;
- }
-
super.onCreateOptionsMenu(menu);
-
- menu.add(MENU_GROUP_ADD, MENU_ADD, 0, R.string.menu_add)
- .setIcon(android.R.drawable.ic_menu_add)
- .setAlphabeticShortcut('A');
- menu.add(0, MENU_MANAGE_APPS, 0, R.string.menu_manage_apps)
- .setIcon(android.R.drawable.ic_menu_manage)
- .setAlphabeticShortcut('M');
- menu.add(MENU_GROUP_WALLPAPER, MENU_WALLPAPER_SETTINGS, 0, R.string.menu_wallpaper)
- .setIcon(android.R.drawable.ic_menu_gallery)
- .setAlphabeticShortcut('W');
- menu.add(0, MENU_SEARCH, 0, R.string.menu_search)
- .setIcon(android.R.drawable.ic_search_category_default)
- .setAlphabeticShortcut(SearchManager.MENU_KEY);
- menu.add(0, MENU_NOTIFICATIONS, 0, R.string.menu_notifications)
- .setIcon(com.android.internal.R.drawable.ic_menu_notifications)
- .setAlphabeticShortcut('N');
-
- final Intent settings = new Intent(android.provider.Settings.ACTION_SETTINGS);
- settings.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
- Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
-
- menu.add(0, MENU_SETTINGS, 0, R.string.menu_settings)
- .setIcon(android.R.drawable.ic_menu_preferences).setAlphabeticShortcut('P')
- .setIntent(settings);
-
return true;
}
@@ -1234,10 +1205,7 @@ public final class Launcher extends Activity
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
- // TODO-APPS_CUSTOMIZE: Remove this for the phone UI at some point, along with all the menu
- // related code?
- if (mAppsCustomizeContent != null && mAppsCustomizeContent.isAnimating()) return false;
-
+ startWallpaper();
return true;
}
@@ -1348,7 +1316,7 @@ public final class Launcher extends Activity
completeAddAppWidget(appWidgetId, info.container, info.screen);
// Exit spring loaded mode if necessary after adding the widget
- exitSpringLoadedDragModeDelayed(false);
+ exitSpringLoadedDragModeDelayed(true, false);
}
}
@@ -1630,16 +1598,6 @@ public final class Launcher extends Activity
}
/**
- * Event handler for the "gear" button that appears on the home screen, which
- * enters home screen customization mode.
- *
- * @param v The view that was clicked.
- */
- public void onClickConfigureButton(View v) {
- addItems();
- }
-
- /**
* Event handler for the "grid" button that appears on the home screen, which
* enters all apps mode.
*
@@ -1824,7 +1782,7 @@ public final class Launcher extends Activity
// User long pressed on empty space
mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
- addItems();
+ startWallpaper();
} else {
if (!(itemUnderLongClick instanceof Folder)) {
// User long pressed on an item
@@ -2238,11 +2196,14 @@ public final class Launcher extends Activity
}
// Otherwise, we are not in spring loaded mode, so don't do anything.
}
- void exitSpringLoadedDragModeDelayed(boolean extendedDelay) {
+ void exitSpringLoadedDragModeDelayed(final boolean successfulDrop, boolean extendedDelay) {
mWorkspace.postDelayed(new Runnable() {
@Override
public void run() {
exitSpringLoadedDragMode();
+ if (successfulDrop) {
+ showWorkspace(true);
+ }
}
}, (extendedDelay ?
EXIT_SPRINGLOADED_MODE_LONG_TIMEOUT :
@@ -2580,13 +2541,6 @@ public final class Launcher extends Activity
AddAdapter.ListItem item = (AddAdapter.ListItem) mAdapter.getItem(which);
switch (item.actionTag) {
- case AddAdapter.ITEM_SHORTCUT: {
- if (mAppsCustomizeTabHost != null) {
- mAppsCustomizeTabHost.selectShortcutsTab();
- }
- showAllApps(true);
- break;
- }
case AddAdapter.ITEM_APPLICATION: {
if (mAppsCustomizeTabHost != null) {
mAppsCustomizeTabHost.selectAppsTab();
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 11528e4b7..390159426 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -3017,7 +3017,7 @@ public class Workspace extends SmoothPagedView
final Runnable exitSpringLoadedRunnable = new Runnable() {
@Override
public void run() {
- mLauncher.exitSpringLoadedDragModeDelayed(false);
+ mLauncher.exitSpringLoadedDragModeDelayed(true, false);
}
};