Skip to content

Commit

Permalink
Merge 24.2 code freeze (#20128)
Browse files Browse the repository at this point in the history
  • Loading branch information
mokagio authored Feb 6, 2024
2 parents dd1d1e9 + 69b9894 commit e50edd4
Show file tree
Hide file tree
Showing 20 changed files with 284 additions and 399 deletions.
4 changes: 4 additions & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
*** PLEASE FOLLOW THIS FORMAT: [<priority indicator, more stars = higher priority>] <description> [<PR URL>]

24.3
-----


24.2
-----
* [**] Fix editor crash occurring on large posts [https://github.com/wordpress-mobile/WordPress-Android/pull/20046]
Expand Down
10 changes: 4 additions & 6 deletions WordPress/jetpack_metadata/release_notes.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
- Get notified when you’re working offline.
- Image block uploads pause/resume with internet connection.
- See custom gradient selections in the editor.
- Fixed forward/back arrows for right-to-left readers.
- Daily Prompt tags work properly.
- Tap Site Domain cards to manage domains.
* [**] 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]
6 changes: 2 additions & 4 deletions WordPress/metadata/release_notes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
- Get notified when you’re working offline.
- Image block uploads pause when you lose internet and resume when you reconnect.
- Select a custom gradient in the editor and see a color indicator.
- “Forward” and “back” arrows are correct for right-to-left readers.
* [**] Fix editor crash occurring on large posts [https://github.com/wordpress-mobile/WordPress-Android/pull/20046]
* [**] Prevent images from temporarily disappearing when uploading media [https://github.com/WordPress/gutenberg/pull/57869]
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ enum class QuickStartMySitePrompts constructor(
R.id.root_view_main,
R.id.bottom_nav_reader_button,
R.string.quick_start_dialog_follow_sites_message_short_reader,
R.drawable.ic_reader_white_24dp
R.drawable.ic_reader_selected
),
UPLOAD_SITE_ICON(
QuickStartStore.QUICK_START_UPLOAD_SITE_ICON_LABEL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,13 @@ public static void showReaderSubs(Context context) {
}

public static void showReaderSubs(Context context, int selectPosition) {
Intent intent = new Intent(context, ReaderSubsActivity.class);
context.startActivity(createIntentShowReaderSubs(context, selectPosition));
}

public static Intent createIntentShowReaderSubs(@NonNull final Context context, final int selectPosition) {
final Intent intent = new Intent(context, ReaderSubsActivity.class);
intent.putExtra(ReaderConstants.ARG_SUBS_TAB_POSITION, selectPosition);
context.startActivity(intent);
return intent;
}

public static void showReaderInterests(Activity activity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,8 @@ private ReaderBlogAdapter getBlogAdapter() {
ReaderTracker.SOURCE_SETTINGS
);
mAdapter.setBlogClickListener(this);
mAdapter.setDataLoadedListener(new ReaderInterfaces.DataLoadedListener() {
@Override
public void onDataLoaded(boolean isEmpty) {
checkEmptyView();
}
mAdapter.setDataLoadedListener(isEmpty -> {
checkEmptyView();
});
}
return mAdapter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package org.wordpress.android.ui.reader

import android.os.Bundle
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.core.view.MenuProvider
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
Expand Down Expand Up @@ -48,12 +44,11 @@ import org.wordpress.android.util.SnackbarItem.Action
import org.wordpress.android.util.SnackbarItem.Info
import org.wordpress.android.util.SnackbarSequencer
import org.wordpress.android.viewmodel.observeEvent
import org.wordpress.android.widgets.QuickStartFocusPoint
import java.util.EnumSet
import javax.inject.Inject

@AndroidEntryPoint
class ReaderFragment : Fragment(R.layout.reader_fragment_layout), MenuProvider, ScrollableViewInitializedListener {
class ReaderFragment : Fragment(R.layout.reader_fragment_layout), ScrollableViewInitializedListener {
@Inject
lateinit var viewModelFactory: ViewModelProvider.Factory

Expand All @@ -70,14 +65,9 @@ class ReaderFragment : Fragment(R.layout.reader_fragment_layout), MenuProvider,
lateinit var snackbarSequencer: SnackbarSequencer
private lateinit var viewModel: ReaderViewModel

private var searchMenuItem: MenuItem? = null
private var settingsMenuItem: MenuItem? = null
private var settingsMenuItemFocusPoint: QuickStartFocusPoint? = null

private var binding: ReaderFragmentLayoutBinding? = null

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
requireActivity().addMenuProvider(this, viewLifecycleOwner)
binding = ReaderFragmentLayoutBinding.bind(view).apply {
initTopAppBar()
initViewModel(savedInstanceState)
Expand All @@ -86,9 +76,6 @@ class ReaderFragment : Fragment(R.layout.reader_fragment_layout), MenuProvider,

override fun onDestroyView() {
super.onDestroyView()
searchMenuItem = null
settingsMenuItem = null
settingsMenuItemFocusPoint = null
binding = null
}

Expand All @@ -102,36 +89,6 @@ class ReaderFragment : Fragment(R.layout.reader_fragment_layout), MenuProvider,
activity?.let { viewModel.onScreenInBackground(it.isChangingConfigurations) }
}

override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
menuInflater.inflate(R.menu.reader_home, menu)
menu.findItem(R.id.menu_search).apply {
searchMenuItem = this
this.isVisible = viewModel.uiState.value?.searchMenuItemUiState?.isVisible ?: false
}
menu.findItem(R.id.menu_settings).apply {
settingsMenuItem = this
settingsMenuItemFocusPoint = this.actionView?.findViewById(R.id.menu_quick_start_focus_point)
this.isVisible = viewModel.uiState.value?.settingsMenuItemUiState?.isVisible ?: false
settingsMenuItemFocusPoint?.isVisible =
viewModel.uiState.value?.settingsMenuItemUiState?.showQuickStartFocusPoint ?: false
this.actionView?.setOnClickListener { viewModel.onSettingsActionClicked() }
}
}

override fun onMenuItemSelected(menuItem: MenuItem) = when (menuItem.itemId) {
R.id.menu_search -> {
viewModel.onSearchActionClicked()
true
}

R.id.menu_settings -> {
viewModel.onSettingsActionClicked()
true
}

else -> false
}

private fun ReaderFragmentLayoutBinding.initTopAppBar() {
readerTopBarComposeView.apply {
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
Expand Down Expand Up @@ -171,10 +128,6 @@ class ReaderFragment : Fragment(R.layout.reader_fragment_layout), MenuProvider,
ReaderActivityLauncher.showReaderSearch(context)
}

viewModel.showSettings.observeEvent(viewLifecycleOwner) {
ReaderActivityLauncher.showReaderSubs(context)
}

viewModel.showReaderInterests.observeEvent(viewLifecycleOwner) {
showReaderInterests()
}
Expand Down Expand Up @@ -225,12 +178,6 @@ class ReaderFragment : Fragment(R.layout.reader_fragment_layout), MenuProvider,
initContentContainer(uiState)
}
}
// TODO As part of Reader IA changes this view is going to be replaced
// uiHelpers.updateVisibility(tabLayout, uiState.tabLayoutVisible)
searchMenuItem?.isVisible = uiState.searchMenuItemUiState.isVisible
settingsMenuItem?.isVisible = uiState.settingsMenuItemUiState.isVisible
settingsMenuItemFocusPoint?.isVisible =
viewModel.uiState.value?.settingsMenuItemUiState?.showQuickStartFocusPoint ?: false
}

private fun initContentContainer(uiState: ContentUiState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import android.widget.ProgressBar;
import android.widget.TextView;

import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
Expand Down Expand Up @@ -214,6 +216,7 @@ public class ReaderPostListFragment extends ViewPagerFragment
private int mSearchTabsPos = NO_POSITION;
private boolean mIsFilterableScreen;
private boolean mIsFiltered = false;
private ActivityResultLauncher<Intent> mReaderSubsActivityResultLauncher;
@NonNull private HashSet<UpdateAction> mCurrentUpdateActions = new HashSet<>();
/*
* called by post adapter to load older posts when user scrolls to the last post
Expand Down Expand Up @@ -652,9 +655,11 @@ private void initSubFilterViewModel(@Nullable Bundle savedInstanceState) {
mSubFilterViewModel.getBottomSheetAction().observe(getViewLifecycleOwner(), event -> {
event.applyIfNotHandled(action -> {
if (action instanceof OpenSubsAtPage) {
ReaderActivityLauncher.showReaderSubs(
requireActivity(),
((OpenSubsAtPage) action).getTabIndex()
mReaderSubsActivityResultLauncher.launch(
ReaderActivityLauncher.createIntentShowReaderSubs(
requireActivity(),
((OpenSubsAtPage) action).getTabIndex()
)
);
} else if (action instanceof OpenLoginPage) {
wpMainActivityViewModel.onOpenLoginPage();
Expand Down Expand Up @@ -846,6 +851,25 @@ public void onAttach(@NonNull Context context) {
if (context instanceof BottomNavController) {
mBottomNavController = (BottomNavController) context;
}

initReaderSubsActivityResultLauncher();
}

private void initReaderSubsActivityResultLauncher() {
mReaderSubsActivityResultLauncher = registerForActivityResult(
new ActivityResultContracts.StartActivityForResult(),
result -> {
if (result.getResultCode() == Activity.RESULT_OK) {
final Intent data = result.getData();
if (data != null) {
final boolean shouldRefreshSubscriptions =
data.getBooleanExtra(ReaderSubsActivity.RESULT_SHOULD_REFRESH_SUBSCRIPTIONS, false);
if (shouldRefreshSubscriptions) {
mSubFilterViewModel.loadSubFilters();
}
}
}
});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public class ReaderSubsActivity extends LocaleAwareActivity
public static final int TAB_IDX_FOLLOWED_TAGS = 0;
public static final int TAB_IDX_FOLLOWED_BLOGS = 1;

public static final String RESULT_SHOULD_REFRESH_SUBSCRIPTIONS = "should_refresh_subscriptions";

@Inject AccountStore mAccountStore;
@Inject ReaderTracker mReaderTracker;

Expand All @@ -98,10 +100,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
OnBackPressedCallback callback = new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
if (!TextUtils.isEmpty(mLastAddedTagName)) {
EventBus.getDefault().postSticky(new ReaderEvents.TagAdded(mLastAddedTagName));
}
mReaderTracker.track(Stat.READER_MANAGE_VIEW_DISMISSED);
setResult();
CompatExtensionsKt.onBackPressedCompat(getOnBackPressedDispatcher(), this);
}
};
Expand Down Expand Up @@ -171,6 +171,20 @@ public void onPageSelected(int position) {
mReaderTracker.track(Stat.READER_MANAGE_VIEW_DISPLAYED);
}

private void setResult() {
final Intent data = new Intent();
boolean shouldRefreshSubscriptions = false;
if (mPageAdapter != null) {
final ReaderTagFragment readerTagFragment = mPageAdapter.getReaderTagFragment();
final ReaderBlogFragment readerBlogFragment = mPageAdapter.getReaderBlogFragment();
if (readerTagFragment != null && readerBlogFragment != null) {
shouldRefreshSubscriptions = readerTagFragment.hasChangedSelectedTags();
}
}
data.putExtra(RESULT_SHOULD_REFRESH_SUBSCRIPTIONS, shouldRefreshSubscriptions);
setResult(RESULT_OK, data);
}

@Override
protected void onPause() {
EventBus.getDefault().unregister(this);
Expand Down Expand Up @@ -564,12 +578,30 @@ public Object instantiateItem(ViewGroup container, int position) {
}

private void refreshFollowedTagFragment() {
for (Fragment fragment : mFragments) {
final ReaderTagFragment fragment = getReaderTagFragment();
if (fragment != null) {
fragment.refresh();
}
}

@Nullable
private ReaderTagFragment getReaderTagFragment() {
for (final Fragment fragment : mFragments) {
if (fragment instanceof ReaderTagFragment) {
ReaderTagFragment tagFragment = (ReaderTagFragment) fragment;
tagFragment.refresh();
return (ReaderTagFragment) fragment;
}
}
return null;
}

@Nullable
private ReaderBlogFragment getReaderBlogFragment() {
for (final Fragment fragment : mFragments) {
if (fragment instanceof ReaderBlogFragment) {
return (ReaderBlogFragment) fragment;
}
}
return null;
}

private void refreshBlogFragments(ReaderBlogType blogType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,27 @@

import org.wordpress.android.R;
import org.wordpress.android.models.ReaderTag;
import org.wordpress.android.models.ReaderTagList;
import org.wordpress.android.ui.ActionableEmptyView;
import org.wordpress.android.ui.reader.adapters.ReaderTagAdapter;
import org.wordpress.android.ui.reader.views.ReaderRecyclerView;
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.WPActivityUtils;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/*
* fragment hosted by ReaderSubsActivity which shows followed tags
*/
public class ReaderTagFragment extends Fragment implements ReaderTagAdapter.TagDeletedListener {
private ReaderRecyclerView mRecyclerView;
private ReaderTagAdapter mTagAdapter;

private boolean mIsFirstDataLoaded;
private final ReaderTagList mInitialReaderTagList = new ReaderTagList();

static ReaderTagFragment newInstance() {
AppLog.d(AppLog.T.READER, "reader tag list > newInstance");
return new ReaderTagFragment();
Expand All @@ -36,6 +44,21 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
return view;
}

public boolean hasChangedSelectedTags() {
final Set<String> initialTagsSlugs = new HashSet<>();
for (final ReaderTag readerTag : mInitialReaderTagList) {
initialTagsSlugs.add(readerTag.getTagSlug());
}
final List<ReaderTag> currentReaderTagList = getTagAdapter().getItems();
final Set<String> currentTagsSlugs = new HashSet<>();
if (currentReaderTagList != null) {
for (final ReaderTag readerTag : currentReaderTagList) {
currentTagsSlugs.add(readerTag.getTagSlug());
}
}
return !(initialTagsSlugs.equals(currentTagsSlugs));
}

private void checkEmptyView() {
if (!isAdded() || getView() == null) {
return;
Expand All @@ -62,6 +85,12 @@ public void onActivityCreated(Bundle savedInstanceState) {
refresh();
}

@Override
public void onAttach(Context context) {
super.onAttach(context);
mIsFirstDataLoaded = true;
}

void refresh() {
if (hasTagAdapter()) {
AppLog.d(AppLog.T.READER, "reader subs > refreshing tag fragment");
Expand All @@ -74,10 +103,14 @@ private ReaderTagAdapter getTagAdapter() {
Context context = WPActivityUtils.getThemedContext(getActivity());
mTagAdapter = new ReaderTagAdapter(context);
mTagAdapter.setTagDeletedListener(this);
mTagAdapter.setDataLoadedListener(new ReaderInterfaces.DataLoadedListener() {
@Override
public void onDataLoaded(boolean isEmpty) {
checkEmptyView();
mTagAdapter.setDataLoadedListener(isEmpty -> {
checkEmptyView();
if (mIsFirstDataLoaded) {
mIsFirstDataLoaded = false;
mInitialReaderTagList.clear();
if (mTagAdapter != null && mTagAdapter.getItems() != null) {
mInitialReaderTagList.addAll(mTagAdapter.getItems());
}
}
});
}
Expand Down
Loading

0 comments on commit e50edd4

Please sign in to comment.