diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 18:28:45 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 18:28:45 -0800 |
commit | d83a98f4ce9cfa908f5c54bbd70f03eec07e7553 (patch) | |
tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /core/java/android/text/style | |
parent | 076357b8567458d4b6dfdcf839ef751634cd2bfb (diff) | |
download | frameworks_base-d83a98f4ce9cfa908f5c54bbd70f03eec07e7553.zip frameworks_base-d83a98f4ce9cfa908f5c54bbd70f03eec07e7553.tar.gz frameworks_base-d83a98f4ce9cfa908f5c54bbd70f03eec07e7553.tar.bz2 |
auto import from //depot/cupcake/@135843
Diffstat (limited to 'core/java/android/text/style')
35 files changed, 0 insertions, 2276 deletions
diff --git a/core/java/android/text/style/AbsoluteSizeSpan.java b/core/java/android/text/style/AbsoluteSizeSpan.java deleted file mode 100644 index 484f8ce..0000000 --- a/core/java/android/text/style/AbsoluteSizeSpan.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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.text.style; - -import android.os.Parcel; -import android.text.ParcelableSpan; -import android.text.TextPaint; -import android.text.TextUtils; - -public class AbsoluteSizeSpan extends MetricAffectingSpan implements ParcelableSpan { - - private final int mSize; - - public AbsoluteSizeSpan(int size) { - mSize = size; - } - - public AbsoluteSizeSpan(Parcel src) { - mSize = src.readInt(); - } - - public int getSpanTypeId() { - return TextUtils.ABSOLUTE_SIZE_SPAN; - } - - public int describeContents() { - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - dest.writeInt(mSize); - } - - public int getSize() { - return mSize; - } - - @Override - public void updateDrawState(TextPaint ds) { - ds.setTextSize(mSize); - } - - @Override - public void updateMeasureState(TextPaint ds) { - ds.setTextSize(mSize); - } -} diff --git a/core/java/android/text/style/AlignmentSpan.java b/core/java/android/text/style/AlignmentSpan.java deleted file mode 100644 index b8a37da..0000000 --- a/core/java/android/text/style/AlignmentSpan.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -import android.os.Parcel; -import android.text.Layout; -import android.text.ParcelableSpan; -import android.text.TextUtils; - -public interface AlignmentSpan extends ParagraphStyle { - public Layout.Alignment getAlignment(); - - public static class Standard - implements AlignmentSpan, ParcelableSpan { - public Standard(Layout.Alignment align) { - mAlignment = align; - } - - public Standard(Parcel src) { - mAlignment = Layout.Alignment.valueOf(src.readString()); - } - - public int getSpanTypeId() { - return TextUtils.ALIGNMENT_SPAN; - } - - public int describeContents() { - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(mAlignment.name()); - } - - public Layout.Alignment getAlignment() { - return mAlignment; - } - - private final Layout.Alignment mAlignment; - } -} diff --git a/core/java/android/text/style/BackgroundColorSpan.java b/core/java/android/text/style/BackgroundColorSpan.java deleted file mode 100644 index 580a369..0000000 --- a/core/java/android/text/style/BackgroundColorSpan.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -import android.os.Parcel; -import android.text.ParcelableSpan; -import android.text.TextPaint; -import android.text.TextUtils; - -public class BackgroundColorSpan extends CharacterStyle - implements UpdateAppearance, ParcelableSpan { - - private final int mColor; - - public BackgroundColorSpan(int color) { - mColor = color; - } - - public BackgroundColorSpan(Parcel src) { - mColor = src.readInt(); - } - - public int getSpanTypeId() { - return TextUtils.BACKGROUND_COLOR_SPAN; - } - - public int describeContents() { - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - dest.writeInt(mColor); - } - - public int getBackgroundColor() { - return mColor; - } - - @Override - public void updateDrawState(TextPaint ds) { - ds.bgColor = mColor; - } -} diff --git a/core/java/android/text/style/BulletSpan.java b/core/java/android/text/style/BulletSpan.java deleted file mode 100644 index 655bd81..0000000 --- a/core/java/android/text/style/BulletSpan.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -import android.graphics.Canvas; -import android.graphics.Paint; -import android.os.Parcel; -import android.text.Layout; -import android.text.ParcelableSpan; -import android.text.Spanned; -import android.text.TextUtils; - -public class BulletSpan implements LeadingMarginSpan, ParcelableSpan { - private final int mGapWidth; - private final boolean mWantColor; - private final int mColor; - - private static final int BULLET_RADIUS = 3; - public static final int STANDARD_GAP_WIDTH = 2; - - public BulletSpan() { - mGapWidth = STANDARD_GAP_WIDTH; - mWantColor = false; - mColor = 0; - } - - public BulletSpan(int gapWidth) { - mGapWidth = gapWidth; - mWantColor = false; - mColor = 0; - } - - public BulletSpan(int gapWidth, int color) { - mGapWidth = gapWidth; - mWantColor = true; - mColor = color; - } - - public BulletSpan(Parcel src) { - mGapWidth = src.readInt(); - mWantColor = src.readInt() != 0; - mColor = src.readInt(); - } - - public int getSpanTypeId() { - return TextUtils.BULLET_SPAN; - } - - public int describeContents() { - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - dest.writeInt(mGapWidth); - dest.writeInt(mWantColor ? 1 : 0); - dest.writeInt(mColor); - } - - public int getLeadingMargin(boolean first) { - return 2 * BULLET_RADIUS + mGapWidth; - } - - public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, - int top, int baseline, int bottom, - CharSequence text, int start, int end, - boolean first, Layout l) { - if (((Spanned) text).getSpanStart(this) == start) { - Paint.Style style = p.getStyle(); - int oldcolor = 0; - - if (mWantColor) { - oldcolor = p.getColor(); - p.setColor(mColor); - } - - p.setStyle(Paint.Style.FILL); - - c.drawCircle(x + dir * BULLET_RADIUS, (top + bottom) / 2.0f, - BULLET_RADIUS, p); - - if (mWantColor) { - p.setColor(oldcolor); - } - - p.setStyle(style); - } - } -} diff --git a/core/java/android/text/style/CharacterStyle.java b/core/java/android/text/style/CharacterStyle.java deleted file mode 100644 index 14dfddd..0000000 --- a/core/java/android/text/style/CharacterStyle.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -import android.text.TextPaint; - -/** - * The classes that affect character-level text formatting extend this - * class. Most extend its subclass {@link MetricAffectingSpan}, but simple - * ones may just implement {@link UpdateAppearance}. - */ -public abstract class CharacterStyle { - public abstract void updateDrawState(TextPaint tp); - - /** - * A given CharacterStyle can only applied to a single region of a given - * Spanned. If you need to attach the same CharacterStyle to multiple - * regions, you can use this method to wrap it with a new object that - * will have the same effect but be a distinct object so that it can - * also be attached without conflict. - */ - public static CharacterStyle wrap(CharacterStyle cs) { - if (cs instanceof MetricAffectingSpan) { - return new MetricAffectingSpan.Passthrough((MetricAffectingSpan) cs); - } else { - return new Passthrough(cs); - } - } - - /** - * Returns "this" for most CharacterStyles, but for CharacterStyles - * that were generated by {@link #wrap}, returns the underlying - * CharacterStyle. - */ - public CharacterStyle getUnderlying() { - return this; - } - - /** - * A Passthrough CharacterStyle is one that - * passes {@link #updateDrawState} calls through to the - * specified CharacterStyle while still being a distinct object, - * and is therefore able to be attached to the same Spannable - * to which the specified CharacterStyle is already attached. - */ - private static class Passthrough extends CharacterStyle { - private CharacterStyle mStyle; - - /** - * Creates a new Passthrough of the specfied CharacterStyle. - */ - public Passthrough(CharacterStyle cs) { - mStyle = cs; - } - - /** - * Passes updateDrawState through to the underlying CharacterStyle. - */ - @Override - public void updateDrawState(TextPaint tp) { - mStyle.updateDrawState(tp); - } - - /** - * Returns the CharacterStyle underlying this one, or the one - * underlying it if it too is a Passthrough. - */ - @Override - public CharacterStyle getUnderlying() { - return mStyle.getUnderlying(); - } - } -} diff --git a/core/java/android/text/style/ClickableSpan.java b/core/java/android/text/style/ClickableSpan.java deleted file mode 100644 index 989ef54..0000000 --- a/core/java/android/text/style/ClickableSpan.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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.text.style; - -import android.text.TextPaint; -import android.view.View; - -/** - * If an object of this type is attached to the text of a TextView - * with a movement method of LinkMovementMethod, the affected spans of - * text can be selected. If clicked, the {@link #onClick} method will - * be called. - */ -public abstract class ClickableSpan extends CharacterStyle implements UpdateAppearance { - - /** - * Performs the click action associated with this span. - */ - public abstract void onClick(View widget); - - /** - * Makes the text underlined and in the link color. - */ - @Override - public void updateDrawState(TextPaint ds) { - ds.setColor(ds.linkColor); - ds.setUnderlineText(true); - } -} diff --git a/core/java/android/text/style/DrawableMarginSpan.java b/core/java/android/text/style/DrawableMarginSpan.java deleted file mode 100644 index 3c471a5..0000000 --- a/core/java/android/text/style/DrawableMarginSpan.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -import android.graphics.drawable.Drawable; -import android.graphics.Paint; -import android.graphics.Canvas; -import android.graphics.RectF; -import android.text.Spanned; -import android.text.Layout; - -public class DrawableMarginSpan -implements LeadingMarginSpan, LineHeightSpan -{ - public DrawableMarginSpan(Drawable b) { - mDrawable = b; - } - - public DrawableMarginSpan(Drawable b, int pad) { - mDrawable = b; - mPad = pad; - } - - public int getLeadingMargin(boolean first) { - return mDrawable.getIntrinsicWidth() + mPad; - } - - public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, - int top, int baseline, int bottom, - CharSequence text, int start, int end, - boolean first, Layout layout) { - int st = ((Spanned) text).getSpanStart(this); - int ix = (int)x; - int itop = (int)layout.getLineTop(layout.getLineForOffset(st)); - - int dw = mDrawable.getIntrinsicWidth(); - int dh = mDrawable.getIntrinsicHeight(); - - if (dir < 0) - x -= dw; - - // XXX What to do about Paint? - mDrawable.setBounds(ix, itop, ix+dw, itop+dh); - mDrawable.draw(c); - } - - public void chooseHeight(CharSequence text, int start, int end, - int istartv, int v, - Paint.FontMetricsInt fm) { - if (end == ((Spanned) text).getSpanEnd(this)) { - int ht = mDrawable.getIntrinsicHeight(); - - int need = ht - (v + fm.descent - fm.ascent - istartv); - if (need > 0) - fm.descent += need; - - need = ht - (v + fm.bottom - fm.top - istartv); - if (need > 0) - fm.bottom += need; - } - } - - private Drawable mDrawable; - private int mPad; -} diff --git a/core/java/android/text/style/DynamicDrawableSpan.java b/core/java/android/text/style/DynamicDrawableSpan.java deleted file mode 100644 index 89dc45b..0000000 --- a/core/java/android/text/style/DynamicDrawableSpan.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Rect; -import android.graphics.Paint.Style; -import android.graphics.drawable.Drawable; -import android.util.Log; - -import java.lang.ref.WeakReference; - -/** - * - */ -public abstract class DynamicDrawableSpan extends ReplacementSpan { - private static final String TAG = "DynamicDrawableSpan"; - - /** - * A constant indicating that the bottom of this span should be aligned - * with the bottom of the surrounding text, i.e., at the same level as the - * lowest descender in the text. - */ - public static final int ALIGN_BOTTOM = 0; - - /** - * A constant indicating that the bottom of this span should be aligned - * with the baseline of the surrounding text. - */ - public static final int ALIGN_BASELINE = 1; - - protected final int mVerticalAlignment; - - public DynamicDrawableSpan() { - mVerticalAlignment = ALIGN_BOTTOM; - } - - /** - * @param verticalAlignment one of {@link #ALIGN_BOTTOM} or {@link #ALIGN_BASELINE}. - */ - protected DynamicDrawableSpan(int verticalAlignment) { - mVerticalAlignment = verticalAlignment; - } - - /** - * Returns the vertical alignment of this span, one of {@link #ALIGN_BOTTOM} or - * {@link #ALIGN_BASELINE}. - */ - public int getVerticalAlignment() { - return mVerticalAlignment; - } - - /** - * Your subclass must implement this method to provide the bitmap - * to be drawn. The dimensions of the bitmap must be the same - * from each call to the next. - */ - public abstract Drawable getDrawable(); - - @Override - public int getSize(Paint paint, CharSequence text, - int start, int end, - Paint.FontMetricsInt fm) { - Drawable d = getCachedDrawable(); - Rect rect = d.getBounds(); - - if (fm != null) { - fm.ascent = -rect.bottom; - fm.descent = 0; - - fm.top = fm.ascent; - fm.bottom = 0; - } - - return rect.right; - } - - @Override - public void draw(Canvas canvas, CharSequence text, - int start, int end, float x, - int top, int y, int bottom, Paint paint) { - Drawable b = getCachedDrawable(); - canvas.save(); - - int transY = bottom - b.getBounds().bottom; - if (mVerticalAlignment == ALIGN_BASELINE) { - transY -= paint.getFontMetricsInt().descent; - } - - canvas.translate(x, transY); - b.draw(canvas); - canvas.restore(); - } - - private Drawable getCachedDrawable() { - WeakReference<Drawable> wr = mDrawableRef; - Drawable d = null; - - if (wr != null) - d = wr.get(); - - if (d == null) { - d = getDrawable(); - mDrawableRef = new WeakReference<Drawable>(d); - } - - return d; - } - - private WeakReference<Drawable> mDrawableRef; -} - diff --git a/core/java/android/text/style/ForegroundColorSpan.java b/core/java/android/text/style/ForegroundColorSpan.java deleted file mode 100644 index 476124d..0000000 --- a/core/java/android/text/style/ForegroundColorSpan.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -import android.os.Parcel; -import android.text.ParcelableSpan; -import android.text.TextPaint; -import android.text.TextUtils; - -public class ForegroundColorSpan extends CharacterStyle - implements UpdateAppearance, ParcelableSpan { - - private final int mColor; - - public ForegroundColorSpan(int color) { - mColor = color; - } - - public ForegroundColorSpan(Parcel src) { - mColor = src.readInt(); - } - - public int getSpanTypeId() { - return TextUtils.FOREGROUND_COLOR_SPAN; - } - - public int describeContents() { - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - dest.writeInt(mColor); - } - - public int getForegroundColor() { - return mColor; - } - - @Override - public void updateDrawState(TextPaint ds) { - ds.setColor(mColor); - } -} diff --git a/core/java/android/text/style/IconMarginSpan.java b/core/java/android/text/style/IconMarginSpan.java deleted file mode 100644 index c786a17..0000000 --- a/core/java/android/text/style/IconMarginSpan.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -import android.graphics.Paint; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.RectF; -import android.text.Spanned; -import android.text.Layout; - -public class IconMarginSpan -implements LeadingMarginSpan, LineHeightSpan -{ - public IconMarginSpan(Bitmap b) { - mBitmap = b; - } - - public IconMarginSpan(Bitmap b, int pad) { - mBitmap = b; - mPad = pad; - } - - public int getLeadingMargin(boolean first) { - return mBitmap.getWidth() + mPad; - } - - public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, - int top, int baseline, int bottom, - CharSequence text, int start, int end, - boolean first, Layout layout) { - int st = ((Spanned) text).getSpanStart(this); - int itop = layout.getLineTop(layout.getLineForOffset(st)); - - if (dir < 0) - x -= mBitmap.getWidth(); - - c.drawBitmap(mBitmap, x, itop, p); - } - - public void chooseHeight(CharSequence text, int start, int end, - int istartv, int v, - Paint.FontMetricsInt fm) { - if (end == ((Spanned) text).getSpanEnd(this)) { - int ht = mBitmap.getHeight(); - - int need = ht - (v + fm.descent - fm.ascent - istartv); - if (need > 0) - fm.descent += need; - - need = ht - (v + fm.bottom - fm.top - istartv); - if (need > 0) - fm.bottom += need; - } - } - - private Bitmap mBitmap; - private int mPad; -} diff --git a/core/java/android/text/style/ImageSpan.java b/core/java/android/text/style/ImageSpan.java deleted file mode 100644 index efb88a0..0000000 --- a/core/java/android/text/style/ImageSpan.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Drawable; -import android.net.Uri; -import android.util.Log; - -import java.io.InputStream; - -public class ImageSpan extends DynamicDrawableSpan { - private Drawable mDrawable; - private Uri mContentUri; - private int mResourceId; - private Context mContext; - private String mSource; - - public ImageSpan(Bitmap b) { - this(b, ALIGN_BOTTOM); - } - - /** - * @param verticalAlignment one of {@link DynamicDrawableSpan#ALIGN_BOTTOM} or - * {@link DynamicDrawableSpan#ALIGN_BASELINE}. - */ - public ImageSpan(Bitmap b, int verticalAlignment) { - super(verticalAlignment); - mDrawable = new BitmapDrawable(b); - int width = mDrawable.getIntrinsicWidth(); - int height = mDrawable.getIntrinsicHeight(); - mDrawable.setBounds(0, 0, width > 0 ? width : 0, height > 0 ? height : 0); - } - - public ImageSpan(Drawable d) { - this(d, ALIGN_BOTTOM); - } - - /** - * @param verticalAlignment one of {@link DynamicDrawableSpan#ALIGN_BOTTOM} or - * {@link DynamicDrawableSpan#ALIGN_BASELINE}. - */ - public ImageSpan(Drawable d, int verticalAlignment) { - super(verticalAlignment); - mDrawable = d; - } - - public ImageSpan(Drawable d, String source) { - this(d, source, ALIGN_BOTTOM); - } - - /** - * @param verticalAlignment one of {@link DynamicDrawableSpan#ALIGN_BOTTOM} or - * {@link DynamicDrawableSpan#ALIGN_BASELINE}. - */ - public ImageSpan(Drawable d, String source, int verticalAlignment) { - super(verticalAlignment); - mDrawable = d; - mSource = source; - } - - public ImageSpan(Context context, Uri uri) { - this(context, uri, ALIGN_BOTTOM); - } - - /** - * @param verticalAlignment one of {@link DynamicDrawableSpan#ALIGN_BOTTOM} or - * {@link DynamicDrawableSpan#ALIGN_BASELINE}. - */ - public ImageSpan(Context context, Uri uri, int verticalAlignment) { - super(verticalAlignment); - mContext = context; - mContentUri = uri; - } - - public ImageSpan(Context context, int resourceId) { - this(context, resourceId, ALIGN_BOTTOM); - } - - /** - * @param verticalAlignment one of {@link DynamicDrawableSpan#ALIGN_BOTTOM} or - * {@link DynamicDrawableSpan#ALIGN_BASELINE}. - */ - public ImageSpan(Context context, int resourceId, int verticalAlignment) { - super(verticalAlignment); - mContext = context; - mResourceId = resourceId; - } - - @Override - public Drawable getDrawable() { - Drawable drawable = null; - - if (mDrawable != null) { - drawable = mDrawable; - } else if (mContentUri != null) { - Bitmap bitmap = null; - try { - InputStream is = mContext.getContentResolver().openInputStream( - mContentUri); - bitmap = BitmapFactory.decodeStream(is); - drawable = new BitmapDrawable(bitmap); - is.close(); - } catch (Exception e) { - Log.e("sms", "Failed to loaded content " + mContentUri, e); - } - } else { - try { - drawable = mContext.getResources().getDrawable(mResourceId); - drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), - drawable.getIntrinsicHeight()); - } catch (Exception e) { - Log.e("sms", "Unable to find resource: " + mResourceId); - } - } - - return drawable; - } - - /** - * Returns the source string that was saved during construction. - */ - public String getSource() { - return mSource; - } - -} diff --git a/core/java/android/text/style/LeadingMarginSpan.java b/core/java/android/text/style/LeadingMarginSpan.java deleted file mode 100644 index 8e212e3..0000000 --- a/core/java/android/text/style/LeadingMarginSpan.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -import android.graphics.Paint; -import android.graphics.Canvas; -import android.os.Parcel; -import android.text.Layout; -import android.text.ParcelableSpan; -import android.text.TextUtils; - -public interface LeadingMarginSpan -extends ParagraphStyle -{ - public int getLeadingMargin(boolean first); - public void drawLeadingMargin(Canvas c, Paint p, - int x, int dir, - int top, int baseline, int bottom, - CharSequence text, int start, int end, - boolean first, Layout layout); - - public static class Standard implements LeadingMarginSpan, ParcelableSpan { - private final int mFirst, mRest; - - public Standard(int first, int rest) { - mFirst = first; - mRest = rest; - } - - public Standard(int every) { - this(every, every); - } - - public Standard(Parcel src) { - mFirst = src.readInt(); - mRest = src.readInt(); - } - - public int getSpanTypeId() { - return TextUtils.LEADING_MARGIN_SPAN; - } - - public int describeContents() { - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - dest.writeInt(mFirst); - dest.writeInt(mRest); - } - - public int getLeadingMargin(boolean first) { - return first ? mFirst : mRest; - } - - public void drawLeadingMargin(Canvas c, Paint p, - int x, int dir, - int top, int baseline, int bottom, - CharSequence text, int start, int end, - boolean first, Layout layout) { - ; - } - } -} diff --git a/core/java/android/text/style/LineBackgroundSpan.java b/core/java/android/text/style/LineBackgroundSpan.java deleted file mode 100644 index 854aeaf..0000000 --- a/core/java/android/text/style/LineBackgroundSpan.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -import android.graphics.Paint; -import android.graphics.Canvas; - -public interface LineBackgroundSpan -extends ParagraphStyle -{ - public void drawBackground(Canvas c, Paint p, - int left, int right, - int top, int baseline, int bottom, - CharSequence text, int start, int end, - int lnum); -} diff --git a/core/java/android/text/style/LineHeightSpan.java b/core/java/android/text/style/LineHeightSpan.java deleted file mode 100644 index c0ef97c..0000000 --- a/core/java/android/text/style/LineHeightSpan.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -import android.graphics.Paint; -import android.graphics.Canvas; -import android.text.Layout; - -public interface LineHeightSpan -extends ParagraphStyle, WrapTogetherSpan -{ - public void chooseHeight(CharSequence text, int start, int end, - int spanstartv, int v, - Paint.FontMetricsInt fm); -} diff --git a/core/java/android/text/style/MaskFilterSpan.java b/core/java/android/text/style/MaskFilterSpan.java deleted file mode 100644 index 64ab0d8..0000000 --- a/core/java/android/text/style/MaskFilterSpan.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -import android.graphics.MaskFilter; -import android.text.TextPaint; - -public class MaskFilterSpan extends CharacterStyle implements UpdateAppearance { - - private MaskFilter mFilter; - - public MaskFilterSpan(MaskFilter filter) { - mFilter = filter; - } - - public MaskFilter getMaskFilter() { - return mFilter; - } - - @Override - public void updateDrawState(TextPaint ds) { - ds.setMaskFilter(mFilter); - } -} diff --git a/core/java/android/text/style/MetricAffectingSpan.java b/core/java/android/text/style/MetricAffectingSpan.java deleted file mode 100644 index 92558eb..0000000 --- a/core/java/android/text/style/MetricAffectingSpan.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -import android.graphics.Paint; -import android.text.TextPaint; - -/** - * The classes that affect character-level text formatting in a way that - * changes the width or height of characters extend this class. - */ -public abstract class MetricAffectingSpan -extends CharacterStyle -implements UpdateLayout { - - public abstract void updateMeasureState(TextPaint p); - - /** - * Returns "this" for most MetricAffectingSpans, but for - * MetricAffectingSpans that were generated by {@link #wrap}, - * returns the underlying MetricAffectingSpan. - */ - @Override - public MetricAffectingSpan getUnderlying() { - return this; - } - - /** - * A Passthrough MetricAffectingSpan is one that - * passes {@link #updateDrawState} and {@link #updateMeasureState} - * calls through to the specified MetricAffectingSpan - * while still being a distinct object, - * and is therefore able to be attached to the same Spannable - * to which the specified MetricAffectingSpan is already attached. - */ - /* package */ static class Passthrough extends MetricAffectingSpan { - private MetricAffectingSpan mStyle; - - /** - * Creates a new Passthrough of the specfied MetricAffectingSpan. - */ - public Passthrough(MetricAffectingSpan cs) { - mStyle = cs; - } - - /** - * Passes updateDrawState through to the underlying MetricAffectingSpan. - */ - @Override - public void updateDrawState(TextPaint tp) { - mStyle.updateDrawState(tp); - } - - /** - * Passes updateMeasureState through to the underlying MetricAffectingSpan. - */ - @Override - public void updateMeasureState(TextPaint tp) { - mStyle.updateMeasureState(tp); - } - - /** - * Returns the MetricAffectingSpan underlying this one, or the one - * underlying it if it too is a Passthrough. - */ - @Override - public MetricAffectingSpan getUnderlying() { - return mStyle.getUnderlying(); - } - } -} diff --git a/core/java/android/text/style/ParagraphStyle.java b/core/java/android/text/style/ParagraphStyle.java deleted file mode 100644 index 423156e..0000000 --- a/core/java/android/text/style/ParagraphStyle.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -/** - * The classes that affect paragraph-level text formatting implement - * this interface. - */ -public interface ParagraphStyle -{ - -} diff --git a/core/java/android/text/style/QuoteSpan.java b/core/java/android/text/style/QuoteSpan.java deleted file mode 100644 index 29dd273..0000000 --- a/core/java/android/text/style/QuoteSpan.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -import android.graphics.Paint; -import android.graphics.Canvas; -import android.os.Parcel; -import android.text.Layout; -import android.text.ParcelableSpan; -import android.text.TextUtils; - -public class QuoteSpan implements LeadingMarginSpan, ParcelableSpan { - private static final int STRIPE_WIDTH = 2; - private static final int GAP_WIDTH = 2; - - private final int mColor; - - public QuoteSpan() { - super(); - mColor = 0xff0000ff; - } - - public QuoteSpan(int color) { - super(); - mColor = color; - } - - public QuoteSpan(Parcel src) { - mColor = src.readInt(); - } - - public int getSpanTypeId() { - return TextUtils.QUOTE_SPAN; - } - - public int describeContents() { - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - dest.writeInt(mColor); - } - - public int getColor() { - return mColor; - } - - public int getLeadingMargin(boolean first) { - return STRIPE_WIDTH + GAP_WIDTH; - } - - public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, - int top, int baseline, int bottom, - CharSequence text, int start, int end, - boolean first, Layout layout) { - Paint.Style style = p.getStyle(); - int color = p.getColor(); - - p.setStyle(Paint.Style.FILL); - p.setColor(mColor); - - c.drawRect(x, top, x + dir * STRIPE_WIDTH, bottom, p); - - p.setStyle(style); - p.setColor(color); - } -} diff --git a/core/java/android/text/style/RasterizerSpan.java b/core/java/android/text/style/RasterizerSpan.java deleted file mode 100644 index 75b5bcc..0000000 --- a/core/java/android/text/style/RasterizerSpan.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2007 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.text.style; - -import android.graphics.Rasterizer; -import android.text.TextPaint; - -public class RasterizerSpan extends CharacterStyle implements UpdateAppearance { - - private Rasterizer mRasterizer; - - public RasterizerSpan(Rasterizer r) { - mRasterizer = r; - } - - public Rasterizer getRasterizer() { - return mRasterizer; - } - - @Override - public void updateDrawState(TextPaint ds) { - ds.setRasterizer(mRasterizer); - } -} diff --git a/core/java/android/text/style/RelativeSizeSpan.java b/core/java/android/text/style/RelativeSizeSpan.java deleted file mode 100644 index 9717362..0000000 --- a/core/java/android/text/style/RelativeSizeSpan.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -import android.os.Parcel; -import android.text.ParcelableSpan; -import android.text.TextPaint; -import android.text.TextUtils; - -public class RelativeSizeSpan extends MetricAffectingSpan implements ParcelableSpan { - - private final float mProportion; - - public RelativeSizeSpan(float proportion) { - mProportion = proportion; - } - - public RelativeSizeSpan(Parcel src) { - mProportion = src.readFloat(); - } - - public int getSpanTypeId() { - return TextUtils.RELATIVE_SIZE_SPAN; - } - - public int describeContents() { - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - dest.writeFloat(mProportion); - } - - public float getSizeChange() { - return mProportion; - } - - @Override - public void updateDrawState(TextPaint ds) { - ds.setTextSize(ds.getTextSize() * mProportion); - } - - @Override - public void updateMeasureState(TextPaint ds) { - ds.setTextSize(ds.getTextSize() * mProportion); - } -} diff --git a/core/java/android/text/style/ReplacementSpan.java b/core/java/android/text/style/ReplacementSpan.java deleted file mode 100644 index 26c725f..0000000 --- a/core/java/android/text/style/ReplacementSpan.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -import android.graphics.Paint; -import android.graphics.Canvas; -import android.text.TextPaint; - -public abstract class ReplacementSpan extends MetricAffectingSpan { - - public abstract int getSize(Paint paint, CharSequence text, - int start, int end, - Paint.FontMetricsInt fm); - public abstract void draw(Canvas canvas, CharSequence text, - int start, int end, float x, - int top, int y, int bottom, Paint paint); - - /** - * This method does nothing, since ReplacementSpans are measured - * explicitly instead of affecting Paint properties. - */ - public void updateMeasureState(TextPaint p) { } - - /** - * This method does nothing, since ReplacementSpans are drawn - * explicitly instead of affecting Paint properties. - */ - public void updateDrawState(TextPaint ds) { } -} diff --git a/core/java/android/text/style/ScaleXSpan.java b/core/java/android/text/style/ScaleXSpan.java deleted file mode 100644 index 655064b..0000000 --- a/core/java/android/text/style/ScaleXSpan.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -import android.os.Parcel; -import android.text.ParcelableSpan; -import android.text.TextPaint; -import android.text.TextUtils; - -public class ScaleXSpan extends MetricAffectingSpan implements ParcelableSpan { - - private final float mProportion; - - public ScaleXSpan(float proportion) { - mProportion = proportion; - } - - public ScaleXSpan(Parcel src) { - mProportion = src.readFloat(); - } - - public int getSpanTypeId() { - return TextUtils.SCALE_X_SPAN; - } - - public int describeContents() { - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - dest.writeFloat(mProportion); - } - - public float getScaleX() { - return mProportion; - } - - @Override - public void updateDrawState(TextPaint ds) { - ds.setTextScaleX(ds.getTextScaleX() * mProportion); - } - - @Override - public void updateMeasureState(TextPaint ds) { - ds.setTextScaleX(ds.getTextScaleX() * mProportion); - } -} diff --git a/core/java/android/text/style/StrikethroughSpan.java b/core/java/android/text/style/StrikethroughSpan.java deleted file mode 100644 index b51363a..0000000 --- a/core/java/android/text/style/StrikethroughSpan.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -import android.os.Parcel; -import android.text.ParcelableSpan; -import android.text.TextPaint; -import android.text.TextUtils; - -public class StrikethroughSpan extends CharacterStyle - implements UpdateAppearance, ParcelableSpan { - public StrikethroughSpan() { - } - - public StrikethroughSpan(Parcel src) { - } - - public int getSpanTypeId() { - return TextUtils.STRIKETHROUGH_SPAN; - } - - public int describeContents() { - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - } - - @Override - public void updateDrawState(TextPaint ds) { - ds.setStrikeThruText(true); - } -} diff --git a/core/java/android/text/style/StyleSpan.java b/core/java/android/text/style/StyleSpan.java deleted file mode 100644 index 8e6147c..0000000 --- a/core/java/android/text/style/StyleSpan.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -import android.graphics.Paint; -import android.graphics.Typeface; -import android.os.Parcel; -import android.text.ParcelableSpan; -import android.text.TextPaint; -import android.text.TextUtils; - -/** - * - * Describes a style in a span. - * Note that styles are cumulative -- if both bold and italic are set in - * separate spans, or if the base style is bold and a span calls for italic, - * you get bold italic. You can't turn off a style from the base style. - * - */ -public class StyleSpan extends MetricAffectingSpan implements ParcelableSpan { - - private final int mStyle; - - /** - * - * @param style An integer constant describing the style for this span. Examples - * include bold, italic, and normal. Values are constants defined - * in {@link android.graphics.Typeface}. - */ - public StyleSpan(int style) { - mStyle = style; - } - - public StyleSpan(Parcel src) { - mStyle = src.readInt(); - } - - public int getSpanTypeId() { - return TextUtils.STYLE_SPAN; - } - - public int describeContents() { - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - dest.writeInt(mStyle); - } - - /** - * Returns the style constant defined in {@link android.graphics.Typeface}. - */ - public int getStyle() { - return mStyle; - } - - @Override - public void updateDrawState(TextPaint ds) { - apply(ds, mStyle); - } - - @Override - public void updateMeasureState(TextPaint paint) { - apply(paint, mStyle); - } - - private static void apply(Paint paint, int style) { - int oldStyle; - - Typeface old = paint.getTypeface(); - if (old == null) { - oldStyle = 0; - } else { - oldStyle = old.getStyle(); - } - - int want = oldStyle | style; - - Typeface tf; - if (old == null) { - tf = Typeface.defaultFromStyle(want); - } else { - tf = Typeface.create(old, want); - } - - int fake = want & ~tf.getStyle(); - - if ((fake & Typeface.BOLD) != 0) { - paint.setFakeBoldText(true); - } - - if ((fake & Typeface.ITALIC) != 0) { - paint.setTextSkewX(-0.25f); - } - - paint.setTypeface(tf); - } -} diff --git a/core/java/android/text/style/SubscriptSpan.java b/core/java/android/text/style/SubscriptSpan.java deleted file mode 100644 index de1d8b2..0000000 --- a/core/java/android/text/style/SubscriptSpan.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -import android.os.Parcel; -import android.text.ParcelableSpan; -import android.text.TextPaint; -import android.text.TextUtils; - -public class SubscriptSpan extends MetricAffectingSpan implements ParcelableSpan { - public SubscriptSpan() { - } - - public SubscriptSpan(Parcel src) { - } - - public int getSpanTypeId() { - return TextUtils.SUBSCRIPT_SPAN; - } - - public int describeContents() { - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - } - - @Override - public void updateDrawState(TextPaint tp) { - tp.baselineShift -= (int) (tp.ascent() / 2); - } - - @Override - public void updateMeasureState(TextPaint tp) { - tp.baselineShift -= (int) (tp.ascent() / 2); - } -} diff --git a/core/java/android/text/style/SuperscriptSpan.java b/core/java/android/text/style/SuperscriptSpan.java deleted file mode 100644 index 285fe84..0000000 --- a/core/java/android/text/style/SuperscriptSpan.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -import android.os.Parcel; -import android.text.ParcelableSpan; -import android.text.TextPaint; -import android.text.TextUtils; - -public class SuperscriptSpan extends MetricAffectingSpan implements ParcelableSpan { - public SuperscriptSpan() { - } - - public SuperscriptSpan(Parcel src) { - } - - public int getSpanTypeId() { - return TextUtils.SUPERSCRIPT_SPAN; - } - - public int describeContents() { - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - } - - @Override - public void updateDrawState(TextPaint tp) { - tp.baselineShift += (int) (tp.ascent() / 2); - } - - @Override - public void updateMeasureState(TextPaint tp) { - tp.baselineShift += (int) (tp.ascent() / 2); - } -} diff --git a/core/java/android/text/style/TabStopSpan.java b/core/java/android/text/style/TabStopSpan.java deleted file mode 100644 index e5b7644..0000000 --- a/core/java/android/text/style/TabStopSpan.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -public interface TabStopSpan -extends ParagraphStyle -{ - public int getTabStop(); - - public static class Standard - implements TabStopSpan - { - public Standard(int where) { - mTab = where; - } - - public int getTabStop() { - return mTab; - } - - private int mTab; - } -} diff --git a/core/java/android/text/style/TextAppearanceSpan.java b/core/java/android/text/style/TextAppearanceSpan.java deleted file mode 100644 index de929e3..0000000 --- a/core/java/android/text/style/TextAppearanceSpan.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * 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.text.style; - -import android.content.Context; -import android.content.res.ColorStateList; -import android.content.res.TypedArray; -import android.graphics.Typeface; -import android.os.Parcel; -import android.text.ParcelableSpan; -import android.text.TextPaint; -import android.text.TextUtils; - -/** - * Sets the text color, size, style, and typeface to match a TextAppearance - * resource. - */ -public class TextAppearanceSpan extends MetricAffectingSpan implements ParcelableSpan { - private final String mTypeface; - private final int mStyle; - private final int mTextSize; - private final ColorStateList mTextColor; - private final ColorStateList mTextColorLink; - - /** - * Uses the specified TextAppearance resource to determine the - * text appearance. The <code>appearance</code> should be, for example, - * <code>android.R.style.TextAppearance_Small</code>. - */ - public TextAppearanceSpan(Context context, int appearance) { - this(context, appearance, -1); - } - - /** - * Uses the specified TextAppearance resource to determine the - * text appearance, and the specified text color resource - * to determine the color. The <code>appearance</code> should be, - * for example, <code>android.R.style.TextAppearance_Small</code>, - * and the <code>colorList</code> should be, for example, - * <code>android.R.styleable.Theme_textColorDim</code>. - */ - public TextAppearanceSpan(Context context, int appearance, - int colorList) { - ColorStateList textColor; - - TypedArray a = - context.obtainStyledAttributes(appearance, - com.android.internal.R.styleable.TextAppearance); - - textColor = a.getColorStateList(com.android.internal.R.styleable. - TextAppearance_textColor); - mTextColorLink = a.getColorStateList(com.android.internal.R.styleable. - TextAppearance_textColorLink); - mTextSize = a.getDimensionPixelSize(com.android.internal.R.styleable. - TextAppearance_textSize, -1); - - mStyle = a.getInt(com.android.internal.R.styleable.TextAppearance_textStyle, 0); - int tf = a.getInt(com.android.internal.R.styleable.TextAppearance_typeface, 0); - - switch (tf) { - case 1: - mTypeface = "sans"; - break; - - case 2: - mTypeface = "serif"; - break; - - case 3: - mTypeface = "monospace"; - break; - - default: - mTypeface = null; - break; - } - - a.recycle(); - - if (colorList >= 0) { - a = context.obtainStyledAttributes(com.android.internal.R.style.Theme, - com.android.internal.R.styleable.Theme); - - textColor = a.getColorStateList(colorList); - a.recycle(); - } - - mTextColor = textColor; - } - - /** - * Makes text be drawn with the specified typeface, size, style, - * and colors. - */ - public TextAppearanceSpan(String family, int style, int size, - ColorStateList color, ColorStateList linkColor) { - mTypeface = family; - mStyle = style; - mTextSize = size; - mTextColor = color; - mTextColorLink = linkColor; - } - - public TextAppearanceSpan(Parcel src) { - mTypeface = src.readString(); - mStyle = src.readInt(); - mTextSize = src.readInt(); - if (src.readInt() != 0) { - mTextColor = ColorStateList.CREATOR.createFromParcel(src); - } else { - mTextColor = null; - } - if (src.readInt() != 0) { - mTextColorLink = ColorStateList.CREATOR.createFromParcel(src); - } else { - mTextColorLink = null; - } - } - - public int getSpanTypeId() { - return TextUtils.TEXT_APPEARANCE_SPAN; - } - - public int describeContents() { - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(mTypeface); - dest.writeInt(mStyle); - dest.writeInt(mTextSize); - if (mTextColor != null) { - dest.writeInt(1); - mTextColor.writeToParcel(dest, flags); - } else { - dest.writeInt(0); - } - if (mTextColorLink != null) { - dest.writeInt(1); - mTextColorLink.writeToParcel(dest, flags); - } else { - dest.writeInt(0); - } - } - - /** - * Returns the typeface family specified by this span, or <code>null</code> - * if it does not specify one. - */ - public String getFamily() { - return mTypeface; - } - - /** - * Returns the text color specified by this span, or <code>null</code> - * if it does not specify one. - */ - public ColorStateList getTextColor() { - return mTextColor; - } - - /** - * Returns the link color specified by this span, or <code>null</code> - * if it does not specify one. - */ - public ColorStateList getLinkTextColor() { - return mTextColorLink; - } - - /** - * Returns the text size specified by this span, or <code>-1</code> - * if it does not specify one. - */ - public int getTextSize() { - return mTextSize; - } - - /** - * Returns the text style specified by this span, or <code>0</code> - * if it does not specify one. - */ - public int getTextStyle() { - return mStyle; - } - - @Override - public void updateDrawState(TextPaint ds) { - updateMeasureState(ds); - - if (mTextColor != null) { - ds.setColor(mTextColor.getColorForState(ds.drawableState, 0)); - } - - if (mTextColorLink != null) { - ds.linkColor = mTextColor.getColorForState(ds.drawableState, 0); - } - } - - @Override - public void updateMeasureState(TextPaint ds) { - if (mTypeface != null || mStyle != 0) { - Typeface tf = ds.getTypeface(); - int style = 0; - - if (tf != null) { - style = tf.getStyle(); - } - - style |= mStyle; - - if (mTypeface != null) { - tf = Typeface.create(mTypeface, style); - } else if (tf == null) { - tf = Typeface.defaultFromStyle(style); - } else { - tf = Typeface.create(tf, style); - } - - int fake = style & ~tf.getStyle(); - - if ((fake & Typeface.BOLD) != 0) { - ds.setFakeBoldText(true); - } - - if ((fake & Typeface.ITALIC) != 0) { - ds.setTextSkewX(-0.25f); - } - - ds.setTypeface(tf); - } - - if (mTextSize > 0) { - ds.setTextSize(mTextSize); - } - } -} diff --git a/core/java/android/text/style/TypefaceSpan.java b/core/java/android/text/style/TypefaceSpan.java deleted file mode 100644 index f194060..0000000 --- a/core/java/android/text/style/TypefaceSpan.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -import android.graphics.Paint; -import android.graphics.Typeface; -import android.os.Parcel; -import android.text.ParcelableSpan; -import android.text.TextPaint; -import android.text.TextUtils; - -/** - * Changes the typeface family of the text to which the span is attached. - */ -public class TypefaceSpan extends MetricAffectingSpan implements ParcelableSpan { - private final String mFamily; - - /** - * @param family The font family for this typeface. Examples include - * "monospace", "serif", and "sans-serif". - */ - public TypefaceSpan(String family) { - mFamily = family; - } - - public TypefaceSpan(Parcel src) { - mFamily = src.readString(); - } - - public int getSpanTypeId() { - return TextUtils.TYPEFACE_SPAN; - } - - public int describeContents() { - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(mFamily); - } - - /** - * Returns the font family name. - */ - public String getFamily() { - return mFamily; - } - - @Override - public void updateDrawState(TextPaint ds) { - apply(ds, mFamily); - } - - @Override - public void updateMeasureState(TextPaint paint) { - apply(paint, mFamily); - } - - private static void apply(Paint paint, String family) { - int oldStyle; - - Typeface old = paint.getTypeface(); - if (old == null) { - oldStyle = 0; - } else { - oldStyle = old.getStyle(); - } - - Typeface tf = Typeface.create(family, oldStyle); - int fake = oldStyle & ~tf.getStyle(); - - if ((fake & Typeface.BOLD) != 0) { - paint.setFakeBoldText(true); - } - - if ((fake & Typeface.ITALIC) != 0) { - paint.setTextSkewX(-0.25f); - } - - paint.setTypeface(tf); - } -} diff --git a/core/java/android/text/style/URLSpan.java b/core/java/android/text/style/URLSpan.java deleted file mode 100644 index f458611..0000000 --- a/core/java/android/text/style/URLSpan.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -import android.content.Intent; -import android.net.Uri; -import android.os.Parcel; -import android.text.ParcelableSpan; -import android.text.TextUtils; -import android.view.View; - -public class URLSpan extends ClickableSpan implements ParcelableSpan { - - private final String mURL; - - public URLSpan(String url) { - mURL = url; - } - - public URLSpan(Parcel src) { - mURL = src.readString(); - } - - public int getSpanTypeId() { - return TextUtils.URL_SPAN; - } - - public int describeContents() { - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(mURL); - } - - public String getURL() { - return mURL; - } - - @Override - public void onClick(View widget) { - Uri uri = Uri.parse(getURL()); - Intent intent = new Intent(Intent.ACTION_VIEW, uri); - intent.addCategory(Intent.CATEGORY_BROWSABLE); - widget.getContext().startActivity(intent); - } -} diff --git a/core/java/android/text/style/UnderlineSpan.java b/core/java/android/text/style/UnderlineSpan.java deleted file mode 100644 index b0cb0e8..0000000 --- a/core/java/android/text/style/UnderlineSpan.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -import android.os.Parcel; -import android.text.ParcelableSpan; -import android.text.TextPaint; -import android.text.TextUtils; - -public class UnderlineSpan extends CharacterStyle - implements UpdateAppearance, ParcelableSpan { - public UnderlineSpan() { - } - - public UnderlineSpan(Parcel src) { - } - - public int getSpanTypeId() { - return TextUtils.UNDERLINE_SPAN; - } - - public int describeContents() { - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - } - - @Override - public void updateDrawState(TextPaint ds) { - ds.setUnderlineText(true); - } -} diff --git a/core/java/android/text/style/UpdateAppearance.java b/core/java/android/text/style/UpdateAppearance.java deleted file mode 100644 index 198e4fa..0000000 --- a/core/java/android/text/style/UpdateAppearance.java +++ /dev/null @@ -1,10 +0,0 @@ -package android.text.style; - -/** - * The classes that affect character-level text in a way that modifies their - * appearance when one is added or removed must implement this interface. Note - * that if the class also impacts size or other metrics, it should instead - * implement {@link UpdateLayout}. - */ -public interface UpdateAppearance { -} diff --git a/core/java/android/text/style/UpdateLayout.java b/core/java/android/text/style/UpdateLayout.java deleted file mode 100644 index 591075e..0000000 --- a/core/java/android/text/style/UpdateLayout.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -/** - * The classes that affect character-level text formatting in a way that - * triggers a text layout update when one is added or removed must implement - * this interface. This interface also includes {@link UpdateAppearance} - * since such a change implicitly also impacts the appearance. - */ -public interface UpdateLayout extends UpdateAppearance { } diff --git a/core/java/android/text/style/WrapTogetherSpan.java b/core/java/android/text/style/WrapTogetherSpan.java deleted file mode 100644 index 11721a8..0000000 --- a/core/java/android/text/style/WrapTogetherSpan.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2006 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.text.style; - -public interface WrapTogetherSpan -extends ParagraphStyle -{ - -} diff --git a/core/java/android/text/style/package.html b/core/java/android/text/style/package.html deleted file mode 100644 index 0a8520c..0000000 --- a/core/java/android/text/style/package.html +++ /dev/null @@ -1,10 +0,0 @@ -<html> -<body> - -<p>Provides classes used to view or change the style of a span of text in a View object. -The classes with a subclass Standard are passed in to {@link android.text.SpannableString#setSpan(java.lang.Object, int, int, int) -SpannableString.setSpan()} or {@link android.text.SpannableStringBuilder#setSpan(java.lang.Object, int, int, int) -SpannableStringBuilder.setSpan()} to add a new styled span to a string in a View object. - -</body> -</html> |