From 6dd280205b5bf4040e690b5aaeb961e3443bd19c Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 27 Dec 2020 10:13:13 -0500 Subject: [PATCH] Initial chapter download icon implementation --- .../ui/manga/chapter/ChapterDownloadView.kt | 36 +++++++++++++ .../ui/manga/chapter/ChapterHolder.kt | 12 ++--- app/src/main/res/drawable/border_circle.xml | 12 +++++ .../res/drawable/ic_arrow_downward_24dp.xml | 9 ++++ .../res/drawable/ic_check_circle_24dp.xml | 9 ++++ .../main/res/layout/chapter_download_view.xml | 50 +++++++++++++++++++ app/src/main/res/layout/chapters_item.xml | 15 +++--- 7 files changed, 128 insertions(+), 15 deletions(-) create mode 100644 app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterDownloadView.kt create mode 100644 app/src/main/res/drawable/border_circle.xml create mode 100644 app/src/main/res/drawable/ic_arrow_downward_24dp.xml create mode 100644 app/src/main/res/drawable/ic_check_circle_24dp.xml create mode 100644 app/src/main/res/layout/chapter_download_view.xml diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterDownloadView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterDownloadView.kt new file mode 100644 index 000000000..47f4b1395 --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterDownloadView.kt @@ -0,0 +1,36 @@ +package eu.kanade.tachiyomi.ui.manga.chapter + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.widget.FrameLayout +import androidx.core.view.isVisible +import eu.kanade.tachiyomi.databinding.ChapterDownloadViewBinding + +class ChapterDownloadView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : + FrameLayout(context, attrs) { + + private val binding: ChapterDownloadViewBinding + + init { + binding = ChapterDownloadViewBinding.inflate(LayoutInflater.from(context), this, false) + addView(binding.root) + } + + fun setState(state: State) { + binding.downloadIconBorder.isVisible = state == State.DOWNLOAD || state == State.ERROR + binding.downloadIcon.isVisible = state == State.DOWNLOAD || state == State.DOWNLOADING + + binding.downloadProgress.isVisible = state == State.DOWNLOADING || state == State.QUEUED + + binding.downloadedIcon.isVisible = state == State.DOWNLOADED + } + + enum class State { + DOWNLOAD, + QUEUED, + DOWNLOADING, + ERROR, + DOWNLOADED, + } +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt index 7cf5e6035..cd8e84b8c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt @@ -71,13 +71,13 @@ class ChapterHolder( notifyStatus(item.status) } - fun notifyStatus(status: Int) = with(binding.downloadText) { + private fun notifyStatus(status: Int) = with(binding.download) { when (status) { - Download.QUEUE -> setText(R.string.chapter_queued) - Download.DOWNLOADING -> setText(R.string.chapter_downloading) - Download.DOWNLOADED -> setText(R.string.chapter_downloaded) - Download.ERROR -> setText(R.string.chapter_error) - else -> text = "" + Download.QUEUE -> setState(ChapterDownloadView.State.QUEUED) + Download.DOWNLOADING -> setState(ChapterDownloadView.State.DOWNLOADING) + Download.DOWNLOADED -> setState(ChapterDownloadView.State.DOWNLOADED) + Download.ERROR -> setState(ChapterDownloadView.State.ERROR) + else -> setState(ChapterDownloadView.State.DOWNLOAD) } } } diff --git a/app/src/main/res/drawable/border_circle.xml b/app/src/main/res/drawable/border_circle.xml new file mode 100644 index 000000000..4dbe8c7bd --- /dev/null +++ b/app/src/main/res/drawable/border_circle.xml @@ -0,0 +1,12 @@ + + + + + + diff --git a/app/src/main/res/drawable/ic_arrow_downward_24dp.xml b/app/src/main/res/drawable/ic_arrow_downward_24dp.xml new file mode 100644 index 000000000..e3c45a50d --- /dev/null +++ b/app/src/main/res/drawable/ic_arrow_downward_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_check_circle_24dp.xml b/app/src/main/res/drawable/ic_check_circle_24dp.xml new file mode 100644 index 000000000..0834047ce --- /dev/null +++ b/app/src/main/res/drawable/ic_check_circle_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/chapter_download_view.xml b/app/src/main/res/layout/chapter_download_view.xml new file mode 100644 index 000000000..980b39232 --- /dev/null +++ b/app/src/main/res/layout/chapter_download_view.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/chapters_item.xml b/app/src/main/res/layout/chapters_item.xml index a93351ba8..1c092d9d4 100644 --- a/app/src/main/res/layout/chapters_item.xml +++ b/app/src/main/res/layout/chapters_item.xml @@ -31,7 +31,7 @@ android:layout_marginTop="12dp" android:ellipsize="end" android:maxLines="1" - app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintEnd_toStartOf="@+id/download" app:layout_constraintStart_toEndOf="@+id/bookmark_icon" app:layout_constraintTop_toTopOf="parent" tools:text="Title" /> @@ -45,19 +45,16 @@ android:ellipsize="end" android:singleLine="true" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toStartOf="@+id/download_text" + app:layout_constraintEnd_toStartOf="@+id/download" app:layout_constraintStart_toStartOf="parent" tools:text="22/02/2016 • Scanlator • Page: 45" /> - + app:layout_constraintEnd_toEndOf="parent" />