Merge "Adding distance threshold to initiate paging regardless of velocity."
diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java
index 5de53d8..4dcdb81 100644
--- a/src/com/android/launcher2/AllAppsPagedView.java
+++ b/src/com/android/launcher2/AllAppsPagedView.java
@@ -430,9 +430,6 @@
TextView icon = (TextView) mInflater.inflate(
R.layout.all_apps_no_items_placeholder, layout, false);
switch (mAppFilter) {
- case ApplicationInfo.GAME_FLAG:
- icon.setText(mContext.getString(R.string.all_apps_no_games));
- break;
case ApplicationInfo.DOWNLOADED_FLAG:
icon.setText(mContext.getString(R.string.all_apps_no_downloads));
break;
@@ -446,7 +443,6 @@
new PagedViewCellLayout.LayoutParams(0, 0, 2, 1));
}
}
-
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
mode.setTitle(R.string.cab_app_selection_text);
@@ -462,6 +458,12 @@
mOrigInfoButtonParent.removeView(infoButton);
infoButton.setManageVisibility(false);
infoButton.setVisibility(View.VISIBLE);
+ infoButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ final ApplicationInfo appInfo = (ApplicationInfo) getChosenItem();
+ mLauncher.startApplicationDetailsActivity(appInfo.componentName);
+ }
+ });
DeleteZone deleteZone = (DeleteZone) mLauncher.findViewById(R.id.delete_zone);
mOrigDeleteZoneParent = (ViewGroup) deleteZone.getParent();
@@ -469,6 +471,12 @@
mOrigDeleteZoneParent.removeView(deleteZone);
deleteZone.setManageVisibility(false);
deleteZone.setVisibility(View.VISIBLE);
+ deleteZone.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ final ApplicationInfo appInfo = (ApplicationInfo) getChosenItem();
+ mLauncher.startApplicationUninstallActivity(appInfo);
+ }
+ });
menu.add(0, MENU_APP_INFO, 0, R.string.cab_menu_app_info).setActionView(infoButton);
menu.add(0, MENU_DELETE_APP, 0, R.string.cab_menu_delete_app).setActionView(deleteZone);
@@ -484,15 +492,18 @@
@Override
public void onDestroyActionMode(ActionMode mode) {
+ final Menu menu = mode.getMenu();
+
// Re-parent the drop targets into the toolbar, and restore their layout params
+
ApplicationInfoDropTarget infoButton =
- (ApplicationInfoDropTarget) mLauncher.findViewById(R.id.info_button);
+ (ApplicationInfoDropTarget) menu.findItem(MENU_APP_INFO).getActionView();
((ViewGroup) infoButton.getParent()).removeView(infoButton);
mOrigInfoButtonParent.addView(infoButton, mOrigInfoButtonLayoutParams);
infoButton.setVisibility(View.GONE);
infoButton.setManageVisibility(true);
- DeleteZone deleteZone = (DeleteZone) mLauncher.findViewById(R.id.delete_zone);
+ DeleteZone deleteZone = (DeleteZone) menu.findItem(MENU_DELETE_APP).getActionView();
((ViewGroup) deleteZone.getParent()).removeView(deleteZone);
mOrigDeleteZoneParent.addView(deleteZone, mOrigDeleteZoneLayoutParams);
deleteZone.setVisibility(View.GONE);
@@ -504,16 +515,7 @@
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
- final int id = item.getItemId();
-
- // Assumes that we are in CHOICE_MODE_SINGLE
- final ApplicationInfo appInfo = (ApplicationInfo) getChosenItem();
-
- if (id == MENU_APP_INFO) {
- mLauncher.startApplicationDetailsActivity(appInfo.componentName);
- } else if (id == MENU_DELETE_APP) {
- mLauncher.startApplicationUninstallActivity(appInfo);
- }
+ // This is never called. Because we use setActionView(), we handle our own click events.
return false;
}
diff --git a/src/com/android/launcher2/AllAppsTabbed.java b/src/com/android/launcher2/AllAppsTabbed.java
index cc6a149..eaeb80f 100644
--- a/src/com/android/launcher2/AllAppsTabbed.java
+++ b/src/com/android/launcher2/AllAppsTabbed.java
@@ -16,24 +16,20 @@
package com.android.launcher2;
-import java.util.ArrayList;
+import com.android.launcher.R;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
-import android.animation.ValueAnimator;
import android.animation.ObjectAnimator;
+import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.Resources;
-import android.graphics.Color;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
-import android.widget.RelativeLayout;
import android.widget.TabHost;
-import android.widget.TabWidget;
-import android.widget.TextView;
-import com.android.launcher.R;
+import java.util.ArrayList;
/**
* Implements a tabbed version of AllApps2D.
@@ -43,8 +39,6 @@
private static final String TAG = "Launcher.AllAppsTabbed";
private static final String TAG_ALL = "ALL";
- private static final String TAG_APPS = "APPS";
- private static final String TAG_GAMES = "GAMES";
private static final String TAG_DOWNLOADED = "DOWNLOADED";
private AllAppsPagedView mAllApps;
@@ -77,27 +71,9 @@
String label = mContext.getString(R.string.all_apps_tab_all);
addTab(newTabSpec(TAG_ALL).setIndicator(label).setContent(contentFactory));
- label = mContext.getString(R.string.all_apps_tab_apps);
- addTab(newTabSpec(TAG_APPS).setIndicator(label).setContent(contentFactory));
-
- label = mContext.getString(R.string.all_apps_tab_games);
- addTab(newTabSpec(TAG_GAMES).setIndicator(label).setContent(contentFactory));
-
label = mContext.getString(R.string.all_apps_tab_downloaded);
addTab(newTabSpec(TAG_DOWNLOADED).setIndicator(label).setContent(contentFactory));
- // TEMP: just styling the tab widget to be a bit nicer until we get the actual
- // new assets
- TabWidget tabWidget = getTabWidget();
- for (int i = 0; i < tabWidget.getChildCount(); ++i) {
- RelativeLayout tab = (RelativeLayout) tabWidget.getChildTabViewAt(i);
- TextView text = (TextView) tab.getChildAt(1);
- text.setTextSize(20.0f);
- text.setPadding(20, 0, 20, 0);
- text.setShadowLayer(1.0f, 0.0f, 1.0f, Color.BLACK);
- tab.setBackgroundDrawable(null);
- }
-
setOnTabChangedListener(new OnTabChangeListener() {
public void onTabChanged(String tabId) {
// animate the changing of the tab content by fading pages in and out
@@ -106,14 +82,11 @@
ValueAnimator alphaAnim = ObjectAnimator.ofFloat(mAllApps, "alpha", alpha, 0.0f).
setDuration(duration);
alphaAnim.addListener(new AnimatorListenerAdapter() {
+ @Override
public void onAnimationEnd(Animator animation) {
String tag = getCurrentTabTag();
if (tag == TAG_ALL) {
mAllApps.setAppFilter(AllAppsPagedView.ALL_APPS_FLAG);
- } else if (tag == TAG_APPS) {
- mAllApps.setAppFilter(ApplicationInfo.APP_FLAG);
- } else if (tag == TAG_GAMES) {
- mAllApps.setAppFilter(ApplicationInfo.GAME_FLAG);
} else if (tag == TAG_DOWNLOADED) {
mAllApps.setAppFilter(ApplicationInfo.DOWNLOADED_FLAG);
}
@@ -127,11 +100,6 @@
}
});
- // TEMP: Working around a bug in tab host where the current tab does not initially have a
- // highlight on it by selecting something else, then selecting the actual tab we want..
- setCurrentTab(1);
- setCurrentTab(0);
-
// It needs to be INVISIBLE so that it will be measured in the layout.
// Otherwise the animations is messed up when we show it for the first time.
setVisibility(INVISIBLE);
diff --git a/src/com/android/launcher2/ApplicationInfoDropTarget.java b/src/com/android/launcher2/ApplicationInfoDropTarget.java
index fe5ffd1..3e5ebd5 100644
--- a/src/com/android/launcher2/ApplicationInfoDropTarget.java
+++ b/src/com/android/launcher2/ApplicationInfoDropTarget.java
@@ -118,10 +118,10 @@
public void onDragEnd() {
if (mActive) {
mActive = false;
- if (mManageVisibility) {
- setVisibility(GONE);
- mHandle.setVisibility(VISIBLE);
- }
+ }
+ if (mManageVisibility) {
+ setVisibility(GONE);
+ mHandle.setVisibility(VISIBLE);
}
}
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 2da5ac3..9bb10fa 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -122,7 +122,7 @@
private boolean mDragging = false;
- private ObjectAnimator mDropAnim;
+ private ValueAnimator mDropAnim;
private TimeInterpolator mEaseOutInterpolator;
public CellLayout(Context context) {
@@ -252,7 +252,7 @@
mDragOutlineAnims[i] = anim;
}
- mDropAnim = new ObjectAnimator();
+ mDropAnim = ValueAnimator.ofFloat(1.0f, 0.0f);
mDropAnim.setInterpolator(mEaseOutInterpolator);
mBackgroundRect = new Rect();
@@ -779,7 +779,7 @@
*/
private void animateChildIntoPosition(final View child) {
final Resources res = getResources();
- final ObjectAnimator anim = mDropAnim;
+ final ValueAnimator anim = mDropAnim;
final CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
final float startX = lp.oldX - lp.x;
final float startY = lp.oldY - lp.y;
@@ -790,18 +790,15 @@
final int duration = (int) (res.getInteger(R.integer.config_dropAnimMaxDuration)
* mEaseOutInterpolator.getInterpolation(dist / maxDist));
- anim.cancel(); // Make sure it's not already running
+ anim.end(); // Make sure it's not already running
anim.setDuration(duration);
- anim.setTarget(child);
- anim.setPropertyName("translationX");
- anim.setFloatValues(startX, 0);
-
+ anim.setFloatValues(1.0f, 0.0f);
anim.removeAllUpdateListeners();
anim.addUpdateListener(new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
- // Set the value of translationY based on the current x value
- final float translationX = (Float) anim.getAnimatedValue();
- child.setTranslationY((startY / startX) * translationX);
+ final float value = (Float) anim.getAnimatedValue();
+ child.setTranslationX(startX * value);
+ child.setTranslationY(startY * value);
}
});
anim.start();
diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java
index a01f1c0..5cfc38f 100644
--- a/src/com/android/launcher2/CustomizePagedView.java
+++ b/src/com/android/launcher2/CustomizePagedView.java
@@ -16,7 +16,10 @@
package com.android.launcher2;
-import com.android.launcher.R;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
@@ -28,12 +31,11 @@
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
+import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Rect;
-import android.graphics.Bitmap.Config;
import android.graphics.Region.Op;
import android.graphics.drawable.Drawable;
-import android.provider.LiveFolders;
import android.util.AttributeSet;
import android.util.Log;
import android.view.ActionMode;
@@ -41,18 +43,12 @@
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
-import android.view.MotionEvent;
import android.view.View;
-import android.view.ViewGroup;
-import android.widget.Checkable;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
+import com.android.launcher.R;
public class CustomizePagedView extends PagedView
implements View.OnLongClickListener, View.OnClickListener,
@@ -60,7 +56,6 @@
public enum CustomizationType {
WidgetCustomization,
- FolderCustomization,
ShortcutCustomization,
WallpaperCustomization,
ApplicationCustomization
@@ -89,7 +84,6 @@
// The raw sources of data for each of the different tabs of the customization page
private List<AppWidgetProviderInfo> mWidgetList;
- private List<ResolveInfo> mFolderList;
private List<ResolveInfo> mShortcutList;
private List<ResolveInfo> mWallpaperList;
private List<ApplicationInfo> mApps;
@@ -256,18 +250,6 @@
}
};
- // get the list of live folder intents
- Intent liveFolderIntent = new Intent(LiveFolders.ACTION_CREATE_LIVE_FOLDER);
- mFolderList = mPackageManager.queryIntentActivities(liveFolderIntent, 0);
-
- // manually create a separate entry for creating a folder in Launcher
- ResolveInfo folder = new ResolveInfo();
- folder.icon = R.drawable.ic_launcher_folder;
- folder.labelRes = R.string.group_folder;
- folder.resolvePackageName = context.getPackageName();
- mFolderList.add(0, folder);
- Collections.sort(mFolderList, resolveInfoComparator);
-
// get the list of shortcuts
Intent shortcutsIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
mShortcutList = mPackageManager.queryIntentActivities(shortcutsIntent, 0);
@@ -321,10 +303,6 @@
mChoiceModeTitleText = R.string.cab_app_selection_text;
enterChoiceMode = true;
break;
- case FolderCustomization:
- mChoiceModeTitleText = R.string.cab_folder_selection_text;
- enterChoiceMode = true;
- break;
case ShortcutCustomization:
mChoiceModeTitleText = R.string.cab_shortcut_selection_text;
enterChoiceMode = true;
@@ -403,19 +381,6 @@
// Cleanup the icon
b.recycle();
return true;
- case FolderCustomization:
- if (v.getTag() instanceof UserFolderInfo) {
- // The UserFolderInfo tag is only really used for live folders
- UserFolderInfo folderInfo = (UserFolderInfo) v.getTag();
- mDragController.startDrag(
- v, this, folderInfo, DragController.DRAG_ACTION_COPY, null);
- } else {
- createItemInfo = (PendingAddItemInfo) v.getTag();
- mDragController.startDrag(
- v, this, createItemInfo, DragController.DRAG_ACTION_COPY, null);
- }
- mLauncher.getWorkspace().onDragStartedWithItemSpans(1, 1);
- return true;
case ShortcutCustomization:
createItemInfo = (PendingAddItemInfo) v.getTag();
mDragController.startDrag(
@@ -645,20 +610,6 @@
case WallpaperCustomization:
icon.setOnClickListener(this);
break;
- case FolderCustomization:
- if (info.labelRes != R.string.group_folder) {
- createItemInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_LIVE_FOLDER;
- createItemInfo.componentName = new ComponentName(info.activityInfo.packageName,
- info.activityInfo.name);
- icon.setTag(createItemInfo);
- } else {
- UserFolderInfo folderInfo = new UserFolderInfo();
- folderInfo.title = getResources().getText(R.string.folder_name);
- icon.setTag(folderInfo);
- }
- icon.setOnClickListener(this);
- icon.setOnLongClickListener(this);
- break;
case ShortcutCustomization:
createItemInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
createItemInfo.componentName = new ComponentName(info.activityInfo.packageName,
@@ -727,10 +678,6 @@
case WidgetCustomization:
syncWidgetPages();
break;
- case FolderCustomization:
- syncListPages(mFolderList);
- centerPagedViewCellLayouts = true;
- break;
case ShortcutCustomization:
syncListPages(mShortcutList);
centerPagedViewCellLayouts = true;
@@ -773,9 +720,6 @@
case WidgetCustomization:
syncWidgetPageItems(page);
break;
- case FolderCustomization:
- syncListPageItems(page, mFolderList);
- break;
case ShortcutCustomization:
syncListPageItems(page, mShortcutList);
break;
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index baec7e3..5d45d27 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -17,15 +17,15 @@
package com.android.launcher2;
-import android.animation.Animator;
-import android.animation.AnimatorListenerAdapter;
-import android.animation.ValueAnimator;
import com.android.common.Search;
import com.android.launcher.R;
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
-import android.animation.AnimatorSet;
+import android.animation.ValueAnimator;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
@@ -53,7 +53,6 @@
import android.database.ContentObserver;
import android.graphics.Bitmap;
import android.graphics.Canvas;
-import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
@@ -90,11 +89,9 @@
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
-import android.widget.RelativeLayout;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.TabHost.TabContentFactory;
-import android.widget.TabWidget;
import android.widget.TextView;
import android.widget.Toast;
@@ -168,7 +165,6 @@
// tags for the customization tabs
private static final String WIDGETS_TAG = "widgets";
private static final String APPLICATIONS_TAG = "applications";
- private static final String FOLDERS_TAG = "folders";
private static final String SHORTCUTS_TAG = "shortcuts";
private static final String WALLPAPERS_TAG = "wallpapers";
@@ -291,9 +287,6 @@
String applicationsLabel = getString(R.string.applications_tab_label);
mHomeCustomizationDrawer.addTab(mHomeCustomizationDrawer.newTabSpec(APPLICATIONS_TAG)
.setIndicator(applicationsLabel).setContent(contentFactory));
- String foldersLabel = getString(R.string.folders_tab_label);
- mHomeCustomizationDrawer.addTab(mHomeCustomizationDrawer.newTabSpec(FOLDERS_TAG)
- .setIndicator(foldersLabel).setContent(contentFactory));
String wallpapersLabel = getString(R.string.wallpapers_tab_label);
mHomeCustomizationDrawer.addTab(mHomeCustomizationDrawer.newTabSpec(WALLPAPERS_TAG)
.setIndicator(wallpapersLabel).setContent(contentFactory));
@@ -301,18 +294,6 @@
mHomeCustomizationDrawer.addTab(mHomeCustomizationDrawer.newTabSpec(SHORTCUTS_TAG)
.setIndicator(shortcutsLabel).setContent(contentFactory));
- // TEMP: just styling the tab widget to be a bit nicer until we get the actual
- // new assets
- TabWidget tabWidget = mHomeCustomizationDrawer.getTabWidget();
- for (int i = 0; i < tabWidget.getChildCount(); ++i) {
- RelativeLayout tab = (RelativeLayout) tabWidget.getChildTabViewAt(i);
- TextView text = (TextView) tab.getChildAt(1);
- text.setTextSize(20.0f);
- text.setPadding(20, 0, 20, 0);
- text.setShadowLayer(1.0f, 0.0f, 1.0f, Color.BLACK);
- tab.setBackgroundDrawable(null);
- }
-
mHomeCustomizationDrawer.setOnTabChangedListener(new OnTabChangeListener() {
public void onTabChanged(String tabId) {
// animate the changing of the tab content by fading pages in and out
@@ -322,6 +303,7 @@
"alpha", alpha, 0.0f);
alphaAnim.setDuration(duration);
alphaAnim.addListener(new AnimatorListenerAdapter() {
+ @Override
public void onAnimationEnd(Animator animation) {
String tag = mHomeCustomizationDrawer.getCurrentTabTag();
if (tag == WIDGETS_TAG) {
@@ -330,9 +312,6 @@
} else if (tag == APPLICATIONS_TAG) {
mCustomizePagedView.setCustomizationFilter(
CustomizePagedView.CustomizationType.ApplicationCustomization);
- } else if (tag == FOLDERS_TAG) {
- mCustomizePagedView.setCustomizationFilter(
- CustomizePagedView.CustomizationType.FolderCustomization);
} else if (tag == WALLPAPERS_TAG) {
mCustomizePagedView.setCustomizationFilter(
CustomizePagedView.CustomizationType.WallpaperCustomization);
@@ -351,11 +330,6 @@
alphaAnim.start();
}
});
-
- // TEMP: Working around a bug in tab host where the current tab does not initially have
- // a highlight on it by selecting something else, then selecting the actual tab we want..
- mHomeCustomizationDrawer.setCurrentTab(1);
- mHomeCustomizationDrawer.setCurrentTab(0);
}
setupViews();
@@ -424,6 +398,7 @@
final LocaleConfiguration localeConfiguration = sLocaleConfiguration;
new Thread("WriteLocaleConfiguration") {
+ @Override
public void run() {
writeConfiguration(Launcher.this, localeConfiguration);
}
@@ -2306,9 +2281,11 @@
Animator anim = ObjectAnimator.ofFloat(view, "alpha", show ? 1.0f : 0.0f);
anim.setDuration(duration);
anim.addListener(new AnimatorListenerAdapter() {
+ @Override
public void onAnimationStart(Animator animation) {
if (showing) showToolbarButton(view);
}
+ @Override
public void onAnimationEnd(Animator animation) {
if (hiding) hideToolbarButton(view);
}
@@ -2409,6 +2386,7 @@
scaleAnim.setDuration(duration);
scaleAnim.setInterpolator(new DecelerateInterpolator());
scaleAnim.addListener(new AnimatorListenerAdapter() {
+ @Override
public void onAnimationStart(Animator animation) {
// Prepare the position
toView.setTranslationX(0.0f);
@@ -2472,6 +2450,7 @@
scaleAnim.setDuration(duration);
scaleAnim.setInterpolator(new AccelerateInterpolator());
mStateAnimation.addListener(new AnimatorListenerAdapter() {
+ @Override
public void onAnimationEnd(Animator animation) {
fromView.setVisibility(View.GONE);
fromView.setScaleX(1.0f);
@@ -2531,10 +2510,12 @@
if (mStateAnimation != null) mStateAnimation.cancel();
mStateAnimation = new AnimatorSet();
mStateAnimation.addListener(new AnimatorListenerAdapter() {
+ @Override
public void onAnimationStart(Animator animation) {
toView.setVisibility(View.VISIBLE);
toView.setY(toViewStartY);
}
+ @Override
public void onAnimationEnd(Animator animation) {
fromView.setVisibility(View.GONE);
}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 7399a9e..ce613f1 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -854,9 +854,6 @@
// never dragged over
public void onDragStopped() {
updateWhichPagesAcceptDrops(mShrunkenState);
- if (mShrunkenState == ShrinkPosition.SHRINK_TO_BOTTOM_VISIBLE) {
- shrink(ShrinkPosition.SHRINK_TO_BOTTOM_HIDDEN, true);
- }
}
// We call this when we trigger an unshrink by clicking on the CellLayout cl