Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 24.6-rc-2 to trunk #20610

Merged
merged 28 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
28b7538
Add accessibility to feedback request paragraph
Apr 2, 2024
7e32acf
Match tags accessibility with Reader Details experience
Apr 2, 2024
c355742
Improve Scheme and Font buttons accessibility
Apr 2, 2024
9a1bd49
Fix accessibility for Font Size slider
Apr 2, 2024
4b1237a
Fix UnknownFormatConversionException on Account Settings screen
irfano Apr 3, 2024
450d44f
Fix UnknownFormatConversionException on Site Settings screen
irfano Apr 3, 2024
73ca0bc
Fix UnknownFormatConversionException on setting default category
irfano Apr 4, 2024
2ff2002
Merge pull request #20574 from wordpress-mobile/feature/reader-custom…
Apr 4, 2024
23b7043
Create ReaderReadingPreferencesTracker
Apr 4, 2024
b74f21b
Add unit tests for ReadingPreferencesTracker
Apr 4, 2024
9b0cdf4
Track analytics events for Reading Preferences
Apr 4, 2024
6283836
Add unit tests for Reading Preferences tracking
Apr 4, 2024
6f6bce6
Cache reading preferences in repository for better multiple-call perf…
Apr 4, 2024
5ee56aa
Add reading preferences properties to reader_article_opened
Apr 4, 2024
97a55b9
Add more reading preferences track related unit tests
Apr 4, 2024
f255597
Add experimental badge
Apr 4, 2024
457aed4
Merge pull request #20592 from wordpress-mobile/issue/20582-fix-unkno…
ravishanker Apr 5, 2024
9e5f733
Text-only experimental badge in Reading Preferences screen
Apr 5, 2024
5c7af50
Merge pull request #20599 from wordpress-mobile/feature/reader-custom…
Apr 5, 2024
c24c155
Make Reading Preferences Feature Config remote
Apr 1, 2024
b034305
Add release notes for Reading Preferences
Apr 5, 2024
d74a6f5
Change font family of badge according to selection
Apr 5, 2024
a22d98c
Merge pull request #20567 from wordpress-mobile/feature/reader-custom…
RenanLukas Apr 5, 2024
eca806c
Merge pull request #20604 from wordpress-mobile/feature/reader-custom…
Apr 8, 2024
c05ca18
Freeze strings for translation
wpmobilebot Apr 8, 2024
f2460d2
Update translations
wpmobilebot Apr 8, 2024
469cd3a
Bump version number
wpmobilebot Apr 8, 2024
3ecff4b
Merge pull request #20609 from wordpress-mobile/new_beta/24.6-rc-2
oguzkocer Apr 8, 2024
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
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* [**] Block editor: Highlight text fixes [https://github.com/WordPress/gutenberg/pull/57650]
* [*] Block editor: Fixes an Aztec editor crash occurring on some occasions when the keyboard suggestions are used [https://github.com/wordpress-mobile/WordPress-Android/pull/20518]
* [*] [Jetpack-only] Change "∞" symbol with "100%" on stats [https://github.com/wordpress-mobile/WordPress-Android/pull/20564]
* [**] [Jetpack-only] Reader: introduce "reading preferences", an experimental feature that allows users to customize their Reader post content screen with the color, font, and size that they like the most. [https://github.com/wordpress-mobile/WordPress-Android/pull/20567]

24.5
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
mSiteSettings.setDefaultCategory(Integer.parseInt(newValue.toString()));
setDetailListPreferenceValue(mCategoryPref,
newValue.toString(),
mSiteSettings.getDefaultCategoryForDisplay());
mSiteSettings.getDefaultCategoryForDisplay().replace("%", "%%"));
} else if (preference == mFormatPref) {
mSiteSettings.setDefaultFormat(newValue.toString());
setDetailListPreferenceValue(mFormatPref,
Expand Down Expand Up @@ -1652,7 +1652,7 @@ private void setCategories() {
mCategoryPref.setEntries(entries);
mCategoryPref.setEntryValues(values);
mCategoryPref.setValue(String.valueOf(mSiteSettings.getDefaultCategory()));
mCategoryPref.setSummary(mSiteSettings.getDefaultCategoryForDisplay());
mCategoryPref.setSummary(mSiteSettings.getDefaultCategoryForDisplay().replace("%", "%%"));
}

private void setPostFormats() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class AccountSettingsFragment : PreferenceFragmentLifeCycleOwner(),
primarySiteSettingsUiState?.let { state ->
primarySitePreference.apply {
value = (state.primarySite?.siteId ?: "").toString()
summary = state.primarySite?.siteName
summary = state.primarySite?.siteName?.replace("%", "%%")
entries = state.siteNames
entryValues = state.siteIds
canShowDialog = state.canShowChoosePrimarySiteDialog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ import org.wordpress.android.ui.reader.discover.ReaderPostCardAction.PrimaryActi
import org.wordpress.android.ui.reader.discover.ReaderPostCardActionType
import org.wordpress.android.ui.reader.models.ReaderBlogIdPostId
import org.wordpress.android.ui.reader.models.ReaderReadingPreferences
import org.wordpress.android.ui.reader.tracker.ReaderReadingPreferencesTracker
import org.wordpress.android.ui.reader.tracker.ReaderTracker
import org.wordpress.android.ui.reader.tracker.ReaderTracker.Companion.SOURCE_POST_DETAIL_TOOLBAR
import org.wordpress.android.ui.reader.usecases.ReaderGetReadingPreferencesSyncUseCase
Expand Down Expand Up @@ -950,7 +951,10 @@ class ReaderPostDetailFragment : ViewPagerFragment(),
}

ReaderNavigationEvents.ShowReadingPreferences ->
ReaderReadingPreferencesDialogFragment.show(childFragmentManager)
ReaderReadingPreferencesDialogFragment.show(
childFragmentManager,
ReaderReadingPreferencesTracker.Source.POST_DETAIL_MORE_MENU,
)

is ReaderNavigationEvents.ShowPostDetail,
is ReaderNavigationEvents.ShowVideoViewer,
Expand Down Expand Up @@ -1128,7 +1132,10 @@ class ReaderPostDetailFragment : ViewPagerFragment(),
true
}
R.id.menu_reading_preferences -> {
ReaderReadingPreferencesDialogFragment.show(childFragmentManager)
ReaderReadingPreferencesDialogFragment.show(
childFragmentManager,
ReaderReadingPreferencesTracker.Source.POST_DETAIL_TOOLBAR,
)
true
}
else -> false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import org.wordpress.android.ui.reader.services.post.ReaderPostServiceStarter;
import org.wordpress.android.ui.reader.tracker.ReaderTracker;
import org.wordpress.android.ui.reader.tracker.ReaderTrackerType;
import org.wordpress.android.ui.reader.usecases.ReaderGetReadingPreferencesSyncUseCase;
import org.wordpress.android.ui.reader.utils.ReaderPostSeenStatusWrapper;
import org.wordpress.android.ui.sitecreation.misc.SiteCreationSource;
import org.wordpress.android.ui.uploads.UploadActionUseCase;
Expand Down Expand Up @@ -176,6 +177,7 @@ public enum DirectOperation {
private JetpackFeatureFullScreenOverlayViewModel mJetpackFullScreenViewModel;
@Inject AccountStore mAccountStore;
@Inject JetpackFeatureRemovalPhaseHelper mJetpackFeatureRemovalPhaseHelper;
@Inject ReaderGetReadingPreferencesSyncUseCase mGetReadingPreferencesSyncUseCase;

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
Expand Down Expand Up @@ -766,7 +768,8 @@ private void trackPost(long blogId, long postId) {
// analytics tracking
mReaderTracker.trackPost(
AnalyticsTracker.Stat.READER_ARTICLE_OPENED,
mReaderPostTableWrapper.getBlogPost(blogId, postId, true)
mReaderPostTableWrapper.getBlogPost(blogId, postId, true),
mGetReadingPreferencesSyncUseCase.invoke()
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.wordpress.android.ui.reader

import android.app.Dialog
import android.content.DialogInterface
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
Expand All @@ -22,11 +23,13 @@ import org.wordpress.android.R
import org.wordpress.android.ui.WPWebViewActivity
import org.wordpress.android.ui.compose.theme.AppTheme
import org.wordpress.android.ui.reader.models.ReaderReadingPreferences
import org.wordpress.android.ui.reader.tracker.ReaderReadingPreferencesTracker
import org.wordpress.android.ui.reader.viewmodels.ReaderPostDetailViewModel
import org.wordpress.android.ui.reader.viewmodels.ReaderReadingPreferencesViewModel
import org.wordpress.android.ui.reader.viewmodels.ReaderReadingPreferencesViewModel.ActionEvent
import org.wordpress.android.ui.reader.views.compose.readingpreferences.ReadingPreferencesScreen
import org.wordpress.android.util.extensions.fillScreen
import org.wordpress.android.util.extensions.getSerializableCompat
import org.wordpress.android.util.extensions.setWindowStatusBarColor

@AndroidEntryPoint
Expand All @@ -40,6 +43,13 @@ class ReaderReadingPreferencesDialogFragment : BottomSheetDialogFragment() {
return R.style.ReaderReadingPreferencesDialogFragment
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.getSerializableCompat<ReaderReadingPreferencesTracker.Source>(ARG_SOURCE)?.let {
viewModel.onScreenOpened(it)
}
}

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
Expand Down Expand Up @@ -78,6 +88,11 @@ class ReaderReadingPreferencesDialogFragment : BottomSheetDialogFragment() {
}
}

override fun onDismiss(dialog: DialogInterface) {
super.onDismiss(dialog)
viewModel.onScreenClosed()
}

private fun observeActionEvents() {
viewModel.actionEvents.onEach {
when (it) {
Expand Down Expand Up @@ -106,13 +121,23 @@ class ReaderReadingPreferencesDialogFragment : BottomSheetDialogFragment() {
}

companion object {
const val TAG = "READER_READING_PREFERENCES_FRAGMENT"
private const val TAG = "READER_READING_PREFERENCES_FRAGMENT"
private const val ARG_SOURCE = "source"

@JvmStatic
fun newInstance(): ReaderReadingPreferencesDialogFragment = ReaderReadingPreferencesDialogFragment()
fun newInstance(
source: ReaderReadingPreferencesTracker.Source,
): ReaderReadingPreferencesDialogFragment = ReaderReadingPreferencesDialogFragment().apply {
arguments = Bundle().apply {
putSerializable(ARG_SOURCE, source)
}
}

@JvmStatic
fun show(fm: FragmentManager): ReaderReadingPreferencesDialogFragment = newInstance().also {
fun show(
fm: FragmentManager,
source: ReaderReadingPreferencesTracker.Source,
): ReaderReadingPreferencesDialogFragment = newInstance(source).also {
it.show(fm, TAG)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ class ReaderPostCardActionsHandler @Inject constructor(
}

private fun handleReadingPreferencesClicked() {
// TODO add analytics readerTracker.track(AnalyticsTracker.Stat.READER_READING_PREFERENCES_OPENED)
_navigationEvents.postValue(Event(ShowReadingPreferences))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import java.util.Locale
import com.google.android.material.R as MaterialR

data class ReaderReadingPreferences @JvmOverloads constructor(
val theme: Theme = Theme.SYSTEM,
val fontFamily: FontFamily = FontFamily.SANS,
val theme: Theme = Theme.DEFAULT,
val fontFamily: FontFamily = FontFamily.DEFAULT,
val fontSize: FontSize = FontSize.DEFAULT,
) {
enum class Theme(
Expand Down Expand Up @@ -74,7 +74,11 @@ data class ReaderReadingPreferences @JvmOverloads constructor(
backgroundColorRes = R.color.reader_theme_candy_background,
baseTextColorRes = R.color.reader_theme_candy_text,
linkColorRes = R.color.reader_theme_candy_text,
),
);

companion object {
val DEFAULT = SYSTEM
}
}

@Suppress("MagicNumber")
Expand Down Expand Up @@ -165,17 +169,39 @@ data class ReaderReadingPreferences @JvmOverloads constructor(
MONO(
displayNameRes = R.string.reader_preferences_font_family_mono,
value = "monospace",
),
);

companion object {
val DEFAULT = SANS
}
}

enum class FontSize(val value: Int) {
EXTRA_SMALL(10),
SMALL(12),
enum class FontSize(
@StringRes val displayNameRes: Int,
val value: Int,
) {
EXTRA_SMALL(
displayNameRes = R.string.reader_preferences_font_size_extra_small,
value = 10,
),
SMALL(
displayNameRes = R.string.reader_preferences_font_size_small,
value = 12,
),

@FallbackValue
NORMAL(16),
LARGE(20),
EXTRA_LARGE(24);
NORMAL(
displayNameRes = R.string.reader_preferences_font_size_normal,
value = 16,
),
LARGE(
displayNameRes = R.string.reader_preferences_font_size_large,
value = 20,
),
EXTRA_LARGE(
displayNameRes = R.string.reader_preferences_font_size_extra_large,
value = 24,
);

val multiplier: Float
get() = value / DEFAULT.value.toFloat()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import org.wordpress.android.util.EnumWithFallbackValueTypeAdapterFactory
import org.wordpress.android.util.config.ReaderReadingPreferencesFeatureConfig
import javax.inject.Inject
import javax.inject.Named
import javax.inject.Singleton

@Singleton
class ReaderReadingPreferencesRepository @Inject constructor(
private val appPrefsWrapper: AppPrefsWrapper,
private val readingPreferencesFeatureConfig: ReaderReadingPreferencesFeatureConfig,
Expand All @@ -20,23 +22,31 @@ class ReaderReadingPreferencesRepository @Inject constructor(
.registerTypeAdapterFactory(EnumWithFallbackValueTypeAdapterFactory())
.create()

// the preferences never change during the app lifecycle, so we can cache them safely for better performance
private var readingPreferences: ReaderReadingPreferences? = null

suspend fun getReadingPreferences(): ReaderReadingPreferences = withContext(ioDispatcher) {
getReadingPreferencesSync()
}

fun getReadingPreferencesSync(): ReaderReadingPreferences {
val savedPreferences = if (readingPreferencesFeatureConfig.isEnabled()) {
appPrefsWrapper.readerReadingPreferencesJson
} else {
null
if (!readingPreferencesFeatureConfig.isEnabled()) {
return ReaderReadingPreferences()
}

return savedPreferences?.let {
gson.fromJson(it, ReaderReadingPreferences::class.java)
} ?: ReaderReadingPreferences()
return readingPreferences ?: loadReadingPreferences().also {
readingPreferences = it
}
}

suspend fun saveReadingPreferences(preferences: ReaderReadingPreferences): Unit = withContext(ioDispatcher) {
appPrefsWrapper.readerReadingPreferencesJson = gson.toJson(preferences)
readingPreferences = preferences
}

private fun loadReadingPreferences(): ReaderReadingPreferences {
return appPrefsWrapper.readerReadingPreferencesJson?.let {
gson.fromJson(it, ReaderReadingPreferences::class.java)
} ?: ReaderReadingPreferences()
}
}
Loading
Loading