Skip to content

Commit

Permalink
Merge pull request #21459 from wordpress-mobile/feat/experimental-fea…
Browse files Browse the repository at this point in the history
…tures-settings

feat: Experimental features settings
  • Loading branch information
dcalhoun authored Nov 13, 2024
2 parents fb219f1 + e4838b2 commit 0a420c8
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ public class AppSettingsFragment extends PreferenceFragment
private WPSwitchPreference mStripImageLocation;
private WPSwitchPreference mReportCrashPref;
private WPSwitchPreference mOpenWebLinksWithJetpack;
@Nullable private PreferenceScreen mExperimentalFeaturesSettings;
@Nullable private WPSwitchPreference mExperimentalBlockEditorPref;
@Nullable private WPSwitchPreference mExperimentalBlockEditorStylesPref;

private Preference mWhatsNew;

Expand Down Expand Up @@ -177,12 +180,18 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
.getPrefAndSetChangeListener(this, R.string.pref_key_site_video_encoder_bitrate, this);
mPrivacySettings = (PreferenceScreen) WPPrefUtils
.getPrefAndSetClickListener(this, R.string.pref_key_privacy_settings, this);
mExperimentalFeaturesSettings = (PreferenceScreen) WPPrefUtils
.getPrefAndSetClickListener(this, R.string.pref_key_experimental_features_settings, this);

mStripImageLocation =
(WPSwitchPreference) WPPrefUtils
.getPrefAndSetChangeListener(this, R.string.pref_key_strip_image_location, this);
mReportCrashPref = (WPSwitchPreference) WPPrefUtils
.getPrefAndSetChangeListener(this, R.string.pref_key_send_crash, this);
mExperimentalBlockEditorPref = (WPSwitchPreference) WPPrefUtils
.getPrefAndSetChangeListener(this, R.string.pref_key_experimental_block_editor, this);
mExperimentalBlockEditorStylesPref = (WPSwitchPreference) WPPrefUtils
.getPrefAndSetChangeListener(this, R.string.pref_key_experimental_block_editor_theme_styles, this);

mOpenWebLinksWithJetpack =
(WPSwitchPreference) WPPrefUtils
Expand Down Expand Up @@ -260,6 +269,7 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Override public void onViewStateRestored(Bundle savedInstanceState) {
super.onViewStateRestored(savedInstanceState);
addPrivacyToolbar();
addExperimentalFeaturesToolbar();
}

private void addJetpackBadgeAsFooterIfEnabled(LayoutInflater inflater, ListView listView) {
Expand Down Expand Up @@ -405,6 +415,8 @@ public boolean onPreferenceClick(Preference preference) {
return handleDevicePreferenceClick();
} else if (preference == mPrivacySettings) {
return handlePrivacyClick();
} else if (preference == mExperimentalFeaturesSettings) {
return handleExperimentalFeaturesClick();
} else if (preference == mWhatsNew) {
return handleFeatureAnnouncementClick();
} else if (preference == mLanguagePreference) {
Expand Down Expand Up @@ -473,6 +485,12 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
} else if (preference == mReportCrashPref) {
AnalyticsTracker.track(Stat.PRIVACY_SETTINGS_REPORT_CRASHES_TOGGLED, Collections
.singletonMap(TRACK_ENABLED, newValue));
} else if (preference == mExperimentalBlockEditorPref) {
AnalyticsTracker.track(Stat.EXPERIMENTAL_BLOCK_EDITOR_TOGGLED, Collections
.singletonMap(TRACK_ENABLED, newValue));
} else if (preference == mExperimentalBlockEditorStylesPref) {
AnalyticsTracker.track(Stat.EXPERIMENTAL_BLOCK_EDITOR_THEME_STYLES_TOGGLED, Collections
.singletonMap(TRACK_ENABLED, newValue));
} else if (preference == mOpenWebLinksWithJetpack) {
handleOpenLinksInJetpack((Boolean) newValue);
}
Expand Down Expand Up @@ -617,6 +635,32 @@ private boolean addPrivacyToolbar() {
return true;
}

private boolean handleExperimentalFeaturesClick() {
AnalyticsTracker.track(Stat.APP_SETTINGS_EXPERIMENTAL_FEATURES_TAPPED);

boolean isToolbarAdded = addExperimentalFeaturesToolbar();

if (!isToolbarAdded) {
return false;
}

AnalyticsTracker.track(Stat.EXPERIMENTAL_FEATURES_SETTINGS_OPENED);
return true;
}

private boolean addExperimentalFeaturesToolbar() {
if (mExperimentalFeaturesSettings == null || !isAdded()) {
return false;
}

String title = getString(R.string.preference_experimental_features_settings);
Dialog dialog = mExperimentalFeaturesSettings.getDialog();
if (dialog != null) {
WPActivityUtils.addToolbarToDialog(this, dialog, title);
}
return true;
}

private boolean handleFeatureAnnouncementClick() {
if (getActivity() instanceof AppCompatActivity) {
AnalyticsTracker.track(Stat.FEATURE_ANNOUNCEMENT_SHOWN_FROM_APP_SETTINGS);
Expand Down
3 changes: 3 additions & 0 deletions WordPress/src/main/res/values/key_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<string name="pref_key_privacy_settings" translatable="false">wp_pref_privacy_settings</string>
<string name="pref_key_send_usage" translatable="false">wp_pref_send_usage_stats</string>
<string name="pref_key_send_crash" translatable="false">wp_pref_send_crash_stats</string>
<string name="pref_key_experimental_features_settings" translatable="false">wp_pref_experimental_features_settings</string>
<string name="pref_key_experimental_block_editor" translatable="false">MANUAL_FEATURE_CONFIGexperimental_block_editor</string>
<string name="pref_key_experimental_block_editor_theme_styles" translatable="false">MANUAL_FEATURE_CONFIGexperimental_block_editor_theme_styles</string>
<string name="pref_key_device_settings" translatable="false">wp_pref_device_settings</string>
<string name="pref_key_experimental_section" translatable="false">wp_pref_app_experimental_section</string>
<string name="pref_key_language" translatable="false">wp_pref_language</string>
Expand Down
3 changes: 3 additions & 0 deletions WordPress/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,9 @@
<string name="ccpa_privacy_notice_header">Privacy notice for California users</string>
<string name="ccpa_privacy_notice_caption">The California Consumer Privacy Act ("CCPA") requires us to provide California residents with some additional information about the categories of personal information we collect and share, where we get that personal information, and how and why we use it.</string>
<string name="ccpa_privacy_notice_read">Read CCPA privacy notice</string>
<string name="preference_experimental_features_settings">Experimental features</string>
<string name="preference_experimental_block_editor">Experimental block editor</string>
<string name="preference_experimental_block_editor_theme_styles">Experimental block editor styles</string>
<string name="preference_strip_image_location">Remove location from media</string>
<string name="app_theme">Appearance</string>
<string name="app_theme_light">Light</string>
Expand Down
17 changes: 17 additions & 0 deletions WordPress/src/main/res/xml/app_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,23 @@

</PreferenceScreen>

<PreferenceScreen
android:id="@+id/pref_experimental_features_settings"
android:key="@string/pref_key_experimental_features_settings"
android:title="@string/preference_experimental_features_settings">

<org.wordpress.android.ui.prefs.WPSwitchPreference
android:defaultValue="false"
android:key="@string/pref_key_experimental_block_editor"
android:title="@string/preference_experimental_block_editor" />

<org.wordpress.android.ui.prefs.WPSwitchPreference
android:defaultValue="false"
android:key="@string/pref_key_experimental_block_editor_theme_styles"
android:title="@string/preference_experimental_block_editor_theme_styles" />

</PreferenceScreen>

<Preference
android:key="@string/pref_key_device_settings"
android:title="@string/preference_open_device_settings" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,7 @@ public enum Stat {
SETTINGS_DID_CHANGE,
APP_SETTINGS_APPEARANCE_CHANGED,
APP_SETTINGS_PRIVACY_SETTINGS_TAPPED,
APP_SETTINGS_EXPERIMENTAL_FEATURES_TAPPED,
APP_SETTINGS_OPEN_DEVICE_SETTINGS_TAPPED,
APP_SETTINGS_MAX_IMAGE_SIZE_CHANGED,
APP_SETTINGS_IMAGE_QUALITY_CHANGED,
Expand All @@ -921,6 +922,9 @@ public enum Stat {
APP_SETTINGS_VIDEO_QUALITY_CHANGED,
PRIVACY_SETTINGS_OPENED,
PRIVACY_SETTINGS_REPORT_CRASHES_TOGGLED,
EXPERIMENTAL_FEATURES_SETTINGS_OPENED,
EXPERIMENTAL_BLOCK_EDITOR_TOGGLED,
EXPERIMENTAL_BLOCK_EDITOR_THEME_STYLES_TOGGLED,
SHARING_BUTTONS_EDIT_SHARING_BUTTONS_CHANGED,
SHARING_BUTTONS_EDIT_MORE_SHARING_BUTTONS_CHANGED,
PEOPLE_MANAGEMENT_USER_INVITED,
Expand Down

0 comments on commit 0a420c8

Please sign in to comment.