Skip to content

Commit

Permalink
Merge pull request #19978 from wordpress-mobile/feature/reader-ia
Browse files Browse the repository at this point in the history
[Reader] Improve content navigation and filtering
  • Loading branch information
Thomas Horta authored Feb 3, 2024
2 parents 2be635d + 1776c29 commit ad69dd1
Show file tree
Hide file tree
Showing 153 changed files with 3,507 additions and 1,414 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* [**] Fix editor crash occurring on large posts [https://github.com/wordpress-mobile/WordPress-Android/pull/20046]
* [*] [Jetpack-only] Site Monitoring: Add Metrics, PHP Logs, and Web Server Logs under Site Monitoring [https://github.com/wordpress-mobile/WordPress-Android/issues/20067]
* [**] Prevent images from temporarily disappearing when uploading media [https://github.com/WordPress/gutenberg/pull/57869]
* [***] [Jetpack-only] Reader: introduced new UI/UX for content navigation and filtering [https://github.com/wordpress-mobile/WordPress-Android/pull/19978]

24.1
-----
Expand Down
3 changes: 3 additions & 0 deletions WordPress/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,9 @@ dependencies {
androidTestImplementation "androidx.compose.ui:ui-test-junit4"
implementation "androidx.compose.material3:material3:$androidxComposeMaterial3Version"

// Cascade - Compose nested menu
implementation "me.saket.cascade:cascade-compose:2.3.0"

// - Flipper
debugImplementation ("com.facebook.flipper:flipper:$flipperVersion") {
exclude group:'org.jetbrains.kotlinx', module:'kotlinx-serialization-json-jvm'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.wordpress.android.e2e

import dagger.hilt.android.testing.HiltAndroidTest
import org.junit.Before
import org.junit.Ignore
import org.junit.Test
import org.wordpress.android.e2e.pages.ReaderPage
import org.wordpress.android.support.BaseTest
Expand All @@ -18,6 +19,7 @@ class ReaderTests : BaseTest() {
}

@Test
@Ignore("Ignored for now considering the context of Reader IA feature that completely changes the Reader design")
fun e2eNavigateThroughPosts() {
ReaderPage()
.tapFollowingTab()
Expand All @@ -31,6 +33,7 @@ class ReaderTests : BaseTest() {
}

@Test
@Ignore("Ignored for now considering the context of Reader IA feature that completely changes the Reader design")
fun e2eLikePost() {
ReaderPage()
.tapFollowingTab()
Expand All @@ -43,6 +46,7 @@ class ReaderTests : BaseTest() {
}

@Test
@Ignore("Ignored for now considering the context of Reader IA feature that completely changes the Reader design")
fun e2eBookmarkPost() {
ReaderPage()
.tapFollowingTab()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -658,14 +658,14 @@ public static String getOldestDateWithTag(final ReaderTag tag) {
public static String getOldestPubDateInBlog(long blogId) {
String sql = "SELECT date_published FROM tbl_posts"
+ " WHERE blog_id=? AND tag_name='' AND tag_type=0"
+ " ORDER BY date_published LIMIT 1";
+ " ORDER BY datetime(date_published) LIMIT 1";
return SqlUtils.stringForQuery(ReaderDatabase.getReadableDb(), sql, new String[]{Long.toString(blogId)});
}

public static String getOldestPubDateInFeed(long feedId) {
String sql = "SELECT date_published FROM tbl_posts"
+ " WHERE feed_id=? AND tag_name='' AND tag_type=0"
+ " ORDER BY date_published LIMIT 1";
+ " ORDER BY datetime(date_published) LIMIT 1";
return SqlUtils.stringForQuery(ReaderDatabase.getReadableDb(), sql, new String[]{Long.toString(feedId)});
}

Expand Down Expand Up @@ -743,15 +743,15 @@ public static String getGapMarkerDateForTag(ReaderTag tag) {
*/
private static String getSortColumnForTag(ReaderTag tag) {
if (tag.isPostsILike()) {
return "date_liked";
return "datetime(date_liked)";
} else if (tag.isFollowedSites()) {
return "date_published";
return "datetime(date_published)";
} else if (tag.tagType == ReaderTagType.SEARCH) {
return "score";
} else if (tag.isTagTopic() || tag.isBookmarked()) {
return "date_tagged";
return "datetime(date_tagged)";
} else {
return "date_published";
return "datetime(date_published)";
}
}

Expand Down Expand Up @@ -982,7 +982,7 @@ public static ReaderPostList getPostsInBlog(long blogId, int maxPosts, boolean e
String columns = (excludeTextColumn ? COLUMN_NAMES_NO_TEXT : "*");
String sql =
"SELECT " + columns + " FROM tbl_posts WHERE blog_id=? AND tag_name='' AND tag_type=0"
+ " ORDER BY date_published DESC";
+ " ORDER BY datetime(date_published) DESC";

if (maxPosts > 0) {
sql += " LIMIT " + maxPosts;
Expand Down Expand Up @@ -1020,7 +1020,7 @@ public static ReaderPostList getPostsInFeed(long feedId, int maxPosts, boolean e
String columns = (excludeTextColumn ? COLUMN_NAMES_NO_TEXT : "*");
String sql =
"SELECT " + columns + " FROM tbl_posts WHERE feed_id=? AND tag_name='' AND tag_type=0"
+ " ORDER BY date_published DESC";
+ " ORDER BY datetime(date_published) DESC";

if (maxPosts > 0) {
sql += " LIMIT " + maxPosts;
Expand Down Expand Up @@ -1097,7 +1097,7 @@ private static ReaderBlogIdPostIdList getBlogIdPostIds(@NonNull String sql, @Non
*/
public static ReaderBlogIdPostIdList getBlogIdPostIdsInBlog(long blogId, int maxPosts) {
String sql = "SELECT post_id FROM tbl_posts WHERE blog_id=? AND tag_name='' AND tag_type=0"
+ " ORDER BY date_published DESC";
+ " ORDER BY datetime(date_published) DESC";

if (maxPosts > 0) {
sql += " LIMIT " + maxPosts;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,4 @@ public ReaderTagList getDeletions(ReaderTagList otherList) {

return deletions;
}

public boolean containsFollowingTag() {
boolean containsFollowing = false;

for (ReaderTag tag : this) {
if (tag.isFollowedSites() || tag.isDefaultInMemoryTag()) {
containsFollowing = true;
break;
}
}

return containsFollowing;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.wordpress.android.models

fun ReaderTagList.containsFollowingTag(): Boolean =
find { it.isFollowedSites || it.isDefaultInMemoryTag } != null
Original file line number Diff line number Diff line change
Expand Up @@ -64,51 +64,51 @@ class ActionableEmptyView : LinearLayout {
bottomImage = layout.findViewById(R.id.bottom_image)
progressBar = layout.findViewById(R.id.actionable_empty_view_progress_bar)

attrs.let {
val typedArray = context.obtainStyledAttributes(
it,
R.styleable.ActionableEmptyView,
0,
0
)

val imageResource = typedArray.getResourceId(
R.styleable.ActionableEmptyView_aevImage,
0
)
val hideImageInLandscape = typedArray.getBoolean(
R.styleable.ActionableEmptyView_aevImageHiddenInLandscape,
false
)
val titleAttribute = typedArray.getString(R.styleable.ActionableEmptyView_aevTitle)
val subtitleAttribute = typedArray.getString(R.styleable.ActionableEmptyView_aevSubtitle)
val buttonAttribute = typedArray.getString(R.styleable.ActionableEmptyView_aevButton)

if (imageResource != 0) {
image.setImageResource(imageResource)
if (!hideImageInLandscape || !DisplayUtils.isLandscape(context)) {
image.visibility = View.VISIBLE
}
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.ActionableEmptyView, 0, 0)
val imageResource = typedArray.getResourceId(
R.styleable.ActionableEmptyView_aevImage,
0
)
val hideImageInLandscape = typedArray.getBoolean(
R.styleable.ActionableEmptyView_aevImageHiddenInLandscape,
false
)
val titleAttribute = typedArray.getString(R.styleable.ActionableEmptyView_aevTitle)
val subtitleAttribute = typedArray.getString(R.styleable.ActionableEmptyView_aevSubtitle)
val buttonAttribute = typedArray.getString(R.styleable.ActionableEmptyView_aevButton)
val buttonStyleAttribute = typedArray.getInt(
R.styleable.ActionableEmptyView_aevButtonStyle,
BUTTON_STYLE_PRIMARY
)

if (imageResource != 0) {
image.setImageResource(imageResource)
if (!hideImageInLandscape || !DisplayUtils.isLandscape(context)) {
image.visibility = View.VISIBLE
}
}

if (!titleAttribute.isNullOrEmpty()) {
title.text = titleAttribute
} else {
throw RuntimeException("$context: ActionableEmptyView must have a title (aevTitle)")
}
if (!titleAttribute.isNullOrEmpty()) {
title.text = titleAttribute
} else {
throw RuntimeException("$context: ActionableEmptyView must have a title (aevTitle)")
}

if (!subtitleAttribute.isNullOrEmpty()) {
subtitle.text = subtitleAttribute
subtitle.visibility = View.VISIBLE
}
if (!subtitleAttribute.isNullOrEmpty()) {
subtitle.text = subtitleAttribute
subtitle.visibility = View.VISIBLE
}

if (!buttonAttribute.isNullOrEmpty()) {
button.text = buttonAttribute
button.visibility = View.VISIBLE
}
if (!buttonAttribute.isNullOrEmpty()) {
button.text = buttonAttribute
button.visibility = View.VISIBLE
}

typedArray.recycle()
if (buttonStyleAttribute == BUTTON_STYLE_READER) {
button.backgroundTintList = context.getColorStateList(R.color.reader_button_primary_background_selector)
button.setTextColor(context.getColorStateList(R.color.reader_button_primary_text))
}
typedArray.recycle()
}

/**
Expand Down Expand Up @@ -163,4 +163,9 @@ class ActionableEmptyView : LinearLayout {

announceForAccessibility("${title.text}.$subTitle")
}

companion object {
private const val BUTTON_STYLE_PRIMARY = 0
private const val BUTTON_STYLE_READER = 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import org.wordpress.android.ui.compose.components.MainTopAppBar
import org.wordpress.android.ui.compose.components.NavigationIcons
import org.wordpress.android.ui.compose.theme.AppColor
import org.wordpress.android.ui.compose.theme.AppTheme
import org.wordpress.android.ui.compose.utils.isLightTheme
import org.wordpress.android.ui.compose.utils.uiStringText
import org.wordpress.android.ui.main.jetpack.migration.compose.state.LoadingState
import org.wordpress.android.ui.utils.UiString
Expand Down Expand Up @@ -279,7 +280,7 @@ fun CampaignListingErrorPreview() {

@Composable
private fun CreateCampaignFloatingActionButton(modifier: Modifier = Modifier, onClick: () -> Unit) {
val isInDarkMode = !MaterialTheme.colors.isLight
val isInDarkMode = !isLightTheme()
FloatingActionButton(
modifier = modifier,
onClick = onClick,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import org.wordpress.android.ui.compose.theme.AppTheme
import org.wordpress.android.ui.compose.utils.isLightTheme
import org.wordpress.android.widgets.WPSwitchCompat
import com.google.android.material.R as MaterialR

Expand Down Expand Up @@ -79,14 +80,14 @@ object WPSwitchDefaults {
fun colors(): SwitchColors {
// thumb colors
val thumbDisabledColor = colorResource(
if (MaterialTheme.colors.isLight) {
if (isLightTheme()) {
MaterialR.color.switch_thumb_disabled_material_light
} else {
MaterialR.color.switch_thumb_disabled_material_dark
}
)
val thumbEnabledUncheckedColor = colorResource(
if (MaterialTheme.colors.isLight) {
if (isLightTheme()) {
MaterialR.color.switch_thumb_normal_material_light
} else {
MaterialR.color.switch_thumb_normal_material_dark
Expand Down
Loading

0 comments on commit ad69dd1

Please sign in to comment.