1 /*
2  * Copyright (C) 2006 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.text.style;
18 
19 import android.annotation.NonNull;
20 import android.os.Parcel;
21 import android.text.ParcelableSpan;
22 import android.text.TextPaint;
23 import android.text.TextUtils;
24 
25 /**
26  * A span that strikes through the text it's attached to.
27  * <p>
28  * The span can be used like this:
29  * <pre>{@code
30  * SpannableString string = new SpannableString("Text with strikethrough span");
31  *string.setSpan(new StrikethroughSpan(), 10, 23, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);}</pre>
32  * <img src="{@docRoot}reference/android/images/text/style/strikethroughspan.png" />
33  * <figcaption>Strikethrough text.</figcaption>
34  */
35 public class StrikethroughSpan extends CharacterStyle
36         implements UpdateAppearance, ParcelableSpan {
37 
38     /**
39      * Creates a {@link StrikethroughSpan}.
40      */
StrikethroughSpan()41     public StrikethroughSpan() {
42     }
43 
44     /**
45      * Creates a {@link StrikethroughSpan} from a parcel.
46      */
StrikethroughSpan(@onNull Parcel src)47     public StrikethroughSpan(@NonNull Parcel src) {
48     }
49 
50     @Override
getSpanTypeId()51     public int getSpanTypeId() {
52         return getSpanTypeIdInternal();
53     }
54 
55     /** @hide */
56     @Override
getSpanTypeIdInternal()57     public int getSpanTypeIdInternal() {
58         return TextUtils.STRIKETHROUGH_SPAN;
59     }
60 
61     @Override
describeContents()62     public int describeContents() {
63         return 0;
64     }
65 
66     @Override
writeToParcel(@onNull Parcel dest, int flags)67     public void writeToParcel(@NonNull Parcel dest, int flags) {
68         writeToParcelInternal(dest, flags);
69     }
70 
71     /** @hide */
72     @Override
writeToParcelInternal(@onNull Parcel dest, int flags)73     public void writeToParcelInternal(@NonNull Parcel dest, int flags) {
74     }
75 
76     @Override
updateDrawState(@onNull TextPaint ds)77     public void updateDrawState(@NonNull TextPaint ds) {
78         ds.setStrikeThruText(true);
79     }
80 
81     @Override
toString()82     public String toString() {
83         return "StrikethroughSpan{}";
84     }
85 }
86