diff options
author | Eric Erfanian <erfanian@google.com> | 2017-08-31 06:57:16 -0700 |
---|---|---|
committer | Roland Levillain <rpl@google.com> | 2017-09-04 18:05:19 +0100 |
commit | fc0eb8ccebcc7846db5e8b5c5430070055679bfa (patch) | |
tree | a8a23c3202e4161ffd57a71095a404db1bcf5735 /java/com/android/dialer/app/list | |
parent | ea7b4dc89590ffa3332766a531e0eab6ffb9aebd (diff) |
Update Dialer source to latest internal Google revision.
Previously, Android's Dialer app was developed in an internal Google
source control system and only exported to public during AOSP drops.
The Dialer team is now switching to a public development model similar
to the telephony team.
This CL represents all internal Google changes that were committed to
Dialer between the public O release and today's tip of tree on internal
master. This CL squashes those changes into a single commit.
In subsequent changes, changes will be exported on a per-commit basis.
(cherry picked from commit 2ca4318cc1ee57dda907ba2069bd61d162b1baef
and amended to match paths of dependencies under
prebuilts/maven_repo/bumptech/com/github/bumptech/glide/.)
This CL was generated using these commands from a repository at
stage-stage-master at revision ea7b4dc89590ffa3332766a531e0eab6ffb9aebd
("Merge "Update Dialer source to latest internal Google revision." am: c39ea3c55f -s ours"):
git diff --binary 2ca4318cc1ee57dda907ba2069bd61d162b1baef | git apply -R --index
git commit -c 2ca4318cc1ee57dda907ba2069bd61d162b1baef
Test: make, flash install, run
Change-Id: I529aaeb88535b9533c0ae4ef4e6c1222d4e0f1c8
PiperOrigin-RevId: 167068436
Diffstat (limited to 'java/com/android/dialer/app/list')
9 files changed, 87 insertions, 36 deletions
diff --git a/java/com/android/dialer/app/list/DialtactsPagerAdapter.java b/java/com/android/dialer/app/list/DialtactsPagerAdapter.java index 822aa789f..1fbf0f01a 100644 --- a/java/com/android/dialer/app/list/DialtactsPagerAdapter.java +++ b/java/com/android/dialer/app/list/DialtactsPagerAdapter.java @@ -24,13 +24,12 @@ import android.support.v13.app.FragmentPagerAdapter; import android.view.ViewGroup; import com.android.dialer.app.calllog.CallLogFragment; import com.android.dialer.app.calllog.VisualVoicemailCallLogFragment; -import com.android.dialer.calllog.CallLogComponent; -import com.android.dialer.calllog.CallLogFramework; -import com.android.dialer.calllog.ui.NewCallLogFragment; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.configprovider.ConfigProviderBindings; import com.android.dialer.contactsfragment.ContactsFragment; +import com.android.dialer.contactsfragment.ContactsFragment.ClickAction; +import com.android.dialer.contactsfragment.ContactsFragment.Header; import com.android.dialer.database.CallLogQueryHandler; import com.android.dialer.speeddial.SpeedDialFragment; import com.android.dialer.util.ViewUtil; @@ -58,12 +57,10 @@ public class DialtactsPagerAdapter extends FragmentPagerAdapter { private final List<Fragment> fragments = new ArrayList<>(); private final String[] tabTitles; private final boolean useNewSpeedDialTab; - private final boolean useNewCallLogTab; private final boolean useNewContactsTab; private OldSpeedDialFragment oldSpeedDialFragment; private SpeedDialFragment speedDialFragment; private CallLogFragment callLogFragment; - private NewCallLogFragment newCallLogFragment; private AllContactsFragment oldContactsFragment; private ContactsFragment contactsFragment; private CallLogFragment voicemailFragment; @@ -75,8 +72,6 @@ public class DialtactsPagerAdapter extends FragmentPagerAdapter { super(fm); useNewSpeedDialTab = ConfigProviderBindings.get(context).getBoolean("enable_new_favorites_tab", false); - CallLogFramework callLogFramework = CallLogComponent.get(context).callLogFramework(); - useNewCallLogTab = callLogFramework.isNewCallLogEnabled(context); useNewContactsTab = ConfigProviderBindings.get(context).getBoolean("enable_new_contacts_tab", true); this.tabTitles = tabTitles; @@ -106,21 +101,15 @@ public class DialtactsPagerAdapter extends FragmentPagerAdapter { return oldSpeedDialFragment; } case TAB_INDEX_HISTORY: - if (useNewCallLogTab) { - if (newCallLogFragment == null) { - newCallLogFragment = new NewCallLogFragment(); - } - return newCallLogFragment; - } else { - if (callLogFragment == null) { - callLogFragment = new CallLogFragment(CallLogQueryHandler.CALL_TYPE_ALL); - } - return callLogFragment; + if (callLogFragment == null) { + callLogFragment = new CallLogFragment(CallLogQueryHandler.CALL_TYPE_ALL); } + return callLogFragment; case TAB_INDEX_ALL_CONTACTS: if (useNewContactsTab) { if (contactsFragment == null) { - contactsFragment = new ContactsFragment(); + contactsFragment = + ContactsFragment.newInstance(Header.ADD_CONTACT, ClickAction.OPEN_CONTACT_CARD); } return contactsFragment; } else { @@ -156,8 +145,6 @@ public class DialtactsPagerAdapter extends FragmentPagerAdapter { speedDialFragment = (SpeedDialFragment) fragment; } else if (fragment instanceof CallLogFragment && position == TAB_INDEX_HISTORY) { callLogFragment = (CallLogFragment) fragment; - } else if (fragment instanceof NewCallLogFragment) { - newCallLogFragment = (NewCallLogFragment) fragment; } else if (fragment instanceof ContactsFragment) { contactsFragment = (ContactsFragment) fragment; } else if (fragment instanceof AllContactsFragment) { diff --git a/java/com/android/dialer/app/list/ListsFragment.java b/java/com/android/dialer/app/list/ListsFragment.java index dbb6c8b5c..86a3d2fbb 100644 --- a/java/com/android/dialer/app/list/ListsFragment.java +++ b/java/com/android/dialer/app/list/ListsFragment.java @@ -98,7 +98,7 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis LogUtil.d("ListsFragment.onCreate", null); Trace.beginSection(TAG + " onCreate"); super.onCreate(savedInstanceState); - mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); + mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext()); Trace.endSection(); } diff --git a/java/com/android/dialer/app/list/OldSpeedDialFragment.java b/java/com/android/dialer/app/list/OldSpeedDialFragment.java index 05d017b28..afc7c133b 100644 --- a/java/com/android/dialer/app/list/OldSpeedDialFragment.java +++ b/java/com/android/dialer/app/list/OldSpeedDialFragment.java @@ -45,13 +45,13 @@ import android.widget.FrameLayout; import android.widget.FrameLayout.LayoutParams; import android.widget.ImageView; import android.widget.ListView; -import com.android.contacts.common.ContactPhotoManager; import com.android.contacts.common.ContactTileLoaderFactory; import com.android.contacts.common.list.ContactTileView; import com.android.contacts.common.list.OnPhoneNumberPickerActionListener; import com.android.dialer.app.R; import com.android.dialer.callintent.CallSpecificAppData; import com.android.dialer.common.LogUtil; +import com.android.dialer.contactphoto.ContactPhotoManager; import com.android.dialer.util.PermissionsUtil; import com.android.dialer.util.ViewUtil; import com.android.dialer.widget.EmptyContentView; diff --git a/java/com/android/dialer/app/list/PhoneFavoriteTileView.java b/java/com/android/dialer/app/list/PhoneFavoriteTileView.java index 30870eb39..e0961be4b 100644 --- a/java/com/android/dialer/app/list/PhoneFavoriteTileView.java +++ b/java/com/android/dialer/app/list/PhoneFavoriteTileView.java @@ -18,20 +18,23 @@ package com.android.dialer.app.list; import android.content.ClipData; import android.content.Context; +import android.net.Uri; import android.provider.ContactsContract.PinnedPositions; import android.text.TextUtils; import android.util.AttributeSet; import android.view.View; import android.widget.ImageView; -import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest; import com.android.contacts.common.MoreContactUtils; -import com.android.contacts.common.lettertiles.LetterTileDrawable; import com.android.contacts.common.list.ContactEntry; import com.android.contacts.common.list.ContactTileView; +import com.android.contacts.common.model.ContactLoader; import com.android.dialer.app.R; import com.android.dialer.callintent.CallInitiationType; import com.android.dialer.callintent.CallSpecificAppData; import com.android.dialer.callintent.SpeedDialContactType; +import com.android.dialer.common.LogUtil; +import com.android.dialer.contactphoto.ContactPhotoManager.DefaultImageRequest; +import com.android.dialer.lettertile.LetterTileDrawable; import com.android.dialer.logging.InteractionEvent; import com.android.dialer.logging.Logger; @@ -94,11 +97,11 @@ public abstract class PhoneFavoriteTileView extends ContactTileView { isPinned = (entry.pinned != PinnedPositions.UNPINNED); isStarred = entry.isFavorite; if (entry != null) { + sendViewNotification(getContext(), entry.lookupUri); // Grab the phone-number to call directly. See {@link onClick()}. mPhoneNumberString = entry.phoneNumber; - // If this is a blank entry, don't show anything. - // TODO krelease: Just hide the view for now. For this to truly look like an empty row + // If this is a blank entry, don't show anything. For this to truly look like an empty row // the entire ContactTileRow needs to be hidden. if (entry == ContactEntry.BLANK_ENTRY) { setVisibility(View.INVISIBLE); @@ -126,6 +129,7 @@ public abstract class PhoneFavoriteTileView extends ContactTileView { CallSpecificAppData.Builder callSpecificAppData = CallSpecificAppData.newBuilder() + .setAllowAssistedDialing(true) .setCallInitiationType(CallInitiationType.Type.SPEED_DIAL) .setSpeedDialContactPosition(position); if (isStarred) { @@ -186,4 +190,22 @@ public abstract class PhoneFavoriteTileView extends ContactTileView { public void setPosition(int position) { this.position = position; } + + /** + * Send a notification using a {@link ContactLoader} to inform the sync adapter that we are + * viewing a particular contact, so that it can download the high-res photo. + */ + private static void sendViewNotification(Context context, Uri contactUri) { + ContactLoader loader = new ContactLoader(context, contactUri, true /* postViewNotification */); + loader.registerListener( + 0, + (loader1, contact) -> { + try { + loader1.reset(); + } catch (RuntimeException e) { + LogUtil.e("PhoneFavoriteTileView.onLoadComplete", "error resetting loader", e); + } + }); + loader.startLoading(); + } } diff --git a/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java b/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java index dbd601a7d..cd5712eed 100644 --- a/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java +++ b/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java @@ -34,13 +34,13 @@ import android.util.LongSparseArray; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; -import com.android.contacts.common.ContactPhotoManager; import com.android.contacts.common.ContactTileLoaderFactory; import com.android.contacts.common.list.ContactEntry; import com.android.contacts.common.list.ContactTileView; import com.android.contacts.common.preference.ContactsPreferences; import com.android.dialer.app.R; import com.android.dialer.common.LogUtil; +import com.android.dialer.contactphoto.ContactPhotoManager; import com.android.dialer.lightbringer.Lightbringer; import com.android.dialer.lightbringer.LightbringerComponent; import com.android.dialer.logging.InteractionEvent; diff --git a/java/com/android/dialer/app/list/RegularSearchFragment.java b/java/com/android/dialer/app/list/RegularSearchFragment.java index 728948bfc..73120c547 100644 --- a/java/com/android/dialer/app/list/RegularSearchFragment.java +++ b/java/com/android/dialer/app/list/RegularSearchFragment.java @@ -18,7 +18,10 @@ package com.android.dialer.app.list; import static android.Manifest.permission.READ_CONTACTS; import android.app.Activity; +import android.content.Context; import android.content.pm.PackageManager; +import android.os.Bundle; +import android.support.annotation.Nullable; import android.support.v13.app.FragmentCompat; import android.view.LayoutInflater; import android.view.ViewGroup; @@ -27,7 +30,11 @@ import com.android.contacts.common.list.PinnedHeaderListView; import com.android.dialer.app.R; import com.android.dialer.callintent.CallInitiationType; import com.android.dialer.common.LogUtil; +import com.android.dialer.common.concurrent.DialerExecutor; +import com.android.dialer.common.concurrent.DialerExecutor.Worker; +import com.android.dialer.common.concurrent.DialerExecutors; import com.android.dialer.phonenumbercache.CachedNumberLookupService; +import com.android.dialer.phonenumbercache.CachedNumberLookupService.CachedContactInfo; import com.android.dialer.phonenumbercache.PhoneNumberCache; import com.android.dialer.util.PermissionsUtil; import com.android.dialer.widget.EmptyContentView; @@ -43,6 +50,8 @@ public class RegularSearchFragment extends SearchFragment private static final int SEARCH_DIRECTORY_RESULT_LIMIT = 5; protected String mPermissionToRequest; + private DialerExecutor<CachedContactInfo> addContactTask; + public RegularSearchFragment() { configureDirectorySearch(); } @@ -53,6 +62,18 @@ public class RegularSearchFragment extends SearchFragment } @Override + public void onCreate(Bundle savedState) { + super.onCreate(savedState); + + addContactTask = + DialerExecutors.createUiTaskBuilder( + getFragmentManager(), + "RegularSearchFragment.addContact", + new AddContactWorker(getContext().getApplicationContext())) + .build(); + } + + @Override protected void onCreateView(LayoutInflater inflater, ViewGroup container) { super.onCreateView(inflater, container); ((PinnedHeaderListView) getListView()).setScrollToSectionOnHeaderTouch(true); @@ -73,8 +94,9 @@ public class RegularSearchFragment extends SearchFragment PhoneNumberCache.get(getContext()).getCachedNumberLookupService(); if (cachedNumberLookupService != null) { final RegularSearchListAdapter adapter = (RegularSearchListAdapter) getAdapter(); - cachedNumberLookupService.addContact( - getContext(), adapter.getContactInfo(cachedNumberLookupService, position)); + CachedContactInfo cachedContactInfo = + adapter.getContactInfo(cachedNumberLookupService, position); + addContactTask.executeSerial(cachedContactInfo); } } @@ -152,4 +174,24 @@ public class RegularSearchFragment extends SearchFragment boolean isNearbyPlacesSearchEnabled(); } + + private static class AddContactWorker implements Worker<CachedContactInfo, Void> { + + private final Context appContext; + + private AddContactWorker(Context appContext) { + this.appContext = appContext; + } + + @Nullable + @Override + public Void doInBackground(@Nullable CachedContactInfo contactInfo) throws Throwable { + CachedNumberLookupService cachedNumberLookupService = + PhoneNumberCache.get(appContext).getCachedNumberLookupService(); + if (cachedNumberLookupService != null) { + cachedNumberLookupService.addContact(appContext, contactInfo); + } + return null; + } + } } diff --git a/java/com/android/dialer/app/list/SearchFragment.java b/java/com/android/dialer/app/list/SearchFragment.java index 00a2708a1..e21e073bd 100644 --- a/java/com/android/dialer/app/list/SearchFragment.java +++ b/java/com/android/dialer/app/list/SearchFragment.java @@ -38,10 +38,10 @@ import com.android.contacts.common.list.OnPhoneNumberPickerActionListener; import com.android.contacts.common.list.PhoneNumberPickerFragment; import com.android.dialer.animation.AnimUtils; import com.android.dialer.app.R; -import com.android.dialer.app.dialpad.DialpadFragment.ErrorDialogFragment; import com.android.dialer.app.widget.DialpadSearchEmptyContentView; import com.android.dialer.callintent.CallSpecificAppData; import com.android.dialer.common.LogUtil; +import com.android.dialer.dialpadview.DialpadFragment.ErrorDialogFragment; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.util.DialerUtils; diff --git a/java/com/android/dialer/app/list/SmartDialNumberListAdapter.java b/java/com/android/dialer/app/list/SmartDialNumberListAdapter.java index 566a15d53..3b00c7643 100644 --- a/java/com/android/dialer/app/list/SmartDialNumberListAdapter.java +++ b/java/com/android/dialer/app/list/SmartDialNumberListAdapter.java @@ -20,9 +20,9 @@ import android.database.Cursor; import android.support.annotation.NonNull; import android.telephony.PhoneNumberUtils; import android.text.TextUtils; -import android.util.Log; import com.android.contacts.common.list.ContactListItemView; -import com.android.dialer.app.dialpad.SmartDialCursorLoader; +import com.android.dialer.common.LogUtil; +import com.android.dialer.dialpadview.SmartDialCursorLoader; import com.android.dialer.smartdial.SmartDialMatchPosition; import com.android.dialer.smartdial.SmartDialNameMatcher; import com.android.dialer.smartdial.SmartDialPrefix; @@ -43,14 +43,14 @@ public class SmartDialNumberListAdapter extends DialerPhoneNumberListAdapter { setShortcutEnabled(SmartDialNumberListAdapter.SHORTCUT_DIRECT_CALL, false); if (DEBUG) { - Log.v(TAG, "Constructing List Adapter"); + LogUtil.v(TAG, "Constructing List Adapter"); } } /** Sets query for the SmartDialCursorLoader. */ public void configureLoader(SmartDialCursorLoader loader) { if (DEBUG) { - Log.v(TAG, "Configure Loader with query" + getQueryString()); + LogUtil.v(TAG, "Configure Loader with query" + getQueryString()); } if (getQueryString() == null) { @@ -77,7 +77,7 @@ public class SmartDialNumberListAdapter extends DialerPhoneNumberListAdapter { for (SmartDialMatchPosition match : nameMatches) { view.addNameHighlightSequence(match.start, match.end); if (DEBUG) { - Log.v( + LogUtil.v( TAG, cursor.getString(PhoneQuery.DISPLAY_NAME) + " " diff --git a/java/com/android/dialer/app/list/SmartDialSearchFragment.java b/java/com/android/dialer/app/list/SmartDialSearchFragment.java index 2ebc06bc3..e97a16c19 100644 --- a/java/com/android/dialer/app/list/SmartDialSearchFragment.java +++ b/java/com/android/dialer/app/list/SmartDialSearchFragment.java @@ -28,10 +28,10 @@ import android.os.Bundle; import android.support.v13.app.FragmentCompat; import com.android.contacts.common.list.ContactEntryListAdapter; import com.android.dialer.app.R; -import com.android.dialer.app.dialpad.SmartDialCursorLoader; import com.android.dialer.callintent.CallInitiationType; import com.android.dialer.common.LogUtil; import com.android.dialer.database.DialerDatabaseHelper; +import com.android.dialer.dialpadview.SmartDialCursorLoader; import com.android.dialer.util.PermissionsUtil; import com.android.dialer.widget.EmptyContentView; import java.util.Arrays; |