1 /*
2  * Copyright 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package androidx.window.extensions.layout;
18 
19 import androidx.window.extensions.RequiresVendorApiLevel;
20 
21 import org.jspecify.annotations.NonNull;
22 
23 import java.util.ArrayList;
24 import java.util.List;
25 
26 /**
27  * A class to represent all the possible features that may interact with or appear in a window,
28  * that an application might want to respond to.
29  */
30 public final class SupportedWindowFeatures {
31 
32     private final List<DisplayFoldFeature> mDisplayFoldFeatureList;
33 
SupportedWindowFeatures( @onNull List<DisplayFoldFeature> displayFoldFeatureList)34     private SupportedWindowFeatures(
35             @NonNull List<DisplayFoldFeature> displayFoldFeatureList) {
36         mDisplayFoldFeatureList = new ArrayList<>(displayFoldFeatureList);
37     }
38 
39     /**
40      * Returns the possible {@link DisplayFoldFeature}s that can be reported to an application.
41      */
42     @RequiresVendorApiLevel(level = 6)
getDisplayFoldFeatures()43     public @NonNull List<DisplayFoldFeature> getDisplayFoldFeatures() {
44         return new ArrayList<>(mDisplayFoldFeatureList);
45     }
46 
47 
48     /**
49      * A class to create a {@link SupportedWindowFeatures} instance.
50      */
51     public static final class Builder {
52 
53         private final List<DisplayFoldFeature> mDisplayFoldFeatures;
54 
55         /**
56          * Creates a new instance of {@link Builder}
57          */
58         @RequiresVendorApiLevel(level = 6)
Builder(@onNull List<DisplayFoldFeature> displayFoldFeatures)59         public Builder(@NonNull List<DisplayFoldFeature> displayFoldFeatures) {
60             mDisplayFoldFeatures = new ArrayList<>(displayFoldFeatures);
61         }
62 
63         /**
64          * Creates an instance of {@link SupportedWindowFeatures} with the features set.
65          */
66         @RequiresVendorApiLevel(level = 6)
build()67         public @NonNull SupportedWindowFeatures build() {
68             return new SupportedWindowFeatures(mDisplayFoldFeatures);
69         }
70     }
71 }
72