FoldingFeature

public final class FoldingFeature implements DisplayFeature


A feature that describes a fold in the flexible display or a hinge between two physical display panels.

Summary

Public fields

@NonNull Rect

The bounding rectangle of the feature within the application window in the window coordinate space.

final boolean

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.

final @NonNull FoldingFeature.OcclusionType

Calculates the occlusion mode to determine if a FoldingFeature occludes a part of the window.

final @NonNull FoldingFeature.Orientation

Returns FoldingFeature.Orientation.HORIZONTAL if the width is greater than the height, FoldingFeature.Orientation.VERTICAL otherwise.

final @NonNull FoldingFeature.State

the physical state of the hinge that is either FoldingFeature.State.FLAT or FoldingFeature.State.HALF_OPENED

Public constructors

FoldingFeature(
    @NonNull Rect bounds,
    @NonNull FoldingFeature.Type type,
    @NonNull FoldingFeature.State state
)

Public methods

boolean
int
@NonNull String

Public fields

bounds

@NonNull
public @NonNull Rect bounds

The bounding rectangle of the feature within the application window in the window coordinate space.

isSeparating

@NonNull
public final 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 FoldingFeature.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 FoldingFeature.OcclusionType.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.

occlusionType

@NonNull
public final @NonNull FoldingFeature.OcclusionType occlusionType

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 FoldingFeature.OcclusionType.NONE the feature can be treated as a guideline. One example would be for a continuously folding screen. For occlusion type FoldingFeature.OcclusionType.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.

orientation

@NonNull
public final @NonNull FoldingFeature.Orientation orientation

Returns FoldingFeature.Orientation.HORIZONTAL if the width is greater than the height, FoldingFeature.Orientation.VERTICAL otherwise.

state

@NonNull
public final @NonNull FoldingFeature.State state

the physical state of the hinge that is either FoldingFeature.State.FLAT or FoldingFeature.State.HALF_OPENED

Public constructors

FoldingFeature

public final FoldingFeature(
    @NonNull Rect bounds,
    @NonNull FoldingFeature.Type type,
    @NonNull FoldingFeature.State state
)

Public methods

equals

@NonNull
public boolean equals(@Nullable Object other)

hashCode

@NonNull
public int hashCode()

toString

@NonNull
public String toString()