TextViewBindingObject.java revision fead9ca09b117136b35bc5bf137340a754f9eddd
1/*
2 * Copyright (C) 2015 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 */
16package android.databinding.testapp.vo;
17
18import android.databinding.Bindable;
19import android.databinding.adapters.TextViewBindingAdapter;
20import android.databinding.testapp.BR;
21import android.text.Editable;
22import android.text.InputType;
23import android.text.method.KeyListener;
24import android.text.method.TextKeyListener;
25import android.text.util.Linkify;
26import android.view.KeyEvent;
27import android.view.View;
28import android.widget.TextView;
29
30public class TextViewBindingObject extends BindingAdapterBindingObject {
31
32    @Bindable
33    private int mAutoLink = Linkify.WEB_URLS;
34
35    @Bindable
36    private int mDrawablePadding;
37
38    @Bindable
39    private int mInputType = InputType.TYPE_CLASS_PHONE;
40
41    @Bindable
42    private boolean mScrollHorizontally;
43
44    @Bindable
45    private boolean mTextAllCaps;
46
47    @Bindable
48    private int mTextColorHighlight;
49
50    @Bindable
51    private int mTextColorHint;
52
53    @Bindable
54    private int mTextColorLink;
55
56    @Bindable
57    private boolean mAutoText;
58
59    @Bindable
60    private TextKeyListener.Capitalize mCapitalize = TextKeyListener.Capitalize.NONE;
61
62    @Bindable
63    private TextView.BufferType mBufferType = TextView.BufferType.NORMAL;
64
65    @Bindable
66    private String mDigits = "abcdefg";
67
68    @Bindable
69    private int mNumeric = TextViewBindingAdapter.DECIMAL;
70
71    @Bindable
72    private boolean mPhoneNumber;
73
74    @Bindable
75    private int mDrawableBottom;
76
77    @Bindable
78    private int mDrawableTop;
79
80    @Bindable
81    private int mDrawableLeft;
82
83    @Bindable
84    private int mDrawableRight;
85
86    @Bindable
87    private int mDrawableStart;
88
89    @Bindable
90    private int mDrawableEnd;
91
92    @Bindable
93    private String mImeActionLabel;
94
95    @Bindable
96    private int mImeActionId;
97
98    @Bindable
99    private String mInputMethod
100            = "android.databinding.testapp.vo.TextViewBindingObject$KeyListener1";
101
102    @Bindable
103    private float mLineSpacingExtra;
104
105    @Bindable
106    private float mLineSpacingMultiplier;
107
108    @Bindable
109    private int mMaxLength;
110
111    @Bindable
112    private int mShadowColor;
113
114    @Bindable
115    private float mShadowDx;
116
117    @Bindable
118    private float mShadowDy;
119
120    @Bindable
121    private float mShadowRadius;
122
123    @Bindable
124    private float mTextSize = 10f;
125
126    public TextView.BufferType getBufferType() {
127        return mBufferType;
128    }
129
130    public float getLineSpacingExtra() {
131        return mLineSpacingExtra;
132    }
133
134    public float getLineSpacingMultiplier() {
135        return mLineSpacingMultiplier;
136    }
137
138    public float getShadowDx() {
139        return mShadowDx;
140    }
141
142    public float getShadowDy() {
143        return mShadowDy;
144    }
145
146    public float getShadowRadius() {
147        return mShadowRadius;
148    }
149
150    public float getTextSize() {
151        return mTextSize;
152    }
153
154    public int getAutoLink() {
155        return mAutoLink;
156    }
157
158    public int getDrawableBottom() {
159        return mDrawableBottom;
160    }
161
162    public int getDrawableEnd() {
163        return mDrawableEnd;
164    }
165
166    public int getDrawableLeft() {
167        return mDrawableLeft;
168    }
169
170    public int getDrawablePadding() {
171        return mDrawablePadding;
172    }
173
174    public int getDrawableRight() {
175        return mDrawableRight;
176    }
177
178    public int getDrawableStart() {
179        return mDrawableStart;
180    }
181
182    public int getDrawableTop() {
183        return mDrawableTop;
184    }
185
186    public int getImeActionId() {
187        return mImeActionId;
188    }
189
190    public int getInputType() {
191        return mInputType;
192    }
193
194    public int getMaxLength() {
195        return mMaxLength;
196    }
197
198    public int getNumeric() {
199        return mNumeric;
200    }
201
202    public int getShadowColor() {
203        return mShadowColor;
204    }
205
206    public int getTextColorHighlight() {
207        return mTextColorHighlight;
208    }
209
210    public int getTextColorHint() {
211        return mTextColorHint;
212    }
213
214    public int getTextColorLink() {
215        return mTextColorLink;
216    }
217
218    public String getDigits() {
219        return mDigits;
220    }
221
222    public String getImeActionLabel() {
223        return mImeActionLabel;
224    }
225
226    public String getInputMethod() {
227        return mInputMethod;
228    }
229
230    public boolean isAutoText() {
231        return mAutoText;
232    }
233
234    public TextKeyListener.Capitalize getCapitalize() {
235        return mCapitalize;
236    }
237
238    public void setCapitalize(TextKeyListener.Capitalize capitalize) {
239        mCapitalize = capitalize;
240        notifyPropertyChanged(BR.capitalize);
241    }
242
243    public boolean isPhoneNumber() {
244        return mPhoneNumber;
245    }
246
247    public boolean isScrollHorizontally() {
248        return mScrollHorizontally;
249    }
250
251    public boolean isTextAllCaps() {
252        return mTextAllCaps;
253    }
254
255    public void changeValues() {
256        mAutoLink = Linkify.EMAIL_ADDRESSES;
257        mDrawablePadding = 10;
258        mInputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS;
259        mScrollHorizontally = true;
260        mTextAllCaps = true;
261        mTextColorHighlight = 0xFF00FF00;
262        mTextColorHint = 0xFFFF0000;
263        mTextColorLink = 0xFF0000FF;
264        mAutoText = true;
265        mCapitalize = TextKeyListener.Capitalize.SENTENCES;
266        mBufferType = TextView.BufferType.SPANNABLE;
267        mDigits = "hijklmno";
268        mNumeric = TextViewBindingAdapter.SIGNED;
269        mPhoneNumber = true;
270        mDrawableBottom = 0xFF880088;
271        mDrawableTop = 0xFF111111;
272        mDrawableLeft = 0xFF222222;
273        mDrawableRight = 0xFF333333;
274        mDrawableStart = 0xFF444444;
275        mDrawableEnd = 0xFF555555;
276        mImeActionLabel = "Hello World";
277        mImeActionId = 3;
278        mInputMethod = "android.databinding.testapp.vo.TextViewBindingObject$KeyListener2";
279        mLineSpacingExtra = 2;
280        mLineSpacingMultiplier = 3;
281        mMaxLength = 100;
282        mShadowColor = 0xFF666666;
283        mShadowDx = 2;
284        mShadowDy = 3;
285        mShadowRadius = 4;
286        mTextSize = 20f;
287        notifyChange();
288    }
289
290    public static class KeyListener1 implements KeyListener {
291
292        @Override
293        public int getInputType() {
294            return InputType.TYPE_CLASS_TEXT;
295        }
296
297        @Override
298        public boolean onKeyDown(View view, Editable text, int keyCode, KeyEvent event) {
299            return false;
300        }
301
302        @Override
303        public boolean onKeyUp(View view, Editable text, int keyCode, KeyEvent event) {
304            return false;
305        }
306
307        @Override
308        public boolean onKeyOther(View view, Editable text, KeyEvent event) {
309            return false;
310        }
311
312        @Override
313        public void clearMetaKeyState(View view, Editable content, int states) {
314        }
315    }
316
317    public static class KeyListener2 extends KeyListener1 {
318
319    }
320}
321