Merge "Make icon drawable for non-focused grid tasks smaller" into sc-v2-dev
This commit is contained in:
commit
42f914e254
5 files changed
+41
-6
No files matched your search
@@ -17,8 +17,10 @@ package com.android.quickstep.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.launcher3.Utilities;
|
||||
@@ -30,6 +32,7 @@ import com.android.launcher3.Utilities;
|
||||
public class IconView extends View {
|
||||
|
||||
private Drawable mDrawable;
|
||||
private int mDrawableWidth, mDrawableHeight;
|
||||
|
||||
public IconView(Context context) {
|
||||
super(context);
|
||||
@@ -50,11 +53,29 @@ public class IconView extends View {
|
||||
mDrawable = d;
|
||||
if (mDrawable != null) {
|
||||
mDrawable.setCallback(this);
|
||||
mDrawable.setBounds(0, 0, getWidth(), getHeight());
|
||||
setDrawableSizeInternal(getWidth(), getHeight());
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the size of the icon drawable.
|
||||
*/
|
||||
public void setDrawableSize(int iconWidth, int iconHeight) {
|
||||
mDrawableWidth = iconWidth;
|
||||
mDrawableHeight = iconHeight;
|
||||
if (mDrawable != null) {
|
||||
setDrawableSizeInternal(getWidth(), getHeight());
|
||||
}
|
||||
}
|
||||
|
||||
private void setDrawableSizeInternal(int selfWidth, int selfHeight) {
|
||||
Rect selfRect = new Rect(0, 0, selfWidth, selfHeight);
|
||||
Rect drawableRect = new Rect();
|
||||
Gravity.apply(Gravity.CENTER, mDrawableWidth, mDrawableHeight, selfRect, drawableRect);
|
||||
mDrawable.setBounds(drawableRect);
|
||||
}
|
||||
|
||||
public Drawable getDrawable() {
|
||||
return mDrawable;
|
||||
}
|
||||
@@ -63,7 +84,7 @@ public class IconView extends View {
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
if (mDrawable != null) {
|
||||
mDrawable.setBounds(0, 0, w, h);
|
||||
setDrawableSizeInternal(w, h);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1353,9 +1353,10 @@ public class TaskView extends FrameLayout implements Reusable {
|
||||
float boxTranslationY;
|
||||
int expectedWidth;
|
||||
int expectedHeight;
|
||||
if (mActivity.getDeviceProfile().overviewShowAsGrid) {
|
||||
final int thumbnailPadding =
|
||||
mActivity.getDeviceProfile().overviewTaskThumbnailTopMarginPx;
|
||||
int iconDrawableSize;
|
||||
DeviceProfile deviceProfile = mActivity.getDeviceProfile();
|
||||
if (deviceProfile.overviewShowAsGrid) {
|
||||
final int thumbnailPadding = deviceProfile.overviewTaskThumbnailTopMarginPx;
|
||||
final Rect lastComputedTaskSize = getRecentsView().getLastComputedTaskSize();
|
||||
final int taskWidth = lastComputedTaskSize.width();
|
||||
final int taskHeight = lastComputedTaskSize.height();
|
||||
@@ -1368,11 +1369,13 @@ public class TaskView extends FrameLayout implements Reusable {
|
||||
// that is associated with the original orientation of the focused task.
|
||||
boxWidth = taskWidth;
|
||||
boxHeight = taskHeight;
|
||||
iconDrawableSize = deviceProfile.overviewTaskIconDrawableSizePx;
|
||||
} else {
|
||||
// Otherwise task is in grid, and should use lastComputedGridTaskSize.
|
||||
Rect lastComputedGridTaskSize = getRecentsView().getLastComputedGridTaskSize();
|
||||
boxWidth = lastComputedGridTaskSize.width();
|
||||
boxHeight = lastComputedGridTaskSize.height();
|
||||
iconDrawableSize = deviceProfile.overviewTaskIconDrawableSizeGridPx;
|
||||
}
|
||||
|
||||
// Bound width/height to the box size.
|
||||
@@ -1389,6 +1392,7 @@ public class TaskView extends FrameLayout implements Reusable {
|
||||
boxTranslationY = 0f;
|
||||
expectedWidth = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
expectedHeight = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
iconDrawableSize = deviceProfile.overviewTaskIconDrawableSizePx;
|
||||
}
|
||||
|
||||
setNonGridScale(nonGridScale);
|
||||
@@ -1398,6 +1402,7 @@ public class TaskView extends FrameLayout implements Reusable {
|
||||
params.height = expectedHeight;
|
||||
setLayoutParams(params);
|
||||
}
|
||||
mIconView.setDrawableSize(iconDrawableSize, iconDrawableSize);
|
||||
}
|
||||
|
||||
private float getGridTrans(float endTranslation) {
|
||||
|
||||
Reference in new issue
Block a user