Debian Codegraph @

core/java/android/app/contentsuggestions/SelectionsRequest.java

raw symbols SCIP
1 /*
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 */
16
17 package android.app.contentsuggestions;
18
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.annotation.SystemApi;
22 import android.graphics.Point;
23 import android.os.Bundle;
24 import android.os.Parcel;
25 import android.os.Parcelable;
26
27 /**
28 * The request object used to request content selections from {@link ContentSuggestionsManager}.
29 *
30 * <p>Selections are requested for a given taskId as specified by
31 * {@link android.app.ActivityManager} and optionally take an interest point that specifies the
32 * point on the screen that should be considered as the most important.
33 *
34 * @hide
35 */
36 @SystemApi
37 public final class SelectionsRequest implements Parcelable {
38 private final int mTaskId;
39 @Nullable
40 private final Point mInterestPoint;
41 @Nullable
42 private final Bundle mExtras;
43
44 private SelectionsRequest(int taskId, @Nullable Point interestPoint, @Nullable Bundle extras) {
45 mTaskId = taskId;
46 mInterestPoint = interestPoint;
47 mExtras = extras;
48 }
49
50 /**
51 * Return the request task id.
52 */
53 public int getTaskId() {
54 return mTaskId;
55 }
56
57 /**
58 * Return the request point of interest or {@code null} if there is no point of interest for
59 * this request.
60 */
61 public @Nullable Point getInterestPoint() {
62 return mInterestPoint;
63 }
64
65 /**
66 * Return the request extras, may be an empty bundle if there aren't any.
67 */
68 public @NonNull Bundle getExtras() {
69 return mExtras == null ? new Bundle() : mExtras;
70 }
71
72 @Override
73 public int describeContents() {
74 return 0;
75 }
76
77 @Override
78 public void writeToParcel(Parcel dest, int flags) {
79 dest.writeInt(mTaskId);
80 dest.writeTypedObject(mInterestPoint, flags);
81 dest.writeBundle(mExtras);
82 }
83
84 public static final @android.annotation.NonNull Creator<SelectionsRequest> CREATOR =
85 new Creator<SelectionsRequest>() {
86 @Override
87 public SelectionsRequest createFromParcel(Parcel source) {
88 return new SelectionsRequest(
89 source.readInt(), source.readTypedObject(Point.CREATOR), source.readBundle());
90 }
91
92 @Override
93 public SelectionsRequest[] newArray(int size) {
94 return new SelectionsRequest[size];
95 }
96 };
97
98 /**
99 * A builder for selections requests events.
100 * @hide
101 */
102 @SystemApi
103 public static final class Builder {
104
105 private final int mTaskId;
106 private Point mInterestPoint;
107 private Bundle mExtras;
108
109 /**
110 * Default constructor.
111 *
112 * @param taskId of the type used by {@link android.app.ActivityManager}
113 */
114 public Builder(int taskId) {
115 mTaskId = taskId;
116 }
117
118 /**
119 * Sets the request extras.
120 */
121 public @NonNull Builder setExtras(@NonNull Bundle extras) {
122 mExtras = extras;
123 return this;
124 }
125
126 /**
127 * Sets the request interest point.
128 */
129 public @NonNull Builder setInterestPoint(@NonNull Point interestPoint) {
130 mInterestPoint = interestPoint;
131 return this;
132 }
133
134 /**
135 * Builds a new request instance.
136 */
137 public @NonNull SelectionsRequest build() {
138 return new SelectionsRequest(mTaskId, mInterestPoint, mExtras);
139 }
140 }
141 }