mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-04 08:08:55 +01:00 
			
		
		
		
	Add background to draggable items (#5353)
This commit is contained in:
		@@ -1,6 +1,7 @@
 | 
			
		||||
package eu.kanade.tachiyomi.ui.category
 | 
			
		||||
 | 
			
		||||
import android.view.View
 | 
			
		||||
import androidx.recyclerview.widget.ItemTouchHelper
 | 
			
		||||
import eu.davidea.viewholders.FlexibleViewHolder
 | 
			
		||||
import eu.kanade.tachiyomi.data.database.models.Category
 | 
			
		||||
import eu.kanade.tachiyomi.databinding.CategoriesItemBinding
 | 
			
		||||
@@ -36,5 +37,13 @@ class CategoryHolder(view: View, val adapter: CategoryAdapter) : FlexibleViewHol
 | 
			
		||||
    override fun onItemReleased(position: Int) {
 | 
			
		||||
        super.onItemReleased(position)
 | 
			
		||||
        adapter.onItemReleaseListener.onItemReleased(position)
 | 
			
		||||
        binding.container.isDragged = false
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    override fun onActionStateChanged(position: Int, actionState: Int) {
 | 
			
		||||
        super.onActionStateChanged(position, actionState)
 | 
			
		||||
        if (actionState == ItemTouchHelper.ACTION_STATE_DRAG) {
 | 
			
		||||
            binding.container.isDragged = true
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
package eu.kanade.tachiyomi.ui.download
 | 
			
		||||
 | 
			
		||||
import android.view.View
 | 
			
		||||
import androidx.recyclerview.widget.ItemTouchHelper
 | 
			
		||||
import eu.davidea.viewholders.FlexibleViewHolder
 | 
			
		||||
import eu.kanade.tachiyomi.R
 | 
			
		||||
import eu.kanade.tachiyomi.data.download.model.Download
 | 
			
		||||
@@ -63,7 +64,7 @@ class DownloadHolder(private val view: View, val adapter: DownloadAdapter) :
 | 
			
		||||
        if (binding.downloadProgress.max == 1) {
 | 
			
		||||
            binding.downloadProgress.max = pages.size * 100
 | 
			
		||||
        }
 | 
			
		||||
        binding.downloadProgress.progress = download.totalProgress
 | 
			
		||||
        binding.downloadProgress.setProgressCompat(download.totalProgress, true)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -77,6 +78,14 @@ class DownloadHolder(private val view: View, val adapter: DownloadAdapter) :
 | 
			
		||||
    override fun onItemReleased(position: Int) {
 | 
			
		||||
        super.onItemReleased(position)
 | 
			
		||||
        adapter.downloadItemListener.onItemReleased(position)
 | 
			
		||||
        binding.container.isDragged = false
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    override fun onActionStateChanged(position: Int, actionState: Int) {
 | 
			
		||||
        super.onActionStateChanged(position, actionState)
 | 
			
		||||
        if (actionState == ItemTouchHelper.ACTION_STATE_DRAG) {
 | 
			
		||||
            binding.container.isDragged = true
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private fun showPopupMenu(view: View) {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,40 +1,41 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 | 
			
		||||
<com.google.android.material.card.MaterialCardView 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:id="@+id/container"
 | 
			
		||||
    android:layout_width="match_parent"
 | 
			
		||||
    android:layout_height="56dp"
 | 
			
		||||
    android:background="@drawable/list_item_selector_background">
 | 
			
		||||
    android:layout_height="wrap_content"
 | 
			
		||||
    app:cardBackgroundColor="?android:attr/colorBackground"
 | 
			
		||||
    app:cardElevation="0dp">
 | 
			
		||||
 | 
			
		||||
    <ImageView
 | 
			
		||||
        android:id="@+id/reorder"
 | 
			
		||||
        android:layout_width="wrap_content"
 | 
			
		||||
    <LinearLayout
 | 
			
		||||
        android:layout_width="match_parent"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:padding="16dp"
 | 
			
		||||
        android:scaleType="center"
 | 
			
		||||
        app:srcCompat="@drawable/ic_drag_handle_24dp"
 | 
			
		||||
        app:tint="?android:attr/textColorHint"
 | 
			
		||||
        tools:ignore="ContentDescription" />
 | 
			
		||||
        android:background="@drawable/list_item_selector_background">
 | 
			
		||||
 | 
			
		||||
    <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" />
 | 
			
		||||
        <ImageView
 | 
			
		||||
            android:id="@+id/reorder"
 | 
			
		||||
            android:layout_width="wrap_content"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:padding="16dp"
 | 
			
		||||
            android:scaleType="center"
 | 
			
		||||
            app:srcCompat="@drawable/ic_drag_handle_24dp"
 | 
			
		||||
            app:tint="?android:attr/textColorHint"
 | 
			
		||||
            tools:ignore="ContentDescription" />
 | 
			
		||||
 | 
			
		||||
    <TextView
 | 
			
		||||
        android:id="@+id/title"
 | 
			
		||||
        android:layout_width="0dp"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:layout_gravity="center_vertical"
 | 
			
		||||
        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" />
 | 
			
		||||
        <TextView
 | 
			
		||||
            android:id="@+id/title"
 | 
			
		||||
            android:layout_width="0dp"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:layout_gravity="center_vertical"
 | 
			
		||||
            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="Category Title" />
 | 
			
		||||
 | 
			
		||||
</LinearLayout>
 | 
			
		||||
    </LinearLayout>
 | 
			
		||||
 | 
			
		||||
</com.google.android.material.card.MaterialCardView>
 | 
			
		||||
@@ -1,102 +1,113 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
 | 
			
		||||
<com.google.android.material.card.MaterialCardView 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:id="@+id/container"
 | 
			
		||||
    android:layout_width="match_parent"
 | 
			
		||||
    android:layout_height="wrap_content"
 | 
			
		||||
    android:paddingTop="8dp">
 | 
			
		||||
    android:layout_marginTop="8dp"
 | 
			
		||||
    app:cardBackgroundColor="?android:attr/colorBackground"
 | 
			
		||||
    app:cardElevation="0dp">
 | 
			
		||||
 | 
			
		||||
    <ImageView
 | 
			
		||||
        android:id="@+id/reorder"
 | 
			
		||||
        android:layout_width="wrap_content"
 | 
			
		||||
    <androidx.constraintlayout.widget.ConstraintLayout
 | 
			
		||||
        android:layout_width="match_parent"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:layout_alignParentStart="true"
 | 
			
		||||
        android:layout_gravity="start"
 | 
			
		||||
        android:padding="16dp"
 | 
			
		||||
        android:scaleType="center"
 | 
			
		||||
        app:layout_constraintBottom_toBottomOf="parent"
 | 
			
		||||
        app:layout_constraintStart_toStartOf="parent"
 | 
			
		||||
        app:layout_constraintTop_toTopOf="parent"
 | 
			
		||||
        app:srcCompat="@drawable/ic_drag_handle_24dp"
 | 
			
		||||
        app:tint="?android:attr/textColorHint" />
 | 
			
		||||
        android:background="@drawable/list_item_selector_background">
 | 
			
		||||
 | 
			
		||||
    <TextView
 | 
			
		||||
        android:id="@+id/manga_full_title"
 | 
			
		||||
        android:layout_width="0dp"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:layout_marginEnd="8dp"
 | 
			
		||||
        android:layout_toEndOf="@id/reorder"
 | 
			
		||||
        android:ellipsize="end"
 | 
			
		||||
        android:maxLines="1"
 | 
			
		||||
        android:textAppearance="@style/TextAppearance.Regular.Body1"
 | 
			
		||||
        app:layout_constraintEnd_toStartOf="@+id/download_progress_text"
 | 
			
		||||
        app:layout_constraintStart_toEndOf="@+id/reorder"
 | 
			
		||||
        app:layout_constraintTop_toTopOf="parent"
 | 
			
		||||
        tools:text="Manga title" />
 | 
			
		||||
        <ImageView
 | 
			
		||||
            android:id="@+id/reorder"
 | 
			
		||||
            android:layout_width="wrap_content"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:layout_alignParentStart="true"
 | 
			
		||||
            android:layout_gravity="start"
 | 
			
		||||
            android:padding="16dp"
 | 
			
		||||
            android:scaleType="center"
 | 
			
		||||
            app:layout_constraintBottom_toBottomOf="parent"
 | 
			
		||||
            app:layout_constraintStart_toStartOf="parent"
 | 
			
		||||
            app:layout_constraintTop_toTopOf="parent"
 | 
			
		||||
            app:srcCompat="@drawable/ic_drag_handle_24dp"
 | 
			
		||||
            app:tint="?android:attr/textColorHint"
 | 
			
		||||
            tools:ignore="ContentDescription" />
 | 
			
		||||
 | 
			
		||||
    <TextView
 | 
			
		||||
        android:id="@+id/chapter_title"
 | 
			
		||||
        android:layout_width="0dp"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:layout_marginTop="4dp"
 | 
			
		||||
        android:layout_marginEnd="8dp"
 | 
			
		||||
        android:layout_toEndOf="@id/reorder"
 | 
			
		||||
        android:ellipsize="end"
 | 
			
		||||
        android:maxLines="1"
 | 
			
		||||
        android:textAppearance="@style/TextAppearance.Regular.Caption"
 | 
			
		||||
        app:layout_constraintEnd_toStartOf="@+id/manga_source"
 | 
			
		||||
        app:layout_constraintStart_toStartOf="@+id/manga_full_title"
 | 
			
		||||
        app:layout_constraintTop_toBottomOf="@+id/manga_full_title"
 | 
			
		||||
        tools:text="Chapter Title" />
 | 
			
		||||
        <TextView
 | 
			
		||||
            android:id="@+id/manga_full_title"
 | 
			
		||||
            android:layout_width="0dp"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:layout_marginEnd="8dp"
 | 
			
		||||
            android:layout_toEndOf="@id/reorder"
 | 
			
		||||
            android:ellipsize="end"
 | 
			
		||||
            android:maxLines="1"
 | 
			
		||||
            android:textAppearance="@style/TextAppearance.Regular.Body1"
 | 
			
		||||
            app:layout_constraintEnd_toStartOf="@+id/download_progress_text"
 | 
			
		||||
            app:layout_constraintStart_toEndOf="@+id/reorder"
 | 
			
		||||
            app:layout_constraintTop_toTopOf="parent"
 | 
			
		||||
            tools:text="Manga title" />
 | 
			
		||||
 | 
			
		||||
    <com.google.android.material.progressindicator.LinearProgressIndicator
 | 
			
		||||
        android:id="@+id/download_progress"
 | 
			
		||||
        android:layout_width="0dp"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:layout_marginTop="4dp"
 | 
			
		||||
        android:layout_marginBottom="4dp"
 | 
			
		||||
        app:layout_constraintBottom_toBottomOf="parent"
 | 
			
		||||
        app:layout_constraintEnd_toStartOf="@+id/menu"
 | 
			
		||||
        app:layout_constraintStart_toEndOf="@+id/reorder"
 | 
			
		||||
        app:layout_constraintTop_toBottomOf="@+id/chapter_title" />
 | 
			
		||||
        <TextView
 | 
			
		||||
            android:id="@+id/chapter_title"
 | 
			
		||||
            android:layout_width="0dp"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:layout_marginTop="2dp"
 | 
			
		||||
            android:layout_marginEnd="8dp"
 | 
			
		||||
            android:layout_toEndOf="@id/reorder"
 | 
			
		||||
            android:ellipsize="end"
 | 
			
		||||
            android:maxLines="1"
 | 
			
		||||
            android:textAppearance="@style/TextAppearance.Regular.Caption"
 | 
			
		||||
            app:layout_constraintEnd_toStartOf="@+id/manga_source"
 | 
			
		||||
            app:layout_constraintStart_toStartOf="@+id/manga_full_title"
 | 
			
		||||
            app:layout_constraintTop_toBottomOf="@+id/manga_full_title"
 | 
			
		||||
            tools:text="Chapter Title" />
 | 
			
		||||
 | 
			
		||||
    <TextView
 | 
			
		||||
        android:id="@+id/download_progress_text"
 | 
			
		||||
        android:layout_width="wrap_content"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:layout_toEndOf="@id/manga_full_title"
 | 
			
		||||
        android:maxLines="1"
 | 
			
		||||
        android:textAppearance="@style/TextAppearance.Regular.Caption.Hint"
 | 
			
		||||
        app:layout_constraintBottom_toBottomOf="@+id/manga_full_title"
 | 
			
		||||
        app:layout_constraintEnd_toStartOf="@+id/menu"
 | 
			
		||||
        app:layout_constraintTop_toTopOf="@+id/manga_full_title"
 | 
			
		||||
        tools:text="(0/10)" />
 | 
			
		||||
        <com.google.android.material.progressindicator.LinearProgressIndicator
 | 
			
		||||
            android:id="@+id/download_progress"
 | 
			
		||||
            android:layout_width="0dp"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:layout_marginTop="8dp"
 | 
			
		||||
            android:layout_marginBottom="4dp"
 | 
			
		||||
            app:layout_constraintBottom_toBottomOf="parent"
 | 
			
		||||
            app:layout_constraintEnd_toStartOf="@+id/menu"
 | 
			
		||||
            app:layout_constraintStart_toEndOf="@+id/reorder"
 | 
			
		||||
            app:layout_constraintTop_toBottomOf="@+id/chapter_title" />
 | 
			
		||||
 | 
			
		||||
    <TextView
 | 
			
		||||
        android:id="@+id/manga_source"
 | 
			
		||||
        android:layout_width="wrap_content"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:layout_toEndOf="@id/chapter_title"
 | 
			
		||||
        android:maxLines="1"
 | 
			
		||||
        android:textAppearance="@style/TextAppearance.Regular.Caption.Hint"
 | 
			
		||||
        app:layout_constraintBottom_toBottomOf="@+id/chapter_title"
 | 
			
		||||
        app:layout_constraintEnd_toStartOf="@+id/menu"
 | 
			
		||||
        app:layout_constraintTop_toTopOf="@+id/chapter_title"
 | 
			
		||||
        tools:text="Manga Source" />
 | 
			
		||||
        <TextView
 | 
			
		||||
            android:id="@+id/download_progress_text"
 | 
			
		||||
            android:layout_width="wrap_content"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:layout_toEndOf="@id/manga_full_title"
 | 
			
		||||
            android:maxLines="1"
 | 
			
		||||
            android:textAppearance="@style/TextAppearance.Regular.Caption.Hint"
 | 
			
		||||
            app:layout_constraintBottom_toBottomOf="@+id/manga_full_title"
 | 
			
		||||
            app:layout_constraintEnd_toStartOf="@+id/menu"
 | 
			
		||||
            app:layout_constraintTop_toTopOf="@+id/manga_full_title"
 | 
			
		||||
            tools:text="0/10" />
 | 
			
		||||
 | 
			
		||||
    <ImageButton
 | 
			
		||||
        android:id="@+id/menu"
 | 
			
		||||
        android:layout_width="wrap_content"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:layout_toEndOf="@id/download_progress_text"
 | 
			
		||||
        android:background="@drawable/ripple_regular"
 | 
			
		||||
        android:contentDescription="@string/action_menu"
 | 
			
		||||
        android:paddingHorizontal="10dp"
 | 
			
		||||
        android:paddingVertical="16dp"
 | 
			
		||||
        app:layout_constraintBottom_toBottomOf="parent"
 | 
			
		||||
        app:layout_constraintEnd_toEndOf="parent"
 | 
			
		||||
        app:layout_constraintTop_toTopOf="parent"
 | 
			
		||||
        app:srcCompat="@drawable/ic_overflow_24dp"
 | 
			
		||||
        app:tint="?attr/colorOnBackground" />
 | 
			
		||||
        <TextView
 | 
			
		||||
            android:id="@+id/manga_source"
 | 
			
		||||
            android:layout_width="wrap_content"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:layout_toEndOf="@id/chapter_title"
 | 
			
		||||
            android:maxLines="1"
 | 
			
		||||
            android:textAppearance="@style/TextAppearance.Regular.Caption.Hint"
 | 
			
		||||
            app:layout_constraintBottom_toBottomOf="@+id/chapter_title"
 | 
			
		||||
            app:layout_constraintEnd_toStartOf="@+id/menu"
 | 
			
		||||
            app:layout_constraintTop_toTopOf="@+id/chapter_title"
 | 
			
		||||
            tools:text="Manga Source" />
 | 
			
		||||
 | 
			
		||||
</androidx.constraintlayout.widget.ConstraintLayout>
 | 
			
		||||
        <ImageButton
 | 
			
		||||
            android:id="@+id/menu"
 | 
			
		||||
            android:layout_width="wrap_content"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:layout_toEndOf="@id/download_progress_text"
 | 
			
		||||
            android:background="@drawable/ripple_regular"
 | 
			
		||||
            android:contentDescription="@string/action_menu"
 | 
			
		||||
            android:paddingHorizontal="10dp"
 | 
			
		||||
            android:paddingVertical="16dp"
 | 
			
		||||
            app:layout_constraintBottom_toBottomOf="parent"
 | 
			
		||||
            app:layout_constraintEnd_toEndOf="parent"
 | 
			
		||||
            app:layout_constraintTop_toTopOf="parent"
 | 
			
		||||
            app:srcCompat="@drawable/ic_overflow_24dp"
 | 
			
		||||
            app:tint="?attr/colorOnBackground" />
 | 
			
		||||
 | 
			
		||||
    </androidx.constraintlayout.widget.ConstraintLayout>
 | 
			
		||||
 | 
			
		||||
</com.google.android.material.card.MaterialCardView>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user