| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package android.app.smartspace; |
| 17 |
|
| 18 |
import android.annotation.IntDef; |
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.Nullable; |
| 21 |
import android.annotation.SystemApi; |
| 22 |
import android.os.Parcel; |
| 23 |
import android.os.Parcelable; |
| 24 |
|
| 25 |
import java.lang.annotation.Retention; |
| 26 |
import java.lang.annotation.RetentionPolicy; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
@SystemApi |
| 34 |
public final class SmartspaceTargetEvent implements Parcelable { |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
public static final int EVENT_TARGET_INTERACTION = 1; |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
public static final int EVENT_TARGET_SHOWN = 2; |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
public static final int EVENT_TARGET_HIDDEN = 3; |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
public static final int EVENT_TARGET_DISMISS = 4; |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
public static final int EVENT_TARGET_BLOCK = 5; |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
public static final int EVENT_UI_SURFACE_SHOWN = 6; |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
public static final int EVENT_UI_SURFACE_HIDDEN = 7; |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
@NonNull |
| 70 |
public static final Creator<SmartspaceTargetEvent> CREATOR = |
| 71 |
new Creator<SmartspaceTargetEvent>() { |
| 72 |
public SmartspaceTargetEvent createFromParcel(Parcel parcel) { |
| 73 |
return new SmartspaceTargetEvent(parcel); |
| 74 |
} |
| 75 |
|
| 76 |
public SmartspaceTargetEvent[] newArray(int size) { |
| 77 |
return new SmartspaceTargetEvent[size]; |
| 78 |
} |
| 79 |
}; |
| 80 |
|
| 81 |
@Nullable |
| 82 |
private final SmartspaceTarget mSmartspaceTarget; |
| 83 |
|
| 84 |
@Nullable |
| 85 |
private final String mSmartspaceActionId; |
| 86 |
|
| 87 |
@EventType |
| 88 |
private final int mEventType; |
| 89 |
|
| 90 |
private SmartspaceTargetEvent(@Nullable SmartspaceTarget smartspaceTarget, |
| 91 |
@Nullable String smartspaceActionId, |
| 92 |
@EventType int eventType) { |
| 93 |
mSmartspaceTarget = smartspaceTarget; |
| 94 |
mSmartspaceActionId = smartspaceActionId; |
| 95 |
mEventType = eventType; |
| 96 |
} |
| 97 |
|
| 98 |
private SmartspaceTargetEvent(Parcel parcel) { |
| 99 |
mSmartspaceTarget = parcel.readParcelable(null, android.app.smartspace.SmartspaceTarget.class); |
| 100 |
mSmartspaceActionId = parcel.readString(); |
| 101 |
mEventType = parcel.readInt(); |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
@Nullable |
| 108 |
public SmartspaceTarget getSmartspaceTarget() { |
| 109 |
return mSmartspaceTarget; |
| 110 |
} |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
@Nullable |
| 116 |
public String getSmartspaceActionId() { |
| 117 |
return mSmartspaceActionId; |
| 118 |
} |
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
@NonNull |
| 124 |
@EventType |
| 125 |
public int getEventType() { |
| 126 |
return mEventType; |
| 127 |
} |
| 128 |
|
| 129 |
@Override |
| 130 |
public int describeContents() { |
| 131 |
return 0; |
| 132 |
} |
| 133 |
|
| 134 |
@Override |
| 135 |
public void writeToParcel(@NonNull Parcel dest, int flags) { |
| 136 |
dest.writeParcelable(mSmartspaceTarget, flags); |
| 137 |
dest.writeString(mSmartspaceActionId); |
| 138 |
dest.writeInt(mEventType); |
| 139 |
} |
| 140 |
|
| 141 |
@Override |
| 142 |
public String toString() { |
| 143 |
return "SmartspaceTargetEvent{" |
| 144 |
+ "mSmartspaceTarget=" + mSmartspaceTarget |
| 145 |
+ ", mSmartspaceActionId='" + mSmartspaceActionId + '\'' |
| 146 |
+ ", mEventType=" + mEventType |
| 147 |
+ '}'; |
| 148 |
} |
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
@IntDef(prefix = {"EVENT_"}, value = { |
| 154 |
EVENT_TARGET_INTERACTION, |
| 155 |
EVENT_TARGET_SHOWN, |
| 156 |
EVENT_TARGET_HIDDEN, |
| 157 |
EVENT_TARGET_DISMISS, |
| 158 |
EVENT_TARGET_BLOCK, |
| 159 |
EVENT_UI_SURFACE_SHOWN, |
| 160 |
EVENT_UI_SURFACE_HIDDEN |
| 161 |
}) |
| 162 |
@Retention(RetentionPolicy.SOURCE) |
| 163 |
public @interface EventType { |
| 164 |
} |
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
@SystemApi |
| 172 |
public static final class Builder { |
| 173 |
@EventType |
| 174 |
private final int mEventType; |
| 175 |
@Nullable |
| 176 |
private SmartspaceTarget mSmartspaceTarget; |
| 177 |
@Nullable |
| 178 |
private String mSmartspaceActionId; |
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
public Builder(@EventType int eventType) { |
| 184 |
mEventType = eventType; |
| 185 |
} |
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
@NonNull |
| 191 |
public Builder setSmartspaceTarget(@NonNull SmartspaceTarget smartspaceTarget) { |
| 192 |
mSmartspaceTarget = smartspaceTarget; |
| 193 |
return this; |
| 194 |
} |
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
@NonNull |
| 200 |
public Builder setSmartspaceActionId(@NonNull String smartspaceActionId) { |
| 201 |
mSmartspaceActionId = smartspaceActionId; |
| 202 |
return this; |
| 203 |
} |
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
@NonNull |
| 209 |
public SmartspaceTargetEvent build() { |
| 210 |
return new SmartspaceTargetEvent(mSmartspaceTarget, mSmartspaceActionId, mEventType); |
| 211 |
} |
| 212 |
} |
| 213 |
} |