Merge "Add snap-back animation when dropping an item on a full page."
diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java
index 4dcdb81..149f9fb 100644
--- a/src/com/android/launcher2/AllAppsPagedView.java
+++ b/src/com/android/launcher2/AllAppsPagedView.java
@@ -18,14 +18,13 @@
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashSet;
import android.content.ComponentName;
import android.content.Context;
import android.content.res.TypedArray;
-import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.ActionMode;
-import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
@@ -294,7 +293,22 @@
}
private void removeAppsWithoutInvalidate(ArrayList<ApplicationInfo> list) {
- // loop through all the apps and remove apps that have the same component
+ // End the choice mode if any of the items in the list that are being removed are
+ // currently selected
+ ArrayList<Checkable> checkedList = getCheckedGrandchildren();
+ HashSet<ApplicationInfo> checkedAppInfos = new HashSet<ApplicationInfo>();
+ for (Checkable checked : checkedList) {
+ PagedViewIcon icon = (PagedViewIcon) checked;
+ checkedAppInfos.add((ApplicationInfo) icon.getTag());
+ }
+ for (ApplicationInfo info : list) {
+ if (checkedAppInfos.contains(info)) {
+ endChoiceMode();
+ break;
+ }
+ }
+
+ // Loop through all the apps and remove apps that have the same component
final int length = list.size();
for (int i = 0; i < length; ++i) {
final ApplicationInfo info = list.get(i);
diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java
index 5cfc38f..a475a50 100644
--- a/src/com/android/launcher2/CustomizePagedView.java
+++ b/src/com/android/launcher2/CustomizePagedView.java
@@ -144,7 +144,7 @@
Collections.sort(mApps, LauncherModel.APP_NAME_COMPARATOR);
// Update the widgets/shortcuts to reflect changes in the set of available apps
- update();
+ invalidatePageDataAndIconCache();
}
/**
@@ -170,7 +170,7 @@
addAppsWithoutInvalidate(list);
// Update the widgets/shortcuts to reflect changes in the set of available apps
- update();
+ invalidatePageDataAndIconCache();
}
/**
@@ -197,7 +197,7 @@
removeAppsWithoutInvalidate(list);
// Update the widgets/shortcuts to reflect changes in the set of available apps
- update();
+ invalidatePageDataAndIconCache();
}
/**
@@ -212,7 +212,7 @@
addAppsWithoutInvalidate(list);
// Update the widgets/shortcuts to reflect changes in the set of available apps
- update();
+ invalidatePageDataAndIconCache();
}
/**
@@ -231,8 +231,6 @@
}
public void update() {
- Context context = getContext();
-
// get the list of widgets
mWidgetList = AppWidgetManager.getInstance(mLauncher).getInstalledProviders();
Collections.sort(mWidgetList, new Comparator<AppWidgetProviderInfo>() {
@@ -260,7 +258,11 @@
mWallpaperList = mPackageManager.queryIntentActivities(wallpapersIntent, 0);
Collections.sort(mWallpaperList, resolveInfoComparator);
- // reset the icon cache
+ invalidatePageDataAndIconCache();
+ }
+
+ private void invalidatePageDataAndIconCache() {
+ // Reset the icon cache
mPageViewIconCache.clear();
// Refresh all the tabs
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index c14c22c..6b1290d 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -991,9 +991,13 @@
View createShortcut(int layoutResId, ViewGroup parent, ShortcutInfo info) {
TextView favorite = (TextView) mInflater.inflate(layoutResId, parent, false);
- // Temporarily, we are scaling up all shortcuts on the workspace
- int scaledSize = parent.getResources().getDimensionPixelSize(R.dimen.temp_scaled_icon_size);
- Bitmap b = Bitmap.createScaledBitmap(info.getIcon(mIconCache), scaledSize, scaledSize, true);
+ Bitmap b = info.getIcon(mIconCache);
+
+ if (LauncherApplication.isScreenXLarge()) {
+ // Temporarily, we are scaling up all shortcuts on the workspace
+ int scaledSize = getResources().getDimensionPixelSize(R.dimen.temp_scaled_icon_size);
+ b = Bitmap.createScaledBitmap(b, scaledSize, scaledSize, true);
+ }
favorite.setCompoundDrawablesWithIntrinsicBounds(null,
new FastBitmapDrawable(b),
diff --git a/src/com/android/launcher2/LauncherApplication.java b/src/com/android/launcher2/LauncherApplication.java
index 8a18317..dab2b58 100644
--- a/src/com/android/launcher2/LauncherApplication.java
+++ b/src/com/android/launcher2/LauncherApplication.java
@@ -52,6 +52,7 @@
filter = new IntentFilter();
filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
+ filter.addAction(Intent.ACTION_LOCALE_CHANGED);
registerReceiver(mModel, filter);
// Register for changes to the favorites
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index aa259aa..67aa311 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -424,24 +424,41 @@
String[] packages = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);
enqueuePackageUpdated(new PackageUpdatedTask(PackageUpdatedTask.OP_ADD, packages));
// Then, rebind everything.
- boolean runLoader = true;
- if (mCallbacks != null) {
- Callbacks callbacks = mCallbacks.get();
- if (callbacks != null) {
- // If they're paused, we can skip loading, because they'll do it again anyway
- if (callbacks.setLoadOnResume()) {
- runLoader = false;
- }
- }
- }
- if (runLoader) {
- startLoader(mApp, false);
- }
-
+ startLoaderFromBackground();
} else if (Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE.equals(action)) {
String[] packages = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);
enqueuePackageUpdated(new PackageUpdatedTask(
PackageUpdatedTask.OP_UNAVAILABLE, packages));
+ } else if (Intent.ACTION_LOCALE_CHANGED.equals(action)) {
+ // If we have changed locale we need to clear out the labels in all apps.
+ // Do this here because if the launcher activity is running it will be restarted.
+ // If it's not running startLoaderFromBackground will merely tell it that it needs
+ // to reload. Either way, mAllAppsLoaded will be cleared so it re-reads everything
+ // next time.
+ mAllAppsLoaded = false;
+ startLoaderFromBackground();
+ }
+ }
+
+ /**
+ * When the launcher is in the background, it's possible for it to miss paired
+ * configuration changes. So whenever we trigger the loader from the background
+ * tell the launcher that it needs to re-run the loader when it comes back instead
+ * of doing it now.
+ */
+ public void startLoaderFromBackground() {
+ boolean runLoader = false;
+ if (mCallbacks != null) {
+ Callbacks callbacks = mCallbacks.get();
+ if (callbacks != null) {
+ // Only actually run the loader if they're not paused.
+ if (!callbacks.setLoadOnResume()) {
+ runLoader = true;
+ }
+ }
+ }
+ if (runLoader) {
+ startLoader(mApp, false);
}
}
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 9739b15..c125696 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -755,7 +755,9 @@
// by a distant descendant, so use the mAllowLongPress flag to block
// everything
final View currentPage = getPageAt(mCurrentPage);
- currentPage.cancelLongPress();
+ if (currentPage != null) {
+ currentPage.cancelLongPress();
+ }
}
}
}