From a9783bffcc926b62cf438f2e50636e433870c34d Mon Sep 17 00:00:00 2001 From: Alan Viverette Date: Wed, 17 Dec 2014 18:56:32 +0000 Subject: [PATCH] Revert "Allow theme attributes in tag, fix context" This reverts commit 866180198a3b4db619a6b08d8aae14852dfc5e7c. Change-Id: Ia77131bf78b53a4360c7fc36d295994119c296cc --- core/java/android/view/LayoutInflater.java | 32 ++++++++-------------- core/res/res/values/attrs.xml | 7 ----- 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/core/java/android/view/LayoutInflater.java b/core/java/android/view/LayoutInflater.java index f86d88e7eacf2..1546877aee77d 100644 --- a/core/java/android/view/LayoutInflater.java +++ b/core/java/android/view/LayoutInflater.java @@ -837,7 +837,7 @@ public abstract class LayoutInflater { throws XmlPullParserException, IOException { int type; - final TypedArray ta = view.getContext().obtainStyledAttributes( + final TypedArray ta = mContext.obtainStyledAttributes( attrs, com.android.internal.R.styleable.ViewTag); final int key = ta.getResourceId(com.android.internal.R.styleable.ViewTag_id, 0); final CharSequence value = ta.getText(com.android.internal.R.styleable.ViewTag_value); @@ -856,26 +856,7 @@ public abstract class LayoutInflater { int type; if (parent instanceof ViewGroup) { - Context context = inheritContext ? parent.getContext() : mContext; - - // Apply a theme wrapper, if requested. - final TypedArray ta = context.obtainStyledAttributes(attrs, ATTRS_THEME); - final int themeResId = ta.getResourceId(0, 0); - if (themeResId != 0) { - context = new ContextThemeWrapper(context, themeResId); - } - ta.recycle(); - - final TypedArray a = context.obtainStyledAttributes( - attrs, com.android.internal.R.styleable.Include); - final int layout = a.getResourceId( - com.android.internal.R.styleable.Include_layout, 0); - final int id = a.getResourceId( - com.android.internal.R.styleable.Include_id, View.NO_ID); - final int visibility = a.getInt( - com.android.internal.R.styleable.Include_visibility, -1); - a.recycle(); - + final int layout = attrs.getAttributeResourceValue(null, "layout", 0); if (layout == 0) { final String value = attrs.getAttributeValue(null, "layout"); if (value == null) { @@ -934,6 +915,15 @@ public abstract class LayoutInflater { // Inflate all children. rInflate(childParser, view, childAttrs, true, true); + // Attempt to override the included layout's android:id with the + // one set on the tag itself. + TypedArray a = mContext.obtainStyledAttributes(attrs, + com.android.internal.R.styleable.View, 0, 0); + int id = a.getResourceId(com.android.internal.R.styleable.View_id, View.NO_ID); + // While we're at it, let's try to override android:visibility. + int visibility = a.getInt(com.android.internal.R.styleable.View_visibility, -1); + a.recycle(); + if (id != View.NO_ID) { view.setId(id); } diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index b9b5f19ec9eaf..b5c71056ade35 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -2624,13 +2624,6 @@ - - - - - - -