blob: 2ac406c5b08cbcd30724f61e11cfc177b1296f5a [file] [log] [blame]
Felipe Leme284ad1c2018-11-15 18:16:12 -08001/*
2 * Copyright (C) 2018 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 */
Felipe Leme749b8892018-12-03 16:30:30 -080016package android.service.autofill.augmented;
Felipe Leme284ad1c2018-11-15 18:16:12 -080017
18import android.annotation.NonNull;
19import android.annotation.Nullable;
20import android.annotation.SystemApi;
Felipe Leme2cab38c2019-01-11 10:39:14 -080021import android.annotation.TestApi;
Felipe Leme284ad1c2018-11-15 18:16:12 -080022import android.view.autofill.AutofillId;
23
24import java.util.List;
25
26/**
27 * Response to a {@link FillRequest}.
28 *
29 * @hide
30 */
31@SystemApi
Felipe Leme2cab38c2019-01-11 10:39:14 -080032@TestApi
Felipe Leme559e21d2019-01-18 17:57:21 -080033public final class FillResponse {
Felipe Leme284ad1c2018-11-15 18:16:12 -080034
35 private final FillWindow mFillWindow;
36
37 private FillResponse(@NonNull Builder builder) {
38 mFillWindow = builder.mFillWindow;
39 }
40
41 /** @hide */
42 @Nullable
43 FillWindow getFillWindow() {
44 return mFillWindow;
45 }
46
47 /**
48 * Builder for {@link FillResponse} objects.
49 *
50 * @hide
51 */
52 @SystemApi
Felipe Leme2cab38c2019-01-11 10:39:14 -080053 @TestApi
Felipe Leme749b8892018-12-03 16:30:30 -080054 public static final class Builder {
Felipe Leme284ad1c2018-11-15 18:16:12 -080055
56 private FillWindow mFillWindow;
57
58 /**
59 * Sets the {@link FillWindow} used to display the Autofill UI.
60 *
61 * <p>Must be called when the service is handling the request so the Android System can
62 * properly synchronize the UI.
63 *
64 * @return this builder
65 */
66 public Builder setFillWindow(@NonNull FillWindow fillWindow) {
Felipe Leme559e21d2019-01-18 17:57:21 -080067 // TODO(b/123100712): check not null / unit test / throw exception if FillWindow not
68 // updated yet
Felipe Leme284ad1c2018-11-15 18:16:12 -080069 mFillWindow = fillWindow;
70 return this;
71 }
72
73 /**
74 * Tells the Android System that the given {@code ids} should not trigger further
75 * {@link FillRequest requests} when focused.
76 *
77 * @param ids ids of the fields that should be ignored
78 *
79 * @return this builder
80 */
81 public Builder setIgnoredIds(@NonNull List<AutofillId> ids) {
Felipe Leme559e21d2019-01-18 17:57:21 -080082 // TODO(b/123100695): implement / check not null / unit test
Felipe Leme284ad1c2018-11-15 18:16:12 -080083 return this;
84 }
85
86 /**
87 * Builds a new {@link FillResponse} instance.
88 *
89 * @throws IllegalStateException if any of the following conditions occur:
90 * <ol>
91 * <li>{@link #build()} was already called.
92 * <li>No call was made to {@link #setFillWindow(FillWindow)} or
93 * {@ling #setIgnoredIds(List<AutofillId>)}.
94 * </ol>
95 *
96 * @return A built response.
97 */
98 public FillResponse build() {
Felipe Leme559e21d2019-01-18 17:57:21 -080099 // TODO(b/123100712): check conditions / add unit test
Felipe Leme284ad1c2018-11-15 18:16:12 -0800100 return new FillResponse(this);
101 }
Felipe Leme284ad1c2018-11-15 18:16:12 -0800102 }
103
Felipe Leme559e21d2019-01-18 17:57:21 -0800104 // TODO(b/123100811): implement to String
Felipe Leme284ad1c2018-11-15 18:16:12 -0800105}