diff options
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; } |