Fixing several layout issues.

- N7/N9 indented area should not block scroll view
- separator at the end of the widget cell should not show up on the last item.

Not covered in this CL:
- Guarantee that last item is showing only 20~40%. Right now, the
hand picked constant works for N5,6,7,9

b/20338324
b/20763871

Change-Id: I274ab95c6c3e2fc8be8ceafb2e8172c0174a41a5
This commit is contained in:
Hyunyoung Song
2015-05-12 15:36:20 -07:00
parent fc9d3d8bcb
commit 5cd1d92f6c
7 changed files with 74 additions and 139 deletions

View File

@@ -51,14 +51,13 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
private static final int FADE_IN_DURATION_MS = 90;
/** Widget cell width is calculated by multiplying this factor to grid cell width. */
private static final float WIDTH_SCALE = 2.8f;
private static final float WIDTH_SCALE = 2.6f;
/** Widget preview width is calculated by multiplying this factor to the widget cell width. */
private static final float PREVIEW_SCALE = 0.9f;
private static final float PREVIEW_SCALE = 0.8f;
private static int mPresetPreviewSize;
private static int mSize;
private static int mDividerWidth;
private int mPresetPreviewSize;
int cellSize;
private ImageView mWidgetImage;
private TextView mWidgetName;
@@ -93,14 +92,9 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
}
private void setContainerWidth() {
// Do nothing if already set
if (mSize > 0) {
return;
}
DeviceProfile profile = LauncherAppState.getInstance().getDynamicGrid().getDeviceProfile();
mSize = (int) (profile.cellWidthPx * WIDTH_SCALE);
cellSize = (int) (profile.cellWidthPx * WIDTH_SCALE);
mPresetPreviewSize = (int) (profile.cellWidthPx * WIDTH_SCALE * PREVIEW_SCALE);
mDividerWidth = getResources().getDimensionPixelSize(R.dimen.widget_row_divider);
}
@Override
@@ -117,12 +111,6 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
mWidgetDims = ((TextView) findViewById(R.id.widget_dims));
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(MeasureSpec.makeMeasureSpec(mSize, MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(mSize, MeasureSpec.EXACTLY));
}
/**
* Called to clear the view and free attached resources. (e.g., {@link Bitmap}
*/
@@ -133,7 +121,6 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
mWidgetImage.setImageDrawable(null);
mWidgetName.setText(null);
mWidgetDims.setText(null);
setSeparator(true);
if (mActiveRequest != null) {
mActiveRequest.cleanup();
@@ -254,11 +241,4 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
}
return "";
}
public void setSeparator(boolean enable) {
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) getLayoutParams();
lp.setMarginEnd(enable? mDividerWidth : 0);
setLayoutParams(lp);
requestLayout();
}
}