mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 23:28:42 +03:00
Updated to work with latest update
This commit is contained in:
parent
a75ffde65f
commit
3dc9a78696
3 changed files with 13 additions and 52 deletions
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<size android:width="20dp"
|
||||
android:height="20dp" />
|
||||
<solid android:color="@android:color/black"/>
|
||||
</shape>
|
|
@ -14,65 +14,39 @@ import android.graphics.drawable.Drawable;
|
|||
public class TextDrawable extends Drawable {
|
||||
|
||||
private final String text;
|
||||
private final Integer color;
|
||||
private final Float size;
|
||||
private final Paint paint;
|
||||
private final Paint bg;
|
||||
|
||||
public TextDrawable(String text, int r, int g, int b, float size) {
|
||||
public TextDrawable(String text, int r, int g, int b) {
|
||||
|
||||
this.text = text;
|
||||
this.color = Color.rgb(r, g, b);
|
||||
this.size = size;
|
||||
Integer color = Color.rgb(r, g, b);
|
||||
|
||||
// this.paint = new Paint();
|
||||
//// paint.setColor(Color.BLACK);
|
||||
//// paint.setTextSize(18f);
|
||||
//// paint.setAntiAlias(true);
|
||||
//// paint.setFakeBoldText(true);
|
||||
//
|
||||
//// paint.setARGB(255, r, g, b);
|
||||
//// paint.setStyle(Paint.Style.FILL);
|
||||
//// paint.setTextAlign(Paint.Align.CENTER);
|
||||
//
|
||||
//
|
||||
// paint.setColor(Color.BLACK);
|
||||
// paint.setTextSize(22f);
|
||||
// paint.setAntiAlias(true);
|
||||
// paint.setFakeBoldText(true);
|
||||
// paint.setTextAlign(Paint.Align.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
// TODO Paint in Constructor
|
||||
Paint bg = new Paint();
|
||||
bg = new Paint();
|
||||
bg.setStyle(Paint.Style.FILL);
|
||||
bg.setColor(color);
|
||||
canvas.drawRect(0,-20,20,40,bg);
|
||||
|
||||
Paint paint = new Paint();
|
||||
paint = new Paint();
|
||||
paint.setColor(Color.WHITE);
|
||||
paint.setTextSize(20);
|
||||
paint.setAntiAlias(true);
|
||||
paint.setFakeBoldText(true);
|
||||
// paint.setTextAlign(Paint.Align.CENTER);
|
||||
}
|
||||
|
||||
Rect bounds = new Rect();
|
||||
paint.getTextBounds(text, 0, text.length(), bounds);
|
||||
int x = (canvas.getWidth() / 2) - (bounds.width() / 2);
|
||||
int y = (canvas.getHeight() / 2) - (bounds.height() / 2);
|
||||
|
||||
// canvas.drawText(text, x, y, paint);
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
canvas.drawRect(0,-20,20,40,bg);
|
||||
canvas.drawText(text, 4, 6, paint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
// paint.setAlpha(alpha);
|
||||
paint.setAlpha(alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter cf) {
|
||||
// paint.setColorFilter(cf);
|
||||
paint.setColorFilter(cf);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -161,13 +161,7 @@ public class NavigationDrawerListAdapter extends BaseAdapter {
|
|||
|
||||
int[] rgb = BitmapUtils.HSLtoRGB(hue, 90.0f, 65.0f, 1.0f);
|
||||
|
||||
// Drawable drawable = MainApp.getAppContext().getResources().getDrawable(R.drawable.radiobutton_avatar);
|
||||
// drawable.setColorFilter(Color.rgb(rgb[0], rgb[1], rgb[2]), PorterDuff.Mode.SRC_ATOP);
|
||||
|
||||
|
||||
|
||||
TextDrawable text = new TextDrawable(username.substring(0, 1).toUpperCase(), rgb[0], rgb[1], rgb[2], rb.getTextSize());
|
||||
|
||||
TextDrawable text = new TextDrawable(username.substring(0, 1).toUpperCase(), rgb[0], rgb[1], rgb[2]);
|
||||
rb.setCompoundDrawablesWithIntrinsicBounds(text, null, null, null);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue