Skip to content

Commit 2d6be84

Browse files
Merge pull request #14610 from woocommerce/issue/WOOMOB-1338-jp-performance-remote-flag
[Jetpack Performance] Integrate remote feature flag
2 parents 230c05c + dc2395b commit 2d6be84

File tree

7 files changed

+28
-13
lines changed

7 files changed

+28
-13
lines changed

RELEASE-NOTES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- [Internal] Migration to POS specific product model [https://github.com/woocommerce/woocommerce-android/pull/14598]
77
- [*] Enhance the shipping label creation screen by making the selected hazardous box tappable [https://github.com/woocommerce/woocommerce-android/pull/14576]
88
- [*] Shipping Labels: Enhance selected package UI in the create shipping label flow [https://github.com/woocommerce/woocommerce-android/pull/14579]
9+
- [***] Performance improvements for users logging in with WordPress.com accounts [https://github.com/woocommerce/woocommerce-android/pull/14610]
910
- [*] Fix an issue where there is delay before displaying the continue button in Site Picker screen [https://github.com/woocommerce/woocommerce-android/pull/14611]
1011

1112
23.2

WooCommerce/src/main/kotlin/com/woocommerce/android/applicationpasswords/WooApplicationPasswordsConfiguration.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@ package com.woocommerce.android.applicationpasswords
33
import com.woocommerce.android.AppPrefsWrapper
44
import com.woocommerce.android.BuildConfig
55
import com.woocommerce.android.util.DeviceInfo
6-
import com.woocommerce.android.util.FeatureFlag.APP_PASSWORDS_FOR_JETPACK_SITES
6+
import com.woocommerce.android.util.IsRemoteFeatureFlagEnabled
7+
import com.woocommerce.android.util.RemoteFeatureFlag
78
import jakarta.inject.Inject
89
import org.wordpress.android.fluxc.network.rest.wpapi.applicationpasswords.ApplicationPasswordsConfiguration
910

1011
class WooApplicationPasswordsConfiguration @Inject constructor(
11-
private val appPrefs: AppPrefsWrapper
12+
private val appPrefs: AppPrefsWrapper,
13+
private val isRemoteFeatureFlagEnabled: IsRemoteFeatureFlagEnabled
1214
) : ApplicationPasswordsConfiguration {
1315
override val applicationName: String =
1416
"${BuildConfig.APPLICATION_ID}.app-client.${DeviceInfo.name.replace(' ', '-')}"
1517

16-
override suspend fun isEnabledForJetpackAccess(): Boolean =
17-
APP_PASSWORDS_FOR_JETPACK_SITES.isEnabled() && appPrefs.jetpackAppPasswordsEnabled
18+
override suspend fun isEnabledForJetpackAccess(): Boolean {
19+
return appPrefs.jetpackAppPasswordsEnabled &&
20+
isRemoteFeatureFlagEnabled(RemoteFeatureFlag.APP_PASSWORDS_FOR_JETPACK_SITES)
21+
}
1822
}

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/prefs/BetaFeaturesFragment.kt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import android.view.View
55
import android.widget.CompoundButton
66
import androidx.core.view.isVisible
77
import androidx.fragment.app.Fragment
8+
import androidx.lifecycle.lifecycleScope
89
import com.google.android.material.snackbar.BaseTransientBottomBar
910
import com.google.android.material.snackbar.Snackbar
1011
import com.woocommerce.android.AppPrefs
@@ -16,8 +17,10 @@ import com.woocommerce.android.tools.SelectedSite
1617
import com.woocommerce.android.tools.SiteConnectionType
1718
import com.woocommerce.android.ui.prefs.MainSettingsFragment.AppSettingsListener
1819
import com.woocommerce.android.util.AnalyticsUtils
19-
import com.woocommerce.android.util.FeatureFlag
20+
import com.woocommerce.android.util.IsRemoteFeatureFlagEnabled
21+
import com.woocommerce.android.util.RemoteFeatureFlag
2022
import dagger.hilt.android.AndroidEntryPoint
23+
import kotlinx.coroutines.launch
2124
import javax.inject.Inject
2225

2326
@AndroidEntryPoint
@@ -29,6 +32,9 @@ class BetaFeaturesFragment : Fragment(R.layout.fragment_settings_beta) {
2932
@Inject
3033
lateinit var selectedSite: SelectedSite
3134

35+
@Inject
36+
lateinit var isRemoteFeatureFlagEnabled: IsRemoteFeatureFlagEnabled
37+
3238
private val settingsListener by lazy {
3339
activity as? AppSettingsListener
3440
}
@@ -59,9 +65,11 @@ class BetaFeaturesFragment : Fragment(R.layout.fragment_settings_beta) {
5965
}
6066

6167
private fun FragmentSettingsBetaBinding.bindJetpackAppPasswordsToggle() {
62-
// TODO check the remote feature flag state once available
63-
val isJetpackSite = selectedSite.connectionType != SiteConnectionType.ApplicationPasswords
64-
jetpackAppPasswordsToggle.isVisible = FeatureFlag.APP_PASSWORDS_FOR_JETPACK_SITES.isEnabled() && isJetpackSite
68+
viewLifecycleOwner.lifecycleScope.launch {
69+
val isJetpackSite = selectedSite.connectionType != SiteConnectionType.ApplicationPasswords
70+
jetpackAppPasswordsToggle.isVisible = isJetpackSite &&
71+
isRemoteFeatureFlagEnabled(RemoteFeatureFlag.APP_PASSWORDS_FOR_JETPACK_SITES)
72+
}
6573

6674
jetpackAppPasswordsToggle.isChecked = AppPrefs.jetpackAppPasswordsEnabled
6775
jetpackAppPasswordsToggle.setOnCheckedChangeListener { _, isChecked ->

WooCommerce/src/main/kotlin/com/woocommerce/android/util/FeatureFlag.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ enum class FeatureFlag {
1212
ORDER_CREATION_AUTO_TAX_RATE,
1313
WOO_POS_HISTORICAL_ORDERS_M1,
1414
WOO_POS_LOCAL_CATALOG_M1,
15-
AI_PRODUCT_IMAGE_BACKGROUND_REMOVAL,
16-
APP_PASSWORDS_FOR_JETPACK_SITES;
15+
AI_PRODUCT_IMAGE_BACKGROUND_REMOVAL;
1716

1817
fun isEnabled(context: Context? = null): Boolean {
1918
return when (this) {
@@ -26,8 +25,7 @@ enum class FeatureFlag {
2625
BETTER_CUSTOMER_SEARCH_M2,
2726
ORDER_CREATION_AUTO_TAX_RATE,
2827
AI_PRODUCT_IMAGE_BACKGROUND_REMOVAL,
29-
WOO_POS_LOCAL_CATALOG_M1,
30-
APP_PASSWORDS_FOR_JETPACK_SITES -> PackageUtils.isDebugBuild()
28+
WOO_POS_LOCAL_CATALOG_M1 -> PackageUtils.isDebugBuild()
3129
}
3230
}
3331
}

WooCommerce/src/main/kotlin/com/woocommerce/android/util/IsRemoteFeatureFlagEnabled.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.woocommerce.android.util
22

33
import com.woocommerce.android.config.WPComRemoteFeatureFlagRepository
4+
import com.woocommerce.android.util.RemoteFeatureFlag.APP_PASSWORDS_FOR_JETPACK_SITES
45
import com.woocommerce.android.util.RemoteFeatureFlag.LOCAL_NOTIFICATION_1D_AFTER_FREE_TRIAL_EXPIRES
56
import com.woocommerce.android.util.RemoteFeatureFlag.LOCAL_NOTIFICATION_1D_BEFORE_FREE_TRIAL_EXPIRES
67
import com.woocommerce.android.util.RemoteFeatureFlag.LOCAL_NOTIFICATION_STORE_CREATION_READY
@@ -15,7 +16,8 @@ class IsRemoteFeatureFlagEnabled @Inject constructor(
1516
LOCAL_NOTIFICATION_STORE_CREATION_READY,
1617
LOCAL_NOTIFICATION_1D_BEFORE_FREE_TRIAL_EXPIRES,
1718
LOCAL_NOTIFICATION_1D_AFTER_FREE_TRIAL_EXPIRES,
18-
WOO_POS ->
19+
WOO_POS,
20+
APP_PASSWORDS_FOR_JETPACK_SITES ->
1921
PackageUtils.isDebugBuild() ||
2022
wpComRemoteFeatureFlagRepository.isRemoteFeatureFlagEnabled(featureFlag.remoteKey)
2123
}

WooCommerce/src/main/kotlin/com/woocommerce/android/util/RemoteFeatureFlag.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ enum class RemoteFeatureFlag(val remoteKey: String) {
55
LOCAL_NOTIFICATION_1D_BEFORE_FREE_TRIAL_EXPIRES("woo_notification_1d_before_free_trial_expires"),
66
LOCAL_NOTIFICATION_1D_AFTER_FREE_TRIAL_EXPIRES("woo_notification_1d_after_free_trial_expires"),
77
WOO_POS("woo_pos"),
8+
APP_PASSWORDS_FOR_JETPACK_SITES("woo_app_passwords_for_jetpack_sites")
89
}

WooCommerce/src/main/res/layout/fragment_settings_beta.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
android:id="@+id/jetpackAppPasswordsToggle"
1919
android:layout_width="match_parent"
2020
android:layout_height="wrap_content"
21+
android:visibility="gone"
2122
app:toggleOptionDesc="@string/settings_enable_jetpack_app_passwords_message"
2223
app:toggleOptionTitle="@string/settings_enable_jetpack_app_passwords_title" />
2324

0 commit comments

Comments
 (0)