You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
src/api-impl: fix up code style, mainly for code imported from AOSP
used the following (plus manual edits):
`clang-format --style="{BasedOnStyle: LLVM, IndentWidth: 8, UseTab: Always, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: true, ColumnLimit: 0}`
This commit is contained in:
@@ -5,18 +5,18 @@ package android.text;
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class ClipboardManager {
|
||||
/**
|
||||
* Returns the text on the clipboard. It will eventually be possible
|
||||
* to store types other than text too, in which case this will return
|
||||
* null if the type cannot be coerced to text.
|
||||
*/
|
||||
public abstract CharSequence getText();
|
||||
/**
|
||||
* Sets the contents of the clipboard to the specified text.
|
||||
*/
|
||||
public abstract void setText(CharSequence text);
|
||||
/**
|
||||
* Returns true if the clipboard contains text; false otherwise.
|
||||
*/
|
||||
public abstract boolean hasText();
|
||||
/**
|
||||
* Returns the text on the clipboard. It will eventually be possible
|
||||
* to store types other than text too, in which case this will return
|
||||
* null if the type cannot be coerced to text.
|
||||
*/
|
||||
public abstract CharSequence getText();
|
||||
/**
|
||||
* Sets the contents of the clipboard to the specified text.
|
||||
*/
|
||||
public abstract void setText(CharSequence text);
|
||||
/**
|
||||
* Returns true if the clipboard contains text; false otherwise.
|
||||
*/
|
||||
public abstract boolean hasText();
|
||||
}
|
||||
|
||||
@@ -22,12 +22,11 @@ package android.text;
|
||||
* calling charAt() multiple times.
|
||||
*/
|
||||
public interface GetChars
|
||||
extends CharSequence
|
||||
{
|
||||
/**
|
||||
* Exactly like String.getChars(): copy chars <code>start</code>
|
||||
* through <code>end - 1</code> from this CharSequence into <code>dest</code>
|
||||
* beginning at offset <code>destoff</code>.
|
||||
*/
|
||||
public void getChars(int start, int end, char[] dest, int destoff);
|
||||
extends CharSequence {
|
||||
/**
|
||||
* Exactly like String.getChars(): copy chars <code>start</code>
|
||||
* through <code>end - 1</code> from this CharSequence into <code>dest</code>
|
||||
* beginning at offset <code>destoff</code>.
|
||||
*/
|
||||
public void getChars(int start, int end, char[] dest, int destoff);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package android.text;
|
||||
|
||||
public class Html {
|
||||
public static Spanned fromHtml(String source) {
|
||||
return new SpannableString(source.replace("<br/>", "\n")); // TODO when JTidy is in use: s/<br \/>//g
|
||||
}
|
||||
public static Spanned fromHtml(String source) {
|
||||
return new SpannableString(source.replace("<br/>", "\n")); // TODO when JTidy is in use: s/<br \/>//g
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ public interface InputFilter {
|
||||
public LengthFilter(int max) {
|
||||
}
|
||||
|
||||
public CharSequence filter (CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
|
||||
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@ package android.text;
|
||||
* Spanned it was placed in.
|
||||
*/
|
||||
public interface NoCopySpan {
|
||||
/**
|
||||
* Convenience equivalent for when you would just want a new Object() for
|
||||
* a span but want it to be no-copy. Use this instead.
|
||||
*/
|
||||
public class Concrete implements NoCopySpan {
|
||||
}
|
||||
/**
|
||||
* Convenience equivalent for when you would just want a new Object() for
|
||||
* a span but want it to be no-copy. Use this instead.
|
||||
*/
|
||||
public class Concrete implements NoCopySpan {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,21 +22,21 @@ package android.text;
|
||||
* added, changed, or removed.
|
||||
*/
|
||||
public interface SpanWatcher extends NoCopySpan {
|
||||
/**
|
||||
* This method is called to notify you that the specified object
|
||||
* has been attached to the specified range of the text.
|
||||
*/
|
||||
public void onSpanAdded(Spannable text, Object what, int start, int end);
|
||||
/**
|
||||
* This method is called to notify you that the specified object
|
||||
* has been detached from the specified range of the text.
|
||||
*/
|
||||
public void onSpanRemoved(Spannable text, Object what, int start, int end);
|
||||
/**
|
||||
* This method is called to notify you that the specified object
|
||||
* has been relocated from the range <code>ostart…oend</code>
|
||||
* to the new range <code>nstart…nend</code> of the text.
|
||||
*/
|
||||
public void onSpanChanged(Spannable text, Object what, int ostart, int oend,
|
||||
int nstart, int nend);
|
||||
/**
|
||||
* This method is called to notify you that the specified object
|
||||
* has been attached to the specified range of the text.
|
||||
*/
|
||||
public void onSpanAdded(Spannable text, Object what, int start, int end);
|
||||
/**
|
||||
* This method is called to notify you that the specified object
|
||||
* has been detached from the specified range of the text.
|
||||
*/
|
||||
public void onSpanRemoved(Spannable text, Object what, int start, int end);
|
||||
/**
|
||||
* This method is called to notify you that the specified object
|
||||
* has been relocated from the range <code>ostart…oend</code>
|
||||
* to the new range <code>nstart…nend</code> of the text.
|
||||
*/
|
||||
public void onSpanChanged(Spannable text, Object what, int ostart, int oend,
|
||||
int nstart, int nend);
|
||||
}
|
||||
|
||||
@@ -22,49 +22,48 @@ package android.text;
|
||||
* see {@link Editable} for that.
|
||||
*/
|
||||
public interface Spannable
|
||||
extends Spanned
|
||||
{
|
||||
/**
|
||||
* Attach the specified markup object to the range <code>start…end</code>
|
||||
* of the text, or move the object to that range if it was already
|
||||
* attached elsewhere. See {@link Spanned} for an explanation of
|
||||
* what the flags mean. The object can be one that has meaning only
|
||||
* within your application, or it can be one that the text system will
|
||||
* use to affect text display or behavior. Some noteworthy ones are
|
||||
* the subclasses of {@link android.text.style.CharacterStyle} and
|
||||
* {@link android.text.style.ParagraphStyle}, and
|
||||
* {@link android.text.TextWatcher} and
|
||||
* {@link android.text.SpanWatcher}.
|
||||
*/
|
||||
public void setSpan(Object what, int start, int end, int flags);
|
||||
extends Spanned {
|
||||
/**
|
||||
* Attach the specified markup object to the range <code>start…end</code>
|
||||
* of the text, or move the object to that range if it was already
|
||||
* attached elsewhere. See {@link Spanned} for an explanation of
|
||||
* what the flags mean. The object can be one that has meaning only
|
||||
* within your application, or it can be one that the text system will
|
||||
* use to affect text display or behavior. Some noteworthy ones are
|
||||
* the subclasses of {@link android.text.style.CharacterStyle} and
|
||||
* {@link android.text.style.ParagraphStyle}, and
|
||||
* {@link android.text.TextWatcher} and
|
||||
* {@link android.text.SpanWatcher}.
|
||||
*/
|
||||
public void setSpan(Object what, int start, int end, int flags);
|
||||
|
||||
/**
|
||||
* Remove the specified object from the range of text to which it
|
||||
* was attached, if any. It is OK to remove an object that was never
|
||||
* attached in the first place.
|
||||
*/
|
||||
public void removeSpan(Object what);
|
||||
/**
|
||||
* Remove the specified object from the range of text to which it
|
||||
* was attached, if any. It is OK to remove an object that was never
|
||||
* attached in the first place.
|
||||
*/
|
||||
public void removeSpan(Object what);
|
||||
|
||||
/**
|
||||
* Factory used by TextView to create new Spannables. You can subclass
|
||||
* it to provide something other than SpannableString.
|
||||
*/
|
||||
public static class Factory {
|
||||
private static Spannable.Factory sInstance = new Spannable.Factory();
|
||||
/**
|
||||
* Factory used by TextView to create new Spannables. You can subclass
|
||||
* it to provide something other than SpannableString.
|
||||
*/
|
||||
public static class Factory {
|
||||
private static Spannable.Factory sInstance = new Spannable.Factory();
|
||||
|
||||
/**
|
||||
* Returns the standard Spannable Factory.
|
||||
*/
|
||||
public static Spannable.Factory getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
/**
|
||||
* Returns the standard Spannable Factory.
|
||||
*/
|
||||
public static Spannable.Factory getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new SpannableString from the specified CharSequence.
|
||||
* You can override this to provide a different kind of Spannable.
|
||||
*/
|
||||
public Spannable newSpannable(CharSequence source) {
|
||||
return new SpannableString(source);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns a new SpannableString from the specified CharSequence.
|
||||
* You can override this to provide a different kind of Spannable.
|
||||
*/
|
||||
public Spannable newSpannable(CharSequence source) {
|
||||
return new SpannableString(source);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,41 +16,39 @@
|
||||
|
||||
package android.text;
|
||||
|
||||
|
||||
/**
|
||||
* This is the class for text whose content is immutable but to which
|
||||
* markup objects can be attached and detached.
|
||||
* For mutable text, see {@link SpannableStringBuilder}.
|
||||
*/
|
||||
public class SpannableString
|
||||
extends SpannableStringInternal
|
||||
implements CharSequence, GetChars, Spannable
|
||||
{
|
||||
public SpannableString(CharSequence source) {
|
||||
super(source, 0, source.length());
|
||||
}
|
||||
extends SpannableStringInternal
|
||||
implements CharSequence, GetChars, Spannable {
|
||||
public SpannableString(CharSequence source) {
|
||||
super(source, 0, source.length());
|
||||
}
|
||||
|
||||
private SpannableString(CharSequence source, int start, int end) {
|
||||
super(source, start, end);
|
||||
}
|
||||
private SpannableString(CharSequence source, int start, int end) {
|
||||
super(source, start, end);
|
||||
}
|
||||
|
||||
public static SpannableString valueOf(CharSequence source) {
|
||||
if (source instanceof SpannableString) {
|
||||
return (SpannableString) source;
|
||||
} else {
|
||||
return new SpannableString(source);
|
||||
}
|
||||
}
|
||||
public static SpannableString valueOf(CharSequence source) {
|
||||
if (source instanceof SpannableString) {
|
||||
return (SpannableString)source;
|
||||
} else {
|
||||
return new SpannableString(source);
|
||||
}
|
||||
}
|
||||
|
||||
public void setSpan(Object what, int start, int end, int flags) {
|
||||
super.setSpan(what, start, end, flags);
|
||||
}
|
||||
public void setSpan(Object what, int start, int end, int flags) {
|
||||
super.setSpan(what, start, end, flags);
|
||||
}
|
||||
|
||||
public void removeSpan(Object what) {
|
||||
super.removeSpan(what);
|
||||
}
|
||||
public void removeSpan(Object what) {
|
||||
super.removeSpan(what);
|
||||
}
|
||||
|
||||
public final CharSequence subSequence(int start, int end) {
|
||||
return new SpannableString(this, start, end);
|
||||
}
|
||||
public final CharSequence subSequence(int start, int end) {
|
||||
return new SpannableString(this, start, end);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -23,176 +23,175 @@ package android.text;
|
||||
* mutable text.
|
||||
*/
|
||||
public interface Spanned
|
||||
extends CharSequence
|
||||
{
|
||||
/**
|
||||
* Bitmask of bits that are relevent for controlling point/mark behavior
|
||||
* of spans.
|
||||
*
|
||||
* MARK and POINT are conceptually located <i>between</i> two adjacent characters.
|
||||
* A MARK is "attached" to the character before, while a POINT will stick to the character
|
||||
* after. The insertion cursor is conceptually located between the MARK and the POINT.
|
||||
*
|
||||
* As a result, inserting a new character between a MARK and a POINT will leave the MARK
|
||||
* unchanged, while the POINT will be shifted, now located after the inserted character and
|
||||
* still glued to the same character after it.
|
||||
*
|
||||
* Depending on whether the insertion happens at the beginning or the end of a span, the span
|
||||
* will hence be expanded to <i>include</i> the new character (when the span is using a MARK at
|
||||
* its beginning or a POINT at its end) or it will be <i>excluded</i>.
|
||||
*
|
||||
* Note that <i>before</i> and <i>after</i> here refer to offsets in the String, which are
|
||||
* independent from the visual representation of the text (left-to-right or right-to-left).
|
||||
*/
|
||||
public static final int SPAN_POINT_MARK_MASK = 0x33;
|
||||
|
||||
/**
|
||||
* 0-length spans with type SPAN_MARK_MARK behave like text marks:
|
||||
* they remain at their original offset when text is inserted
|
||||
* at that offset. Conceptually, the text is added after the mark.
|
||||
*/
|
||||
public static final int SPAN_MARK_MARK = 0x11;
|
||||
/**
|
||||
* SPAN_MARK_POINT is a synonym for {@link #SPAN_INCLUSIVE_INCLUSIVE}.
|
||||
*/
|
||||
public static final int SPAN_MARK_POINT = 0x12;
|
||||
/**
|
||||
* SPAN_POINT_MARK is a synonym for {@link #SPAN_EXCLUSIVE_EXCLUSIVE}.
|
||||
*/
|
||||
public static final int SPAN_POINT_MARK = 0x21;
|
||||
extends CharSequence {
|
||||
/**
|
||||
* Bitmask of bits that are relevent for controlling point/mark behavior
|
||||
* of spans.
|
||||
*
|
||||
* MARK and POINT are conceptually located <i>between</i> two adjacent characters.
|
||||
* A MARK is "attached" to the character before, while a POINT will stick to the character
|
||||
* after. The insertion cursor is conceptually located between the MARK and the POINT.
|
||||
*
|
||||
* As a result, inserting a new character between a MARK and a POINT will leave the MARK
|
||||
* unchanged, while the POINT will be shifted, now located after the inserted character and
|
||||
* still glued to the same character after it.
|
||||
*
|
||||
* Depending on whether the insertion happens at the beginning or the end of a span, the span
|
||||
* will hence be expanded to <i>include</i> the new character (when the span is using a MARK at
|
||||
* its beginning or a POINT at its end) or it will be <i>excluded</i>.
|
||||
*
|
||||
* Note that <i>before</i> and <i>after</i> here refer to offsets in the String, which are
|
||||
* independent from the visual representation of the text (left-to-right or right-to-left).
|
||||
*/
|
||||
public static final int SPAN_POINT_MARK_MASK = 0x33;
|
||||
|
||||
/**
|
||||
* 0-length spans with type SPAN_POINT_POINT behave like cursors:
|
||||
* they are pushed forward by the length of the insertion when text
|
||||
* is inserted at their offset.
|
||||
* The text is conceptually inserted before the point.
|
||||
*/
|
||||
public static final int SPAN_POINT_POINT = 0x22;
|
||||
/**
|
||||
* 0-length spans with type SPAN_MARK_MARK behave like text marks:
|
||||
* they remain at their original offset when text is inserted
|
||||
* at that offset. Conceptually, the text is added after the mark.
|
||||
*/
|
||||
public static final int SPAN_MARK_MARK = 0x11;
|
||||
/**
|
||||
* SPAN_MARK_POINT is a synonym for {@link #SPAN_INCLUSIVE_INCLUSIVE}.
|
||||
*/
|
||||
public static final int SPAN_MARK_POINT = 0x12;
|
||||
/**
|
||||
* SPAN_POINT_MARK is a synonym for {@link #SPAN_EXCLUSIVE_EXCLUSIVE}.
|
||||
*/
|
||||
public static final int SPAN_POINT_MARK = 0x21;
|
||||
|
||||
/**
|
||||
* SPAN_PARAGRAPH behaves like SPAN_INCLUSIVE_EXCLUSIVE
|
||||
* (SPAN_MARK_MARK), except that if either end of the span is
|
||||
* at the end of the buffer, that end behaves like _POINT
|
||||
* instead (so SPAN_INCLUSIVE_INCLUSIVE if it starts in the
|
||||
* middle and ends at the end, or SPAN_EXCLUSIVE_INCLUSIVE
|
||||
* if it both starts and ends at the end).
|
||||
* <p>
|
||||
* Its endpoints must be the start or end of the buffer or
|
||||
* immediately after a \n character, and if the \n
|
||||
* that anchors it is deleted, the endpoint is pulled to the
|
||||
* next \n that follows in the buffer (or to the end of
|
||||
* the buffer).
|
||||
*/
|
||||
public static final int SPAN_PARAGRAPH = 0x33;
|
||||
/**
|
||||
* 0-length spans with type SPAN_POINT_POINT behave like cursors:
|
||||
* they are pushed forward by the length of the insertion when text
|
||||
* is inserted at their offset.
|
||||
* The text is conceptually inserted before the point.
|
||||
*/
|
||||
public static final int SPAN_POINT_POINT = 0x22;
|
||||
|
||||
/**
|
||||
* Non-0-length spans of type SPAN_INCLUSIVE_EXCLUSIVE expand
|
||||
* to include text inserted at their starting point but not at their
|
||||
* ending point. When 0-length, they behave like marks.
|
||||
*/
|
||||
public static final int SPAN_INCLUSIVE_EXCLUSIVE = SPAN_MARK_MARK;
|
||||
/**
|
||||
* SPAN_PARAGRAPH behaves like SPAN_INCLUSIVE_EXCLUSIVE
|
||||
* (SPAN_MARK_MARK), except that if either end of the span is
|
||||
* at the end of the buffer, that end behaves like _POINT
|
||||
* instead (so SPAN_INCLUSIVE_INCLUSIVE if it starts in the
|
||||
* middle and ends at the end, or SPAN_EXCLUSIVE_INCLUSIVE
|
||||
* if it both starts and ends at the end).
|
||||
* <p>
|
||||
* Its endpoints must be the start or end of the buffer or
|
||||
* immediately after a \n character, and if the \n
|
||||
* that anchors it is deleted, the endpoint is pulled to the
|
||||
* next \n that follows in the buffer (or to the end of
|
||||
* the buffer).
|
||||
*/
|
||||
public static final int SPAN_PARAGRAPH = 0x33;
|
||||
|
||||
/**
|
||||
* Spans of type SPAN_INCLUSIVE_INCLUSIVE expand
|
||||
* to include text inserted at either their starting or ending point.
|
||||
*/
|
||||
public static final int SPAN_INCLUSIVE_INCLUSIVE = SPAN_MARK_POINT;
|
||||
/**
|
||||
* Non-0-length spans of type SPAN_INCLUSIVE_EXCLUSIVE expand
|
||||
* to include text inserted at their starting point but not at their
|
||||
* ending point. When 0-length, they behave like marks.
|
||||
*/
|
||||
public static final int SPAN_INCLUSIVE_EXCLUSIVE = SPAN_MARK_MARK;
|
||||
|
||||
/**
|
||||
* Spans of type SPAN_EXCLUSIVE_EXCLUSIVE do not expand
|
||||
* to include text inserted at either their starting or ending point.
|
||||
* They can never have a length of 0 and are automatically removed
|
||||
* from the buffer if all the text they cover is removed.
|
||||
*/
|
||||
public static final int SPAN_EXCLUSIVE_EXCLUSIVE = SPAN_POINT_MARK;
|
||||
/**
|
||||
* Spans of type SPAN_INCLUSIVE_INCLUSIVE expand
|
||||
* to include text inserted at either their starting or ending point.
|
||||
*/
|
||||
public static final int SPAN_INCLUSIVE_INCLUSIVE = SPAN_MARK_POINT;
|
||||
|
||||
/**
|
||||
* Non-0-length spans of type SPAN_EXCLUSIVE_INCLUSIVE expand
|
||||
* to include text inserted at their ending point but not at their
|
||||
* starting point. When 0-length, they behave like points.
|
||||
*/
|
||||
public static final int SPAN_EXCLUSIVE_INCLUSIVE = SPAN_POINT_POINT;
|
||||
/**
|
||||
* Spans of type SPAN_EXCLUSIVE_EXCLUSIVE do not expand
|
||||
* to include text inserted at either their starting or ending point.
|
||||
* They can never have a length of 0 and are automatically removed
|
||||
* from the buffer if all the text they cover is removed.
|
||||
*/
|
||||
public static final int SPAN_EXCLUSIVE_EXCLUSIVE = SPAN_POINT_MARK;
|
||||
|
||||
/**
|
||||
* This flag is set on spans that are being used to apply temporary
|
||||
* styling information on the composing text of an input method, so that
|
||||
* they can be found and removed when the composing text is being
|
||||
* replaced.
|
||||
*/
|
||||
public static final int SPAN_COMPOSING = 0x100;
|
||||
|
||||
/**
|
||||
* This flag will be set for intermediate span changes, meaning there
|
||||
* is guaranteed to be another change following it. Typically it is
|
||||
* used for {@link Selection} which automatically uses this with the first
|
||||
* offset it sets when updating the selection.
|
||||
*/
|
||||
public static final int SPAN_INTERMEDIATE = 0x200;
|
||||
|
||||
/**
|
||||
* The bits numbered SPAN_USER_SHIFT and above are available
|
||||
* for callers to use to store scalar data associated with their
|
||||
* span object.
|
||||
*/
|
||||
public static final int SPAN_USER_SHIFT = 24;
|
||||
/**
|
||||
* The bits specified by the SPAN_USER bitfield are available
|
||||
* for callers to use to store scalar data associated with their
|
||||
* span object.
|
||||
*/
|
||||
public static final int SPAN_USER = 0xFFFFFFFF << SPAN_USER_SHIFT;
|
||||
/**
|
||||
* Non-0-length spans of type SPAN_EXCLUSIVE_INCLUSIVE expand
|
||||
* to include text inserted at their ending point but not at their
|
||||
* starting point. When 0-length, they behave like points.
|
||||
*/
|
||||
public static final int SPAN_EXCLUSIVE_INCLUSIVE = SPAN_POINT_POINT;
|
||||
|
||||
/**
|
||||
* The bits numbered just above SPAN_PRIORITY_SHIFT determine the order
|
||||
* of change notifications -- higher numbers go first. You probably
|
||||
* don't need to set this; it is used so that when text changes, the
|
||||
* text layout gets the chance to update itself before any other
|
||||
* callbacks can inquire about the layout of the text.
|
||||
*/
|
||||
public static final int SPAN_PRIORITY_SHIFT = 16;
|
||||
/**
|
||||
* The bits specified by the SPAN_PRIORITY bitmap determine the order
|
||||
* of change notifications -- higher numbers go first. You probably
|
||||
* don't need to set this; it is used so that when text changes, the
|
||||
* text layout gets the chance to update itself before any other
|
||||
* callbacks can inquire about the layout of the text.
|
||||
*/
|
||||
public static final int SPAN_PRIORITY = 0xFF << SPAN_PRIORITY_SHIFT;
|
||||
/**
|
||||
* This flag is set on spans that are being used to apply temporary
|
||||
* styling information on the composing text of an input method, so that
|
||||
* they can be found and removed when the composing text is being
|
||||
* replaced.
|
||||
*/
|
||||
public static final int SPAN_COMPOSING = 0x100;
|
||||
|
||||
/**
|
||||
* Return an array of the markup objects attached to the specified
|
||||
* slice of this CharSequence and whose type is the specified type
|
||||
* or a subclass of it. Specify Object.class for the type if you
|
||||
* want all the objects regardless of type.
|
||||
*/
|
||||
public <T> T[] getSpans(int start, int end, Class<T> type);
|
||||
/**
|
||||
* This flag will be set for intermediate span changes, meaning there
|
||||
* is guaranteed to be another change following it. Typically it is
|
||||
* used for {@link Selection} which automatically uses this with the first
|
||||
* offset it sets when updating the selection.
|
||||
*/
|
||||
public static final int SPAN_INTERMEDIATE = 0x200;
|
||||
|
||||
/**
|
||||
* Return the beginning of the range of text to which the specified
|
||||
* markup object is attached, or -1 if the object is not attached.
|
||||
*/
|
||||
public int getSpanStart(Object tag);
|
||||
/**
|
||||
* The bits numbered SPAN_USER_SHIFT and above are available
|
||||
* for callers to use to store scalar data associated with their
|
||||
* span object.
|
||||
*/
|
||||
public static final int SPAN_USER_SHIFT = 24;
|
||||
/**
|
||||
* The bits specified by the SPAN_USER bitfield are available
|
||||
* for callers to use to store scalar data associated with their
|
||||
* span object.
|
||||
*/
|
||||
public static final int SPAN_USER = 0xFFFFFFFF << SPAN_USER_SHIFT;
|
||||
|
||||
/**
|
||||
* Return the end of the range of text to which the specified
|
||||
* markup object is attached, or -1 if the object is not attached.
|
||||
*/
|
||||
public int getSpanEnd(Object tag);
|
||||
/**
|
||||
* The bits numbered just above SPAN_PRIORITY_SHIFT determine the order
|
||||
* of change notifications -- higher numbers go first. You probably
|
||||
* don't need to set this; it is used so that when text changes, the
|
||||
* text layout gets the chance to update itself before any other
|
||||
* callbacks can inquire about the layout of the text.
|
||||
*/
|
||||
public static final int SPAN_PRIORITY_SHIFT = 16;
|
||||
/**
|
||||
* The bits specified by the SPAN_PRIORITY bitmap determine the order
|
||||
* of change notifications -- higher numbers go first. You probably
|
||||
* don't need to set this; it is used so that when text changes, the
|
||||
* text layout gets the chance to update itself before any other
|
||||
* callbacks can inquire about the layout of the text.
|
||||
*/
|
||||
public static final int SPAN_PRIORITY = 0xFF << SPAN_PRIORITY_SHIFT;
|
||||
|
||||
/**
|
||||
* Return the flags that were specified when {@link Spannable#setSpan} was
|
||||
* used to attach the specified markup object, or 0 if the specified
|
||||
* object has not been attached.
|
||||
*/
|
||||
public int getSpanFlags(Object tag);
|
||||
/**
|
||||
* Return an array of the markup objects attached to the specified
|
||||
* slice of this CharSequence and whose type is the specified type
|
||||
* or a subclass of it. Specify Object.class for the type if you
|
||||
* want all the objects regardless of type.
|
||||
*/
|
||||
public <T> T[] getSpans(int start, int end, Class<T> type);
|
||||
|
||||
/**
|
||||
* Return the first offset greater than or equal to <code>start</code>
|
||||
* where a markup object of class <code>type</code> begins or ends,
|
||||
* or <code>limit</code> if there are no starts or ends greater than or
|
||||
* equal to <code>start</code> but less than <code>limit</code>. Specify
|
||||
* <code>null</code> or Object.class for the type if you want every
|
||||
* transition regardless of type.
|
||||
*/
|
||||
public int nextSpanTransition(int start, int limit, Class type);
|
||||
/**
|
||||
* Return the beginning of the range of text to which the specified
|
||||
* markup object is attached, or -1 if the object is not attached.
|
||||
*/
|
||||
public int getSpanStart(Object tag);
|
||||
|
||||
/**
|
||||
* Return the end of the range of text to which the specified
|
||||
* markup object is attached, or -1 if the object is not attached.
|
||||
*/
|
||||
public int getSpanEnd(Object tag);
|
||||
|
||||
/**
|
||||
* Return the flags that were specified when {@link Spannable#setSpan} was
|
||||
* used to attach the specified markup object, or 0 if the specified
|
||||
* object has not been attached.
|
||||
*/
|
||||
public int getSpanFlags(Object tag);
|
||||
|
||||
/**
|
||||
* Return the first offset greater than or equal to <code>start</code>
|
||||
* where a markup object of class <code>type</code> begins or ends,
|
||||
* or <code>limit</code> if there are no starts or ends greater than or
|
||||
* equal to <code>start</code> but less than <code>limit</code>. Specify
|
||||
* <code>null</code> or Object.class for the type if you want every
|
||||
* transition regardless of type.
|
||||
*/
|
||||
public int nextSpanTransition(int start, int limit, Class type);
|
||||
}
|
||||
|
||||
@@ -16,33 +16,31 @@
|
||||
|
||||
package android.text;
|
||||
|
||||
|
||||
/**
|
||||
* This is the class for text whose content and markup are immutable.
|
||||
* For mutable markup, see {@link SpannableString}; for mutable text,
|
||||
* see {@link SpannableStringBuilder}.
|
||||
*/
|
||||
public final class SpannedString
|
||||
extends SpannableStringInternal
|
||||
implements CharSequence, GetChars, Spanned
|
||||
{
|
||||
public SpannedString(CharSequence source) {
|
||||
super(source, 0, source.length());
|
||||
}
|
||||
extends SpannableStringInternal
|
||||
implements CharSequence, GetChars, Spanned {
|
||||
public SpannedString(CharSequence source) {
|
||||
super(source, 0, source.length());
|
||||
}
|
||||
|
||||
private SpannedString(CharSequence source, int start, int end) {
|
||||
super(source, start, end);
|
||||
}
|
||||
private SpannedString(CharSequence source, int start, int end) {
|
||||
super(source, start, end);
|
||||
}
|
||||
|
||||
public CharSequence subSequence(int start, int end) {
|
||||
return new SpannedString(this, start, end);
|
||||
}
|
||||
public CharSequence subSequence(int start, int end) {
|
||||
return new SpannedString(this, start, end);
|
||||
}
|
||||
|
||||
public static SpannedString valueOf(CharSequence source) {
|
||||
if (source instanceof SpannedString) {
|
||||
return (SpannedString) source;
|
||||
} else {
|
||||
return new SpannedString(source);
|
||||
}
|
||||
}
|
||||
public static SpannedString valueOf(CharSequence source) {
|
||||
if (source instanceof SpannedString) {
|
||||
return (SpannedString)source;
|
||||
} else {
|
||||
return new SpannedString(source);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,59 +24,59 @@ import android.graphics.Paint;
|
||||
*/
|
||||
public class TextPaint extends Paint {
|
||||
|
||||
// Special value 0 means no background paint
|
||||
public int bgColor;
|
||||
public int baselineShift;
|
||||
public int linkColor;
|
||||
public int[] drawableState;
|
||||
public float density = 1.0f;
|
||||
/**
|
||||
* Special value 0 means no custom underline
|
||||
* @hide
|
||||
*/
|
||||
public int underlineColor = 0;
|
||||
/**
|
||||
* Defined as a multiplier of the default underline thickness. Use 1.0f for default thickness.
|
||||
* @hide
|
||||
*/
|
||||
public float underlineThickness;
|
||||
// Special value 0 means no background paint
|
||||
public int bgColor;
|
||||
public int baselineShift;
|
||||
public int linkColor;
|
||||
public int[] drawableState;
|
||||
public float density = 1.0f;
|
||||
/**
|
||||
* Special value 0 means no custom underline
|
||||
* @hide
|
||||
*/
|
||||
public int underlineColor = 0;
|
||||
/**
|
||||
* Defined as a multiplier of the default underline thickness. Use 1.0f for default thickness.
|
||||
* @hide
|
||||
*/
|
||||
public float underlineThickness;
|
||||
|
||||
public TextPaint() {
|
||||
super();
|
||||
}
|
||||
public TextPaint() {
|
||||
super();
|
||||
}
|
||||
|
||||
public TextPaint(int flags) {
|
||||
super(/*flags*/);
|
||||
}
|
||||
public TextPaint(int flags) {
|
||||
super(/*flags*/);
|
||||
}
|
||||
|
||||
public TextPaint(Paint p) {
|
||||
super(/*p*/);
|
||||
}
|
||||
public TextPaint(Paint p) {
|
||||
super(/*p*/);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the fields from tp into this TextPaint, including the
|
||||
* fields inherited from Paint.
|
||||
*/
|
||||
public void set(TextPaint tp) {
|
||||
// super.set(tp);
|
||||
/**
|
||||
* Copy the fields from tp into this TextPaint, including the
|
||||
* fields inherited from Paint.
|
||||
*/
|
||||
public void set(TextPaint tp) {
|
||||
// super.set(tp);
|
||||
|
||||
bgColor = tp.bgColor;
|
||||
baselineShift = tp.baselineShift;
|
||||
linkColor = tp.linkColor;
|
||||
drawableState = tp.drawableState;
|
||||
density = tp.density;
|
||||
underlineColor = tp.underlineColor;
|
||||
underlineThickness = tp.underlineThickness;
|
||||
}
|
||||
bgColor = tp.bgColor;
|
||||
baselineShift = tp.baselineShift;
|
||||
linkColor = tp.linkColor;
|
||||
drawableState = tp.drawableState;
|
||||
density = tp.density;
|
||||
underlineColor = tp.underlineColor;
|
||||
underlineThickness = tp.underlineThickness;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a custom underline for this Paint.
|
||||
* @param color underline solid color
|
||||
* @param thickness underline thickness
|
||||
* @hide
|
||||
*/
|
||||
public void setUnderlineText(int color, float thickness) {
|
||||
underlineColor = color;
|
||||
underlineThickness = thickness;
|
||||
}
|
||||
/**
|
||||
* Defines a custom underline for this Paint.
|
||||
* @param color underline solid color
|
||||
* @param thickness underline thickness
|
||||
* @hide
|
||||
*/
|
||||
public void setUnderlineText(int color, float thickness) {
|
||||
underlineColor = color;
|
||||
underlineThickness = thickness;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,60 +7,59 @@ public class TextUtils {
|
||||
|
||||
/* split */
|
||||
|
||||
private static String[] EMPTY_STRING_ARRAY = new String[]{};
|
||||
private static String[] EMPTY_STRING_ARRAY = new String[] {};
|
||||
|
||||
public static String[] split(String text, String expression) {
|
||||
if (text.length() == 0) {
|
||||
return EMPTY_STRING_ARRAY;
|
||||
} else {
|
||||
return text.split(expression, -1);
|
||||
}
|
||||
}
|
||||
public static String[] split(String text, String expression) {
|
||||
if (text.length() == 0) {
|
||||
return EMPTY_STRING_ARRAY;
|
||||
} else {
|
||||
return text.split(expression, -1);
|
||||
}
|
||||
}
|
||||
|
||||
public static String[] split(String text, Pattern pattern) {
|
||||
if (text.length() == 0) {
|
||||
return EMPTY_STRING_ARRAY;
|
||||
} else {
|
||||
return pattern.split(text, -1);
|
||||
}
|
||||
}
|
||||
public static String[] split(String text, Pattern pattern) {
|
||||
if (text.length() == 0) {
|
||||
return EMPTY_STRING_ARRAY;
|
||||
} else {
|
||||
return pattern.split(text, -1);
|
||||
}
|
||||
}
|
||||
|
||||
/* join */
|
||||
|
||||
public static String join(CharSequence delimiter, Object[] tokens) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean firstTime = true;
|
||||
for (Object token : tokens) {
|
||||
if (firstTime) {
|
||||
firstTime = false;
|
||||
} else {
|
||||
sb.append(delimiter);
|
||||
}
|
||||
sb.append(token);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String join(CharSequence delimiter, Object[] tokens) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean firstTime = true;
|
||||
for (Object token: tokens) {
|
||||
if (firstTime) {
|
||||
firstTime = false;
|
||||
} else {
|
||||
sb.append(delimiter);
|
||||
}
|
||||
sb.append(token);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String join(CharSequence delimiter, Iterable tokens) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean firstTime = true;
|
||||
for (Object token: tokens) {
|
||||
if (firstTime) {
|
||||
firstTime = false;
|
||||
} else {
|
||||
sb.append(delimiter);
|
||||
}
|
||||
sb.append(token);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
public static String join(CharSequence delimiter, Iterable tokens) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean firstTime = true;
|
||||
for (Object token : tokens) {
|
||||
if (firstTime) {
|
||||
firstTime = false;
|
||||
} else {
|
||||
sb.append(delimiter);
|
||||
}
|
||||
sb.append(token);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
// end of unchanged from android source
|
||||
|
||||
public static CharSequence join(Iterable<CharSequence> list) {
|
||||
final CharSequence delimiter = ","; // ????
|
||||
return join(delimiter, list);
|
||||
}
|
||||
public static CharSequence join(Iterable<CharSequence> list) {
|
||||
final CharSequence delimiter = ","; // ????
|
||||
return join(delimiter, list);
|
||||
}
|
||||
|
||||
public static boolean isEmpty(CharSequence str) {
|
||||
return str.equals(""); // presumably?
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
package android.text;
|
||||
|
||||
public interface TextWatcher {
|
||||
|
||||
}
|
||||
|
||||
@@ -5,5 +5,5 @@ import android.widget.TextView;
|
||||
|
||||
public class Linkify {
|
||||
public static final boolean addLinks(Spannable text, int mask) { return true; }
|
||||
public static final boolean addLinks(TextView text, int mask) { return true; }
|
||||
public static final boolean addLinks(TextView text, int mask) { return true; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user