From 34f7e4d448e06505d36dc988f7ce73fd9ca824c6 Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Wed, 22 Apr 2020 21:23:44 -0400 Subject: [PATCH] Replace TextDrawable with a Kotlin fork (#2929) * Replace old TextDrawable with Kotlin fork * Update androidx preferences library --- app/build.gradle | 4 ++-- .../tachiyomi/util/view/ViewExtensions.kt | 17 ++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index a846b49eb5..59ee6d25aa 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -126,7 +126,7 @@ dependencies { implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.recyclerview:recyclerview:1.1.0' - implementation 'androidx.preference:preference:1.1.0' + implementation 'androidx.preference:preference:1.1.1' implementation 'androidx.annotation:annotation:1.1.0' implementation 'androidx.browser:browser:1.2.0' implementation 'androidx.multidex:multidex:2.0.1' @@ -219,7 +219,7 @@ dependencies { implementation 'eu.davidea:flexible-adapter:5.1.0' implementation 'eu.davidea:flexible-adapter-ui:1.0.0' implementation 'com.nononsenseapps:filepicker:2.5.2' - implementation 'com.github.amulyakhare:TextDrawable:558677e' + implementation 'com.github.Kennyc1012:TextDrawable:2.0.1' implementation 'com.nightlynexus.viewstatepageradapter:viewstatepageradapter:1.1.0' implementation 'com.github.mthli:Slice:v1.3' implementation 'com.github.chrisbanes:PhotoView:2.3.0' diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt index f3102d49ef..9de5ac717c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt @@ -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) ) }