Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From dd2f70ffbc2b5ec935968f9f9751a8de65e61ef3 Mon Sep 17 00:00:00 2001
- From: Jay Wang <[email protected]>
- Date: Fri, 19 Dec 2014 10:08:06 -0800
- Subject: [PATCH] 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
- ---
- res/values/strings.xml | 6 ++
- res/xml/blur_effect_settings.xml | 46 +++++++++++
- res/xml/security_settings_lockscreen.xml | 6 ++
- src/com/android/settings/BlurEffectSettings.java | 98 ++++++++++++++++++++++++
- 4 files changed, 156 insertions(+)
- create mode 100644 res/xml/blur_effect_settings.xml
- create mode 100644 src/com/android/settings/BlurEffectSettings.java
- diff --git a/res/values/strings.xml b/res/values/strings.xml
- index c202ecd..9db96fe 100644
- --- a/res/values/strings.xml
- +++ b/res/values/strings.xml
- @@ -6056,9 +6056,15 @@
- <string name="switch_data_subscription">Data services are now switched to SIM%1$s.</string>
- <string name="select_sim_card">Select SIM card</string>
- +
- <!-- Title and summary for SIM Status -->
- <string name="imei_information_title">IMEI information</string>
- <string name="imei_information_summary">IMEI relative information</string>
- <string name="slot_number">(Slot<xliff:g id="slot_num">%1$d</xliff:g>)</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>
- diff --git a/res/xml/blur_effect_settings.xml b/res/xml/blur_effect_settings.xml
- new file mode 100644
- index 0000000..f59daf0
- --- /dev/null
- +++ b/res/xml/blur_effect_settings.xml
- @@ -0,0 +1,46 @@
- +<?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>
- diff --git a/res/xml/security_settings_lockscreen.xml b/res/xml/security_settings_lockscreen.xml
- index 6a7715a..516bcc1 100644
- --- a/res/xml/security_settings_lockscreen.xml
- +++ b/res/xml/security_settings_lockscreen.xml
- @@ -52,6 +52,12 @@
- android:title="@string/lockscreen_visualizer_title"
- android:defaultValue="true"
- settings:advanced="true"/>
- +
- + <PreferenceScreen
- + android:key="blur_effect"
- + android:title="@string/blur_effect_settings_title"
- + android:fragment="com.android.settings.BlurEffectSettings" />
- +
- </PreferenceCategory>
- </PreferenceScreen>
- diff --git a/src/com/android/settings/BlurEffectSettings.java b/src/com/android/settings/BlurEffectSettings.java
- new file mode 100644
- index 0000000..23bf3e1
- --- /dev/null
- +++ b/src/com/android/settings/BlurEffectSettings.java
- @@ -0,0 +1,98 @@
- +/*
- + * 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);
- + }
- +
- +}
- --
- 2.4.0
Advertisement
Add Comment
Please, Sign In to add comment