Added 1dp borders to each color and added black and white colors.
This commit is contained in:
parent
222942b050
commit
e5b5fefc39
7 changed files with 39 additions and 59 deletions
|
|
@ -28,6 +28,9 @@
|
|||
<h3>Version 0.9.44 beta1</h3>
|
||||
|
||||
<ol>
|
||||
<li><b>IMPROVEMENT:</b> Completely rewritten color chooser. Had great help from <a
|
||||
href="https://plus.google.com/u/0/+AidanFollestad">Aidan Follestad</a> here once again.
|
||||
</li>
|
||||
<li><b>IMPROVEMENT:</b> Increased album cover quality when selecting the "ignore media store
|
||||
covers" option.
|
||||
</li>
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ public class ColorChooserDialog extends LeakDetectDialogFragment implements View
|
|||
|
||||
private void setIndexesFor(@ColorInt int color) {
|
||||
if (getTopIndex() != -1) return;
|
||||
if (color != -1) {
|
||||
if (color != 0) {
|
||||
for (int i = 0; i < colorSetWithHeaders.colors.length; i++) {
|
||||
for (int z = 0; z < colorSetWithHeaders.colors[i].length; z++) {
|
||||
if (color == colorSetWithHeaders.colors[i][z]) {
|
||||
|
|
@ -223,10 +223,10 @@ public class ColorChooserDialog extends LeakDetectDialogFragment implements View
|
|||
}
|
||||
SelectableColorView child = (SelectableColorView) convertView;
|
||||
if (isInSub()) {
|
||||
child.setBackgroundColor(colorSetWithHeaders.colors[getTopIndex()][position]);
|
||||
child.setColor(colorSetWithHeaders.colors[getTopIndex()][position]);
|
||||
child.setSelected(getSubIndex() == position);
|
||||
} else {
|
||||
child.setBackgroundColor(colorSetWithHeaders.colors[position][colorSetWithHeaders.headerColorIndexes[position]]);
|
||||
child.setColor(colorSetWithHeaders.colors[position][colorSetWithHeaders.headerColorIndexes[position]]);
|
||||
child.setSelected(getTopIndex() == position);
|
||||
}
|
||||
child.setTag(position);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class ColorPalette {
|
|||
5,
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
6,
|
||||
5
|
||||
};
|
||||
|
||||
|
|
@ -234,6 +234,7 @@ public class ColorPalette {
|
|||
Color.parseColor("#3E2723")
|
||||
},
|
||||
new int[]{
|
||||
Color.parseColor("#FFFFFF"), // not in the original palette
|
||||
Color.parseColor("#FAFAFA"),
|
||||
Color.parseColor("#F5F5F5"),
|
||||
Color.parseColor("#EEEEEE"),
|
||||
|
|
@ -244,6 +245,7 @@ public class ColorPalette {
|
|||
Color.parseColor("#616161"),
|
||||
Color.parseColor("#424242"),
|
||||
Color.parseColor("#212121"),
|
||||
Color.parseColor("#000000") // not in the original palette
|
||||
},
|
||||
new int[]{
|
||||
Color.parseColor("#ECEFF1"),
|
||||
|
|
@ -275,6 +277,7 @@ public class ColorPalette {
|
|||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
|
|
@ -376,5 +379,11 @@ public class ColorPalette {
|
|||
Color.parseColor("#ff3d00"),
|
||||
Color.parseColor("#dd2c00")
|
||||
},
|
||||
new int[]{
|
||||
Color.parseColor("#FFFFFF"), // not in the original palette
|
||||
Color.parseColor("#9E9E9E"), // not in the original palette
|
||||
Color.parseColor("#424242"), // not in the original palette
|
||||
Color.parseColor("#000000") // not in the original palette
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import com.kabouzeid.gramophone.views.ColorView;
|
|||
public class ColorChooserPreference extends Preference {
|
||||
|
||||
@ColorInt
|
||||
private int color = -1;
|
||||
private int color;
|
||||
private ColorView colorView;
|
||||
|
||||
public ColorChooserPreference(@NonNull Context context) {
|
||||
|
|
@ -44,9 +44,9 @@ public class ColorChooserPreference extends Preference {
|
|||
|
||||
private void invalidateColor() {
|
||||
if (colorView != null) {
|
||||
if (this.color != -1) {
|
||||
if (this.color != 0) {
|
||||
colorView.setVisibility(View.VISIBLE);
|
||||
colorView.setBackgroundColor(color);
|
||||
colorView.setColor(color);
|
||||
} else {
|
||||
colorView.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,8 +37,7 @@ public class ColorView extends FrameLayout {
|
|||
setWillNotDraw(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackgroundColor(int color) {
|
||||
public void setColor(int color) {
|
||||
paint.setColor(color);
|
||||
paintBorder.setColor(ColorUtil.shiftColorDown(color));
|
||||
requestLayout();
|
||||
|
|
@ -62,7 +61,6 @@ public class ColorView extends FrameLayout {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDraw(@NonNull Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ import android.graphics.drawable.StateListDrawable;
|
|||
import android.graphics.drawable.shapes.OvalShape;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.ColorRes;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.TypedValue;
|
||||
import android.widget.FrameLayout;
|
||||
|
|
@ -24,13 +22,15 @@ import com.kabouzeid.gramophone.util.ColorUtil;
|
|||
|
||||
public class SelectableColorView extends FrameLayout {
|
||||
|
||||
private boolean selected;
|
||||
|
||||
private final int borderWidthExtraSmall;
|
||||
private final int borderWidthSmall;
|
||||
private final int borderWidthLarge;
|
||||
|
||||
private Paint outerPaint;
|
||||
private Paint gapPaint;
|
||||
private Paint innerPaint;
|
||||
private boolean mSelected;
|
||||
|
||||
public SelectableColorView(Context context) {
|
||||
this(context, null, 0);
|
||||
|
|
@ -43,12 +43,13 @@ public class SelectableColorView extends FrameLayout {
|
|||
public SelectableColorView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
final Resources r = getResources();
|
||||
borderWidthExtraSmall = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, r.getDisplayMetrics());
|
||||
borderWidthSmall = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 3, r.getDisplayMetrics());
|
||||
borderWidthLarge = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, r.getDisplayMetrics());
|
||||
|
||||
gapPaint = new Paint();
|
||||
gapPaint.setAntiAlias(true);
|
||||
gapPaint.setColor(ColorUtil.resolveColor(context, R.attr.cardBackgroundColor));
|
||||
resetGapColor();
|
||||
|
||||
innerPaint = new Paint();
|
||||
innerPaint.setAntiAlias(true);
|
||||
|
|
@ -59,7 +60,11 @@ public class SelectableColorView extends FrameLayout {
|
|||
setWillNotDraw(false);
|
||||
}
|
||||
|
||||
private void update(@ColorInt int color) {
|
||||
private void resetGapColor() {
|
||||
gapPaint.setColor(ColorUtil.resolveColor(getContext(), R.attr.cardBackgroundColor));
|
||||
}
|
||||
|
||||
private void updateColor(@ColorInt int color) {
|
||||
innerPaint.setColor(color);
|
||||
outerPaint.setColor(ColorUtil.shiftColorDown(color));
|
||||
|
||||
|
|
@ -92,49 +97,15 @@ public class SelectableColorView extends FrameLayout {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackgroundColor(@ColorInt int color) {
|
||||
update(color);
|
||||
public void setColor(@ColorInt int color) {
|
||||
updateColor(color);
|
||||
requestLayout();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackgroundResource(@ColorRes int color) {
|
||||
setBackgroundColor(ContextCompat.getColor(getContext(), color));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public void setBackground(Drawable background) {
|
||||
throw new IllegalStateException("Cannot use setBackground() on CircleView.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
@Override
|
||||
public void setBackgroundDrawable(Drawable background) {
|
||||
throw new IllegalStateException("Cannot use setBackgroundDrawable() on CircleView.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
@Override
|
||||
public void setActivated(boolean activated) {
|
||||
throw new IllegalStateException("Cannot use setActivated() on CircleView.");
|
||||
}
|
||||
|
||||
public void setSelected(boolean selected) {
|
||||
mSelected = selected;
|
||||
this.selected = selected;
|
||||
requestLayout();
|
||||
invalidate();
|
||||
}
|
||||
|
|
@ -159,7 +130,7 @@ public class SelectableColorView extends FrameLayout {
|
|||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
final int outerRadius = getMeasuredWidth() / 2;
|
||||
if (mSelected) {
|
||||
if (selected) {
|
||||
final int whiteRadius = outerRadius - borderWidthLarge;
|
||||
final int innerRadius = whiteRadius - borderWidthSmall;
|
||||
canvas.drawCircle(getMeasuredWidth() / 2,
|
||||
|
|
@ -175,9 +146,14 @@ public class SelectableColorView extends FrameLayout {
|
|||
innerRadius,
|
||||
innerPaint);
|
||||
} else {
|
||||
final int innerRadius = outerRadius - borderWidthExtraSmall;
|
||||
canvas.drawCircle(getMeasuredWidth() / 2,
|
||||
getMeasuredHeight() / 2,
|
||||
outerRadius,
|
||||
outerPaint);
|
||||
canvas.drawCircle(getMeasuredWidth() / 2,
|
||||
getMeasuredHeight() / 2,
|
||||
innerRadius,
|
||||
innerPaint);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.kabouzeid.gramophone.views.ColorView
|
||||
android:id="@+id/color_view"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
Loading…
Add table
Add a link
Reference in a new issue