Replace TextDrawable with a Kotlin fork (#2929)

* Replace old TextDrawable with Kotlin fork

* Update androidx preferences library
This commit is contained in:
TacoTheDank
2020-04-22 21:23:44 -04:00
committed by GitHub
parent f7c139030f
commit 34f7e4d448
2 changed files with 12 additions and 9 deletions

View File

@ -14,10 +14,10 @@ import android.widget.TextView
import androidx.annotation.MenuRes
import androidx.appcompat.widget.PopupMenu
import androidx.recyclerview.widget.RecyclerView
import com.amulyakhare.textdrawable.TextDrawable
import com.amulyakhare.textdrawable.util.ColorGenerator
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
import com.google.android.material.snackbar.Snackbar
import com.kennyc.textdrawable.ColorGenerator
import com.kennyc.textdrawable.TextDrawable
import eu.kanade.tachiyomi.R
import kotlin.math.min
@ -93,11 +93,14 @@ fun ImageView.roundTextIcon(text: String) {
val letter = text.take(1).toUpperCase()
val size = min(this.width, this.height)
setImageDrawable(
TextDrawable.builder().beginConfig().width(size).height(size).textColor(Color.WHITE)
.useFont(Typeface.DEFAULT).endConfig().buildRound(
letter, ColorGenerator.MATERIAL.getColor(letter)
)
TextDrawable(
shape = TextDrawable.DRAWABLE_SHAPE_OVAL,
desiredWidth = size,
desiredHeight = size,
typeFace = Typeface.DEFAULT,
textColor = Color.WHITE,
text = letter,
color = ColorGenerator.MATERIAL.getColor(letter)
)
}