diff options
author | Danesh M <daneshm90@gmail.com> | 2015-12-09 16:07:22 -0800 |
---|---|---|
committer | Danesh M <daneshm90@gmail.com> | 2015-12-09 17:22:08 -0800 |
commit | a119231e952d011eac2e1609d3cafd577dbcc30e (patch) | |
tree | b1cafcad220f1c84a6876b553141bafda4daf229 /packages/SystemUI | |
parent | db9cc40c962f63e5622c2bd1aa0f08b2592134bd (diff) | |
download | frameworks_base-a119231e952d011eac2e1609d3cafd577dbcc30e.zip frameworks_base-a119231e952d011eac2e1609d3cafd577dbcc30e.tar.gz frameworks_base-a119231e952d011eac2e1609d3cafd577dbcc30e.tar.bz2 |
QSBooleanSettingsRow : Add default value attribute
Without this, settings might throw NotFoundException
and set incorrect defaults
Change-Id: Ia7e193d7c8f935cd5e371e3377af7b64ddcb37cc
Diffstat (limited to 'packages/SystemUI')
-rw-r--r-- | packages/SystemUI/res/layout/qs_settings.xml | 2 | ||||
-rw-r--r-- | packages/SystemUI/res/values/cm_attrs.xml | 1 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/QSBooleanSettingRow.java | 46 |
3 files changed, 24 insertions, 25 deletions
diff --git a/packages/SystemUI/res/layout/qs_settings.xml b/packages/SystemUI/res/layout/qs_settings.xml index af2cc0c..8f965ea 100644 --- a/packages/SystemUI/res/layout/qs_settings.xml +++ b/packages/SystemUI/res/layout/qs_settings.xml @@ -36,6 +36,7 @@ style="@style/SettingRow" android:key="status_bar_show_weather" android:title="@string/quick_settings_title_show_weather" + systemui:defaultValue="1" systemui:table="cm_system" /> @@ -53,6 +54,7 @@ style="@style/SettingRow" android:title="@string/quick_settings_title_enlarge_first_row" android:key="sysui_qs_main_tiles" + systemui:defaultValue="1" systemui:table="cm_secure" /> <LinearLayout diff --git a/packages/SystemUI/res/values/cm_attrs.xml b/packages/SystemUI/res/values/cm_attrs.xml index 8e88e67..0e4933a 100644 --- a/packages/SystemUI/res/values/cm_attrs.xml +++ b/packages/SystemUI/res/values/cm_attrs.xml @@ -28,6 +28,7 @@ <attr name="android:key"/> <attr name="android:title" /> + <attr name="defaultValue" format="integer"/> </declare-styleable> </resources> diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSBooleanSettingRow.java b/packages/SystemUI/src/com/android/systemui/qs/QSBooleanSettingRow.java index ca0783e..d2d13ae 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSBooleanSettingRow.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSBooleanSettingRow.java @@ -48,6 +48,7 @@ public class QSBooleanSettingRow extends LinearLayout implements View.OnClickLis String mKey; private TextView mText; private Switch mSwitch; + private int mDefaultValue; public QSBooleanSettingRow(Context context) { this(context, null); @@ -79,6 +80,7 @@ public class QSBooleanSettingRow extends LinearLayout implements View.OnClickLis mTitle = a.getString(R.styleable.QuickSettingsRow_android_title); mKey = a.getString(R.styleable.QuickSettingsRow_android_key); + mDefaultValue = a.getInt(R.styleable.QuickSettingsRow_defaultValue, 0); if (mText != null) { mText.setText(mTitle); @@ -131,31 +133,25 @@ public class QSBooleanSettingRow extends LinearLayout implements View.OnClickLis private boolean getCurrent() { ContentResolver cr = getContext().getContentResolver(); int ret = 0; - try { - switch (mWhichTable) { - case TABLE_GLOBAL: - ret = Settings.Global.getInt(cr, mKey); - break; - case TABLE_SECURE: - ret = Settings.Secure.getInt(cr, mKey); - break; - case TABLE_SYSTEM: - ret = Settings.System.getInt(cr, mKey); - break; - case TABLE_CM_GLOBAL: - ret = CMSettings.Global.getInt(cr, mKey); - break; - case TABLE_CM_SECURE: - ret = CMSettings.Secure.getInt(cr, mKey); - break; - case TABLE_CM_SYSTEM: - ret = CMSettings.System.getInt(cr, mKey); - break; - } - } catch (Settings.SettingNotFoundException|CMSettings.CMSettingNotFoundException e) { - Log.e(TAG, "need to add a default setting for key: " + mKey - + " in table: " + mWhichTable); - e.printStackTrace(); + switch (mWhichTable) { + case TABLE_GLOBAL: + ret = Settings.Global.getInt(cr, mKey, mDefaultValue); + break; + case TABLE_SECURE: + ret = Settings.Secure.getInt(cr, mKey, mDefaultValue); + break; + case TABLE_SYSTEM: + ret = Settings.System.getInt(cr, mKey, mDefaultValue); + break; + case TABLE_CM_GLOBAL: + ret = CMSettings.Global.getInt(cr, mKey, mDefaultValue); + break; + case TABLE_CM_SECURE: + ret = CMSettings.Secure.getInt(cr, mKey, mDefaultValue); + break; + case TABLE_CM_SYSTEM: + ret = CMSettings.System.getInt(cr, mKey, mDefaultValue); + break; } return ret == 1; } |