luca020400

blur.patch

May 8th, 2015
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.50 KB | None | 0 0
  1. From dd2f70ffbc2b5ec935968f9f9751a8de65e61ef3 Mon Sep 17 00:00:00 2001
  2. From: Jay Wang <[email protected]>
  3. Date: Fri, 19 Dec 2014 10:08:06 -0800
  4. Subject: [PATCH] Settings: Add settings for Blur Effect
  5.  
  6. Blue effect settings are added under display setting which allow
  7. user to enable or disable effect.
  8.  
  9. Change-Id: Ic6dd430a099bbb2480feb6037a5c34795b507291
  10. ---
  11. res/values/strings.xml | 6 ++
  12. res/xml/blur_effect_settings.xml | 46 +++++++++++
  13. res/xml/security_settings_lockscreen.xml | 6 ++
  14. src/com/android/settings/BlurEffectSettings.java | 98 ++++++++++++++++++++++++
  15. 4 files changed, 156 insertions(+)
  16. create mode 100644 res/xml/blur_effect_settings.xml
  17. create mode 100644 src/com/android/settings/BlurEffectSettings.java
  18.  
  19. diff --git a/res/values/strings.xml b/res/values/strings.xml
  20. index c202ecd..9db96fe 100644
  21. --- a/res/values/strings.xml
  22. +++ b/res/values/strings.xml
  23. @@ -6056,9 +6056,15 @@
  24.  
  25. <string name="switch_data_subscription">Data services are now switched to SIM%1$s.</string>
  26. <string name="select_sim_card">Select SIM card</string>
  27. +
  28. <!-- Title and summary for SIM Status -->
  29. <string name="imei_information_title">IMEI information</string>
  30. <string name="imei_information_summary">IMEI relative information</string>
  31. <string name="slot_number">(Slot<xliff:g id="slot_num">%1$d</xliff:g>)</string>
  32.  
  33. + <!-- blur effect -->
  34. + <string name="blur_effect_settings_title">Blur Effect</string>
  35. + <string name="blur_effect_lockscreen_title">Lockscreen</string>
  36. + <string name="blur_effect_globalaction_title">Global action dialog</string>
  37. + <string name="blur_effect_volumecontrol_title">Volume control inside</string>
  38. </resources>
  39. diff --git a/res/xml/blur_effect_settings.xml b/res/xml/blur_effect_settings.xml
  40. new file mode 100644
  41. index 0000000..f59daf0
  42. --- /dev/null
  43. +++ b/res/xml/blur_effect_settings.xml
  44. @@ -0,0 +1,46 @@
  45. +<?xml version="1.0" encoding="utf-8"?>
  46. +<!--Copyright (c) 2014, The Linux Foundation. All rights reserved.
  47. +
  48. +Redistribution and use in source and binary forms, with or without
  49. +modification, are permitted provided that the following conditions are
  50. +met:
  51. + * Redistributions of source code must retain the above copyright
  52. + notice, this list of conditions and the following disclaimer.
  53. + * Redistributions in binary form must reproduce the above
  54. + copyright notice, this list of conditions and the following
  55. + disclaimer in the documentation and/or other materials provided
  56. + with the distribution.
  57. + * Neither the name of The Linux Foundation nor the names of its
  58. + contributors may be used to endorse or promote products derived
  59. + from this software without specific prior written permission.
  60. +
  61. +THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
  62. +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  63. +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
  64. +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
  65. +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  66. +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  67. +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  68. +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  69. +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  70. +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  71. +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  72. +-->
  73. +
  74. +<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
  75. + android:title="@string/blur_effect_settings_title">
  76. +
  77. + <CheckBoxPreference
  78. + android:key="lockscreen"
  79. + android:title="@string/blur_effect_lockscreen_title"
  80. + android:persistent="false" />
  81. + <CheckBoxPreference
  82. + android:key="globalaction"
  83. + android:title="@string/blur_effect_globalaction_title"
  84. + android:persistent="false" />
  85. + <CheckBoxPreference
  86. + android:key="volumecontrol"
  87. + android:title="@string/blur_effect_volumecontrol_title"
  88. + android:persistent="false" />
  89. +
  90. +</PreferenceScreen>
  91. diff --git a/res/xml/security_settings_lockscreen.xml b/res/xml/security_settings_lockscreen.xml
  92. index 6a7715a..516bcc1 100644
  93. --- a/res/xml/security_settings_lockscreen.xml
  94. +++ b/res/xml/security_settings_lockscreen.xml
  95. @@ -52,6 +52,12 @@
  96. android:title="@string/lockscreen_visualizer_title"
  97. android:defaultValue="true"
  98. settings:advanced="true"/>
  99. +
  100. + <PreferenceScreen
  101. + android:key="blur_effect"
  102. + android:title="@string/blur_effect_settings_title"
  103. + android:fragment="com.android.settings.BlurEffectSettings" />
  104. +
  105. </PreferenceCategory>
  106.  
  107. </PreferenceScreen>
  108. diff --git a/src/com/android/settings/BlurEffectSettings.java b/src/com/android/settings/BlurEffectSettings.java
  109. new file mode 100644
  110. index 0000000..23bf3e1
  111. --- /dev/null
  112. +++ b/src/com/android/settings/BlurEffectSettings.java
  113. @@ -0,0 +1,98 @@
  114. +/*
  115. + * Copyright (c) 2014, The Linux Foundation. All rights reserved.
  116. + *
  117. + * Redistribution and use in source and binary forms, with or without
  118. + * modification, are permitted provided that the following conditions are
  119. + * met:
  120. + * * Redistributions of source code must retain the above copyright
  121. + * notice, this list of conditions and the following disclaimer.
  122. + * * Redistributions in binary form must reproduce the above
  123. + * copyright notice, this list of conditions and the following
  124. + * disclaimer in the documentation and/or other materials provided
  125. + * with the distribution.
  126. + * * Neither the name of The Linux Foundation nor the names of its
  127. + * contributors may be used to endorse or promote products derived
  128. + * from this software without specific prior written permission.
  129. + *
  130. + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
  131. + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  132. + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
  133. + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
  134. + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  135. + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  136. + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  137. + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  138. + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  139. + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  140. + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  141. + */
  142. +
  143. +package com.android.settings;
  144. +
  145. +import android.os.Bundle;
  146. +import android.content.ContentResolver;
  147. +import android.preference.CheckBoxPreference;
  148. +import android.preference.Preference;
  149. +import android.preference.PreferenceScreen;
  150. +import android.provider.Settings;
  151. +
  152. +import java.util.List;
  153. +
  154. +public class BlurEffectSettings extends SettingsPreferenceFragment {
  155. + private static final String TAG = "BlurEffectSettings";
  156. +
  157. + private static final String KEY_LOCKSCREEN = "lockscreen";
  158. + private static final String KEY_GLOBALACTION = "globalaction";
  159. + private static final String KEY_VOLUMECONTROL = "volumecontrol";
  160. +
  161. + private CheckBoxPreference mLockscreen;
  162. + private CheckBoxPreference mGlobalaction;
  163. + private CheckBoxPreference mVolumecontrol;
  164. +
  165. + @Override
  166. + public void onCreate(Bundle savedInstanceState) {
  167. + super.onCreate(savedInstanceState);
  168. +
  169. + addPreferencesFromResource(R.xml.blur_effect_settings);
  170. +
  171. + ContentResolver resolver = getContentResolver();
  172. +
  173. + mLockscreen = (CheckBoxPreference) findPreference(KEY_LOCKSCREEN);
  174. + if (mLockscreen != null) {
  175. + Settings.System.putInt(resolver,
  176. + Settings.System.BLUR_EFFECT_LOCKSCREEN, 0);
  177. + mLockscreen.setChecked(false);
  178. + }
  179. + mGlobalaction = (CheckBoxPreference) findPreference(KEY_GLOBALACTION);
  180. + if (mGlobalaction != null) {
  181. + Settings.System.putInt(resolver,
  182. + Settings.System.BLUR_EFFECT_GLOBALACTION, 0);
  183. + mGlobalaction.setChecked(false);
  184. + }
  185. + mVolumecontrol = (CheckBoxPreference) findPreference(KEY_VOLUMECONTROL);
  186. + if (mVolumecontrol != null) {
  187. + Settings.System.putInt(resolver,
  188. + Settings.System.BLUR_EFFECT_VOLUMECONTROL, 0);
  189. + mVolumecontrol.setChecked(false);
  190. + }
  191. + }
  192. +
  193. + @Override
  194. + public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
  195. + if (preference == mLockscreen) {
  196. + boolean value = mLockscreen.isChecked();
  197. + Settings.System.putInt(getContentResolver(), Settings.System.BLUR_EFFECT_LOCKSCREEN, value ? 1 : 0);
  198. + return true;
  199. + } else if (preference == mGlobalaction) {
  200. + boolean value = mGlobalaction.isChecked();
  201. + Settings.System.putInt(getContentResolver(), Settings.System.BLUR_EFFECT_GLOBALACTION, value ? 1 : 0);
  202. + return true;
  203. + } else if (preference == mVolumecontrol) {
  204. + boolean value = mVolumecontrol.isChecked();
  205. + Settings.System.putInt(getContentResolver(), Settings.System.BLUR_EFFECT_VOLUMECONTROL, value ? 1 : 0);
  206. + return true;
  207. + }
  208. + return super.onPreferenceTreeClick(preferenceScreen, preference);
  209. + }
  210. +
  211. +}
  212. --
  213. 2.4.0
Advertisement
Add Comment
Please, Sign In to add comment