mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-30 22:07:57 +01:00 
			
		
		
		
	Remove TextDrawable
This commit is contained in:
		| @@ -23,13 +23,6 @@ class CategoryAdapter(controller: CategoryController) : | ||||
|         (0 until itemCount).forEach { getItem(it)?.isSelected = false } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Clears the active selections from the model. | ||||
|      */ | ||||
|     fun clearModelSelection() { | ||||
|         selectedPositions.forEach { getItem(it)?.isSelected = false } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Toggles the selection of the given position. | ||||
|      * | ||||
|   | ||||
| @@ -3,8 +3,6 @@ package eu.kanade.tachiyomi.ui.category | ||||
| import android.view.View | ||||
| import eu.kanade.tachiyomi.data.database.models.Category | ||||
| import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder | ||||
| import eu.kanade.tachiyomi.util.view.roundTextIcon | ||||
| import kotlinx.android.synthetic.main.categories_item.image | ||||
| import kotlinx.android.synthetic.main.categories_item.reorder | ||||
| import kotlinx.android.synthetic.main.categories_item.title | ||||
|  | ||||
| @@ -17,12 +15,6 @@ import kotlinx.android.synthetic.main.categories_item.title | ||||
| class CategoryHolder(view: View, val adapter: CategoryAdapter) : BaseFlexibleViewHolder(view, adapter) { | ||||
|  | ||||
|     init { | ||||
|         // Create round letter image onclick to simulate long click | ||||
|         image.setOnClickListener { | ||||
|             // Simulate long click on this view to enter selection mode | ||||
|             onLongClick(view) | ||||
|         } | ||||
|  | ||||
|         setDragHandleView(reorder) | ||||
|     } | ||||
|  | ||||
| @@ -34,11 +26,6 @@ class CategoryHolder(view: View, val adapter: CategoryAdapter) : BaseFlexibleVie | ||||
|     fun bind(category: Category) { | ||||
|         // Set capitalized title. | ||||
|         title.text = category.name.capitalize() | ||||
|  | ||||
|         // Update circle letter image. | ||||
|         itemView.post { | ||||
|             image.roundTextIcon(category.name) | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -100,7 +100,7 @@ class CategoryPresenter( | ||||
|     /** | ||||
|      * Returns true if a category with the given name already exists. | ||||
|      */ | ||||
|     fun categoryExists(name: String): Boolean { | ||||
|     private fun categoryExists(name: String): Boolean { | ||||
|         return categories.any { it.name.equals(name, true) } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -6,7 +6,6 @@ import eu.kanade.tachiyomi.source.icon | ||||
| import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder | ||||
| import eu.kanade.tachiyomi.ui.base.holder.SlicedHolder | ||||
| import eu.kanade.tachiyomi.util.view.gone | ||||
| import eu.kanade.tachiyomi.util.view.roundTextIcon | ||||
| import io.github.mthli.slice.Slice | ||||
| import kotlinx.android.synthetic.main.source_main_controller_card_item.card | ||||
| import kotlinx.android.synthetic.main.source_main_controller_card_item.image | ||||
| @@ -43,8 +42,9 @@ class SourceHolder(view: View, override val adapter: SourceAdapter) : | ||||
|         // Set circle letter image. | ||||
|         itemView.post { | ||||
|             val icon = source.icon() | ||||
|             if (icon != null) image.setImageDrawable(icon) | ||||
|             else image.roundTextIcon(source.name) | ||||
|             if (icon != null) { | ||||
|                 image.setImageDrawable(icon) | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -7,7 +7,6 @@ import eu.kanade.tachiyomi.source.icon | ||||
| import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder | ||||
| import eu.kanade.tachiyomi.ui.base.holder.SlicedHolder | ||||
| import eu.kanade.tachiyomi.util.view.gone | ||||
| import eu.kanade.tachiyomi.util.view.roundTextIcon | ||||
| import eu.kanade.tachiyomi.util.view.visible | ||||
| import io.github.mthli.slice.Slice | ||||
| import kotlinx.android.synthetic.main.source_main_controller_card_item.card | ||||
| @@ -50,7 +49,6 @@ class SourceHolder(view: View, override val adapter: SourceAdapter) : | ||||
|             when { | ||||
|                 icon != null -> image.setImageDrawable(icon) | ||||
|                 item.source.id == LocalSource.ID -> image.setImageResource(R.mipmap.ic_local_source) | ||||
|                 else -> image.roundTextIcon(source.name) | ||||
|             } | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -4,12 +4,10 @@ package eu.kanade.tachiyomi.util.view | ||||
|  | ||||
| import android.graphics.Color | ||||
| import android.graphics.Point | ||||
| import android.graphics.Typeface | ||||
| import android.view.Gravity | ||||
| import android.view.Menu | ||||
| import android.view.MenuItem | ||||
| import android.view.View | ||||
| import android.widget.ImageView | ||||
| import android.widget.TextView | ||||
| import androidx.annotation.MenuRes | ||||
| import androidx.appcompat.widget.PopupMenu | ||||
| @@ -18,10 +16,7 @@ import com.google.android.material.chip.Chip | ||||
| import com.google.android.material.chip.ChipGroup | ||||
| 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 | ||||
|  | ||||
| /** | ||||
|  * Returns coordinates of view. | ||||
| @@ -86,28 +81,6 @@ inline fun View.toggle() { | ||||
|     visibleIf { visibility == View.GONE } | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Sets a round TextDrawable into an ImageView determined by input. | ||||
|  * | ||||
|  * @param text text of [TextDrawable] | ||||
|  */ | ||||
| fun ImageView.roundTextIcon(text: String) { | ||||
|     val letter = text.take(1).toUpperCase() | ||||
|     val size = min(this.width, this.height) | ||||
|  | ||||
|     setImageDrawable( | ||||
|         TextDrawable( | ||||
|             shape = TextDrawable.DRAWABLE_SHAPE_OVAL, | ||||
|             desiredWidth = size, | ||||
|             desiredHeight = size, | ||||
|             typeFace = Typeface.DEFAULT, | ||||
|             textColor = Color.WHITE, | ||||
|             text = letter, | ||||
|             color = ColorGenerator.MATERIAL.getColor(letter) | ||||
|         ) | ||||
|     ) | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Shrink an ExtendedFloatingActionButton when the associated RecyclerView is scrolled down. | ||||
|  * | ||||
|   | ||||
		Reference in New Issue
	
	Block a user