1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.view.inputmethod;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
/**
* Information about text that has been extracted for use by an input method.
*
* This contains information about a portion of the currently edited text,
* that the IME should display into its own interface while in extracted mode.
*/
public class ExtractedText implements Parcelable {
/**
* The text that has been extracted.
*
* @see android.widget.TextView#getText()
*/
public CharSequence text;
/**
* The offset in the overall text at which the extracted text starts.
*/
public int startOffset;
/**
* If the content is a report of a partial text change, this is the
* offset where the change starts and it runs until
* {@link #partialEndOffset}. If the content is the full text, this
* field is -1.
*/
public int partialStartOffset;
/**
* If the content is a report of a partial text change, this is the offset
* where the change ends. Note that the actual text may be larger or
* smaller than the difference between this and {@link #partialStartOffset},
* meaning a reduction or increase, respectively, in the total text.
*/
public int partialEndOffset;
/**
* The offset where the selection currently starts within the extracted
* text. The real selection start position is at
* <var>startOffset</var>+<var>selectionStart</var>.
*/
public int selectionStart;
/**
* The offset where the selection currently ends within the extracted
* text. The real selection end position is at
* <var>startOffset</var>+<var>selectionEnd</var>.
*/
public int selectionEnd;
/**
* Bit for {@link #flags}: set if the text being edited can only be on
* a single line.
*/
public static final int FLAG_SINGLE_LINE = 0x0001;
/**
* Bit for {@link #flags}: set if the editor is currently in selection mode.
*
* This happens when a hardware keyboard with latched keys is attached and
* the shift key is currently latched.
*/
public static final int FLAG_SELECTING = 0x0002;
/**
* Additional bit flags of information about the edited text.
*/
public int flags;
/**
* The hint that has been extracted.
*
* @see android.widget.TextView#getHint()
*/
public CharSequence hint;
/**
* Used to package this object into a {@link Parcel}.
*
* @param dest The {@link Parcel} to be written.
* @param flags The flags used for parceling.
*/
public void writeToParcel(Parcel dest, int flags) {
TextUtils.writeToParcel(text, dest, flags);
dest.writeInt(startOffset);
dest.writeInt(partialStartOffset);
dest.writeInt(partialEndOffset);
dest.writeInt(selectionStart);
dest.writeInt(selectionEnd);
dest.writeInt(this.flags);
TextUtils.writeToParcel(hint, dest, flags);
}
/**
* Used to make this class parcelable.
*/
public static final @android.annotation.NonNull Parcelable.Creator<ExtractedText> CREATOR
= new Parcelable.Creator<ExtractedText>() {
public ExtractedText createFromParcel(Parcel source) {
ExtractedText res = new ExtractedText();
res.text = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
res.startOffset = source.readInt();
res.partialStartOffset = source.readInt();
res.partialEndOffset = source.readInt();
res.selectionStart = source.readInt();
res.selectionEnd = source.readInt();
res.flags = source.readInt();
res.hint = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
return res;
}
public ExtractedText[] newArray(int size) {
return new ExtractedText[size];
}
};
public int describeContents() {
return 0;
}
}
|