diff options
Diffstat (limited to 'src/com')
-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 |
4 files changed, 48 insertions, 46 deletions
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 631042e02..5cf8e9cdf 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; @@ -3252,12 +3247,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); @@ -3272,6 +3266,8 @@ public final class Launcher extends Activity } public void onDismiss(DialogInterface dialog) { + mWaitingForResult = false; + cleanup(); } private void cleanup() { @@ -3289,22 +3285,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; |