| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.view.inputmethod; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.os.Parcel; |
| 21 |
import android.os.Parcelable; |
| 22 |
import android.os.PersistableBundle; |
| 23 |
|
| 24 |
import java.util.ArrayList; |
| 25 |
import java.util.Collections; |
| 26 |
import java.util.List; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
public final class TextAttribute implements Parcelable { |
| 36 |
private final @NonNull List<String> mTextConversionSuggestions; |
| 37 |
private final @NonNull PersistableBundle mExtras; |
| 38 |
|
| 39 |
private TextAttribute(Builder builder) { |
| 40 |
mTextConversionSuggestions = builder.mTextConversionSuggestions; |
| 41 |
mExtras = builder.mExtras; |
| 42 |
} |
| 43 |
|
| 44 |
private TextAttribute(Parcel source) { |
| 45 |
mTextConversionSuggestions = source.createStringArrayList(); |
| 46 |
mExtras = source.readPersistableBundle(); |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
public @NonNull List<String> getTextConversionSuggestions() { |
| 57 |
return mTextConversionSuggestions; |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
public @NonNull PersistableBundle getExtras() { |
| 68 |
return mExtras; |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
public static final class Builder { |
| 75 |
private List<String> mTextConversionSuggestions = new ArrayList<>(); |
| 76 |
private PersistableBundle mExtras = new PersistableBundle(); |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
public @NonNull Builder setTextConversionSuggestions( |
| 91 |
@NonNull List<String> textConversionSuggestions) { |
| 92 |
mTextConversionSuggestions = Collections.unmodifiableList(textConversionSuggestions); |
| 93 |
return this; |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
public @NonNull Builder setExtras(@NonNull PersistableBundle extras) { |
| 105 |
mExtras = extras; |
| 106 |
return this; |
| 107 |
} |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
public @NonNull TextAttribute build() { |
| 113 |
return new TextAttribute(this); |
| 114 |
} |
| 115 |
} |
| 116 |
|
| 117 |
@Override |
| 118 |
public int describeContents() { |
| 119 |
return 0; |
| 120 |
} |
| 121 |
|
| 122 |
@Override |
| 123 |
public void writeToParcel(@NonNull Parcel dest, int flags) { |
| 124 |
dest.writeStringList(mTextConversionSuggestions); |
| 125 |
dest.writePersistableBundle(mExtras); |
| 126 |
} |
| 127 |
|
| 128 |
public static final @NonNull Parcelable.Creator<TextAttribute> CREATOR = |
| 129 |
new Parcelable.Creator<TextAttribute>() { |
| 130 |
@Override |
| 131 |
public TextAttribute createFromParcel(Parcel source) { |
| 132 |
return new TextAttribute(source); |
| 133 |
} |
| 134 |
|
| 135 |
@Override |
| 136 |
public TextAttribute[] newArray(int size) { |
| 137 |
return new TextAttribute[size]; |
| 138 |
} |
| 139 |
}; |
| 140 |
} |