Add proguard rules. Show unread count. Use compact font

This commit is contained in:
inorichi
2015-10-02 13:20:15 +02:00
parent ff26c38860
commit 7fe40525f2
7 changed files with 191 additions and 17 deletions

View File

@@ -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();
}
}