Merge "[Dev options] Conditionally show Freeform toggle: Only display when freeform is NOT available by default on the device." into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
0dcf3ff102
@@ -12240,16 +12240,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 enabling freeform windows (desktop mode) developer option toggle [CHAR LIMIT=50] -->
|
<!-- Title for a toggle that enables freeform windowing experiences. Freeform windowing experiences are features involving apps running in resizable windows. [CHAR LIMIT=50] -->
|
||||||
<string name="enable_desktop_mode">Enable freeform windows</string>
|
<string name="enable_desktop_mode">Enable freeform windowing experiences</string>
|
||||||
<!-- Summary for enabling freeform windows (desktop mode) developer option toggle [CHAR LIMIT=NONE] -->
|
|
||||||
<string name="enable_desktop_mode_summary">Enable support for freeform windows.</string>
|
|
||||||
|
|
||||||
<!-- TODO(b/348193756): Rename resources for this toggle to indicate that it is for secondary display -->
|
<!-- Title for a toggle that enables desktop mode on secondary display. [CHAR LIMIT=50] -->
|
||||||
<!-- Title for enabling freeform windows (desktop mode) on secondary display developer option toggle [CHAR LIMIT=50] -->
|
<string name="enable_desktop_mode_on_secondary_display">Enable desktop mode on secondary display</string>
|
||||||
<string name="force_desktop_mode">Enable freeform windowing on second display</string>
|
|
||||||
<!-- Summary for enabling freeform windows (desktop mode) on secondary display developer option toggle [CHAR LIMIT=NONE] -->
|
|
||||||
<string name="force_desktop_mode_summary">Enable freeform windows only 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>
|
||||||
@@ -13212,14 +13207,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 support for
|
<!-- 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] -->
|
||||||
it to work [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 legacy freeform windowing 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 overriding freeform windowing (desktop mode) support. [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 change freeform windowing support.</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 forcing freeform windowing (desktop mode) on
|
<string name="reboot_dialog_enable_desktop_mode_on_secondary_display">A reboot is required to enable desktop mode on secondary displays.</string>
|
||||||
secondary displays. [CHAR LIMIT=none] -->
|
|
||||||
<string name="reboot_dialog_force_desktop_mode">A reboot is required to force freeform windowing 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] -->
|
||||||
|
@@ -739,18 +739,15 @@
|
|||||||
|
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
android:key="override_desktop_mode_features"
|
android:key="override_desktop_mode_features"
|
||||||
android:title="@string/enable_desktop_mode"
|
android:title="@string/enable_desktop_mode" />
|
||||||
android:summary="@string/enable_desktop_mode_summary" />
|
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
android:key="enable_freeform_support"
|
android:key="enable_freeform_support"
|
||||||
android:title="@string/enable_freeform_support"
|
android:title="@string/enable_freeform_support" />
|
||||||
android:summary="@string/enable_freeform_support_summary" />
|
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
android:key="force_desktop_mode_on_external_displays"
|
android:key="force_desktop_mode_on_external_displays"
|
||||||
android:title="@string/force_desktop_mode"
|
android:title="@string/enable_desktop_mode_on_secondary_display"/>
|
||||||
android:summary="@string/force_desktop_mode_summary" />
|
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
android:key="enable_non_resizable_multi_window"
|
android:key="enable_non_resizable_multi_window"
|
||||||
|
@@ -69,7 +69,8 @@ public class DesktopModeSecondaryDisplayPreferenceController extends
|
|||||||
isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
|
isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
|
||||||
if (isEnabled && mFragment != null) {
|
if (isEnabled && mFragment != null) {
|
||||||
RebootConfirmationDialogFragment.show(
|
RebootConfirmationDialogFragment.show(
|
||||||
mFragment, R.string.reboot_dialog_force_desktop_mode, this);
|
mFragment, R.string.reboot_dialog_enable_desktop_mode_on_secondary_display,
|
||||||
|
this);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,9 @@
|
|||||||
|
|
||||||
package com.android.settings.development;
|
package com.android.settings.development;
|
||||||
|
|
||||||
|
import static android.content.pm.PackageManager.FEATURE_FREEFORM_WINDOW_MANAGEMENT;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Build;
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@@ -40,7 +41,8 @@ public class FreeformWindowsPreferenceController extends DeveloperOptionsPrefere
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final int SETTING_VALUE_ON = 1;
|
static final int SETTING_VALUE_ON = 1;
|
||||||
|
|
||||||
@Nullable private final DevelopmentSettingsDashboardFragment mFragment;
|
@Nullable
|
||||||
|
private final DevelopmentSettingsDashboardFragment mFragment;
|
||||||
|
|
||||||
public FreeformWindowsPreferenceController(
|
public FreeformWindowsPreferenceController(
|
||||||
Context context, @Nullable DevelopmentSettingsDashboardFragment fragment) {
|
Context context, @Nullable DevelopmentSettingsDashboardFragment fragment) {
|
||||||
@@ -48,6 +50,13 @@ public class FreeformWindowsPreferenceController extends DeveloperOptionsPrefere
|
|||||||
mFragment = fragment;
|
mFragment = fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAvailable() {
|
||||||
|
// When devices have the system feature FEATURE_FREEFORM_WINDOW_MANAGEMENT, freeform
|
||||||
|
// mode is enabled automatically, and this toggle is not needed.
|
||||||
|
return !mContext.getPackageManager().hasSystemFeature(FEATURE_FREEFORM_WINDOW_MANAGEMENT);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPreferenceKey() {
|
public String getPreferenceKey() {
|
||||||
return ENABLE_FREEFORM_SUPPORT_KEY;
|
return ENABLE_FREEFORM_SUPPORT_KEY;
|
||||||
@@ -80,9 +89,4 @@ public class FreeformWindowsPreferenceController extends DeveloperOptionsPrefere
|
|||||||
Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT, SETTING_VALUE_OFF);
|
Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT, SETTING_VALUE_OFF);
|
||||||
((TwoStatePreference) mPreference).setChecked(false);
|
((TwoStatePreference) mPreference).setChecked(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
String getBuildType() {
|
|
||||||
return Build.TYPE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,9 @@
|
|||||||
|
|
||||||
package com.android.settings.development;
|
package com.android.settings.development;
|
||||||
|
|
||||||
import static com.android.settings.development.FreeformWindowsPreferenceController
|
import static android.content.pm.PackageManager.FEATURE_FREEFORM_WINDOW_MANAGEMENT;
|
||||||
.SETTING_VALUE_OFF;
|
|
||||||
|
import static com.android.settings.development.FreeformWindowsPreferenceController.SETTING_VALUE_OFF;
|
||||||
import static com.android.settings.development.FreeformWindowsPreferenceController.SETTING_VALUE_ON;
|
import static com.android.settings.development.FreeformWindowsPreferenceController.SETTING_VALUE_ON;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
@@ -29,6 +30,7 @@ import static org.mockito.Mockito.verify;
|
|||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
@@ -43,7 +45,6 @@ import org.junit.runner.RunWith;
|
|||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
|
||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@@ -52,9 +53,10 @@ import org.robolectric.annotation.Config;
|
|||||||
})
|
})
|
||||||
public class FreeformWindowsPreferenceControllerTest {
|
public class FreeformWindowsPreferenceControllerTest {
|
||||||
|
|
||||||
private static final String ENG_BUILD_TYPE = "eng";
|
@Mock
|
||||||
private static final String USER_BUILD_TYPE = "user";
|
Context mContext;
|
||||||
|
@Mock
|
||||||
|
private PackageManager mPackageManager;
|
||||||
@Mock
|
@Mock
|
||||||
private SwitchPreference mPreference;
|
private SwitchPreference mPreference;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -68,33 +70,33 @@ public class FreeformWindowsPreferenceControllerTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private FragmentTransaction mTransaction;
|
private FragmentTransaction mTransaction;
|
||||||
|
|
||||||
private Context mContext;
|
|
||||||
private FreeformWindowsPreferenceController mController;
|
private FreeformWindowsPreferenceController mController;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = RuntimeEnvironment.application;
|
|
||||||
doReturn(mTransaction).when(mFragmentManager).beginTransaction();
|
doReturn(mTransaction).when(mFragmentManager).beginTransaction();
|
||||||
doReturn(mFragmentManager).when(mActivity).getSupportFragmentManager();
|
doReturn(mFragmentManager).when(mActivity).getSupportFragmentManager();
|
||||||
doReturn(mActivity).when(mFragment).getActivity();
|
doReturn(mActivity).when(mFragment).getActivity();
|
||||||
mController = new FreeformWindowsPreferenceController(mContext, mFragment);
|
mController = new FreeformWindowsPreferenceController(mContext, mFragment);
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
|
when(mContext.getPackageManager()).thenReturn(mPackageManager);
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isAvailable_engBuild_shouldBeTrue() {
|
public void isAvailable_deviceHasFreeformWindowSystemFeature_returnsFalse() {
|
||||||
mController = spy(mController);
|
mController = spy(mController);
|
||||||
doReturn(ENG_BUILD_TYPE).when(mController).getBuildType();
|
when(mPackageManager.hasSystemFeature(FEATURE_FREEFORM_WINDOW_MANAGEMENT)).thenReturn(true);
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isTrue();
|
assertThat(mController.isAvailable()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isAvailable_userBuild_shouldBeTrue() {
|
public void isAvailable_deviceDoesNotHaveFreeformWindowSystemFeature_returnsTrue() {
|
||||||
mController = spy(mController);
|
mController = spy(mController);
|
||||||
doReturn(USER_BUILD_TYPE).when(mController).getBuildType();
|
when(mPackageManager.hasSystemFeature(FEATURE_FREEFORM_WINDOW_MANAGEMENT)).thenReturn(
|
||||||
|
false);
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isTrue();
|
assertThat(mController.isAvailable()).isTrue();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user