Skip to content

Commit

Permalink
Merge pull request #20947 from wordpress-mobile/issue/19261-reader-re…
Browse files Browse the repository at this point in the history
…move-unused-files

[Reader] Remove improvements FF and unused UI files
  • Loading branch information
nbradbury authored Aug 28, 2024
2 parents 5f0bc7d + 5726d0d commit 9ee898d
Show file tree
Hide file tree
Showing 59 changed files with 621 additions and 3,001 deletions.
1 change: 0 additions & 1 deletion WordPress/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ android {
buildConfigField "boolean", "CONTACT_SUPPORT_CHATBOT", "false"
buildConfigField "boolean", "ENABLE_DOMAIN_MANAGEMENT_FEATURE", "false"
buildConfigField "boolean", "PLANS_IN_SITE_CREATION", "false"
buildConfigField "boolean", "READER_IMPROVEMENTS", "false"
buildConfigField "boolean", "BLOGANUARY_DASHBOARD_NUDGE", "false"
buildConfigField "boolean", "DYNAMIC_DASHBOARD_CARDS", "false"
buildConfigField "boolean", "STATS_TRAFFIC_SUBSCRIBERS_TABS", "false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.appbar.CollapsingToolbarLayout
import com.google.android.material.behavior.HideBottomViewOnScrollBehavior
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.elevation.ElevationOverlayProvider
import com.google.android.material.snackbar.Snackbar
import dagger.hilt.android.AndroidEntryPoint
import org.greenrobot.eventbus.EventBus
Expand All @@ -64,7 +63,6 @@ import org.wordpress.android.WordPress
import org.wordpress.android.analytics.AnalyticsTracker
import org.wordpress.android.databinding.ReaderFragmentPostDetailBinding
import org.wordpress.android.databinding.ReaderIncludePostDetailFooterBinding
import org.wordpress.android.databinding.ReaderIncludePostDetailFooterNewBinding
import org.wordpress.android.datasets.ReaderPostTable
import org.wordpress.android.fluxc.Dispatcher
import org.wordpress.android.fluxc.generated.SiteActionBuilder
Expand Down Expand Up @@ -145,7 +143,6 @@ import org.wordpress.android.util.WPPermissionUtils.READER_FILE_DOWNLOAD_PERMISS
import org.wordpress.android.util.WPSwipeToRefreshHelper.buildSwipeToRefreshHelper
import org.wordpress.android.util.config.CommentsSnippetFeatureConfig
import org.wordpress.android.util.config.LikesEnhancementsFeatureConfig
import org.wordpress.android.util.config.ReaderImprovementsFeatureConfig
import org.wordpress.android.util.config.ReaderReadingPreferencesFeatureConfig
import org.wordpress.android.util.extensions.getColorFromAttribute
import org.wordpress.android.util.extensions.getParcelableCompat
Expand Down Expand Up @@ -283,9 +280,6 @@ class ReaderPostDetailFragment : ViewPagerFragment(),
@Inject
lateinit var jetpackBrandingUtils: JetpackBrandingUtils

@Inject
lateinit var readerImprovementsFeatureConfig: ReaderImprovementsFeatureConfig

@Inject
lateinit var readingPreferencesFeatureConfig: ReaderReadingPreferencesFeatureConfig

Expand Down Expand Up @@ -484,31 +478,15 @@ class ReaderPostDetailFragment : ViewPagerFragment(),
}

private fun initLayoutFooter(view: View) {
val isReaderImprovementsEnabled = readerImprovementsFeatureConfig.isEnabled()
view.findViewById<ViewStub>(R.id.layout_post_detail_footer).apply {
layoutResource = if (isReaderImprovementsEnabled) {
R.layout.reader_include_post_detail_footer_new
} else {
R.layout.reader_include_post_detail_footer
}
layoutResource = R.layout.reader_include_post_detail_footer

setOnInflateListener { _, inflated ->
layoutFooterBinding = if (isReaderImprovementsEnabled) {
ReaderIncludePostDetailFooterNewBinding.bind(inflated).mapBinding().apply {
layoutFooterBinding = ReaderIncludePostDetailFooterBinding.bind(inflated).mapBinding().apply {
// the new bar should hide on scroll
val params = root.layoutParams as CoordinatorLayout.LayoutParams
params.behavior = HideBottomViewOnScrollBehavior<View>()
}
} else {
ReaderIncludePostDetailFooterBinding.bind(inflated).mapBinding().apply {
// the old bar should have the elevated surface color background
val elevationOverlayProvider = ElevationOverlayProvider(root.context)
val appbarElevation = resources.getDimension(R.dimen.appbar_elevation)
val elevatedSurfaceColor = elevationOverlayProvider
.compositeOverlayWithThemeSurfaceColorIfNeeded(appbarElevation)
root.setBackgroundColor(elevatedSurfaceColor)
}
}
layoutFooterBinding.root.isInvisible = true
}
}.also { stub ->
Expand Down Expand Up @@ -1891,15 +1869,6 @@ class ReaderPostDetailFragment : ViewPagerFragment(),
)

private fun ReaderIncludePostDetailFooterBinding.mapBinding(): PostDetailFooterBarBinding =
PostDetailFooterBarBinding(
root,
bookmark,
reblog,
countComments,
countLikes,
)

private fun ReaderIncludePostDetailFooterNewBinding.mapBinding(): PostDetailFooterBarBinding =
PostDetailFooterBarBinding(
root,
bookmark,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@
import org.wordpress.android.util.StringUtils;
import org.wordpress.android.util.ToastUtils;
import org.wordpress.android.util.WPActivityUtils;
import org.wordpress.android.util.config.ReaderImprovementsFeatureConfig;
import org.wordpress.android.util.config.SeenUnseenWithCounterFeatureConfig;
import org.wordpress.android.util.image.ImageManager;
import org.wordpress.android.widgets.AppReviewManager;
Expand Down Expand Up @@ -186,7 +185,6 @@ public class ReaderPostListFragment extends ViewPagerFragment
@Inject ReaderTracker mReaderTracker;
@Inject SnackbarSequencer mSnackbarSequencer;
@Inject DisplayUtilsWrapper mDisplayUtilsWrapper;
@Inject ReaderImprovementsFeatureConfig mReaderImprovementsFeatureConfig;
private ReaderPostAdapter mPostAdapter;
private ReaderSiteSearchAdapter mSiteSearchAdapter;
private ReaderSearchSuggestionAdapter mSearchSuggestionAdapter;
Expand Down Expand Up @@ -1067,27 +1065,20 @@ public void onShowCustomEmptyView(EmptyViewMessageType emptyViewMsgType) {
}
});

// set the background color as we have different colors for the new and legacy designs that are not easy to
// change via styles, because of the FeatureConfig logic
int backgroundColor = mReaderImprovementsFeatureConfig.isEnabled()
? R.color.reader_post_list_background_new
: R.color.reader_post_list_background;
mRecyclerView.setBackgroundColor(ContextCompat.getColor(requireContext(), backgroundColor));
mRecyclerView.setBackgroundColor(ContextCompat.getColor(
requireContext(), R.color.reader_post_list_background)
);

// add the item decoration (dividers) to the recycler, skipping the first item if the first
// item is the tag toolbar (shown when viewing posts in followed tags) - this is to avoid
// having the tag toolbar take up more vertical space than necessary
int spacingVerticalRes = mReaderImprovementsFeatureConfig.isEnabled()
? R.dimen.reader_card_gutters_new
: R.dimen.reader_card_gutters;
int spacingVerticalRes = R.dimen.reader_card_gutters;
int spacingHorizontal = getResources().getDimensionPixelSize(R.dimen.reader_card_margin);
int spacingVertical = getResources().getDimensionPixelSize(spacingVerticalRes);
mRecyclerView.addItemDecoration(new RecyclerItemDecoration(spacingHorizontal, spacingVertical, false));

// add a proper item divider to the RecyclerView when Reader Improvements are enabled
if (mReaderImprovementsFeatureConfig.isEnabled()) {
mRecyclerView.addItemDivider(R.drawable.default_list_divider);
}
// add a proper item divider to the RecyclerView
mRecyclerView.addItemDivider(R.drawable.default_list_divider);

mRecyclerView.setToolbarBackgroundColor(0);
mRecyclerView.setToolbarSpinnerDrawable(R.drawable.ic_dropdown_primary_30_24dp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@
import org.wordpress.android.ui.reader.actions.ReaderActions;
import org.wordpress.android.ui.reader.actions.ReaderTagActions;
import org.wordpress.android.ui.reader.discover.ReaderCardUiState;
import org.wordpress.android.ui.reader.discover.ReaderCardUiState.ReaderPostNewUiState;
import org.wordpress.android.ui.reader.discover.ReaderCardUiState.ReaderPostUiState;
import org.wordpress.android.ui.reader.discover.ReaderPostCardActionType;
import org.wordpress.android.ui.reader.discover.ReaderPostMoreButtonUiStateBuilder;
import org.wordpress.android.ui.reader.discover.ReaderPostUiStateBuilder;
import org.wordpress.android.ui.reader.discover.viewholders.ReaderPostNewViewHolder;
import org.wordpress.android.ui.reader.discover.viewholders.ReaderPostViewHolder;
import org.wordpress.android.ui.reader.models.ReaderBlogIdPostId;
import org.wordpress.android.ui.reader.utils.ReaderAnnouncementHelper;
import org.wordpress.android.ui.reader.tracker.ReaderTab;
Expand All @@ -68,7 +66,6 @@
import org.wordpress.android.util.NetworkUtilsWrapper;
import org.wordpress.android.util.SiteUtils;
import org.wordpress.android.util.ToastUtils;
import org.wordpress.android.util.config.ReaderImprovementsFeatureConfig;
import org.wordpress.android.util.extensions.ContextExtensionsKt;
import org.wordpress.android.util.image.BlavatarShape;
import org.wordpress.android.util.image.ImageManager;
Expand Down Expand Up @@ -136,7 +133,6 @@ public class ReaderPostAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
@Inject ReaderPostUiStateBuilder mReaderPostUiStateBuilder;
@Inject ReaderPostMoreButtonUiStateBuilder mReaderPostMoreButtonUiStateBuilder;
@Inject ReaderTracker mReaderTracker;
@Inject ReaderImprovementsFeatureConfig mReaderImprovementsFeatureConfig;
@Inject ReaderAnnouncementHelper mReaderAnnouncementHelper;

public String getSource() {
Expand Down Expand Up @@ -279,28 +275,23 @@ public int getItemViewType(int position) {
return new GapMarkerViewHolder(new ReaderGapMarkerView(context));

case VIEW_TYPE_XPOST:
final int layoutRestId = mReaderImprovementsFeatureConfig.isEnabled()
? R.layout.reader_cardview_xpost_new : R.layout.reader_cardview_xpost;
postView = LayoutInflater.from(context).inflate(layoutRestId, parent, false);
postView = LayoutInflater.from(context).inflate(R.layout.reader_cardview_xpost, parent, false);
return new ReaderXPostViewHolder(postView);
case VIEW_TYPE_REMOVED_POST:
final int layoutResId = mReaderImprovementsFeatureConfig.isEnabled()
? R.layout.reader_cardview_removed_post_new : R.layout.reader_cardview_removed_post;
postView = LayoutInflater.from(context).inflate(layoutResId, parent, false);
postView = LayoutInflater.from(context).inflate(
R.layout.reader_cardview_removed_post, parent, false
);
return new ReaderRemovedPostViewHolder(postView);
default:
return mReaderImprovementsFeatureConfig.isEnabled()
? new ReaderPostNewViewHolder(mUiHelpers, mImageManager, mReaderTracker, mNetworkUtilsWrapper,
parent)
: new ReaderPostViewHolder(mUiHelpers, mImageManager, mReaderTracker, parent);
return new ReaderPostNewViewHolder(
mUiHelpers, mImageManager, mReaderTracker, mNetworkUtilsWrapper, parent
);
}
}

@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof ReaderPostViewHolder) {
renderPost(position, (ReaderPostViewHolder) holder, false);
} else if (holder instanceof ReaderPostNewViewHolder) {
if (holder instanceof ReaderPostNewViewHolder) {
renderPostNew(position, (ReaderPostNewViewHolder) holder, false);
} else if (holder instanceof ReaderXPostViewHolder) {
renderXPost(position, (ReaderXPostViewHolder) holder);
Expand Down Expand Up @@ -459,116 +450,6 @@ private void undoPostUnbookmarked(final ReaderPost post) {
}
}

private void renderPost(final int position, final ReaderPostViewHolder holder, boolean showMoreMenu) {
final ReaderPost post = getItem(position);
ReaderPostListType postListType = getPostListType();
if (post == null) {
return;
}
Context ctx = holder.getViewContext();
Function3<Long, Long, ReaderPostCardActionType, Unit> onButtonClicked =
(postId, blogId, type) -> {
mOnPostListItemButtonListener.onButtonClicked(post, type);
renderPost(position, holder, false);
return Unit.INSTANCE;
};
Function2<Long, Long, Unit> onItemClicked = (postId, blogId) -> {
if (mPostSelectedListener != null) {
mPostSelectedListener.onPostSelected(post);
}
return Unit.INSTANCE;
};
Function1<ReaderCardUiState, Unit> onItemRendered = (item) -> {
checkLoadMore(position);

// if we haven't already rendered this post and it has a "railcar" attached to it, add it
// to the rendered list and record the TrainTracks render event
if (post.hasRailcar() && !mRenderedIds.contains(post.getPseudoId())) {
mRenderedIds.add(post.getPseudoId());
mReaderTracker.trackRailcar(post.getRailcarJson());
}
return Unit.INSTANCE;
};
Function2<Long, Long, Unit> onDiscoverSectionClicked = (postId, blogId) -> {
ReaderPostDiscoverData discoverData = post.getDiscoverData();
switch (discoverData.getDiscoverType()) {
case EDITOR_PICK:
if (mPostSelectedListener != null) {
mPostSelectedListener.onPostSelected(post);
}
break;
case SITE_PICK:
if (discoverData.getBlogId() != 0) {
ReaderActivityLauncher.showReaderBlogPreview(
ctx,
discoverData.getBlogId(),
post.isFollowedByCurrentUser,
mSource,
mReaderTracker
);
} else if (discoverData.hasBlogUrl()) {
ReaderActivityLauncher.openUrl(ctx, discoverData.getBlogUrl());
}
break;
case OTHER:
// noop
break;
}
return Unit.INSTANCE;
};
Function1<ReaderPostUiState, Unit> onMoreButtonClicked = (uiState) -> {
renderPost(position, holder, true);
return Unit.INSTANCE;
};

Function1<ReaderPostUiState, Unit> onMoreDismissed = (uiState) -> {
renderPost(position, holder, false);
return Unit.INSTANCE;
};

Function2<Long, Long, Unit> onVideoOverlayClicked = (postId, blogId) -> {
ReaderActivityLauncher.showReaderVideoViewer(ctx, post.getFeaturedVideo());
return Unit.INSTANCE;
};

Function0<Unit> onPostHeaderClicked = () -> {
ReaderActivityLauncher.showReaderBlogPreview(
ctx,
post,
mSource,
mReaderTracker
);
return Unit.INSTANCE;
};

Function1<String, Unit> onTagItemClicked = (tagSlug) -> {
// noop
return Unit.INSTANCE;
};

ReaderPostUiState uiState = mReaderPostUiStateBuilder
.mapPostToUiStateBlocking(
mSource,
post,
false,
mPhotonWidth,
mPhotonHeight,
postListType,
onButtonClicked,
onItemClicked,
onItemRendered,
onDiscoverSectionClicked,
onMoreButtonClicked,
onMoreDismissed,
onVideoOverlayClicked,
onPostHeaderClicked,
onTagItemClicked,
showMoreMenu ? mReaderPostMoreButtonUiStateBuilder
.buildMoreMenuItemsBlocking(post, false, false, onButtonClicked) : null
);
holder.onBind(uiState);
}

// TODO update the viewholder to the new one
private void renderPostNew(final int position, final ReaderPostNewViewHolder holder, boolean showMoreMenu) {
final ReaderPost post = getItem(position);
Expand Down Expand Up @@ -626,12 +507,12 @@ private void renderPostNew(final int position, final ReaderPostNewViewHolder hol
}
return Unit.INSTANCE;
};
Function1<ReaderPostNewUiState, Unit> onMoreButtonClicked = (uiState) -> {
Function1<ReaderPostUiState, Unit> onMoreButtonClicked = (uiState) -> {
renderPostNew(position, holder, true);
return Unit.INSTANCE;
};

Function1<ReaderPostNewUiState, Unit> onMoreDismissed = (uiState) -> {
Function1<ReaderPostUiState, Unit> onMoreDismissed = (uiState) -> {
renderPostNew(position, holder, false);
return Unit.INSTANCE;
};
Expand All @@ -651,8 +532,8 @@ private void renderPostNew(final int position, final ReaderPostNewViewHolder hol
return Unit.INSTANCE;
};

ReaderPostNewUiState uiState = mReaderPostUiStateBuilder
.mapPostToNewUiStateBlocking(
ReaderPostUiState uiState = mReaderPostUiStateBuilder
.mapPostToUiStateBlocking(
mSource,
post,
mPhotonWidth,
Expand Down
Loading

0 comments on commit 9ee898d

Please sign in to comment.