mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-30 22:07:57 +01:00 
			
		
		
		
	Made rounded library covers configurable
This commit is contained in:
		| @@ -1,15 +1,21 @@ | ||||
| package eu.kanade.tachiyomi.ui.browse.source.browse | ||||
|  | ||||
| import android.util.TypedValue | ||||
| import android.view.View | ||||
| import com.bumptech.glide.load.engine.DiskCacheStrategy | ||||
| import eu.davidea.flexibleadapter.FlexibleAdapter | ||||
| import eu.kanade.tachiyomi.data.database.models.Manga | ||||
| import eu.kanade.tachiyomi.data.glide.GlideApp | ||||
| import eu.kanade.tachiyomi.data.glide.toMangaThumbnail | ||||
| import eu.kanade.tachiyomi.data.preference.PreferencesHelper | ||||
| import eu.kanade.tachiyomi.data.preference.getOrDefault | ||||
| import eu.kanade.tachiyomi.widget.StateImageViewTarget | ||||
| import kotlinx.android.synthetic.main.source_grid_item.card | ||||
| import kotlinx.android.synthetic.main.source_grid_item.progress | ||||
| import kotlinx.android.synthetic.main.source_grid_item.thumbnail | ||||
| import kotlinx.android.synthetic.main.source_grid_item.title | ||||
| import uy.kohesive.injekt.Injekt | ||||
| import uy.kohesive.injekt.api.get | ||||
|  | ||||
| /** | ||||
|  * Class used to hold the displayed data of a manga in the catalogue, like the cover or the title. | ||||
| @@ -22,6 +28,8 @@ import kotlinx.android.synthetic.main.source_grid_item.title | ||||
| class SourceGridHolder(private val view: View, private val adapter: FlexibleAdapter<*>) : | ||||
|     SourceHolder(view, adapter) { | ||||
|  | ||||
|     private val preferences: PreferencesHelper = Injekt.get() | ||||
|  | ||||
|     /** | ||||
|      * Method called from [CatalogueAdapter.onBindViewHolder]. It updates the data for this | ||||
|      * holder with the given manga. | ||||
| @@ -39,6 +47,12 @@ class SourceGridHolder(private val view: View, private val adapter: FlexibleAdap | ||||
|         // Set manga title | ||||
|         title.text = manga.title | ||||
|  | ||||
|         card.radius = TypedValue.applyDimension( | ||||
|             TypedValue.COMPLEX_UNIT_DIP, | ||||
|             preferences.eh_library_corner_radius().getOrDefault().toFloat(), | ||||
|             view.context.resources.displayMetrics | ||||
|         ) | ||||
|  | ||||
|         GlideApp.with(view.context).clear(thumbnail) | ||||
|         if (!manga.thumbnail_url.isNullOrEmpty()) { | ||||
|             GlideApp.with(view.context) | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| package eu.kanade.tachiyomi.ui.library | ||||
|  | ||||
| import android.util.TypedValue | ||||
| import android.view.View | ||||
| import com.bumptech.glide.load.engine.DiskCacheStrategy | ||||
| import eu.davidea.flexibleadapter.FlexibleAdapter | ||||
| @@ -7,13 +8,18 @@ import androidx.recyclerview.widget.RecyclerView | ||||
| import eu.davidea.flexibleadapter.items.IFlexible | ||||
| import eu.kanade.tachiyomi.data.glide.GlideApp | ||||
| import eu.kanade.tachiyomi.data.glide.toMangaThumbnail | ||||
| import eu.kanade.tachiyomi.data.preference.PreferencesHelper | ||||
| import eu.kanade.tachiyomi.data.preference.getOrDefault | ||||
| import eu.kanade.tachiyomi.source.LocalSource | ||||
| import eu.kanade.tachiyomi.util.view.visibleIf | ||||
| import kotlinx.android.synthetic.main.source_grid_item.card | ||||
| import kotlinx.android.synthetic.main.source_grid_item.download_text | ||||
| import kotlinx.android.synthetic.main.source_grid_item.local_text | ||||
| import kotlinx.android.synthetic.main.source_grid_item.thumbnail | ||||
| import kotlinx.android.synthetic.main.source_grid_item.title | ||||
| import kotlinx.android.synthetic.main.source_grid_item.unread_text | ||||
| import uy.kohesive.injekt.Injekt | ||||
| import uy.kohesive.injekt.api.get | ||||
|  | ||||
| /** | ||||
|  * Class used to hold the displayed data of a manga in the library, like the cover or the title. | ||||
| @@ -28,7 +34,7 @@ class LibraryGridHolder( | ||||
|     private val view: View, | ||||
|     adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>> | ||||
| ) : LibraryHolder(view, adapter) { | ||||
|  | ||||
|     private val preferences: PreferencesHelper = Injekt.get() | ||||
|     /** | ||||
|      * Method called from [LibraryCategoryAdapter.onBindViewHolder]. It updates the data for this | ||||
|      * holder with the given manga. | ||||
| @@ -52,6 +58,12 @@ class LibraryGridHolder( | ||||
|         // set local visibility if its local manga | ||||
|         local_text.visibleIf { item.manga.source == LocalSource.ID } | ||||
|  | ||||
|         card.radius = TypedValue.applyDimension( | ||||
|             TypedValue.COMPLEX_UNIT_DIP, | ||||
|             preferences.eh_library_corner_radius().getOrDefault().toFloat(), | ||||
|             view.context.resources.displayMetrics | ||||
|         ) | ||||
|  | ||||
|         // Update the cover. | ||||
|         GlideApp.with(view.context).clear(thumbnail) | ||||
|         GlideApp.with(view.context) | ||||
|   | ||||
| @@ -72,6 +72,17 @@ class SettingsLibraryController : SettingsController() { | ||||
|                             "${context.getString(R.string.landscape)}: $landscape" | ||||
|                     } | ||||
|             } | ||||
|             intListPreference { | ||||
|                 key = Keys.eh_library_rounded_corners | ||||
|                 title = "Rounded Corner Radius" | ||||
|                 entriesRes = arrayOf(R.string.eh_rounded_corner_0, R.string.eh_rounded_corner_1, | ||||
|                     R.string.eh_rounded_corner_2, R.string.eh_rounded_corner_3, R.string.eh_rounded_corner_4, | ||||
|                     R.string.eh_rounded_corner_5, R.string.eh_rounded_corner_6, R.string.eh_rounded_corner_7, | ||||
|                     R.string.eh_rounded_corner_8, R.string.eh_rounded_corner_9, R.string.eh_rounded_corner_10) | ||||
|                 entryValues = arrayOf("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10") | ||||
|                 defaultValue = "4" | ||||
|                 summaryRes = R.string.eh_rounded_corners_desc | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         val dbCategories = db.getCategories().executeAsBlocking() | ||||
|   | ||||
| @@ -657,5 +657,19 @@ | ||||
|     <string name="eh_autoscroll">Autoscroll</string> | ||||
|     <string name="eh_retry_all">Retry all</string> | ||||
|     <string name="eh_boost_page">Boost page</string> | ||||
|     <string name="eh_rounded_corner_0">No Rounded Corners</string> | ||||
|     <string name="eh_rounded_corner_1">Radius of 1</string> | ||||
|     <string name="eh_rounded_corner_2">Radius of 2</string> | ||||
|     <string name="eh_rounded_corner_3">Radius of 3</string> | ||||
|     <string name="eh_rounded_corner_4">Radius of 4</string> | ||||
|     <string name="eh_rounded_corner_5">Radius of 5</string> | ||||
|     <string name="eh_rounded_corner_6">Radius of 6</string> | ||||
|     <string name="eh_rounded_corner_7">Radius of 7</string> | ||||
|     <string name="eh_rounded_corner_8">Radius of 8</string> | ||||
|     <string name="eh_rounded_corner_9">Radius of 9</string> | ||||
|     <string name="eh_rounded_corner_10">Radius of 10</string> | ||||
|     <string name="eh_rounded_corners_desc">The level of radius that the corners are rounded to. Current value is: %s</string> | ||||
|  | ||||
|  | ||||
|  | ||||
| </resources> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user