diff options
author | Winson Chung <winsonc@google.com> | 2011-05-26 12:03:43 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2011-05-26 15:03:07 -0700 |
commit | 55b6550e37da5df2fda44fc712bc082731f2d8e7 (patch) | |
tree | 4003df523f68b268838759381258def2976a45fe | |
parent | ed4c1f1eaddd23ea3a19750533e84d7411334534 (diff) | |
download | android_packages_apps_Trebuchet-55b6550e37da5df2fda44fc712bc082731f2d8e7.tar.gz android_packages_apps_Trebuchet-55b6550e37da5df2fda44fc712bc082731f2d8e7.tar.bz2 android_packages_apps_Trebuchet-55b6550e37da5df2fda44fc712bc082731f2d8e7.zip |
Changing long-press-on-workspace behaviour to show Applications & Widgets.
- Disabling tap-on-widgets-to-add in favour of long press
Change-Id: Ia82143b74216a968ab11890cba83a01c4ab72a06
-rw-r--r-- | res/layout/add_list_item.xml | 2 | ||||
-rw-r--r-- | res/values/strings.xml | 4 | ||||
-rw-r--r-- | src/com/android/launcher2/AddAdapter.java | 5 | ||||
-rw-r--r-- | src/com/android/launcher2/AppsCustomizePagedView.java | 44 | ||||
-rw-r--r-- | src/com/android/launcher2/AppsCustomizeTabHost.java | 7 | ||||
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 38 |
6 files changed, 53 insertions, 47 deletions
diff --git a/res/layout/add_list_item.xml b/res/layout/add_list_item.xml index 62fc4f481..e937d7bc1 100644 --- a/res/layout/add_list_item.xml +++ b/res/layout/add_list_item.xml @@ -18,7 +18,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="?android:attr/listPreferredItemHeight" - android:textAppearance="?android:attr/textAppearanceLargeInverse" + android:textAppearance="?android:attr/textAppearanceLarge" android:gravity="center_vertical" android:drawablePadding="14dip" android:paddingLeft="15dip" diff --git a/res/values/strings.xml b/res/values/strings.xml index 7e8bec048..0b90353ff 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -74,6 +74,10 @@ <!-- Tile of the tab for applications that were downloaded from market [CHAR_LIMIT=24] --> <string name="all_apps_tab_downloaded">My apps</string> + <!-- AppsCustomize pane --> + <!-- Message to tell the user to long-press on a widget to add it [CHAR_LIMIT=50] --> + <string name="long_press_widget_to_add">Long-press to pick up a widget</string> + <!-- All Apps pane --> <!-- Message to show when there are no games [CHAR_LIMIT=25] --> <string name="all_apps_no_games">No games found.</string> diff --git a/src/com/android/launcher2/AddAdapter.java b/src/com/android/launcher2/AddAdapter.java index 6f97d72ed..d1076b16b 100644 --- a/src/com/android/launcher2/AddAdapter.java +++ b/src/com/android/launcher2/AddAdapter.java @@ -40,6 +40,7 @@ public class AddAdapter extends BaseAdapter { public static final int ITEM_SHORTCUT = 0; public static final int ITEM_APPWIDGET = 1; + public static final int ITEM_APPLICATION = 2; public static final int ITEM_WALLPAPER = 3; /** @@ -69,8 +70,8 @@ public class AddAdapter extends BaseAdapter { // Create default actions Resources res = launcher.getResources(); - mItems.add(new ListItem(res, R.string.group_shortcuts, - R.drawable.ic_launcher_shortcut, ITEM_SHORTCUT)); + 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)); diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index 4500744a1..bd7046348 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -25,8 +25,10 @@ import org.xmlpull.v1.XmlPullParser; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; +import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; +import android.animation.ValueAnimator; import android.app.WallpaperManager; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProviderInfo; @@ -53,10 +55,12 @@ import android.util.Xml; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.animation.AccelerateInterpolator; import android.view.animation.DecelerateInterpolator; import android.view.animation.LinearInterpolator; import android.widget.ImageView; import android.widget.TextView; +import android.widget.Toast; import com.android.launcher.R; @@ -341,31 +345,21 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen }); } } else { - // Add the widget to the current workspace screen - Workspace w = mLauncher.getWorkspace(); - int currentWorkspaceScreen = mLauncher.getCurrentWorkspaceScreen(); - final CellLayout cl = (CellLayout) w.getChildAt(currentWorkspaceScreen); - final View dragView = v.findViewById(R.id.widget_preview); - final ItemInfo itemInfo = (ItemInfo) v.getTag(); - animateClickFeedback(v, new Runnable() { - @Override - public void run() { - cl.calculateSpans(itemInfo); - if (cl.findCellForSpan(null, itemInfo.spanX, itemInfo.spanY)) { - if (LauncherApplication.isScreenLarge()) { - animateItemOntoScreen(dragView, cl, itemInfo); - } else { - mLauncher.addExternalItemToScreen(itemInfo, cl); - itemInfo.dropPos = null; - } - - // Hide the pane so we can see the workspace we dropped on - mLauncher.showWorkspace(true); - } else { - mLauncher.showOutOfSpaceMessage(); - } - } - }); + // Let the user know that they have to long press to add a widget + Toast.makeText(getContext(), R.string.long_press_widget_to_add, + Toast.LENGTH_SHORT).show(); + + // Create a little animation to show that the widget can move + float offsetY = getResources().getDimensionPixelSize(R.dimen.dragViewOffsetY); + final ImageView p = (ImageView) v.findViewById(R.id.widget_preview); + AnimatorSet bounce = new AnimatorSet(); + ValueAnimator tyuAnim = ObjectAnimator.ofFloat(p, "translationY", offsetY); + tyuAnim.setDuration(125); + ValueAnimator tydAnim = ObjectAnimator.ofFloat(p, "translationY", 0f); + tydAnim.setDuration(100); + bounce.play(tyuAnim).before(tydAnim); + bounce.setInterpolator(new AccelerateInterpolator()); + bounce.start(); } } } diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java index e2d21b6cb..cd8e7efb0 100644 --- a/src/com/android/launcher2/AppsCustomizeTabHost.java +++ b/src/com/android/launcher2/AppsCustomizeTabHost.java @@ -42,6 +42,13 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona mLayoutInflater = LayoutInflater.from(context); } + void selectAppsTab() { + setCurrentTabByTag(APPS_TAB_TAG); + } + void selectWidgetsTab() { + 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 2a16e9978..f8d341198 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -2230,11 +2230,7 @@ public final class Launcher extends Activity mWorkspace.setAllowLongPress(false); mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); - if (LauncherApplication.isScreenLarge()) { - addItems(); - } else { - startWallpaper(); - } + addItems(); } else { if (!(itemUnderLongClick instanceof Folder)) { // User long pressed on an item @@ -2970,9 +2966,8 @@ public final class Launcher extends Activity // Change the state *after* we've called all the transition code mState = State.ALL_APPS; } else { - View appsCustomizePane = findViewById(R.id.apps_customize_pane); cameraZoomOut(State.APPS_CUSTOMIZE, animated, false); - appsCustomizePane.requestFocus(); + mAppsCustomizeTabHost.requestFocus(); // Change the state *after* we've called all the transition code mState = State.APPS_CUSTOMIZE; @@ -3242,12 +3237,11 @@ public final class Launcher extends Activity Dialog createDialog() { mAdapter = new AddAdapter(Launcher.this); - final AlertDialog.Builder builder = new AlertDialog.Builder(Launcher.this); + final AlertDialog.Builder builder = new AlertDialog.Builder(Launcher.this, + AlertDialog.THEME_HOLO_DARK); builder.setTitle(getString(R.string.menu_item_add_item)); builder.setAdapter(mAdapter, this); - builder.setInverseBackgroundForced(true); - AlertDialog dialog = builder.create(); dialog.setOnCancelListener(this); dialog.setOnDismissListener(this); @@ -3262,6 +3256,8 @@ public final class Launcher extends Activity } public void onDismiss(DialogInterface dialog) { + mWaitingForResult = false; + cleanup(); } private void cleanup() { @@ -3279,22 +3275,26 @@ public final class Launcher extends Activity Resources res = getResources(); cleanup(); - switch (which) { + AddAdapter.ListItem item = (AddAdapter.ListItem) mAdapter.getItem(which); + switch (item.actionTag) { case AddAdapter.ITEM_SHORTCUT: { pickShortcut(); break; } - + case AddAdapter.ITEM_APPLICATION: { + if (mAppsCustomizeTabHost != null) { + mAppsCustomizeTabHost.selectAppsTab(); + } + showAllApps(true); + break; + } case AddAdapter.ITEM_APPWIDGET: { - int appWidgetId = Launcher.this.mAppWidgetHost.allocateAppWidgetId(); - - Intent pickIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_PICK); - pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); - // start the pick activity - startActivityForResult(pickIntent, REQUEST_PICK_APPWIDGET); + if (mAppsCustomizeTabHost != null) { + mAppsCustomizeTabHost.selectWidgetsTab(); + } + showAllApps(true); break; } - case AddAdapter.ITEM_WALLPAPER: { startWallpaper(); break; |