Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e3fc4d7
Add new Compose post list backed by wordpress-rs
nbradbury Feb 10, 2026
b6a07ee
Use scrollable tabs in post list to prevent label wrapping
nbradbury Feb 10, 2026
f047e40
Add create post button to empty state in post list
nbradbury Feb 10, 2026
0fbd59e
Use tab-specific empty messages matching existing post list
nbradbury Feb 10, 2026
2891d74
Remove unused snapshotFlow import
nbradbury Feb 10, 2026
557e849
Remove unused fields and tighten visibility in post list
nbradbury Feb 11, 2026
0c67beb
Use relative time formatting for post dates in post list
nbradbury Feb 11, 2026
88721e4
Fix date parsing for posts without timezone offset
nbradbury Feb 11, 2026
c7ccb02
Add floating action button for creating new posts
nbradbury Feb 11, 2026
94c80a5
Move rslist package to ui.posts_rs
nbradbury Feb 11, 2026
da8626c
Simplify ViewModel coroutine handling and remove redundant code
nbradbury Feb 11, 2026
0ab5593
Consolidate posts-rs feature gating into ActivityLauncher
nbradbury Feb 11, 2026
3544080
Fix checkstyle and detekt violations
nbradbury Feb 11, 2026
fbf9877
Extract composables from PostRsListActivity into screens package
nbradbury Feb 11, 2026
1848a54
Refresh post list when a post finishes uploading
nbradbury Feb 11, 2026
3d63b84
Merge branch 'trunk' into feature/rs-post-list
nbradbury Feb 11, 2026
83b4f96
Replace local stripHtml with HtmlUtils.fastStripHtml
nbradbury Feb 11, 2026
56902b7
Use Channel for one-shot UI events to prevent race conditions
nbradbury Feb 11, 2026
a68a06c
Replace hardcoded strings with existing string resources
nbradbury Feb 11, 2026
cbd9bcc
Debounce tab selection to avoid redundant network requests
nbradbury Feb 11, 2026
447aaf9
Use snapshotFlow for load-more observer to fix stale state reads
nbradbury Feb 11, 2026
819f7c7
Use PostStatus enum instead of strings and fix double tab selection
nbradbury Feb 11, 2026
4493382
Scope UI event collection to STARTED lifecycle state
nbradbury Feb 11, 2026
a1aa4a1
Merge trunk and remove NAV_MENUS experimental feature flag
nbradbury Feb 12, 2026
d54adde
Corrected string resource indentation
nbradbury Feb 12, 2026
8be7c7a
Added comment
nbradbury Feb 12, 2026
8a2cd0c
Use view context instead of edit context for post list API
nbradbury Feb 12, 2026
b44ea51
Add authorId to PostRsModel
nbradbury Feb 12, 2026
700d9b5
Use ConcurrentHashMap for thread-safe loadedCounts access
nbradbury Feb 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions WordPress/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,12 @@
android:launchMode="singleTop"
android:theme="@style/WordPress.NoActionBar"/>

<activity
android:name=".ui.postsrs.PostRsListActivity"
android:label="@string/my_site_btn_blog_posts"
android:launchMode="singleTop"
android:theme="@style/WordPress.NoActionBar"/>

<!--Plugins-->
<activity
android:name=".ui.plugins.PluginDetailActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@
import org.wordpress.android.ui.prefs.notifications.NotificationsSettingsActivity;
import org.wordpress.android.ui.publicize.PublicizeListActivity;
import org.wordpress.android.ui.navmenus.NavMenusActivity;
import org.wordpress.android.ui.postsrs.PostRsListActivity;
import org.wordpress.android.ui.prefs.AppPrefs;
import org.wordpress.android.ui.qrcodeauth.QRCodeAuthActivity;
import org.wordpress.android.ui.reader.ReaderActivityLauncher;
import org.wordpress.android.ui.reader.ReaderConstants;
Expand Down Expand Up @@ -651,6 +653,13 @@ public static void viewConnectJetpackForStats(Context context, SiteModel site) {
}

public static void viewCurrentBlogPosts(Context context, SiteModel site) {
if (site != null
&& site.hasApplicationPassword()
&& AppPrefs.getExperimentalFeatureConfig(
ExperimentalFeatures.Feature.POSTS_RS_LIST.getPrefKey())) {
context.startActivity(PostRsListActivity.createIntent(context));
return;
}
viewCurrentBlogPostsOfType(context, site, null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import org.wordpress.android.ui.mysite.personalization.PersonalizationActivity
import org.wordpress.android.ui.navmenus.NavMenusActivity
import org.wordpress.android.ui.notifications.NotificationsDetailActivity
import org.wordpress.android.ui.posts.EditPostActivity
import org.wordpress.android.ui.postsrs.PostRsListActivity
import org.wordpress.android.ui.posts.GutenbergKitActivity
import org.wordpress.android.ui.posts.sharemessage.EditJetpackSocialShareMessageActivity
import org.wordpress.android.ui.prefs.experimentalfeatures.ExperimentalFeaturesActivity
Expand Down Expand Up @@ -96,6 +97,7 @@ private val excludedActivities = listOf(
MediaPreviewActivity::class.java.name,
MenuActivity::class.java.name,
NavMenusActivity::class.java.name,
PostRsListActivity::class.java.name,
NewDomainSearchActivity::class.java.name,
PersonalizationActivity::class.java.name,
PurchaseDomainActivity::class.java.name,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
package org.wordpress.android.ui.postsrs

import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Bundle
import androidx.activity.viewModels
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch
import org.wordpress.android.R
import org.wordpress.android.fluxc.store.PostStore
import org.wordpress.android.ui.ActivityLauncher
import org.wordpress.android.ui.PagePostCreationSourcesDetail
import org.wordpress.android.ui.main.BaseAppCompatActivity
import org.wordpress.android.ui.mysite.SelectedSiteRepository
import org.wordpress.android.ui.posts.PostUtils.EntryPoint
import org.wordpress.android.ui.postsrs.screens.PostRsListScreen
import org.wordpress.android.util.ToastUtils
import javax.inject.Inject

@AndroidEntryPoint
class PostRsListActivity : BaseAppCompatActivity() {
private val viewModel by viewModels<PostRsListViewModel>()

@Inject lateinit var postStore: PostStore
@Inject lateinit var selectedSiteRepository: SelectedSiteRepository

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

val composeView = ComposeView(this)
setContentView(
composeView.apply {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
this.isForceDarkAllowed = false
}
setViewCompositionStrategy(
ViewCompositionStrategy
.DisposeOnViewTreeLifecycleDestroyed
)
setContent {
val selectedTab by viewModel
.selectedTab.collectAsState()
PostRsListScreen(
selectedTab = selectedTab,
tabStateFlow = viewModel::tabState,
onTabSelected = viewModel::onTabSelected,
onPostClick = viewModel::onPostClicked,
onRefresh = viewModel::refreshPosts,
onLoadMore = viewModel::loadMorePosts,
onCreatePost = ::createNewPost,
onBack = ::finish
)
}
}
)

observeUiEvents()
}

private fun observeUiEvents() {
lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
viewModel.uiEvent.collect { event ->
handleUiEvent(event)
}
}
}
}

private fun handleUiEvent(event: PostRsListUiEvent) {
when (event) {
is PostRsListUiEvent.ShowError -> {
ToastUtils.showToast(
this, event.message, ToastUtils.Duration.LONG
)
}
is PostRsListUiEvent.OpenPost -> {
openPostEditor(event.remotePostId)
}
}
}

private fun openPostEditor(remotePostId: Long) {
val site =
selectedSiteRepository.getSelectedSite() ?: return
val post = postStore.getPostByRemotePostId(
remotePostId, site
)
if (post != null) {
ActivityLauncher.editPostOrPageForResult(
this, site, post
)
} else {
ToastUtils.showToast(
this,
R.string.post_not_found,
ToastUtils.Duration.SHORT
)
}
}

private fun createNewPost() {
val site =
selectedSiteRepository.getSelectedSite()
?: return
ActivityLauncher.addNewPostForResult(
this,
site,
false,
PagePostCreationSourcesDetail
.POST_FROM_POSTS_LIST,
-1,
EntryPoint.MY_SITE_CARD_ANSWER_PROMPT
)
}

companion object {
@JvmStatic
fun createIntent(context: Context): Intent {
return Intent(
context, PostRsListActivity::class.java
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.wordpress.android.ui.postsrs

import androidx.annotation.StringRes
import org.wordpress.android.R
import uniffi.wp_api.PostStatus
import uniffi.wp_api.WpApiParamOrder

/**
* Tabs for the wordpress-rs post list, each mapping
* to one or more [PostStatus] values.
*/
enum class PostRsListTab(
@StringRes val titleResId: Int,
val statuses: List<PostStatus>,
val order: WpApiParamOrder
) {
PUBLISHED(
titleResId = R.string.post_list_tab_published_posts,
statuses = listOf(
PostStatus.Publish,
PostStatus.Private
),
order = WpApiParamOrder.DESC
),
DRAFTS(
titleResId = R.string.post_list_tab_drafts,
statuses = listOf(
PostStatus.Draft,
PostStatus.Pending
),
order = WpApiParamOrder.DESC
),
SCHEDULED(
titleResId = R.string.post_list_tab_scheduled_posts,
statuses = listOf(PostStatus.Future),
order = WpApiParamOrder.ASC
),
TRASHED(
titleResId = R.string.post_list_tab_trashed_posts,
statuses = listOf(PostStatus.Trash),
order = WpApiParamOrder.DESC
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
package org.wordpress.android.ui.postsrs

import org.wordpress.android.R
import org.wordpress.android.ui.postsrs.models.PostRsModel
import org.wordpress.android.util.DateTimeUtils
import org.wordpress.android.util.DateTimeUtilsWrapper
import org.wordpress.android.util.HtmlUtils
import org.wordpress.android.viewmodel.ResourceProvider
import uniffi.wp_api.PostStatus
import java.text.DateFormat

/**
* UI state for a single tab in the post list.
*/
data class PostTabUiState(
val isLoading: Boolean = false,
val isRefreshing: Boolean = false,
val isLoadingMore: Boolean = false,
val canLoadMore: Boolean = false,
val posts: List<PostUiModel> = emptyList(),
val error: String? = null
)

/**
* Display model for a single post in the list.
*/
data class PostUiModel(
val remoteId: Long,
val title: String,
val excerpt: String,
val dateFormatted: String,
val statusLabel: String
)

/**
* One-time UI events emitted by the ViewModel.
*/
sealed class PostRsListUiEvent {
data class ShowError(
val message: String
) : PostRsListUiEvent()

data class OpenPost(
val remotePostId: Long
) : PostRsListUiEvent()
}

// ========== Mapping Functions ==========

fun PostRsModel.toUiModel(
dateTimeUtilsWrapper: DateTimeUtilsWrapper,
resourceProvider: ResourceProvider
): PostUiModel {
val parsed = DateTimeUtils.dateUTCFromIso8601(
normalizeIso8601(date)
)
val formatted = if (status is PostStatus.Future && parsed != null) {
DateFormat.getDateTimeInstance(
DateFormat.MEDIUM,
DateFormat.SHORT
).format(parsed)
} else {
dateTimeUtilsWrapper.javaDateToTimeSpan(parsed)
}
return PostUiModel(
remoteId = remotePostId,
title = title.ifBlank {
resourceProvider.getString(
R.string.untitled_in_parentheses
)
},
excerpt = HtmlUtils.fastStripHtml(excerpt)
.take(MAX_EXCERPT_LENGTH),
dateFormatted = formatted,
statusLabel = mapStatusLabel(status, resourceProvider)
)
}

private fun mapStatusLabel(
status: PostStatus,
resourceProvider: ResourceProvider
): String {
return when (status) {
is PostStatus.Publish -> resourceProvider.getString(
R.string.post_status_post_published
)
is PostStatus.Draft -> resourceProvider.getString(
R.string.post_status_draft
)
is PostStatus.Pending -> resourceProvider.getString(
R.string.post_status_pending_review
)
is PostStatus.Private -> resourceProvider.getString(
R.string.post_status_post_private
)
is PostStatus.Future -> resourceProvider.getString(
R.string.post_status_post_scheduled
)
is PostStatus.Trash -> resourceProvider.getString(
R.string.post_status_post_trashed
)
is PostStatus.Custom -> status.v1.replaceFirstChar {
it.uppercase()
}
}
}

private fun normalizeIso8601(date: String): String {
return if (date.contains("+") || date.endsWith("Z")) {
date
} else {
"${date}+0000"
}
}

private const val MAX_EXCERPT_LENGTH = 150
Loading