add: autogestione tab, list, filter.kind mastodon.api

This commit is contained in:
user 2023-11-12 17:49:23 +01:00
parent dc26e6bb7b
commit 642643c9de
7 changed files with 21 additions and 1 deletions

View file

@ -38,6 +38,7 @@ const val TRENDING_STATUSES = "TrendingStatuses"
const val HASHTAG = "Hashtag"
const val LIST = "List"
const val BOOKMARKS = "Bookmarks"
const val AUTOGESTIONE = "Autogestione"
data class TabData(
val id: String,
@ -128,6 +129,14 @@ fun createTabDataFromId(id: String, arguments: List<String> = emptyList()): TabD
icon = R.drawable.ic_bookmark_active_24dp,
fragment = { TimelineFragment.newInstance(TimelineViewModel.Kind.BOOKMARKS) }
)
AUTOGESTIONE -> TabData(
id = AUTOGESTIONE,
text = R.string.autogestione,
icon = R.drawable.ic_hashtag,
fragment = { args -> TimelineFragment.newInstance(TimelineViewModel.Kind.AUTOGESTIONE, args.getOrNull(0).orEmpty()) },
arguments = arguments,
title = { arguments.getOrNull(1).orEmpty() }
)
else -> throw IllegalArgumentException("unknown tab type")
}
}

View file

@ -387,6 +387,7 @@ class TabPreferenceActivity : BaseActivity(), Injectable, ItemInteractionListene
addableTabs.add(createTabDataFromId(HASHTAG))
addableTabs.add(createTabDataFromId(LIST))
addableTabs.add(createTabDataFromId(AUTOGESTIONE))
addTabAdapter.updateData(addableTabs)
currentTabsAdapter.setRemoveButtonVisible(currentTabs.size > MIN_TAB_COUNT)

View file

@ -546,6 +546,7 @@ class TimelineFragment :
TimelineViewModel.Kind.FAVOURITES,
TimelineViewModel.Kind.LIST,
TimelineViewModel.Kind.BOOKMARKS,
TimelineViewModel.Kind.AUTOGESTIONE,
TimelineViewModel.Kind.USER_PINNED -> return
}
}

View file

@ -291,6 +291,7 @@ class NetworkTimelineViewModel @Inject constructor(
Kind.BOOKMARKS -> api.bookmarks(fromId, uptoId, limit)
Kind.LIST -> api.listTimeline(id!!, fromId, uptoId, limit)
Kind.PUBLIC_TRENDING_STATUSES -> api.trendingStatuses(limit = limit, offset = fromId)
Kind.AUTOGESTIONE -> api.autogestione(remote = false, only_media = false)
}
}

View file

@ -316,13 +316,14 @@ abstract class TimelineViewModel(
}
enum class Kind {
HOME, PUBLIC_LOCAL, PUBLIC_FEDERATED, TAG, USER, USER_PINNED, USER_WITH_REPLIES, FAVOURITES, LIST, BOOKMARKS, PUBLIC_TRENDING_STATUSES;
HOME, PUBLIC_LOCAL, PUBLIC_FEDERATED, TAG, USER, USER_PINNED, USER_WITH_REPLIES, FAVOURITES, LIST, BOOKMARKS, PUBLIC_TRENDING_STATUSES,AUTOGESTIONE;
fun toFilterKind(): Filter.Kind {
return when (valueOf(name)) {
HOME, LIST -> Filter.Kind.HOME
PUBLIC_FEDERATED, PUBLIC_LOCAL, TAG, FAVOURITES, PUBLIC_TRENDING_STATUSES -> Filter.Kind.PUBLIC
USER, USER_WITH_REPLIES, USER_PINNED -> Filter.Kind.ACCOUNT
AUTOGESTIONE -> Filter.Kind.PUBLIC
else -> Filter.Kind.PUBLIC
}
}

View file

@ -860,4 +860,10 @@ interface MastodonApi {
@Query("limit") limit: Int? = null,
@Query("offset") offset: String? = null
): Response<List<Status>>
@GET("/api/v1/timelines/autogestione?remote=false&only_media=false")
suspend fun autogestione(
@Query("remote") remote: Boolean? = false,
@Query("only_media") only_media: Boolean? = false
): Response<List<Status>>
}

View file

@ -841,4 +841,5 @@
<string name="list_reply_policy_list">Members of the list</string>
<string name="list_reply_policy_followed">Any followed user</string>
<string name="list_reply_policy_label">Show replies to</string>
<string name="autogestione">Autogestione\t\t\t</string>
</resources>