Unify history and update item (#4361)

* Unify history and update item

* Use card_radius
This commit is contained in:
Andreas 2021-01-28 00:28:02 +01:00 committed by GitHub
parent 58860b51a2
commit 0a10f66053
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 81 additions and 78 deletions

View file

@ -2,6 +2,9 @@ package eu.kanade.tachiyomi.ui.recent.history
import android.view.View import android.view.View
import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.bitmap.CenterCrop
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.request.RequestOptions
import eu.davidea.viewholders.FlexibleViewHolder import eu.davidea.viewholders.FlexibleViewHolder
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.MangaChapterHistory import eu.kanade.tachiyomi.data.database.models.MangaChapterHistory
@ -65,12 +68,15 @@ class HistoryHolder(
binding.mangaSubtitle.text = Date(history.last_read).toTimestampString() binding.mangaSubtitle.text = Date(history.last_read).toTimestampString()
} }
val radius = itemView.context.resources.getDimensionPixelSize(R.dimen.card_radius)
val requestOptions = RequestOptions().transform(CenterCrop(), RoundedCorners(radius))
// Set cover // Set cover
GlideApp.with(itemView.context).clear(binding.cover) GlideApp.with(itemView.context).clear(binding.cover)
GlideApp.with(itemView.context) GlideApp.with(itemView.context)
.load(manga.toMangaThumbnail()) .load(manga.toMangaThumbnail())
.diskCacheStrategy(DiskCacheStrategy.RESOURCE) .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
.centerCrop() .apply(requestOptions)
.into(binding.cover) .into(binding.cover)
} }
} }

View file

@ -1,84 +1,81 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/holder" android:id="@+id/holder"
style="@style/Theme.Widget.CardView.Item" android:layout_width="match_parent"
android:padding="0dp"> android:layout_height="80dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:orientation="horizontal">
<androidx.constraintlayout.widget.ConstraintLayout <ImageView
android:layout_width="match_parent" android:id="@+id/cover"
android:layout_height="80dp" android:layout_width="0dp"
android:orientation="horizontal"> android:layout_height="match_parent"
android:contentDescription="@string/description_cover"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="h,3:2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@mipmap/ic_launcher" />
<ImageView <LinearLayout
android:id="@+id/cover" android:layout_width="0dp"
android:layout_width="0dp" android:layout_height="wrap_content"
android:layout_height="match_parent" android:layout_marginStart="16dp"
android:contentDescription="@string/description_cover" android:layout_marginEnd="8dp"
android:scaleType="centerCrop" android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="h,3:2" app:layout_constraintEnd_toStartOf="@+id/remove"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toEndOf="@+id/cover"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent">
tools:src="@mipmap/ic_launcher" />
<LinearLayout <TextView
android:layout_width="0dp" android:id="@+id/manga_title"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:ellipsize="end"
android:layout_marginEnd="8dp" android:maxLines="2"
android:orientation="vertical" android:textAppearance="@style/TextAppearance.Medium"
app:layout_constraintBottom_toBottomOf="parent" tools:text="Title" />
app:layout_constraintEnd_toStartOf="@+id/remove"
app:layout_constraintStart_toEndOf="@+id/cover"
app:layout_constraintTop_toTopOf="parent">
<TextView <TextView
android:id="@+id/manga_title" android:id="@+id/manga_subtitle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:textAppearance="@style/TextAppearance.Medium"
tools:text="Title" />
<TextView
android:id="@+id/manga_subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
tools:text="Subtitle" />
</LinearLayout>
<ImageButton
android:id="@+id/remove"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?selectableItemBackgroundBorderless" android:layout_marginTop="4dp"
android:contentDescription="@string/action_resume" tools:text="Subtitle" />
android:padding="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/resume"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_delete_24dp"
app:tint="?android:attr/textColorPrimary" />
<ImageButton </LinearLayout>
android:id="@+id/resume"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/action_resume"
android:padding="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_play_arrow_24dp"
app:tint="?android:attr/textColorPrimary" />
</androidx.constraintlayout.widget.ConstraintLayout> <ImageButton
android:id="@+id/remove"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/action_resume"
android:padding="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/resume"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_delete_24dp"
app:tint="?android:attr/textColorPrimary" />
</androidx.cardview.widget.CardView> <ImageButton
android:id="@+id/resume"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/action_resume"
android:padding="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_play_arrow_24dp"
app:tint="?android:attr/textColorPrimary" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -9,13 +9,13 @@
<ImageView <ImageView
android:id="@+id/manga_cover" android:id="@+id/manga_cover"
android:layout_width="56dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:paddingStart="16dp" android:layout_marginStart="16dp"
android:paddingTop="8dp" android:layout_marginTop="8dp"
android:paddingEnd="0dp" android:layout_marginBottom="8dp"
android:paddingBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="h,1:1"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
tools:src="@mipmap/ic_launcher" /> tools:src="@mipmap/ic_launcher" />
@ -27,7 +27,7 @@
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:textAppearance="@style/TextAppearance.Regular.Body1" android:textAppearance="@style/TextAppearance.Medium.Body2"
app:layout_constraintBottom_toTopOf="@+id/chapter_title" app:layout_constraintBottom_toTopOf="@+id/chapter_title"
app:layout_constraintEnd_toStartOf="@+id/download" app:layout_constraintEnd_toStartOf="@+id/download"
app:layout_constraintStart_toEndOf="@+id/manga_cover" app:layout_constraintStart_toEndOf="@+id/manga_cover"