Skip to content

Commit

Permalink
Lists: add watched next, favorite change, update to item menu
Browse files Browse the repository at this point in the history
  • Loading branch information
UweTrottmann committed Mar 14, 2024
1 parent d9b7653 commit 19bcc45
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 30 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Version 72
*in development*

* 🔧 Seasons: different indicators if only some or all episodes are skipped or in collection.
* 🔧 Lists: add option to watch next episode, update to shows more options menu.

#### 72.0.5 🧪
*2024-03-08*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import com.battlelancer.seriesguide.databinding.FragmentListBinding
import com.battlelancer.seriesguide.lists.ListsDistillationSettings.ListsSortOrderChangedEvent
import com.battlelancer.seriesguide.lists.database.SgListItemWithDetails
import com.battlelancer.seriesguide.provider.SeriesGuideContract.ListItemTypes
import com.battlelancer.seriesguide.shows.episodes.EpisodeTools
import com.battlelancer.seriesguide.shows.tools.ShowSync
import com.battlelancer.seriesguide.ui.AutoGridLayoutManager
import com.battlelancer.seriesguide.ui.OverviewActivity
import com.battlelancer.seriesguide.ui.widgets.SgFastScroller
Expand Down Expand Up @@ -120,10 +122,14 @@ class SgListFragment : Fragment() {
override fun onMenuClick(anchor: View, item: SgListItemWithDetails) {
val popupMenu = PopupMenu(anchor.context, anchor)
popupMenu.inflate(R.menu.lists_popup_menu)
val menu = popupMenu.menu
menu.findItem(R.id.menu_action_lists_favorites_add).isVisible = !item.favorite
menu.findItem(R.id.menu_action_lists_favorites_remove).isVisible = item.favorite
popupMenu.setOnMenuItemClickListener(
PopupMenuItemClickListener(
requireContext(), parentFragmentManager,
item.listItemId, item.showId
item.listItemId, item.showId,
item.nextEpisode?.toLongOrNull() ?: 0
)
)
// Hide manage lists option for legacy show items, only allow removal.
Expand All @@ -144,18 +150,40 @@ class SgListFragment : Fragment() {
private val context: Context,
private val fragmentManager: FragmentManager,
private val itemId: String,
private val showId: Long
private val showId: Long,
private val nextEpisodeId: Long
) : PopupMenu.OnMenuItemClickListener {

private val showTools = SgApp.getServicesComponent(context).showTools()

override fun onMenuItemClick(item: MenuItem): Boolean {
val id = item.itemId
if (id == R.id.menu_action_lists_manage) {
ManageListsDialogFragment.show(fragmentManager, showId)
return true
} else if (id == R.id.menu_action_lists_remove) {
ListsTools.removeListItem(context, itemId)
return true
when (item.itemId) {
R.id.menu_action_lists_watched_next -> {
EpisodeTools.episodeWatchedIfNotZero(context, nextEpisodeId)
return true
}
R.id.menu_action_lists_favorites_add -> {
showTools.storeIsFavorite(showId, true)
return true
}
R.id.menu_action_lists_favorites_remove -> {
showTools.storeIsFavorite(showId, false)
return true
}
R.id.menu_action_lists_manage -> {
ManageListsDialogFragment.show(fragmentManager, showId)
return true
}
R.id.menu_action_lists_update -> {
ShowSync.triggerDeltaSync(context, showId)
return true
}
R.id.menu_action_lists_remove -> {
ListsTools.removeListItem(context, itemId)
return true
}
else -> return false
}
return false
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ data class SgListItemWithDetails(
@ColumnInfo(name = SgShow2Columns.POSTER_SMALL) val posterSmall: String?,
@ColumnInfo(name = SgShow2Columns.NETWORK) val network: String?,
@ColumnInfo(name = SgShow2Columns.STATUS) val status: Int?,
@ColumnInfo(name = SgShow2Columns.NEXTEPISODE) val nextEpisode: String?,
@ColumnInfo(name = SgShow2Columns.FAVORITE) var favorite: Boolean,
@ColumnInfo(name = SgShow2Columns.RELEASE_WEEKDAY) val releaseWeekDay: Int?,
@ColumnInfo(name = SgShow2Columns.RELEASE_TIMEZONE) val releaseTimeZone: String?,
Expand All @@ -102,24 +103,4 @@ data class SgListItemWithDetails(
get() = customReleaseDayOffset ?: SgShow2.CUSTOM_RELEASE_DAY_OFFSET_NOT_SET
val statusOrUnknown: Int
get() = status ?: ShowStatus.UNKNOWN

companion object {
const val SELECT = "SELECT ${ListItems._ID}," +
"${ListItems.LIST_ITEM_ID}," +
"${ListItems.ITEM_REF_ID}," +
"${ListItems.TYPE}," +
"${SgShow2Columns.REF_SHOW_ID}," +
"${SgShow2Columns.TITLE}," +
"${SgShow2Columns.POSTER_SMALL}," +
"${SgShow2Columns.NETWORK}," +
"${SgShow2Columns.RELEASE_TIME}," +
"${SgShow2Columns.RELEASE_WEEKDAY}," +
"${SgShow2Columns.RELEASE_TIMEZONE}," +
"${SgShow2Columns.RELEASE_COUNTRY}," +
"${SgShow2Columns.STATUS}," +
"${SgShow2Columns.NEXTTEXT}," +
"${SgShow2Columns.NEXTAIRDATEMS}," +
"${SgShow2Columns.FAVORITE}," +
SgShow2Columns.UNWATCHED_COUNT
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ private interface ItemsQuery {
+ SgShow2Columns.POSTER_SMALL + ","
+ SgShow2Columns.NETWORK + ","
+ SgShow2Columns.STATUS + ","
+ SgShow2Columns.NEXTEPISODE + ","
+ SgShow2Columns.FAVORITE + ","
+ SgShow2Columns.RELEASE_WEEKDAY + ","
+ SgShow2Columns.RELEASE_TIMEZONE + ","
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/res/menu/lists_popup_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

<menu xmlns:android="http://schemas.android.com/apk/res/android">

<item
android:id="@+id/menu_action_lists_watched_next"
android:title="@string/context_marknext" />
<item
android:id="@+id/menu_action_lists_favorites_add"
android:title="@string/context_favorite" />
<item
android:id="@+id/menu_action_lists_favorites_remove"
android:title="@string/context_unfavorite" />
<item
android:id="@+id/menu_action_lists_update"
android:title="@string/context_updateshow" />
<item
android:id="@+id/menu_action_lists_manage"
android:title="@string/list_item_manage" />
Expand Down

0 comments on commit 19bcc45

Please sign in to comment.