mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-18 06:57:28 +01:00
Add proguard rules. Show unread count. Use compact font
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package eu.kanade.mangafeed.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.TextView;
|
||||
|
||||
import eu.kanade.mangafeed.R;
|
||||
|
||||
|
||||
public class PTSansTextView extends TextView {
|
||||
private final static int PTSANS_NARROW = 0;
|
||||
private final static int PTSANS_NARROW_BOLD = 1;
|
||||
|
||||
|
||||
public PTSansTextView(Context c) {
|
||||
super(c);
|
||||
}
|
||||
|
||||
public PTSansTextView(Context c, AttributeSet attrs) {
|
||||
super(c, attrs);
|
||||
parseAttributes(c, attrs);
|
||||
}
|
||||
|
||||
public PTSansTextView(Context c, AttributeSet attrs, int defStyle) {
|
||||
super(c, attrs, defStyle);
|
||||
parseAttributes(c, attrs);
|
||||
}
|
||||
|
||||
private void parseAttributes(Context c, AttributeSet attrs) {
|
||||
TypedArray values = c.obtainStyledAttributes(attrs, R.styleable.PTSansTextView);
|
||||
|
||||
//The value 0 is a default, but shouldn't ever be used since the attr is an enum
|
||||
int typeface = values.getInt(R.styleable.PTSansTextView_typeface, 0);
|
||||
|
||||
switch(typeface) {
|
||||
case PTSANS_NARROW:
|
||||
//You can instantiate your typeface anywhere, I would suggest as a
|
||||
//singleton somewhere to avoid unnecessary copies
|
||||
setTypeface(Typeface.createFromAsset(c.getAssets(), "fonts/PTSans-Narrow.ttf"));
|
||||
break;
|
||||
case PTSANS_NARROW_BOLD:
|
||||
setTypeface(Typeface.createFromAsset(c.getAssets(), "fonts/PTSans-NarrowBold.ttf"));
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Font not found " + typeface);
|
||||
}
|
||||
|
||||
values.recycle();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user