Altering the workspace padding to account for default widget padding (Bug 11116452)
This commit is contained in:
parent
3057b1c259
commit
f7d458543e
|
@ -16,11 +16,14 @@
|
||||||
|
|
||||||
package com.android.launcher3;
|
package com.android.launcher3;
|
||||||
|
|
||||||
|
import android.appwidget.AppWidgetHostView;
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.PointF;
|
|
||||||
import android.graphics.Paint.FontMetrics;
|
import android.graphics.Paint.FontMetrics;
|
||||||
|
import android.graphics.PointF;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
|
@ -64,7 +67,9 @@ class DeviceProfile {
|
||||||
boolean isLargeTablet;
|
boolean isLargeTablet;
|
||||||
boolean transposeLayoutWithOrientation;
|
boolean transposeLayoutWithOrientation;
|
||||||
|
|
||||||
|
int desiredWorkspaceLeftRightMarginPx;
|
||||||
int edgeMarginPx;
|
int edgeMarginPx;
|
||||||
|
Rect defaultWidgetPadding;
|
||||||
|
|
||||||
int widthPx;
|
int widthPx;
|
||||||
int heightPx;
|
int heightPx;
|
||||||
|
@ -109,7 +114,8 @@ class DeviceProfile {
|
||||||
hotseatIconSize = his;
|
hotseatIconSize = his;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceProfile(ArrayList<DeviceProfile> profiles,
|
DeviceProfile(Context context,
|
||||||
|
ArrayList<DeviceProfile> profiles,
|
||||||
float minWidth, float minHeight,
|
float minWidth, float minHeight,
|
||||||
int wPx, int hPx,
|
int wPx, int hPx,
|
||||||
int awPx, int ahPx,
|
int awPx, int ahPx,
|
||||||
|
@ -122,7 +128,11 @@ class DeviceProfile {
|
||||||
minWidthDps = minWidth;
|
minWidthDps = minWidth;
|
||||||
minHeightDps = minHeight;
|
minHeightDps = minHeight;
|
||||||
|
|
||||||
|
ComponentName cn = new ComponentName(context.getPackageName(),
|
||||||
|
this.getClass().getName());
|
||||||
|
defaultWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, cn, null);
|
||||||
edgeMarginPx = resources.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin);
|
edgeMarginPx = resources.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin);
|
||||||
|
desiredWorkspaceLeftRightMarginPx = 2 * edgeMarginPx;
|
||||||
pageIndicatorHeightPx = resources.getDimensionPixelSize(R.dimen.dynamic_grid_page_indicator_height);
|
pageIndicatorHeightPx = resources.getDimensionPixelSize(R.dimen.dynamic_grid_page_indicator_height);
|
||||||
|
|
||||||
// Interpolate the rows
|
// Interpolate the rows
|
||||||
|
@ -312,9 +322,9 @@ class DeviceProfile {
|
||||||
hotseatBarHeightPx + pageIndicatorHeightPx);
|
hotseatBarHeightPx + pageIndicatorHeightPx);
|
||||||
} else {
|
} else {
|
||||||
// Pad the top and bottom of the workspace with search/hotseat bar sizes
|
// Pad the top and bottom of the workspace with search/hotseat bar sizes
|
||||||
padding.set(edgeMarginPx,
|
padding.set(desiredWorkspaceLeftRightMarginPx - defaultWidgetPadding.left,
|
||||||
searchBarSpaceHeightPx,
|
searchBarSpaceHeightPx,
|
||||||
edgeMarginPx,
|
desiredWorkspaceLeftRightMarginPx - defaultWidgetPadding.right,
|
||||||
hotseatBarHeightPx + pageIndicatorHeightPx);
|
hotseatBarHeightPx + pageIndicatorHeightPx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -489,7 +499,8 @@ public class DynamicGrid {
|
||||||
size, metrics));
|
size, metrics));
|
||||||
}
|
}
|
||||||
|
|
||||||
public DynamicGrid(Resources resources, int minWidthPx, int minHeightPx,
|
public DynamicGrid(Context context, Resources resources,
|
||||||
|
int minWidthPx, int minHeightPx,
|
||||||
int widthPx, int heightPx,
|
int widthPx, int heightPx,
|
||||||
int awPx, int ahPx) {
|
int awPx, int ahPx) {
|
||||||
DisplayMetrics dm = resources.getDisplayMetrics();
|
DisplayMetrics dm = resources.getDisplayMetrics();
|
||||||
|
@ -526,7 +537,7 @@ public class DynamicGrid {
|
||||||
1527, 2527, 7, 7, 100, 20, 7, 72));
|
1527, 2527, 7, 7, 100, 20, 7, 72));
|
||||||
mMinWidth = dpiFromPx(minWidthPx, dm);
|
mMinWidth = dpiFromPx(minWidthPx, dm);
|
||||||
mMinHeight = dpiFromPx(minHeightPx, dm);
|
mMinHeight = dpiFromPx(minHeightPx, dm);
|
||||||
mProfile = new DeviceProfile(deviceProfiles,
|
mProfile = new DeviceProfile(context, deviceProfiles,
|
||||||
mMinWidth, mMinHeight,
|
mMinWidth, mMinHeight,
|
||||||
widthPx, heightPx,
|
widthPx, heightPx,
|
||||||
awPx, ahPx,
|
awPx, ahPx,
|
||||||
|
|
|
@ -178,7 +178,8 @@ public class LauncherAppState {
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int availableWidth, int availableHeight) {
|
int availableWidth, int availableHeight) {
|
||||||
if (mDynamicGrid == null) {
|
if (mDynamicGrid == null) {
|
||||||
mDynamicGrid = new DynamicGrid(context.getResources(),
|
mDynamicGrid = new DynamicGrid(context,
|
||||||
|
context.getResources(),
|
||||||
minWidth, minHeight, width, height,
|
minWidth, minHeight, width, height,
|
||||||
availableWidth, availableHeight);
|
availableWidth, availableHeight);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue