Loading api/current.txt +33 −3 Original line number Original line Diff line number Diff line Loading @@ -22826,6 +22826,17 @@ package android.util { method public void set(T, V); method public void set(T, V); } } public class PropertyValueModel extends android.util.ValueModel { method public T get(); method public H getHost(); method public android.util.Property<H, T> getProperty(); method public java.lang.Class<T> getType(); method public static android.util.PropertyValueModel<H, T> of(H, android.util.Property<H, T>); method public static android.util.PropertyValueModel<H, T> of(H, java.lang.Class<T>, java.lang.String); method public static android.util.PropertyValueModel of(java.lang.Object, java.lang.String); method public void set(T); } public class SparseArray implements java.lang.Cloneable { public class SparseArray implements java.lang.Cloneable { ctor public SparseArray(); ctor public SparseArray(); ctor public SparseArray(int); ctor public SparseArray(int); Loading Loading @@ -22974,6 +22985,14 @@ package android.util { field public int type; field public int type; } } public abstract class ValueModel { ctor protected ValueModel(); method public abstract T get(); method public abstract java.lang.Class<T> getType(); method public abstract void set(T); field public static final android.util.ValueModel EMPTY; } public class Xml { public class Xml { method public static android.util.AttributeSet asAttributeSet(org.xmlpull.v1.XmlPullParser); method public static android.util.AttributeSet asAttributeSet(org.xmlpull.v1.XmlPullParser); method public static android.util.Xml.Encoding findEncodingByName(java.lang.String) throws java.io.UnsupportedEncodingException; method public static android.util.Xml.Encoding findEncodingByName(java.lang.String) throws java.io.UnsupportedEncodingException; Loading Loading @@ -27395,10 +27414,12 @@ package android.widget { method public abstract void onSelectedDayChange(android.widget.CalendarView, int, int, int); method public abstract void onSelectedDayChange(android.widget.CalendarView, int, int, int); } } public class CheckBox extends android.widget.CompoundButton { public class CheckBox extends android.widget.CompoundButton implements android.widget.ValueEditor { ctor public CheckBox(android.content.Context); ctor public CheckBox(android.content.Context); ctor public CheckBox(android.content.Context, android.util.AttributeSet); ctor public CheckBox(android.content.Context, android.util.AttributeSet); ctor public CheckBox(android.content.Context, android.util.AttributeSet, int); ctor public CheckBox(android.content.Context, android.util.AttributeSet, int); method public android.util.ValueModel<java.lang.Boolean> getValueModel(); method public void setValueModel(android.util.ValueModel<java.lang.Boolean>); } } public abstract interface Checkable { public abstract interface Checkable { Loading Loading @@ -27571,14 +27592,16 @@ package android.widget { method public void setSize(int, int); method public void setSize(int, int); } } public class EditText extends android.widget.TextView { public class EditText extends android.widget.TextView implements android.widget.ValueEditor { ctor public EditText(android.content.Context); ctor public EditText(android.content.Context); ctor public EditText(android.content.Context, android.util.AttributeSet); ctor public EditText(android.content.Context, android.util.AttributeSet); ctor public EditText(android.content.Context, android.util.AttributeSet, int); ctor public EditText(android.content.Context, android.util.AttributeSet, int); method public void extendSelection(int); method public void extendSelection(int); method public android.util.ValueModel<java.lang.CharSequence> getValueModel(); method public void selectAll(); method public void selectAll(); method public void setSelection(int, int); method public void setSelection(int, int); method public void setSelection(int); method public void setSelection(int); method public void setValueModel(android.util.ValueModel<java.lang.CharSequence>); } } public abstract interface ExpandableListAdapter { public abstract interface ExpandableListAdapter { Loading Loading @@ -28595,11 +28618,13 @@ package android.widget { method public abstract java.lang.Object[] getSections(); method public abstract java.lang.Object[] getSections(); } } public class SeekBar extends android.widget.AbsSeekBar { public class SeekBar extends android.widget.AbsSeekBar implements android.widget.ValueEditor { ctor public SeekBar(android.content.Context); ctor public SeekBar(android.content.Context); ctor public SeekBar(android.content.Context, android.util.AttributeSet); ctor public SeekBar(android.content.Context, android.util.AttributeSet); ctor public SeekBar(android.content.Context, android.util.AttributeSet, int); ctor public SeekBar(android.content.Context, android.util.AttributeSet, int); method public android.util.ValueModel<java.lang.Integer> getValueModel(); method public void setOnSeekBarChangeListener(android.widget.SeekBar.OnSeekBarChangeListener); method public void setOnSeekBarChangeListener(android.widget.SeekBar.OnSeekBarChangeListener); method public void setValueModel(android.util.ValueModel<java.lang.Integer>); } } public static abstract interface SeekBar.OnSeekBarChangeListener { public static abstract interface SeekBar.OnSeekBarChangeListener { Loading Loading @@ -29171,6 +29196,11 @@ package android.widget { method public android.widget.TextView getText2(); method public android.widget.TextView getText2(); } } public abstract interface ValueEditor { method public abstract android.util.ValueModel<T> getValueModel(); method public abstract void setValueModel(android.util.ValueModel<T>); } public class VideoView extends android.view.SurfaceView implements android.widget.MediaController.MediaPlayerControl { public class VideoView extends android.view.SurfaceView implements android.widget.MediaController.MediaPlayerControl { ctor public VideoView(android.content.Context); ctor public VideoView(android.content.Context); ctor public VideoView(android.content.Context, android.util.AttributeSet); ctor public VideoView(android.content.Context, android.util.AttributeSet); core/java/android/util/PropertyValueModel.java 0 → 100755 +143 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2012 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.util; /** * A value model for a {@link Property property} of a host object. This class can be used for * both reflective and non-reflective property implementations. * * @param <H> the host type, where the host is the object that holds this property * @param <T> the value type * * @see Property * @see ValueModel */ public class PropertyValueModel<H, T> extends ValueModel<T> { private final H mHost; private final Property<H, T> mProperty; private PropertyValueModel(H host, Property<H, T> property) { mProperty = property; mHost = host; } /** * Returns the host. * * @return the host */ public H getHost() { return mHost; } /** * Returns the property. * * @return the property */ public Property<H, T> getProperty() { return mProperty; } @Override public Class<T> getType() { return mProperty.getType(); } @Override public T get() { return mProperty.get(mHost); } @Override public void set(T value) { mProperty.set(mHost, value); } /** * Return an appropriate PropertyValueModel for this host and property. * * @param host the host * @param property the property * @return the value model */ public static <H, T> PropertyValueModel<H, T> of(H host, Property<H, T> property) { return new PropertyValueModel<H, T>(host, property); } /** * Return a PropertyValueModel for this {@code host} and a * reflective property, constructed from this {@code propertyType} and {@code propertyName}. * * @param host * @param propertyType the property type * @param propertyName the property name * @return a value model with this host and a reflective property with this type and name * * @see Property#of */ public static <H, T> PropertyValueModel<H, T> of(H host, Class<T> propertyType, String propertyName) { return of(host, Property.of((Class<H>) host.getClass(), propertyType, propertyName)); } private static Class getNullaryMethodReturnType(Class c, String name) { try { return c.getMethod(name).getReturnType(); } catch (NoSuchMethodException e) { return null; } } private static Class getFieldType(Class c, String name) { try { return c.getField(name).getType(); } catch (NoSuchFieldException e) { return null; } } private static String capitalize(String name) { if (name.isEmpty()) { return name; } return Character.toUpperCase(name.charAt(0)) + name.substring(1); } /** * Return a PropertyValueModel for this {@code host} and and {@code propertyName}. * * @param host the host * @param propertyName the property name * @return a value model with this host and a reflective property with this name */ public static PropertyValueModel of(Object host, String propertyName) { Class clazz = host.getClass(); String suffix = capitalize(propertyName); Class propertyType = getNullaryMethodReturnType(clazz, "get" + suffix); if (propertyType == null) { propertyType = getNullaryMethodReturnType(clazz, "is" + suffix); } if (propertyType == null) { propertyType = getFieldType(clazz, propertyName); } if (propertyType == null) { throw new NoSuchPropertyException(propertyName); } return of(host, propertyType, propertyName); } } core/java/android/util/ValueModel.java 0 → 100755 +74 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2012 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.util; /** * A ValueModel is an abstraction for a 'slot' or place in memory in which a value * may be stored and retrieved. A common implementation of ValueModel is a regular property of * an object, whose value may be retrieved by calling the appropriate <em>getter</em> * method and set by calling the corresponding <em>setter</em> method. * * @param <T> the value type * * @see PropertyValueModel */ public abstract class ValueModel<T> { /** * The empty model should be used in place of {@code null} to indicate that a * model has not been set. The empty model has no value and does nothing when it is set. */ public static final ValueModel EMPTY = new ValueModel() { @Override public Class getType() { return Object.class; } @Override public Object get() { return null; } @Override public void set(Object value) { } }; protected ValueModel() { } /** * Returns the type of this property. * * @return the property type */ public abstract Class<T> getType(); /** * Returns the value of this property. * * @return the property value */ public abstract T get(); /** * Sets the value of this property. * * @param value the new value for this property */ public abstract void set(T value); } No newline at end of file core/java/android/widget/CheckBox.java +22 −1 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.content.Context; import android.util.AttributeSet; import android.util.AttributeSet; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityNodeInfo; import android.util.ValueModel; /** /** Loading Loading @@ -55,7 +56,9 @@ import android.view.accessibility.AccessibilityNodeInfo; * {@link android.R.styleable#View View Attributes} * {@link android.R.styleable#View View Attributes} * </p> * </p> */ */ public class CheckBox extends CompoundButton { public class CheckBox extends CompoundButton implements ValueEditor<Boolean> { private ValueModel<Boolean> mValueModel = ValueModel.EMPTY; public CheckBox(Context context) { public CheckBox(Context context) { this(context, null); this(context, null); } } Loading @@ -79,4 +82,22 @@ public class CheckBox extends CompoundButton { super.onInitializeAccessibilityNodeInfo(info); super.onInitializeAccessibilityNodeInfo(info); info.setClassName(CheckBox.class.getName()); info.setClassName(CheckBox.class.getName()); } } @Override public ValueModel<Boolean> getValueModel() { return mValueModel; } @Override public void setValueModel(ValueModel<Boolean> valueModel) { mValueModel = valueModel; setChecked(mValueModel.get()); } @Override public boolean performClick() { boolean handled = super.performClick(); mValueModel.set(isChecked()); return handled; } } } core/java/android/widget/EditText.java +22 −1 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.widget; package android.widget; import android.content.Context; import android.content.Context; import android.graphics.Rect; import android.text.Editable; import android.text.Editable; import android.text.Selection; import android.text.Selection; import android.text.Spannable; import android.text.Spannable; Loading @@ -24,6 +25,7 @@ import android.text.TextUtils; import android.text.method.ArrowKeyMovementMethod; import android.text.method.ArrowKeyMovementMethod; import android.text.method.MovementMethod; import android.text.method.MovementMethod; import android.util.AttributeSet; import android.util.AttributeSet; import android.util.ValueModel; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityNodeInfo; Loading @@ -47,7 +49,9 @@ import android.view.accessibility.AccessibilityNodeInfo; * {@link android.R.styleable#TextView TextView Attributes}, * {@link android.R.styleable#TextView TextView Attributes}, * {@link android.R.styleable#View View Attributes} * {@link android.R.styleable#View View Attributes} */ */ public class EditText extends TextView { public class EditText extends TextView implements ValueEditor<CharSequence> { private ValueModel<CharSequence> mValueModel = ValueModel.EMPTY; public EditText(Context context) { public EditText(Context context) { this(context, null); this(context, null); } } Loading Loading @@ -128,4 +132,21 @@ public class EditText extends TextView { super.onInitializeAccessibilityNodeInfo(info); super.onInitializeAccessibilityNodeInfo(info); info.setClassName(EditText.class.getName()); info.setClassName(EditText.class.getName()); } } @Override public ValueModel<CharSequence> getValueModel() { return mValueModel; } @Override public void setValueModel(ValueModel<CharSequence> valueModel) { mValueModel = valueModel; setText(mValueModel.get()); } @Override void sendAfterTextChanged(Editable text) { super.sendAfterTextChanged(text); mValueModel.set(text); } } } Loading
api/current.txt +33 −3 Original line number Original line Diff line number Diff line Loading @@ -22826,6 +22826,17 @@ package android.util { method public void set(T, V); method public void set(T, V); } } public class PropertyValueModel extends android.util.ValueModel { method public T get(); method public H getHost(); method public android.util.Property<H, T> getProperty(); method public java.lang.Class<T> getType(); method public static android.util.PropertyValueModel<H, T> of(H, android.util.Property<H, T>); method public static android.util.PropertyValueModel<H, T> of(H, java.lang.Class<T>, java.lang.String); method public static android.util.PropertyValueModel of(java.lang.Object, java.lang.String); method public void set(T); } public class SparseArray implements java.lang.Cloneable { public class SparseArray implements java.lang.Cloneable { ctor public SparseArray(); ctor public SparseArray(); ctor public SparseArray(int); ctor public SparseArray(int); Loading Loading @@ -22974,6 +22985,14 @@ package android.util { field public int type; field public int type; } } public abstract class ValueModel { ctor protected ValueModel(); method public abstract T get(); method public abstract java.lang.Class<T> getType(); method public abstract void set(T); field public static final android.util.ValueModel EMPTY; } public class Xml { public class Xml { method public static android.util.AttributeSet asAttributeSet(org.xmlpull.v1.XmlPullParser); method public static android.util.AttributeSet asAttributeSet(org.xmlpull.v1.XmlPullParser); method public static android.util.Xml.Encoding findEncodingByName(java.lang.String) throws java.io.UnsupportedEncodingException; method public static android.util.Xml.Encoding findEncodingByName(java.lang.String) throws java.io.UnsupportedEncodingException; Loading Loading @@ -27395,10 +27414,12 @@ package android.widget { method public abstract void onSelectedDayChange(android.widget.CalendarView, int, int, int); method public abstract void onSelectedDayChange(android.widget.CalendarView, int, int, int); } } public class CheckBox extends android.widget.CompoundButton { public class CheckBox extends android.widget.CompoundButton implements android.widget.ValueEditor { ctor public CheckBox(android.content.Context); ctor public CheckBox(android.content.Context); ctor public CheckBox(android.content.Context, android.util.AttributeSet); ctor public CheckBox(android.content.Context, android.util.AttributeSet); ctor public CheckBox(android.content.Context, android.util.AttributeSet, int); ctor public CheckBox(android.content.Context, android.util.AttributeSet, int); method public android.util.ValueModel<java.lang.Boolean> getValueModel(); method public void setValueModel(android.util.ValueModel<java.lang.Boolean>); } } public abstract interface Checkable { public abstract interface Checkable { Loading Loading @@ -27571,14 +27592,16 @@ package android.widget { method public void setSize(int, int); method public void setSize(int, int); } } public class EditText extends android.widget.TextView { public class EditText extends android.widget.TextView implements android.widget.ValueEditor { ctor public EditText(android.content.Context); ctor public EditText(android.content.Context); ctor public EditText(android.content.Context, android.util.AttributeSet); ctor public EditText(android.content.Context, android.util.AttributeSet); ctor public EditText(android.content.Context, android.util.AttributeSet, int); ctor public EditText(android.content.Context, android.util.AttributeSet, int); method public void extendSelection(int); method public void extendSelection(int); method public android.util.ValueModel<java.lang.CharSequence> getValueModel(); method public void selectAll(); method public void selectAll(); method public void setSelection(int, int); method public void setSelection(int, int); method public void setSelection(int); method public void setSelection(int); method public void setValueModel(android.util.ValueModel<java.lang.CharSequence>); } } public abstract interface ExpandableListAdapter { public abstract interface ExpandableListAdapter { Loading Loading @@ -28595,11 +28618,13 @@ package android.widget { method public abstract java.lang.Object[] getSections(); method public abstract java.lang.Object[] getSections(); } } public class SeekBar extends android.widget.AbsSeekBar { public class SeekBar extends android.widget.AbsSeekBar implements android.widget.ValueEditor { ctor public SeekBar(android.content.Context); ctor public SeekBar(android.content.Context); ctor public SeekBar(android.content.Context, android.util.AttributeSet); ctor public SeekBar(android.content.Context, android.util.AttributeSet); ctor public SeekBar(android.content.Context, android.util.AttributeSet, int); ctor public SeekBar(android.content.Context, android.util.AttributeSet, int); method public android.util.ValueModel<java.lang.Integer> getValueModel(); method public void setOnSeekBarChangeListener(android.widget.SeekBar.OnSeekBarChangeListener); method public void setOnSeekBarChangeListener(android.widget.SeekBar.OnSeekBarChangeListener); method public void setValueModel(android.util.ValueModel<java.lang.Integer>); } } public static abstract interface SeekBar.OnSeekBarChangeListener { public static abstract interface SeekBar.OnSeekBarChangeListener { Loading Loading @@ -29171,6 +29196,11 @@ package android.widget { method public android.widget.TextView getText2(); method public android.widget.TextView getText2(); } } public abstract interface ValueEditor { method public abstract android.util.ValueModel<T> getValueModel(); method public abstract void setValueModel(android.util.ValueModel<T>); } public class VideoView extends android.view.SurfaceView implements android.widget.MediaController.MediaPlayerControl { public class VideoView extends android.view.SurfaceView implements android.widget.MediaController.MediaPlayerControl { ctor public VideoView(android.content.Context); ctor public VideoView(android.content.Context); ctor public VideoView(android.content.Context, android.util.AttributeSet); ctor public VideoView(android.content.Context, android.util.AttributeSet);
core/java/android/util/PropertyValueModel.java 0 → 100755 +143 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2012 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.util; /** * A value model for a {@link Property property} of a host object. This class can be used for * both reflective and non-reflective property implementations. * * @param <H> the host type, where the host is the object that holds this property * @param <T> the value type * * @see Property * @see ValueModel */ public class PropertyValueModel<H, T> extends ValueModel<T> { private final H mHost; private final Property<H, T> mProperty; private PropertyValueModel(H host, Property<H, T> property) { mProperty = property; mHost = host; } /** * Returns the host. * * @return the host */ public H getHost() { return mHost; } /** * Returns the property. * * @return the property */ public Property<H, T> getProperty() { return mProperty; } @Override public Class<T> getType() { return mProperty.getType(); } @Override public T get() { return mProperty.get(mHost); } @Override public void set(T value) { mProperty.set(mHost, value); } /** * Return an appropriate PropertyValueModel for this host and property. * * @param host the host * @param property the property * @return the value model */ public static <H, T> PropertyValueModel<H, T> of(H host, Property<H, T> property) { return new PropertyValueModel<H, T>(host, property); } /** * Return a PropertyValueModel for this {@code host} and a * reflective property, constructed from this {@code propertyType} and {@code propertyName}. * * @param host * @param propertyType the property type * @param propertyName the property name * @return a value model with this host and a reflective property with this type and name * * @see Property#of */ public static <H, T> PropertyValueModel<H, T> of(H host, Class<T> propertyType, String propertyName) { return of(host, Property.of((Class<H>) host.getClass(), propertyType, propertyName)); } private static Class getNullaryMethodReturnType(Class c, String name) { try { return c.getMethod(name).getReturnType(); } catch (NoSuchMethodException e) { return null; } } private static Class getFieldType(Class c, String name) { try { return c.getField(name).getType(); } catch (NoSuchFieldException e) { return null; } } private static String capitalize(String name) { if (name.isEmpty()) { return name; } return Character.toUpperCase(name.charAt(0)) + name.substring(1); } /** * Return a PropertyValueModel for this {@code host} and and {@code propertyName}. * * @param host the host * @param propertyName the property name * @return a value model with this host and a reflective property with this name */ public static PropertyValueModel of(Object host, String propertyName) { Class clazz = host.getClass(); String suffix = capitalize(propertyName); Class propertyType = getNullaryMethodReturnType(clazz, "get" + suffix); if (propertyType == null) { propertyType = getNullaryMethodReturnType(clazz, "is" + suffix); } if (propertyType == null) { propertyType = getFieldType(clazz, propertyName); } if (propertyType == null) { throw new NoSuchPropertyException(propertyName); } return of(host, propertyType, propertyName); } }
core/java/android/util/ValueModel.java 0 → 100755 +74 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2012 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.util; /** * A ValueModel is an abstraction for a 'slot' or place in memory in which a value * may be stored and retrieved. A common implementation of ValueModel is a regular property of * an object, whose value may be retrieved by calling the appropriate <em>getter</em> * method and set by calling the corresponding <em>setter</em> method. * * @param <T> the value type * * @see PropertyValueModel */ public abstract class ValueModel<T> { /** * The empty model should be used in place of {@code null} to indicate that a * model has not been set. The empty model has no value and does nothing when it is set. */ public static final ValueModel EMPTY = new ValueModel() { @Override public Class getType() { return Object.class; } @Override public Object get() { return null; } @Override public void set(Object value) { } }; protected ValueModel() { } /** * Returns the type of this property. * * @return the property type */ public abstract Class<T> getType(); /** * Returns the value of this property. * * @return the property value */ public abstract T get(); /** * Sets the value of this property. * * @param value the new value for this property */ public abstract void set(T value); } No newline at end of file
core/java/android/widget/CheckBox.java +22 −1 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.content.Context; import android.util.AttributeSet; import android.util.AttributeSet; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityNodeInfo; import android.util.ValueModel; /** /** Loading Loading @@ -55,7 +56,9 @@ import android.view.accessibility.AccessibilityNodeInfo; * {@link android.R.styleable#View View Attributes} * {@link android.R.styleable#View View Attributes} * </p> * </p> */ */ public class CheckBox extends CompoundButton { public class CheckBox extends CompoundButton implements ValueEditor<Boolean> { private ValueModel<Boolean> mValueModel = ValueModel.EMPTY; public CheckBox(Context context) { public CheckBox(Context context) { this(context, null); this(context, null); } } Loading @@ -79,4 +82,22 @@ public class CheckBox extends CompoundButton { super.onInitializeAccessibilityNodeInfo(info); super.onInitializeAccessibilityNodeInfo(info); info.setClassName(CheckBox.class.getName()); info.setClassName(CheckBox.class.getName()); } } @Override public ValueModel<Boolean> getValueModel() { return mValueModel; } @Override public void setValueModel(ValueModel<Boolean> valueModel) { mValueModel = valueModel; setChecked(mValueModel.get()); } @Override public boolean performClick() { boolean handled = super.performClick(); mValueModel.set(isChecked()); return handled; } } }
core/java/android/widget/EditText.java +22 −1 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.widget; package android.widget; import android.content.Context; import android.content.Context; import android.graphics.Rect; import android.text.Editable; import android.text.Editable; import android.text.Selection; import android.text.Selection; import android.text.Spannable; import android.text.Spannable; Loading @@ -24,6 +25,7 @@ import android.text.TextUtils; import android.text.method.ArrowKeyMovementMethod; import android.text.method.ArrowKeyMovementMethod; import android.text.method.MovementMethod; import android.text.method.MovementMethod; import android.util.AttributeSet; import android.util.AttributeSet; import android.util.ValueModel; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityNodeInfo; Loading @@ -47,7 +49,9 @@ import android.view.accessibility.AccessibilityNodeInfo; * {@link android.R.styleable#TextView TextView Attributes}, * {@link android.R.styleable#TextView TextView Attributes}, * {@link android.R.styleable#View View Attributes} * {@link android.R.styleable#View View Attributes} */ */ public class EditText extends TextView { public class EditText extends TextView implements ValueEditor<CharSequence> { private ValueModel<CharSequence> mValueModel = ValueModel.EMPTY; public EditText(Context context) { public EditText(Context context) { this(context, null); this(context, null); } } Loading Loading @@ -128,4 +132,21 @@ public class EditText extends TextView { super.onInitializeAccessibilityNodeInfo(info); super.onInitializeAccessibilityNodeInfo(info); info.setClassName(EditText.class.getName()); info.setClassName(EditText.class.getName()); } } @Override public ValueModel<CharSequence> getValueModel() { return mValueModel; } @Override public void setValueModel(ValueModel<CharSequence> valueModel) { mValueModel = valueModel; setText(mValueModel.get()); } @Override void sendAfterTextChanged(Editable text) { super.sendAfterTextChanged(text); mValueModel.set(text); } } }