Merge "Fixing some issues with our use of GridLayout."
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 22516cc..ae22507 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -64,6 +64,8 @@
private int mCountX;
private int mCountY;
+ private int mOriginalWidthGap;
+ private int mOriginalHeightGap;
private int mWidthGap;
private int mHeightGap;
private int mMaxGap;
@@ -155,8 +157,8 @@
mCellWidth = a.getDimensionPixelSize(R.styleable.CellLayout_cellWidth, 10);
mOriginalCellHeight =
mCellHeight = a.getDimensionPixelSize(R.styleable.CellLayout_cellHeight, 10);
- mWidthGap = a.getDimensionPixelSize(R.styleable.CellLayout_widthGap, 0);
- mHeightGap = a.getDimensionPixelSize(R.styleable.CellLayout_heightGap, 0);
+ mWidthGap = mOriginalWidthGap = a.getDimensionPixelSize(R.styleable.CellLayout_widthGap, 0);
+ mHeightGap = mOriginalHeightGap = a.getDimensionPixelSize(R.styleable.CellLayout_heightGap, 0);
mMaxGap = a.getDimensionPixelSize(R.styleable.CellLayout_maxGap, 0);
mCountX = LauncherModel.getCellCountX();
mCountY = LauncherModel.getCellCountY();
@@ -872,7 +874,7 @@
int numWidthGaps = mCountX - 1;
int numHeightGaps = mCountY - 1;
- if (mWidthGap < 0 || mHeightGap < 0) {
+ if (mOriginalWidthGap < 0 || mOriginalHeightGap < 0) {
int hSpace = widthSpecSize - mPaddingLeft - mPaddingRight;
int vSpace = heightSpecSize - mPaddingTop - mPaddingBottom;
int hFreeSpace = hSpace - (mCountX * mOriginalCellWidth);
@@ -885,6 +887,9 @@
mCellHeight = mOriginalCellHeight + remainingVSpace / mCountY;
mChildren.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap);
+ } else {
+ mWidthGap = mOriginalWidthGap;
+ mHeightGap = mOriginalHeightGap;
}
// Initial values correspond to widthSpecMode == MeasureSpec.EXACTLY
diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java
index ef02de6..7641fe7 100644
--- a/src/com/android/launcher2/Folder.java
+++ b/src/com/android/launcher2/Folder.java
@@ -35,6 +35,7 @@
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
+import android.view.View.MeasureSpec;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.inputmethod.EditorInfo;
@@ -783,6 +784,23 @@
centerAboutIcon();
}
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth();
+ // Technically there is no padding at the bottom, but we add space equal to the padding
+ // and have to account for that here.
+ int height = getPaddingTop() + mContent.getDesiredHeight() + mFolderNameHeight;
+
+ int contentWidthSpec = MeasureSpec.makeMeasureSpec(mContent.getDesiredWidth(),
+ MeasureSpec.EXACTLY);
+ int contentHeightSpec = MeasureSpec.makeMeasureSpec(mContent.getDesiredHeight(),
+ MeasureSpec.EXACTLY);
+ mContent.measure(contentWidthSpec, contentHeightSpec);
+
+ mFolderName.measure(contentWidthSpec,
+ MeasureSpec.makeMeasureSpec(mFolderNameHeight, MeasureSpec.EXACTLY));
+ setMeasuredDimension(width, height);
+ }
+
private void arrangeChildren(ArrayList<View> list) {
int[] vacant = new int[2];
if (list == null) {
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 489f3fb..5814500 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -317,6 +317,7 @@
// If we have a saved version of these external icons, we load them up immediately
if (sGlobalSearchIcon == null || sVoiceSearchIcon == null || sAppMarketIcon == null) {
updateIconsAffectedByPackageManagerChanges();
+ updateGlobalSearchIcon();
}
if (sGlobalSearchIcon != null) {
updateGlobalSearchIcon(sGlobalSearchIcon);
@@ -1217,7 +1218,7 @@
};
void addWidgetToAutoAdvanceIfNeeded(View hostView, AppWidgetProviderInfo appWidgetInfo) {
- if (appWidgetInfo.autoAdvanceViewId == -1) return;
+ if (appWidgetInfo == null || appWidgetInfo.autoAdvanceViewId == -1) return;
View v = hostView.findViewById(appWidgetInfo.autoAdvanceViewId);
if (v instanceof Advanceable) {
mWidgetsToAdvance.put(hostView, appWidgetInfo);
@@ -3133,10 +3134,14 @@
*/
private void updateIconsAffectedByPackageManagerChanges() {
updateAppMarketIcon();
- updateGlobalSearchIcon();
updateVoiceSearchIcon();
}
+ @Override
+ public void bindSearchablesChanged() {
+ updateGlobalSearchIcon();
+ }
+
/**
* Add the icons for all apps.
*
@@ -3147,6 +3152,7 @@
mAppsCustomizeContent.setApps(apps);
}
updateIconsAffectedByPackageManagerChanges();
+ updateGlobalSearchIcon();
}
/**
diff --git a/src/com/android/launcher2/LauncherApplication.java b/src/com/android/launcher2/LauncherApplication.java
index db3a4cb..94163ac 100644
--- a/src/com/android/launcher2/LauncherApplication.java
+++ b/src/com/android/launcher2/LauncherApplication.java
@@ -17,6 +17,7 @@
package com.android.launcher2;
import android.app.Application;
+import android.app.SearchManager;
import android.content.ContentResolver;
import android.content.Intent;
import android.content.IntentFilter;
@@ -57,6 +58,9 @@
filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
filter.addAction(Intent.ACTION_LOCALE_CHANGED);
registerReceiver(mModel, filter);
+ filter = new IntentFilter();
+ filter.addAction(SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED);
+ registerReceiver(mModel, filter);
// Register for changes to the favorites
ContentResolver resolver = getContentResolver();
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index 331f124..b4e632a 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -16,6 +16,7 @@
package com.android.launcher2;
+import android.app.SearchManager;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
import android.content.BroadcastReceiver;
@@ -129,6 +130,7 @@
public void bindAppsRemoved(ArrayList<ApplicationInfo> apps, boolean permanent);
public void bindPackagesUpdated();
public boolean isAllAppsVisible();
+ public void bindSearchablesChanged();
}
LauncherModel(LauncherApplication app, IconCache iconCache) {
@@ -513,6 +515,7 @@
* Call from the handler for ACTION_PACKAGE_ADDED, ACTION_PACKAGE_REMOVED and
* ACTION_PACKAGE_CHANGED.
*/
+ @Override
public void onReceive(Context context, Intent intent) {
if (DEBUG_LOADERS) Log.d(TAG, "onReceive intent=" + intent);
@@ -570,6 +573,9 @@
mAllAppsLoaded = false;
mWorkspaceLoaded = false;
startLoaderFromBackground();
+ } else if (SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED.equals(action)) {
+ Callbacks callbacks = mCallbacks.get();
+ callbacks.bindSearchablesChanged();
}
}
diff --git a/src/com/android/launcher2/PagedViewCellLayout.java b/src/com/android/launcher2/PagedViewCellLayout.java
index 39b0a62..bec00ec 100644
--- a/src/com/android/launcher2/PagedViewCellLayout.java
+++ b/src/com/android/launcher2/PagedViewCellLayout.java
@@ -41,6 +41,8 @@
private int mOriginalCellHeight;
private int mCellWidth;
private int mCellHeight;
+ private int mOriginalWidthGap;
+ private int mOriginalHeightGap;
private int mWidthGap;
private int mHeightGap;
private int mMaxGap;
@@ -72,7 +74,7 @@
mPeekWidth = resources.getDimensionPixelSize(R.dimen.apps_customize_peek_width);
mCellCountX = LauncherModel.getCellCountX();
mCellCountY = LauncherModel.getCellCountY();
- mWidthGap = mHeightGap = -1;
+ mOriginalHeightGap = mOriginalHeightGap = mWidthGap = mHeightGap = -1;
mMaxGap = resources.getDimensionPixelSize(R.dimen.apps_customize_max_gap);
mChildren = new PagedViewCellLayoutChildren(context);
@@ -224,7 +226,7 @@
int numWidthGaps = mCellCountX - 1;
int numHeightGaps = mCellCountY - 1;
- if (mWidthGap < 0 || mHeightGap < 0) {
+ if (mOriginalWidthGap < 0 || mOriginalHeightGap < 0) {
int hSpace = widthSpecSize - mPaddingLeft - mPaddingRight;
int vSpace = heightSpecSize - mPaddingTop - mPaddingBottom;
int hFreeSpace = hSpace - (mCellCountX * mOriginalCellWidth);
@@ -234,6 +236,9 @@
mChildren.setGap(mWidthGap, mHeightGap);
mHolographicChildren.setGap(mWidthGap, mHeightGap);
+ } else {
+ mWidthGap = mOriginalWidthGap;
+ mHeightGap = mOriginalHeightGap;
}
// Initial values correspond to widthSpecMode == MeasureSpec.EXACTLY