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

Commit b5c9f8c9 authored by Jay Wang's avatar Jay Wang
Browse files

Settings: Add settings for Blur Effect

Blue effect settings are added under display setting which allow
user to enable or disable effect.

Change-Id: Ic6dd430a099bbb2480feb6037a5c34795b507291
parent fce0b71a
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -6264,4 +6264,10 @@
    <string name="menu_hidden_apps_reset_lock">Reset pattern lock</string>
    <string name="protected_apps">Protected apps</string>
    <string name="saving_protected_components">Saving component state</string>

    <!-- blur effect -->
    <string name="blur_effect_settings_title">Blur Effect</string>
    <string name="blur_effect_lockscreen_title">Lockscreen</string>
    <string name="blur_effect_globalaction_title">Global action dialog</string>
    <string name="blur_effect_volumecontrol_title">Volume control inside</string>
</resources>
+46 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--Copyright (c) 2014, The Linux Foundation. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above
      copyright notice, this list of conditions and the following
      disclaimer in the documentation and/or other materials provided
      with the distribution.
    * Neither the name of The Linux Foundation nor the names of its
      contributors may be used to endorse or promote products derived
      from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
        android:title="@string/blur_effect_settings_title">

    <CheckBoxPreference
        android:key="lockscreen"
        android:title="@string/blur_effect_lockscreen_title"
        android:persistent="false" />
    <CheckBoxPreference
        android:key="globalaction"
        android:title="@string/blur_effect_globalaction_title"
        android:persistent="false" />
    <CheckBoxPreference
        android:key="volumecontrol"
        android:title="@string/blur_effect_volumecontrol_title"
        android:persistent="false" />

</PreferenceScreen>
+5 −0
Original line number Diff line number Diff line
@@ -97,4 +97,9 @@
                settings:keywords="@string/keywords_display_cast_screen"
                android:fragment="com.android.settings.wfd.WifiDisplaySettings" />

        <PreferenceScreen
                android:key="blur_effect"
                android:title="@string/blur_effect_settings_title"
                android:fragment="com.android.settings.BlurEffectSettings" />

</PreferenceScreen>
+98 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2014, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 *       copyright notice, this list of conditions and the following
 *       disclaimer in the documentation and/or other materials provided
 *       with the distribution.
 *     * Neither the name of The Linux Foundation nor the names of its
 *       contributors may be used to endorse or promote products derived
 *       from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package com.android.settings;

import android.os.Bundle;
import android.content.ContentResolver;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceScreen;
import android.provider.Settings;

import java.util.List;

public class BlurEffectSettings extends SettingsPreferenceFragment {
    private static final String TAG = "BlurEffectSettings";

	private static final String KEY_LOCKSCREEN = "lockscreen";
	private static final String KEY_GLOBALACTION = "globalaction";
	private static final String KEY_VOLUMECONTROL = "volumecontrol";

	private CheckBoxPreference mLockscreen;
	private CheckBoxPreference mGlobalaction;
	private CheckBoxPreference mVolumecontrol;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        addPreferencesFromResource(R.xml.blur_effect_settings);

        ContentResolver resolver = getContentResolver();

        mLockscreen = (CheckBoxPreference) findPreference(KEY_LOCKSCREEN);
        if (mLockscreen != null) {
            Settings.System.putInt(resolver,
                    Settings.System.BLUR_EFFECT_LOCKSCREEN, 0);
            mLockscreen.setChecked(false);
        }
        mGlobalaction = (CheckBoxPreference) findPreference(KEY_GLOBALACTION);
        if (mGlobalaction != null) {
            Settings.System.putInt(resolver,
                    Settings.System.BLUR_EFFECT_GLOBALACTION, 0);
            mGlobalaction.setChecked(false);
        }
        mVolumecontrol = (CheckBoxPreference) findPreference(KEY_VOLUMECONTROL);
        if (mVolumecontrol != null) {
            Settings.System.putInt(resolver,
                    Settings.System.BLUR_EFFECT_VOLUMECONTROL, 0);
            mVolumecontrol.setChecked(false);
        }
    }

    @Override
    public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
        if (preference == mLockscreen) {
            boolean value = mLockscreen.isChecked();
            Settings.System.putInt(getContentResolver(), Settings.System.BLUR_EFFECT_LOCKSCREEN, value ? 1 : 0);
            return true;
        } else if (preference == mGlobalaction) {
            boolean value = mGlobalaction.isChecked();
            Settings.System.putInt(getContentResolver(), Settings.System.BLUR_EFFECT_GLOBALACTION, value ? 1 : 0);
            return true;
        } else if (preference == mVolumecontrol) {
            boolean value = mVolumecontrol.isChecked();
            Settings.System.putInt(getContentResolver(), Settings.System.BLUR_EFFECT_VOLUMECONTROL, value ? 1 : 0);
            return true;
        }
        return super.onPreferenceTreeClick(preferenceScreen, preference);
    }

}