Refactor SplitBounds to always use creation-time measurements
In flexible split ratios like 90:10 and 10:90, we hide the Overview icon of the smaller app completely (ag/30949010). However, there was an unintentional side effect where one of the icons would disappear when rotating the display. This happened (basically) because SplitBounds is not recalculated on device rotation, so fields like leftTaskPercent and topTaskPercent should not be used directly when the rotation state is not known. I added an API to SplitBounds that hopefully makes it harder to write bugs like this in the future. Fixes: 395783367 Flag: com.android.wm.shell.enable_flexible_two_app_split Test: Icons do not disappear on rotation. When app chip menus are enabled, the (existing) correct behavior is not changed. Change-Id: I2c1b38f4bd9a76dfb127b7bbf230897d747d3c49
This commit is contained in:
1 parent
c7e545674d
commit
b392f61ced
7 files changed
+65
-87
No files matched your search
@@ -127,10 +127,10 @@ public final class SplitConfigurationOptions {
|
||||
/** This rect represents the actual gap between the two apps */
|
||||
public final Rect visualDividerBounds;
|
||||
// This class is orientation-agnostic, so we compute both for later use
|
||||
public final float topTaskPercent;
|
||||
public final float leftTaskPercent;
|
||||
public final float dividerWidthPercent;
|
||||
public final float dividerHeightPercent;
|
||||
private final float topTaskPercent;
|
||||
private final float leftTaskPercent;
|
||||
private final float dividerWidthPercent;
|
||||
private final float dividerHeightPercent;
|
||||
public final int snapPosition;
|
||||
|
||||
/**
|
||||
@@ -190,6 +190,39 @@ public final class SplitConfigurationOptions {
|
||||
dividerHeightPercent = visualDividerBounds.height() / totalHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the percentage size of the left/top task (compared to the full width/height of
|
||||
* the split pair). E.g. if the left task is 4 units wide, the divider is 2 units, and the
|
||||
* right task is 4 units, this method will return 0.4f.
|
||||
*/
|
||||
public float getLeftTopTaskPercent() {
|
||||
// topTaskPercent and leftTaskPercent are defined at creation time, and are not updated
|
||||
// on device rotate, so we have to check appsStackedVertically to return the right
|
||||
// creation-time measurements.
|
||||
return appsStackedVertically ? topTaskPercent : leftTaskPercent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the percentage size of the divider's thickness (compared to the full width/height
|
||||
* of the split pair). E.g. if the left task is 4 units wide, the divider is 2 units, and
|
||||
* the right task is 4 units, this method will return 0.2f.
|
||||
*/
|
||||
public float getDividerPercent() {
|
||||
// dividerHeightPercent and dividerWidthPercent are defined at creation time, and are
|
||||
// not updated on device rotate, so we have to check appsStackedVertically to return
|
||||
// the right creation-time measurements.
|
||||
return appsStackedVertically ? dividerHeightPercent : dividerWidthPercent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the percentage size of the right/bottom task (compared to the full width/height
|
||||
* of the split pair). E.g. if the left task is 4 units wide, the divider is 2 units, and
|
||||
* the right task is 4 units, this method will return 0.4f.
|
||||
*/
|
||||
public float getRightBottomTaskPercent() {
|
||||
return 1 - (getLeftTopTaskPercent() + getDividerPercent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LeftTop: " + leftTopBounds + ", taskId: " + leftTopTaskId + "\n"
|
||||
|
||||
Reference in new issue
Block a user