Loading core/java/android/preference/Preference.java +1 −1 Original line number Diff line number Diff line Loading @@ -215,7 +215,7 @@ public class Preference implements Comparable<Preference> { final TypedArray a = context.obtainStyledAttributes( attrs, com.android.internal.R.styleable.Preference, defStyleAttr, defStyleRes); for (int i = a.getIndexCount(); i >= 0; i--) { for (int i = a.getIndexCount() - 1; i >= 0; i--) { int attr = a.getIndex(i); switch (attr) { case com.android.internal.R.styleable.Preference_icon: Loading core/java/android/preference/PreferenceManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -156,7 +156,7 @@ public class PreferenceManager { * should be used ANY time a preference will be displayed, since some preference * types need an Activity for managed queries. */ private PreferenceManager(Context context) { /*package*/ PreferenceManager(Context context) { init(context); } Loading tools/layoutlib/bridge/src/android/preference/BridgePreferenceInflater.java 0 → 100644 +51 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 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.preference; import com.android.layoutlib.bridge.android.BridgeXmlBlockParser; import android.content.Context; import android.util.AttributeSet; import java.util.Map; public class BridgePreferenceInflater extends PreferenceInflater { private final Map<Preference, Object> mViewCookieMap; public BridgePreferenceInflater(Context context, PreferenceManager preferenceManager, Map<Preference, Object> viewCookieMap) { super(context, preferenceManager); mViewCookieMap = viewCookieMap; } @Override protected Preference onCreateItem(String name, AttributeSet attrs) throws ClassNotFoundException { Object viewKey; if (attrs instanceof BridgeXmlBlockParser) { viewKey = ((BridgeXmlBlockParser) attrs).getViewCookie(); } else { viewKey = null; } Preference preference = super.onCreateItem(name, attrs); if (viewKey != null) { mViewCookieMap.put(preference, viewKey); } return preference; } } tools/layoutlib/bridge/src/android/preference/Preference_Delegate.java 0 → 100644 +94 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 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.preference; import com.android.internal.R; import com.android.layoutlib.bridge.android.BridgeContext; import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import org.xmlpull.v1.XmlPullParser; import android.content.Context; import android.content.res.TypedArray; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; import java.util.HashMap; import java.util.Map; /** * Delegate that provides implementation for native methods in {@link Preference} * <p/> * Through the layoutlib_create tool, selected methods of Preference have been replaced by calls to * methods of the same name in this delegate class. */ public class Preference_Delegate { private static final Map<Preference, Object> sViewCookies = new HashMap<Preference, Object>(); @LayoutlibDelegate /*package*/ static void dispatchSetInitialValue(Preference preference) { // pass. } @LayoutlibDelegate /*package*/ static View getView(Preference pref, View convertView, ViewGroup parent) { Context context = pref.getContext(); BridgeContext bc = context instanceof BridgeContext ? ((BridgeContext) context) : null; convertView = pref.getView_Original(convertView, parent); Object cookie = sViewCookies.get(pref); if (bc != null && cookie != null) { bc.addViewKey(convertView, cookie); } return convertView; } /** * Inflates the parser and returns the ListView containing the Preferences. The caller must call * {@link #clearCookiesMap()} when the rendering is complete. */ public static View inflatePreference(Context context, XmlPullParser parser, ViewGroup root) { assert sViewCookies.isEmpty(); PreferenceManager pm = new PreferenceManager(context); PreferenceScreen ps = pm.getPreferenceScreen(); PreferenceInflater inflater = new BridgePreferenceInflater(context, pm, sViewCookies); ps = (PreferenceScreen) inflater.inflate(parser, ps, true); ListView preferenceView = createContainerView(context, root); ps.bind(preferenceView); return preferenceView; } private static ListView createContainerView(Context context, ViewGroup root) { TypedArray a = context.obtainStyledAttributes(null, R.styleable.PreferenceFragment, R.attr.preferenceFragmentStyle, 0); int mLayoutResId = a.getResourceId(R.styleable.PreferenceFragment_layout, R.layout.preference_list_fragment); a.recycle(); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(mLayoutResId, root, true); return (ListView) root.findViewById(android.R.id.list); } public static void clearCookiesMap() { sViewCookies.clear(); } } tools/layoutlib/bridge/src/android/text/StaticLayout_Delegate.java +2 −2 Original line number Diff line number Diff line Loading @@ -13,8 +13,8 @@ import javax.swing.text.Segment; /** * Delegate that provides implementation for native methods in {@link android.text.StaticLayout} * * Through the layoutlib_create tool, selected methods of Handler have been replaced * <p/> * Through the layoutlib_create tool, selected methods of StaticLayout have been replaced * by calls to methods of the same name in this delegate class. * */ Loading Loading
core/java/android/preference/Preference.java +1 −1 Original line number Diff line number Diff line Loading @@ -215,7 +215,7 @@ public class Preference implements Comparable<Preference> { final TypedArray a = context.obtainStyledAttributes( attrs, com.android.internal.R.styleable.Preference, defStyleAttr, defStyleRes); for (int i = a.getIndexCount(); i >= 0; i--) { for (int i = a.getIndexCount() - 1; i >= 0; i--) { int attr = a.getIndex(i); switch (attr) { case com.android.internal.R.styleable.Preference_icon: Loading
core/java/android/preference/PreferenceManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -156,7 +156,7 @@ public class PreferenceManager { * should be used ANY time a preference will be displayed, since some preference * types need an Activity for managed queries. */ private PreferenceManager(Context context) { /*package*/ PreferenceManager(Context context) { init(context); } Loading
tools/layoutlib/bridge/src/android/preference/BridgePreferenceInflater.java 0 → 100644 +51 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 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.preference; import com.android.layoutlib.bridge.android.BridgeXmlBlockParser; import android.content.Context; import android.util.AttributeSet; import java.util.Map; public class BridgePreferenceInflater extends PreferenceInflater { private final Map<Preference, Object> mViewCookieMap; public BridgePreferenceInflater(Context context, PreferenceManager preferenceManager, Map<Preference, Object> viewCookieMap) { super(context, preferenceManager); mViewCookieMap = viewCookieMap; } @Override protected Preference onCreateItem(String name, AttributeSet attrs) throws ClassNotFoundException { Object viewKey; if (attrs instanceof BridgeXmlBlockParser) { viewKey = ((BridgeXmlBlockParser) attrs).getViewCookie(); } else { viewKey = null; } Preference preference = super.onCreateItem(name, attrs); if (viewKey != null) { mViewCookieMap.put(preference, viewKey); } return preference; } }
tools/layoutlib/bridge/src/android/preference/Preference_Delegate.java 0 → 100644 +94 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 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.preference; import com.android.internal.R; import com.android.layoutlib.bridge.android.BridgeContext; import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import org.xmlpull.v1.XmlPullParser; import android.content.Context; import android.content.res.TypedArray; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; import java.util.HashMap; import java.util.Map; /** * Delegate that provides implementation for native methods in {@link Preference} * <p/> * Through the layoutlib_create tool, selected methods of Preference have been replaced by calls to * methods of the same name in this delegate class. */ public class Preference_Delegate { private static final Map<Preference, Object> sViewCookies = new HashMap<Preference, Object>(); @LayoutlibDelegate /*package*/ static void dispatchSetInitialValue(Preference preference) { // pass. } @LayoutlibDelegate /*package*/ static View getView(Preference pref, View convertView, ViewGroup parent) { Context context = pref.getContext(); BridgeContext bc = context instanceof BridgeContext ? ((BridgeContext) context) : null; convertView = pref.getView_Original(convertView, parent); Object cookie = sViewCookies.get(pref); if (bc != null && cookie != null) { bc.addViewKey(convertView, cookie); } return convertView; } /** * Inflates the parser and returns the ListView containing the Preferences. The caller must call * {@link #clearCookiesMap()} when the rendering is complete. */ public static View inflatePreference(Context context, XmlPullParser parser, ViewGroup root) { assert sViewCookies.isEmpty(); PreferenceManager pm = new PreferenceManager(context); PreferenceScreen ps = pm.getPreferenceScreen(); PreferenceInflater inflater = new BridgePreferenceInflater(context, pm, sViewCookies); ps = (PreferenceScreen) inflater.inflate(parser, ps, true); ListView preferenceView = createContainerView(context, root); ps.bind(preferenceView); return preferenceView; } private static ListView createContainerView(Context context, ViewGroup root) { TypedArray a = context.obtainStyledAttributes(null, R.styleable.PreferenceFragment, R.attr.preferenceFragmentStyle, 0); int mLayoutResId = a.getResourceId(R.styleable.PreferenceFragment_layout, R.layout.preference_list_fragment); a.recycle(); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(mLayoutResId, root, true); return (ListView) root.findViewById(android.R.id.list); } public static void clearCookiesMap() { sViewCookies.clear(); } }
tools/layoutlib/bridge/src/android/text/StaticLayout_Delegate.java +2 −2 Original line number Diff line number Diff line Loading @@ -13,8 +13,8 @@ import javax.swing.text.Segment; /** * Delegate that provides implementation for native methods in {@link android.text.StaticLayout} * * Through the layoutlib_create tool, selected methods of Handler have been replaced * <p/> * Through the layoutlib_create tool, selected methods of StaticLayout have been replaced * by calls to methods of the same name in this delegate class. * */ Loading