diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 92aa6784e8..08f0089438 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -154,12 +154,7 @@ - - - - - - + @@ -241,10 +236,7 @@ - - - - + diff --git a/res/xml/device_profiles.xml b/res/xml/device_profiles.xml index 256999cd7f..e030f81098 100644 --- a/res/xml/device_profiles.xml +++ b/res/xml/device_profiles.xml @@ -121,7 +121,7 @@ launcher:minHeightDps="694" launcher:iconImageSize="56" launcher:iconTextSize="14.4" - launcher:canBeDefault="split_display" /> + launcher:canBeDefault="true" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 1b2f177ff2..d844b877a7 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 The Android Open Source Project + * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -70,11 +70,6 @@ public class InvariantDeviceProfile { public static final MainThreadInitializedObject INSTANCE = new MainThreadInitializedObject<>(InvariantDeviceProfile::new); - private static final int DEFAULT_TRUE = -1; - private static final int DEFAULT_SPLIT_DISPLAY = 2; - private static final int GRID_ENABLED_ALL_DISPLAYS = 0; - private static final int GRID_ENABLED_SINGLE_DISPLAY = 1; - private static final String KEY_IDP_GRID_NAME = "idp_grid_name"; private static final float ICON_SIZE_DEFINED_IN_APP_DP = 48; @@ -393,7 +388,9 @@ public class InvariantDeviceProfile { private static ArrayList getPredefinedDeviceProfiles( Context context, String gridName, boolean isSplitDisplay, boolean allowDisabledGrid) { ArrayList profiles = new ArrayList<>(); - try (XmlResourceParser parser = context.getResources().getXml(R.xml.device_profiles)) { + int xmlResource = isSplitDisplay ? R.xml.device_profiles_split : R.xml.device_profiles; + + try (XmlResourceParser parser = context.getResources().getXml(xmlResource)) { final int depth = parser.getDepth(); int type; while (((type = parser.next()) != XmlPullParser.END_TAG || @@ -411,8 +408,7 @@ public class InvariantDeviceProfile { if ((type == XmlPullParser.START_TAG) && "display-option".equals( parser.getName())) { profiles.add(new DisplayOption(gridOption, context, - Xml.asAttributeSet(parser), - isSplitDisplay ? DEFAULT_SPLIT_DISPLAY : DEFAULT_TRUE)); + Xml.asAttributeSet(parser))); } } } @@ -450,7 +446,9 @@ public class InvariantDeviceProfile { */ public List parseAllGridOptions(Context context) { List result = new ArrayList<>(); - try (XmlResourceParser parser = context.getResources().getXml(R.xml.device_profiles)) { + int xmlResource = isSplitDisplay ? R.xml.device_profiles_split : R.xml.device_profiles; + + try (XmlResourceParser parser = context.getResources().getXml(xmlResource)) { final int depth = parser.getDepth(); int type; while (((type = parser.next()) != XmlPullParser.END_TAG @@ -702,11 +700,7 @@ public class InvariantDeviceProfile { devicePaddingId = a.getResourceId( R.styleable.GridDisplayOption_devicePaddingId, 0); - final int enabledInt = - a.getInteger(R.styleable.GridDisplayOption_gridEnabled, - GRID_ENABLED_ALL_DISPLAYS); - isEnabled = enabledInt == GRID_ENABLED_ALL_DISPLAYS - || enabledInt == GRID_ENABLED_SINGLE_DISPLAY && !isSplitDisplay; + isEnabled = a.getBoolean(R.styleable.GridDisplayOption_gridEnabled, true); a.recycle(); extraAttrs = Themes.createValueMap(context, attrs, @@ -732,17 +726,15 @@ public class InvariantDeviceProfile { private final float[] iconSizes = new float[COUNT_SIZES]; private final float[] textSizes = new float[COUNT_SIZES]; - DisplayOption(GridOption grid, Context context, AttributeSet attrs, int defaultFlagValue) { + DisplayOption(GridOption grid, Context context, AttributeSet attrs) { this.grid = grid; - TypedArray a = context.obtainStyledAttributes( - attrs, R.styleable.ProfileDisplayOption); + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ProfileDisplayOption); minWidthDps = a.getFloat(R.styleable.ProfileDisplayOption_minWidthDps, 0); minHeightDps = a.getFloat(R.styleable.ProfileDisplayOption_minHeightDps, 0); - canBeDefault = a.getInt(R.styleable.ProfileDisplayOption_canBeDefault, 0) - == defaultFlagValue; + canBeDefault = a.getBoolean(R.styleable.ProfileDisplayOption_canBeDefault, false); float x; float y;