瀏覽代碼

Use native fontFamily support for library titles

arkon 5 年之前
父節點
當前提交
9058536406

二進制
app/src/main/assets/fonts/PTSans-Narrow.ttf


+ 0 - 45
app/src/main/java/eu/kanade/tachiyomi/widget/PTSansTextView.kt

@@ -1,45 +0,0 @@
-package eu.kanade.tachiyomi.widget
-
-import android.content.Context
-import android.graphics.Canvas
-import android.graphics.Typeface
-import android.util.AttributeSet
-import androidx.appcompat.widget.AppCompatTextView
-import eu.kanade.tachiyomi.R
-import java.util.HashMap
-
-class PTSansTextView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
-        AppCompatTextView(context, attrs) {
-
-    companion object {
-        const val PTSANS_NARROW = 0
-        const val PTSANS_NARROW_BOLD = 1
-
-        // Map where typefaces are cached
-        private val typefaces = HashMap<Int, Typeface>(2)
-    }
-
-    init {
-        if (attrs != null) {
-            val values = context.obtainStyledAttributes(attrs, R.styleable.PTSansTextView)
-
-            val typeface = values.getInt(R.styleable.PTSansTextView_typeface, 0)
-
-            setTypeface(typefaces.getOrPut(typeface) {
-                Typeface.createFromAsset(context.assets, when (typeface) {
-                    PTSANS_NARROW -> "fonts/PTSans-Narrow.ttf"
-                    PTSANS_NARROW_BOLD -> "fonts/PTSans-NarrowBold.ttf"
-                    else -> throw IllegalArgumentException("Font not found $typeface")
-                })
-            })
-
-            values.recycle()
-        }
-    }
-
-    override fun onDraw(canvas: Canvas) {
-        // Draw two times for a more visible shadow around the text
-        super.onDraw(canvas)
-        super.onDraw(canvas)
-    }
-}

+ 0 - 0
app/src/main/assets/fonts/PTSans-NarrowBold.ttf → app/src/main/res/font/ptsans_narrow_bold.ttf


+ 2 - 2
app/src/main/res/layout/source_grid_item.xml

@@ -89,7 +89,7 @@
                 tools:visibility="visible" />
         </androidx.constraintlayout.widget.ConstraintLayout>
 
-        <eu.kanade.tachiyomi.widget.PTSansTextView
+        <TextView
             android:id="@+id/title"
             style="@style/TextAppearance.Regular.Body1.Light"
             android:layout_width="match_parent"
@@ -103,7 +103,7 @@
             android:shadowDx="0"
             android:shadowDy="0"
             android:shadowRadius="4"
-            app:typeface="ptsansNarrowBold"
+            android:fontFamily="@font/ptsans_narrow_bold"
             tools:text="Sample name" />
 
         <ProgressBar

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

@@ -1,15 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
 
-    <attr name="typeface" format="enum">
-        <enum name="ptsansNarrow" value="0"/>
-        <enum name="ptsansNarrowBold" value="1"/>
-    </attr>
-
-    <declare-styleable name="PTSansTextView">
-        <attr name="typeface"/>
-    </declare-styleable>
-
     <declare-styleable name="MinMaxNumberPicker">
         <attr name="min" format="integer"/>
         <attr name="max" format="integer"/>