Skip to content

Commit

Permalink
Merge branch 'trunk' into feat/update-image-block-upload-visuals
Browse files Browse the repository at this point in the history
  • Loading branch information
derekblank authored Jan 10, 2024
2 parents b97dbec + d7c3f49 commit 92c2b99
Show file tree
Hide file tree
Showing 131 changed files with 881 additions and 383 deletions.
1 change: 1 addition & 0 deletions WordPress/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ android {
buildConfigField "boolean", "BLOGANUARY_DASHBOARD_NUDGE", "false"
buildConfigField "boolean", "IN_APP_REVIEWS", "false"
buildConfigField "boolean", "DYNAMIC_DASHBOARD_CARDS", "false"
buildConfigField "boolean", "STATS_TRAFFIC_TAB", "false"

// Override these constants in jetpack product flavor to enable/ disable features
buildConfigField "boolean", "ENABLE_SITE_CREATION", "true"
Expand Down
13 changes: 9 additions & 4 deletions WordPress/jetpack_metadata/release_notes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
No updates this week! Enjoy these reindeer facts:
- Male reindeer shed their antlers in fall and females in spring, so Santa’s reindeer are female.
- Reindeer don’t actually have red noses.
- Santa hasn’t eaten milk and cookies since 2003 because Blitzen always gets there first.
* [*] Filter media types when sharing files to the editor [https://github.com/wordpress-mobile/WordPress-Android/pull/19754]
* [***] [Jetpack-only] Plans: Upgrade to a Plan from domains dashboard in Jetpack app [https://github.com/wordpress-mobile/WordPress-Android/pull/19818]
* [**] [internal] Removes unused resources and code [https://github.com/wordpress-mobile/WordPress-Android/pull/19788]
* [*] Block Editor: Add support for unselecting blocks with the hardware back button [https://github.com/wordpress-mobile/WordPress-Android/pull/19828]
* [**] [internal] Removes unused code using android tool [https://github.com/wordpress-mobile/WordPress-Android/pull/19850]
* [**] [internal] [Jetpack-only] Adds support for dynamic dashboard cards driven by the backend [https://github.com/wordpress-mobile/WordPress-Android/pull/19801]
* [***] Block Editor: Avoid keyboard dismiss when interacting with text blocks [https://github.com/WordPress/gutenberg/pull/57070]
* [**] Block Editor: Auto-scroll upon block insertion [https://github.com/WordPress/gutenberg/pull/57273]

12 changes: 8 additions & 4 deletions WordPress/metadata/release_notes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
No updates this week! Enjoy these reindeer facts:
- Male reindeer shed their antlers in fall and females in spring, so Santa’s reindeer are female.
- Reindeer don’t actually have red noses.
- Santa hasn’t eaten milk and cookies since 2003 because Blitzen always gets there first.
* [*] Filter media types when sharing files to the editor [https://github.com/wordpress-mobile/WordPress-Android/pull/19754]
* [**] [internal] Removes unused resources and code [https://github.com/wordpress-mobile/WordPress-Android/pull/19788]
* [*] Block Editor: Add support for unselecting blocks with the hardware back button [https://github.com/wordpress-mobile/WordPress-Android/pull/19828]
* [**] [internal] Removes unused code using android tool [https://github.com/wordpress-mobile/WordPress-Android/pull/19850]
* [**] [internal] [Jetpack-only] Adds support for dynamic dashboard cards driven by the backend [https://github.com/wordpress-mobile/WordPress-Android/pull/19801]
* [***] Block Editor: Avoid keyboard dismiss when interacting with text blocks [https://github.com/WordPress/gutenberg/pull/57070]
* [**] Block Editor: Auto-scroll upon block insertion [https://github.com/WordPress/gutenberg/pull/57273]

5 changes: 4 additions & 1 deletion WordPress/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
<activity
android:name=".ui.debug.previews.PreviewFragmentActivity"
android:theme="@style/WordPress.NoActionBar" />
<activity
android:name=".ui.debug.preferences.DebugSharedPreferenceFlagsActivity"
android:label="@string/debug_settings_debug_flags_screen"
android:theme="@style/WordPress.NoActionBar" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.wordpress.android.ui.comments.unified.UnifiedCommentsActivity;
import org.wordpress.android.ui.comments.unified.UnifiedCommentsDetailsActivity;
import org.wordpress.android.ui.debug.cookies.DebugCookiesActivity;
import org.wordpress.android.ui.debug.preferences.DebugSharedPreferenceFlagsActivity;
import org.wordpress.android.ui.domains.DomainRegistrationActivity;
import org.wordpress.android.ui.domains.DomainRegistrationActivity.DomainRegistrationPurpose;
import org.wordpress.android.ui.domains.DomainsDashboardActivity;
Expand Down Expand Up @@ -1803,6 +1804,9 @@ public static void viewDebugCookies(@NonNull Context context) {
context.startActivity(new Intent(context, DebugCookiesActivity.class));
}

public static void viewDebugSharedPreferenceFlags(@NonNull Context context) {
context.startActivity(new Intent(context, DebugSharedPreferenceFlagsActivity.class));
}
public static void startQRCodeAuthFlow(@NonNull Context context) {
QRCodeAuthActivity.start(context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class DebugSettingsActivity : LocaleAwareActivity() {
is DebugSettingsViewModel.NavigationAction.PreviewFragment -> {
previewFragmentInActivity(it.name)
}
is DebugSettingsViewModel.NavigationAction.DebugFlags ->
ActivityLauncher.viewDebugSharedPreferenceFlags(this@DebugSettingsActivity)
}
}
}
Expand All @@ -68,6 +70,7 @@ class DebugSettingsActivity : LocaleAwareActivity() {
R.id.menu_debug_cookies -> viewModel.onDebugCookiesClick()
R.id.menu_restart_app -> viewModel.onRestartAppClick()
R.id.menu_show_weekly_notifications -> viewModel.onForceShowWeeklyRoundupClick()
R.id.menu_debug_flags -> viewModel.onDebugFlagsClick()
}
return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ class DebugSettingsViewModel
}
}

fun onDebugFlagsClick() {
_onNavigation.value = Event(NavigationAction.DebugFlags)
}

private fun buildDevelopedFeatures(): List<LocalFeatureFlag> {
return FeaturesInDevelopment.featuresInDevelopment.map { name ->
val value = if (manualFeatureConfig.hasManualSetup(name)) {
Expand Down Expand Up @@ -156,6 +160,7 @@ class DebugSettingsViewModel

sealed class NavigationAction {
object DebugCookies : NavigationAction()
object DebugFlags : NavigationAction()
data class PreviewFragment(val name: String) : NavigationAction()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.wordpress.android.ui.debug.preferences

import android.os.Bundle
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import dagger.hilt.android.AndroidEntryPoint
import org.wordpress.android.ui.domains.management.M3Theme
import org.wordpress.android.util.extensions.setContent

@AndroidEntryPoint
class DebugSharedPreferenceFlagsActivity : AppCompatActivity() {
private val viewModel: DebugSharedPreferenceFlagsViewModel by viewModels()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
M3Theme {
val uiState by viewModel.uiStateFlow.collectAsState()
DebugSharedPreferenceFlagsScreen(
flags = uiState,
onFlagChanged = viewModel::setFlag,
onBackTapped = { onBackPressedDispatcher.onBackPressed() },
)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package org.wordpress.android.ui.debug.preferences

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.Checkbox
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment.Companion.CenterVertically
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import org.wordpress.android.R
import org.wordpress.android.ui.compose.components.MainTopAppBar
import org.wordpress.android.ui.compose.components.NavigationIcons
import org.wordpress.android.ui.domains.management.M3Theme

@Composable
fun DebugSharedPreferenceFlagsScreen(
flags: Map<String, Boolean>,
onBackTapped: () -> Unit,
onFlagChanged: (String, Boolean) -> Unit,
) {
Scaffold(
topBar = {
MainTopAppBar(
title = stringResource(R.string.debug_settings_debug_flags_screen),
navigationIcon = NavigationIcons.BackIcon,
onNavigationIconClick = onBackTapped,
backgroundColor = MaterialTheme.colorScheme.surface,
contentColor = MaterialTheme.colorScheme.onSurface,
)
},
) { paddingValues ->
LazyColumn(modifier = Modifier.padding(paddingValues)) {
items(flags.toList()) { (key, value) ->
DebugFlagRow(
key = key,
value = value,
onFlagChanged = onFlagChanged,
)
}
}
}
}

@Composable
fun DebugFlagRow(
key: String,
value: Boolean,
onFlagChanged: (String, Boolean) -> Unit,
modifier: Modifier = Modifier,
) {
Row(
modifier = modifier
.padding(vertical = 4.dp)
.clickable { onFlagChanged(key, !value) }
) {
Text(
text = key,
modifier = Modifier
.weight(1f)
.align(CenterVertically)
.padding(start = 16.dp)
)
Checkbox(
checked = value,
modifier = Modifier.align(CenterVertically).padding(end = 8.dp),
onCheckedChange = { onFlagChanged(key, it) }
)
}
}

@Preview
@Composable
fun DebugFlagsScreenPreview() {
M3Theme {
DebugSharedPreferenceFlagsScreen(
flags = mapOf(
"EXAMPLE_FEATURE_FLAG" to true,
"RANDOM_FLAG" to false,
"ANOTHER_FLAG" to true,
"YET_ANOTHER_FLAG" to false,

),
onBackTapped = {},
onFlagChanged = { _, _ -> },
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.wordpress.android.ui.debug.preferences

import androidx.lifecycle.ViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import org.wordpress.android.ui.prefs.AppPrefsWrapper
import javax.inject.Inject

@HiltViewModel
class DebugSharedPreferenceFlagsViewModel @Inject constructor(
private val prefsWrapper: AppPrefsWrapper
) : ViewModel() {
private val _uiStateFlow = MutableStateFlow<Map<String, Boolean>>(emptyMap())
val uiStateFlow = _uiStateFlow.asStateFlow()

init {
val flags = prefsWrapper.getAllPrefs().mapNotNull { (key, value) ->
if (value is Boolean) key to value else null
}.toMap()
_uiStateFlow.value = flags
}

fun setFlag(key: String, value: Boolean) {
prefsWrapper.putBoolean({ key }, value)
_uiStateFlow.value = _uiStateFlow.value.toMutableMap().apply { this[key] = value }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ import org.wordpress.android.ui.deeplinks.DeepLinkNavigator.NavigateAction.OpenI
import org.wordpress.android.ui.deeplinks.DeepLinkTrackingUtils.DeepLinkSource.BANNER
import org.wordpress.android.ui.deeplinks.DeepLinkTrackingUtils.DeepLinkSource.EMAIL
import org.wordpress.android.ui.deeplinks.DeepLinkTrackingUtils.DeepLinkSource.LINK
import org.wordpress.android.ui.deeplinks.DeepLinkTrackingUtils.DeepLinkSource.QRCODE_AUTH
import org.wordpress.android.ui.deeplinks.DeepLinkTrackingUtils.DeepLinkSource.QRCODE_MEDIA
import org.wordpress.android.ui.deeplinks.handlers.DeepLinkHandlers
import org.wordpress.android.ui.deeplinks.handlers.QRCodeAuthLinkHandler
import org.wordpress.android.ui.deeplinks.handlers.QRCodeMediaLinkHandler
import org.wordpress.android.util.UriWrapper
import org.wordpress.android.util.analytics.AnalyticsUtilsWrapper
import javax.inject.Inject
Expand Down Expand Up @@ -58,9 +54,10 @@ class DeepLinkTrackingUtils
val trackingSource = source ?: if (uri.host == DeepLinkingIntentReceiverViewModel.HOST_WORDPRESS_COM) {
LINK
} else {
applyBannerOrQrCodeSourceFromUri(uri)
BANNER
}
return TrackingData(trackingSource, url ?: "", sourceInfo)
val trackingSourceInfo = sourceInfo ?: applyBannerSourceInfoIfNeeded(uri)
return TrackingData(trackingSource, url ?: "", trackingSourceInfo)
}

private fun extractTargetUri(uri: UriWrapper): UriWrapper {
Expand All @@ -73,12 +70,10 @@ class DeepLinkTrackingUtils
} ?: uri
}

private fun applyBannerOrQrCodeSourceFromUri(uri: UriWrapper): DeepLinkSource {
return when (uri.getQueryParameter("campaign")) {
null -> BANNER
QRCodeMediaLinkHandler.CAMPAIGN_TYPE -> QRCODE_MEDIA
QRCodeAuthLinkHandler.CAMPAIGN_TYPE -> QRCODE_AUTH
else -> LINK
private fun applyBannerSourceInfoIfNeeded(uri: UriWrapper): String? {
return when (val campaign = uri.getQueryParameter("campaign")) {
null -> null
else -> campaign
}
}

Expand All @@ -88,7 +83,5 @@ class DeepLinkTrackingUtils
EMAIL("email"),
BANNER("banner"),
LINK("link"),
QRCODE_AUTH("qr-code-auth"),
QRCODE_MEDIA("qr-code-media")
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
package org.wordpress.android.ui.deeplinks.handlers

import org.wordpress.android.analytics.AnalyticsTracker
import org.wordpress.android.ui.deeplinks.DeepLinkNavigator.NavigateAction
import org.wordpress.android.ui.deeplinks.DeepLinkUriUtils
import org.wordpress.android.util.UriWrapper
import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper
import javax.inject.Inject

class QRCodeMediaLinkHandler @Inject constructor(
private val deepLinkUriUtils: DeepLinkUriUtils
private val deepLinkUriUtils: DeepLinkUriUtils,
private val analyticsTrackerWrapper: AnalyticsTrackerWrapper
) : DeepLinkHandler {
/**
* Returns true if the URI looks like `apps.wordpress.com/get`
*/
override fun shouldHandleUrl(uri: UriWrapper): Boolean {
// https://apps.wordpress.com/get/?campaign=qr-code-media&data=post_id:6,site_id:227148183
// https://apps.wordpress.com/get/?campaign=qr-code-media#/media/{blog_id}
return uri.host == HOST_APPS_WORDPRESS_COM &&
uri.pathSegments.firstOrNull() == GET_PATH &&
uri.getQueryParameter(CAMPAIGN) == CAMPAIGN_TYPE
Expand All @@ -22,6 +25,9 @@ class QRCodeMediaLinkHandler @Inject constructor(
val extractedSiteId = extractSiteIdFromUrl(uri)
return when (val siteModel = extractedSiteId?.let { siteId -> deepLinkUriUtils.blogIdToSite(siteId) }) {
null -> {
analyticsTrackerWrapper.track(AnalyticsTracker.Stat.DEEP_LINK_FAILED,
mapOf(ERROR to INVALID_SITE_ID,
CAMPAIGN to uri.getQueryParameter(CAMPAIGN)?.replace("-", "_")))
NavigateAction.OpenMySite
}
else -> {
Expand All @@ -37,9 +43,12 @@ class QRCodeMediaLinkHandler @Inject constructor(
}

private fun extractSiteIdFromUrl(uri: UriWrapper): String? {
uri.getQueryParameter("data")?.let { data ->
val siteIdPair = data.split(",").find { it.startsWith("site_id:") }
return siteIdPair?.substringAfter(":")
uri.fragment?.let { fragment ->
val pathSegments = fragment.split("/")

if (pathSegments.isNotEmpty()) {
return pathSegments.last()
}
}
return null
}
Expand All @@ -48,6 +57,8 @@ class QRCodeMediaLinkHandler @Inject constructor(
private const val GET_PATH = "get"
private const val HOST_APPS_WORDPRESS_COM = "apps.wordpress.com"
private const val CAMPAIGN = "campaign"
private const val ERROR = "error"
private const val INVALID_SITE_ID = "invalid_site_id"
const val CAMPAIGN_TYPE = "qr-code-media"
}
}
Loading

0 comments on commit 92c2b99

Please sign in to comment.