Skip to content

Commit

Permalink
Merge branch 'feature/android15' into issue/21596-android-15-compile
Browse files Browse the repository at this point in the history
  • Loading branch information
nbradbury authored Jan 20, 2025
2 parents 744b6d1 + 94fd5f6 commit 25d1b32
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 100 deletions.
17 changes: 9 additions & 8 deletions WordPress/jetpack_metadata/PlayStoreStrings.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ msgstr ""
"X-Generator: VsCode\n"
"Project-Id-Version: Jetpack - Apps - Android - Release Notes\n"

msgctxt "release_note_256"
msgid ""
"25.6:\n"
"This update:\n"
"- Fixes a rare crash when registering a domain.\n"
"- Fixes a bunch of under-the-hood things that should make the app more reliable.\n"
"- Uses a web-based approach for WordPress.com login. This should be more reliable for most users, but please contact support if you have any trouble!\n"
msgstr ""

msgctxt "release_note_255"
msgid ""
"25.5:\n"
Expand All @@ -20,14 +29,6 @@ msgid ""
"- Adjusted how users log into WordPress.com – this fixes a long-standing issue where you couldn't log in if you used a Passkey.\n"
msgstr ""

msgctxt "release_note_254"
msgid ""
"25.4:\n"
"Lots of under-the-hood improvements this month – mostly bugfixes, but you should notice that the app doesn't prompt you for ratings nearly as often.\n"
"We're excited to have more to share with you soon!\n"
"We'd love to hear your feedback on the app – you can reach us at [email protected].\n"
msgstr ""

#. translators: Release notes for this version to be displayed in the Play Store. Limit to 500 characters including spaces and commas!
#. translators: Title to be displayed in the Play Store. Limit to 30 characters including spaces and commas!
msgctxt "play_store_app_title"
Expand Down
6 changes: 4 additions & 2 deletions WordPress/jetpack_metadata/release_notes.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@


This update:
- Fixes a rare crash when registering a domain.
- Fixes a bunch of under-the-hood things that should make the app more reliable.
- Uses a web-based approach for WordPress.com login. This should be more reliable for most users, but please contact support if you have any trouble!
17 changes: 9 additions & 8 deletions WordPress/metadata/PlayStoreStrings.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ msgstr ""
"X-Generator: VsCode\n"
"Project-Id-Version: Release Notes & Play Store Descriptions\n"

msgctxt "release_note_256"
msgid ""
"25.6:\n"
"This update:\n"
"- Fixes a rare crash when registering a domain.\n"
"- Fixes a bunch of under-the-hood things that should make the app more reliable.\n"
"- Uses a web-based approach for WordPress.com login. This should be more reliable for most users, but please contact support if you have any trouble!\n"
msgstr ""

msgctxt "release_note_255"
msgid ""
"25.5:\n"
Expand All @@ -19,14 +28,6 @@ msgid ""
"- Adjusted how users log into WordPress.com – this fixes a long-standing issue where you couldn't log in if you used a Passkey.\n"
msgstr ""

msgctxt "release_note_254"
msgid ""
"25.4:\n"
"Lots of under-the-hood improvements this month – mostly bugfixes, but you should notice that the app doesn't prompt you for ratings nearly as often.\n"
"We're excited to have more to share with you soon!\n"
"We'd love to hear your feedback on the app – you can reach us at [email protected].\n"
msgstr ""

#. translators: Release notes for this version to be displayed in the Play Store. Limit to 500 characters including spaces and commas!
#. translators: Shorter Release notes for this version to be displayed in the Play Store. Limit to 500 characters including spaces and commas!
msgctxt "sample_post_content"
Expand Down
6 changes: 4 additions & 2 deletions WordPress/metadata/release_notes.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@


This update:
- Fixes a rare crash when registering a domain.
- Fixes a bunch of under-the-hood things that should make the app more reliable.
- Uses a web-based approach for WordPress.com login. This should be more reliable for most users, but please contact support if you have any trouble!
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ import org.wordpress.android.ui.posts.services.AztecVideoLoader
import org.wordpress.android.ui.posts.sharemessage.EditJetpackSocialShareMessageActivity
import org.wordpress.android.ui.posts.sharemessage.EditJetpackSocialShareMessageActivity.Companion.createIntent
import org.wordpress.android.ui.prefs.AppPrefs
import org.wordpress.android.ui.prefs.ExperimentalFeature
import org.wordpress.android.ui.prefs.SiteSettingsInterface
import org.wordpress.android.ui.prefs.SiteSettingsInterface.SiteSettingsListener
import org.wordpress.android.ui.reader.utils.ReaderUtilsWrapper
Expand Down Expand Up @@ -234,8 +235,6 @@ import org.wordpress.android.util.analytics.AnalyticsUtils
import org.wordpress.android.util.analytics.AnalyticsUtils.BlockEditorEnabledSource
import org.wordpress.android.util.config.ContactSupportFeatureConfig
import org.wordpress.android.util.config.PostConflictResolutionFeatureConfig
import org.wordpress.android.util.config.GutenbergKitFeatureConfig
import org.wordpress.android.util.config.GutenbergKitThemeStylesFeatureConfig
import org.wordpress.android.util.extensions.setLiftOnScrollTargetViewIdAndRequestLayout
import org.wordpress.android.util.helpers.MediaFile
import org.wordpress.android.util.helpers.MediaGallery
Expand Down Expand Up @@ -409,8 +408,9 @@ class EditPostActivity : AppCompatActivity(), EditorFragmentActivity, EditorImag

@Inject lateinit var postConflictResolutionFeatureConfig: PostConflictResolutionFeatureConfig

@Inject lateinit var gutenbergKitFeatureConfig: GutenbergKitFeatureConfig
@Inject lateinit var gutenbergKitThemeStylesConfig: GutenbergKitThemeStylesFeatureConfig
private val gutenbergKitFeatureConfig: ExperimentalFeature = ExperimentalFeature.EXPERIMENTAL_BLOCK_EDITOR
private val gutenbergKitThemeStylesConfig: ExperimentalFeature =
ExperimentalFeature.EXPERIMENTAL_BLOCK_EDITOR_THEME_STYLES

@Inject lateinit var storePostViewModel: StorePostViewModel
@Inject lateinit var storageUtilsViewModel: StorageUtilsViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public enum DeletablePrefKey implements PrefKey {
// Selected Reader feed ID for persisting user preferred feed
READER_TOP_BAR_SELECTED_FEED_ITEM_ID,
MANUAL_FEATURE_CONFIG,
EXPERIMENTAL_FEATURE_CONFIG,
SITE_JETPACK_CAPABILITIES,
REMOVED_QUICK_START_CARD_TYPE,
PINNED_DYNAMIC_CARD,
Expand Down Expand Up @@ -1309,6 +1310,18 @@ public static boolean hasManualFeatureConfig(String featureKey) {
return DeletablePrefKey.MANUAL_FEATURE_CONFIG.name() + featureKey;
}

public static void setExperimentalFeatureConfig(boolean isEnabled, @NonNull String featureKey) {
prefs().edit().putBoolean(getExperimentalFeatureConfigKey(featureKey), isEnabled).apply();
}

public static boolean getExperimentalFeatureConfig(@NonNull String featureKey) {
return prefs().getBoolean(getExperimentalFeatureConfigKey(featureKey), false);
}

@NonNull private static String getExperimentalFeatureConfigKey(@NonNull String featureKey) {
return DeletablePrefKey.EXPERIMENTAL_FEATURE_CONFIG.name() + featureKey;
}

public static void incrementPublishedPostCount() {
putInt(DeletablePrefKey.PUBLISHED_POST_COUNT, getPublishedPostCount() + 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ class AppPrefsWrapper @Inject constructor(val buildConfigWrapper: BuildConfigWra
return AppPrefs.getManualFeatureConfig(featureKey)
}

fun getExperimentalFeatureConfig(featureKey: String): Boolean {
return AppPrefs.getExperimentalFeatureConfig(featureKey)
}

fun incrementPublishedPostCount() {
AppPrefs.incrementPublishedPostCount()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.wordpress.android.ui.prefs

import android.annotation.SuppressLint
import android.content.Context
import android.content.res.Configuration.UI_MODE_NIGHT_YES
import android.os.Bundle
import androidx.activity.viewModels
Expand All @@ -26,7 +24,6 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.lifecycle.ViewModel
Expand All @@ -41,32 +38,38 @@ import org.wordpress.android.ui.compose.theme.AppThemeM3
import org.wordpress.android.ui.compose.unit.Margin
import org.wordpress.android.util.extensions.setContent

val experimentalFeatures = listOf(
Feature(key = "experimental_block_editor"),
Feature(key = "experimental_block_editor_theme_styles"),
)
enum class ExperimentalFeature(val prefKey: String, val labelResId: Int) {
EXPERIMENTAL_BLOCK_EDITOR("experimental_block_editor", R.string.experimental_block_editor),
EXPERIMENTAL_BLOCK_EDITOR_THEME_STYLES(
"experimental_block_editor_theme_styles",
R.string.experimental_block_editor_theme_styles
);

data class Feature(
val enabled: Boolean = false,
val key: String,
)
fun isEnabled() : Boolean {
return AppPrefs.getExperimentalFeatureConfig(prefKey)
}

fun setEnabled(isEnabled: Boolean) {
AppPrefs.setExperimentalFeatureConfig(isEnabled, prefKey)
}
}

class FeatureViewModel : ViewModel() {
private val _switchStates = MutableStateFlow<Map<String, Feature>>(emptyMap())
val switchStates: StateFlow<Map<String, Feature>> = _switchStates.asStateFlow()
private val _switchStates = MutableStateFlow<Map<ExperimentalFeature, Boolean>>(emptyMap())
val switchStates: StateFlow<Map<ExperimentalFeature, Boolean>> = _switchStates.asStateFlow()

init {
val initialStates = experimentalFeatures.associate { item ->
item.key to Feature(AppPrefs.getManualFeatureConfig(item.key), item.key)
val initialStates = ExperimentalFeature.entries.associate { feature ->
feature to feature.isEnabled()
}
_switchStates.value = initialStates
}

fun onFeatureToggled(key: String, enabled: Boolean) {
fun onFeatureToggled(feature: ExperimentalFeature, enabled: Boolean) {
_switchStates.update { currentStates ->
currentStates.toMutableMap().apply {
this[key] = Feature(enabled, key)
AppPrefs.setManualFeatureConfig(enabled, key)
this[feature] = enabled
feature.setEnabled(enabled)
}
}
}
Expand Down Expand Up @@ -96,8 +99,8 @@ class ExperimentalFeaturesActivity : AppCompatActivity() {
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ExperimentalFeaturesScreen(
features: Map<String, Feature>,
onFeatureToggled: (key: String, enabled: Boolean) -> Unit,
features: Map<ExperimentalFeature, Boolean>,
onFeatureToggled: (feature: ExperimentalFeature, enabled: Boolean) -> Unit,
onNavigateBack: () -> Unit
) {
Scaffold(
Expand All @@ -119,16 +122,10 @@ fun ExperimentalFeaturesScreen(
) { innerPadding ->
Box(modifier = Modifier.padding(innerPadding)) {
Column {
features.forEach { (key, feature) ->
val context = LocalContext.current
val label = remember(key) {
context.getStringResourceByName(key)
}

features.forEach { (feature, enabled) ->
FeatureToggle(
key = key,
label = label,
enabled = feature.enabled,
feature = feature,
enabled = enabled,
onChange = onFeatureToggled,
)
}
Expand All @@ -137,27 +134,20 @@ fun ExperimentalFeaturesScreen(
}
}

@SuppressLint("DiscouragedApi")
fun Context.getStringResourceByName(name: String): String {
val resourceId = resources.getIdentifier(name, "string", packageName)
return if (resourceId != 0) getString(resourceId) else name
}

@Composable
fun FeatureToggle(
key: String,
label: String,
feature: ExperimentalFeature,
enabled: Boolean,
onChange: (String, Boolean) -> Unit,
onChange: (ExperimentalFeature, Boolean) -> Unit,
) {
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.clickable { onChange(key, !enabled) }
.clickable { onChange(feature, !enabled) }
.padding(horizontal = Margin.ExtraLarge.value, vertical = Margin.MediumLarge.value)
) {
Text(
text = label,
text = stringResource(feature.labelResId),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurface,
modifier = Modifier
Expand All @@ -167,7 +157,7 @@ fun FeatureToggle(
Switch(
checked = enabled,
onCheckedChange = { newValue ->
onChange(key, newValue)
onChange(feature, newValue)
},
)
}
Expand All @@ -179,8 +169,8 @@ fun FeatureToggle(
fun ExperimentalFeaturesScreenPreview() {
AppThemeM3 {
val featuresStatusAlternated = remember {
experimentalFeatures.mapIndexed { index, feature ->
feature.key to feature.copy(enabled = index % 2 == 0)
ExperimentalFeature.entries.toTypedArray().mapIndexed { index, feature ->
feature to (index % 2 == 0)
}.toMap()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.wordpress.android.ui.sitecreation.domains.compose
import android.content.res.Configuration
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.focusable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
Expand Down Expand Up @@ -61,6 +62,7 @@ fun DomainItem(uiState: DomainUiState): Unit = with(uiState) {
indication = ripple(color = HighlightBgColor),
onClick = onClick::invoke,
)
.focusable(enabled = true)
.then(if (cost is Cost.Paid) {
Modifier.padding(top = Margin.ExtraLarge.value)
} else {
Expand Down

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ androidx-webkit = '1.12.1'
androidx-work = '2.9.1'
apache-commons-text = '1.13.0'
apache-http-client-android = '4.3.5.1'
assertj = '3.27.2'
assertj = '3.27.3'
automattic-about = '1.4.0'
automattic-measure-builds = '3.1.1'
automattic-rest = '1.0.8'
Expand Down

0 comments on commit 25d1b32

Please sign in to comment.