[2/2] OmniGears: easy switch to soft keys

make it easier to switch to soft keys for devices
with hw keys. this is already possible now but the
settings are spread in different categories and require
multiple steps and using the property qemu.hw.mainkeys

this adds two new settings
1) allow enabling navigation bar during runtime on devices
that dont have it already enabled in the config.
This replaces the usage of the property qemu.hq.mainkeys

2) allow disabling hw keys (actions, brightness, haptic feedback)
with a single setting. This requires that the device supports
config_button_brightness_support config_has_hardware_buttons
and config_deviceHardwareKeys

as part of this the button brightness settings screen
has been moved to a separate screen

TODO: disable google search on long press menu

Change-Id: I06eedf26abd2885b711321193e9a486c08a5e192
diff --git a/res/values/custom_strings.xml b/res/values/custom_strings.xml
index dabc9d1..7beda56 100644
--- a/res/values/custom_strings.xml
+++ b/res/values/custom_strings.xml
@@ -149,6 +149,8 @@
     <string name="sensor_category">Sensor</string>
     <string name="button_timeout_title">Timeout</string>
     <string name="button_timeout_summary">Disabled on value 0</string>
+    <string name="button_brightness_title">Button brightness</string>
+    <string name="button_brightness_summary">Button brightness settings</string>
 
     <!-- button settings -->
     <string name="button_volume_keys_title">Volume</string>
@@ -218,6 +220,10 @@
     <string name="no_home_key">You have no button assigned to the \"Home\" action! This can make your device unusable!</string>
     <string name="virtual_key_haptic_feedback_title">Vibrate on touch</string>
     <string name="virtual_key_haptic_feedback_summary">Enable depends on \"Vibrate on touch\" in sound settings</string>
+    <string name="navigation_bar_show_title">Show navigation bar</string>
+    <string name="navigation_bar_show_summary">Force enable navigation bar</string>
+    <string name="hardware_keys_disable_title">Disable keys</string>
+    <string name="hardware_keys_disable_summary">Force disable keys</string>
 
     <!-- Power Menu Options-->
     <string name="bars_and_menus_category_power_menu_title">Power menu</string>
@@ -342,6 +348,7 @@
 
     <!-- Navigation Bar customization-->
     <string name="navigation_bar_title">Buttons and layout</string>
+    <string name="navigation_bar_summary">Configure navigation bar buttons</string>
     <string name="navigation_bar_help_text">1 - To begin editing, tap the lock icon\n\n2 - Tap any button to assign or change functionality\n\n3 - Long press any button to rearrange the order\n\n4 - To save, tap the lock icon again\n\n5 - To restore system default, tap the reset button\n\n</string>
     <string name="navigation_bar_tips">\u2022 Actions can only be assigned to one button at a time\n\n\u2022 The home button cannot be re-assigned\n\n\u2022 Side buttons cannot be rearranged</string>
     <string name="navigation_bar_tips_title">Quick tips</string>
@@ -353,6 +360,7 @@
 
     <!-- Navigation ring shortcuts -->
     <string name="navigation_ring_title">Quick launch shortcuts</string>
+    <string name="navigation_ring_summary">Configure custom navigation bar shortcuts</string>
     <string name="navring_target_reset_message">Delete all user created navigation bar shortcuts and restore to default?</string>
     <string name="navring_target_reset">Navigation bar shortcuts reset to default</string>
     <string name="navring_action_open_ime_switcher">Open IME Switcher</string>
@@ -526,6 +534,7 @@
 
     <!-- Navigation bar height/width -->
     <string name="navbar_dimen_title">Dimensions</string>
+    <string name="navbar_dimen_summary">Configure width and height of navigation bar</string>
     <string name="navbar_dimensions_reset_message">Reset all dimensions entries to default?</string>
     <string name="navigation_bar_height_title">Navigation bar height</string>
     <string name="navigation_bar_height_summary">Navigation bar height while in portrait.</string>
diff --git a/res/xml/bars_settings.xml b/res/xml/bars_settings.xml
index 7c873e2..2dba831 100644
--- a/res/xml/bars_settings.xml
+++ b/res/xml/bars_settings.xml
@@ -114,16 +114,19 @@
         <PreferenceScreen
             android:key="navigation_bar"
             android:fragment="org.omnirom.omnigears.interfacesettings.NavBar"
+            android:summary="@string/navigation_bar_summary"
             android:title="@string/navigation_bar_title" />
 
         <PreferenceScreen
             android:key="navigation_bar_dimen"
             android:fragment="org.omnirom.omnigears.interfacesettings.NavBarDimen"
+            android:summary="@string/navbar_dimen_summary"
             android:title="@string/navbar_dimen_title" />
 
         <PreferenceScreen
             android:key="navigation_ring"
             android:fragment="org.omnirom.omnigears.interfacesettings.NavRing"
+            android:summary="@string/navigation_ring_summary"
             android:title="@string/navigation_ring_title" />
 
         <CheckBoxPreference
diff --git a/res/xml/brightness_settings.xml b/res/xml/brightness_settings.xml
index 6c8d0a7..d0124db 100644
--- a/res/xml/brightness_settings.xml
+++ b/res/xml/brightness_settings.xml
@@ -17,7 +17,6 @@
 
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
         android:title="@string/brightness"
-        android:key="backlight_settings"
         xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
 
         <PreferenceCategory
@@ -28,7 +27,7 @@
                         android:title="@string/brightness"
                         android:persistent="false"/>
 
-                <Preference
+                <PreferenceScreen
                         android:key="screen_auto_brightness"
                         android:title="@string/screen_auto_brightness"
                         android:summary="@string/screen_auto_brighness_summary"/>
@@ -38,33 +37,12 @@
                 android:key="button_brightness_category"
                 android:title="@string/button_brightness_category">
 
-                <Preference
-                        android:key="button_auto_brightness"
-                        android:title="@string/button_auto_brightness"
-                        android:summary="@string/button_auto_brighness_summary"/>
-                <Preference
-                        android:key="button_manual_brightness"
-                        android:title="@string/button_manual_brightness"
-                        android:summary="@string/button_manual_brightness_summary"/>
-                <CheckBoxPreference
-                        android:key="button_no_brightness"
-                        android:title="@string/button_no_brightness"
-                        android:summary="@string/button_no_brightness_summary"
-                        android:persistent="false"/>
-                <CheckBoxPreference
-                        android:key="button_link_brightness"
-                        android:title="@string/button_link_brightness"
-                        android:summary="@string/button_link_brightness_summary"
-                        android:persistent="false"/>
-                <org.omnirom.omnigears.chameleonos.SeekBarPreference
-                        android:key="button_timeout"
-                        android:title="@string/button_timeout_title"
-                        android:summary="@string/button_timeout_summary"
-                        android:max="30"
-                        settings:min="0"
-                        settings:unitsLeft=""
-                        settings:unitsRight="@string/unit_sec"
-                        android:persistent="false" />
+                <PreferenceScreen
+                        android:key="button_brightness"
+                        android:title="@string/brightness"
+                        android:summary="@string/button_brightness_summary"
+                        android:fragment="org.omnirom.omnigears.brightness.ButtonBrightnessSettings" />
+
         </PreferenceCategory>
 
         <PreferenceCategory
diff --git a/res/xml/button_brightness_settings.xml b/res/xml/button_brightness_settings.xml
new file mode 100644
index 0000000..60d0095
--- /dev/null
+++ b/res/xml/button_brightness_settings.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--  Copyright (C) 2014 The OmniROM Project
+
+  This program is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 2 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ -->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+        android:title="@string/button_brightness_title"
+        xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
+
+        <Preference
+                android:key="button_auto_brightness"
+                android:title="@string/button_auto_brightness"
+                android:summary="@string/button_auto_brighness_summary"/>
+        <Preference
+                android:key="button_manual_brightness"
+                android:title="@string/button_manual_brightness"
+                android:summary="@string/button_manual_brightness_summary"/>
+        <CheckBoxPreference
+                android:key="button_no_brightness"
+                android:title="@string/button_no_brightness"
+                android:summary="@string/button_no_brightness_summary"
+                android:persistent="false"/>
+        <CheckBoxPreference
+                android:key="button_link_brightness"
+                android:title="@string/button_link_brightness"
+                android:summary="@string/button_link_brightness_summary"
+                android:persistent="false"/>
+        <org.omnirom.omnigears.chameleonos.SeekBarPreference
+                android:key="button_timeout"
+                android:title="@string/button_timeout_title"
+                android:summary="@string/button_timeout_summary"
+                android:max="30"
+                settings:min="0"
+                settings:unitsLeft=""
+                settings:unitsRight="@string/unit_sec"
+                android:persistent="false" />
+</PreferenceScreen>
diff --git a/res/xml/button_settings.xml b/res/xml/button_settings.xml
index 8e3b781..c3396e2 100644
--- a/res/xml/button_settings.xml
+++ b/res/xml/button_settings.xml
@@ -69,6 +69,17 @@
         android:key="button_keys"
         android:title="@string/button_keys_title" >
 
+        <org.omnirom.omnigears.preference.SystemCheckBoxPreference
+            android:key="navigation_bar_show"
+            android:title="@string/navigation_bar_show_title"
+            android:summary="@string/navigation_bar_show_summary" />
+
+        <CheckBoxPreference
+            android:key="hardware_keys_disable"
+            android:title="@string/hardware_keys_disable_title"
+            android:summary="@string/hardware_keys_disable_summary"
+            android:persistent="false"/>
+
         <CheckBoxPreference
             android:key="virtual_key_haptic_feedback"
             android:title="@string/virtual_key_haptic_feedback_title"
@@ -81,6 +92,12 @@
             android:summary="@string/force_show_overflow_menu_summary"
             android:persistent="false"/>
 
+        <PreferenceScreen
+            android:key="button_brightness"
+            android:title="@string/brightness"
+            android:summary="@string/button_brightness_summary"
+            android:fragment="org.omnirom.omnigears.brightness.ButtonBrightnessSettings" />
+
         <SwitchPreference
             android:key="keys_enable_custom"
             android:title="@string/keys_enable_custom_title"