Return display_name after joining multiple contacts.
am: 3bb8514aa1
Change-Id: I4e3c08f62a9b1e4aa05825b3549f3a92c84a2f93
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index e5c10c9..c67593e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -49,6 +49,8 @@
<uses-permission android:name="com.android.voicemail.permission.READ_VOICEMAIL" />
<!-- Following used for Contact metadata syncing -->
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
+ <!-- Following used for getting the status of the contacts sync adapter -->
+ <uses-permission android:name="android.permission.READ_SYNC_STATS" />
<uses-feature android:name="android.hardware.telephony" android:required="false"/>
diff --git a/res/layout/contact_editor_accounts_changed_activity_with_picker.xml b/res/layout/contact_editor_accounts_changed_activity_with_picker.xml
index 172c9c5..0faea20 100644
--- a/res/layout/contact_editor_accounts_changed_activity_with_picker.xml
+++ b/res/layout/contact_editor_accounts_changed_activity_with_picker.xml
@@ -24,14 +24,9 @@
android:layout_height="match_parent"
android:orientation="vertical">
- <TextView android:id="@+id/text"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="24dip"
- android:layout_marginStart="24dip"
- android:paddingTop="15dip"
- android:paddingBottom="15dip"
- android:textAppearance="?android:attr/textAppearanceMedium"/>
+ <include
+ android:id="@+id/text"
+ layout="@layout/dialog_title"/>
<View
android:layout_width="match_parent"
@@ -42,8 +37,6 @@
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
- android:layout_marginLeft="8dip"
- android:layout_marginStart="8dip"
android:fadingEdge="none"/>
<View
@@ -54,7 +47,9 @@
<Button
android:id="@+id/add_account_button"
style="?android:attr/buttonBarButtonStyle"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingStart="24dp"
+ android:layout_marginBottom="8dp"/>
</LinearLayout>
diff --git a/res/layout/contact_editor_accounts_changed_activity_with_text.xml b/res/layout/contact_editor_accounts_changed_activity_with_text.xml
index 345d937..7ee30f7 100644
--- a/res/layout/contact_editor_accounts_changed_activity_with_text.xml
+++ b/res/layout/contact_editor_accounts_changed_activity_with_text.xml
@@ -27,7 +27,10 @@
<TextView android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:padding="15dip"
+ android:layout_marginStart="24dp"
+ android:layout_marginEnd="24dp"
+ android:layout_marginTop="24dp"
+ android:layout_marginBottom="24dp"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<View
@@ -35,7 +38,7 @@
android:layout_height="1dip"
android:background="?android:attr/listDivider"/>
- <LinearLayout
+ <RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
@@ -44,20 +47,24 @@
style="?android:attr/buttonBarStyle">
<Button
- android:id="@+id/left_button"
- style="?android:attr/buttonBarButtonStyle"
- android:layout_width="0dip"
- android:layout_height="wrap_content"
- android:singleLine="false"
- android:layout_weight="1" />
-
- <Button
android:id="@+id/right_button"
style="?android:attr/buttonBarButtonStyle"
- android:layout_width="0dip"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_weight="1" />
+ android:layout_alignParentEnd="true"
+ android:layout_marginStart="8dp"
+ android:layout_marginEnd="8dp"
+ android:layout_marginTop="8dp"
+ android:layout_marginBottom="8dp"/>
- </LinearLayout>
+ <Button
+ android:id="@+id/left_button"
+ style="?android:attr/buttonBarButtonStyle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_toLeftOf="@id/right_button"
+ android:layout_marginTop="8dp"/>
+
+ </RelativeLayout>
</LinearLayout>
diff --git a/res/values-b+sr+Latn/strings.xml b/res/values-b+sr+Latn/strings.xml
index 3078976..ca2197a 100644
--- a/res/values-b+sr+Latn/strings.xml
+++ b/res/values-b+sr+Latn/strings.xml
@@ -52,7 +52,7 @@
<string name="menu_call" msgid="3992595586042260618">"Pozovi kontakt"</string>
<string name="menu_sendSMS" msgid="5535886767547006515">"Pošalji SMS kontaktu"</string>
<string name="menu_splitAggregate" msgid="2627252205317945563">"Razdvoji"</string>
- <string name="menu_editGroup" msgid="5062005185370983720">"Izmeni"</string>
+ <string name="menu_editGroup" msgid="6696843438454341063">"Ukloni kontakte"</string>
<string name="menu_renameGroup" msgid="7169512355179757182">"Preimenuj oznaku"</string>
<string name="menu_deleteGroup" msgid="1126469629233412249">"Izbriši oznaku"</string>
<string name="menu_addToGroup" msgid="3267409983764370041">"Dodaj kontakt"</string>
@@ -80,10 +80,15 @@
<item quantity="few">Kontakti su izbrisani</item>
<item quantity="other">Kontakti su izbrisani</item>
</plurals>
- <plurals name="contacts_count" formatted="false" msgid="3287407967505649458">
- <item quantity="one"><xliff:g id="COUNT">%d</xliff:g> kontakt</item>
- <item quantity="few"><xliff:g id="COUNT">%d</xliff:g> kontakta</item>
- <item quantity="other"><xliff:g id="COUNT">%d</xliff:g> kontakata</item>
+ <plurals name="contacts_count" formatted="false" msgid="8696793457340503668">
+ <item quantity="one"><xliff:g id="COUNT_1">%d</xliff:g> kontakt</item>
+ <item quantity="few"><xliff:g id="COUNT_1">%d</xliff:g> kontakta</item>
+ <item quantity="other"><xliff:g id="COUNT_1">%d</xliff:g> kontakata</item>
+ </plurals>
+ <plurals name="contacts_count_with_account" formatted="false" msgid="7402583111980220575">
+ <item quantity="one"><xliff:g id="COUNT_2">%d</xliff:g> kontakt · <xliff:g id="ACCOUNT_3">%s</xliff:g></item>
+ <item quantity="few"><xliff:g id="COUNT_2">%d</xliff:g> kontakta · <xliff:g id="ACCOUNT_3">%s</xliff:g></item>
+ <item quantity="other"><xliff:g id="COUNT_2">%d</xliff:g> kontakata · <xliff:g id="ACCOUNT_3">%s</xliff:g></item>
</plurals>
<string name="title_from_google" msgid="4664084747121207202">"Sa Google-a"</string>
<string name="title_from_other_accounts" msgid="8307885412426754288">"Sa <xliff:g id="ACCOUNT">%s</xliff:g>"</string>
@@ -237,8 +242,7 @@
<string name="cancel_confirmation_dialog_keep_editing_button" msgid="7737724111972855348">"Nastavi izmene"</string>
<string name="call_type_and_date" msgid="747163730039311423">"<xliff:g id="CALL_TYPE">%1$s</xliff:g> <xliff:g id="CALL_SHORT_DATE">%2$s</xliff:g>"</string>
<string name="enter_contact_name" msgid="4594274696120278368">"Pretražite kontakte"</string>
- <!-- no translation found for title_edit_group (1889302367574226969) -->
- <skip />
+ <string name="title_edit_group" msgid="8602752287270586734">"Uklonite kontakte"</string>
<string name="local_profile_title" msgid="2021416826991393684">"Moj lokalni profil"</string>
<string name="external_profile_title" msgid="8034998767621359438">"Moj <xliff:g id="EXTERNAL_SOURCE">%1$s</xliff:g> profil"</string>
<string name="toast_displaying_all_contacts" msgid="2737388783898593875">"Prikazani su svi kontakti"</string>
diff --git a/res/values-be-rBY/strings.xml b/res/values-be-rBY/strings.xml
index 2eee399..42d52e3 100644
--- a/res/values-be-rBY/strings.xml
+++ b/res/values-be-rBY/strings.xml
@@ -52,7 +52,8 @@
<string name="menu_call" msgid="3992595586042260618">"Выклікаць кантакт"</string>
<string name="menu_sendSMS" msgid="5535886767547006515">"Паведамленне кантакту"</string>
<string name="menu_splitAggregate" msgid="2627252205317945563">"Выдаліць сувязь"</string>
- <string name="menu_editGroup" msgid="5062005185370983720">"Рэдагаваць"</string>
+ <!-- no translation found for menu_editGroup (6696843438454341063) -->
+ <skip />
<string name="menu_renameGroup" msgid="7169512355179757182">"Перайменаваць метку"</string>
<string name="menu_deleteGroup" msgid="1126469629233412249">"Выдаліць метку"</string>
<string name="menu_addToGroup" msgid="3267409983764370041">"Дадаць кантакт"</string>
@@ -81,11 +82,17 @@
<item quantity="many">Кантакты выдалены</item>
<item quantity="other">Кантакты выдалены</item>
</plurals>
- <plurals name="contacts_count" formatted="false" msgid="3287407967505649458">
- <item quantity="one"><xliff:g id="COUNT">%d</xliff:g> кантакт</item>
- <item quantity="few"><xliff:g id="COUNT">%d</xliff:g> кантакты</item>
- <item quantity="many"><xliff:g id="COUNT">%d</xliff:g> кантактаў</item>
- <item quantity="other"><xliff:g id="COUNT">%d</xliff:g> кантакту</item>
+ <plurals name="contacts_count" formatted="false" msgid="8696793457340503668">
+ <item quantity="one"><xliff:g id="COUNT_1">%d</xliff:g> кантакт</item>
+ <item quantity="few"><xliff:g id="COUNT_1">%d</xliff:g> кантакты</item>
+ <item quantity="many"><xliff:g id="COUNT_1">%d</xliff:g> кантактаў</item>
+ <item quantity="other"><xliff:g id="COUNT_1">%d</xliff:g> кантакту</item>
+ </plurals>
+ <plurals name="contacts_count_with_account" formatted="false" msgid="7402583111980220575">
+ <item quantity="one"><xliff:g id="COUNT_2">%d</xliff:g> кантакт · <xliff:g id="ACCOUNT_3">%s</xliff:g></item>
+ <item quantity="few"><xliff:g id="COUNT_2">%d</xliff:g> кантакты · <xliff:g id="ACCOUNT_3">%s</xliff:g></item>
+ <item quantity="many"><xliff:g id="COUNT_2">%d</xliff:g> кантактаў · <xliff:g id="ACCOUNT_3">%s</xliff:g></item>
+ <item quantity="other"><xliff:g id="COUNT_2">%d</xliff:g> кантакту · <xliff:g id="ACCOUNT_3">%s</xliff:g></item>
</plurals>
<string name="title_from_google" msgid="4664084747121207202">"З Google"</string>
<string name="title_from_other_accounts" msgid="8307885412426754288">"З <xliff:g id="ACCOUNT">%s</xliff:g>"</string>
@@ -243,7 +250,7 @@
<string name="cancel_confirmation_dialog_keep_editing_button" msgid="7737724111972855348">"Працягнуць рэдагаванне"</string>
<string name="call_type_and_date" msgid="747163730039311423">"<xliff:g id="CALL_TYPE">%1$s</xliff:g> <xliff:g id="CALL_SHORT_DATE">%2$s</xliff:g>"</string>
<string name="enter_contact_name" msgid="4594274696120278368">"Пошук кантактаў"</string>
- <!-- no translation found for title_edit_group (1889302367574226969) -->
+ <!-- no translation found for title_edit_group (8602752287270586734) -->
<skip />
<string name="local_profile_title" msgid="2021416826991393684">"Мой лакальны профіль"</string>
<string name="external_profile_title" msgid="8034998767621359438">"Мой профіль у <xliff:g id="EXTERNAL_SOURCE">%1$s</xliff:g>"</string>
diff --git a/res/values-bs-rBA/strings.xml b/res/values-bs-rBA/strings.xml
index 67f5166..7b3d95a 100644
--- a/res/values-bs-rBA/strings.xml
+++ b/res/values-bs-rBA/strings.xml
@@ -52,7 +52,7 @@
<string name="menu_call" msgid="3992595586042260618">"Pozovi kontakt"</string>
<string name="menu_sendSMS" msgid="5535886767547006515">"Pošalji tekstualnu poruku kontaktu"</string>
<string name="menu_splitAggregate" msgid="2627252205317945563">"Razdvoji"</string>
- <string name="menu_editGroup" msgid="5062005185370983720">"Uredi"</string>
+ <string name="menu_editGroup" msgid="6696843438454341063">"Ukloni kontakte"</string>
<string name="menu_renameGroup" msgid="7169512355179757182">"Preimenuj oznaku"</string>
<string name="menu_deleteGroup" msgid="1126469629233412249">"Izbriši oznaku"</string>
<string name="menu_addToGroup" msgid="3267409983764370041">"Dodaj kontakt"</string>
@@ -80,10 +80,15 @@
<item quantity="few">Kontakti su izbrisani</item>
<item quantity="other">Kontakti su izbrisani</item>
</plurals>
- <plurals name="contacts_count" formatted="false" msgid="3287407967505649458">
- <item quantity="one"><xliff:g id="COUNT">%d</xliff:g> kontakt</item>
- <item quantity="few"><xliff:g id="COUNT">%d</xliff:g> kontakta</item>
- <item quantity="other"><xliff:g id="COUNT">%d</xliff:g> kontakata</item>
+ <plurals name="contacts_count" formatted="false" msgid="8696793457340503668">
+ <item quantity="one"><xliff:g id="COUNT_1">%d</xliff:g> kontakt</item>
+ <item quantity="few"><xliff:g id="COUNT_1">%d</xliff:g> kontakta</item>
+ <item quantity="other"><xliff:g id="COUNT_1">%d</xliff:g> kontakata</item>
+ </plurals>
+ <plurals name="contacts_count_with_account" formatted="false" msgid="7402583111980220575">
+ <item quantity="one"><xliff:g id="COUNT_2">%d</xliff:g> kontakt · <xliff:g id="ACCOUNT_3">%s</xliff:g></item>
+ <item quantity="few"><xliff:g id="COUNT_2">%d</xliff:g> kontakta · <xliff:g id="ACCOUNT_3">%s</xliff:g></item>
+ <item quantity="other"><xliff:g id="COUNT_2">%d</xliff:g> kontakata · <xliff:g id="ACCOUNT_3">%s</xliff:g></item>
</plurals>
<string name="title_from_google" msgid="4664084747121207202">"Sa Googlea"</string>
<string name="title_from_other_accounts" msgid="8307885412426754288">"Sa računa <xliff:g id="ACCOUNT">%s</xliff:g>"</string>
@@ -237,8 +242,7 @@
<string name="cancel_confirmation_dialog_keep_editing_button" msgid="7737724111972855348">"Nastavi uređivanje"</string>
<string name="call_type_and_date" msgid="747163730039311423">"<xliff:g id="CALL_TYPE">%1$s</xliff:g> <xliff:g id="CALL_SHORT_DATE">%2$s</xliff:g>"</string>
<string name="enter_contact_name" msgid="4594274696120278368">"Traži kontakte"</string>
- <!-- no translation found for title_edit_group (1889302367574226969) -->
- <skip />
+ <string name="title_edit_group" msgid="8602752287270586734">"Ukloni kontakte"</string>
<string name="local_profile_title" msgid="2021416826991393684">"Moj lokalni profil"</string>
<string name="external_profile_title" msgid="8034998767621359438">"Moj profil <xliff:g id="EXTERNAL_SOURCE">%1$s</xliff:g>"</string>
<string name="toast_displaying_all_contacts" msgid="2737388783898593875">"Prikazuju se svi kontakti"</string>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 0d1b6ea..f1b6f06 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -81,4 +81,9 @@
<!-- Color of background of all empty states. -->
<color name="empty_state_background">#efefef</color>
+ <!-- Colors of swipeRefreshLayout's spinning circle. -->
+ <color name="swipe_refresh_color1">#0f9d58</color>
+ <color name="swipe_refresh_color2">#dd4b37</color>
+ <color name="swipe_refresh_color3">#4285f4</color>
+ <color name="swipe_refresh_color4">#f4b400</color>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index f9111d3..171c9d5 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -292,6 +292,9 @@
<!-- Minimum height for group name EditText -->
<dimen name="group_name_edit_text_min_height">48dp</dimen>
+ <!-- Distance to pull down before causing a refresh. -->
+ <dimen name="pull_to_refresh_distance">40dp</dimen>
+
<!-- Elevation of contact list header -->
<dimen name="contact_list_header_elevation">2dp</dimen>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ec9b4a9..ef82a26 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -697,7 +697,7 @@
<string name="generic_no_account_prompt_title">Add an account</string>
<!-- Message in the contact editor prompt that notifies the user that the newly created contact will not be saved to any account, and prompts addition of an account [CHAR LIMIT=NONE] -->
- <string name="contact_editor_prompt_zero_accounts">Your new contact won\'t be backed up. Add an account that backs up contacts online?</string>
+ <string name="contact_editor_prompt_zero_accounts">Take a minute to add an account that will back up your contacts to Google.</string>
<!-- Message in the contact editor prompt that asks the user if it's okay to save the newly created contact to the account shown. [CHAR LIMIT=NONE] -->
<string name="contact_editor_prompt_one_account">New contacts will be saved to <xliff:g id="account_name">%1$s</xliff:g>.</string>
@@ -715,9 +715,6 @@
at a pre-determined text size. [CHAR LIMIT=20] -->
<string name="contact_editor_title_existing_contact">Edit contact</string>
- <!-- Button label to indicate that the user wants to save the newly created contact locally (instead of backing it up online) [CHAR LIMIT=20] -->
- <string name="keep_local">Keep local</string>
-
<!-- Button label to prompt the user to add an account (when there are 0 existing accounts on the device) [CHAR LIMIT=30] -->
<string name="add_account">Add account</string>
diff --git a/src/com/android/contacts/activities/ContactEditorAccountsChangedActivity.java b/src/com/android/contacts/activities/ContactEditorAccountsChangedActivity.java
index 212f888..c4c0e27 100644
--- a/src/com/android/contacts/activities/ContactEditorAccountsChangedActivity.java
+++ b/src/com/android/contacts/activities/ContactEditorAccountsChangedActivity.java
@@ -148,7 +148,7 @@
// This button allows the user to continue editing the contact as a phone-only
// local contact.
- leftButton.setText(getString(R.string.keep_local));
+ leftButton.setText(getString(android.R.string.cancel));
leftButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
diff --git a/src/com/android/contacts/activities/PeopleActivity.java b/src/com/android/contacts/activities/PeopleActivity.java
index 756aeb4..6a8f0c7 100644
--- a/src/com/android/contacts/activities/PeopleActivity.java
+++ b/src/com/android/contacts/activities/PeopleActivity.java
@@ -21,13 +21,16 @@
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.ActivityNotFoundException;
+import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.Intent;
+import android.content.SyncStatusObserver;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Bundle;
+import android.os.Handler;
import android.os.Parcelable;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Intents;
@@ -37,6 +40,7 @@
import android.support.v4.view.GravityCompat;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
+import android.support.v4.widget.SwipeRefreshLayout;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyCharacterMap;
@@ -55,6 +59,7 @@
import com.android.contacts.ContactsDrawerActivity;
import com.android.contacts.R;
import com.android.contacts.activities.ActionBarAdapter.TabState;
+import com.android.contacts.common.Experiments;
import com.android.contacts.common.activity.RequestPermissionsActivity;
import com.android.contacts.common.compat.CompatUtils;
import com.android.contacts.common.interactions.ImportExportDialogFragment;
@@ -74,6 +79,7 @@
import com.android.contacts.common.util.Constants;
import com.android.contacts.common.util.ImplicitIntentsUtil;
import com.android.contacts.common.widget.FloatingActionButtonController;
+import com.android.contacts.commonbind.experiments.Flags;
import com.android.contacts.editor.EditorIntents;
import com.android.contacts.interactions.ContactDeletionInteraction;
import com.android.contacts.interactions.ContactMultiDeletionInteraction;
@@ -87,6 +93,7 @@
import com.android.contacts.list.OnContactsUnavailableActionListener;
import com.android.contacts.quickcontact.QuickContactActivity;
import com.android.contacts.util.DialogManager;
+import com.android.contacts.util.SyncUtil;
import java.util.List;
import java.util.Locale;
@@ -164,6 +171,53 @@
private final int mInstanceId;
private static final AtomicInteger sNextInstanceId = new AtomicInteger();
+ private Object mStatusChangeListenerHandle;
+
+ private final Handler mHandler = new Handler();
+
+ private SyncStatusObserver mSyncStatusObserver = new SyncStatusObserver() {
+ public void onStatusChanged(int which) {
+ mHandler.post(new Runnable() {
+ public void run() {
+ onSyncStateUpdated();
+ }
+ });
+ }
+ };
+
+ // Update sync status for accounts in current ContactListFilter
+ private void onSyncStateUpdated() {
+ if (mActionBarAdapter.isSearchMode() || mActionBarAdapter.isSelectionMode()) {
+ return;
+ }
+
+ final ContactListFilter filter = mContactListFilterController.getFilter();
+ if (filter != null) {
+ final SwipeRefreshLayout swipeRefreshLayout = mAllFragment.getSwipeRefreshLayout();
+ if (swipeRefreshLayout == null) {
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Can not load swipeRefreshLayout, swipeRefreshLayout is null");
+ }
+ return;
+ }
+
+ final List<AccountWithDataSet> accounts = AccountTypeManager.getInstance(this)
+ .getAccounts(/* contactsWritableOnly */ true);
+ final List<Account> syncableAccounts = filter.getSyncableAccounts(accounts);
+ // If one of the accounts is active or pending, use spinning circle to indicate one of
+ // the syncs is in progress.
+ if (syncableAccounts != null && syncableAccounts.size() > 0) {
+ for (Account account: syncableAccounts) {
+ if (SyncUtil.isSyncStatusPendingOrActive(account)) {
+ swipeRefreshLayout.setRefreshing(true);
+ return;
+ }
+ }
+ }
+ swipeRefreshLayout.setRefreshing(false);
+ }
+ }
+
public PeopleActivity() {
mInstanceId = sNextInstanceId.getAndIncrement();
mIntentResolver = new ContactsIntentResolver(this);
@@ -397,6 +451,11 @@
mOptionsMenuContactsAvailable = false;
mProviderStatusWatcher.stop();
super.onPause();
+
+ if (Flags.getInstance(this).getBoolean(Experiments.PULL_TO_REFRESH)) {
+ ContentResolver.removeStatusChangeListener(mStatusChangeListenerHandle);
+ onSyncStateUpdated();
+ }
}
@Override
@@ -416,6 +475,15 @@
// Current tab may have changed since the last onSaveInstanceState(). Make sure
// the actual contents match the tab.
updateFragmentsVisibility();
+
+ if (Flags.getInstance(this).getBoolean(Experiments.PULL_TO_REFRESH)) {
+ mStatusChangeListenerHandle = ContentResolver.addStatusChangeListener(
+ ContentResolver.SYNC_OBSERVER_TYPE_ACTIVE
+ | ContentResolver.SYNC_OBSERVER_TYPE_PENDING
+ | ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS,
+ mSyncStatusObserver);
+ onSyncStateUpdated();
+ }
}
@Override
@@ -566,6 +634,10 @@
updateFragmentsVisibility();
invalidateOptionsMenu();
showFabWithAnimation(shouldShowFabForAccount());
+ // Determine whether the account has pullToRefresh feature
+ if (Flags.getInstance(this).getBoolean(Experiments.PULL_TO_REFRESH)) {
+ setSwipeRefreshLayoutEnabledOrNot(mContactListFilterController.getFilter());
+ }
break;
case ActionBarAdapter.Listener.Action.CHANGE_SEARCH_QUERY:
final String queryString = mActionBarAdapter.getQueryString();
@@ -765,6 +837,10 @@
mCurTransaction = mFragmentManager.beginTransaction();
}
Fragment f = getFragment(position);
+ if (!mIsRecreatedInstance && (f instanceof DefaultContactBrowseListFragment)) {
+ mCurTransaction.setCustomAnimations(android.R.animator.fade_in,
+ android.R.animator.fade_out);
+ }
mCurTransaction.show(f);
// Non primary pages are not visible.
@@ -1420,6 +1496,33 @@
.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
}
}
+
+ // Determine whether the account has pullToRefresh feature
+ if (Flags.getInstance(this).getBoolean(Experiments.PULL_TO_REFRESH)) {
+ setSwipeRefreshLayoutEnabledOrNot(filter);
+ }
+ }
+
+ private void setSwipeRefreshLayoutEnabledOrNot(ContactListFilter filter) {
+ final SwipeRefreshLayout swipeRefreshLayout = mAllFragment.getSwipeRefreshLayout();
+ if (swipeRefreshLayout == null) {
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Can not load swipeRefreshLayout, swipeRefreshLayout is null");
+ }
+ return;
+ }
+
+ swipeRefreshLayout.setRefreshing(false);
+ swipeRefreshLayout.setEnabled(false);
+
+ if (filter != null && !mActionBarAdapter.isSearchMode()
+ && !mActionBarAdapter.isSelectionMode()) {
+ final List<AccountWithDataSet> accounts = AccountTypeManager.getInstance(this)
+ .getAccounts(/* contactsWritableOnly */ true);
+ if (filter.isSyncable(accounts)) {
+ swipeRefreshLayout.setEnabled(true);
+ }
+ }
}
private String getActionBarTitleForAccount(ContactListFilter filter) {
diff --git a/src/com/android/contacts/editor/PhotoSourceDialogFragment.java b/src/com/android/contacts/editor/PhotoSourceDialogFragment.java
index 4b502e5..c2ed3b4 100644
--- a/src/com/android/contacts/editor/PhotoSourceDialogFragment.java
+++ b/src/com/android/contacts/editor/PhotoSourceDialogFragment.java
@@ -26,6 +26,8 @@
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
+import android.view.View;
+import android.widget.TextView;
import java.util.ArrayList;
@@ -91,8 +93,10 @@
};
// Build the AlertDialog
+ final TextView title = (TextView) View.inflate(getActivity(), R.layout.dialog_title, null);
+ title.setText(R.string.menu_change_photo);
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- builder.setTitle(R.string.menu_change_photo);
+ builder.setCustomTitle(title);
builder.setItems(items, clickListener);
builder.setNegativeButton(android.R.string.cancel, /* listener =*/ null);
return builder.create();
diff --git a/src/com/android/contacts/list/ContactBrowseListFragment.java b/src/com/android/contacts/list/ContactBrowseListFragment.java
index 2060068..da33b55 100644
--- a/src/com/android/contacts/list/ContactBrowseListFragment.java
+++ b/src/com/android/contacts/list/ContactBrowseListFragment.java
@@ -92,7 +92,7 @@
private boolean mSelectionVerified;
private int mLastSelectedPosition = -1;
private boolean mRefreshingContactUri;
- private ContactListFilter mFilter;
+ protected ContactListFilter mFilter;
private String mPersistentSelectionPrefix = PERSISTENT_SELECTION_PREFIX;
protected OnContactBrowserActionListener mListener;
diff --git a/src/com/android/contacts/list/DefaultContactBrowseListFragment.java b/src/com/android/contacts/list/DefaultContactBrowseListFragment.java
index 8fdce75..41917a5 100644
--- a/src/com/android/contacts/list/DefaultContactBrowseListFragment.java
+++ b/src/com/android/contacts/list/DefaultContactBrowseListFragment.java
@@ -15,11 +15,16 @@
*/
package com.android.contacts.list;
+import android.accounts.Account;
+import android.content.ContentResolver;
import android.content.Context;
import android.content.CursorLoader;
import android.content.Loader;
import android.database.Cursor;
import android.net.Uri;
+import android.os.Bundle;
+import android.provider.ContactsContract;
+import android.support.v4.widget.SwipeRefreshLayout;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
@@ -29,13 +34,19 @@
import android.widget.TextView;
import com.android.contacts.R;
+import com.android.contacts.common.Experiments;
import com.android.contacts.common.list.ContactListAdapter;
import com.android.contacts.common.list.ContactListFilter;
import com.android.contacts.common.list.ContactListFilterController;
import com.android.contacts.common.list.ContactListItemView;
import com.android.contacts.common.list.DefaultContactListAdapter;
import com.android.contacts.common.list.FavoritesAndContactsLoader;
+import com.android.contacts.common.model.AccountTypeManager;
import com.android.contacts.common.model.account.AccountWithDataSet;
+import com.android.contacts.commonbind.experiments.Flags;
+import com.android.contacts.util.SyncUtil;
+
+import java.util.List;
/**
* Fragment containing a contact list used for browsing (as compared to
@@ -45,6 +56,7 @@
private View mSearchHeaderView;
private View mSearchProgress;
private TextView mSearchProgressText;
+ private SwipeRefreshLayout mSwipeRefreshLayout;
public DefaultContactBrowseListFragment() {
setPhotoLoaderEnabled(true);
@@ -119,6 +131,10 @@
protected void onCreateView(LayoutInflater inflater, ViewGroup container) {
super.onCreateView(inflater, container);
+ if (Flags.getInstance(getActivity()).getBoolean(Experiments.PULL_TO_REFRESH)) {
+ initSwipeRefreshLayout();
+
+ }
// Putting the header view inside a container will allow us to make
// it invisible later. See checkHeaderViewVisibility()
FrameLayout headerContainer = new FrameLayout(inflater.getContext());
@@ -131,6 +147,50 @@
mSearchProgressText = (TextView) mSearchHeaderView.findViewById(R.id.totalContactsText);
}
+ private void initSwipeRefreshLayout() {
+ mSwipeRefreshLayout = (SwipeRefreshLayout) mView.findViewById(R.id.swipe_refresh);
+ if (mSwipeRefreshLayout == null) {
+ return;
+ }
+
+ mSwipeRefreshLayout.setEnabled(true);
+ // Request sync contacts
+ mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
+ @Override
+ public void onRefresh() {
+ syncContacts(mFilter);
+ }
+ });
+ mSwipeRefreshLayout.setColorSchemeResources(
+ R.color.swipe_refresh_color1,
+ R.color.swipe_refresh_color2,
+ R.color.swipe_refresh_color3,
+ R.color.swipe_refresh_color4);
+ mSwipeRefreshLayout.setDistanceToTriggerSync(
+ (int) getResources().getDimension(R.dimen.pull_to_refresh_distance));
+ }
+
+ /** Request sync for Google accounts(not include Google+ accounts) in filter. */
+ private void syncContacts(ContactListFilter filter) {
+ if (filter == null) {
+ return;
+ }
+ final Bundle bundle = new Bundle();
+ bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
+ bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
+
+ final List<AccountWithDataSet> accounts = AccountTypeManager.getInstance(
+ getActivity()).getAccounts(/* contactsWritableOnly */ true);
+ final List<Account> syncableAccounts = filter.getSyncableAccounts(accounts);
+ if (syncableAccounts != null && syncableAccounts.size() > 0) {
+ for (Account account : syncableAccounts) {
+ if (!SyncUtil.isSyncStatusPendingOrActive(account)) {
+ ContentResolver.requestSync(account, ContactsContract.AUTHORITY, bundle);
+ }
+ }
+ }
+ }
+
@Override
protected void setSearchMode(boolean flag) {
super.setSearchMode(flag);
@@ -179,4 +239,8 @@
}
}
}
+
+ public SwipeRefreshLayout getSwipeRefreshLayout() {
+ return mSwipeRefreshLayout;
+ }
}
\ No newline at end of file
diff --git a/src/com/android/contacts/util/SyncUtil.java b/src/com/android/contacts/util/SyncUtil.java
new file mode 100644
index 0000000..0823ba3
--- /dev/null
+++ b/src/com/android/contacts/util/SyncUtil.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2016 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.util;
+
+import android.accounts.Account;
+import android.content.ContentResolver;
+import android.provider.ContactsContract;
+
+/**
+ * Utilities related to sync.
+ */
+public final class SyncUtil {
+ private static final String TAG = "SyncUtil";
+
+ private SyncUtil() {
+ }
+
+ public static final boolean isSyncStatusPendingOrActive(Account account) {
+ return ContentResolver.isSyncPending(account, ContactsContract.AUTHORITY)
+ || ContentResolver.isSyncActive(account, ContactsContract.AUTHORITY);
+ }
+}