OmniControl: incall vibration options [3/3]

Change-Id: Iecb15689185d2c464a931fd4d47becb732286006
Signed-off-by: Ali Hasan <ahb7671@gmail.com>
diff --git a/app/src/main/java/org/omnirom/control/DialerSettingsFragment.kt b/app/src/main/java/org/omnirom/control/DialerSettingsFragment.kt
new file mode 100644
index 0000000..4a10cb5
--- /dev/null
+++ b/app/src/main/java/org/omnirom/control/DialerSettingsFragment.kt
@@ -0,0 +1,48 @@
+/*
+ *  Copyright (C) 2021 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/>.
+ *
+ */
+package org.omnirom.control
+
+import android.os.Bundle
+import android.provider.Settings
+import androidx.appcompat.app.AppCompatActivity
+import androidx.preference.Preference
+import androidx.preference.PreferenceFragmentCompat
+
+
+class DialerSettingsFragment : AbstractSettingsFragment() {
+
+    override fun getFragmentTitle(): String {
+        return resources.getString(R.string.dialer_settings_title)
+    }
+
+    override fun getFragmentSummary(): String {
+        return resources.getString(R.string.dialer_settings_summary)
+    }
+
+    override fun getFragmentIcon(): Int {
+        return R.drawable.ic_dialer_tile
+    }
+
+    override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
+        setPreferencesFromResource(R.xml.dialer_settings_preferences, rootKey)
+    }
+
+    override fun onPreferenceTreeClick(preference: Preference?): Boolean {
+        return super.onPreferenceTreeClick(preference)
+    }
+}
diff --git a/app/src/main/java/org/omnirom/control/GridViewFragment.kt b/app/src/main/java/org/omnirom/control/GridViewFragment.kt
index 0054a7d..7e8485f 100644
--- a/app/src/main/java/org/omnirom/control/GridViewFragment.kt
+++ b/app/src/main/java/org/omnirom/control/GridViewFragment.kt
@@ -28,6 +28,7 @@
 import androidx.appcompat.app.AppCompatActivity
 import androidx.fragment.app.Fragment
 
+import org.omnirom.omnilib.utils.DeviceUtils
 
 class GridViewFragment() : Fragment() {
     private lateinit var gridView: GridView
@@ -110,6 +111,16 @@
                 ButtonSettingsFragment()
             )
         )
+        if (DeviceUtils.isVoiceCapable(getContext())) {
+            gridItems.add(
+                FragmentGridItem(
+                    R.string.dialer_settings_title,
+                    R.string.dialer_settings_summary,
+                    R.drawable.ic_dialer_tile,
+                    DialerSettingsFragment()
+                )
+            )
+        }
         gridItems.add(
             FragmentGridItem(
                 R.string.lockscreen_item_title,
@@ -272,4 +283,4 @@
     }
 
 
-}
\ No newline at end of file
+}
diff --git a/app/src/main/res/drawable/ic_dialer_tile.xml b/app/src/main/res/drawable/ic_dialer_tile.xml
new file mode 100644
index 0000000..b97aac7
--- /dev/null
+++ b/app/src/main/res/drawable/ic_dialer_tile.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+     Copyright (C) 2015 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24"
+    android:tint="?android:textColorPrimary">
+  <path
+      android:fillColor="@android:color/white"
+      android:pathData="M6.54,5c0.06,0.89 0.21,1.76 0.45,2.59l-1.2,1.2c-0.41,-1.2 -0.67,-2.47 -0.76,-3.79h1.51m9.86,12.02c0.85,0.24 1.72,0.39 2.6,0.45v1.49c-1.32,-0.09 -2.59,-0.35 -3.8,-0.75l1.2,-1.19M7.5,3H4c-0.55,0 -1,0.45 -1,1 0,9.39 7.61,17 17,17 0.55,0 1,-0.45 1,-1v-3.49c0,-0.55 -0.45,-1 -1,-1 -1.24,0 -2.45,-0.2 -3.57,-0.57 -0.1,-0.04 -0.21,-0.05 -0.31,-0.05 -0.26,0 -0.51,0.1 -0.71,0.29l-2.2,2.2c-2.83,-1.45 -5.15,-3.76 -6.59,-6.59l2.2,-2.2c0.28,-0.28 0.36,-0.67 0.25,-1.02C8.7,6.45 8.5,5.25 8.5,4c0,-0.55 -0.45,-1 -1,-1z"/>
+</vector>
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 161a88e..05e3f99 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -117,4 +117,14 @@
     <string name="qs_layout_columns_landscape_summary"></string>
     <string name="qs_tile_label_hide_title">Hide labels</string>
     <string name="qs_tile_label_hide_summary">Do not show text</string>
-</resources>
\ No newline at end of file
+
+    <!-- Dialer Setting -->
+    <string name="dialer_settings_title">Dialer</string>
+    <string name="dialer_settings_summary">Dialer options</string>
+    <string name="incall_vibrate_connect_title">Vibrate on connect</string>
+    <string name="incall_vibrate_connect_summary">Device vibrate on connect</string>
+    <string name="incall_vibrate_call_wait_title">Vibrate on call waiting</string>
+    <string name="incall_vibrate_call_wait_summary">Device vibrate on call waiting</string>
+    <string name="incall_vibrate_disconnect_title">Vibrate on disconnect</string>
+    <string name="incall_vibrate_disconnect_summary">Device vibrate on call disconnect</string>
+</resources>
diff --git a/app/src/main/res/xml/dialer_settings_preferences.xml b/app/src/main/res/xml/dialer_settings_preferences.xml
new file mode 100644
index 0000000..138ec3e
--- /dev/null
+++ b/app/src/main/res/xml/dialer_settings_preferences.xml
@@ -0,0 +1,26 @@
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+    android:key="bars_settings">
+    <PreferenceCategory
+        android:key="dialer_settings_category"
+        android:title="@string/dialer_settings_title">
+
+        <org.omnirom.omnilib.preference.SystemSettingSwitchPreference
+            android:key="vibrate_on_connect"
+            android:title="@string/incall_vibrate_connect_title"
+            android:summary="@string/incall_vibrate_connect_summary"
+            android:defaultValue="false" />
+
+        <org.omnirom.omnilib.preference.SystemSettingSwitchPreference
+            android:key="vibrate_on_callwaiting"
+            android:title="@string/incall_vibrate_call_wait_title"
+            android:summary="@string/incall_vibrate_call_wait_summary"
+            android:defaultValue="false" />
+
+        <org.omnirom.omnilib.preference.SystemSettingSwitchPreference
+            android:key="vibrate_on_disconnect"
+            android:title="@string/incall_vibrate_disconnect_title"
+            android:summary="@string/incall_vibrate_disconnect_summary"
+            android:defaultValue="false" />
+
+    </PreferenceCategory>
+</PreferenceScreen>