Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f861c0ce authored by Deepanshu Gupta's avatar Deepanshu Gupta Committed by Android (Google) Code Review
Browse files

Merge "Fix default initial value for preferences" into lmp-dev

parents 7081a114 dfeffd4c
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -42,11 +42,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();
+6 −3
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ 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.
@@ -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
+138 −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 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) {
    }
}
+0 −1
Original line number Diff line number Diff line
@@ -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",