Loading res/values/attrs.xml +2 −10 Original line number Diff line number Diff line Loading @@ -154,12 +154,7 @@ <attr name="demoModeLayoutId" format="reference" /> <attr name="isScalable" format="boolean" /> <attr name="devicePaddingId" format="reference" /> <attr name="gridEnabled" format="integer" > <!-- Enable on all devices; default value --> <enum name="all_displays" value="0" /> <!-- Enable on single display devices only --> <enum name="single_display" value="1" /> </attr> <attr name="gridEnabled" format="boolean" /> </declare-styleable> Loading Loading @@ -241,10 +236,7 @@ <attr name="twoPanelLandscapeIconTextSize" format="float" /> <!-- If set, this display option is used to determine the default grid --> <attr name="canBeDefault" format="boolean|integer" > <!-- The profile can be default on split display devices --> <flag name="split_display" value="0x2" /> </attr> <attr name="canBeDefault" format="boolean" /> <!-- Margin on left and right of the workspace when GridDisplayOption#isScalable is true --> <attr name="horizontalMargin" format="float"/> Loading res/xml/device_profiles.xml +1 −1 Original line number Diff line number Diff line Loading @@ -121,7 +121,7 @@ launcher:minHeightDps="694" launcher:iconImageSize="56" launcher:iconTextSize="14.4" launcher:canBeDefault="split_display" /> launcher:canBeDefault="true" /> <display-option launcher:name="Shorter Stubby" Loading res/xml/device_profiles_split.xml 0 → 100644 +137 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- 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. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <profiles xmlns:launcher="http://schemas.android.com/apk/res-auto" > <grid-option launcher:name="3_by_3" launcher:numRows="3" launcher:numColumns="3" launcher:numFolderRows="2" launcher:numFolderColumns="3" launcher:numHotseatIcons="3" launcher:dbFile="launcher_3_by_3.db" launcher:defaultLayoutId="@xml/default_workspace_3x3" > <display-option launcher:name="Super Short Stubby" launcher:minWidthDps="255" launcher:minHeightDps="300" launcher:iconImageSize="48" launcher:iconTextSize="13.0" launcher:canBeDefault="true" /> <display-option launcher:name="Shorter Stubby" launcher:minWidthDps="255" launcher:minHeightDps="400" launcher:iconImageSize="48" launcher:iconTextSize="13.0" launcher:canBeDefault="true" /> </grid-option> <grid-option launcher:name="4_by_4" launcher:numRows="4" launcher:numColumns="4" launcher:numFolderRows="3" launcher:numFolderColumns="4" launcher:numHotseatIcons="4" launcher:dbFile="launcher_4_by_4.db" launcher:defaultLayoutId="@xml/default_workspace_4x4" > <display-option launcher:name="Short Stubby" launcher:minWidthDps="275" launcher:minHeightDps="420" launcher:iconImageSize="48" launcher:iconTextSize="13.0" launcher:canBeDefault="true" /> <display-option launcher:name="Stubby" launcher:minWidthDps="255" launcher:minHeightDps="450" launcher:iconImageSize="48" launcher:iconTextSize="13.0" launcher:canBeDefault="true" /> <display-option launcher:name="Nexus S" launcher:minWidthDps="296" launcher:minHeightDps="491.33" launcher:iconImageSize="48" launcher:iconTextSize="13.0" launcher:canBeDefault="true" /> <display-option launcher:name="Nexus 4" launcher:minWidthDps="359" launcher:minHeightDps="567" launcher:iconImageSize="54" launcher:iconTextSize="13.0" launcher:canBeDefault="true" /> <display-option launcher:name="Nexus 5" launcher:minWidthDps="335" launcher:minHeightDps="567" launcher:iconImageSize="54" launcher:iconTextSize="13.0" launcher:canBeDefault="true" /> </grid-option> <grid-option launcher:name="5_by_5" launcher:numRows="5" launcher:numColumns="5" launcher:numFolderRows="4" launcher:numFolderColumns="4" launcher:numHotseatIcons="5" launcher:numExtendedHotseatIcons="8" launcher:dbFile="launcher.db" launcher:defaultLayoutId="@xml/default_workspace_5x5" > <display-option launcher:name="Large Phone" launcher:minWidthDps="406" launcher:minHeightDps="694" launcher:iconImageSize="56" launcher:iconTextSize="14.4" launcher:canBeDefault="true" /> <display-option launcher:name="Large Phone Split Display" launcher:minWidthDps="406" launcher:minHeightDps="694" launcher:iconImageSize="56" launcher:iconTextSize="14.4" launcher:canBeDefault="true" /> <display-option launcher:name="Shorter Stubby" launcher:minWidthDps="255" launcher:minHeightDps="400" launcher:iconImageSize="48" launcher:iconTextSize="13.0" launcher:canBeDefault="true" /> </grid-option> </profiles> No newline at end of file src/com/android/launcher3/InvariantDeviceProfile.java +12 −20 Original line number Diff line number Diff line /* * 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. Loading Loading @@ -70,11 +70,6 @@ public class InvariantDeviceProfile { public static final MainThreadInitializedObject<InvariantDeviceProfile> 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; Loading Loading @@ -393,7 +388,9 @@ public class InvariantDeviceProfile { private static ArrayList<DisplayOption> getPredefinedDeviceProfiles( Context context, String gridName, boolean isSplitDisplay, boolean allowDisabledGrid) { ArrayList<DisplayOption> 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 || Loading @@ -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))); } } } Loading Loading @@ -450,7 +446,9 @@ public class InvariantDeviceProfile { */ public List<GridOption> parseAllGridOptions(Context context) { List<GridOption> 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 Loading Loading @@ -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, Loading @@ -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; Loading Loading
res/values/attrs.xml +2 −10 Original line number Diff line number Diff line Loading @@ -154,12 +154,7 @@ <attr name="demoModeLayoutId" format="reference" /> <attr name="isScalable" format="boolean" /> <attr name="devicePaddingId" format="reference" /> <attr name="gridEnabled" format="integer" > <!-- Enable on all devices; default value --> <enum name="all_displays" value="0" /> <!-- Enable on single display devices only --> <enum name="single_display" value="1" /> </attr> <attr name="gridEnabled" format="boolean" /> </declare-styleable> Loading Loading @@ -241,10 +236,7 @@ <attr name="twoPanelLandscapeIconTextSize" format="float" /> <!-- If set, this display option is used to determine the default grid --> <attr name="canBeDefault" format="boolean|integer" > <!-- The profile can be default on split display devices --> <flag name="split_display" value="0x2" /> </attr> <attr name="canBeDefault" format="boolean" /> <!-- Margin on left and right of the workspace when GridDisplayOption#isScalable is true --> <attr name="horizontalMargin" format="float"/> Loading
res/xml/device_profiles.xml +1 −1 Original line number Diff line number Diff line Loading @@ -121,7 +121,7 @@ launcher:minHeightDps="694" launcher:iconImageSize="56" launcher:iconTextSize="14.4" launcher:canBeDefault="split_display" /> launcher:canBeDefault="true" /> <display-option launcher:name="Shorter Stubby" Loading
res/xml/device_profiles_split.xml 0 → 100644 +137 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- 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. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <profiles xmlns:launcher="http://schemas.android.com/apk/res-auto" > <grid-option launcher:name="3_by_3" launcher:numRows="3" launcher:numColumns="3" launcher:numFolderRows="2" launcher:numFolderColumns="3" launcher:numHotseatIcons="3" launcher:dbFile="launcher_3_by_3.db" launcher:defaultLayoutId="@xml/default_workspace_3x3" > <display-option launcher:name="Super Short Stubby" launcher:minWidthDps="255" launcher:minHeightDps="300" launcher:iconImageSize="48" launcher:iconTextSize="13.0" launcher:canBeDefault="true" /> <display-option launcher:name="Shorter Stubby" launcher:minWidthDps="255" launcher:minHeightDps="400" launcher:iconImageSize="48" launcher:iconTextSize="13.0" launcher:canBeDefault="true" /> </grid-option> <grid-option launcher:name="4_by_4" launcher:numRows="4" launcher:numColumns="4" launcher:numFolderRows="3" launcher:numFolderColumns="4" launcher:numHotseatIcons="4" launcher:dbFile="launcher_4_by_4.db" launcher:defaultLayoutId="@xml/default_workspace_4x4" > <display-option launcher:name="Short Stubby" launcher:minWidthDps="275" launcher:minHeightDps="420" launcher:iconImageSize="48" launcher:iconTextSize="13.0" launcher:canBeDefault="true" /> <display-option launcher:name="Stubby" launcher:minWidthDps="255" launcher:minHeightDps="450" launcher:iconImageSize="48" launcher:iconTextSize="13.0" launcher:canBeDefault="true" /> <display-option launcher:name="Nexus S" launcher:minWidthDps="296" launcher:minHeightDps="491.33" launcher:iconImageSize="48" launcher:iconTextSize="13.0" launcher:canBeDefault="true" /> <display-option launcher:name="Nexus 4" launcher:minWidthDps="359" launcher:minHeightDps="567" launcher:iconImageSize="54" launcher:iconTextSize="13.0" launcher:canBeDefault="true" /> <display-option launcher:name="Nexus 5" launcher:minWidthDps="335" launcher:minHeightDps="567" launcher:iconImageSize="54" launcher:iconTextSize="13.0" launcher:canBeDefault="true" /> </grid-option> <grid-option launcher:name="5_by_5" launcher:numRows="5" launcher:numColumns="5" launcher:numFolderRows="4" launcher:numFolderColumns="4" launcher:numHotseatIcons="5" launcher:numExtendedHotseatIcons="8" launcher:dbFile="launcher.db" launcher:defaultLayoutId="@xml/default_workspace_5x5" > <display-option launcher:name="Large Phone" launcher:minWidthDps="406" launcher:minHeightDps="694" launcher:iconImageSize="56" launcher:iconTextSize="14.4" launcher:canBeDefault="true" /> <display-option launcher:name="Large Phone Split Display" launcher:minWidthDps="406" launcher:minHeightDps="694" launcher:iconImageSize="56" launcher:iconTextSize="14.4" launcher:canBeDefault="true" /> <display-option launcher:name="Shorter Stubby" launcher:minWidthDps="255" launcher:minHeightDps="400" launcher:iconImageSize="48" launcher:iconTextSize="13.0" launcher:canBeDefault="true" /> </grid-option> </profiles> No newline at end of file
src/com/android/launcher3/InvariantDeviceProfile.java +12 −20 Original line number Diff line number Diff line /* * 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. Loading Loading @@ -70,11 +70,6 @@ public class InvariantDeviceProfile { public static final MainThreadInitializedObject<InvariantDeviceProfile> 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; Loading Loading @@ -393,7 +388,9 @@ public class InvariantDeviceProfile { private static ArrayList<DisplayOption> getPredefinedDeviceProfiles( Context context, String gridName, boolean isSplitDisplay, boolean allowDisabledGrid) { ArrayList<DisplayOption> 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 || Loading @@ -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))); } } } Loading Loading @@ -450,7 +446,9 @@ public class InvariantDeviceProfile { */ public List<GridOption> parseAllGridOptions(Context context) { List<GridOption> 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 Loading Loading @@ -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, Loading @@ -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; Loading