Remove TextDrawable

This commit is contained in:
arkon 2020-04-26 11:59:15 -04:00
parent 2c2f8f5853
commit d243ee4b4c
8 changed files with 23 additions and 73 deletions

View File

@ -216,7 +216,6 @@ 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.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'

View File

@ -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.
*

View File

@ -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)
}
}
/**

View File

@ -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) }
}
}

View File

@ -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)
}
}
}
}

View File

@ -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)
}
}

View File

@ -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.
*

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
@ -7,33 +7,33 @@
android:background="@drawable/list_item_selector">
<ImageView
android:id="@+id/image"
android:id="@+id/reorder"
android:layout_width="@dimen/material_component_lists_single_line_with_avatar_height"
android:layout_height="@dimen/material_component_lists_single_line_with_avatar_height"
android:clickable="true"
android:paddingStart="@dimen/material_component_lists_icon_left_padding"
android:paddingEnd="0dp"
tools:src="@mipmap/ic_launcher_round" />
android:scaleType="center"
app:srcCompat="@drawable/ic_reorder_grey_24dp"
app:tint="?android:attr/textColorPrimary"
tools:ignore="ContentDescription" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:scaleType="center"
app:srcCompat="@drawable/ic_label_24dp"
app:tint="?android:attr/textColorPrimary"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/material_component_lists_text_left_padding"
android:layout_marginEnd="@dimen/material_component_lists_single_line_with_avatar_height"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.Regular.SubHeading"
tools:text="Title" />
<ImageView
android:id="@+id/reorder"
android:layout_width="@dimen/material_component_lists_single_line_with_avatar_height"
android:layout_height="@dimen/material_component_lists_single_line_with_avatar_height"
android:layout_gravity="end"
android:scaleType="center"
app:srcCompat="@drawable/ic_reorder_grey_24dp"
app:tint="?android:attr/textColorPrimary" />
</FrameLayout>
</LinearLayout>