summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-07-16 00:06:44 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-07-15 16:05:07 +0000
commit0b0e794921ffe9540ddbb8d3489779ad3afd38b7 (patch)
treeb7800a3d976d1f338562b12c2fcd01b0b0b2c981 /src
parent714455bba22b99d168a2e864dfbc74a6e30dfdb6 (diff)
parentc9bb2179ab321461f88f54d49e9d41f2f6b19fe3 (diff)
downloadpackages_apps_Contacts-0b0e794921ffe9540ddbb8d3489779ad3afd38b7.tar.gz
packages_apps_Contacts-0b0e794921ffe9540ddbb8d3489779ad3afd38b7.tar.bz2
packages_apps_Contacts-0b0e794921ffe9540ddbb8d3489779ad3afd38b7.zip
Merge "Make ContactPreferences use SharedPreferences instead of System settings (2/5)" into lmp-dev
Diffstat (limited to 'src')
-rw-r--r--src/com/android/contacts/GroupMemberLoader.java2
-rw-r--r--src/com/android/contacts/activities/PeopleActivity.java2
-rw-r--r--src/com/android/contacts/detail/ContactDetailDisplayUtils.java3
-rw-r--r--src/com/android/contacts/list/EmailAddressListAdapter.java5
-rw-r--r--src/com/android/contacts/list/JoinContactListAdapter.java3
-rw-r--r--src/com/android/contacts/list/PostalAddressListAdapter.java5
-rw-r--r--src/com/android/contacts/preference/DisplayOptionsPreferenceFragment.java37
-rw-r--r--src/com/android/contacts/preference/DisplayOrderPreference.java92
-rw-r--r--src/com/android/contacts/preference/SortOrderPreference.java92
9 files changed, 11 insertions, 230 deletions
diff --git a/src/com/android/contacts/GroupMemberLoader.java b/src/com/android/contacts/GroupMemberLoader.java
index e52ddda8e..6001f2c77 100644
--- a/src/com/android/contacts/GroupMemberLoader.java
+++ b/src/com/android/contacts/GroupMemberLoader.java
@@ -95,7 +95,7 @@ public final class GroupMemberLoader extends CursorLoader {
setSelectionArgs(createSelectionArgs());
ContactsPreferences prefs = new ContactsPreferences(context);
- if (prefs.getSortOrder() == ContactsContract.Preferences.SORT_ORDER_PRIMARY) {
+ if (prefs.getSortOrder() == ContactsPreferences.SORT_ORDER_PRIMARY) {
setSortOrder(Contacts.SORT_KEY_PRIMARY);
} else {
setSortOrder(Contacts.SORT_KEY_ALTERNATIVE);
diff --git a/src/com/android/contacts/activities/PeopleActivity.java b/src/com/android/contacts/activities/PeopleActivity.java
index ed1395008..5759350e4 100644
--- a/src/com/android/contacts/activities/PeopleActivity.java
+++ b/src/com/android/contacts/activities/PeopleActivity.java
@@ -62,12 +62,12 @@ import com.android.contacts.list.ContactsRequest;
import com.android.contacts.list.ContactsUnavailableFragment;
import com.android.contacts.list.DefaultContactBrowseListFragment;
import com.android.contacts.common.list.DirectoryListLoader;
+import com.android.contacts.common.preference.DisplayOptionsPreferenceFragment;
import com.android.contacts.list.OnContactBrowserActionListener;
import com.android.contacts.list.OnContactsUnavailableActionListener;
import com.android.contacts.list.ProviderStatusWatcher;
import com.android.contacts.list.ProviderStatusWatcher.ProviderStatusListener;
import com.android.contacts.preference.ContactsPreferenceActivity;
-import com.android.contacts.preference.DisplayOptionsPreferenceFragment;
import com.android.contacts.common.util.AccountFilterUtil;
import com.android.contacts.common.util.ViewUtil;
import com.android.contacts.quickcontact.QuickContactActivity;
diff --git a/src/com/android/contacts/detail/ContactDetailDisplayUtils.java b/src/com/android/contacts/detail/ContactDetailDisplayUtils.java
index 67d14e2d3..2684af7a2 100644
--- a/src/com/android/contacts/detail/ContactDetailDisplayUtils.java
+++ b/src/com/android/contacts/detail/ContactDetailDisplayUtils.java
@@ -34,7 +34,6 @@ import android.content.res.Resources.NotFoundException;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.provider.ContactsContract.DisplayNameSources;
-import android.provider.ContactsContract.Preferences;
import android.text.Html;
import android.text.TextUtils;
import android.util.Log;
@@ -61,7 +60,7 @@ public class ContactDetailDisplayUtils {
public static CharSequence getDisplayName(Context context, Contact contactData) {
ContactsPreferences prefs = new ContactsPreferences(context);
final CharSequence displayName = contactData.getDisplayName();
- if (prefs.getDisplayOrder() == Preferences.DISPLAY_ORDER_PRIMARY) {
+ if (prefs.getDisplayOrder() == ContactsPreferences.DISPLAY_ORDER_PRIMARY) {
if (!TextUtils.isEmpty(displayName)) {
return displayName;
}
diff --git a/src/com/android/contacts/list/EmailAddressListAdapter.java b/src/com/android/contacts/list/EmailAddressListAdapter.java
index 9d5ae7ac5..53963647a 100644
--- a/src/com/android/contacts/list/EmailAddressListAdapter.java
+++ b/src/com/android/contacts/list/EmailAddressListAdapter.java
@@ -32,6 +32,7 @@ import android.view.ViewGroup;
import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest;
import com.android.contacts.common.list.ContactEntryListAdapter;
import com.android.contacts.common.list.ContactListItemView;
+import com.android.contacts.common.preference.ContactsPreferences;
/**
* A cursor adapter for the {@link Email#CONTENT_TYPE} content type.
@@ -94,13 +95,13 @@ public class EmailAddressListAdapter extends ContactEntryListAdapter {
builder.appendQueryParameter(ContactsContract.REMOVE_DUPLICATE_ENTRIES, "true");
loader.setUri(builder.build());
- if (getContactNameDisplayOrder() == ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY) {
+ if (getContactNameDisplayOrder() == ContactsPreferences.DISPLAY_ORDER_PRIMARY) {
loader.setProjection(EmailQuery.PROJECTION_PRIMARY);
} else {
loader.setProjection(EmailQuery.PROJECTION_ALTERNATIVE);
}
- if (getSortOrder() == ContactsContract.Preferences.SORT_ORDER_PRIMARY) {
+ if (getSortOrder() == ContactsPreferences.SORT_ORDER_PRIMARY) {
loader.setSortOrder(Email.SORT_KEY_PRIMARY);
} else {
loader.setSortOrder(Email.SORT_KEY_ALTERNATIVE);
diff --git a/src/com/android/contacts/list/JoinContactListAdapter.java b/src/com/android/contacts/list/JoinContactListAdapter.java
index 597a7c388..a9c9c94b3 100644
--- a/src/com/android/contacts/list/JoinContactListAdapter.java
+++ b/src/com/android/contacts/list/JoinContactListAdapter.java
@@ -34,6 +34,7 @@ import com.android.contacts.R;
import com.android.contacts.common.list.ContactListAdapter;
import com.android.contacts.common.list.ContactListItemView;
import com.android.contacts.common.list.DirectoryListLoader;
+import com.android.contacts.common.preference.ContactsPreferences;
public class JoinContactListAdapter extends ContactListAdapter {
@@ -101,7 +102,7 @@ public class JoinContactListAdapter extends ContactListAdapter {
loader.setUri(allContactsUri);
loader.setSelection(Contacts._ID + "!=?");
loader.setSelectionArgs(new String[]{ String.valueOf(mTargetContactId) });
- if (getSortOrder() == ContactsContract.Preferences.SORT_ORDER_PRIMARY) {
+ if (getSortOrder() == ContactsPreferences.SORT_ORDER_PRIMARY) {
loader.setSortOrder(Contacts.SORT_KEY_PRIMARY);
} else {
loader.setSortOrder(Contacts.SORT_KEY_ALTERNATIVE);
diff --git a/src/com/android/contacts/list/PostalAddressListAdapter.java b/src/com/android/contacts/list/PostalAddressListAdapter.java
index d011430aa..35fccfe82 100644
--- a/src/com/android/contacts/list/PostalAddressListAdapter.java
+++ b/src/com/android/contacts/list/PostalAddressListAdapter.java
@@ -31,6 +31,7 @@ import android.view.ViewGroup;
import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest;
import com.android.contacts.common.list.ContactEntryListAdapter;
import com.android.contacts.common.list.ContactListItemView;
+import com.android.contacts.common.preference.ContactsPreferences;
/**
* A cursor adapter for the {@link StructuredPostal#CONTENT_TYPE} content type.
@@ -84,13 +85,13 @@ public class PostalAddressListAdapter extends ContactEntryListAdapter {
}
loader.setUri(builder.build());
- if (getContactNameDisplayOrder() == ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY) {
+ if (getContactNameDisplayOrder() == ContactsPreferences.DISPLAY_ORDER_PRIMARY) {
loader.setProjection(PostalQuery.PROJECTION_PRIMARY);
} else {
loader.setProjection(PostalQuery.PROJECTION_ALTERNATIVE);
}
- if (getSortOrder() == ContactsContract.Preferences.SORT_ORDER_PRIMARY) {
+ if (getSortOrder() == ContactsPreferences.SORT_ORDER_PRIMARY) {
loader.setSortOrder(StructuredPostal.SORT_KEY_PRIMARY);
} else {
loader.setSortOrder(StructuredPostal.SORT_KEY_ALTERNATIVE);
diff --git a/src/com/android/contacts/preference/DisplayOptionsPreferenceFragment.java b/src/com/android/contacts/preference/DisplayOptionsPreferenceFragment.java
deleted file mode 100644
index 02177d2e3..000000000
--- a/src/com/android/contacts/preference/DisplayOptionsPreferenceFragment.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.contacts.preference;
-
-import android.os.Bundle;
-import android.preference.PreferenceFragment;
-
-import com.android.contacts.R;
-
-/**
- * This fragment shows the preferences for the first header.
- */
-public class DisplayOptionsPreferenceFragment extends PreferenceFragment {
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Load the preferences from an XML resource
- addPreferencesFromResource(R.xml.preference_display_options);
- }
-}
-
diff --git a/src/com/android/contacts/preference/DisplayOrderPreference.java b/src/com/android/contacts/preference/DisplayOrderPreference.java
deleted file mode 100644
index 81489a028..000000000
--- a/src/com/android/contacts/preference/DisplayOrderPreference.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.contacts.preference;
-
-import android.app.AlertDialog.Builder;
-import android.content.Context;
-import android.preference.ListPreference;
-import android.provider.ContactsContract;
-import android.util.AttributeSet;
-
-import com.android.contacts.R;
-import com.android.contacts.common.preference.ContactsPreferences;
-
-/**
- * Custom preference: view-name-as (first name first or last name first).
- */
-public final class DisplayOrderPreference extends ListPreference {
-
- private ContactsPreferences mPreferences;
- private Context mContext;
-
- public DisplayOrderPreference(Context context) {
- super(context);
- prepare();
- }
-
- public DisplayOrderPreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- prepare();
- }
-
- private void prepare() {
- mContext = getContext();
- mPreferences = new ContactsPreferences(mContext);
- setEntries(new String[]{
- mContext.getString(R.string.display_options_view_given_name_first),
- mContext.getString(R.string.display_options_view_family_name_first),
- });
- setEntryValues(new String[]{
- String.valueOf(ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY),
- String.valueOf(ContactsContract.Preferences.DISPLAY_ORDER_ALTERNATIVE),
- });
- setValue(String.valueOf(mPreferences.getDisplayOrder()));
- }
-
- @Override
- protected boolean shouldPersist() {
- return false; // This preference takes care of its own storage
- }
-
- @Override
- public CharSequence getSummary() {
- switch (mPreferences.getDisplayOrder()) {
- case ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY:
- return mContext.getString(R.string.display_options_view_given_name_first);
- case ContactsContract.Preferences.DISPLAY_ORDER_ALTERNATIVE:
- return mContext.getString(R.string.display_options_view_family_name_first);
- }
- return null;
- }
-
- @Override
- protected boolean persistString(String value) {
- int newValue = Integer.parseInt(value);
- if (newValue != mPreferences.getDisplayOrder()) {
- mPreferences.setDisplayOrder(newValue);
- notifyChanged();
- }
- return true;
- }
-
- @Override
- // UX recommendation is not to show cancel button on such lists.
- protected void onPrepareDialogBuilder(Builder builder) {
- super.onPrepareDialogBuilder(builder);
- builder.setNegativeButton(null, null);
- }
-}
diff --git a/src/com/android/contacts/preference/SortOrderPreference.java b/src/com/android/contacts/preference/SortOrderPreference.java
deleted file mode 100644
index da51eed71..000000000
--- a/src/com/android/contacts/preference/SortOrderPreference.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.contacts.preference;
-
-import android.app.AlertDialog.Builder;
-import android.content.Context;
-import android.preference.ListPreference;
-import android.provider.ContactsContract;
-import android.util.AttributeSet;
-
-import com.android.contacts.R;
-import com.android.contacts.common.preference.ContactsPreferences;
-
-/**
- * Custom preference: sort-by.
- */
-public final class SortOrderPreference extends ListPreference {
-
- private ContactsPreferences mPreferences;
- private Context mContext;
-
- public SortOrderPreference(Context context) {
- super(context);
- prepare();
- }
-
- public SortOrderPreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- prepare();
- }
-
- private void prepare() {
- mContext = getContext();
- mPreferences = new ContactsPreferences(mContext);
- setEntries(new String[]{
- mContext.getString(R.string.display_options_sort_by_given_name),
- mContext.getString(R.string.display_options_sort_by_family_name),
- });
- setEntryValues(new String[]{
- String.valueOf(ContactsContract.Preferences.SORT_ORDER_PRIMARY),
- String.valueOf(ContactsContract.Preferences.SORT_ORDER_ALTERNATIVE),
- });
- setValue(String.valueOf(mPreferences.getSortOrder()));
- }
-
- @Override
- protected boolean shouldPersist() {
- return false; // This preference takes care of its own storage
- }
-
- @Override
- public CharSequence getSummary() {
- switch (mPreferences.getSortOrder()) {
- case ContactsContract.Preferences.SORT_ORDER_PRIMARY:
- return mContext.getString(R.string.display_options_sort_by_given_name);
- case ContactsContract.Preferences.SORT_ORDER_ALTERNATIVE:
- return mContext.getString(R.string.display_options_sort_by_family_name);
- }
- return null;
- }
-
- @Override
- protected boolean persistString(String value) {
- int newValue = Integer.parseInt(value);
- if (newValue != mPreferences.getSortOrder()) {
- mPreferences.setSortOrder(newValue);
- notifyChanged();
- }
- return true;
- }
-
- @Override
- // UX recommendation is not to show cancel button on such lists.
- protected void onPrepareDialogBuilder(Builder builder) {
- super.onPrepareDialogBuilder(builder);
- builder.setNegativeButton(null, null);
- }
-}