Add tooltips to manga info header action icons

This commit is contained in:
arkon 2020-06-19 17:40:17 -04:00
parent b8947a1c50
commit 361b0284fa
2 changed files with 17 additions and 2 deletions

View File

@ -20,6 +20,7 @@ import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.util.system.copyToClipboard import eu.kanade.tachiyomi.util.system.copyToClipboard
import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.setChips import eu.kanade.tachiyomi.util.view.setChips
import eu.kanade.tachiyomi.util.view.setTooltip
import eu.kanade.tachiyomi.util.view.visible import eu.kanade.tachiyomi.util.view.visible
import eu.kanade.tachiyomi.util.view.visibleIf import eu.kanade.tachiyomi.util.view.visibleIf
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
@ -89,17 +90,20 @@ class MangaInfoHeaderAdapter(
binding.btnCategories.clicks() binding.btnCategories.clicks()
.onEach { controller.onCategoriesClick() } .onEach { controller.onCategoriesClick() }
.launchIn(scope) .launchIn(scope)
binding.btnCategories.setTooltip(R.string.action_move_category)
if (controller.presenter.source is HttpSource) { if (controller.presenter.source is HttpSource) {
binding.btnWebview.visible() binding.btnWebview.visible()
binding.btnShare.visible()
binding.btnWebview.clicks() binding.btnWebview.clicks()
.onEach { controller.openMangaInWebView() } .onEach { controller.openMangaInWebView() }
.launchIn(scope) .launchIn(scope)
binding.btnWebview.setTooltip(R.string.action_open_in_web_view)
binding.btnShare.visible()
binding.btnShare.clicks() binding.btnShare.clicks()
.onEach { controller.shareManga() } .onEach { controller.shareManga() }
.launchIn(scope) .launchIn(scope)
binding.btnShare.setTooltip(R.string.action_share)
} }
binding.mangaFullTitle.longClicks() binding.mangaFullTitle.longClicks()

View File

@ -8,7 +8,9 @@ import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import androidx.annotation.MenuRes import androidx.annotation.MenuRes
import androidx.annotation.StringRes
import androidx.appcompat.widget.PopupMenu import androidx.appcompat.widget.PopupMenu
import androidx.appcompat.widget.TooltipCompat
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.chip.Chip import com.google.android.material.chip.Chip
import com.google.android.material.chip.ChipGroup import com.google.android.material.chip.ChipGroup
@ -38,6 +40,15 @@ inline fun View.snack(message: String, length: Int = Snackbar.LENGTH_LONG, f: Sn
return snack return snack
} }
/**
* Adds a tooltip shown on long press.
*
* @param stringRes String resource for tooltip.
*/
inline fun View.setTooltip(@StringRes stringRes: Int) {
TooltipCompat.setTooltipText(this, context.getString(stringRes))
}
/** /**
* Shows a popup menu on top of this view. * Shows a popup menu on top of this view.
* *