mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-02 08:56:55 +00:00
Making launcher update widgets with min/max extents
Change-Id: Iba9325eeb95a8a8256ef6f59f4010aff09767892
This commit is contained in:
@@ -307,11 +307,38 @@ public class AppWidgetResizeFrame extends FrameLayout {
|
||||
lp.cellVSpan = spanY;
|
||||
mRunningVInc += vSpanDelta;
|
||||
mRunningHInc += hSpanDelta;
|
||||
if (!onDismiss) {
|
||||
updateWidgetSizeRanges(mWidgetView, mLauncher, spanX, spanY);
|
||||
}
|
||||
}
|
||||
|
||||
mWidgetView.requestLayout();
|
||||
}
|
||||
|
||||
static void updateWidgetSizeRanges(AppWidgetHostView widgetView, Launcher launcher,
|
||||
int spanX, int spanY) {
|
||||
Rect landMetrics = Workspace.getCellLayoutMetrics(launcher, CellLayout.LANDSCAPE);
|
||||
Rect portMetrics = Workspace.getCellLayoutMetrics(launcher, CellLayout.PORTRAIT);
|
||||
final float density = launcher.getResources().getDisplayMetrics().density;
|
||||
|
||||
// Compute landscape size
|
||||
int cellWidth = landMetrics.left;
|
||||
int cellHeight = landMetrics.top;
|
||||
int widthGap = landMetrics.right;
|
||||
int heightGap = landMetrics.bottom;
|
||||
int landWidth = (int) ((spanX * cellWidth + (spanX - 1) * widthGap) / density);
|
||||
int landHeight = (int) ((spanY * cellHeight + (spanY - 1) * heightGap) / density);
|
||||
|
||||
// Compute portrait size
|
||||
cellWidth = portMetrics.left;
|
||||
cellHeight = portMetrics.top;
|
||||
widthGap = portMetrics.right;
|
||||
heightGap = portMetrics.bottom;
|
||||
int portWidth = (int) ((spanX * cellWidth + (spanX - 1) * widthGap) / density);
|
||||
int portHeight = (int) ((spanY * cellHeight + (spanY - 1) * heightGap) / density);
|
||||
|
||||
widgetView.updateAppWidgetSize(null, portWidth, landHeight, landWidth, portHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the final step of the resize. Here we save the new widget size and position
|
||||
* to LauncherModel and animate the resize frame.
|
||||
|
||||
Reference in New Issue
Block a user