[1/2] OmniGears : less intrusive UI

Change-Id: I0ee14998f26a4225708c1a11d8dac0e7c7a11901
diff --git a/res/drawable/bg_app_chooser.xml b/res/drawable/bg_app_chooser.xml
new file mode 100644
index 0000000..a79d829
--- /dev/null
+++ b/res/drawable/bg_app_chooser.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--  Copyright (C) 2016 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/>.
+ -->
+
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <item>
+        <shape android:shape="rectangle" >
+            <solid android:color="?android:attr/colorBackgroundFloating" />
+            <corners android:radius="10dp" />
+        </shape>
+    </item>
+    <item>
+        <shape android:shape="rectangle" >
+            <stroke android:width="1dp" android:color="@android:color/black" />
+            <corners android:radius="10dp" />
+        </shape>
+    </item>
+</layer-list>
diff --git a/res/layout/app_grid_view.xml b/res/layout/app_grid_view.xml
deleted file mode 100644
index 38c575f..0000000
--- a/res/layout/app_grid_view.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--  Copyright (C) 2016 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/>.
- -->
-<GridView xmlns:android="http://schemas.android.com/apk/res/android"
-    android:columnWidth="@android:dimen/app_icon_size"
-    android:gravity="center"
-    android:horizontalSpacing="16dp"
-    android:id="@+id/app_grid_view"
-    android:layout_height="match_parent"
-    android:layout_width="match_parent"
-    android:listSelector="@android:color/transparent"
-    android:numColumns="auto_fit"
-    android:padding="16dp"
-    android:stretchMode="columnWidth"
-    android:verticalSpacing="16dp" />
-
diff --git a/res/layout/layout_floating_widget.xml b/res/layout/layout_floating_widget.xml
new file mode 100644
index 0000000..06a913a
--- /dev/null
+++ b/res/layout/layout_floating_widget.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--  Copyright (C) 2016 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/>.
+ -->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content" >
+
+    <RelativeLayout
+        android:id="@+id/root_container"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        tools:ignore="UselessParent">
+
+        <ScrollView
+            android:id="@+id/verticalScroll"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_centerHorizontal="true"
+            android:layout_centerVertical="true"
+            android:layout_marginBottom="8dip"
+            android:layout_marginTop="8dip"
+            android:scrollbars="none">
+
+            <LinearLayout
+                android:id="@+id/selected_apps"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:background="@drawable/bg_app_chooser"
+                android:orientation="vertical"
+                android:padding="10dp" />
+        </ScrollView>
+    </RelativeLayout>
+</FrameLayout>
diff --git a/res/values/custom_arrays.xml b/res/values/custom_arrays.xml
index cfaf4ed..f4c3f94 100644
--- a/res/values/custom_arrays.xml
+++ b/res/values/custom_arrays.xml
@@ -628,4 +628,14 @@
         <item>2</item>
         <item>3</item>
     </string-array>
+
+    <string-array name="app_chooser_position_entries" translatable="false">
+        <item>@string/app_chooser_left</item>
+        <item>@string/app_chooser_right</item>
+    </string-array>
+
+    <string-array name="app_chooser_position_values" translatable="false">
+        <item>0</item>
+        <item>1</item>
+    </string-array>
 </resources>
diff --git a/res/values/custom_strings.xml b/res/values/custom_strings.xml
index c882a1b..c58bb8f 100644
--- a/res/values/custom_strings.xml
+++ b/res/values/custom_strings.xml
@@ -712,6 +712,10 @@
     <string name="autorun_single_app_summary">Dont show app selection dialog</string>
     <string name="bt_a2dp_connect_app_list_summary">App(s) to be listed when an A2DP event is triggered, such as connecting a Bluetooth headset</string>
     <string name="headset_connect_app_list_summary">App(s) to be listed when a wired headset is connected</string>
+    <string name="app_chooser_left">Left</string>
+    <string name="app_chooser_right">Right</string>
+    <string name="app_chooser_timeout_title">App chooser dialog timeout</string>
+    <string name="app_chooser_position_title">App chooser dialog position</string>
 
     <!-- Quick Pulldown-->
     <string name="quick_pulldown_title">Quick pulldown</string>
diff --git a/res/xml/event_service_settings.xml b/res/xml/event_service_settings.xml
index cff6d4d..8983e64 100644
--- a/res/xml/event_service_settings.xml
+++ b/res/xml/event_service_settings.xml
@@ -17,6 +17,7 @@
  -->
 
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
     android:key="event_service_settings"
     android:title="@string/event_service_settings_title">
 
@@ -47,8 +48,8 @@
         <org.omnirom.omnigears.preference.ScrollAppsViewPreference
             android:dependency="event_service_enabled"
             android:key="a2dp_app_list"
-            android:selectable="false"
-            android:persistent="false" />
+            android:persistent="false"
+            android:selectable="false" />
 
         <org.omnirom.omnigears.preference.AppMultiSelectListPreference
             android:dependency="event_service_enabled"
@@ -61,8 +62,8 @@
         <org.omnirom.omnigears.preference.ScrollAppsViewPreference
             android:dependency="event_service_enabled"
             android:key="headset_app_list"
-            android:selectable="false"
-            android:persistent="false" />
+            android:persistent="false"
+            android:selectable="false" />
 
         <SwitchPreference
             android:defaultValue="true"
@@ -85,5 +86,23 @@
             android:persistent="false"
             android:title="@string/media_player_autostart_title" />
 
+        <org.omnirom.omnigears.preference.SeekBarPreference
+            android:dependency="event_service_enabled"
+            android:key="app_chooser_timeout"
+            android:max="60"
+            android:persistent="false"
+            android:title="@string/app_chooser_timeout_title"
+            settings:min="0"
+            settings:unitsLeft=""
+            settings:unitsRight="@string/unit_sec" />
+
+        <ListPreference
+            android:dependency="event_service_enabled"
+            android:entries="@array/app_chooser_position_entries"
+            android:entryValues="@array/app_chooser_position_values"
+            android:key="app_chooser_position"
+            android:persistent="false"
+            android:title="@string/app_chooser_position_title" />
+
     </PreferenceCategory>
 </PreferenceScreen>