소스 검색

Add proguard rules. Show unread count. Use compact font

inorichi 9 년 전
부모
커밋
7fe40525f2

+ 79 - 1
app/proguard-rules.pro

@@ -15,4 +15,82 @@
 #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
 #   public *;
 #}
--dontwarn java.lang.invoke.*
+
+# Retrolambda
+-dontwarn java.lang.invoke.*
+
+# OkHttp
+-keepattributes Signature
+-keepattributes *Annotation*
+-keep class com.squareup.okhttp.** { *; }
+-keep interface com.squareup.okhttp.** { *; }
+-dontwarn com.squareup.okhttp.**
+-dontwarn okio.**
+
+# Butterknife
+-keep class butterknife.** { *; }
+-dontwarn butterknife.internal.**
+-keep class **$$ViewBinder { *; }
+
+-keepclasseswithmembernames class * {
+    @butterknife.* <fields>;
+}
+
+-keepclasseswithmembernames class * {
+    @butterknife.* <methods>;
+}
+
+#Easy-Adapter v1.5.0
+-keepattributes *Annotation*
+-keepclassmembers class * extends uk.co.ribot.easyadapter.ItemViewHolder {
+    public <init>(...);
+ }
+
+## GreenRobot EventBus specific rules ##
+# https://github.com/greenrobot/EventBus/blob/master/HOWTO.md#proguard-configuration
+-keepclassmembers class ** {
+    public void onEvent*(***);
+}
+
+# Only required if you use AsyncExecutor
+-keepclassmembers class * extends de.greenrobot.event.util.ThrowableFailureEvent {
+    public <init>(java.lang.Throwable);
+}
+
+# Don't warn for missing support classes
+-dontwarn de.greenrobot.event.util.*$Support
+-dontwarn de.greenrobot.event.util.*$SupportManagerFragment
+
+# Glide specific rules #
+# https://github.com/bumptech/glide
+-keep public class * implements com.bumptech.glide.module.GlideModule
+-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
+    **[] $VALUES;
+    public *;
+}
+
+
+# RxJava 0.21
+
+-keep class rx.schedulers.Schedulers {
+    public static <methods>;
+}
+-keep class rx.schedulers.ImmediateScheduler {
+    public <methods>;
+}
+-keep class rx.schedulers.TestScheduler {
+    public <methods>;
+}
+-keep class rx.schedulers.Schedulers {
+    public static ** test();
+}
+-dontwarn sun.misc.Unsafe
+
+# AppCombat
+-keep public class android.support.v7.widget.** { *; }
+-keep public class android.support.v7.internal.widget.** { *; }
+-keep public class android.support.v7.internal.view.menu.** { *; }
+
+-keep public class * extends android.support.v4.view.ActionProvider {
+    public <init>(android.content.Context);
+}

BIN
app/src/main/assets/fonts/PTSans-Narrow.ttf


BIN
app/src/main/assets/fonts/PTSans-NarrowBold.ttf


+ 13 - 6
app/src/main/java/eu/kanade/mangafeed/ui/adapter/MangaLibraryHolder.java

@@ -17,22 +17,29 @@ import uk.co.ribot.easyadapter.annotations.ViewId;
 @LayoutId(R.layout.item_library)
 public class MangaLibraryHolder extends ItemViewHolder<Manga> {
 
-    @ViewId(R.id.thumbnailImageView)
-    ImageView mImageView;
+    @ViewId(R.id.thumbnailImage)
+    ImageView mThumbImage;
 
-    @ViewId(R.id.nameTextView)
-    TextView mTextView;
+    @ViewId(R.id.titleText)
+    TextView mTitleText;
+
+    @ViewId(R.id.unreadText)
+    TextView mUnreadText;
 
     public MangaLibraryHolder(View view) {
         super(view);
     }
 
     public void onSetValues(Manga manga, PositionInfo positionInfo) {
-        mTextView.setText(manga.title);
+        mTitleText.setText(manga.title);
+        if (manga.unread > 0) {
+            mUnreadText.setVisibility(View.VISIBLE);
+            mUnreadText.setText(Integer.toString(manga.unread));
+        }
         Glide.with(getContext())
                 .load("http://img1.wikia.nocookie.net/__cb20090524204255/starwars/images/thumb/1/1a/R2d2.jpg/400px-R2d2.jpg")
                 .centerCrop()
-                .into(mImageView);
+                .into(mThumbImage);
     }
 
 }

+ 52 - 0
app/src/main/java/eu/kanade/mangafeed/widget/PTSansTextView.java

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

+ 33 - 10
app/src/main/res/layout/item_library.xml

@@ -2,35 +2,58 @@
 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:orientation="vertical"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     >
 
-    <ImageView
+    <FrameLayout
         android:layout_width="match_parent"
-        android:layout_height="144dp"
-        android:id="@+id/thumbnailImageView"
-        tools:src="@mipmap/ic_launcher"
-        tools:background="@color/md_red_100"/>
+        android:layout_height="wrap_content">
+
+        <ImageView
+            android:layout_width="match_parent"
+            android:layout_height="144dp"
+            android:id="@+id/thumbnailImage"
+            tools:src="@mipmap/ic_launcher"
+            tools:background="@color/md_red_100"/>
+
+        <eu.kanade.mangafeed.widget.PTSansTextView
+            android:id="@+id/unreadText"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="123"
+            app:typeface="ptsansNarrowBold"
+            android:background="@color/md_red_300"
+            android:layout_gravity="right"
+            android:textSize="12sp"
+            android:visibility="gone"
+            android:textColor="@color/white"
+            android:paddingLeft="3dp"
+            android:paddingRight="3dp"
+            android:paddingTop="1dp"
+            android:paddingBottom="1dp" />
+    </FrameLayout>
+
 
     <LinearLayout
         android:orientation="horizontal"
         android:layout_width="match_parent"
         android:layout_height="36dp"
         android:id="@+id/footerLinearLayout"
-        android:background="@color/md_blue_100">
+        android:background="@color/md_grey_300">
 
-        <TextView
+        <eu.kanade.mangafeed.widget.PTSansTextView
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_gravity="center_vertical"
+            app:typeface="ptsansNarrowBold"
             android:ellipsize="middle"
             android:maxLines="2"
             android:textColor="@color/black_87pc"
-            android:textStyle="bold"
-            android:textSize="12sp"
-            android:id="@+id/nameTextView"
+            android:textSize="13sp"
+            android:id="@+id/titleText"
             android:paddingRight="8dp"
             android:paddingLeft="8dp"
             tools:text="Sample name"/>

+ 14 - 0
app/src/main/res/values/attrs.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <!-- Define the values for the attribute -->
+    <attr name="typeface" format="enum">
+        <enum name="ptsansNarrow" value="0"/>
+        <enum name="ptsansNarrowBold" value="1"/>
+    </attr>
+
+    <!-- Tell Android that the class "CustomButton" can be styled,
+         and which attributes it supports -->
+    <declare-styleable name="PTSansTextView">
+        <attr name="typeface"/>
+    </declare-styleable>
+</resources>