Moving the resources related to PiP to the WindowManager/Shell.
Test: Test: atest WMShellUnitTests:PipBoundsAlgorithmTest Bug: 218653892 Change-Id: Ieeff465e04cbd1bfc3ddfc47f38e11eefa9e798d
This commit is contained in:
@@ -24,19 +24,6 @@
|
||||
<!-- Flags enabling default window features. See Window.java -->
|
||||
<bool name="config_defaultWindowFeatureOptionsPanel">false</bool>
|
||||
|
||||
<!-- The percentage of the screen width to use for the default width or height of
|
||||
picture-in-picture windows. Regardless of the percent set here, calculated size will never
|
||||
be smaller than @dimen/default_minimal_size_pip_resizable_task. -->
|
||||
<item name="config_pictureInPictureDefaultSizePercent" format="float" type="dimen">0.2</item>
|
||||
|
||||
<!-- Default insets [LEFT/RIGHTxTOP/BOTTOM] from the screen edge for picture-in-picture windows.
|
||||
These values are in DPs and will be converted to pixel sizes internally. -->
|
||||
<string translatable="false" name="config_defaultPictureInPictureScreenEdgeInsets">24x24</string>
|
||||
|
||||
<!-- The default gravity for the picture-in-picture window.
|
||||
Currently, this maps to Gravity.BOTTOM | Gravity.RIGHT -->
|
||||
<integer name="config_defaultPictureInPictureGravity">0x55</integer>
|
||||
|
||||
<!-- The maximum height of the expanded horizontal picture-in-picture window -->
|
||||
<item name="config_pictureInPictureExpandedHorizontalHeight"
|
||||
format="dimension" type="dimen">110dp</item>
|
||||
|
||||
@@ -3704,26 +3704,6 @@
|
||||
snapped to any position between the first target and the last target. -->
|
||||
<bool name="config_dockedStackDividerFreeSnapMode">false</bool>
|
||||
|
||||
<!-- Default insets [LEFT/RIGHTxTOP/BOTTOM] from the screen edge for picture-in-picture windows.
|
||||
These values are in DPs and will be converted to pixel sizes internally. -->
|
||||
<string translatable="false" name="config_defaultPictureInPictureScreenEdgeInsets">16x16</string>
|
||||
|
||||
<!-- The percentage of the screen width to use for the default width or height of
|
||||
picture-in-picture windows. Regardless of the percent set here, calculated size will never
|
||||
be smaller than @dimen/default_minimal_size_pip_resizable_task. -->
|
||||
<item name="config_pictureInPictureDefaultSizePercent" format="float" type="dimen">0.23</item>
|
||||
|
||||
<!-- The default aspect ratio for picture-in-picture windows. -->
|
||||
<item name="config_pictureInPictureDefaultAspectRatio" format="float" type="dimen">1.777778</item>
|
||||
|
||||
<!-- This is the limit for the max and min aspect ratio (1 / this value) at which the min size
|
||||
will be used instead of an adaptive size based loosely on area. -->
|
||||
<item name="config_pictureInPictureAspectRatioLimitForMinSize" format="float" type="dimen">1.777778</item>
|
||||
|
||||
<!-- The default gravity for the picture-in-picture window.
|
||||
Currently, this maps to Gravity.BOTTOM | Gravity.RIGHT -->
|
||||
<integer name="config_defaultPictureInPictureGravity">0x55</integer>
|
||||
|
||||
<!-- The minimum aspect ratio (width/height) that is supported for picture-in-picture. Any
|
||||
ratio smaller than this is considered too tall and thin to be usable. Currently, this
|
||||
is the inverse of the max landscape aspect ratio (1:2.39), but this is an extremely
|
||||
|
||||
@@ -714,16 +714,6 @@
|
||||
<!-- The default minimal size of a resizable task, in both dimensions. -->
|
||||
<dimen name="default_minimal_size_resizable_task">220dp</dimen>
|
||||
|
||||
<!-- The default minimal size of a PiP task, in both dimensions. -->
|
||||
<dimen name="default_minimal_size_pip_resizable_task">108dp</dimen>
|
||||
|
||||
<!--
|
||||
The overridable minimal size of a PiP task, in both dimensions.
|
||||
Different from default_minimal_size_pip_resizable_task, this is to limit the dimension
|
||||
when the pinned stack size is overridden by app via minWidth/minHeight.
|
||||
-->
|
||||
<dimen name="overridable_minimal_size_pip_resizable_task">48dp</dimen>
|
||||
|
||||
<!-- Height of a task when in minimized mode from the top when launcher is resizable. -->
|
||||
<dimen name="task_height_of_minimized_mode">80dp</dimen>
|
||||
|
||||
|
||||
@@ -408,11 +408,6 @@
|
||||
<java-symbol type="array" name="config_localPrivateDisplayPorts" />
|
||||
<java-symbol type="integer" name="config_defaultDisplayDefaultColorMode" />
|
||||
<java-symbol type="bool" name="config_enableAppWidgetService" />
|
||||
<java-symbol type="string" name="config_defaultPictureInPictureScreenEdgeInsets" />
|
||||
<java-symbol type="dimen" name="config_pictureInPictureDefaultSizePercent" />
|
||||
<java-symbol type="dimen" name="config_pictureInPictureDefaultAspectRatio" />
|
||||
<java-symbol type="dimen" name="config_pictureInPictureAspectRatioLimitForMinSize" />
|
||||
<java-symbol type="integer" name="config_defaultPictureInPictureGravity" />
|
||||
<java-symbol type="dimen" name="config_pictureInPictureMinAspectRatio" />
|
||||
<java-symbol type="dimen" name="config_pictureInPictureMaxAspectRatio" />
|
||||
<java-symbol type="integer" name="config_pictureInPictureMaxNumberOfActions" />
|
||||
@@ -2015,8 +2010,6 @@
|
||||
<java-symbol type="id" name="replace_message" />
|
||||
<java-symbol type="fraction" name="config_dimBehindFadeDuration" />
|
||||
<java-symbol type="dimen" name="default_minimal_size_resizable_task" />
|
||||
<java-symbol type="dimen" name="default_minimal_size_pip_resizable_task" />
|
||||
<java-symbol type="dimen" name="overridable_minimal_size_pip_resizable_task" />
|
||||
<java-symbol type="dimen" name="task_height_of_minimized_mode" />
|
||||
<java-symbol type="fraction" name="config_screenAutoBrightnessDozeScaleFactor" />
|
||||
<java-symbol type="bool" name="config_allowPriorityVibrationsInLowPowerMode" />
|
||||
|
||||
36
libs/WindowManager/Shell/res/values-television/config.xml
Normal file
36
libs/WindowManager/Shell/res/values-television/config.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2022 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.
|
||||
-->
|
||||
|
||||
<!-- These resources are around just to allow their values to be customized
|
||||
for TV products. Do not translate. -->
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
|
||||
<!-- The percentage of the screen width to use for the default width or height of
|
||||
picture-in-picture windows. Regardless of the percent set here, calculated size will never
|
||||
be smaller than @dimen/default_minimal_size_pip_resizable_task. -->
|
||||
<item name="config_pictureInPictureDefaultSizePercent" format="float" type="dimen">0.2</item>
|
||||
|
||||
<!-- Default insets [LEFT/RIGHTxTOP/BOTTOM] from the screen edge for picture-in-picture windows.
|
||||
These values are in DPs and will be converted to pixel sizes internally. -->
|
||||
<string translatable="false" name="config_defaultPictureInPictureScreenEdgeInsets">
|
||||
24x24
|
||||
</string>
|
||||
|
||||
<!-- The default gravity for the picture-in-picture window.
|
||||
Currently, this maps to Gravity.BOTTOM | Gravity.RIGHT -->
|
||||
<integer name="config_defaultPictureInPictureGravity">0x55</integer>
|
||||
</resources>
|
||||
@@ -70,4 +70,30 @@
|
||||
|
||||
<!-- Animation duration when exit starting window: reveal app -->
|
||||
<integer name="starting_window_app_reveal_anim_duration">266</integer>
|
||||
|
||||
<!-- Default insets [LEFT/RIGHTxTOP/BOTTOM] from the screen edge for picture-in-picture windows.
|
||||
These values are in DPs and will be converted to pixel sizes internally. -->
|
||||
<string translatable="false" name="config_defaultPictureInPictureScreenEdgeInsets">
|
||||
16x16
|
||||
</string>
|
||||
|
||||
<!-- The percentage of the screen width to use for the default width or height of
|
||||
picture-in-picture windows. Regardless of the percent set here, calculated size will never
|
||||
be smaller than @dimen/default_minimal_size_pip_resizable_task. -->
|
||||
<item name="config_pictureInPictureDefaultSizePercent" format="float" type="dimen">0.23</item>
|
||||
|
||||
<!-- The default aspect ratio for picture-in-picture windows. -->
|
||||
<item name="config_pictureInPictureDefaultAspectRatio" format="float" type="dimen">
|
||||
1.777778
|
||||
</item>
|
||||
|
||||
<!-- This is the limit for the max and min aspect ratio (1 / this value) at which the min size
|
||||
will be used instead of an adaptive size based loosely on area. -->
|
||||
<item name="config_pictureInPictureAspectRatioLimitForMinSize" format="float" type="dimen">
|
||||
1.777778
|
||||
</item>
|
||||
|
||||
<!-- The default gravity for the picture-in-picture window.
|
||||
Currently, this maps to Gravity.BOTTOM | Gravity.RIGHT -->
|
||||
<integer name="config_defaultPictureInPictureGravity">0x55</integer>
|
||||
</resources>
|
||||
|
||||
@@ -251,4 +251,14 @@
|
||||
|
||||
<!-- The distance of the shift icon when early exit starting window. -->
|
||||
<dimen name="starting_surface_early_exit_icon_distance">32dp</dimen>
|
||||
|
||||
<!-- The default minimal size of a PiP task, in both dimensions. -->
|
||||
<dimen name="default_minimal_size_pip_resizable_task">108dp</dimen>
|
||||
|
||||
<!--
|
||||
The overridable minimal size of a PiP task, in both dimensions.
|
||||
Different from default_minimal_size_pip_resizable_task, this is to limit the dimension
|
||||
when the pinned stack size is overridden by app via minWidth/minHeight.
|
||||
-->
|
||||
<dimen name="overridable_minimal_size_pip_resizable_task">48dp</dimen>
|
||||
</resources>
|
||||
|
||||
@@ -32,6 +32,7 @@ import android.util.Size;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
|
||||
import com.android.wm.shell.R;
|
||||
import com.android.wm.shell.common.DisplayLayout;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
@@ -76,15 +77,15 @@ public class PipBoundsAlgorithm {
|
||||
protected void reloadResources(Context context) {
|
||||
final Resources res = context.getResources();
|
||||
mDefaultAspectRatio = res.getFloat(
|
||||
com.android.internal.R.dimen.config_pictureInPictureDefaultAspectRatio);
|
||||
R.dimen.config_pictureInPictureDefaultAspectRatio);
|
||||
mDefaultStackGravity = res.getInteger(
|
||||
com.android.internal.R.integer.config_defaultPictureInPictureGravity);
|
||||
R.integer.config_defaultPictureInPictureGravity);
|
||||
mDefaultMinSize = res.getDimensionPixelSize(
|
||||
com.android.internal.R.dimen.default_minimal_size_pip_resizable_task);
|
||||
R.dimen.default_minimal_size_pip_resizable_task);
|
||||
mOverridableMinSize = res.getDimensionPixelSize(
|
||||
com.android.internal.R.dimen.overridable_minimal_size_pip_resizable_task);
|
||||
R.dimen.overridable_minimal_size_pip_resizable_task);
|
||||
final String screenEdgeInsetsDpString = res.getString(
|
||||
com.android.internal.R.string.config_defaultPictureInPictureScreenEdgeInsets);
|
||||
R.string.config_defaultPictureInPictureScreenEdgeInsets);
|
||||
final Size screenEdgeInsetsDp = !screenEdgeInsetsDpString.isEmpty()
|
||||
? Size.parseSize(screenEdgeInsetsDpString)
|
||||
: null;
|
||||
@@ -96,9 +97,9 @@ public class PipBoundsAlgorithm {
|
||||
mMaxAspectRatio = res.getFloat(
|
||||
com.android.internal.R.dimen.config_pictureInPictureMaxAspectRatio);
|
||||
mDefaultSizePercent = res.getFloat(
|
||||
com.android.internal.R.dimen.config_pictureInPictureDefaultSizePercent);
|
||||
R.dimen.config_pictureInPictureDefaultSizePercent);
|
||||
mMaxAspectRatioForMinSize = res.getFloat(
|
||||
com.android.internal.R.dimen.config_pictureInPictureAspectRatioLimitForMinSize);
|
||||
R.dimen.config_pictureInPictureAspectRatioLimitForMinSize);
|
||||
mMinAspectRatioForMinSize = 1f / mMaxAspectRatioForMinSize;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import android.view.Gravity;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.wm.shell.R;
|
||||
import com.android.wm.shell.ShellTestCase;
|
||||
import com.android.wm.shell.common.DisplayLayout;
|
||||
|
||||
@@ -72,16 +73,16 @@ public class PipBoundsAlgorithmTest extends ShellTestCase {
|
||||
private void initializeMockResources() {
|
||||
final TestableResources res = mContext.getOrCreateTestableResources();
|
||||
res.addOverride(
|
||||
com.android.internal.R.dimen.config_pictureInPictureDefaultAspectRatio,
|
||||
R.dimen.config_pictureInPictureDefaultAspectRatio,
|
||||
DEFAULT_ASPECT_RATIO);
|
||||
res.addOverride(
|
||||
com.android.internal.R.integer.config_defaultPictureInPictureGravity,
|
||||
R.integer.config_defaultPictureInPictureGravity,
|
||||
Gravity.END | Gravity.BOTTOM);
|
||||
res.addOverride(
|
||||
com.android.internal.R.dimen.default_minimal_size_pip_resizable_task,
|
||||
R.dimen.default_minimal_size_pip_resizable_task,
|
||||
DEFAULT_MIN_EDGE_SIZE);
|
||||
res.addOverride(
|
||||
com.android.internal.R.string.config_defaultPictureInPictureScreenEdgeInsets,
|
||||
R.string.config_defaultPictureInPictureScreenEdgeInsets,
|
||||
"16x16");
|
||||
res.addOverride(
|
||||
com.android.internal.R.dimen.config_pictureInPictureMinAspectRatio,
|
||||
@@ -107,7 +108,7 @@ public class PipBoundsAlgorithmTest extends ShellTestCase {
|
||||
public void onConfigurationChanged_reloadResources() {
|
||||
final float newDefaultAspectRatio = (DEFAULT_ASPECT_RATIO + MAX_ASPECT_RATIO) / 2;
|
||||
final TestableResources res = mContext.getOrCreateTestableResources();
|
||||
res.addOverride(com.android.internal.R.dimen.config_pictureInPictureDefaultAspectRatio,
|
||||
res.addOverride(R.dimen.config_pictureInPictureDefaultAspectRatio,
|
||||
newDefaultAspectRatio);
|
||||
|
||||
mPipBoundsAlgorithm.onConfigurationChanged(mContext);
|
||||
@@ -463,7 +464,7 @@ public class PipBoundsAlgorithmTest extends ShellTestCase {
|
||||
private void overrideDefaultAspectRatio(float aspectRatio) {
|
||||
final TestableResources res = mContext.getOrCreateTestableResources();
|
||||
res.addOverride(
|
||||
com.android.internal.R.dimen.config_pictureInPictureDefaultAspectRatio,
|
||||
R.dimen.config_pictureInPictureDefaultAspectRatio,
|
||||
aspectRatio);
|
||||
mPipBoundsAlgorithm.onConfigurationChanged(mContext);
|
||||
}
|
||||
@@ -471,7 +472,7 @@ public class PipBoundsAlgorithmTest extends ShellTestCase {
|
||||
private void overrideDefaultStackGravity(int stackGravity) {
|
||||
final TestableResources res = mContext.getOrCreateTestableResources();
|
||||
res.addOverride(
|
||||
com.android.internal.R.integer.config_defaultPictureInPictureGravity,
|
||||
R.integer.config_defaultPictureInPictureGravity,
|
||||
stackGravity);
|
||||
mPipBoundsAlgorithm.onConfigurationChanged(mContext);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user