summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2011-05-26 12:03:43 -0700
committerWinson Chung <winsonc@google.com>2011-05-26 15:03:07 -0700
commit55b6550e37da5df2fda44fc712bc082731f2d8e7 (patch)
tree4003df523f68b268838759381258def2976a45fe /src
parented4c1f1eaddd23ea3a19750533e84d7411334534 (diff)
downloadandroid_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
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/AddAdapter.java5
-rw-r--r--src/com/android/launcher2/AppsCustomizePagedView.java44
-rw-r--r--src/com/android/launcher2/AppsCustomizeTabHost.java7
-rw-r--r--src/com/android/launcher2/Launcher.java38
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 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;