gello: support disabling colored statubar

Change-Id: I9e7ab50c87d7a4fd86250f84224f7323b49724f7
Signed-off-by: jrizzoli <joey@cyanogenmoditalia.it>

Conflicts:
	res/values/strings.xml
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4228de5..90b8962 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -501,6 +501,8 @@
 -->
         <item>@string/pref_disable_edge_swipe</item>
     </string-array>
+    <string name="pref_coloredsb_title">Colored statusbar</string>
+    <string name="pref_coloredsb_summary">Statusbar will change color basing on the visited page</string>
     <!-- Title for accessibility settings [CHAR LIMIT=25] -->
     <string name="pref_accessibility_title">Accessibility</string>
     <string name="pref_accessibility_title_summary">Text size and zooming</string>
diff --git a/res/xml/general_preferences.xml b/res/xml/general_preferences.xml
index 6d7e5b4..74e24d3 100644
--- a/res/xml/general_preferences.xml
+++ b/res/xml/general_preferences.xml
@@ -74,6 +74,13 @@
         <SwitchPreference
             android:layout="@layout/swe_preference"
             android:defaultValue="false"
+            android:key="coloredsb_enabled"
+            android:summary="@string/pref_coloredsb_summary"
+            android:title="@string/pref_coloredsb_title" />
+
+        <SwitchPreference
+            android:layout="@layout/swe_preference"
+            android:defaultValue="false"
             android:key="nightmode_enabled"
             android:summary="@string/pref_nightmode_enabled_summary"
             android:title="@string/pref_nightmode_enabled" />
diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java
index fce0c10..bc1b83e 100644
--- a/src/com/android/browser/BrowserSettings.java
+++ b/src/com/android/browser/BrowserSettings.java
@@ -902,6 +902,14 @@
         mPrefs.edit().putBoolean(PREF_AUTOFILL_ENABLED, value).apply();
     }
 
+    public boolean isColoredSBEnabled() {
+        return mPrefs.getBoolean(PREF_COLOREDSB_ENABLED, false);
+    }
+
+    public void setColoredSBEnabled(boolean value) {
+        mPrefs.edit().putBoolean(PREF_COLOREDSB_ENABLED, value).apply();
+    }
+
     public boolean isPowerSaveModeEnabled() {
         return mPrefs.getBoolean(PREF_POWERSAVE_ENABLED, false);
     }
diff --git a/src/com/android/browser/NavigationBarBase.java b/src/com/android/browser/NavigationBarBase.java
index 690b007..dfdc3bf 100644
--- a/src/com/android/browser/NavigationBarBase.java
+++ b/src/com/android/browser/NavigationBarBase.java
@@ -203,6 +203,9 @@
         // The flag that allows coloring is disabled in PowerSaveMode, no point in trying to color.
         if (BrowserSettings.getInstance().isPowerSaveModeEnabled())
             return;
+        // Disable colored statusbar if user asked so
+        if (! BrowserSettings.getInstance().isColoredSBEnabled())
+            return;
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
             int currentColor = activity.getWindow().getStatusBarColor();
             Integer from = currentColor;
diff --git a/src/com/android/browser/PreferenceKeys.java b/src/com/android/browser/PreferenceKeys.java
index ce6c4cb..135ecb3 100644
--- a/src/com/android/browser/PreferenceKeys.java
+++ b/src/com/android/browser/PreferenceKeys.java
@@ -62,6 +62,7 @@
     static final String PREF_AUTOFILL_PROFILE = "autofill_profile";
     static final String PREF_HOMEPAGE = "homepage";
     static final String PREF_POWERSAVE_ENABLED = "powersave_enabled";
+    static final String PREF_COLOREDSB_ENABLED = "coloredsb_enabled";
     static final String PREF_NIGHTMODE_ENABLED = "nightmode_enabled";
     static final String PREF_SYNC_WITH_CHROME = "sync_with_chrome";