Merge "Add an public api to create a DisplayCutout with path for test only"
This commit is contained in:
@@ -48193,6 +48193,18 @@ package android.view {
|
||||
method @NonNull public android.graphics.Insets getWaterfallInsets();
|
||||
}
|
||||
|
||||
public static final class DisplayCutout.Builder {
|
||||
ctor public DisplayCutout.Builder();
|
||||
method @NonNull public android.view.DisplayCutout build();
|
||||
method @NonNull public android.view.DisplayCutout.Builder setBoundingRectBottom(@NonNull android.graphics.Rect);
|
||||
method @NonNull public android.view.DisplayCutout.Builder setBoundingRectLeft(@NonNull android.graphics.Rect);
|
||||
method @NonNull public android.view.DisplayCutout.Builder setBoundingRectRight(@NonNull android.graphics.Rect);
|
||||
method @NonNull public android.view.DisplayCutout.Builder setBoundingRectTop(@NonNull android.graphics.Rect);
|
||||
method @NonNull public android.view.DisplayCutout.Builder setCutoutPath(@NonNull android.graphics.Path);
|
||||
method @NonNull public android.view.DisplayCutout.Builder setSafeInsets(@NonNull android.graphics.Insets);
|
||||
method @NonNull public android.view.DisplayCutout.Builder setWaterfallInsets(@NonNull android.graphics.Insets);
|
||||
}
|
||||
|
||||
public final class DragAndDropPermissions implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public void release();
|
||||
|
||||
@@ -1249,4 +1249,119 @@ public final class DisplayCutout {
|
||||
return String.valueOf(mInner);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A Builder class to construct a DisplayCutout instance.
|
||||
*
|
||||
* <p>Note that this is only for tests purpose. For production code, developers should always
|
||||
* use a {@link DisplayCutout} obtained from the system.</p>
|
||||
*/
|
||||
public static final class Builder {
|
||||
private Insets mSafeInsets = Insets.NONE;
|
||||
private Insets mWaterfallInsets = Insets.NONE;
|
||||
private Path mCutoutPath;
|
||||
private final Rect mBoundingRectLeft = new Rect();
|
||||
private final Rect mBoundingRectTop = new Rect();
|
||||
private final Rect mBoundingRectRight = new Rect();
|
||||
private final Rect mBoundingRectBottom = new Rect();
|
||||
|
||||
/**
|
||||
* Begin building a DisplayCutout.
|
||||
*/
|
||||
public Builder() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new {@link DisplayCutout} with the set parameters.
|
||||
*/
|
||||
@NonNull
|
||||
public DisplayCutout build() {
|
||||
final CutoutPathParserInfo info;
|
||||
if (mCutoutPath != null) {
|
||||
// Create a fake CutoutPathParserInfo and set it to sCachedCutoutPathParserInfo so
|
||||
// that when getCutoutPath() is called, it will return the cached Path.
|
||||
info = new CutoutPathParserInfo(0, 0, 0, "test", 0, 1f);
|
||||
synchronized (CACHE_LOCK) {
|
||||
DisplayCutout.sCachedCutoutPathParserInfo = info;
|
||||
DisplayCutout.sCachedCutoutPath = mCutoutPath;
|
||||
}
|
||||
} else {
|
||||
info = null;
|
||||
}
|
||||
return new DisplayCutout(mSafeInsets.toRect(), mWaterfallInsets, mBoundingRectLeft,
|
||||
mBoundingRectTop, mBoundingRectRight, mBoundingRectBottom, info, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the safe insets. If not set, the default value is {@link Insets#NONE}.
|
||||
*/
|
||||
@SuppressWarnings("MissingGetterMatchingBuilder")
|
||||
@NonNull
|
||||
public Builder setSafeInsets(@NonNull Insets safeInsets) {
|
||||
mSafeInsets = safeInsets;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the waterfall insets of the DisplayCutout. If not set, the default value is
|
||||
* {@link Insets#NONE}
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setWaterfallInsets(@NonNull Insets waterfallInsets) {
|
||||
mWaterfallInsets = waterfallInsets;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a bounding rectangle for a non-functional area on the display which is located on
|
||||
* the left of the screen. If not set, the default value is an empty rectangle.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setBoundingRectLeft(@NonNull Rect boundingRectLeft) {
|
||||
mBoundingRectLeft.set(boundingRectLeft);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a bounding rectangle for a non-functional area on the display which is located on
|
||||
* the top of the screen. If not set, the default value is an empty rectangle.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setBoundingRectTop(@NonNull Rect boundingRectTop) {
|
||||
mBoundingRectTop.set(boundingRectTop);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a bounding rectangle for a non-functional area on the display which is located on
|
||||
* the right of the screen. If not set, the default value is an empty rectangle.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setBoundingRectRight(@NonNull Rect boundingRectRight) {
|
||||
mBoundingRectRight.set(boundingRectRight);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a bounding rectangle for a non-functional area on the display which is located on
|
||||
* the bottom of the screen. If not set, the default value is an empty rectangle.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setBoundingRectBottom(@NonNull Rect boundingRectBottom) {
|
||||
mBoundingRectBottom.set(boundingRectBottom);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the cutout {@link Path}.
|
||||
*
|
||||
* Note that not support creating/testing multiple display cutouts with setCutoutPath() in
|
||||
* parallel.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setCutoutPath(@NonNull Path cutoutPath) {
|
||||
mCutoutPath = cutoutPath;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user