[dev_option] Update 'Desktop mode on secondary toggle' to be

'Freeform windows on secondary diplay'.

Make sure the toggles enables freeform support on devices. This remove
reliance on 'Enable freeform windows suppport' toggle when using this
toggle.

Also update strings for all toggles to just use term 'freeform windows'
instead of 'desktop mode' or 'freeform windowing experiences'.

Two toggles have the same name 'enable freeform windows', but users will
see only one of them at a time.

Test: Added new tests
Bug: 348193756
Bug: 348186127
Flag: EXEMPT minor change
Change-Id: Ic4528618e6902d084c58a6b5ddeb4b92d63386d6
This commit is contained in:
Alina Zaidi
2024-07-25 15:59:35 +00:00
parent d0333eb674
commit e85695f88c
3 changed files with 44 additions and 15 deletions

View File

@@ -12268,11 +12268,11 @@
<!-- Default title for the settings panel [CHAR LIMIT=NONE] --> <!-- Default title for the settings panel [CHAR LIMIT=NONE] -->
<string name="settings_panel_title">Settings Panel</string> <string name="settings_panel_title">Settings Panel</string>
<!-- Title for a toggle that enables freeform windowing experiences. Freeform windowing experiences are features involving apps running in resizable windows. [CHAR LIMIT=50] --> <!-- Title for a toggle that enables freeform windows. Freeform windows enables users to freely arrange and resize overlapping apps. [CHAR LIMIT=50] -->
<string name="enable_desktop_mode">Enable freeform windowing experiences</string> <string name="enable_desktop_mode">Enable freeform windows</string>
<!-- Title for a toggle that enables desktop mode on secondary display. [CHAR LIMIT=50] --> <!-- Title for a toggle that enables freeform windows on secondary display. Freeform windows enables users to freely arrange and resize overlapping apps. [CHAR LIMIT=50] -->
<string name="enable_desktop_mode_on_secondary_display">Enable desktop mode on secondary display</string> <string name="enable_desktop_mode_on_secondary_display">Enable freeform windows on secondary display</string>
<!-- UI debug setting: enable non-resizables in multi window [CHAR LIMIT=60] --> <!-- UI debug setting: enable non-resizables in multi window [CHAR LIMIT=60] -->
<string name="enable_non_resizable_multi_window">Enable non-resizable in multi window</string> <string name="enable_non_resizable_multi_window">Enable non-resizable in multi window</string>
@@ -13232,12 +13232,12 @@
<!-- The content description for accessibility tools of the customize button. It specifies which screensaver the user is customizing [CHAR LIMIT=NONE] --> <!-- The content description for accessibility tools of the customize button. It specifies which screensaver the user is customizing [CHAR LIMIT=NONE] -->
<string name="customize_button_description">Customize <xliff:g id="screensaver_name" example="Art Gallery">%1$s</xliff:g></string> <string name="customize_button_description">Customize <xliff:g id="screensaver_name" example="Art Gallery">%1$s</xliff:g></string>
<!-- Dialog body text used to explain a reboot is required after enabling freeform window support for it to work. Freeform window is when an app runs in a resizable window. [CHAR LIMIT=none] --> <!-- Dialog body text used to explain a reboot is required after enabling freeform window support for it to work. Freeform windows enables users to freely arrange and resize overlapping apps. [CHAR LIMIT=none] -->
<string name="reboot_dialog_enable_freeform_support">A reboot is required to enable freeform window support.</string> <string name="reboot_dialog_enable_freeform_support">A reboot is required to enable freeform window support.</string>
<!-- Dialog body text used to explain a reboot is required after updating availability of freeform windowing experiences. Freeform windowing experiences are features involving apps running in resizable windows. [CHAR LIMIT=none] --> <!-- Dialog body text used to explain a reboot is required after updating availability of freeform windows. Freeform windows enables users to freely arrange and resize overlapping apps. [CHAR LIMIT=none] -->
<string name="reboot_dialog_override_desktop_mode">A reboot is required to update availability of freeform windowing experiences.</string> <string name="reboot_dialog_override_desktop_mode">A reboot is required to update availability of freeform windows.</string>
<!-- Dialog body text used to explain a reboot is required after enabling desktop mode on secondary displays. [CHAR LIMIT=none] --> <!-- Dialog body text used to explain a reboot is required after enabling freeform windows on secondary displays. Freeform windows enables users to freely arrange and resize overlapping apps. [CHAR LIMIT=none] -->
<string name="reboot_dialog_enable_desktop_mode_on_secondary_display">A reboot is required to enable desktop mode on secondary displays.</string> <string name="reboot_dialog_enable_desktop_mode_on_secondary_display">A reboot is required to enable freeform windows on secondary displays.</string>
<!-- Text on the dialog button to reboot the device now [CHAR LIMIT=50] --> <!-- Text on the dialog button to reboot the device now [CHAR LIMIT=50] -->
<string name="reboot_dialog_reboot_now">Reboot now</string> <string name="reboot_dialog_reboot_now">Reboot now</string>
<!-- Text on the dialog button to reboot the device later [CHAR LIMIT=50] --> <!-- Text on the dialog button to reboot the device later [CHAR LIMIT=50] -->

View File

@@ -67,6 +67,12 @@ public class DesktopModeSecondaryDisplayPreferenceController extends
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.putInt(mContext.getContentResolver(),
DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS, DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS,
isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF); isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
// Update freeform window support on device.
// DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT setting enables freeform support on device
// where it's not present by default.
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT,
isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
if (isEnabled && mFragment != null) { if (isEnabled && mFragment != null) {
RebootConfirmationDialogFragment.show( RebootConfirmationDialogFragment.show(
mFragment, R.string.reboot_dialog_enable_desktop_mode_on_secondary_display, mFragment, R.string.reboot_dialog_enable_desktop_mode_on_secondary_display,

View File

@@ -16,6 +16,7 @@
package com.android.settings.development; package com.android.settings.development;
import static android.provider.Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT;
import static android.provider.Settings.Global.DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS; import static android.provider.Settings.Global.DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS;
import static com.android.settings.development.DesktopModeSecondaryDisplayPreferenceController.SETTING_VALUE_OFF; import static com.android.settings.development.DesktopModeSecondaryDisplayPreferenceController.SETTING_VALUE_OFF;
@@ -55,6 +56,7 @@ public class DesktopModeSecondaryDisplayPreferenceControllerTest {
private static final String ENG_BUILD_TYPE = "eng"; private static final String ENG_BUILD_TYPE = "eng";
private static final String USER_BUILD_TYPE = "user"; private static final String USER_BUILD_TYPE = "user";
private static final int SETTING_VALUE_INVALID = -1;
@Mock @Mock
private SwitchPreference mPreference; private SwitchPreference mPreference;
@@ -102,21 +104,41 @@ public class DesktopModeSecondaryDisplayPreferenceControllerTest {
@Test @Test
public void onPreferenceChange_switchEnabled_enablesDesktopModeOnSecondaryDisplay() { public void onPreferenceChange_switchEnabled_enablesDesktopModeOnSecondaryDisplay() {
mController.onPreferenceChange(mPreference, true /* new value */); mController.onPreferenceChange(mPreference, /* newValue= */ true);
final int mode = Settings.Global.getInt(mContext.getContentResolver(), final int mode = Settings.Global.getInt(mContext.getContentResolver(),
DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS, -1 /* default */); DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS,
/* def= */ SETTING_VALUE_INVALID);
assertThat(mode).isEqualTo(SETTING_VALUE_ON); assertThat(mode).isEqualTo(SETTING_VALUE_ON);
verify(mTransaction).add(any(RebootConfirmationDialogFragment.class), any()); verify(mTransaction).add(any(RebootConfirmationDialogFragment.class), any());
} }
@Test @Test
public void onPreferenceChange_switchDisabled_disablesDesktopModeOnSecondaryDisplay() { public void onPreferenceChange_switchEnabled_enablesFreeformSupport() {
mController.onPreferenceChange(mPreference, false /* new value */); mController.onPreferenceChange(mPreference, /* newValue= */ true);
final int mode = Settings.Global.getInt(mContext.getContentResolver(), final int mode = Settings.Global.getInt(mContext.getContentResolver(),
DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS, -1 /* default */); DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT, /* def= */ SETTING_VALUE_INVALID);
assertThat(mode).isEqualTo(SETTING_VALUE_ON);
}
@Test
public void onPreferenceChange_switchDisabled_disablesDesktopModeOnSecondaryDisplay() {
mController.onPreferenceChange(mPreference, /* newValue= */ false);
final int mode = Settings.Global.getInt(mContext.getContentResolver(),
DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS,
/* def= */ SETTING_VALUE_INVALID);
assertThat(mode).isEqualTo(SETTING_VALUE_OFF);
}
@Test
public void onPreferenceChange_switchDisabled_disablesFreeformSupport() {
mController.onPreferenceChange(mPreference, /* newValue= */ false);
final int mode = Settings.Global.getInt(mContext.getContentResolver(),
DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT, /* def= */ SETTING_VALUE_INVALID);
assertThat(mode).isEqualTo(SETTING_VALUE_OFF); assertThat(mode).isEqualTo(SETTING_VALUE_OFF);
} }
@@ -145,7 +167,8 @@ public class DesktopModeSecondaryDisplayPreferenceControllerTest {
mController.onDeveloperOptionsSwitchDisabled(); mController.onDeveloperOptionsSwitchDisabled();
final int mode = Settings.Global.getInt(mContext.getContentResolver(), final int mode = Settings.Global.getInt(mContext.getContentResolver(),
DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS, -1 /* default */); DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS,
/* def= */ SETTING_VALUE_INVALID);
assertThat(mode).isEqualTo(SETTING_VALUE_OFF); assertThat(mode).isEqualTo(SETTING_VALUE_OFF);
verify(mPreference).setEnabled(false); verify(mPreference).setEnabled(false);
} }