Add DisplayOptions PreferenceFragment.

- Remove display options from the general settings fragment.
+ Move display options into their own fragment, and add header in
the top-level Dialer settingss which points to them.

Bug: 19372734
Change-Id: I3452177ba5c31fd9e86dafbcf22eebd56c2bb091
diff --git a/res/values/strings.xml b/res/values/strings.xml
index baa7746..ab8fd27 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -690,13 +690,13 @@
 
     <!-- Dialer settings related strings-->
 
+    <!-- Title for "Display options" category, which controls how contacts are shown.
+         [CHAR LIMIT=40] -->
+    <string name="display_options_title">Display options</string>
+
     <!-- Label for the general dialer settings section [CHAR LIMIT=30]-->
     <string name="general_settings_label">General</string>
 
-    <!-- Title for "Contact display options" category, which is shown above options which
-         manipulate how contacts are shown. [CHAR LIMIT=40] -->
-    <string name="contact_display_options_category_title">Contact display options</string>
-
     <!-- Title for the category "sounds", which is shown above sounds and vibration related
          settings. [CHAR LIMIT=30] -->
     <string name="sounds_and_vibrate_category_title">Sounds and vibrate</string>
diff --git a/res/xml/display_options.xml b/res/xml/display_options.xml
new file mode 100644
index 0000000..07aadf7
--- /dev/null
+++ b/res/xml/display_options.xml
@@ -0,0 +1,31 @@
+<?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
+  -->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <com.android.contacts.common.preference.SortOrderPreference
+        android:key="sortOrder"
+        android:title="@string/display_options_sort_list_by"
+        android:dialogTitle="@string/display_options_sort_list_by" />
+
+    <com.android.contacts.common.preference.DisplayOrderPreference
+        android:key="displayOrder"
+        android:title="@string/display_options_view_names_as"
+        android:dialogTitle="@string/display_options_view_names_as" />
+
+</PreferenceScreen>
diff --git a/res/xml/general_settings.xml b/res/xml/general_settings.xml
index 29845ed..c856e1a 100644
--- a/res/xml/general_settings.xml
+++ b/res/xml/general_settings.xml
@@ -19,23 +19,6 @@
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
 
     <PreferenceCategory
-        android:key="dialer_contact_display_options_category_key"
-        android:title="@string/contact_display_options_category_title"
-        android:persistent="false">
-
-        <com.android.contacts.common.preference.SortOrderPreference
-            android:key="sortOrder"
-            android:title="@string/display_options_sort_list_by"
-            android:dialogTitle="@string/display_options_sort_list_by" />
-
-        <com.android.contacts.common.preference.DisplayOrderPreference
-            android:key="displayOrder"
-            android:title="@string/display_options_view_names_as"
-            android:dialogTitle="@string/display_options_view_names_as" />
-
-    </PreferenceCategory>
-
-    <PreferenceCategory
         android:key="dialer_general_sounds_category_key"
         android:title="@string/sounds_and_vibrate_category_title"
         android:persistent="false">
diff --git a/src/com/android/dialer/settings/DialerSettingsActivity.java b/src/com/android/dialer/settings/DialerSettingsActivity.java
index d6e8826..bdffa93 100644
--- a/src/com/android/dialer/settings/DialerSettingsActivity.java
+++ b/src/com/android/dialer/settings/DialerSettingsActivity.java
@@ -43,6 +43,11 @@
 
     @Override
     public void onBuildHeaders(List<Header> target) {
+        Header displayOptionsHeader = new Header();
+        displayOptionsHeader.titleRes = R.string.display_options_title;
+        displayOptionsHeader.fragment = DisplayOptionsFragment.class.getName();
+        target.add(displayOptionsHeader);
+
         Header generalSettingsHeader = new Header();
         generalSettingsHeader.titleRes = R.string.general_settings_label;
         generalSettingsHeader.fragment = GeneralSettingsFragment.class.getName();
diff --git a/src/com/android/dialer/settings/DisplayOptionsFragment.java b/src/com/android/dialer/settings/DisplayOptionsFragment.java
new file mode 100644
index 0000000..3a932d5
--- /dev/null
+++ b/src/com/android/dialer/settings/DisplayOptionsFragment.java
@@ -0,0 +1,31 @@
+/*
+ * 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
+ */
+
+package com.android.dialer.settings;
+
+import android.os.Bundle;
+import android.preference.PreferenceFragment;
+
+import com.android.dialer.R;
+
+public class DisplayOptionsFragment extends PreferenceFragment {
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        addPreferencesFromResource(R.xml.display_options);
+    }
+}