• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 android.service.autofill;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.widget.RemoteViews;
22 
23 import com.android.internal.util.DataClass;
24 
25 /**
26  * Holds presentations used to visualize autofill suggestions for each available UI type.
27  *
28  * @see Field
29  */
30 @DataClass(genBuilder = true)
31 public final class Presentations {
32 
33     /**
34      * The presentation used to visualize this field in fill UI.
35      *
36      * <p>Note: Before Android 13, this was referred to simply as "presentation" in the SDK.
37      *
38      * <p>Theme does not work with RemoteViews layout. Avoid hardcoded text color
39      * or background color: Autofill on different platforms may have different themes.
40      */
41     private @Nullable RemoteViews mMenuPresentation;
42 
43     /**
44      * The {@link InlinePresentation} used to visualize this dataset as inline suggestions.
45      * If the dataset supports inline suggestions, this should not be null.
46      */
47     private @Nullable InlinePresentation mInlinePresentation;
48 
49     /**
50      * The presentation used to visualize this field in the
51      * <a href="Dataset.html#FillDialogUI">fill dialog UI</a>
52      *
53      * <p>Theme does not work with RemoteViews layout. Avoid hardcoded text color
54      * or background color: Autofill on different platforms may have different themes.
55      */
56     private @Nullable RemoteViews mDialogPresentation;
57 
58     /**
59      * The {@link InlinePresentation} used to show the tooltip for the
60      * {@code mInlinePresentation}. If the set this field, the
61      * {@code mInlinePresentation} should not be null.
62      */
63     private @Nullable InlinePresentation mInlineTooltipPresentation;
64 
defaultMenuPresentation()65     private static RemoteViews defaultMenuPresentation() {
66         return null;
67     }
68 
defaultInlinePresentation()69     private static InlinePresentation defaultInlinePresentation() {
70         return null;
71     }
72 
defaultDialogPresentation()73     private static RemoteViews defaultDialogPresentation() {
74         return null;
75     }
76 
defaultInlineTooltipPresentation()77     private static InlinePresentation defaultInlineTooltipPresentation() {
78         return null;
79     }
80 
onConstructed()81     private void onConstructed() {
82         if (mMenuPresentation == null
83                 && mInlinePresentation == null
84                 && mDialogPresentation == null) {
85             throw new IllegalStateException("All presentations are null.");
86         }
87         if (mInlineTooltipPresentation != null && mInlinePresentation == null) {
88             throw new IllegalStateException(
89                     "The inline presentation is required for mInlineTooltipPresentation.");
90         }
91     }
92 
93 
94 
95     // Code below generated by codegen v1.0.23.
96     //
97     // DO NOT MODIFY!
98     // CHECKSTYLE:OFF Generated code
99     //
100     // To regenerate run:
101     // $ codegen $ANDROID_BUILD_TOP/./frameworks/base/core/java/android/service/autofill/Presentations.java
102     //
103     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
104     //   Settings > Editor > Code Style > Formatter Control
105     //@formatter:off
106 
107 
108     @DataClass.Generated.Member
Presentations( @ullable RemoteViews menuPresentation, @Nullable InlinePresentation inlinePresentation, @Nullable RemoteViews dialogPresentation, @Nullable InlinePresentation inlineTooltipPresentation)109     /* package-private */ Presentations(
110             @Nullable RemoteViews menuPresentation,
111             @Nullable InlinePresentation inlinePresentation,
112             @Nullable RemoteViews dialogPresentation,
113             @Nullable InlinePresentation inlineTooltipPresentation) {
114         this.mMenuPresentation = menuPresentation;
115         this.mInlinePresentation = inlinePresentation;
116         this.mDialogPresentation = dialogPresentation;
117         this.mInlineTooltipPresentation = inlineTooltipPresentation;
118 
119         onConstructed();
120     }
121 
122     /**
123      * The presentation used to visualize this field in fill UI.
124      *
125      * <p>Theme does not work with RemoteViews layout. Avoid hardcoded text color
126      * or background color: Autofill on different platforms may have different themes.
127      */
128     @DataClass.Generated.Member
getMenuPresentation()129     public @Nullable RemoteViews getMenuPresentation() {
130         return mMenuPresentation;
131     }
132 
133     /**
134      * The {@link InlinePresentation} used to visualize this dataset as inline suggestions.
135      * If the dataset supports inline suggestions, this should not be null.
136      */
137     @DataClass.Generated.Member
getInlinePresentation()138     public @Nullable InlinePresentation getInlinePresentation() {
139         return mInlinePresentation;
140     }
141 
142     /**
143      * The presentation used to visualize this field in the fill dialog UI.
144      *
145      * <p>Theme does not work with RemoteViews layout. Avoid hardcoded text color
146      * or background color: Autofill on different platforms may have different themes.
147      */
148     @DataClass.Generated.Member
getDialogPresentation()149     public @Nullable RemoteViews getDialogPresentation() {
150         return mDialogPresentation;
151     }
152 
153     /**
154      * The {@link InlinePresentation} used to show the tooltip for the
155      * {@code mInlinePresentation}. If the set this field, the
156      * {@code mInlinePresentation} should not be null.
157      */
158     @DataClass.Generated.Member
getInlineTooltipPresentation()159     public @Nullable InlinePresentation getInlineTooltipPresentation() {
160         return mInlineTooltipPresentation;
161     }
162 
163     /**
164      * A builder for {@link Presentations}
165      */
166     @SuppressWarnings("WeakerAccess")
167     @DataClass.Generated.Member
168     public static final class Builder {
169 
170         private @Nullable RemoteViews mMenuPresentation;
171         private @Nullable InlinePresentation mInlinePresentation;
172         private @Nullable RemoteViews mDialogPresentation;
173         private @Nullable InlinePresentation mInlineTooltipPresentation;
174 
175         private long mBuilderFieldsSet = 0L;
176 
Builder()177         public Builder() {
178         }
179 
180         /**
181          * The presentation used to visualize this field in fill UI.
182          *
183          * <p>Theme does not work with RemoteViews layout. Avoid hardcoded text color
184          * or background color: Autofill on different platforms may have different themes.
185          */
186         @DataClass.Generated.Member
setMenuPresentation(@onNull RemoteViews value)187         public @NonNull Builder setMenuPresentation(@NonNull RemoteViews value) {
188             checkNotUsed();
189             mBuilderFieldsSet |= 0x1;
190             mMenuPresentation = value;
191             return this;
192         }
193 
194         /**
195          * The {@link InlinePresentation} used to visualize this dataset as inline suggestions.
196          * If the dataset supports inline suggestions, this should not be null.
197          */
198         @DataClass.Generated.Member
setInlinePresentation(@onNull InlinePresentation value)199         public @NonNull Builder setInlinePresentation(@NonNull InlinePresentation value) {
200             checkNotUsed();
201             mBuilderFieldsSet |= 0x2;
202             mInlinePresentation = value;
203             return this;
204         }
205 
206         /**
207          * The presentation used to visualize this field in the fill dialog UI.
208          *
209          * <p>Theme does not work with RemoteViews layout. Avoid hardcoded text color
210          * or background color: Autofill on different platforms may have different themes.
211          */
212         @DataClass.Generated.Member
setDialogPresentation(@onNull RemoteViews value)213         public @NonNull Builder setDialogPresentation(@NonNull RemoteViews value) {
214             checkNotUsed();
215             mBuilderFieldsSet |= 0x4;
216             mDialogPresentation = value;
217             return this;
218         }
219 
220         /**
221          * The {@link InlinePresentation} used to show the tooltip for the
222          * {@code mInlinePresentation}. If the set this field, the
223          * {@code mInlinePresentation} should not be null.
224          */
225         @DataClass.Generated.Member
setInlineTooltipPresentation(@onNull InlinePresentation value)226         public @NonNull Builder setInlineTooltipPresentation(@NonNull InlinePresentation value) {
227             checkNotUsed();
228             mBuilderFieldsSet |= 0x8;
229             mInlineTooltipPresentation = value;
230             return this;
231         }
232 
233         /** Builds the instance. This builder should not be touched after calling this! */
build()234         public @NonNull Presentations build() {
235             checkNotUsed();
236             mBuilderFieldsSet |= 0x10; // Mark builder used
237 
238             if ((mBuilderFieldsSet & 0x1) == 0) {
239                 mMenuPresentation = defaultMenuPresentation();
240             }
241             if ((mBuilderFieldsSet & 0x2) == 0) {
242                 mInlinePresentation = defaultInlinePresentation();
243             }
244             if ((mBuilderFieldsSet & 0x4) == 0) {
245                 mDialogPresentation = defaultDialogPresentation();
246             }
247             if ((mBuilderFieldsSet & 0x8) == 0) {
248                 mInlineTooltipPresentation = defaultInlineTooltipPresentation();
249             }
250             Presentations o = new Presentations(
251                     mMenuPresentation,
252                     mInlinePresentation,
253                     mDialogPresentation,
254                     mInlineTooltipPresentation);
255             return o;
256         }
257 
checkNotUsed()258         private void checkNotUsed() {
259             if ((mBuilderFieldsSet & 0x10) != 0) {
260                 throw new IllegalStateException(
261                         "This Builder should not be reused. Use a new Builder instance instead");
262             }
263         }
264     }
265 
266     @DataClass.Generated(
267             time = 1643083242164L,
268             codegenVersion = "1.0.23",
269             sourceFile = "frameworks/base/core/java/android/service/autofill/Presentations.java",
270             inputSignatures = "private @android.annotation.Nullable android.widget.RemoteViews mMenuPresentation\nprivate @android.annotation.Nullable android.service.autofill.InlinePresentation mInlinePresentation\nprivate @android.annotation.Nullable android.widget.RemoteViews mDialogPresentation\nprivate @android.annotation.Nullable android.service.autofill.InlinePresentation mInlineTooltipPresentation\nprivate static  android.widget.RemoteViews defaultMenuPresentation()\nprivate static  android.service.autofill.InlinePresentation defaultInlinePresentation()\nprivate static  android.widget.RemoteViews defaultDialogPresentation()\nprivate static  android.service.autofill.InlinePresentation defaultInlineTooltipPresentation()\nprivate  void onConstructed()\nclass Presentations extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genBuilder=true)")
271     @Deprecated
__metadata()272     private void __metadata() {}
273 
274 
275     //@formatter:on
276     // End of generated code
277 
278 }
279