Multitude of launcher behaviour changes.
- Merging widgets and shortcuts in widgets pane - Removing legacy long press menu items (make it go straight to wallpapers) - Removing old option menu (just making it point to wallpapers) - Dropping user to workspace after adding an item (animations to be tweaked) or back to AppsCustomize only on failure/cancel Change-Id: Ia73670ce76f321dc45defb27bb5a828764240ab4
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
<integer name="config_dragAppsCustomizeIconFadeInDuration">150</integer>
|
||||
<integer name="config_dragAppsCustomizeIconFadeOutDuration">200</integer>
|
||||
<integer name="config_dragAppsCustomizeIconFadeAlpha">100</integer>
|
||||
<integer name="config_workspaceUnshrinkTime">650</integer>
|
||||
<integer name="config_workspaceUnshrinkTime">300</integer>
|
||||
<!-- Out of 100, the percent to shrink the workspace during spring loaded mode. -->
|
||||
<integer name="config_workspaceSpringLoadShrinkPercentage">80</integer>
|
||||
<!-- When items are dropped on the mini screens in customize mode, we have a bounce animation
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1629,16 +1597,6 @@ public final class Launcher extends Activity
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
@@ -3026,7 +3026,7 @@ public class Workspace extends SmoothPagedView
|
||||
final Runnable exitSpringLoadedRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mLauncher.exitSpringLoadedDragModeDelayed(false);
|
||||
mLauncher.exitSpringLoadedDragModeDelayed(true, false);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user