From d7d37315676097e7f2db1b4c64a1698b62bf54d2 Mon Sep 17 00:00:00 2001 From: arkon Date: Mon, 9 Mar 2020 18:59:17 -0400 Subject: [PATCH] Random kaomoji for empty view --- .../ui/category/CategoryController.kt | 2 +- .../ui/download/DownloadController.kt | 3 +- .../extension/ExtensionDetailsController.kt | 3 +- .../tachiyomi/ui/library/LibraryController.kt | 2 +- .../ui/recent/history/HistoryController.kt | 2 +- .../ui/recent/updates/UpdatesController.kt | 2 +- .../eu/kanade/tachiyomi/widget/EmptyView.kt | 33 ++++++++++++++----- .../main/res/drawable/ic_book_black_128dp.xml | 9 ----- .../drawable/ic_file_download_black_128dp.xml | 9 ----- .../res/drawable/ic_history_black_128dp.xml | 9 ----- .../drawable/ic_new_releases_black_128dp.xml | 9 ----- app/src/main/res/drawable/ic_no_settings.xml | 9 ----- .../res/drawable/ic_shape_black_128dp.xml | 9 ----- app/src/main/res/layout/common_view_empty.xml | 21 ++++++++---- 14 files changed, 44 insertions(+), 78 deletions(-) delete mode 100644 app/src/main/res/drawable/ic_book_black_128dp.xml delete mode 100644 app/src/main/res/drawable/ic_file_download_black_128dp.xml delete mode 100644 app/src/main/res/drawable/ic_history_black_128dp.xml delete mode 100644 app/src/main/res/drawable/ic_new_releases_black_128dp.xml delete mode 100644 app/src/main/res/drawable/ic_no_settings.xml delete mode 100644 app/src/main/res/drawable/ic_shape_black_128dp.xml diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryController.kt index 111402d9a7..55591726e0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryController.kt @@ -120,7 +120,7 @@ class CategoryController : NucleusController(), selected.forEach { onItemLongClick(categories.indexOf(it)) } } } else { - empty_view.show(R.drawable.ic_shape_black_128dp, R.string.information_empty_category) + empty_view.show(R.string.information_empty_category) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadController.kt index fc6e899d00..dcb32127c2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadController.kt @@ -242,8 +242,7 @@ class DownloadController : NucleusController() { */ private fun setInformationView() { if (presenter.downloadQueue.isEmpty()) { - empty_view?.show(R.drawable.ic_file_download_black_128dp, - R.string.information_no_downloads) + empty_view?.show(R.string.information_no_downloads) } else { empty_view?.hide() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionDetailsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionDetailsController.kt index 78aa6ae83a..124874370b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionDetailsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionDetailsController.kt @@ -112,8 +112,7 @@ class ExtensionDetailsController(bundle: Bundle? = null) : extension_prefs_recycler.addItemDecoration(DividerItemDecoration(context, VERTICAL)) if (screen.preferenceCount == 0) { - extension_prefs_empty_view.show(R.drawable.ic_no_settings, - R.string.ext_empty_preferences) + extension_prefs_empty_view.show(R.string.ext_empty_preferences) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index b4c4127d93..a2bdb439eb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -237,7 +237,7 @@ class LibraryController( if (mangaMap.isNotEmpty()) { empty_view.hide() } else { - empty_view.show(R.drawable.ic_book_black_128dp, R.string.information_empty_library) + empty_view.show(R.string.information_empty_library) } // Get the current active category. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt index 167cb16f26..a3051e2ad1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt @@ -81,7 +81,7 @@ class HistoryController : NucleusController(), if (size > 0) { empty_view.hide() } else { - empty_view.show(R.drawable.ic_history_black_128dp, R.string.information_no_recent_manga) + empty_view.show(R.string.information_no_recent_manga) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt index 2a602de730..324822db3d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt @@ -194,7 +194,7 @@ class UpdatesController : NucleusController(), if (size > 0) { empty_view?.hide() } else { - empty_view?.show(R.drawable.ic_new_releases_black_128dp, R.string.information_no_recent) + empty_view?.show(R.string.information_no_recent) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/EmptyView.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/EmptyView.kt index 0e1e2977ff..84628dac94 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/EmptyView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/EmptyView.kt @@ -2,12 +2,13 @@ package eu.kanade.tachiyomi.widget import android.content.Context import android.util.AttributeSet -import android.view.View import android.widget.RelativeLayout +import androidx.annotation.StringRes import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.util.system.getResourceColor -import eu.kanade.tachiyomi.util.view.setVectorCompat -import kotlinx.android.synthetic.main.common_view_empty.view.image_view +import eu.kanade.tachiyomi.util.view.gone +import eu.kanade.tachiyomi.util.view.visible +import kotlin.random.Random +import kotlinx.android.synthetic.main.common_view_empty.view.text_face import kotlinx.android.synthetic.main.common_view_empty.view.text_label class EmptyView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : @@ -21,17 +22,31 @@ class EmptyView @JvmOverloads constructor(context: Context, attrs: AttributeSet? * Hide the information view */ fun hide() { - this.visibility = View.GONE + this.gone() } /** * Show the information view - * @param drawable icon of information view * @param textResource text of information view */ - fun show(drawable: Int, textResource: Int) { - image_view.setVectorCompat(drawable, context.getResourceColor(android.R.attr.textColorHint)) + fun show(@StringRes textResource: Int) { + text_face.text = getRandomErrorFace() text_label.text = context.getString(textResource) - this.visibility = View.VISIBLE + this.visible() + } + + companion object { + private val ERROR_FACES = listOf( + "(・o・;)", + "Σ(ಠ_ಠ)", + "ಥ_ಥ", + "(˘・_・˘)", + "(; ̄Д ̄)", + "(・Д・。" + ) + + fun getRandomErrorFace(): String { + return ERROR_FACES[Random.nextInt(ERROR_FACES.size)] + } } } diff --git a/app/src/main/res/drawable/ic_book_black_128dp.xml b/app/src/main/res/drawable/ic_book_black_128dp.xml deleted file mode 100644 index 5226a4ad51..0000000000 --- a/app/src/main/res/drawable/ic_book_black_128dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_file_download_black_128dp.xml b/app/src/main/res/drawable/ic_file_download_black_128dp.xml deleted file mode 100644 index 6edeb1b280..0000000000 --- a/app/src/main/res/drawable/ic_file_download_black_128dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_history_black_128dp.xml b/app/src/main/res/drawable/ic_history_black_128dp.xml deleted file mode 100644 index 1fff4d1b49..0000000000 --- a/app/src/main/res/drawable/ic_history_black_128dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_new_releases_black_128dp.xml b/app/src/main/res/drawable/ic_new_releases_black_128dp.xml deleted file mode 100644 index b6baaad252..0000000000 --- a/app/src/main/res/drawable/ic_new_releases_black_128dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_no_settings.xml b/app/src/main/res/drawable/ic_no_settings.xml deleted file mode 100644 index 71acd27e8e..0000000000 --- a/app/src/main/res/drawable/ic_no_settings.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_shape_black_128dp.xml b/app/src/main/res/drawable/ic_shape_black_128dp.xml deleted file mode 100644 index 98a101f5ef..0000000000 --- a/app/src/main/res/drawable/ic_shape_black_128dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/layout/common_view_empty.xml b/app/src/main/res/layout/common_view_empty.xml index c7d4a27c3a..7fdc6b21f8 100644 --- a/app/src/main/res/layout/common_view_empty.xml +++ b/app/src/main/res/layout/common_view_empty.xml @@ -2,22 +2,29 @@ - + + android:gravity="center" + tools:text="Label" />