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:
Treehugger Robot
2024-07-22 20:34:19 +00:00
committed by Android (Google) Code Review
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;
}
}