文件夹改成九宫格模式
This commit is contained in:
@@ -471,7 +471,7 @@ public class CellLayout extends ViewGroup implements Transposable {
|
|||||||
cellToPoint(bg.delegateCellX, bg.delegateCellY, mTempLocation);
|
cellToPoint(bg.delegateCellX, bg.delegateCellY, mTempLocation);
|
||||||
canvas.save();
|
canvas.save();
|
||||||
canvas.translate(mTempLocation[0], mTempLocation[1]);
|
canvas.translate(mTempLocation[0], mTempLocation[1]);
|
||||||
bg.drawBackground(canvas);
|
bg.drawBackground(canvas,getContext());
|
||||||
if (!bg.isClipping) {
|
if (!bg.isClipping) {
|
||||||
bg.drawBackgroundStroke(canvas);
|
bg.drawBackgroundStroke(canvas);
|
||||||
}
|
}
|
||||||
@@ -813,9 +813,9 @@ public class CellLayout extends ViewGroup implements Transposable {
|
|||||||
@Override
|
@Override
|
||||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||||
int left = getPaddingLeft();
|
int left = getPaddingLeft();
|
||||||
left += (int) Math.ceil(getUnusedHorizontalSpace() / 2f);
|
// left += (int) Math.ceil(getUnusedHorizontalSpace() / 2f);
|
||||||
int right = r - l - getPaddingRight();
|
int right = r - l - getPaddingRight();
|
||||||
right -= (int) Math.ceil(getUnusedHorizontalSpace() / 2f);
|
// right -= (int) Math.ceil(getUnusedHorizontalSpace() / 2f);
|
||||||
|
|
||||||
int top = getPaddingTop();
|
int top = getPaddingTop();
|
||||||
int bottom = b - t - getPaddingBottom();
|
int bottom = b - t - getPaddingBottom();
|
||||||
@@ -2553,11 +2553,13 @@ public class CellLayout extends ViewGroup implements Transposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getDesiredWidth() {
|
public int getDesiredWidth() {
|
||||||
return getPaddingLeft() + getPaddingRight() + (mCountX * mCellWidth);
|
return getPaddingLeft() + getPaddingRight() + (4 * mCellWidth);
|
||||||
|
//固定返回文件夹宽度
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDesiredHeight() {
|
public int getDesiredHeight() {
|
||||||
return getPaddingTop() + getPaddingBottom() + (mCountY * mCellHeight);
|
return getPaddingTop() + getPaddingBottom() + (4 * mCellHeight);
|
||||||
|
//固定返回文件夹高度
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOccupied(int x, int y) {
|
public boolean isOccupied(int x, int y) {
|
||||||
|
|||||||
@@ -102,8 +102,8 @@ public class FolderAdaptiveIcon extends AdaptiveIconDrawable {
|
|||||||
|
|
||||||
// Initialize badge
|
// Initialize badge
|
||||||
c.setBitmap(badgeBitmap);
|
c.setBitmap(badgeBitmap);
|
||||||
bg.drawShadow(c);
|
// bg.drawShadow(c);
|
||||||
bg.drawBackgroundStroke(c);
|
// bg.drawBackgroundStroke(c);
|
||||||
icon.drawDot(c);
|
icon.drawDot(c);
|
||||||
|
|
||||||
// Initialize preview
|
// Initialize preview
|
||||||
|
|||||||
@@ -2,10 +2,11 @@ package com.android.uiuios.folder;
|
|||||||
|
|
||||||
public class ClippedFolderIconLayoutRule {
|
public class ClippedFolderIconLayoutRule {
|
||||||
|
|
||||||
public static final int MAX_NUM_ITEMS_IN_PREVIEW = 4;
|
// public static final int MAX_NUM_ITEMS_IN_PREVIEW = 4;
|
||||||
|
static final int MAX_NUM_ITEMS_IN_PREVIEW = Integer.MAX_VALUE;
|
||||||
private static final int MIN_NUM_ITEMS_IN_PREVIEW = 2;
|
private static final int MIN_NUM_ITEMS_IN_PREVIEW = 2;
|
||||||
|
|
||||||
private static final float MIN_SCALE = 0.48f;
|
private static final float MIN_SCALE = 0.15f;
|
||||||
private static final float MAX_SCALE = 0.58f;
|
private static final float MAX_SCALE = 0.58f;
|
||||||
private static final float MAX_RADIUS_DILATION = 0.15f;
|
private static final float MAX_RADIUS_DILATION = 0.15f;
|
||||||
private static final float ITEM_RADIUS_SCALE_FACTOR = 1.33f;
|
private static final float ITEM_RADIUS_SCALE_FACTOR = 1.33f;
|
||||||
@@ -53,6 +54,11 @@ public class ClippedFolderIconLayoutRule {
|
|||||||
|
|
||||||
transX = mTmpPoint[0];
|
transX = mTmpPoint[0];
|
||||||
transY = mTmpPoint[1];
|
transY = mTmpPoint[1];
|
||||||
|
int padl = 15;
|
||||||
|
int padt = 15;
|
||||||
|
int tempIndex = index % 9;
|
||||||
|
transX = padl + mIconSize * MIN_SCALE * getCol(tempIndex) + getCol(tempIndex) * 5;
|
||||||
|
transY = padt + mIconSize * MIN_SCALE * (getRow(tempIndex) - 1) + (getRow(tempIndex) - 1) * 5;
|
||||||
|
|
||||||
if (params == null) {
|
if (params == null) {
|
||||||
params = new PreviewItemDrawingParams(transX, transY, totalScale, overlayAlpha);
|
params = new PreviewItemDrawingParams(transX, transY, totalScale, overlayAlpha);
|
||||||
@@ -63,6 +69,16 @@ public class ClippedFolderIconLayoutRule {
|
|||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 20180702 modify begin */
|
||||||
|
private int getRow(int index) {
|
||||||
|
return index / 4 + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getCol(int index) {
|
||||||
|
return (index) % 4;
|
||||||
|
}
|
||||||
|
/* 20180702 modify end */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a grid based on the positioning of the items when there are
|
* Builds a grid based on the positioning of the items when there are
|
||||||
* {@link #MAX_NUM_ITEMS_IN_PREVIEW} in the preview.
|
* {@link #MAX_NUM_ITEMS_IN_PREVIEW} in the preview.
|
||||||
@@ -137,7 +153,8 @@ public class ClippedFolderIconLayoutRule {
|
|||||||
} else {
|
} else {
|
||||||
scale = MIN_SCALE;
|
scale = MIN_SCALE;
|
||||||
}
|
}
|
||||||
return scale * mBaselineIconScale;
|
return MIN_SCALE * mBaselineIconScale;
|
||||||
|
// return scale * mBaselineIconScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getIconSize() {
|
public float getIconSize() {
|
||||||
|
|||||||
@@ -490,7 +490,7 @@ public class FolderIcon extends FrameLayout implements FolderListener {
|
|||||||
mPreviewItemManager.recomputePreviewDrawingParams();
|
mPreviewItemManager.recomputePreviewDrawingParams();
|
||||||
|
|
||||||
if (!mBackground.drawingDelegated()) {
|
if (!mBackground.drawingDelegated()) {
|
||||||
mBackground.drawBackground(canvas);
|
mBackground.drawBackground(canvas,getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mFolder == null) return;
|
if (mFolder == null) return;
|
||||||
@@ -502,7 +502,8 @@ public class FolderIcon extends FrameLayout implements FolderListener {
|
|||||||
canvas.restoreToCount(saveCount);
|
canvas.restoreToCount(saveCount);
|
||||||
|
|
||||||
if (!mBackground.drawingDelegated()) {
|
if (!mBackground.drawingDelegated()) {
|
||||||
mBackground.drawBackgroundStroke(canvas);
|
// mBackground.drawBackgroundStroke(canvas);
|
||||||
|
//边框
|
||||||
}
|
}
|
||||||
|
|
||||||
drawDot(canvas);
|
drawDot(canvas);
|
||||||
|
|||||||
@@ -91,9 +91,10 @@ public class FolderPagedView extends PagedView<PageIndicatorDots> {
|
|||||||
public FolderPagedView(Context context, AttributeSet attrs) {
|
public FolderPagedView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
InvariantDeviceProfile profile = LauncherAppState.getIDP(context);
|
InvariantDeviceProfile profile = LauncherAppState.getIDP(context);
|
||||||
mMaxCountX = profile.numFolderColumns;
|
// mMaxCountX = profile.numFolderColumns;
|
||||||
mMaxCountY = profile.numFolderRows;
|
// mMaxCountY = profile.numFolderRows;
|
||||||
|
mMaxCountX = 4;
|
||||||
|
mMaxCountY = 4;
|
||||||
mMaxItemsPerPage = mMaxCountX * mMaxCountY;
|
mMaxItemsPerPage = mMaxCountX * mMaxCountY;
|
||||||
|
|
||||||
mInflater = LayoutInflater.from(context);
|
mInflater = LayoutInflater.from(context);
|
||||||
@@ -127,27 +128,36 @@ public class FolderPagedView extends PagedView<PageIndicatorDots> {
|
|||||||
done = true;
|
done = true;
|
||||||
} else {
|
} else {
|
||||||
done = false;
|
done = false;
|
||||||
|
/* 添加新计算 begin */
|
||||||
|
if(count >4){
|
||||||
|
gridCountX = 4;
|
||||||
|
gridCountY = (count+1)/4 + 1;
|
||||||
|
}else{
|
||||||
|
gridCountX = count;
|
||||||
|
gridCountY =1 ;
|
||||||
|
}
|
||||||
|
/* 添加新计算 end */
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!done) {
|
// while (!done) {
|
||||||
int oldCountX = gridCountX;
|
// int oldCountX = gridCountX;
|
||||||
int oldCountY = gridCountY;
|
// int oldCountY = gridCountY;
|
||||||
if (gridCountX * gridCountY < count) {
|
// if (gridCountX * gridCountY < count) {
|
||||||
// Current grid is too small, expand it
|
// // Current grid is too small, expand it
|
||||||
if ((gridCountX <= gridCountY || gridCountY == maxCountY)
|
// if ((gridCountX <= gridCountY || gridCountY == maxCountY)
|
||||||
&& gridCountX < maxCountX) {
|
// && gridCountX < maxCountX) {
|
||||||
gridCountX++;
|
// gridCountX++;
|
||||||
} else if (gridCountY < maxCountY) {
|
// } else if (gridCountY < maxCountY) {
|
||||||
gridCountY++;
|
// gridCountY++;
|
||||||
}
|
// }
|
||||||
if (gridCountY == 0) gridCountY++;
|
// if (gridCountY == 0) gridCountY++;
|
||||||
} else if ((gridCountY - 1) * gridCountX >= count && gridCountY >= gridCountX) {
|
// } else if ((gridCountY - 1) * gridCountX >= count && gridCountY >= gridCountX) {
|
||||||
gridCountY = Math.max(0, gridCountY - 1);
|
// gridCountY = Math.max(0, gridCountY - 1);
|
||||||
} else if ((gridCountX - 1) * gridCountY >= count) {
|
// } else if ((gridCountX - 1) * gridCountY >= count) {
|
||||||
gridCountX = Math.max(0, gridCountX - 1);
|
// gridCountX = Math.max(0, gridCountX - 1);
|
||||||
}
|
// }
|
||||||
done = gridCountX == oldCountX && gridCountY == oldCountY;
|
// done = gridCountX == oldCountX && gridCountY == oldCountY;
|
||||||
}
|
// }
|
||||||
|
|
||||||
out[0] = gridCountX;
|
out[0] = gridCountX;
|
||||||
out[1] = gridCountY;
|
out[1] = gridCountY;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import android.graphics.RadialGradient;
|
|||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.Region;
|
import android.graphics.Region;
|
||||||
import android.graphics.Shader;
|
import android.graphics.Shader;
|
||||||
|
import android.util.Log;
|
||||||
import android.util.Property;
|
import android.util.Property;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
@@ -210,12 +211,31 @@ public class PreviewBackground {
|
|||||||
return mDotColor;
|
return mDotColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawBackground(Canvas canvas) {
|
public void drawBackground(Canvas canvas,Context context) {
|
||||||
mPaint.setStyle(Paint.Style.FILL);
|
mPaint.setStyle(Paint.Style.FILL);
|
||||||
mPaint.setColor(getBgColor());
|
mPaint.setColor(getBgColor());
|
||||||
|
// Bitmap bitmap =BitmapFactory.decodeResource(context.getResources(), R.drawable.square);
|
||||||
|
// float radius = getScaledRadius();
|
||||||
|
// canvas.drawBitmap(bitmap,0 + getOffsetX(),0 + getOffsetY() ,mPaint);
|
||||||
|
drawCircle(canvas, 0 /* deltaRadius */);
|
||||||
|
// getShape().drawShape(canvas, getOffsetX(), getOffsetY(), getScaledRadius(), mPaint);
|
||||||
|
// drawShadow(canvas);
|
||||||
|
}
|
||||||
|
|
||||||
getShape().drawShape(canvas, getOffsetX(), getOffsetY(), getScaledRadius(), mPaint);
|
private void drawCircle(Canvas canvas,float deltaRadius) {
|
||||||
drawShadow(canvas);
|
Log.e("fht", "drawCircle: previewSize:" + previewSize );
|
||||||
|
Log.e("fht", "drawCircle: getScaledRadius:" + getScaledRadius() );
|
||||||
|
Log.e("fht", "drawCircle: getOffsetX:" + getOffsetX());
|
||||||
|
Log.e("fht", "drawCircle: getOffsetY:" + getOffsetY());
|
||||||
|
float radius = getScaledRadius()-4;
|
||||||
|
Log.e("fht", "drawCircle: radius:" + radius);
|
||||||
|
|
||||||
|
/* 20180702 modify begin */
|
||||||
|
// canvas.drawCircle(radius + getOffsetX(), radius + getOffsetY(),
|
||||||
|
// radius - deltaRadius, mPaint);
|
||||||
|
mPaint.setAlpha(76);
|
||||||
|
canvas.drawRoundRect(0 + getOffsetX() + 6, 0 + getOffsetY() + 6 , radius * 2 + getOffsetX() + 2,radius * 2 + getOffsetY() + 2, 30, 30, mPaint);
|
||||||
|
/* 20180702 modify end */
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawShadow(Canvas canvas) {
|
public void drawShadow(Canvas canvas) {
|
||||||
|
|||||||
Reference in New Issue
Block a user