Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java +7 −6 Original line number Original line Diff line number Diff line Loading @@ -212,24 +212,25 @@ public class PipSizeSpecHandler { */ */ @Override @Override public Size getSizeForAspectRatio(Size size, float aspectRatio) { public Size getSizeForAspectRatio(Size size, float aspectRatio) { // getting the percentage of the max size that current size takes float currAspectRatio = (float) size.getWidth() / size.getHeight(); float currAspectRatio = (float) size.getWidth() / size.getHeight(); // getting the percentage of the max size that current size takes Size currentMaxSize = getMaxSize(currAspectRatio); Size currentMaxSize = getMaxSize(currAspectRatio); float currentPercent = (float) size.getWidth() / currentMaxSize.getWidth(); float currentPercent = (float) size.getWidth() / currentMaxSize.getWidth(); // getting the max size for the target aspect ratio // getting the max size for the target aspect ratio Size updatedMaxSize = getMaxSize(aspectRatio); Size updatedMaxSize = getMaxSize(aspectRatio); int width = (int) (updatedMaxSize.getWidth() * currentPercent); int width = Math.round(updatedMaxSize.getWidth() * currentPercent); int height = (int) (updatedMaxSize.getHeight() * currentPercent); int height = Math.round(updatedMaxSize.getHeight() * currentPercent); // adjust the dimensions if below allowed min edge size // adjust the dimensions if below allowed min edge size if (width < getMinEdgeSize() && aspectRatio <= 1) { if (width < getMinEdgeSize() && aspectRatio <= 1) { width = getMinEdgeSize(); width = getMinEdgeSize(); height = (int) (width / aspectRatio); height = Math.round(width / aspectRatio); } else if (height < getMinEdgeSize() && aspectRatio > 1) { } else if (height < getMinEdgeSize() && aspectRatio > 1) { height = getMinEdgeSize(); height = getMinEdgeSize(); width = (int) (height * aspectRatio); width = Math.round(height * aspectRatio); } } // reduce the dimensions of the updated size to the calculated percentage // reduce the dimensions of the updated size to the calculated percentage Loading Loading @@ -365,7 +366,7 @@ public class PipSizeSpecHandler { mContext = context; mContext = context; boolean enablePipSizeLargeScreen = SystemProperties boolean enablePipSizeLargeScreen = SystemProperties .getBoolean("persist.wm.debug.enable_pip_size_large_screen", false); .getBoolean("persist.wm.debug.enable_pip_size_large_screen", true); // choose between two implementations of size spec logic // choose between two implementations of size spec logic if (enablePipSizeLargeScreen) { if (enablePipSizeLargeScreen) { Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java +7 −6 Original line number Original line Diff line number Diff line Loading @@ -212,24 +212,25 @@ public class PipSizeSpecHandler { */ */ @Override @Override public Size getSizeForAspectRatio(Size size, float aspectRatio) { public Size getSizeForAspectRatio(Size size, float aspectRatio) { // getting the percentage of the max size that current size takes float currAspectRatio = (float) size.getWidth() / size.getHeight(); float currAspectRatio = (float) size.getWidth() / size.getHeight(); // getting the percentage of the max size that current size takes Size currentMaxSize = getMaxSize(currAspectRatio); Size currentMaxSize = getMaxSize(currAspectRatio); float currentPercent = (float) size.getWidth() / currentMaxSize.getWidth(); float currentPercent = (float) size.getWidth() / currentMaxSize.getWidth(); // getting the max size for the target aspect ratio // getting the max size for the target aspect ratio Size updatedMaxSize = getMaxSize(aspectRatio); Size updatedMaxSize = getMaxSize(aspectRatio); int width = (int) (updatedMaxSize.getWidth() * currentPercent); int width = Math.round(updatedMaxSize.getWidth() * currentPercent); int height = (int) (updatedMaxSize.getHeight() * currentPercent); int height = Math.round(updatedMaxSize.getHeight() * currentPercent); // adjust the dimensions if below allowed min edge size // adjust the dimensions if below allowed min edge size if (width < getMinEdgeSize() && aspectRatio <= 1) { if (width < getMinEdgeSize() && aspectRatio <= 1) { width = getMinEdgeSize(); width = getMinEdgeSize(); height = (int) (width / aspectRatio); height = Math.round(width / aspectRatio); } else if (height < getMinEdgeSize() && aspectRatio > 1) { } else if (height < getMinEdgeSize() && aspectRatio > 1) { height = getMinEdgeSize(); height = getMinEdgeSize(); width = (int) (height * aspectRatio); width = Math.round(height * aspectRatio); } } // reduce the dimensions of the updated size to the calculated percentage // reduce the dimensions of the updated size to the calculated percentage Loading Loading @@ -365,7 +366,7 @@ public class PipSizeSpecHandler { mContext = context; mContext = context; boolean enablePipSizeLargeScreen = SystemProperties boolean enablePipSizeLargeScreen = SystemProperties .getBoolean("persist.wm.debug.enable_pip_size_large_screen", false); .getBoolean("persist.wm.debug.enable_pip_size_large_screen", true); // choose between two implementations of size spec logic // choose between two implementations of size spec logic if (enablePipSizeLargeScreen) { if (enablePipSizeLargeScreen) { Loading