Redesign settings on tablets
1. Move ContactsPreferenceActivity to ContactsCommon since it is called
in DisplayOptionsPreferenceFragment, which is built as part of Dialer.
2. Remove preference_headers.xml since we are going to get rid of headers.
3. Kitkat backporting.
Here's how it looks:
https://docs.google.com/a/google.com/presentation/d/1A5n2o8epBCrizZvbOyelvjoHz-s5-IRlJd-KqWAMBao/edit?usp=sharing
Bug: 25629359
Bug: 26469731
Change-Id: I2dc8dec8a6e3725c3180f0e0a56ed68fe28cca50
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 32016b2..74a8a91 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -203,7 +203,7 @@
<!-- Used to set options -->
<activity
- android:name=".preference.ContactsPreferenceActivity"
+ android:name=".common.preference.ContactsPreferenceActivity"
android:label="@string/activity_title_settings"
android:theme="@style/ContactsPreferencesTheme"
android:exported="false"/>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index db1b5d8..7f49820 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -299,8 +299,10 @@
<item name="android:layout_height">match_parent</item>
</style>
- <style name="ContactsPreferencesTheme" parent="@style/PeopleTheme">
- <item name="android:listViewStyle">@style/ListViewStyle</item>
+ <style name="ContactsPreferencesTheme" parent="@style/PeopleThemeAppCompat">
+ <!-- Styles that require AppCompat compatibility, remember to update both sets -->
+ <item name="android:alertDialogTheme">@style/ContactsAlertDialogThemeAppCompat</item>
+ <item name="alertDialogTheme">@style/ContactsAlertDialogThemeAppCompat</item>
</style>
<style name="ContactListFilterTheme" parent="@style/PeopleThemeAppCompat">
@@ -420,6 +422,11 @@
<item name="android:colorAccent">@color/primary_color</item>
</style>
+ <style name="ContactsAlertDialogThemeAppCompat" parent="Theme.AppCompat.Light.Dialog">
+ <item name="android:colorAccent">@color/primary_color</item>
+ <item name="colorAccent">@color/primary_color</item>
+ </style>
+
<style name="EditKindIconStyle">
<item name="android:layout_width">24dp</item>
<item name="android:layout_height">24dp</item>
diff --git a/res/xml/preference_headers.xml b/res/xml/preference_headers.xml
deleted file mode 100644
index 98019fd..0000000
--- a/res/xml/preference_headers.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 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.
--->
-
-<preference-headers
- xmlns:android="http://schemas.android.com/apk/res/android">
-
- <header
- android:fragment="com.android.contacts.common.preference.DisplayOptionsPreferenceFragment"
- android:title="@string/preference_displayOptions" />
-
-</preference-headers>
diff --git a/src/com/android/contacts/activities/PeopleActivity.java b/src/com/android/contacts/activities/PeopleActivity.java
index c495ee8..77eccb1 100644
--- a/src/com/android/contacts/activities/PeopleActivity.java
+++ b/src/com/android/contacts/activities/PeopleActivity.java
@@ -87,7 +87,7 @@
import com.android.contacts.common.list.ViewPagerTabs;
import com.android.contacts.common.logging.Logger;
import com.android.contacts.common.logging.ScreenEvent;
-import com.android.contacts.preference.ContactsPreferenceActivity;
+import com.android.contacts.common.preference.ContactsPreferenceActivity;
import com.android.contacts.common.util.AccountFilterUtil;
import com.android.contacts.common.util.ViewUtil;
import com.android.contacts.quickcontact.QuickContactActivity;
@@ -1192,18 +1192,7 @@
return true;
}
case R.id.menu_settings: {
- final Intent intent = new Intent(this, ContactsPreferenceActivity.class);
- // Since there is only one section right now, make sure it is selected on
- // small screens.
- intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT,
- DisplayOptionsPreferenceFragment.class.getName());
- // By default, the title of the activity should be equivalent to the fragment
- // title. We set this argument to avoid this. Because of a bug, the following
- // line isn't necessary. But, once the bug is fixed this may become necessary.
- // b/5045558 refers to this issue, as well as another.
- intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_TITLE,
- R.string.activity_title_settings);
- startActivity(intent);
+ startActivity(new Intent(this, ContactsPreferenceActivity.class));
return true;
}
case R.id.menu_contacts_filter: {
diff --git a/src/com/android/contacts/preference/ContactsPreferenceActivity.java b/src/com/android/contacts/preference/ContactsPreferenceActivity.java
deleted file mode 100644
index a779a94..0000000
--- a/src/com/android/contacts/preference/ContactsPreferenceActivity.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2009 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.contacts.preference;
-
-import android.app.ActionBar;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.preference.PreferenceActivity;
-import android.view.MenuItem;
-
-import com.android.contacts.R;
-import com.android.contacts.activities.PeopleActivity;
-
-import java.util.List;
-
-/**
- * Contacts settings.
- */
-public final class ContactsPreferenceActivity extends PreferenceActivity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // This Activity will always fall back to the "top" Contacts screen when touched on the
- // app up icon, regardless of launch context.
- ActionBar actionBar = getActionBar();
- if (actionBar != null) {
- actionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP);
- }
- }
-
- /**
- * Populate the activity with the top-level headers.
- */
- @Override
- public void onBuildHeaders(List<Header> target) {
- loadHeadersFromResource(R.xml.preference_headers, target);
- }
-
- /**
- * Returns true if there are no preferences to display and therefore the
- * corresponding menu item can be removed.
- */
- public static boolean isEmpty(Context context) {
- return !context.getResources().getBoolean(R.bool.config_sort_order_user_changeable)
- && !context.getResources().getBoolean(R.bool.config_display_order_user_changeable)
- && !context.getResources().getBoolean(
- R.bool.config_default_account_user_changeable);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home: {
- Intent intent = new Intent(this, PeopleActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- startActivity(intent);
- finish();
- return true;
- }
- }
- return false;
- }
-
- @Override
- protected boolean isValidFragment(String fragmentName) {
- return true;
- }
-}