Skip to content
Snippets Groups Projects
Verified Commit 9ab1bdca authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Fixes scale for shortcut icons

parent bb1bce23
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -764,7 +764,11 @@ class ChatActivity : ServiceBoundActivity(), SharedPreferences.OnSharedPreferenc ...@@ -764,7 +764,11 @@ class ChatActivity : ServiceBoundActivity(), SharedPreferences.OnSharedPreferenc
val initial = rawInitial?.toUpperCase().toString() val initial = rawInitial?.toUpperCase().toString()
val senderColor = senderColors[senderColorIndex] val senderColor = senderColors[senderColorIndex]
val fallback = colorContext.prepareTextDrawable().buildRect(initial, senderColor) val fallback = colorContext.prepareTextDrawable()
.beginConfig()
.scale(0.5f)
.endConfig()
.buildRect(initial, senderColor)
val urls = viewModel.networks.value?.get(info.networkId)?.ircUser(info.bufferName)?.let { val urls = viewModel.networks.value?.get(info.networkId)?.ircUser(info.bufferName)?.let {
AvatarHelper.avatar(messageSettings, it, 432) AvatarHelper.avatar(messageSettings, it, 432)
......
...@@ -50,6 +50,7 @@ public class TextDrawable extends ShapeDrawable { ...@@ -50,6 +50,7 @@ public class TextDrawable extends ShapeDrawable {
private final int fontSize; private final int fontSize;
private final float radius; private final float radius;
private final int borderThickness; private final int borderThickness;
private final float scale;
private TextDrawable(Builder builder) { private TextDrawable(Builder builder) {
super(builder.shape); super(builder.shape);
...@@ -60,6 +61,8 @@ public class TextDrawable extends ShapeDrawable { ...@@ -60,6 +61,8 @@ public class TextDrawable extends ShapeDrawable {
width = builder.width; width = builder.width;
radius = builder.radius; radius = builder.radius;
scale = builder.scale;
// text and color // text and color
text = builder.toUpperCase ? builder.text.toUpperCase(Locale.getDefault()) : builder.text; text = builder.toUpperCase ? builder.text.toUpperCase(Locale.getDefault()) : builder.text;
...@@ -114,7 +117,7 @@ public class TextDrawable extends ShapeDrawable { ...@@ -114,7 +117,7 @@ public class TextDrawable extends ShapeDrawable {
// draw text // draw text
int width = this.width < 0 ? r.width() : this.width; int width = this.width < 0 ? r.width() : this.width;
int height = this.height < 0 ? r.height() : this.height; int height = this.height < 0 ? r.height() : this.height;
int fontSize = this.fontSize < 0 ? (int) (Math.min(width, height) * 0.67) : this.fontSize; int fontSize = this.fontSize < 0 ? (int) (Math.min(width, height) * scale) : this.fontSize;
textPaint.setTextSize(fontSize); textPaint.setTextSize(fontSize);
canvas.drawText(text, width / 2, height / 2 - ((textPaint.descent() + textPaint.ascent()) / 2), textPaint); canvas.drawText(text, width / 2, height / 2 - ((textPaint.descent() + textPaint.ascent()) / 2), textPaint);
...@@ -165,6 +168,8 @@ public class TextDrawable extends ShapeDrawable { ...@@ -165,6 +168,8 @@ public class TextDrawable extends ShapeDrawable {
IConfigBuilder height(int height); IConfigBuilder height(int height);
IConfigBuilder scale(float scale);
IConfigBuilder textColor(int color); IConfigBuilder textColor(int color);
IConfigBuilder withBorder(int thickness); IConfigBuilder withBorder(int thickness);
...@@ -203,6 +208,7 @@ public class TextDrawable extends ShapeDrawable { ...@@ -203,6 +208,7 @@ public class TextDrawable extends ShapeDrawable {
public static class Builder implements IConfigBuilder, IShapeBuilder, IBuilder { public static class Builder implements IConfigBuilder, IShapeBuilder, IBuilder {
public int textColor; public int textColor;
public float radius; public float radius;
private float scale;
private String text; private String text;
private int color; private int color;
private int borderThickness; private int borderThickness;
...@@ -221,6 +227,7 @@ public class TextDrawable extends ShapeDrawable { ...@@ -221,6 +227,7 @@ public class TextDrawable extends ShapeDrawable {
borderThickness = 0; borderThickness = 0;
width = -1; width = -1;
height = -1; height = -1;
scale = 0.67f;
shape = new RectShape(); shape = new RectShape();
font = Typeface.create("sans-serif-light", Typeface.NORMAL); font = Typeface.create("sans-serif-light", Typeface.NORMAL);
fontSize = -1; fontSize = -1;
...@@ -228,41 +235,55 @@ public class TextDrawable extends ShapeDrawable { ...@@ -228,41 +235,55 @@ public class TextDrawable extends ShapeDrawable {
toUpperCase = false; toUpperCase = false;
} }
@Override
public IConfigBuilder width(int width) { public IConfigBuilder width(int width) {
this.width = width; this.width = width;
return this; return this;
} }
@Override
public IConfigBuilder height(int height) { public IConfigBuilder height(int height) {
this.height = height; this.height = height;
return this; return this;
} }
@Override
public IConfigBuilder textColor(int color) { public IConfigBuilder textColor(int color) {
this.textColor = color; this.textColor = color;
return this; return this;
} }
@Override
public IConfigBuilder scale(float scale) {
this.scale = scale;
return this;
}
@Override
public IConfigBuilder withBorder(int thickness) { public IConfigBuilder withBorder(int thickness) {
this.borderThickness = thickness; this.borderThickness = thickness;
return this; return this;
} }
@Override
public IConfigBuilder useFont(Typeface font) { public IConfigBuilder useFont(Typeface font) {
this.font = font; this.font = font;
return this; return this;
} }
@Override
public IConfigBuilder fontSize(int size) { public IConfigBuilder fontSize(int size) {
this.fontSize = size; this.fontSize = size;
return this; return this;
} }
@Override
public IConfigBuilder bold() { public IConfigBuilder bold() {
this.isBold = true; this.isBold = true;
return this; return this;
} }
@Override
public IConfigBuilder toUpperCase() { public IConfigBuilder toUpperCase() {
this.toUpperCase = true; this.toUpperCase = true;
return this; return this;
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
android:viewportHeight="108" android:viewportHeight="108"
android:viewportWidth="108"> android:viewportWidth="108">
<path <path
android:fillColor="#fff" android:fillColor="#8affffff"
android:pathData="m47.116,47.211 0.885,-6.39a1.875,1.875 0 0 1 3.714,0.51l-0.81,5.859 8.337, android:pathData="m47.116,47.211 0.885,-6.39a1.875,1.875 0 0 1 3.714,0.51l-0.81,5.859 8.337,
-0.045 0.879,-6.327a1.876,1.876 0 0 1 3.717,0.513l-0.804,5.796 4.827,-0.024a1.876,1.876 0 1 1 -0.045 0.879,-6.327a1.876,1.876 0 0 1 3.717,0.513l-0.804,5.796 4.827,-0.024a1.876,1.876 0 1 1
0.018,3.75l-5.367,0.027-0.993,7.164 5.136,-0.027a1.875,1.875 0 0 1 0.021,3.747l-5.676,0.03-0.915 0.018,3.75l-5.367,0.027-0.993,7.164 5.136,-0.027a1.875,1.875 0 0 1 0.021,3.747l-5.676,0.03-0.915
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
android:viewportHeight="108" android:viewportHeight="108"
android:viewportWidth="108"> android:viewportWidth="108">
<path <path
android:fillColor="#fff" android:fillColor="#8affffff"
android:pathData="m 54,40 a 7,7 0 0 1 7,7 7,7 0 0 1 -7,7 7,7 0 0 1 -7,-7 7,7 0 0 1 7,-7 m 0,17 c android:pathData="m 54,40 a 7,7 0 0 1 7,7 7,7 0 0 1 -7,7 7,7 0 0 1 -7,-7 7,7 0 0 1 7,-7 m 0,17 c
7.735,0 14,3.1325 14,7 l 0,3.5 -28,0 0,-3.5 c 0,-3.8675 6.265,-7 14,-7 z" /> 7.735,0 14,3.1325 14,7 l 0,3.5 -28,0 0,-3.5 c 0,-3.8675 6.265,-7 14,-7 z" />
</vector> </vector>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment