am ee8ee0ee: Merge "Put DessertCase on a diet." into klp-dev
* commit 'ee8ee0eeb8d61ab80981356c1a5683ae294f5233': Put DessertCase on a diet.
This commit is contained in:
@@ -200,7 +200,8 @@
|
||||
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
|
||||
android:hardwareAccelerated="true"
|
||||
android:launchMode="singleInstance"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="locked"
|
||||
android:process=":sweetsweetdesserts"
|
||||
android:excludeFromRecents="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
@@ -215,6 +216,7 @@
|
||||
android:exported="true"
|
||||
android:label="@string/dessert_case"
|
||||
android:enabled="false"
|
||||
android:process=":sweetsweetdesserts"
|
||||
>
|
||||
<intent-filter>
|
||||
<action android:name="android.service.dreams.DreamService" />
|
||||
|
||||
@@ -96,6 +96,13 @@ public class DessertCaseView extends FrameLayout {
|
||||
1f, 0f, 0f, 0f, 0f
|
||||
};
|
||||
|
||||
private static final float[] ALPHA_MASK = {
|
||||
0f, 0f, 0f, 0f, 255f,
|
||||
0f, 0f, 0f, 0f, 255f,
|
||||
0f, 0f, 0f, 0f, 255f,
|
||||
0f, 0f, 0f, 1f, 0f
|
||||
};
|
||||
|
||||
private static final float[] WHITE_MASK = {
|
||||
0f, 0f, 0f, 0f, 255f,
|
||||
0f, 0f, 0f, 0f, 255f,
|
||||
@@ -162,8 +169,8 @@ public class DessertCaseView extends FrameLayout {
|
||||
for (int[] list : new int[][] { PASTRIES, RARE_PASTRIES, XRARE_PASTRIES, XXRARE_PASTRIES }) {
|
||||
for (int resid : list) {
|
||||
final BitmapDrawable d = new BitmapDrawable(res,
|
||||
BitmapFactory.decodeResource(res, resid, opts));
|
||||
d.setColorFilter(new ColorMatrixColorFilter(MASK));
|
||||
convertToAlphaMask(BitmapFactory.decodeResource(res, resid, opts)));
|
||||
d.setColorFilter(new ColorMatrixColorFilter(ALPHA_MASK));
|
||||
d.setBounds(0, 0, mCellSize, mCellSize);
|
||||
mDrawables.append(resid, d);
|
||||
}
|
||||
@@ -171,6 +178,15 @@ public class DessertCaseView extends FrameLayout {
|
||||
if (DEBUG) setWillNotDraw(false);
|
||||
}
|
||||
|
||||
private static Bitmap convertToAlphaMask(Bitmap b) {
|
||||
Bitmap a = Bitmap.createBitmap(b.getWidth(), b.getHeight(), Bitmap.Config.ALPHA_8);
|
||||
Canvas c = new Canvas(a);
|
||||
Paint pt = new Paint();
|
||||
pt.setColorFilter(new ColorMatrixColorFilter(MASK));
|
||||
c.drawBitmap(b, 0.0f, 0.0f, pt);
|
||||
return a;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
if (!mStarted) {
|
||||
mStarted = true;
|
||||
@@ -273,9 +289,9 @@ public class DessertCaseView extends FrameLayout {
|
||||
|
||||
final float which = frand();
|
||||
final Drawable d;
|
||||
if (which < 0.001f) {
|
||||
if (which < 0.0005f) {
|
||||
d = mDrawables.get(pick(XXRARE_PASTRIES));
|
||||
} else if (which < 0.01f) {
|
||||
} else if (which < 0.005f) {
|
||||
d = mDrawables.get(pick(XRARE_PASTRIES));
|
||||
} else if (which < 0.5f) {
|
||||
d = mDrawables.get(pick(RARE_PASTRIES));
|
||||
@@ -288,8 +304,7 @@ public class DessertCaseView extends FrameLayout {
|
||||
v.getOverlay().add(d);
|
||||
}
|
||||
|
||||
final Paint paint = new Paint();
|
||||
v.setLayerType(View.LAYER_TYPE_HARDWARE, paint);
|
||||
v.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||
|
||||
lp.width = lp.height = mCellSize;
|
||||
addView(v, lp);
|
||||
|
||||
Reference in New Issue
Block a user