Support desktop device category in grid options

Adds desktop enum value to grid option deviceCategory attribute type.
The device type is used for devices that have
`R.bool.desktop_form_factor` config value set.

Bug: 30153091
Flag: com.android.launcher3.enable_scalability_for_desktop_experience
Test: Manual
Change-Id: Ie4747b5bae3e124e914af51445778c9b6285ff66
This commit is contained in:
Ana Salazar
2025-01-23 00:23:36 +00:00
committed by Toni Barzic
parent 37437bafc5
commit 501df846c4
3 changed files with 20 additions and 2 deletions
+2
View File
@@ -296,6 +296,8 @@
<flag name="tablet" value="2" />
<!-- Enable on multi display devices only -->
<flag name="multi_display" value="4" />
<!-- Enable on desktop devices only -->
<flag name="desktop" value="8" />
</attr>
<!-- By default all are false -->
@@ -106,13 +106,14 @@ public class InvariantDeviceProfile {
"idp_non_fixed_landscape_grid_name";
@Retention(RetentionPolicy.SOURCE)
@IntDef({TYPE_PHONE, TYPE_MULTI_DISPLAY, TYPE_TABLET})
@IntDef({TYPE_PHONE, TYPE_MULTI_DISPLAY, TYPE_TABLET, TYPE_DESKTOP})
public @interface DeviceType {
}
public static final int TYPE_PHONE = 0;
public static final int TYPE_MULTI_DISPLAY = 1;
public static final int TYPE_TABLET = 2;
public static final int TYPE_DESKTOP = 3;
private static final float ICON_SIZE_DEFINED_IN_APP_DP = 48;
@@ -1008,8 +1009,10 @@ public class InvariantDeviceProfile {
private static final int DEVICE_CATEGORY_PHONE = 1 << 0;
private static final int DEVICE_CATEGORY_TABLET = 1 << 1;
private static final int DEVICE_CATEGORY_MULTI_DISPLAY = 1 << 2;
private static final int DEVICE_CATEGORY_DESKTOP = 1 << 3;
private static final int DEVICE_CATEGORY_ANY =
DEVICE_CATEGORY_PHONE | DEVICE_CATEGORY_TABLET | DEVICE_CATEGORY_MULTI_DISPLAY;
DEVICE_CATEGORY_PHONE | DEVICE_CATEGORY_TABLET | DEVICE_CATEGORY_MULTI_DISPLAY
| DEVICE_CATEGORY_DESKTOP;
private static final int INLINE_QSB_FOR_PORTRAIT = 1 << 0;
private static final int INLINE_QSB_FOR_LANDSCAPE = 1 << 1;
@@ -1234,6 +1237,9 @@ public class InvariantDeviceProfile {
case TYPE_MULTI_DISPLAY:
return (deviceCategory & DEVICE_CATEGORY_MULTI_DISPLAY)
== DEVICE_CATEGORY_MULTI_DISPLAY;
case TYPE_DESKTOP:
return (deviceCategory & DEVICE_CATEGORY_DESKTOP)
== DEVICE_CATEGORY_DESKTOP;
default:
return false;
}
@@ -18,6 +18,8 @@ package com.android.launcher3.util;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
import static com.android.launcher3.Flags.enableScalabilityForDesktopExperience;
import static com.android.launcher3.InvariantDeviceProfile.TYPE_DESKTOP;
import static com.android.launcher3.InvariantDeviceProfile.TYPE_MULTI_DISPLAY;
import static com.android.launcher3.InvariantDeviceProfile.TYPE_PHONE;
import static com.android.launcher3.InvariantDeviceProfile.TYPE_TABLET;
@@ -53,6 +55,7 @@ import androidx.annotation.VisibleForTesting;
import com.android.launcher3.InvariantDeviceProfile.DeviceType;
import com.android.launcher3.LauncherPrefChangeListener;
import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.dagger.ApplicationContext;
import com.android.launcher3.dagger.LauncherAppComponent;
@@ -507,6 +510,7 @@ public class DisplayController implements DesktopVisibilityListener {
private final boolean mShowLockedTaskbarOnHome;
private final boolean mIsHomeVisible;
private final boolean mIsDesktopFormFactor;
private final boolean mShowDesktopTaskbarForFreeformDisplay;
@@ -573,6 +577,8 @@ public class DisplayController implements DesktopVisibilityListener {
mShowDesktopTaskbarForFreeformDisplay = wmProxy.showDesktopTaskbarForFreeformDisplay(
displayInfoContext);
mIsHomeVisible = wmProxy.isHomeVisible();
mIsDesktopFormFactor = enableScalabilityForDesktopExperience()
&& displayInfoContext.getResources().getBoolean(R.bool.desktop_form_factor);
}
/**
@@ -657,6 +663,10 @@ public class DisplayController implements DesktopVisibilityListener {
}
public @DeviceType int getDeviceType() {
if (mIsDesktopFormFactor) {
return TYPE_DESKTOP;
}
int flagPhone = 1 << 0;
int flagTablet = 1 << 1;