Fixed the check drawable getting black when on white background. Replaced the check drawable with lower dp. Moved two files to another package.
|
|
@ -17,8 +17,8 @@ import com.kabouzeid.gramophone.dialogs.ColorChooserDialog;
|
||||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||||
import com.kabouzeid.gramophone.misc.SmallOnGestureListener;
|
import com.kabouzeid.gramophone.misc.SmallOnGestureListener;
|
||||||
import com.kabouzeid.gramophone.model.MusicRemoteEvent;
|
import com.kabouzeid.gramophone.model.MusicRemoteEvent;
|
||||||
import com.kabouzeid.gramophone.ui.widget.PlayPauseDrawable;
|
|
||||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||||
|
import com.kabouzeid.gramophone.views.PlayPauseDrawable;
|
||||||
import com.melnykov.fab.FloatingActionButton;
|
import com.melnykov.fab.FloatingActionButton;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,38 +15,38 @@ import android.widget.FrameLayout;
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
|
|
||||||
public class CircleView extends FrameLayout {
|
public class CircleView extends FrameLayout {
|
||||||
|
|
||||||
private final Bitmap mCheck;
|
private final Bitmap mCheck;
|
||||||
private final Paint paint;
|
private final Paint paint;
|
||||||
private final Paint paintBorder;
|
private final Paint paintBorder;
|
||||||
private Paint paintCheck;
|
private Paint paintCheck;
|
||||||
private final int borderWidth;
|
private final int borderWidth;
|
||||||
|
|
||||||
public CircleView(Context context) {
|
public CircleView(Context context) {
|
||||||
this(context, null, 0);
|
this(context, null, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CircleView(Context context, AttributeSet attrs) {
|
public CircleView(Context context, AttributeSet attrs) {
|
||||||
this(context, attrs, 0);
|
this(context, attrs, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CircleView(Context context, AttributeSet attrs, int defStyleAttr) {
|
public CircleView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
final int checkSize = (int) context.getResources().getDimension(R.dimen.circle_view_check);
|
final int checkSize = (int) context.getResources().getDimension(R.dimen.circle_view_check);
|
||||||
mCheck = getResizedBitmap(BitmapFactory.decodeResource(context.getResources(),
|
mCheck = getResizedBitmap(BitmapFactory.decodeResource(context.getResources(),
|
||||||
R.drawable.ic_check), checkSize, checkSize);
|
R.drawable.ic_check_white_24dp), checkSize, checkSize);
|
||||||
borderWidth = (int) getResources().getDimension(R.dimen.circle_view_border);
|
borderWidth = (int) getResources().getDimension(R.dimen.circle_view_border);
|
||||||
|
|
||||||
paint = new Paint();
|
paint = new Paint();
|
||||||
paint.setAntiAlias(true);
|
paint.setAntiAlias(true);
|
||||||
|
|
||||||
paintBorder = new Paint();
|
paintBorder = new Paint();
|
||||||
paintBorder.setAntiAlias(true);
|
paintBorder.setAntiAlias(true);
|
||||||
paintBorder.setColor(Color.BLACK);
|
paintBorder.setColor(Color.BLACK);
|
||||||
|
|
||||||
setWillNotDraw(false);
|
setWillNotDraw(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Bitmap getResizedBitmap(Bitmap bm, int newHeight, int newWidth) {
|
private static Bitmap getResizedBitmap(Bitmap bm, int newHeight, int newWidth) {
|
||||||
int width = bm.getWidth();
|
int width = bm.getWidth();
|
||||||
int height = bm.getHeight();
|
int height = bm.getHeight();
|
||||||
|
|
@ -55,29 +55,32 @@ public class CircleView extends FrameLayout {
|
||||||
Matrix matrix = new Matrix();
|
Matrix matrix = new Matrix();
|
||||||
matrix.postScale(scaleWidth, scaleHeight);
|
matrix.postScale(scaleWidth, scaleHeight);
|
||||||
Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false);
|
Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false);
|
||||||
bm.recycle();
|
if (bm != resizedBitmap) {
|
||||||
|
bm.recycle();
|
||||||
|
}
|
||||||
return resizedBitmap;
|
return resizedBitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBackgroundColor(int color) {
|
public void setBackgroundColor(int color) {
|
||||||
paint.setColor(color);
|
paint.setColor(color);
|
||||||
requestLayout();
|
requestLayout();
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBorderColor(int color) {
|
public void setBorderColor(int color) {
|
||||||
paintBorder.setColor(color);
|
paintBorder.setColor(color);
|
||||||
requestLayout();
|
requestLayout();
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
|
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
|
||||||
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
|
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
|
||||||
if (widthMode == MeasureSpec.EXACTLY && heightMode != MeasureSpec.EXACTLY) {
|
if (widthMode == MeasureSpec.EXACTLY && heightMode != MeasureSpec.EXACTLY) {
|
||||||
int width = MeasureSpec.getSize(widthMeasureSpec);
|
int width = MeasureSpec.getSize(widthMeasureSpec);
|
||||||
|
//noinspection SuspiciousNameCombination
|
||||||
int height = width;
|
int height = width;
|
||||||
if (heightMode == MeasureSpec.AT_MOST) {
|
if (heightMode == MeasureSpec.AT_MOST) {
|
||||||
height = Math.min(height, MeasureSpec.getSize(heightMeasureSpec));
|
height = Math.min(height, MeasureSpec.getSize(heightMeasureSpec));
|
||||||
|
|
@ -87,25 +90,28 @@ public class CircleView extends FrameLayout {
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDraw(Canvas canvas) {
|
protected void onDraw(Canvas canvas) {
|
||||||
super.onDraw(canvas);
|
super.onDraw(canvas);
|
||||||
|
|
||||||
int canvasSize = canvas.getWidth();
|
int canvasSize = canvas.getWidth();
|
||||||
if (canvas.getHeight() < canvasSize)
|
if (canvas.getHeight() < canvasSize)
|
||||||
canvasSize = canvas.getHeight();
|
canvasSize = canvas.getHeight();
|
||||||
|
|
||||||
int circleCenter = (canvasSize - (borderWidth * 2)) / 2;
|
int circleCenter = (canvasSize - (borderWidth * 2)) / 2;
|
||||||
canvas.drawCircle(circleCenter + borderWidth, circleCenter + borderWidth, ((canvasSize - (borderWidth * 2)) / 2) + borderWidth - 4.0f, paintBorder);
|
canvas.drawCircle(circleCenter + borderWidth, circleCenter + borderWidth, ((canvasSize - (borderWidth * 2)) / 2) + borderWidth - 4.0f, paintBorder);
|
||||||
canvas.drawCircle(circleCenter + borderWidth, circleCenter + borderWidth, ((canvasSize - (borderWidth * 2)) / 2) - 4.0f, paint);
|
canvas.drawCircle(circleCenter + borderWidth, circleCenter + borderWidth, ((canvasSize - (borderWidth * 2)) / 2) - 4.0f, paint);
|
||||||
|
|
||||||
if (isActivated()) {
|
if (isActivated()) {
|
||||||
final int offset = (canvasSize / 2) - (mCheck.getWidth() / 2);
|
final int offset = (canvasSize / 2) - (mCheck.getWidth() / 2);
|
||||||
if (paint.getColor() == Color.WHITE && paintCheck == null) {
|
if (paint.getColor() == Color.WHITE) {
|
||||||
paintCheck = new Paint();
|
if (paintCheck == null) {
|
||||||
paintCheck.setAntiAlias(true);
|
paintCheck = new Paint();
|
||||||
paintCheck.setColorFilter(new PorterDuffColorFilter(Color.BLACK, PorterDuff.Mode.SRC_IN));
|
paintCheck.setAntiAlias(true);
|
||||||
|
paintCheck.setColorFilter(new PorterDuffColorFilter(Color.BLACK, PorterDuff.Mode.SRC_IN));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
paintCheck = null;
|
paintCheck = null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.kabouzeid.gramophone.ui.widget;
|
package com.kabouzeid.gramophone.views;
|
||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.AnimatorListenerAdapter;
|
import android.animation.AnimatorListenerAdapter;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.kabouzeid.gramophone.ui.widget;
|
package com.kabouzeid.gramophone.views;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
Before Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/drawable-hdpi/ic_check_white_24dp.png
Normal file
|
After Width: | Height: | Size: 248 B |
|
Before Width: | Height: | Size: 613 B |
BIN
app/src/main/res/drawable-mdpi/ic_check_white_24dp.png
Normal file
|
After Width: | Height: | Size: 180 B |
|
Before Width: | Height: | Size: 1.3 KiB |
BIN
app/src/main/res/drawable-xhdpi/ic_check_white_24dp.png
Normal file
|
After Width: | Height: | Size: 297 B |
|
Before Width: | Height: | Size: 2.2 KiB |
BIN
app/src/main/res/drawable-xxhdpi/ic_check_white_24dp.png
Normal file
|
After Width: | Height: | Size: 407 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_check_white_24dp.png
Normal file
|
After Width: | Height: | Size: 516 B |
|
|
@ -15,7 +15,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<com.kabouzeid.gramophone.ui.widget.SquareImageView
|
<com.kabouzeid.gramophone.views.SquareImageView
|
||||||
android:id="@+id/image"
|
android:id="@+id/image"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<com.kabouzeid.gramophone.ui.widget.SquareImageView
|
<com.kabouzeid.gramophone.views.SquareImageView
|
||||||
android:id="@+id/image"
|
android:id="@+id/image"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:ignore="UnusedAttribute,UselessParent">
|
tools:ignore="UnusedAttribute,UselessParent">
|
||||||
|
|
||||||
<com.kabouzeid.gramophone.ui.widget.SquareImageView
|
<com.kabouzeid.gramophone.views.SquareImageView
|
||||||
android:id="@+id/album_art"
|
android:id="@+id/album_art"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
android:paddingLeft="16dp"
|
android:paddingLeft="16dp"
|
||||||
android:paddingStart="16dp">
|
android:paddingStart="16dp">
|
||||||
|
|
||||||
<com.kabouzeid.gramophone.ui.widget.SquareImageView
|
<com.kabouzeid.gramophone.views.SquareImageView
|
||||||
android:id="@+id/album_art"
|
android:id="@+id/album_art"
|
||||||
android:layout_width="40dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
android:paddingLeft="16dp"
|
android:paddingLeft="16dp"
|
||||||
android:paddingStart="16dp">
|
android:paddingStart="16dp">
|
||||||
|
|
||||||
<com.kabouzeid.gramophone.ui.widget.SquareImageView
|
<com.kabouzeid.gramophone.views.SquareImageView
|
||||||
android:id="@+id/image"
|
android:id="@+id/image"
|
||||||
android:layout_width="40dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
android:paddingLeft="16dp"
|
android:paddingLeft="16dp"
|
||||||
android:paddingStart="16dp">
|
android:paddingStart="16dp">
|
||||||
|
|
||||||
<com.kabouzeid.gramophone.ui.widget.SquareImageView
|
<com.kabouzeid.gramophone.views.SquareImageView
|
||||||
android:id="@+id/album_art"
|
android:id="@+id/album_art"
|
||||||
android:layout_width="40dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
|
|
|
||||||