[1/2] Omnigears: QS panel opacity

Change-Id: Iad2942bfc17d1802a061f334bfa54796137ba0d9
diff --git a/res/xml/bars_settings.xml b/res/xml/bars_settings.xml
index 457164a..8b2a44e 100644
--- a/res/xml/bars_settings.xml
+++ b/res/xml/bars_settings.xml
@@ -21,6 +21,20 @@
             android:title="@string/custom_bars_settings_title" >
 
         <PreferenceCategory
+            android:key="quick_settings_category"
+            android:title="@string/quick_settings_category">
+
+            <org.omnirom.omnilib.preference.SeekBarPreference
+                android:key="qs_panel_alpha"
+                android:title="@string/qs_panel_alpha_title"
+                android:summary="@string/qs_panel_alpha_summary"
+                android:max="100"
+                settings:min="0"
+                settings:unitsRight="@string/unit_percent"
+                android:persistent="false" />
+        </PreferenceCategory>
+
+        <PreferenceCategory
             android:key="aspect_ratio_category"
             android:title="@string/aspect_ratio_category_title">
 
diff --git a/src/org/omnirom/omnigears/interfacesettings/BarsSettings.java b/src/org/omnirom/omnigears/interfacesettings/BarsSettings.java
index 2a61b1a..0fe8f7b 100644
--- a/src/org/omnirom/omnigears/interfacesettings/BarsSettings.java
+++ b/src/org/omnirom/omnigears/interfacesettings/BarsSettings.java
@@ -53,9 +53,11 @@
     private static final String KEY_ASPECT_RATIO_APPS_LIST = "aspect_ratio_apps_list";
     private static final String KEY_ASPECT_RATIO_CATEGORY = "aspect_ratio_category";
     private static final String KEY_ASPECT_RATIO_APPS_LIST_SCROLLER = "aspect_ratio_apps_list_scroller";
+    private static final String KEY_QS_PANEL_ALPHA = "qs_panel_alpha";
 
     private AppMultiSelectListPreference mAspectRatioAppsSelect;
     private ScrollAppsViewPreference mAspectRatioApps;
+    private SeekBarPreference mQsPanelAlpha;
 
     @Override
     public int getMetricsCategory() {
@@ -69,6 +71,12 @@
 
         PreferenceScreen prefScreen = getPreferenceScreen();
 
+        mQsPanelAlpha = (SeekBarPreference) findPreference(KEY_QS_PANEL_ALPHA);
+        int qsPanelAlpha = Settings.System.getInt(getContentResolver(),
+                Settings.System.OMNI_QS_PANEL_BG_ALPHA, 221);
+        mQsPanelAlpha.setValue((int)(((double) qsPanelAlpha / 255) * 100));
+        mQsPanelAlpha.setOnPreferenceChangeListener(this);
+
         final PreferenceCategory aspectRatioCategory =
                 (PreferenceCategory) getPreferenceScreen().findPreference(KEY_ASPECT_RATIO_CATEGORY);
         final boolean supportMaxAspectRatio = getResources().getBoolean(com.android.internal.R.bool.config_haveHigherAspectRatioScreen);
@@ -110,6 +118,12 @@
                 Settings.System.putString(getContentResolver(), Settings.System.OMNI_ASPECT_RATIO_APPS_LIST, "");
             }
             return true;
+        } else if (preference == mQsPanelAlpha) {
+            int bgAlpha = (Integer) newValue;
+            int trueValue = (int) (((double) bgAlpha / 100) * 255);
+            Settings.System.putInt(getContentResolver(),
+                    Settings.System.OMNI_QS_PANEL_BG_ALPHA, trueValue);
+            return true;
         }
         return false;
     }