[Dev options] Conditionally show Freeform toggle: Only display when freeform is NOT available by default on the device.

Previously Freeform Toggle was a no-op when freeform was by default available on devices

On the other hand Desktop mode toggle is displayed only when freeform IS available by default on the device. (This is because desktop mode support is tied to devices with default freeform capability.)

Also update toggle strings for a clearer user experience

Test: Updated tests
Bug: 348193756
Bug: 348186127
Flag: com.android.window.flags.show_desktop_windowing_dev_option
Change-Id: I29e36a939db78010bb3153e756f95bb6c21a31f9
This commit is contained in:
Alina Zaidi
2024-07-22 14:31:04 +00:00
parent 5c466c5ba3
commit 9609216cb5
5 changed files with 41 additions and 44 deletions

View File

@@ -69,7 +69,8 @@ public class DesktopModeSecondaryDisplayPreferenceController extends
isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
if (isEnabled && mFragment != null) {
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;
}

View File

@@ -16,8 +16,9 @@
package com.android.settings.development;
import static android.content.pm.PackageManager.FEATURE_FREEFORM_WINDOW_MANAGEMENT;
import android.content.Context;
import android.os.Build;
import android.provider.Settings;
import androidx.annotation.Nullable;
@@ -40,7 +41,8 @@ public class FreeformWindowsPreferenceController extends DeveloperOptionsPrefere
@VisibleForTesting
static final int SETTING_VALUE_ON = 1;
@Nullable private final DevelopmentSettingsDashboardFragment mFragment;
@Nullable
private final DevelopmentSettingsDashboardFragment mFragment;
public FreeformWindowsPreferenceController(
Context context, @Nullable DevelopmentSettingsDashboardFragment fragment) {
@@ -48,6 +50,13 @@ public class FreeformWindowsPreferenceController extends DeveloperOptionsPrefere
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
public String getPreferenceKey() {
return ENABLE_FREEFORM_SUPPORT_KEY;
@@ -80,9 +89,4 @@ public class FreeformWindowsPreferenceController extends DeveloperOptionsPrefere
Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT, SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(false);
}
@VisibleForTesting
String getBuildType() {
return Build.TYPE;
}
}