diff options
author | Siva Velusamy <vsiva@google.com> | 2015-05-05 15:07:00 -0700 |
---|---|---|
committer | Siva Velusamy <vsiva@google.com> | 2015-05-07 18:44:21 -0700 |
commit | 94a6d15ede149189bba9e5f474ed853c98230e75 (patch) | |
tree | edc5a5211a7b69e091a13ddc3c60dcf88d9a5ea6 /core | |
parent | 0d857b9028f2702ce439e13feccde8182d40e1e5 (diff) | |
download | frameworks_base-94a6d15ede149189bba9e5f474ed853c98230e75.zip frameworks_base-94a6d15ede149189bba9e5f474ed853c98230e75.tar.gz frameworks_base-94a6d15ede149189bba9e5f474ed853c98230e75.tar.bz2 |
Use new hierarchy viewer protocol in all View subclasses
A previous CL introduced a new way of encoding view properties for
use by heirarchy viewer. This CL updates all views using the old
@ExportedProperty annotation to use this new method. The older
mechanism will be removed in a subsequent CL.
Change-Id: I6cc23b90cd9da1c6ce89b4caffe54874db203452
Diffstat (limited to 'core')
20 files changed, 256 insertions, 4 deletions
diff --git a/core/java/android/app/ActionBar.java b/core/java/android/app/ActionBar.java index 94e3b66..4d34349 100644 --- a/core/java/android/app/ActionBar.java +++ b/core/java/android/app/ActionBar.java @@ -33,6 +33,7 @@ import android.view.KeyEvent; import android.view.View; import android.view.ViewDebug; import android.view.ViewGroup; +import android.view.ViewHierarchyEncoder; import android.view.Window; import android.widget.SpinnerAdapter; import java.lang.annotation.Retention; @@ -1373,5 +1374,13 @@ public abstract class ActionBar { * version of the SDK an app can end up statically linking to the new MarginLayoutParams * overload, causing a crash when running on older platform versions with no other changes. */ + + /** @hide */ + @Override + protected void encodeProperties(@NonNull ViewHierarchyEncoder encoder) { + super.encodeProperties(encoder); + + encoder.addProperty("gravity", gravity); + } } } diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index a26c953..a3d0b2a 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -22355,7 +22355,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } /** {@hide} */ - void encode(@NonNull ViewHierarchyEncoder stream) { + public void encode(@NonNull ViewHierarchyEncoder stream) { stream.beginObject(this); encodeProperties(stream); stream.endObject(); diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 7ab5aaa..a261aaf 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -16,6 +16,7 @@ package android.webkit; +import android.annotation.NonNull; import android.annotation.SystemApi; import android.annotation.Widget; import android.content.Context; @@ -43,6 +44,7 @@ import android.view.View; import android.view.ViewAssistStructure; import android.view.ViewDebug; import android.view.ViewGroup; +import android.view.ViewHierarchyEncoder; import android.view.ViewTreeObserver; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; @@ -2576,4 +2578,18 @@ public class WebView extends AbsoluteLayout super.onFinishTemporaryDetach(); mProvider.getViewDelegate().onFinishTemporaryDetach(); } + + /** @hide */ + @Override + protected void encodeProperties(@NonNull ViewHierarchyEncoder encoder) { + super.encodeProperties(encoder); + + checkThread(); + encoder.addProperty("webview:contentHeight", mProvider.getContentHeight()); + encoder.addProperty("webview:contentWidth", mProvider.getContentWidth()); + encoder.addProperty("webview:scale", mProvider.getScale()); + encoder.addProperty("webview:title", mProvider.getTitle()); + encoder.addProperty("webview:url", mProvider.getUrl()); + encoder.addProperty("webview:originalUrl", mProvider.getOriginalUrl()); + } } diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index c57a53a..9903b7e 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -18,6 +18,7 @@ package android.widget; import android.annotation.ColorInt; import android.annotation.DrawableRes; +import android.annotation.NonNull; import android.content.Context; import android.content.Intent; import android.content.res.TypedArray; @@ -56,6 +57,7 @@ import android.view.View; import android.view.ViewConfiguration; import android.view.ViewDebug; import android.view.ViewGroup; +import android.view.ViewHierarchyEncoder; import android.view.ViewParent; import android.view.ViewTreeObserver; import android.view.accessibility.AccessibilityEvent; @@ -6330,6 +6332,16 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te public LayoutParams(ViewGroup.LayoutParams source) { super(source); } + + /** @hide */ + @Override + protected void encodeProperties(@NonNull ViewHierarchyEncoder encoder) { + super.encodeProperties(encoder); + + encoder.addProperty("list:viewType", viewType); + encoder.addProperty("list:recycledHeaderFooter", recycledHeaderFooter); + encoder.addProperty("list:forceAdd", forceAdd); + } } /** @@ -6912,6 +6924,25 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te } } + /** @hide */ + @Override + protected void encodeProperties(@NonNull ViewHierarchyEncoder encoder) { + super.encodeProperties(encoder); + + encoder.addProperty("drawing:cacheColorHint", getCacheColorHint()); + encoder.addProperty("list:fastScrollEnabled", isFastScrollEnabled()); + encoder.addProperty("list:scrollingCacheEnabled", isScrollingCacheEnabled()); + encoder.addProperty("list:smoothScrollbarEnabled", isSmoothScrollbarEnabled()); + encoder.addProperty("list:stackFromBottom", isStackFromBottom()); + encoder.addProperty("list:textFilterEnabled", isTextFilterEnabled()); + + View selectedView = getSelectedView(); + if (selectedView != null) { + encoder.addPropertyKey("selectedView"); + selectedView.encode(encoder); + } + } + /** * Abstract positon scroller used to handle smooth scrolling. */ diff --git a/core/java/android/widget/ActionMenuView.java b/core/java/android/widget/ActionMenuView.java index d6f2276..278a8fb 100644 --- a/core/java/android/widget/ActionMenuView.java +++ b/core/java/android/widget/ActionMenuView.java @@ -15,6 +15,7 @@ */ package android.widget; +import android.annotation.NonNull; import android.annotation.StyleRes; import android.content.Context; import android.content.res.ColorStateList; @@ -28,6 +29,7 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewDebug; import android.view.ViewGroup; +import android.view.ViewHierarchyEncoder; import android.view.accessibility.AccessibilityEvent; import com.android.internal.view.menu.ActionMenuItemView; import com.android.internal.view.menu.MenuBuilder; @@ -835,5 +837,17 @@ public class ActionMenuView extends LinearLayout implements MenuBuilder.ItemInvo super(width, height); this.isOverflowButton = isOverflowButton; } + + /** @hide */ + @Override + protected void encodeProperties(@NonNull ViewHierarchyEncoder encoder) { + super.encodeProperties(encoder); + + encoder.addProperty("layout:overFlowButton", isOverflowButton); + encoder.addProperty("layout:cellsUsed", cellsUsed); + encoder.addProperty("layout:extraPixels", extraPixels); + encoder.addProperty("layout:expandable", expandable); + encoder.addProperty("layout:preventEdgeOffset", preventEdgeOffset); + } } } diff --git a/core/java/android/widget/AdapterView.java b/core/java/android/widget/AdapterView.java index 72cb0b5..54e3996 100644 --- a/core/java/android/widget/AdapterView.java +++ b/core/java/android/widget/AdapterView.java @@ -16,6 +16,7 @@ package android.widget; +import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; import android.database.DataSetObserver; @@ -29,6 +30,7 @@ import android.view.SoundEffectConstants; import android.view.View; import android.view.ViewDebug; import android.view.ViewGroup; +import android.view.ViewHierarchyEncoder; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityNodeInfo; @@ -1245,4 +1247,16 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup { } } } + + /** @hide */ + @Override + protected void encodeProperties(@NonNull ViewHierarchyEncoder encoder) { + super.encodeProperties(encoder); + + encoder.addProperty("scrolling:firstPosition", mFirstPosition); + encoder.addProperty("list:nextSelectedPosition", mNextSelectedPosition); + encoder.addProperty("list:nextSelectedRowId", mNextSelectedRowId); + encoder.addProperty("list:selectedPosition", mSelectedPosition); + encoder.addProperty("list:itemCount", mItemCount); + } } diff --git a/core/java/android/widget/CheckedTextView.java b/core/java/android/widget/CheckedTextView.java index 22e079c..6b4b2c7 100644 --- a/core/java/android/widget/CheckedTextView.java +++ b/core/java/android/widget/CheckedTextView.java @@ -16,6 +16,8 @@ package android.widget; +import android.annotation.NonNull; +import android.view.ViewHierarchyEncoder; import com.android.internal.R; import android.annotation.DrawableRes; @@ -459,4 +461,11 @@ public class CheckedTextView extends TextView implements Checkable { info.setCheckable(true); info.setChecked(mChecked); } + + /** @hide */ + @Override + protected void encodeProperties(@NonNull ViewHierarchyEncoder stream) { + super.encodeProperties(stream); + stream.addProperty("text:checked", isChecked()); + } } diff --git a/core/java/android/widget/CompoundButton.java b/core/java/android/widget/CompoundButton.java index f2afeeb..770077d 100644 --- a/core/java/android/widget/CompoundButton.java +++ b/core/java/android/widget/CompoundButton.java @@ -17,8 +17,10 @@ package android.widget; import android.annotation.DrawableRes; +import android.annotation.NonNull; import android.annotation.Nullable; import android.graphics.PorterDuff; +import android.view.ViewHierarchyEncoder; import com.android.internal.R; import android.content.Context; @@ -530,9 +532,16 @@ public abstract class CompoundButton extends Button implements Checkable { @Override public void onRestoreInstanceState(Parcelable state) { SavedState ss = (SavedState) state; - + super.onRestoreInstanceState(ss.getSuperState()); setChecked(ss.checked); requestLayout(); } + + /** @hide */ + @Override + protected void encodeProperties(@NonNull ViewHierarchyEncoder stream) { + super.encodeProperties(stream); + stream.addProperty("checked", isChecked()); + } } diff --git a/core/java/android/widget/FrameLayout.java b/core/java/android/widget/FrameLayout.java index 0602944..7ca450a 100644 --- a/core/java/android/widget/FrameLayout.java +++ b/core/java/android/widget/FrameLayout.java @@ -33,6 +33,7 @@ import android.view.Gravity; import android.view.View; import android.view.ViewDebug; import android.view.ViewGroup; +import android.view.ViewHierarchyEncoder; import android.widget.RemoteViews.RemoteView; import com.android.internal.R; @@ -407,6 +408,18 @@ public class FrameLayout extends ViewGroup { return FrameLayout.class.getName(); } + /** @hide */ + @Override + protected void encodeProperties(@NonNull ViewHierarchyEncoder encoder) { + super.encodeProperties(encoder); + + encoder.addProperty("measurement:measureAllChildren", mMeasureAllChildren); + encoder.addProperty("padding:foregroundPaddingLeft", mForegroundPaddingLeft); + encoder.addProperty("padding:foregroundPaddingTop", mForegroundPaddingTop); + encoder.addProperty("padding:foregroundPaddingRight", mForegroundPaddingRight); + encoder.addProperty("padding:foregroundPaddingBottom", mForegroundPaddingBottom); + } + /** * Per-child layout information for layouts that support margins. * See {@link android.R.styleable#FrameLayout_Layout FrameLayout Layout Attributes} diff --git a/core/java/android/widget/GridView.java b/core/java/android/widget/GridView.java index c959774..dcaafa5 100644 --- a/core/java/android/widget/GridView.java +++ b/core/java/android/widget/GridView.java @@ -17,6 +17,7 @@ package android.widget; import android.annotation.IntDef; +import android.annotation.NonNull; import android.content.Context; import android.content.Intent; import android.content.res.TypedArray; @@ -31,6 +32,7 @@ import android.view.SoundEffectConstants; import android.view.View; import android.view.ViewDebug; import android.view.ViewGroup; +import android.view.ViewHierarchyEncoder; import android.view.ViewRootImpl; import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; @@ -2420,4 +2422,11 @@ public class GridView extends AbsListView { row, 1, column, 1, isHeading, isSelected); info.setCollectionItemInfo(itemInfo); } + + /** @hide */ + @Override + protected void encodeProperties(@NonNull ViewHierarchyEncoder encoder) { + super.encodeProperties(encoder); + encoder.addProperty("numColumns", getNumColumns()); + } } diff --git a/core/java/android/widget/HorizontalScrollView.java b/core/java/android/widget/HorizontalScrollView.java index 0879c5d..cf67905 100644 --- a/core/java/android/widget/HorizontalScrollView.java +++ b/core/java/android/widget/HorizontalScrollView.java @@ -16,6 +16,7 @@ package android.widget; +import android.annotation.NonNull; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; @@ -35,6 +36,7 @@ import android.view.View; import android.view.ViewConfiguration; import android.view.ViewDebug; import android.view.ViewGroup; +import android.view.ViewHierarchyEncoder; import android.view.ViewParent; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; @@ -1695,6 +1697,13 @@ public class HorizontalScrollView extends FrameLayout { return ss; } + /** @hide */ + @Override + protected void encodeProperties(@NonNull ViewHierarchyEncoder encoder) { + super.encodeProperties(encoder); + encoder.addProperty("layout:fillViewPort", mFillViewport); + } + static class SavedState extends BaseSavedState { public int scrollPosition; public boolean isLayoutRtl; diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java index 6d2f368..05059bc 100644 --- a/core/java/android/widget/ImageView.java +++ b/core/java/android/widget/ImageView.java @@ -17,6 +17,7 @@ package android.widget; import android.annotation.DrawableRes; +import android.annotation.NonNull; import android.annotation.Nullable; import android.content.ContentResolver; import android.content.Context; @@ -43,6 +44,7 @@ import android.util.Log; import android.view.RemotableViewMethod; import android.view.View; import android.view.ViewDebug; +import android.view.ViewHierarchyEncoder; import android.view.accessibility.AccessibilityEvent; import android.widget.RemoteViews.RemoteView; @@ -1431,4 +1433,11 @@ public class ImageView extends View { public CharSequence getAccessibilityClassName() { return ImageView.class.getName(); } + + /** @hide */ + @Override + protected void encodeProperties(@NonNull ViewHierarchyEncoder stream) { + super.encodeProperties(stream); + stream.addProperty("layout:baseline", getBaseline()); + } } diff --git a/core/java/android/widget/LinearLayout.java b/core/java/android/widget/LinearLayout.java index 72f51c9..f153ce5 100644 --- a/core/java/android/widget/LinearLayout.java +++ b/core/java/android/widget/LinearLayout.java @@ -19,6 +19,7 @@ package android.widget; import com.android.internal.R; import android.annotation.IntDef; +import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; import android.content.res.TypedArray; @@ -29,6 +30,7 @@ import android.view.Gravity; import android.view.View; import android.view.ViewDebug; import android.view.ViewGroup; +import android.view.ViewHierarchyEncoder; import android.widget.RemoteViews.RemoteView; import java.lang.annotation.Retention; @@ -1813,6 +1815,20 @@ public class LinearLayout extends ViewGroup { return LinearLayout.class.getName(); } + /** @hide */ + @Override + protected void encodeProperties(@NonNull ViewHierarchyEncoder encoder) { + super.encodeProperties(encoder); + encoder.addProperty("layout:baselineAligned", mBaselineAligned); + encoder.addProperty("layout:baselineAlignedChildIndex", mBaselineAlignedChildIndex); + encoder.addProperty("measurement:baselineChildTop", mBaselineChildTop); + encoder.addProperty("measurement:orientation", mOrientation); + encoder.addProperty("measurement:gravity", mGravity); + encoder.addProperty("measurement:totalLength", mTotalLength); + encoder.addProperty("layout:totalLength", mTotalLength); + encoder.addProperty("layout:useLargestChild", mUseLargestChild); + } + /** * Per-child layout information associated with ViewLinearLayout. * @@ -1921,5 +1937,14 @@ public class LinearLayout extends ViewGroup { return output + "LinearLayout.LayoutParams={width=" + sizeToString(width) + ", height=" + sizeToString(height) + " weight=" + weight + "}"; } + + /** @hide */ + @Override + protected void encodeProperties(@NonNull ViewHierarchyEncoder encoder) { + super.encodeProperties(encoder); + + encoder.addProperty("layout:weight", weight); + encoder.addProperty("layout:gravity", gravity); + } } } diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java index a79c8e8..7dcaa1f 100644 --- a/core/java/android/widget/ListView.java +++ b/core/java/android/widget/ListView.java @@ -23,6 +23,7 @@ import com.android.internal.util.Predicate; import com.google.android.collect.Lists; import android.annotation.IdRes; +import android.annotation.NonNull; import android.content.Context; import android.content.Intent; import android.content.res.TypedArray; @@ -40,6 +41,7 @@ import android.view.SoundEffectConstants; import android.view.View; import android.view.ViewDebug; import android.view.ViewGroup; +import android.view.ViewHierarchyEncoder; import android.view.ViewParent; import android.view.ViewRootImpl; import android.view.accessibility.AccessibilityNodeInfo; @@ -3938,4 +3940,12 @@ public class ListView extends AbsListView { position, 1, 0, 1, isHeading, isSelected); info.setCollectionItemInfo(itemInfo); } + + /** @hide */ + @Override + protected void encodeProperties(@NonNull ViewHierarchyEncoder encoder) { + super.encodeProperties(encoder); + + encoder.addProperty("recycleOnMeasure", recycleOnMeasure()); + } } diff --git a/core/java/android/widget/ProgressBar.java b/core/java/android/widget/ProgressBar.java index b59ae17..639a09c 100644 --- a/core/java/android/widget/ProgressBar.java +++ b/core/java/android/widget/ProgressBar.java @@ -16,6 +16,7 @@ package android.widget; +import android.annotation.NonNull; import android.annotation.Nullable; import android.graphics.PorterDuff; @@ -49,6 +50,7 @@ import android.view.Gravity; import android.view.RemotableViewMethod; import android.view.View; import android.view.ViewDebug; +import android.view.ViewHierarchyEncoder; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; import android.view.animation.AlphaAnimation; @@ -1893,6 +1895,17 @@ public class ProgressBar extends View { postDelayed(mAccessibilityEventSender, TIMEOUT_SEND_ACCESSIBILITY_EVENT); } + /** @hide */ + @Override + protected void encodeProperties(@NonNull ViewHierarchyEncoder stream) { + super.encodeProperties(stream); + + stream.addProperty("progress:max", getMax()); + stream.addProperty("progress:progress", getProgress()); + stream.addProperty("progress:secondaryProgress", getSecondaryProgress()); + stream.addProperty("progress:indeterminate", isIndeterminate()); + } + /** * Command for sending an accessibility event. */ diff --git a/core/java/android/widget/RelativeLayout.java b/core/java/android/widget/RelativeLayout.java index d12739f..affc5da 100644 --- a/core/java/android/widget/RelativeLayout.java +++ b/core/java/android/widget/RelativeLayout.java @@ -16,6 +16,7 @@ package android.widget; +import android.annotation.NonNull; import android.util.ArrayMap; import com.android.internal.R; @@ -36,6 +37,7 @@ import android.view.Gravity; import android.view.View; import android.view.ViewDebug; import android.view.ViewGroup; +import android.view.ViewHierarchyEncoder; import android.view.accessibility.AccessibilityEvent; import android.widget.RemoteViews.RemoteView; @@ -1616,6 +1618,13 @@ public class RelativeLayout extends ViewGroup { // This will set the layout direction super.resolveLayoutDirection(layoutDirection); } + + /** @hide */ + @Override + protected void encodeProperties(@NonNull ViewHierarchyEncoder encoder) { + super.encodeProperties(encoder); + encoder.addProperty("layout:alignWithParent", alignWithParent); + } } private static class DependencyGraph { diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java index 98d61d3..2709f25 100644 --- a/core/java/android/widget/ScrollView.java +++ b/core/java/android/widget/ScrollView.java @@ -16,6 +16,7 @@ package android.widget; +import android.annotation.NonNull; import android.os.Build; import android.os.Parcel; import android.os.Parcelable; @@ -38,6 +39,7 @@ import android.view.View; import android.view.ViewConfiguration; import android.view.ViewDebug; import android.view.ViewGroup; +import android.view.ViewHierarchyEncoder; import android.view.ViewParent; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; @@ -1787,6 +1789,13 @@ public class ScrollView extends FrameLayout { return ss; } + /** @hide */ + @Override + protected void encodeProperties(@NonNull ViewHierarchyEncoder encoder) { + super.encodeProperties(encoder); + encoder.addProperty("fillViewport", mFillViewport); + } + static class SavedState extends BaseSavedState { public int scrollPosition; diff --git a/core/java/android/widget/TableRow.java b/core/java/android/widget/TableRow.java index f73ee49..d4288d6 100644 --- a/core/java/android/widget/TableRow.java +++ b/core/java/android/widget/TableRow.java @@ -16,6 +16,7 @@ package android.widget; +import android.annotation.NonNull; import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; @@ -24,7 +25,7 @@ import android.view.Gravity; import android.view.View; import android.view.ViewDebug; import android.view.ViewGroup; - +import android.view.ViewHierarchyEncoder; /** * <p>A layout that arranges its children horizontally. A TableRow should @@ -509,6 +510,14 @@ public class TableRow extends LinearLayout { height = WRAP_CONTENT; } } + + /** @hide */ + @Override + protected void encodeProperties(@NonNull ViewHierarchyEncoder encoder) { + super.encodeProperties(encoder); + encoder.addProperty("layout:column", column); + encoder.addProperty("layout:span", span); + } } // special transparent hierarchy change listener diff --git a/core/java/android/widget/TextClock.java b/core/java/android/widget/TextClock.java index e2acaac..5d7b569 100644 --- a/core/java/android/widget/TextClock.java +++ b/core/java/android/widget/TextClock.java @@ -16,6 +16,7 @@ package android.widget; +import android.annotation.NonNull; import android.app.ActivityManager; import android.content.BroadcastReceiver; import android.content.ContentResolver; @@ -32,6 +33,7 @@ import android.provider.Settings; import android.text.format.DateFormat; import android.util.AttributeSet; import android.view.RemotableViewMethod; +import android.view.ViewHierarchyEncoder; import com.android.internal.R; @@ -546,4 +548,18 @@ public class TextClock extends TextView { mTime.setTimeInMillis(System.currentTimeMillis()); setText(DateFormat.format(mFormat, mTime)); } + + /** @hide */ + @Override + protected void encodeProperties(@NonNull ViewHierarchyEncoder stream) { + super.encodeProperties(stream); + + CharSequence s = getFormat12Hour(); + stream.addProperty("format12Hour", s == null ? null : s.toString()); + + s = getFormat24Hour(); + stream.addProperty("format24Hour", s == null ? null : s.toString()); + stream.addProperty("format", mFormat == null ? null : mFormat.toString()); + stream.addProperty("hasSeconds", mHasSeconds); + } } diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 449173f..b9a08f5 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -120,6 +120,7 @@ import android.view.ViewDebug; import android.view.ViewGroup.LayoutParams; import android.view.ViewRootImpl; import android.view.ViewTreeObserver; +import android.view.ViewHierarchyEncoder; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityNodeInfo; @@ -2844,7 +2845,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener @ViewDebug.IntToString(from = Typeface.BOLD_ITALIC, to = "BOLD_ITALIC") }) public int getTypefaceStyle() { - return mTextPaint.getTypeface().getStyle(); + Typeface typeface = mTextPaint.getTypeface(); + return typeface != null ? typeface.getStyle() : Typeface.NORMAL; } /** @@ -9556,6 +9558,23 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } + /** @hide */ + @Override + protected void encodeProperties(@NonNull ViewHierarchyEncoder stream) { + super.encodeProperties(stream); + + TruncateAt ellipsize = getEllipsize(); + stream.addProperty("text:ellipsize", ellipsize == null ? null : ellipsize.name()); + stream.addProperty("text:textSize", getTextSize()); + stream.addProperty("text:scaledTextSize", getScaledTextSize()); + stream.addProperty("text:typefaceStyle", getTypefaceStyle()); + stream.addProperty("text:selectionStart", getSelectionStart()); + stream.addProperty("text:selectionEnd", getSelectionEnd()); + stream.addProperty("text:curTextColor", mCurTextColor); + stream.addProperty("text:text", mText == null ? null : mText.toString()); + stream.addProperty("text:gravity", mGravity); + } + /** * User interface state that is stored by TextView for implementing * {@link View#onSaveInstanceState}. |