Commit 05fcbde6 authored by Dan Sandler's avatar Dan Sandler Committed by Android (Google) Code Review
Browse files

Merge "Stretch small wallpapers to cover the screen in the picker." into lmp-dev

parents 7aaebd5a e6851f57
master lollipop-cts-release lollipop-dev lollipop-mr1-cts-release lollipop-mr1-dev lollipop-mr1-fi-release lollipop-mr1-release lollipop-mr1-wfc-release lollipop-release lollipop-wear-release marshmallow-cts-release marshmallow-dev marshmallow-dr-dev marshmallow-dr-dragon-release marshmallow-dr-release marshmallow-dr1.5-dev marshmallow-dr1.5-release marshmallow-dr1.6-release marshmallow-mr1-dev marshmallow-mr1-release marshmallow-mr2-release marshmallow-mr3-release marshmallow-release master-soong nougat-cts-release nougat-dev nougat-dr1-release nougat-mr0.5-release nougat-mr1-cts-release nougat-mr1-dev nougat-mr1-release nougat-mr1.1-release nougat-mr1.2-release nougat-release rockchip-5.1.1_r33 sdk-release android-wear-n-preview-2 android-wear-n-preview-1 android-wear-5.1.1_r1 android-wear-5.1.0_r1 android-wear-5.0.0_r1 android-n-preview-5 android-n-preview-4 android-n-preview-3 android-n-preview-2 android-n-preview-1 android-n-mr1-preview-2 android-n-mr1-preview-1 android-m-preview android-m-preview-2 android-m-preview-1 android-cts-7.1_r1 android-cts-7.0_r5 android-cts-7.0_r4 android-cts-7.0_r3 android-cts-7.0_r2 android-cts-7.0_r1 android-cts-6.0_r14 android-cts-6.0_r13 android-cts-6.0_r12 android-cts-6.0_r9 android-cts-6.0_r8 android-cts-6.0_r7 android-cts-6.0_r6 android-cts-6.0_r5 android-cts-6.0_r4 android-cts-6.0_r3 android-cts-6.0_r2 android-cts-6.0_r1 android-cts-5.1_r15 android-cts-5.1_r14 android-cts-5.1_r13 android-cts-5.1_r10 android-cts-5.1_r9 android-cts-5.1_r8 android-cts-5.1_r7 android-cts-5.1_r6 android-cts-5.1_r5 android-cts-5.1_r4 android-cts-5.1_r3 android-cts-5.1_r2 android-cts-5.1_r1 android-cts-5.0_r9 android-cts-5.0_r8 android-cts-5.0_r7 android-cts-5.0_r6 android-cts-5.0_r5 android-cts-5.0_r4 android-cts-5.0_r3 android-7.1.1_r13 android-7.1.1_r12 android-7.1.1_r11 android-7.1.1_r10 android-7.1.1_r9 android-7.1.1_r8 android-7.1.1_r7 android-7.1.1_r6 android-7.1.1_r4 android-7.1.1_r3 android-7.1.1_r2 android-7.1.1_r1 android-7.1.0_r7 android-7.1.0_r6 android-7.1.0_r5 android-7.1.0_r4 android-7.1.0_r3 android-7.1.0_r2 android-7.1.0_r1 android-7.0.0_r27 android-7.0.0_r24 android-7.0.0_r21 android-7.0.0_r19 android-7.0.0_r17 android-7.0.0_r15 android-7.0.0_r14 android-7.0.0_r13 android-7.0.0_r12 android-7.0.0_r7 android-7.0.0_r6 android-7.0.0_r5 android-7.0.0_r4 android-7.0.0_r3 android-7.0.0_r1 android-6.0.1_r78 android-6.0.1_r77 android-6.0.1_r74 android-6.0.1_r73 android-6.0.1_r72 android-6.0.1_r70 android-6.0.1_r69 android-6.0.1_r68 android-6.0.1_r67 android-6.0.1_r66 android-6.0.1_r65 android-6.0.1_r63 android-6.0.1_r62 android-6.0.1_r61 android-6.0.1_r60 android-6.0.1_r59 android-6.0.1_r58 android-6.0.1_r57 android-6.0.1_r56 android-6.0.1_r55 android-6.0.1_r54 android-6.0.1_r53 android-6.0.1_r52 android-6.0.1_r51 android-6.0.1_r50 android-6.0.1_r49 android-6.0.1_r48 android-6.0.1_r47 android-6.0.1_r46 android-6.0.1_r45 android-6.0.1_r43 android-6.0.1_r42 android-6.0.1_r41 android-6.0.1_r40 android-6.0.1_r33 android-6.0.1_r32 android-6.0.1_r31 android-6.0.1_r30 android-6.0.1_r28 android-6.0.1_r27 android-6.0.1_r26 android-6.0.1_r25 android-6.0.1_r24 android-6.0.1_r22 android-6.0.1_r21 android-6.0.1_r20 android-6.0.1_r18 android-6.0.1_r17 android-6.0.1_r16 android-6.0.1_r13 android-6.0.1_r12 android-6.0.1_r11 android-6.0.1_r10 android-6.0.1_r9 android-6.0.1_r8 android-6.0.1_r7 android-6.0.1_r5 android-6.0.1_r4 android-6.0.1_r3 android-6.0.1_r1 android-6.0.0_r41 android-6.0.0_r26 android-6.0.0_r25 android-6.0.0_r24 android-6.0.0_r23 android-6.0.0_r13 android-6.0.0_r12 android-6.0.0_r11 android-6.0.0_r7 android-6.0.0_r6 android-6.0.0_r5 android-6.0.0_r4 android-6.0.0_r3 android-6.0.0_r2 android-6.0.0_r1 android-5.1.1_r38 android-5.1.1_r37 android-5.1.1_r36 android-5.1.1_r35 android-5.1.1_r34 android-5.1.1_r33 android-5.1.1_r30 android-5.1.1_r29 android-5.1.1_r28 android-5.1.1_r26 android-5.1.1_r25 android-5.1.1_r24 android-5.1.1_r23 android-5.1.1_r22 android-5.1.1_r20 android-5.1.1_r19 android-5.1.1_r18 android-5.1.1_r17 android-5.1.1_r16 android-5.1.1_r15 android-5.1.1_r14 android-5.1.1_r13 android-5.1.1_r12 android-5.1.1_r10 android-5.1.1_r9 android-5.1.1_r8 android-5.1.1_r7 android-5.1.1_r6 android-5.1.1_r5 android-5.1.1_r4 android-5.1.1_r3 android-5.1.1_r2 android-5.1.1_r1 android-5.1.0_r5 android-5.1.0_r4 android-5.1.0_r3 android-5.1.0_r1 android-5.0.2_r3 android-5.0.2_r1 android-5.0.1_r1 android-5.0.0_r7 android-5.0.0_r6 android-5.0.0_r5.1 android-5.0.0_r5 android-5.0.0_r4 android-5.0.0_r3 android-5.0.0_r2 android-5.0.0_r1
No related merge requests found
......@@ -26,6 +26,7 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Matrix;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
......@@ -323,6 +324,7 @@ public class WallpaperChooserDialogFragment extends DialogFragment implements
Bitmap mBitmap;
int mIntrinsicWidth;
int mIntrinsicHeight;
Matrix mMatrix;
/* package */void setBitmap(Bitmap bitmap) {
mBitmap = bitmap;
......@@ -330,16 +332,35 @@ public class WallpaperChooserDialogFragment extends DialogFragment implements
return;
mIntrinsicWidth = mBitmap.getWidth();
mIntrinsicHeight = mBitmap.getHeight();
mMatrix = null;
}
@Override
public void draw(Canvas canvas) {
if (mBitmap == null) return;
int width = canvas.getWidth();
int height = canvas.getHeight();
int x = (width - mIntrinsicWidth) / 2;
int y = (height - mIntrinsicHeight) / 2;
canvas.drawBitmap(mBitmap, x, y, null);
if (mMatrix == null) {
final int vwidth = canvas.getWidth();
final int vheight = canvas.getHeight();
final int dwidth = mIntrinsicWidth;
final int dheight = mIntrinsicHeight;
float scale = 1.0f;
if (dwidth < vwidth || dheight < vheight) {
scale = Math.max((float) vwidth / (float) dwidth,
(float) vheight / (float) dheight);
}
float dx = (vwidth - dwidth * scale) * 0.5f + 0.5f;
float dy = (vheight - dheight * scale) * 0.5f + 0.5f;
mMatrix = new Matrix();
mMatrix.setScale(scale, scale);
mMatrix.postTranslate((int) dx, (int) dy);
}
canvas.drawBitmap(mBitmap, mMatrix, null);
}
@Override
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment