FoldingFeature
public
class
FoldingFeature
extends Object
implements
DisplayFeature
java.lang.Object | |
↳ | androidx.window.FoldingFeature |
A feature that describes a fold in the flexible display or a hinge between two physical display panels.
Summary
Constants | |
---|---|
int |
OCCLUSION_FULL
The |
int |
OCCLUSION_NONE
The |
int |
ORIENTATION_HORIZONTAL
The width of the |
int |
ORIENTATION_VERTICAL
The height of the |
int |
STATE_FLAT
The foldable device is completely open, the screen space that is presented to the user is flat. |
int |
STATE_FLIPPED
The foldable device is flipped with the flexible screen parts or physical screens facing opposite directions. |
int |
STATE_HALF_OPENED
The foldable device's hinge is in an intermediate position between opened and closed state, there is a non-flat angle between parts of the flexible screen or between physical screen panels. |
int |
TYPE_FOLD
A fold in the flexible screen without a physical gap. |
int |
TYPE_HINGE
A physical separation with a hinge that allows two display panels to fold. |
Inherited constants |
---|
Public constructors | |
---|---|
FoldingFeature(Rect bounds, int type, int state)
|
Public methods | |
---|---|
boolean
|
equals(Object o)
|
Rect
|
getBounds()
The bounding rectangle of the feature within the application window in the window coordinate space. |
int
|
getOcclusionMode()
Calculates the occlusion mode to determine if a |
int
|
getOrientation()
Returns |
int
|
getState()
|
int
|
getType()
This method is deprecated. visibility will be reduced. |
int
|
hashCode()
|
boolean
|
isSeparating()
Calculates if a |
String
|
toString()
|
Inherited methods | |
---|---|
Constants
OCCLUSION_FULL
public static final int OCCLUSION_FULL
The FoldingFeature
occludes all content. One example is a hinge that is considered to
be part of the window, so that part of the UI is not visible to the user. Any content shown
in the same area as the hinge may not be accessible in any way. Fully occluded areas should
always be avoided when placing interactive UI elements and text.
Constant Value: 1 (0x00000001)
OCCLUSION_NONE
public static final int OCCLUSION_NONE
The FoldingFeature
does not occlude the content in any way. One example is a flat
continuous fold where content can stretch across the fold. Another example is a hinge that
has width or height equal to 0. In this case the content is physically split across both
displays, but fully visible.
Constant Value: 0 (0x00000000)
ORIENTATION_HORIZONTAL
public static final int ORIENTATION_HORIZONTAL
The width of the FoldingFeature
is greater than the height.
Constant Value: 1 (0x00000001)
ORIENTATION_VERTICAL
public static final int ORIENTATION_VERTICAL
The height of the FoldingFeature
is greater than or equal to the width.
Constant Value: 0 (0x00000000)
STATE_FLAT
public static final int STATE_FLAT
The foldable device is completely open, the screen space that is presented to the user is flat. See the Posture section in the official documentation for visual samples and references.
Constant Value: 1 (0x00000001)
STATE_FLIPPED
public static final int STATE_FLIPPED
The foldable device is flipped with the flexible screen parts or physical screens facing opposite directions. See the Posture section in the official documentation for visual samples and references.
Constant Value: 3 (0x00000003)
STATE_HALF_OPENED
public static final int STATE_HALF_OPENED
The foldable device's hinge is in an intermediate position between opened and closed state, there is a non-flat angle between parts of the flexible screen or between physical screen panels. See the Posture section in the official documentation for visual samples and references.
Constant Value: 2 (0x00000002)
TYPE_FOLD
public static final int TYPE_FOLD
A fold in the flexible screen without a physical gap.
Constant Value: 1 (0x00000001)
TYPE_HINGE
public static final int TYPE_HINGE
A physical separation with a hinge that allows two display panels to fold.
Constant Value: 2 (0x00000002)
Public constructors
FoldingFeature
public FoldingFeature (Rect bounds, int type, int state)
Parameters | |
---|---|
bounds |
Rect |
type |
int |
state |
int |
Public methods
equals
public boolean equals (Object o)
Parameters | |
---|---|
o |
Object |
Returns | |
---|---|
boolean |
getBounds
public Rect getBounds ()
The bounding rectangle of the feature within the application window in the window coordinate space.
Returns | |
---|---|
Rect |
bounds of display feature. |
getOcclusionMode
public int getOcclusionMode ()
Calculates the occlusion mode to determine if a FoldingFeature
occludes a part of
the window. This flag is useful for determining if UI elements need to be moved
around so that the user can access them. For some devices occluded elements can not be
accessed by the user at all.
For occlusion type OCCLUSION_NONE
the feature can be treated as a
guideline. One example would be for a continuously folding screen. For occlusion type
OCCLUSION_FULL
the feature should be avoided completely since content
will not be visible or touchable, like a hinge device with two displays.
The occlusion mode is useful to determine if the UI needs to adapt to the
FoldingFeature
. For example, full screen games should consider avoiding anything in
the occluded region if it negatively affects the gameplay. The user can not tap
on the occluded interactive UI elements nor can they see important information.
Returns | |
---|---|
int |
OCCLUSION_NONE if the FoldingFeature has empty
bounds.
|
getOrientation
public int getOrientation ()
Returns ORIENTATION_HORIZONTAL
if the width is greater than the
height, ORIENTATION_VERTICAL
otherwise.
Returns | |
---|---|
int |
getState
public int getState ()
Returns | |
---|---|
int |
getType
public int getType ()
This method is deprecated.
visibility will be reduced.
Returns type that is either TYPE_FOLD
or
TYPE_HINGE
Returns | |
---|---|
int |
hashCode
public int hashCode ()
Returns | |
---|---|
int |
isSeparating
public boolean isSeparating ()
Calculates if a FoldingFeature
should be thought of as splitting the window into
multiple physical areas that can be seen by users as logically separate. Display panels
connected by a hinge are always separated. Folds on flexible screens should be treated as
separating when they are not STATE_FLAT
.
Apps may use this to determine if content should lay out around the FoldingFeature
.
Developers should consider the placement of interactive elements. Similar to the case of
OCCLUSION_FULL
, when a feature is separating then consider laying
out the controls around the FoldingFeature
.
An example use case is to determine if the UI should be split into two logical areas. A media
app where there is some auxiliary content, such as comments or description of a video, may
need to adapt the layout. The media can be put on one side of the FoldingFeature
and
the auxiliary content can be placed on the other side.
Returns | |
---|---|
boolean |
true if the feature splits the display into two areas, false
otherwise.
|
toString
public String toString ()
Returns | |
---|---|
String |