default cover can be styled in themes.xml
This commit is contained in:
parent
abdc3d5c62
commit
12027036df
@ -33,6 +33,12 @@ THE SOFTWARE.
|
|||||||
<color name="vanillaAccent">#455A64</color>
|
<color name="vanillaAccent">#455A64</color>
|
||||||
<color name="material_grey_900">#ff212121</color>
|
<color name="material_grey_900">#ff212121</color>
|
||||||
|
|
||||||
|
<!-- styling of the default cover bitmap -->
|
||||||
|
<color name="defaultcover_background">@color/overlay_background_color</color>
|
||||||
|
<color name="defaultcover_gradient_begin">@color/divider_color</color>
|
||||||
|
<color name="defaultcover_gradient_end">@color/divider_color</color>
|
||||||
|
<color name="defaultcover_center">#55ffffff</color>
|
||||||
|
|
||||||
<!-- styles -->
|
<!-- styles -->
|
||||||
<style name="Dialog" parent="android:Theme.Material.Light.Dialog" />
|
<style name="Dialog" parent="android:Theme.Material.Light.Dialog" />
|
||||||
<style name="DialogMinWidth" parent="android:Theme.Material.Light.Dialog.MinWidth" />
|
<style name="DialogMinWidth" parent="android:Theme.Material.Light.Dialog.MinWidth" />
|
||||||
|
@ -28,6 +28,12 @@ THE SOFTWARE.
|
|||||||
<color name="overlay_foreground_color">#ffb2b2b2</color>
|
<color name="overlay_foreground_color">#ffb2b2b2</color>
|
||||||
<color name="float_color">#f222</color>
|
<color name="float_color">#f222</color>
|
||||||
|
|
||||||
|
<!-- styling of the default cover bitmap -->
|
||||||
|
<color name="defaultcover_background">#ff000000</color>
|
||||||
|
<color name="defaultcover_gradient_begin">#ff606060</color>
|
||||||
|
<color name="defaultcover_gradient_end">#ff404040</color>
|
||||||
|
<color name="defaultcover_center">#88000000</color>
|
||||||
|
|
||||||
<!-- styles -->
|
<!-- styles -->
|
||||||
<style name="Dialog" parent="android:Theme.Holo.Dialog" />
|
<style name="Dialog" parent="android:Theme.Holo.Dialog" />
|
||||||
<style name="DialogMinWidth" parent="android:Theme.Holo.Dialog.MinWidth" />
|
<style name="DialogMinWidth" parent="android:Theme.Holo.Dialog.MinWidth" />
|
||||||
|
@ -333,14 +333,21 @@ public final class CoverBitmap {
|
|||||||
* @param height The max height
|
* @param height The max height
|
||||||
* @return The default cover.
|
* @return The default cover.
|
||||||
*/
|
*/
|
||||||
public static Bitmap generateDefaultCover(int width, int height)
|
public static Bitmap generateDefaultCover(Context context, int width, int height)
|
||||||
{
|
{
|
||||||
int size = Math.min(width, height);
|
int size = Math.min(width, height);
|
||||||
int halfSize = size / 2;
|
int halfSize = size / 2;
|
||||||
int eightSize = size / 8;
|
int eightSize = size / 8;
|
||||||
|
|
||||||
Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.RGB_565);
|
int rgb_background = context.getResources().getColor(R.color.defaultcover_background);
|
||||||
LinearGradient gradient = new LinearGradient(size, 0, 0, size, 0xff646464, 0xff464646, Shader.TileMode.CLAMP);
|
int rgb_gardient_begin = context.getResources().getColor(R.color.defaultcover_gradient_begin);
|
||||||
|
int rgb_gardient_end = context.getResources().getColor(R.color.defaultcover_gradient_end);
|
||||||
|
int rgb_center = context.getResources().getColor(R.color.defaultcover_center);
|
||||||
|
|
||||||
|
Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
|
||||||
|
bitmap.eraseColor(rgb_background);
|
||||||
|
|
||||||
|
LinearGradient gradient = new LinearGradient(size, 0, 0, size, rgb_gardient_begin, rgb_gardient_end, Shader.TileMode.CLAMP);
|
||||||
RectF oval = new RectF(eightSize, 0, size - eightSize, size);
|
RectF oval = new RectF(eightSize, 0, size - eightSize, size);
|
||||||
|
|
||||||
Paint paint = new Paint();
|
Paint paint = new Paint();
|
||||||
@ -355,12 +362,13 @@ public final class CoverBitmap {
|
|||||||
canvas.drawOval(oval, paint);
|
canvas.drawOval(oval, paint);
|
||||||
|
|
||||||
paint.setShader(null);
|
paint.setShader(null);
|
||||||
paint.setColor(0xff000000);
|
paint.setColor(rgb_center);
|
||||||
canvas.translate(size / 3, size / 3);
|
canvas.translate(size / 3, size / 3);
|
||||||
canvas.scale(0.333f, 0.333f);
|
canvas.scale(0.333f, 0.333f);
|
||||||
canvas.drawOval(oval, paint);
|
canvas.drawOval(oval, paint);
|
||||||
|
|
||||||
paint.setShader(gradient);
|
paint.setShader(null);
|
||||||
|
paint.setColor(rgb_background);
|
||||||
canvas.translate(size / 3, size / 3);
|
canvas.translate(size / 3, size / 3);
|
||||||
canvas.scale(0.333f, 0.333f);
|
canvas.scale(0.333f, 0.333f);
|
||||||
canvas.drawOval(oval, paint);
|
canvas.drawOval(oval, paint);
|
||||||
|
@ -366,7 +366,7 @@ public final class CoverView extends View implements Handler.Callback {
|
|||||||
if (cover == null && style == CoverBitmap.STYLE_NO_INFO) {
|
if (cover == null && style == CoverBitmap.STYLE_NO_INFO) {
|
||||||
Bitmap def = mDefaultCover;
|
Bitmap def = mDefaultCover;
|
||||||
if (def == null) {
|
if (def == null) {
|
||||||
mDefaultCover = def = CoverBitmap.generateDefaultCover(getWidth(), getHeight());
|
mDefaultCover = def = CoverBitmap.generateDefaultCover(context, getWidth(), getHeight());
|
||||||
}
|
}
|
||||||
mBitmaps[i] = def;
|
mBitmaps[i] = def;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user