mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 22:01:51 +01:00
Remove chapter updates popup menu
This commit is contained in:
parent
507471e318
commit
4061232fe3
@ -296,7 +296,7 @@ class UpdatesController : NucleusController<UpdatesPresenter>(),
|
|||||||
* @param menu menu object of ActionMode
|
* @param menu menu object of ActionMode
|
||||||
*/
|
*/
|
||||||
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
|
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
|
||||||
mode.menuInflater.inflate(R.menu.chapter_recent_selection, menu)
|
mode.menuInflater.inflate(R.menu.updates_chapter_selection, menu)
|
||||||
adapter?.mode = SelectableAdapter.Mode.MULTI
|
adapter?.mode = SelectableAdapter.Mode.MULTI
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -308,7 +308,14 @@ class UpdatesController : NucleusController<UpdatesPresenter>(),
|
|||||||
destroyActionModeIfNeeded()
|
destroyActionModeIfNeeded()
|
||||||
} else {
|
} else {
|
||||||
mode.title = count.toString()
|
mode.title = count.toString()
|
||||||
|
|
||||||
|
val chapters = getSelectedChapters()
|
||||||
|
menu.findItem(R.id.action_download).isVisible = chapters.any { !it.isDownloaded }
|
||||||
|
menu.findItem(R.id.action_delete).isVisible = chapters.any { it.isDownloaded }
|
||||||
|
menu.findItem(R.id.action_mark_as_read).isVisible = chapters.any { !it.chapter.read }
|
||||||
|
menu.findItem(R.id.action_mark_as_unread).isVisible = chapters.any { it.chapter.read }
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,11 +326,11 @@ class UpdatesController : NucleusController<UpdatesPresenter>(),
|
|||||||
*/
|
*/
|
||||||
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.action_mark_as_read -> markAsRead(getSelectedChapters())
|
|
||||||
R.id.action_mark_as_unread -> markAsUnread(getSelectedChapters())
|
|
||||||
R.id.action_download -> downloadChapters(getSelectedChapters())
|
R.id.action_download -> downloadChapters(getSelectedChapters())
|
||||||
R.id.action_delete -> ConfirmDeleteChaptersDialog(this, getSelectedChapters())
|
R.id.action_delete -> ConfirmDeleteChaptersDialog(this, getSelectedChapters())
|
||||||
.showDialog(router)
|
.showDialog(router)
|
||||||
|
R.id.action_mark_as_read -> markAsRead(getSelectedChapters())
|
||||||
|
R.id.action_mark_as_unread -> markAsUnread(getSelectedChapters())
|
||||||
else -> return false
|
else -> return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
package eu.kanade.tachiyomi.ui.recent.updates
|
package eu.kanade.tachiyomi.ui.recent.updates
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.PopupMenu
|
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
import eu.kanade.tachiyomi.data.glide.GlideApp
|
import eu.kanade.tachiyomi.data.glide.GlideApp
|
||||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import kotlinx.android.synthetic.main.updates_item.chapter_menu
|
|
||||||
import kotlinx.android.synthetic.main.updates_item.chapter_title
|
import kotlinx.android.synthetic.main.updates_item.chapter_title
|
||||||
import kotlinx.android.synthetic.main.updates_item.download_text
|
import kotlinx.android.synthetic.main.updates_item.download_text
|
||||||
import kotlinx.android.synthetic.main.updates_item.manga_cover
|
import kotlinx.android.synthetic.main.updates_item.manga_cover
|
||||||
@ -43,10 +41,6 @@ class UpdatesHolder(private val view: View, private val adapter: UpdatesAdapter)
|
|||||||
private var item: UpdatesItem? = null
|
private var item: UpdatesItem? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// We need to post a Runnable to show the popup to make sure that the PopupMenu is
|
|
||||||
// correctly positioned. The reason being that the view may change position before the
|
|
||||||
// PopupMenu is shown.
|
|
||||||
chapter_menu.setOnClickListener { it.post { showPopupMenu(it) } }
|
|
||||||
manga_cover.setOnClickListener {
|
manga_cover.setOnClickListener {
|
||||||
adapter.coverClickListener.onCoverClick(adapterPosition)
|
adapter.coverClickListener.onCoverClick(adapterPosition)
|
||||||
}
|
}
|
||||||
@ -103,50 +97,4 @@ class UpdatesHolder(private val view: View, private val adapter: UpdatesAdapter)
|
|||||||
else -> text = ""
|
else -> text = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Show pop up menu
|
|
||||||
*
|
|
||||||
* @param view view containing popup menu.
|
|
||||||
*/
|
|
||||||
private fun showPopupMenu(view: View) = item?.let { item ->
|
|
||||||
// Create a PopupMenu, giving it the clicked view for an anchor
|
|
||||||
val popup = PopupMenu(view.context, view)
|
|
||||||
|
|
||||||
// Inflate our menu resource into the PopupMenu's Menu
|
|
||||||
popup.menuInflater.inflate(R.menu.chapter_recent, popup.menu)
|
|
||||||
|
|
||||||
// Hide download and show delete if the chapter is downloaded and
|
|
||||||
if (item.isDownloaded) {
|
|
||||||
popup.menu.findItem(R.id.action_download).isVisible = false
|
|
||||||
popup.menu.findItem(R.id.action_delete).isVisible = true
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hide mark as unread when the chapter is unread
|
|
||||||
if (!item.chapter.read /*&& mangaChapter.chapter.last_page_read == 0*/) {
|
|
||||||
popup.menu.findItem(R.id.action_mark_as_unread).isVisible = false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hide mark as read when the chapter is read
|
|
||||||
if (item.chapter.read) {
|
|
||||||
popup.menu.findItem(R.id.action_mark_as_read).isVisible = false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set a listener so we are notified if a menu item is clicked
|
|
||||||
popup.setOnMenuItemClickListener { menuItem ->
|
|
||||||
with(adapter.controller) {
|
|
||||||
when (menuItem.itemId) {
|
|
||||||
R.id.action_download -> downloadChapter(item)
|
|
||||||
R.id.action_delete -> deleteChapter(item)
|
|
||||||
R.id.action_mark_as_read -> markAsRead(listOf(item))
|
|
||||||
R.id.action_mark_as_unread -> markAsUnread(listOf(item))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally show the PopupMenu
|
|
||||||
popup.show()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/material_component_lists_two_line_height"
|
android:layout_height="@dimen/material_component_lists_two_line_height"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
android:background="?attr/selectable_list_drawable">
|
android:background="?attr/selectable_list_drawable">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
@ -26,7 +27,7 @@
|
|||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:textAppearance="@style/TextAppearance.Regular.Body1"
|
android:textAppearance="@style/TextAppearance.Regular.Body1"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/chapter_title"
|
app:layout_constraintBottom_toTopOf="@+id/chapter_title"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/chapter_menu"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@+id/manga_cover"
|
app:layout_constraintStart_toEndOf="@+id/manga_cover"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintVertical_chainStyle="packed"
|
app:layout_constraintVertical_chainStyle="packed"
|
||||||
@ -51,27 +52,11 @@
|
|||||||
android:id="@+id/download_text"
|
android:id="@+id/download_text"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="16dp"
|
|
||||||
android:layout_marginBottom="3dp"
|
|
||||||
android:textAllCaps="true"
|
android:textAllCaps="true"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/manga_title"
|
||||||
tools:text="Downloaded" />
|
tools:text="Downloaded" />
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/chapter_menu"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center|end"
|
|
||||||
android:layout_marginEnd="8dp"
|
|
||||||
android:background="?selectableItemBackgroundBorderless"
|
|
||||||
android:contentDescription="@string/action_menu"
|
|
||||||
android:padding="8dp"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/download_text"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:srcCompat="@drawable/ic_more_horiz_black_24dp"
|
|
||||||
app:tint="?attr/icon_color" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
|
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/action_download"
|
|
||||||
android:title="@string/action_download"
|
|
||||||
android:visible="true"
|
|
||||||
app:showAsAction="ifRoom" />
|
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/action_delete"
|
|
||||||
android:title="@string/action_delete"
|
|
||||||
android:visible="false"
|
|
||||||
app:showAsAction="ifRoom" />
|
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/action_mark_as_read"
|
|
||||||
android:title="@string/action_mark_as_read"
|
|
||||||
app:showAsAction="ifRoom" />
|
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/action_mark_as_unread"
|
|
||||||
android:title="@string/action_mark_as_unread"
|
|
||||||
app:showAsAction="ifRoom" />
|
|
||||||
|
|
||||||
</menu>
|
|
@ -1,5 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu 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">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user