diff --git a/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/MALApi.kt b/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/MALApi.kt index e8c343519b..be4ce90062 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/MALApi.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/MALApi.kt @@ -326,6 +326,7 @@ class MALApi : SyncAPI() { SyncWatchType.DROPPED -> MalStatusType.Dropped SyncWatchType.PLANTOWATCH -> MalStatusType.PlanToWatch SyncWatchType.REWATCHING -> MalStatusType.Watching + else -> MalStatusType.None } } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/WatchType.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/WatchType.kt index ec0ef5c6bf..8be1160ba4 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/WatchType.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/WatchType.kt @@ -3,30 +3,67 @@ package com.lagradost.cloudstream3.ui import androidx.annotation.DrawableRes import androidx.annotation.StringRes import com.lagradost.cloudstream3.R +import com.lagradost.cloudstream3.syncproviders.SyncAPI +/** + * Enum class representing watch states for library. + * + * @property internalId The unique ID used internally to identify the watch type and to store data. This value must never be changed. + * @property stringRes The string resource ID representing the watch type name. + * @property iconRes The drawable resource ID representing the watch type icon. + */ enum class WatchType(val internalId: Int, @StringRes val stringRes: Int, @DrawableRes val iconRes: Int) { - WATCHING(0, R.string.type_watching, R.drawable.ic_baseline_bookmark_24), - COMPLETED(1, R.string.type_completed, R.drawable.ic_baseline_bookmark_24), - ONHOLD(2, R.string.type_on_hold, R.drawable.ic_baseline_bookmark_24), - DROPPED(3, R.string.type_dropped, R.drawable.ic_baseline_bookmark_24), - PLANTOWATCH(4, R.string.type_plan_to_watch, R.drawable.ic_baseline_bookmark_24), - NONE(5, R.string.type_none, R.drawable.ic_baseline_add_24); + WATCHING(internalId = 0, R.string.type_watching, R.drawable.ic_baseline_bookmark_24), + COMPLETED(internalId = 1, R.string.type_completed, R.drawable.ic_baseline_bookmark_24), + ONHOLD(internalId = 2, R.string.type_on_hold, R.drawable.ic_baseline_bookmark_24), + DROPPED(internalId = 3, R.string.type_dropped, R.drawable.ic_baseline_bookmark_24), + PLANTOWATCH(internalId = 4, R.string.type_plan_to_watch, R.drawable.ic_baseline_bookmark_24), + + // Any types with negative internal IDs, or those for which the order is important, + // should be placed at the bottom. This ensures that we don't need to worry about + // their internal IDs when adding new types in the future. + NOTINTERESTED(internalId = -2, R.string.type_not_interested, R.drawable.ic_baseline_bookmark_24), + NONE(internalId = -1, R.string.type_none, R.drawable.ic_baseline_add_24); companion object { + /** + * Finds a [WatchType] corresponding to the given [internalId]. + * + * @param id The internal ID to search for. + * @return The corresponding [WatchType], or [NONE] if no match is found. + */ fun fromInternalId(id: Int?) = entries.find { value -> value.internalId == id } ?: NONE } } +/** + * Enum class representing various watch states for when using a remote library in [SyncAPI]. + * + * @property internalId The unique ID used internally to identify the watch type and to store data locally. This value must never be changed. + * @property stringRes The string resource ID representing the watch type name. + * @property iconRes The drawable resource ID representing the watch type icon. + */ enum class SyncWatchType(val internalId: Int, @StringRes val stringRes: Int, @DrawableRes val iconRes: Int) { - NONE(-1, R.string.type_none, R.drawable.ic_baseline_add_24), - WATCHING(0, R.string.type_watching, R.drawable.ic_baseline_bookmark_24), - COMPLETED(1, R.string.type_completed, R.drawable.ic_baseline_bookmark_24), - ONHOLD(2, R.string.type_on_hold, R.drawable.ic_baseline_bookmark_24), - DROPPED(3, R.string.type_dropped, R.drawable.ic_baseline_bookmark_24), - PLANTOWATCH(4, R.string.type_plan_to_watch, R.drawable.ic_baseline_bookmark_24), - REWATCHING(5, R.string.type_re_watching, R.drawable.ic_baseline_bookmark_24); + NONE(internalId = -1, R.string.type_none, R.drawable.ic_baseline_add_24), + WATCHING(internalId = 0, R.string.type_watching, R.drawable.ic_baseline_bookmark_24), + COMPLETED(internalId = 1, R.string.type_completed, R.drawable.ic_baseline_bookmark_24), + ONHOLD(internalId = 2, R.string.type_on_hold, R.drawable.ic_baseline_bookmark_24), + DROPPED(internalId = 3, R.string.type_dropped, R.drawable.ic_baseline_bookmark_24), + PLANTOWATCH(internalId = 4, R.string.type_plan_to_watch, R.drawable.ic_baseline_bookmark_24), + REWATCHING(internalId = 5, R.string.type_re_watching, R.drawable.ic_baseline_bookmark_24), + + // Any types with negative internal IDs, or those for which the order is important, + // should be placed at the bottom, except for "NONE", which has a negative ID but is + // placed at the top for UI reasons. + NOTINTERESTED(internalId = -2, R.string.type_not_interested, R.drawable.ic_baseline_bookmark_24); companion object { + /** + * Finds a [SyncWatchType] corresponding to the given [internalId]. + * + * @param id The internal ID to search for. + * @return The corresponding [SyncWatchType], or [NONE] if no match is found. + */ fun fromInternalId(id: Int?) = entries.find { value -> value.internalId == id } ?: NONE } -} +} \ No newline at end of file diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeParentItemAdapterPreview.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeParentItemAdapterPreview.kt index 701018c964..dbed584013 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeParentItemAdapterPreview.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeParentItemAdapterPreview.kt @@ -453,7 +453,8 @@ class HomeParentItemAdapterPreview( Pair(itemView.findViewById(R.id.home_type_completed_btt), WatchType.COMPLETED), Pair(itemView.findViewById(R.id.home_type_dropped_btt), WatchType.DROPPED), Pair(itemView.findViewById(R.id.home_type_on_hold_btt), WatchType.ONHOLD), - Pair(itemView.findViewById(R.id.home_plan_to_watch_btt), WatchType.PLANTOWATCH), + Pair(itemView.findViewById(R.id.home_type_plan_to_watch_btt), WatchType.PLANTOWATCH), + Pair(itemView.findViewById(R.id.home_type_not_interested_btt), WatchType.NOTINTERESTED), ) private val toggleListHolder: ChipGroup? = itemView.findViewById(R.id.home_type_holder) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentPhone.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentPhone.kt index cd9d05527f..187c3598d3 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentPhone.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentPhone.kt @@ -51,6 +51,7 @@ import com.lagradost.cloudstream3.mvvm.observeNullable import com.lagradost.cloudstream3.mvvm.safe import com.lagradost.cloudstream3.services.SubscriptionWorkManager import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.APP_STRING_SHARE +import com.lagradost.cloudstream3.ui.SyncWatchType import com.lagradost.cloudstream3.ui.WatchType import com.lagradost.cloudstream3.ui.download.DOWNLOAD_ACTION_DOWNLOAD import com.lagradost.cloudstream3.ui.download.DOWNLOAD_ACTION_LONG_CLICK @@ -1010,15 +1011,10 @@ open class ResultFragmentPhone : FullScreenPlayer() { } context?.let { ctx -> val arrayAdapter = ArrayAdapter(ctx, R.layout.sort_bottom_single_choice) - /* - -1 -> None - 0 -> Watching - 1 -> Completed - 2 -> OnHold - 3 -> Dropped - 4 -> PlanToWatch - 5 -> ReWatching - */ + /** + * @see SyncWatchType.internalId + * For the corresponding values. + */ val items = listOf( R.string.none, R.string.type_watching, @@ -1026,7 +1022,8 @@ open class ResultFragmentPhone : FullScreenPlayer() { R.string.type_on_hold, R.string.type_dropped, R.string.type_plan_to_watch, - R.string.type_re_watching + R.string.type_re_watching, + R.string.type_not_interested ).map { ctx.getString(it) } arrayAdapter.addAll(items) syncBinding?.apply { diff --git a/app/src/main/res/layout/fragment_home_head.xml b/app/src/main/res/layout/fragment_home_head.xml index e57990dc49..e9624215f1 100644 --- a/app/src/main/res/layout/fragment_home_head.xml +++ b/app/src/main/res/layout/fragment_home_head.xml @@ -275,11 +275,11 @@ android:layout_height="wrap_content" android:nextFocusLeft="@id/nav_rail_view" - android:nextFocusRight="@id/home_plan_to_watch_btt" + android:nextFocusRight="@id/home_type_plan_to_watch_btt" android:text="@string/type_watching" /> @@ -312,10 +312,20 @@ android:id="@+id/home_type_completed_btt" style="@style/ChipFilled" android:layout_width="wrap_content" - android:layout_height="wrap_content" + android:nextFocusLeft="@id/home_type_dropped_btt" + android:nextFocusRight="@id/home_type_not_interested_btt" android:text="@string/type_completed" /> + + @@ -341,4 +351,4 @@ app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" tools:listitem="@layout/home_result_grid" /> - + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home_head_tv.xml b/app/src/main/res/layout/fragment_home_head_tv.xml index 11a8b815ff..d6800d1504 100644 --- a/app/src/main/res/layout/fragment_home_head_tv.xml +++ b/app/src/main/res/layout/fragment_home_head_tv.xml @@ -321,14 +321,14 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:nextFocusLeft="@id/navigation_home" - android:nextFocusRight="@id/home_plan_to_watch_btt" + android:nextFocusRight="@id/home_type_plan_to_watch_btt" android:nextFocusUp="@id/home_watch_child_recyclerview" android:nextFocusDown="@id/home_bookmarked_child_recyclerview" android:text="@string/type_watching" /> + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0ba5599f06..b0b1f2452a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -141,6 +141,7 @@ Plan to Watch @string/none Rewatching + Not Interested Play Movie Play Trailer Play Livestream