1 /* 2 * Copyright (C) 2008 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.view.inputmethod; 18 19 import android.os.Parcel; 20 import android.os.Parcelable; 21 import android.text.TextUtils; 22 23 /** 24 * Description of what an input method would like from an application when 25 * extract text from its input editor. 26 */ 27 public class ExtractedTextRequest implements Parcelable { 28 /** 29 * Arbitrary integer that can be supplied in the request, which will be 30 * delivered back when reporting updates. 31 */ 32 public int token; 33 34 /** 35 * Additional request flags, having the same possible values as the 36 * flags parameter of {@link InputConnection#getTextBeforeCursor 37 * InputConnection.getTextBeforeCursor()}. 38 */ 39 public int flags; 40 41 /** 42 * Hint for the maximum number of lines to return. 43 */ 44 public int hintMaxLines; 45 46 /** 47 * Hint for the maximum number of characters to return. 48 */ 49 public int hintMaxChars; 50 51 /** 52 * Used to package this object into a {@link Parcel}. 53 * 54 * @param dest The {@link Parcel} to be written. 55 * @param flags The flags used for parceling. 56 */ writeToParcel(Parcel dest, int flags)57 public void writeToParcel(Parcel dest, int flags) { 58 dest.writeInt(token); 59 dest.writeInt(this.flags); 60 dest.writeInt(hintMaxLines); 61 dest.writeInt(hintMaxChars); 62 } 63 64 /** 65 * Used to make this class parcelable. 66 */ 67 public static final Parcelable.Creator<ExtractedTextRequest> CREATOR 68 = new Parcelable.Creator<ExtractedTextRequest>() { 69 public ExtractedTextRequest createFromParcel(Parcel source) { 70 ExtractedTextRequest res = new ExtractedTextRequest(); 71 res.token = source.readInt(); 72 res.flags = source.readInt(); 73 res.hintMaxLines = source.readInt(); 74 res.hintMaxChars = source.readInt(); 75 return res; 76 } 77 78 public ExtractedTextRequest[] newArray(int size) { 79 return new ExtractedTextRequest[size]; 80 } 81 }; 82 describeContents()83 public int describeContents() { 84 return 0; 85 } 86 } 87