Commit e6268a04 authored by Amit Kumar's avatar Amit Kumar
Browse files

Use green notification badge instead of red

parent b7ecc3db
package org.indin.blisslaunchero.notification;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.Log;
import org.indin.blisslaunchero.R;
/**
* Created by falcon on 20/3/18.
*/
......@@ -13,23 +18,32 @@ import android.util.Log;
public class DotRenderer {
private static final String TAG = "DotRenderer";
private static final float SIZE_PERCENTAGE = 0.25f;
private static final float SIZE_PERCENTAGE = 0.35f;
private final Context mContext;
private final int mSize;
private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG |
Paint.FILTER_BITMAP_FLAG);
public DotRenderer(int iconSizePx){
this.mSize = (int) (SIZE_PERCENTAGE *iconSizePx);
public DotRenderer(Context context, int iconSizePx) {
mContext = context;
this.mSize = (int) (SIZE_PERCENTAGE * iconSizePx);
}
public void drawDot(Canvas canvas, Rect iconBounds){
public void drawDot(Canvas canvas, Rect iconBounds) {
Log.d(TAG, "drawDot() called with: canvas = [" + canvas + "], iconBounds = [" + iconBounds
+ "]");
int badgeCenterX = (int) (iconBounds.left + mSize*0.25);
int badgeCenterY = (int) (iconBounds.top + mSize*0.25);
int badgeCenterX = (int) (iconBounds.left + mSize * 0.25);
int badgeCenterY = (int) (iconBounds.top + mSize * 0.25);
Bitmap myBitmap = BitmapFactory.decodeResource(
mContext.getResources(),
R.drawable.notification_icon_72);
Bitmap scaledBitmap = Bitmap.createScaledBitmap(myBitmap, mSize,mSize, true);
mPaint.setColor(Color.parseColor("#FF0800"));
canvas.drawCircle(badgeCenterX, badgeCenterY, mSize/2, mPaint);
canvas.drawBitmap(scaledBitmap, iconBounds.left - scaledBitmap.getWidth() / 3,
iconBounds.top - scaledBitmap.getHeight() / 3, null);
//canvas.drawCircle(badgeCenterX, badgeCenterY, mSize/2, mPaint);
}
}
......@@ -85,7 +85,7 @@ public class BlissFrameLayout extends FrameLayout {
private void drawBadgeIfNecessary(Canvas canvas) {
if (hasBadge) {
getIconBounds(mTempIconBounds);
DotRenderer dotRenderer = new DotRenderer(LauncherActivity.appIconWidth);
DotRenderer dotRenderer = new DotRenderer(mContext, LauncherActivity.appIconWidth);
dotRenderer.drawDot(canvas, mTempIconBounds);
}
}
......
Supports Markdown
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