diff options
author | Deepanshu Gupta <deepanshu@google.com> | 2015-01-05 23:32:58 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-01-05 23:32:58 +0000 |
commit | cec8e5a10de413c733223b8b1cc11b70c6254647 (patch) | |
tree | 8e2022a60384c3ce6d902d5d5c4c13adbcf70821 /tools | |
parent | 7ed145493d3f5bea32c567980f77cc42f613197e (diff) | |
parent | f861c0ce3ff42550f3d5ede837e7bfb3855f5964 (diff) | |
download | frameworks_base-cec8e5a10de413c733223b8b1cc11b70c6254647.zip frameworks_base-cec8e5a10de413c733223b8b1cc11b70c6254647.tar.gz frameworks_base-cec8e5a10de413c733223b8b1cc11b70c6254647.tar.bz2 |
am f861c0ce: Merge "Fix default initial value for preferences" into lmp-dev
* commit 'f861c0ce3ff42550f3d5ede837e7bfb3855f5964':
Fix default initial value for preferences
Diffstat (limited to 'tools')
4 files changed, 144 insertions, 9 deletions
diff --git a/tools/layoutlib/bridge/src/android/preference/Preference_Delegate.java b/tools/layoutlib/bridge/src/android/preference/Preference_Delegate.java index 230fe8c..37a0adc 100644 --- a/tools/layoutlib/bridge/src/android/preference/Preference_Delegate.java +++ b/tools/layoutlib/bridge/src/android/preference/Preference_Delegate.java @@ -43,11 +43,6 @@ 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; diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java index fe34c46..edc3c38 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java @@ -120,8 +120,9 @@ public final class BridgeContext extends Context { private BridgeContentResolver mContentResolver; private final Stack<BridgeXmlBlockParser> mParserStack = new Stack<BridgeXmlBlockParser>(); + private SharedPreferences mSharedPreferences; - /** + /** * @param projectKey An Object identifying the project. This is used for the cache mechanism. * @param metrics the {@link DisplayMetrics}. * @param renderResources the configured resources (both framework and projects) for this @@ -1163,8 +1164,10 @@ public final class BridgeContext extends Context { @Override public SharedPreferences getSharedPreferences(String arg0, int arg1) { - // pass - return null; + if (mSharedPreferences == null) { + mSharedPreferences = new BridgeSharedPreferences(); + } + return mSharedPreferences; } @Override diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeSharedPreferences.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeSharedPreferences.java new file mode 100644 index 0000000..132ff2f --- /dev/null +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeSharedPreferences.java @@ -0,0 +1,138 @@ +/* + * 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 com.android.layoutlib.bridge.android; + +import android.content.SharedPreferences; + +import java.util.Map; +import java.util.Set; + +/** + * An empty shared preferences implementation which doesn't store anything. It always returns + * null, 0 or false. + */ +public class BridgeSharedPreferences implements SharedPreferences { + private Editor mEditor; + + @Override + public Map<String, ?> getAll() { + return null; + } + + @Override + public String getString(String key, String defValue) { + return null; + } + + @Override + public Set<String> getStringSet(String key, Set<String> defValues) { + return null; + } + + @Override + public int getInt(String key, int defValue) { + return 0; + } + + @Override + public long getLong(String key, long defValue) { + return 0; + } + + @Override + public float getFloat(String key, float defValue) { + return 0; + } + + @Override + public boolean getBoolean(String key, boolean defValue) { + return false; + } + + @Override + public boolean contains(String key) { + return false; + } + + @Override + public Editor edit() { + if (mEditor != null) { + return mEditor; + } + mEditor = new Editor() { + @Override + public Editor putString(String key, String value) { + return null; + } + + @Override + public Editor putStringSet(String key, Set<String> values) { + return null; + } + + @Override + public Editor putInt(String key, int value) { + return null; + } + + @Override + public Editor putLong(String key, long value) { + return null; + } + + @Override + public Editor putFloat(String key, float value) { + return null; + } + + @Override + public Editor putBoolean(String key, boolean value) { + return null; + } + + @Override + public Editor remove(String key) { + return null; + } + + @Override + public Editor clear() { + return null; + } + + @Override + public boolean commit() { + return false; + } + + @Override + public void apply() { + } + }; + return mEditor; + } + + @Override + public void registerOnSharedPreferenceChangeListener( + OnSharedPreferenceChangeListener listener) { + } + + @Override + public void unregisterOnSharedPreferenceChangeListener( + OnSharedPreferenceChangeListener listener) { + } +} diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java index 2f04b11..7c6f112 100644 --- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java +++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java @@ -152,7 +152,6 @@ public final class CreateInfo implements ICreateInfo { "android.graphics.Typeface#getSystemFontConfigLocation", "android.os.Handler#sendMessageAtTime", "android.os.HandlerThread#run", - "android.preference.Preference#dispatchSetInitialValue", "android.preference.Preference#getView", "android.text.format.DateFormat#is24HourFormat", "android.util.Xml#newPullParser", |