Skip to content

Commit

Permalink
Merge pull request #20812 from wordpress-mobile/feature/tags-ia
Browse files Browse the repository at this point in the history
[Feature] Tags IA
  • Loading branch information
RenanLukas committed May 25, 2024
2 parents 1292631 + 10d743d commit b4d6861
Show file tree
Hide file tree
Showing 93 changed files with 6,465 additions and 575 deletions.
2 changes: 2 additions & 0 deletions WordPress/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ android {
buildConfigField "boolean", "READER_DISCOVER_NEW_ENDPOINT", "false"
buildConfigField "boolean", "READER_READING_PREFERENCES", "false"
buildConfigField "boolean", "READER_READING_PREFERENCES_FEEDBACK", "false"
buildConfigField "boolean", "READER_TAGS_FEED", "false"
buildConfigField "boolean", "READER_ANNOUNCEMENT_CARD", "false"
buildConfigField "boolean", "VOICE_TO_CONTENT", "false"

// Override these constants in jetpack product flavor to enable/ disable features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import org.wordpress.android.datasets.ReaderPostTable
import org.wordpress.android.models.ReaderPost
import org.wordpress.android.models.ReaderPostList
import org.wordpress.android.models.ReaderTag
import org.wordpress.android.ui.reader.actions.ReaderActions.UpdateResult
import org.wordpress.android.ui.reader.models.ReaderBlogIdPostId
import javax.inject.Inject

@Reusable
Expand All @@ -30,6 +32,23 @@ class ReaderPostTableWrapper @Inject constructor() {

fun getNumPostsWithTag(readerTag: ReaderTag): Int = ReaderPostTable.getNumPostsWithTag(readerTag)

fun addOrUpdatePosts(readerTag: ReaderTag, posts: ReaderPostList) =
fun addOrUpdatePosts(readerTag: ReaderTag?, posts: ReaderPostList) =
ReaderPostTable.addOrUpdatePosts(readerTag, posts)

fun deletePostsWithTag(tag: ReaderTag) = ReaderPostTable.deletePostsWithTag(tag)

fun comparePosts(posts: ReaderPostList): UpdateResult = ReaderPostTable.comparePosts(posts)

fun updateBookmarkedPostPseudoId(posts: ReaderPostList) = ReaderPostTable.updateBookmarkedPostPseudoId(posts)

fun setGapMarkerForTag(blogId: Long, postId: Long, tag: ReaderTag) =
ReaderPostTable.setGapMarkerForTag(blogId, postId, tag)

fun removeGapMarkerForTag(tag: ReaderTag) = ReaderPostTable.removeGapMarkerForTag(tag)

fun deletePostsBeforeGapMarkerForTag(tag: ReaderTag) = ReaderPostTable.deletePostsBeforeGapMarkerForTag(tag)

fun hasOverlap(posts: ReaderPostList?, tag: ReaderTag): Boolean = ReaderPostTable.hasOverlap(posts, tag)

fun getGapMarkerIdsForTag(tag: ReaderTag): ReaderBlogIdPostId? = ReaderPostTable.getGapMarkerIdsForTag(tag)
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ public boolean isBookmarked() {
return tagType == ReaderTagType.BOOKMARKED;
}

public boolean isTags() {
return tagType == ReaderTagType.TAGS;
}

public boolean isDiscover() {
return tagType == ReaderTagType.DEFAULT && getEndpoint().endsWith(DISCOVER_PATH);
}
Expand All @@ -204,7 +208,7 @@ public boolean isA8C() {
}

public boolean isFilterable() {
return this.isFollowedSites() || this.isA8C() || this.isP2();
return this.isFollowedSites() || this.isA8C() || this.isP2() || this.isTags();
}

public boolean isListTopic() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ public enum ReaderTagType {
CUSTOM_LIST,
SEARCH,
INTERESTS,
DISCOVER_POST_CARDS;
DISCOVER_POST_CARDS,
TAGS;

private static final int INT_DEFAULT = 0;
private static final int INT_FOLLOWED = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.wordpress.android.ui.bloggingprompts

import org.wordpress.android.models.ReaderTag
import org.wordpress.android.models.ReaderTagType
import org.wordpress.android.ui.reader.services.post.ReaderPostLogic
import org.wordpress.android.ui.reader.repository.ReaderPostRepository
import org.wordpress.android.ui.reader.utils.ReaderUtilsWrapper
import javax.inject.Inject

Expand All @@ -23,7 +23,7 @@ class BloggingPromptsPostTagProvider @Inject constructor(
promptIdTag,
promptIdTag,
promptIdTag,
ReaderPostLogic.formatFullEndpointForTag(promptIdTag),
ReaderPostRepository.formatFullEndpointForTag(promptIdTag),
ReaderTagType.FOLLOWED,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ private fun FetchErrorContent() {
@Composable
private fun NetworkErrorContent() {
EmptyContent(
title = stringResource(R.string.blogging_prompts_list_error_network_title),
subtitle = stringResource(R.string.blogging_prompts_list_error_network_subtitle),
title = stringResource(R.string.no_connection_error_title),
subtitle = stringResource(R.string.no_connection_error_description),
image = R.drawable.img_illustration_cloud_off_152dp,
modifier = Modifier.fillMaxSize(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ public enum DeletablePrefKey implements PrefKey {
SHOULD_HIDE_DYNAMIC_CARD,
PINNED_SITE_IDS,
READER_READING_PREFERENCES_JSON,
SHOULD_SHOW_READER_ANNOUNCEMENT_CARD,
}

/**
Expand Down Expand Up @@ -1784,6 +1785,14 @@ public static void setPinnedSiteLocalIds(@NonNull final String ids) {
setString(DeletablePrefKey.PINNED_SITE_IDS, ids);
}

public static boolean getShouldShowReaderAnnouncementCard() {
return prefs().getBoolean(DeletablePrefKey.SHOULD_SHOW_READER_ANNOUNCEMENT_CARD.name(), true);
}

public static void setShouldShowReaderAnnouncementCard(final boolean shouldShow) {
prefs().edit().putBoolean(DeletablePrefKey.SHOULD_SHOW_READER_ANNOUNCEMENT_CARD.name(), shouldShow).apply();
}

@Nullable
public static String getReaderReadingPreferencesJson() {
return getString(DeletablePrefKey.READER_READING_PREFERENCES_JSON, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,15 @@ class AppPrefsWrapper @Inject constructor(val buildConfigWrapper: BuildConfigWra
fun getShouldHideDynamicCard(id: String, ): Boolean =
AppPrefs.getShouldHideDynamicCard(id)

fun shouldUpdateBookmarkPostsPseudoIds(tag: ReaderTag?): Boolean = AppPrefs.shouldUpdateBookmarkPostsPseudoIds(tag)

fun setBookmarkPostsPseudoIdsUpdated() = AppPrefs.setBookmarkPostsPseudoIdsUpdated()

fun shouldShowReaderAnnouncementCard(): Boolean = AppPrefs.getShouldShowReaderAnnouncementCard()

fun setShouldShowReaderAnnouncementCard(shouldShow: Boolean) =
AppPrefs.setShouldShowReaderAnnouncementCard(shouldShow)

fun getAllPrefs(): Map<String, Any?> = AppPrefs.getAllPrefs()

fun getDebugBooleanPref(key: String, default: Boolean = false) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,19 @@ public static void showReaderTagPreview(Context context, @NonNull ReaderTag tag,
tag.getTagSlug(),
source
);
Intent intent = new Intent(context, ReaderPostListActivity.class);
final Intent intent = createReaderTagPreviewIntent(context, tag, source);
context.startActivity(intent);
}

@NonNull
public static Intent createReaderTagPreviewIntent(@NonNull final Context context,
@NonNull final ReaderTag tag,
@NonNull final String source) {
final Intent intent = new Intent(context, ReaderPostListActivity.class);
intent.putExtra(ReaderConstants.ARG_SOURCE, source);
intent.putExtra(ReaderConstants.ARG_TAG, tag);
intent.putExtra(ReaderConstants.ARG_POST_LIST_TYPE, ReaderPostListType.TAG_PREVIEW);
context.startActivity(intent);
return intent;
}

public static void showReaderSearch(Context context) {
Expand Down
Loading

0 comments on commit b4d6861

Please sign in to comment.