diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher3/BubbleTextView.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/CellLayout.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/Cling.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/DynamicGrid.java | 181 | ||||
-rw-r--r-- | src/com/android/launcher3/FastBitmapDrawable.java | 1 | ||||
-rw-r--r-- | src/com/android/launcher3/Folder.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/FolderIcon.java | 19 | ||||
-rw-r--r-- | src/com/android/launcher3/IconCache.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 12 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherAppState.java | 11 | ||||
-rw-r--r-- | src/com/android/launcher3/PagedViewIcon.java | 6 | ||||
-rw-r--r-- | src/com/android/launcher3/PagedViewWidget.java | 4 |
12 files changed, 168 insertions, 78 deletions
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 8dab9432a..400dd4b4b 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -87,7 +87,7 @@ public class BubbleTextView extends TextView { // Ensure we are using the right text size LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); - setTextSize(TypedValue.COMPLEX_UNIT_SP, grid.iconTextSize); + setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.iconTextSizePx); setTextColor(getResources().getColor(R.color.workspace_icon_text_color)); } @@ -111,7 +111,7 @@ public class BubbleTextView extends TextView { setCompoundDrawables(null, Utilities.createIconDrawable(b), null, null); - setCompoundDrawablePadding((int) ((grid.folderIconSizePx - grid.iconSizePx) / 2f)); + setCompoundDrawablePadding(grid.iconDrawablePaddingPx); setText(info.title); setTag(info); } diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index dafb79ffc..bf1e9c931 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -214,7 +214,7 @@ public class CellLayout extends ViewGroup { setAlwaysDrawnWithCacheEnabled(false); final Resources res = getResources(); - mHotseatScale = (float) grid.hotseatIconSize / grid.iconSize; + mHotseatScale = (float) grid.hotseatIconSizePx / grid.iconSizePx; mNormalBackground = res.getDrawable(R.drawable.screenpanel); mActiveGlowBackground = res.getDrawable(R.drawable.screenpanel_hover); diff --git a/src/com/android/launcher3/Cling.java b/src/com/android/launcher3/Cling.java index 338b722ab..9974acde6 100644 --- a/src/com/android/launcher3/Cling.java +++ b/src/com/android/launcher3/Cling.java @@ -147,7 +147,7 @@ public class Cling extends FrameLayout implements Insettable, View.OnClickListen pos.left + Utilities.sIconTextureWidth, pos.top + Utilities.sIconTextureHeight); Utilities.scaleRectAboutCenter(mFocusedHotseatAppBounds, - (grid.hotseatIconSize / grid.iconSize)); + ((float) grid.hotseatIconSizePx / grid.iconSizePx)); // Set the title TextView v = (TextView) findViewById(R.id.focused_hotseat_app_title); diff --git a/src/com/android/launcher3/DynamicGrid.java b/src/com/android/launcher3/DynamicGrid.java index 4776c8668..d90deca4f 100644 --- a/src/com/android/launcher3/DynamicGrid.java +++ b/src/com/android/launcher3/DynamicGrid.java @@ -23,13 +23,17 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Paint; import android.graphics.Paint.FontMetrics; +import android.graphics.Point; import android.graphics.PointF; import android.graphics.Rect; import android.util.DisplayMetrics; import android.util.TypedValue; +import android.view.Display; import android.view.Gravity; +import android.view.Surface; import android.view.View; import android.view.ViewGroup.LayoutParams; +import android.view.WindowManager; import android.widget.FrameLayout; import java.util.ArrayList; @@ -52,15 +56,20 @@ class DeviceProfileQuery { } class DeviceProfile { + public static interface DeviceProfileCallbacks { + public void onAvailableSizeChanged(DeviceProfile grid); + } + String name; float minWidthDps; float minHeightDps; float numRows; float numColumns; - float iconSize; - float iconTextSize; float numHotseatIcons; - float hotseatIconSize; + private float iconSize; + private float iconTextSize; + private int iconDrawablePaddingOriginalPx; + private float hotseatIconSize; boolean isLandscape; boolean isTablet; @@ -75,8 +84,10 @@ class DeviceProfile { int heightPx; int availableWidthPx; int availableHeightPx; + int iconSizePx; int iconTextSizePx; + int iconDrawablePaddingPx; int cellWidthPx; int cellHeightPx; int folderBackgroundOffset; @@ -96,6 +107,8 @@ class DeviceProfile { int searchBarHeightPx; int pageIndicatorHeightPx; + private ArrayList<DeviceProfileCallbacks> mCallbacks = new ArrayList<DeviceProfileCallbacks>(); + DeviceProfile(String n, float w, float h, float r, float c, float is, float its, float hs, float his) { // Ensure that we have an odd number of hotseat items (since we need to place all apps) @@ -146,13 +159,20 @@ class DeviceProfile { points.add(new DeviceProfileQuery(p.minWidthDps, p.minHeightDps, p.numColumns)); } numColumns = Math.round(invDistWeightedInterpolate(minWidth, minHeight, points)); + // Interpolate the hotseat length + points.clear(); + for (DeviceProfile p : profiles) { + points.add(new DeviceProfileQuery(p.minWidthDps, p.minHeightDps, p.numHotseatIcons)); + } + numHotseatIcons = Math.round(invDistWeightedInterpolate(minWidth, minHeight, points)); + hotseatAllAppsRank = (int) (numHotseatIcons / 2); + // Interpolate the icon size points.clear(); for (DeviceProfile p : profiles) { points.add(new DeviceProfileQuery(p.minWidthDps, p.minHeightDps, p.iconSize)); } iconSize = invDistWeightedInterpolate(minWidth, minHeight, points); - iconSizePx = DynamicGrid.pxFromDp(iconSize, dm); // Interpolate the icon text size points.clear(); @@ -160,14 +180,8 @@ class DeviceProfile { points.add(new DeviceProfileQuery(p.minWidthDps, p.minHeightDps, p.iconTextSize)); } iconTextSize = invDistWeightedInterpolate(minWidth, minHeight, points); - iconTextSizePx = DynamicGrid.pxFromSp(iconTextSize, dm); + iconDrawablePaddingOriginalPx = resources.getDimensionPixelSize(R.dimen.dynamic_grid_icon_drawable_padding); - // Interpolate the hotseat size - points.clear(); - for (DeviceProfile p : profiles) { - points.add(new DeviceProfileQuery(p.minWidthDps, p.minHeightDps, p.numHotseatIcons)); - } - numHotseatIcons = Math.round(invDistWeightedInterpolate(minWidth, minHeight, points)); // Interpolate the hotseat icon size points.clear(); for (DeviceProfile p : profiles) { @@ -175,11 +189,91 @@ class DeviceProfile { } // Hotseat hotseatIconSize = invDistWeightedInterpolate(minWidth, minHeight, points); - hotseatIconSizePx = DynamicGrid.pxFromDp(hotseatIconSize, dm); - hotseatAllAppsRank = (int) (numColumns / 2); - // Calculate other vars based on Configuration - updateFromConfiguration(resources, wPx, hPx, awPx, ahPx); + // Calculate the remaining vars + updateFromConfiguration(context, resources, wPx, hPx, awPx, ahPx); + updateAvailableDimensions(context); + } + + void addCallback(DeviceProfileCallbacks cb) { + mCallbacks.add(cb); + cb.onAvailableSizeChanged(this); + } + void removeCallback(DeviceProfileCallbacks cb) { + mCallbacks.remove(cb); + } + + private int getDeviceOrientation(Context context) { + WindowManager windowManager = (WindowManager) + context.getSystemService(Context.WINDOW_SERVICE); + Resources resources = context.getResources(); + DisplayMetrics dm = resources.getDisplayMetrics(); + Configuration config = resources.getConfiguration(); + int rotation = windowManager.getDefaultDisplay().getRotation(); + + boolean isLandscape = (config.orientation == Configuration.ORIENTATION_LANDSCAPE) && + (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180); + boolean isRotatedPortrait = (config.orientation == Configuration.ORIENTATION_PORTRAIT) && + (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270); + if (isLandscape || isRotatedPortrait) { + return CellLayout.LANDSCAPE; + } else { + return CellLayout.PORTRAIT; + } + } + + private void updateAvailableDimensions(Context context) { + WindowManager windowManager = (WindowManager) + context.getSystemService(Context.WINDOW_SERVICE); + Display display = windowManager.getDefaultDisplay(); + Resources resources = context.getResources(); + DisplayMetrics dm = resources.getDisplayMetrics(); + Configuration config = resources.getConfiguration(); + + // There are three possible configurations that the dynamic grid accounts for, portrait, + // landscape with the nav bar at the bottom, and landscape with the nav bar at the side. + // To prevent waiting for fitSystemWindows(), we make the observation that in landscape, + // the height is the smallest height (either with the nav bar at the bottom or to the + // side) and otherwise, the height is simply the largest possible height for a portrait + // device. + Point size = new Point(); + Point smallestSize = new Point(); + Point largestSize = new Point(); + display.getSize(size); + display.getCurrentSizeRange(smallestSize, largestSize); + availableWidthPx = size.x; + if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) { + availableHeightPx = smallestSize.y; + } else { + availableHeightPx = largestSize.y; + } + + // Check to see if the icons fit in the new available height. If not, then we need to + // shrink the icon size. + Rect workspacePadding = getWorkspacePadding(); + float scale = 1f; + int drawablePadding = iconDrawablePaddingOriginalPx; + updateIconSize(1f, drawablePadding, resources, dm); + float usedHeight = (cellHeightPx * numRows); + int maxHeight = (availableHeightPx - workspacePadding.top - workspacePadding.bottom); + if (usedHeight > maxHeight) { + scale = maxHeight / usedHeight; + drawablePadding = 0; + } + updateIconSize(scale, drawablePadding, resources, dm); + + // Make the callbacks + for (DeviceProfileCallbacks cb : mCallbacks) { + cb.onAvailableSizeChanged(this); + } + } + + private void updateIconSize(float scale, int drawablePadding, Resources resources, + DisplayMetrics dm) { + iconSizePx = (int) (DynamicGrid.pxFromDp(iconSize, dm) * scale); + iconTextSizePx = (int) (DynamicGrid.pxFromSp(iconTextSize, dm) * scale); + iconDrawablePaddingPx = drawablePadding; + hotseatIconSizePx = (int) (DynamicGrid.pxFromDp(hotseatIconSize, dm) * scale); // Search Bar searchBarSpaceMaxWidthPx = resources.getDimensionPixelSize(R.dimen.dynamic_grid_search_bar_max_width); @@ -192,23 +286,7 @@ class DeviceProfile { textPaint.setTextSize(iconTextSizePx); FontMetrics fm = textPaint.getFontMetrics(); cellWidthPx = iconSizePx; - cellHeightPx = iconSizePx + (int) Math.ceil(fm.bottom - fm.top); - - // At this point, if the cells do not fit into the available height, then we need - // to shrink the icon size - /* - Rect padding = getWorkspacePadding(isLandscape ? - CellLayout.LANDSCAPE : CellLayout.PORTRAIT); - int h = (int) (numRows * cellHeightPx) + padding.top + padding.bottom; - if (h > availableHeightPx) { - float delta = h - availableHeightPx; - int deltaPx = (int) Math.ceil(delta / numRows); - iconSizePx -= deltaPx; - iconSize = DynamicGrid.dpiFromPx(iconSizePx, dm); - cellWidthPx = iconSizePx; - cellHeightPx = iconSizePx + (int) Math.ceil(fm.bottom - fm.top); - } - */ + cellHeightPx = iconSizePx + iconDrawablePaddingPx + (int) Math.ceil(fm.bottom - fm.top); // Hotseat hotseatBarHeightPx = iconSizePx + 4 * edgeMarginPx; @@ -217,26 +295,15 @@ class DeviceProfile { // Folder folderCellWidthPx = cellWidthPx + 3 * edgeMarginPx; - folderCellHeightPx = cellHeightPx + (int) ((3f/2f) * edgeMarginPx); + folderCellHeightPx = cellHeightPx + edgeMarginPx; folderBackgroundOffset = -edgeMarginPx; folderIconSizePx = iconSizePx + 2 * -folderBackgroundOffset; - } - - void updateFromConfiguration(Resources resources, int wPx, int hPx, - int awPx, int ahPx) { - isLandscape = (resources.getConfiguration().orientation == - Configuration.ORIENTATION_LANDSCAPE); - isTablet = resources.getBoolean(R.bool.is_tablet); - isLargeTablet = resources.getBoolean(R.bool.is_large_tablet); - widthPx = wPx; - heightPx = hPx; - availableWidthPx = awPx; - availableHeightPx = ahPx; + // All Apps Rect padding = getWorkspacePadding(isLandscape ? CellLayout.LANDSCAPE : CellLayout.PORTRAIT); int pageIndicatorOffset = - resources.getDimensionPixelSize(R.dimen.apps_customize_page_indicator_offset); + resources.getDimensionPixelSize(R.dimen.apps_customize_page_indicator_offset); if (isLandscape) { allAppsNumRows = (availableHeightPx - pageIndicatorOffset - 4 * edgeMarginPx) / (iconSizePx + iconTextSizePx + 2 * edgeMarginPx); @@ -247,6 +314,20 @@ class DeviceProfile { (iconSizePx + 2 * edgeMarginPx); } + void updateFromConfiguration(Context context, Resources resources, int wPx, int hPx, + int awPx, int ahPx) { + isLandscape = (resources.getConfiguration().orientation == + Configuration.ORIENTATION_LANDSCAPE); + isTablet = resources.getBoolean(R.bool.is_tablet); + isLargeTablet = resources.getBoolean(R.bool.is_large_tablet); + widthPx = wPx; + heightPx = hPx; + availableWidthPx = awPx; + availableHeightPx = ahPx; + + updateAvailableDimensions(context); + } + private float dist(PointF p0, PointF p1) { return (float) Math.sqrt((p1.x - p0.x)*(p1.x-p0.x) + (p1.y-p0.y)*(p1.y-p0.y)); @@ -298,6 +379,9 @@ class DeviceProfile { return sum; } + Rect getWorkspacePadding() { + return getWorkspacePadding(isLandscape ? CellLayout.LANDSCAPE : CellLayout.PORTRAIT); + } Rect getWorkspacePadding(int orientation) { Rect padding = new Rect(); if (orientation == CellLayout.LANDSCAPE && @@ -431,8 +515,7 @@ class DeviceProfile { lp.gravity = Gravity.RIGHT; lp.width = hotseatBarHeightPx; lp.height = LayoutParams.MATCH_PARENT; - hotseat.setPadding(0, 2 * edgeMarginPx, - 2 * edgeMarginPx, 2 * edgeMarginPx); + hotseat.findViewById(R.id.layout).setPadding(0, 2 * edgeMarginPx, 0, 2 * edgeMarginPx); } else if (isTablet()) { // Pad the hotseat with the grid gap calculated above int gridGap = (int) ((widthPx - 2 * edgeMarginPx - @@ -553,7 +636,7 @@ public class DynamicGrid { "Wd: " + mProfile.minWidthDps + ", Hd: " + mProfile.minHeightDps + ", W: " + mProfile.widthPx + ", H: " + mProfile.heightPx + " [r: " + mProfile.numRows + ", c: " + mProfile.numColumns + - ", is: " + mProfile.iconSizePx + ", its: " + mProfile.iconTextSize + + ", is: " + mProfile.iconSizePx + ", its: " + mProfile.iconTextSizePx + ", cw: " + mProfile.cellWidthPx + ", ch: " + mProfile.cellHeightPx + ", hc: " + mProfile.numHotseatIcons + ", his: " + mProfile.hotseatIconSizePx + "]"; } diff --git a/src/com/android/launcher3/FastBitmapDrawable.java b/src/com/android/launcher3/FastBitmapDrawable.java index 14760c7b6..bce6707da 100644 --- a/src/com/android/launcher3/FastBitmapDrawable.java +++ b/src/com/android/launcher3/FastBitmapDrawable.java @@ -67,6 +67,7 @@ class FastBitmapDrawable extends Drawable { public void setFilterBitmap(boolean filterBitmap) { mPaint.setFilterBitmap(filterBitmap); + mPaint.setAntiAlias(filterBitmap); } public int getAlpha() { diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java index 69d9a3d4b..7aa5de832 100644 --- a/src/com/android/launcher3/Folder.java +++ b/src/com/android/launcher3/Folder.java @@ -956,9 +956,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList Rect workspacePadding = grid.getWorkspacePadding(grid.isLandscape ? CellLayout.LANDSCAPE : CellLayout.PORTRAIT); int maxContentAreaHeight = grid.availableHeightPx - - 4 * grid.edgeMarginPx - workspacePadding.top - workspacePadding.bottom - - getPaddingTop() - getPaddingBottom() - mFolderNameHeight; return Math.min(maxContentAreaHeight, mContent.getDesiredHeight()); diff --git a/src/com/android/launcher3/FolderIcon.java b/src/com/android/launcher3/FolderIcon.java index cd1ff2c37..5e461a7b5 100644 --- a/src/com/android/launcher3/FolderIcon.java +++ b/src/com/android/launcher3/FolderIcon.java @@ -37,7 +37,7 @@ import android.view.ViewGroup; import android.view.animation.AccelerateInterpolator; import android.view.animation.DecelerateInterpolator; import android.widget.ImageView; -import android.widget.LinearLayout; +import android.widget.FrameLayout; import android.widget.TextView; import com.android.launcher3.R; @@ -49,7 +49,7 @@ import java.util.ArrayList; /** * An icon that can appear on in the workspace representing an {@link UserFolder}. */ -public class FolderIcon extends LinearLayout implements FolderListener { +public class FolderIcon extends FrameLayout implements FolderListener { private Launcher mLauncher; private Folder mFolder; private FolderInfo mInfo; @@ -134,17 +134,20 @@ public class FolderIcon extends LinearLayout implements FolderListener { "INITIAL_ITEM_ANIMATION_DURATION, as sequencing of adding first two items " + "is dependent on this"); } + LauncherAppState app = LauncherAppState.getInstance(); + DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); FolderIcon icon = (FolderIcon) LayoutInflater.from(launcher).inflate(resId, group, false); icon.setClipToPadding(false); icon.mFolderName = (BubbleTextView) icon.findViewById(R.id.folder_icon_name); icon.mFolderName.setText(folderInfo.title); - icon.mPreviewBackground = (ImageView) icon.findViewById(R.id.preview_background); - LauncherAppState app = LauncherAppState.getInstance(); - DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); + icon.mFolderName.setCompoundDrawablePadding(0); + FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) icon.mFolderName.getLayoutParams(); + lp.topMargin = grid.iconSizePx + grid.iconDrawablePaddingPx; + // Offset the preview background to center this view accordingly - LinearLayout.LayoutParams lp = - (LinearLayout.LayoutParams) icon.mPreviewBackground.getLayoutParams(); + icon.mPreviewBackground = (ImageView) icon.findViewById(R.id.preview_background); + lp = (FrameLayout.LayoutParams) icon.mPreviewBackground.getLayoutParams(); lp.topMargin = grid.folderBackgroundOffset; lp.width = grid.folderIconSizePx; lp.height = grid.folderIconSizePx; @@ -537,12 +540,10 @@ public class FolderIcon extends LinearLayout implements FolderListener { if (d != null) { mOldBounds.set(d.getBounds()); d.setBounds(0, 0, mIntrinsicIconSize, mIntrinsicIconSize); - d.setFilterBitmap(true); d.setColorFilter(Color.argb(params.overlayAlpha, 255, 255, 255), PorterDuff.Mode.SRC_ATOP); d.draw(canvas); d.clearColorFilter(); - d.setFilterBitmap(false); d.setBounds(mOldBounds); } canvas.restore(); diff --git a/src/com/android/launcher3/IconCache.java b/src/com/android/launcher3/IconCache.java index 543b8ee2d..a55fce01c 100644 --- a/src/com/android/launcher3/IconCache.java +++ b/src/com/android/launcher3/IconCache.java @@ -156,7 +156,7 @@ public class IconCache { Iterator<Entry<ComponentName, CacheEntry>> it = mCache.entrySet().iterator(); while (it.hasNext()) { final CacheEntry e = it.next().getValue(); - if (e.icon.getWidth() != grid.iconSizePx || e.icon.getHeight() != grid.iconSizePx) { + if (e.icon.getWidth() < grid.iconSizePx || e.icon.getHeight() < grid.iconSizePx) { it.remove(); } } diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index f35daaade..29e8fe969 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -305,6 +305,7 @@ public class Launcher extends Activity private Drawable mWorkspaceBackgroundDrawable; private final ArrayList<Integer> mSynchronouslyBoundPages = new ArrayList<Integer>(); + private static final boolean DISABLE_SYNCHRONOUS_BINDING_CURRENT_PAGE = false; static final ArrayList<String> sDumpLogs = new ArrayList<String>(); static Date sDateStamp = new Date(); @@ -390,6 +391,7 @@ public class Launcher extends Activity display.getRealSize(realSize); DisplayMetrics dm = new DisplayMetrics(); display.getMetrics(dm); + // Lazy-initialize the dynamic grid DeviceProfile grid = app.initDynamicGrid(this, Math.min(smallestSize.x, smallestSize.y), @@ -437,18 +439,12 @@ public class Launcher extends Activity mSavedState = savedInstanceState; restoreState(mSavedState); - // Update customization drawer _after_ restoring the states - if (mAppsCustomizeContent != null) { - mAppsCustomizeContent.onPackagesUpdated( - LauncherModel.getSortedWidgetsAndShortcuts(this)); - } - if (PROFILE_STARTUP) { android.os.Debug.stopMethodTracing(); } if (!mRestoring) { - if (sPausedFromUserAction) { + if (DISABLE_SYNCHRONOUS_BINDING_CURRENT_PAGE || sPausedFromUserAction) { // If the user leaves launcher, then we should just load items asynchronously when // they return. mModel.startLoader(true, -1); @@ -3963,6 +3959,8 @@ public class Launcher extends Activity } else { if (mAppsCustomizeContent != null) { mAppsCustomizeContent.setApps(apps); + mAppsCustomizeContent.onPackagesUpdated( + LauncherModel.getSortedWidgetsAndShortcuts(this)); } } } diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java index a255b89a2..fe2b43fe4 100644 --- a/src/com/android/launcher3/LauncherAppState.java +++ b/src/com/android/launcher3/LauncherAppState.java @@ -28,7 +28,7 @@ import android.view.Display; import java.lang.ref.WeakReference; -public class LauncherAppState { +public class LauncherAppState implements DeviceProfile.DeviceProfileCallbacks { private static final String TAG = "LauncherAppState"; private static final String SHARED_PREFERENCES_KEY = "com.android.launcher3.prefs"; @@ -182,12 +182,12 @@ public class LauncherAppState { context.getResources(), minWidth, minHeight, width, height, availableWidth, availableHeight); + mDynamicGrid.getDeviceProfile().addCallback(this); } // Update the icon size DeviceProfile grid = mDynamicGrid.getDeviceProfile(); - Utilities.setIconSize(grid.iconSizePx); - grid.updateFromConfiguration(context.getResources(), width, height, + grid.updateFromConfiguration(context, context.getResources(), width, height, availableWidth, availableHeight); return grid; } @@ -216,4 +216,9 @@ public class LauncherAppState { public int getLongPressTimeout() { return mLongPressTimeout; } + + @Override + public void onAvailableSizeChanged(DeviceProfile grid) { + Utilities.setIconSize(grid.iconSizePx); + } } diff --git a/src/com/android/launcher3/PagedViewIcon.java b/src/com/android/launcher3/PagedViewIcon.java index 8bfe42d24..865c0b286 100644 --- a/src/com/android/launcher3/PagedViewIcon.java +++ b/src/com/android/launcher3/PagedViewIcon.java @@ -62,15 +62,19 @@ public class PagedViewIcon extends TextView { // Ensure we are using the right text size LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); - setTextSize(TypedValue.COMPLEX_UNIT_SP, grid.iconTextSize); + setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.iconTextSizePx); } public void applyFromApplicationInfo(AppInfo info, boolean scaleUp, PagedViewIcon.PressedCallback cb) { + LauncherAppState app = LauncherAppState.getInstance(); + DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); + mIcon = info.iconBitmap; mPressedCallback = cb; setCompoundDrawables(null, Utilities.createIconDrawable(mIcon), null, null); + setCompoundDrawablePadding(grid.iconDrawablePaddingPx); setText(info.title); setTag(info); } diff --git a/src/com/android/launcher3/PagedViewWidget.java b/src/com/android/launcher3/PagedViewWidget.java index 45320a484..d2f897a33 100644 --- a/src/com/android/launcher3/PagedViewWidget.java +++ b/src/com/android/launcher3/PagedViewWidget.java @@ -84,11 +84,11 @@ public class PagedViewWidget extends LinearLayout { DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); TextView name = (TextView) findViewById(R.id.widget_name); if (name != null) { - name.setTextSize(TypedValue.COMPLEX_UNIT_SP, grid.iconTextSize); + name.setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.iconTextSizePx); } TextView dims = (TextView) findViewById(R.id.widget_dims); if (dims != null) { - dims.setTextSize(TypedValue.COMPLEX_UNIT_SP, grid.iconTextSize); + dims.setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.iconTextSizePx); } } |