diff options
author | Eric Erfanian <erfanian@google.com> | 2017-05-05 15:23:13 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-05-05 15:23:13 +0000 |
commit | 300a8683b9c28424fb0f0c571a0abe128c461f69 (patch) | |
tree | 3a325b0effac02fbd228b8ddf2f96589e5df72cd /java/com/android/dialer/app/calllog | |
parent | d67f1627521b174f12e0c247f154c7c93c5e408e (diff) | |
parent | 10b34a5ebf12e97ecba0caf3c8e30b476b038a96 (diff) |
Update Dialer to V10 RC16
am: 10b34a5ebf
Change-Id: Iea3e96ccdeaf1fa796ceca702cace82ca20f298c
Diffstat (limited to 'java/com/android/dialer/app/calllog')
8 files changed, 97 insertions, 45 deletions
diff --git a/java/com/android/dialer/app/calllog/BlockReportSpamListener.java b/java/com/android/dialer/app/calllog/BlockReportSpamListener.java index 740d6b361..28082df2b 100644 --- a/java/com/android/dialer/app/calllog/BlockReportSpamListener.java +++ b/java/com/android/dialer/app/calllog/BlockReportSpamListener.java @@ -20,6 +20,7 @@ import android.app.FragmentManager; import android.content.ContentValues; import android.content.Context; import android.net.Uri; +import android.support.annotation.NonNull; import android.support.v7.widget.RecyclerView; import com.android.dialer.blocking.BlockReportSpamDialogs; import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler; @@ -55,7 +56,7 @@ public class BlockReportSpamListener implements CallLogListItemViewHolder.OnClic final String number, final String countryIso, final int callType, - final ContactSource.Type contactSourceType) { + @NonNull final ContactSource.Type contactSourceType) { BlockReportSpamDialogs.BlockReportSpamDialogFragment.newInstance( displayNumber, Spam.get(mContext).isDialogReportSpamCheckedByDefault(), @@ -99,7 +100,7 @@ public class BlockReportSpamListener implements CallLogListItemViewHolder.OnClic final String number, final String countryIso, final int callType, - final ContactSource.Type contactSourceType) { + @NonNull final ContactSource.Type contactSourceType) { BlockReportSpamDialogs.BlockDialogFragment.newInstance( displayNumber, Spam.get(mContext).isSpamEnabled(), diff --git a/java/com/android/dialer/app/calllog/CallLogAdapter.java b/java/com/android/dialer/app/calllog/CallLogAdapter.java index d4872d5b3..b433e6529 100644 --- a/java/com/android/dialer/app/calllog/CallLogAdapter.java +++ b/java/com/android/dialer/app/calllog/CallLogAdapter.java @@ -77,6 +77,7 @@ import com.android.dialer.enrichedcall.historyquery.proto.HistoryResult; import com.android.dialer.lightbringer.Lightbringer; import com.android.dialer.lightbringer.LightbringerComponent; import com.android.dialer.lightbringer.LightbringerListener; +import com.android.dialer.logging.ContactSource; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.phonenumbercache.CallLogQuery; @@ -177,13 +178,14 @@ public class CallLogAdapter extends GroupingListAdapter } }; + // Todo (uabdullah): Use plurals http://b/37751831 private void showDeleteSelectedItemsDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); Assert.checkArgument(selectedItems.size() > 0); String voicemailString = selectedItems.size() == 1 ? mActivity.getResources().getString(R.string.voicemailMultiSelectVoicemail) - : mActivity.getResources().getString(R.string.voicemailMultiSelectVoicemail); + : mActivity.getResources().getString(R.string.voicemailMultiSelectVoicemails); String deleteVoicemailTitle = mActivity .getResources() @@ -228,14 +230,15 @@ public class CallLogAdapter extends GroupingListAdapter if (ConfigProviderBindings.get(v.getContext()) .getBoolean("enable_call_log_multiselect", true) && mVoicemailPlaybackPresenter != null) { - if (v.getId() == R.id.primary_action_view) { + if (v.getId() == R.id.primary_action_view || v.getId() == R.id.quick_contact_photo) { if (mActionMode == null) { mActionMode = v.startActionMode(mActionModeCallback); } CallLogListItemViewHolder viewHolder = (CallLogListItemViewHolder) v.getTag(); viewHolder.quickContactView.setVisibility(View.GONE); viewHolder.checkBoxView.setVisibility(View.VISIBLE); - return false; + mExpandCollapseListener.onClick(v); + return true; } } return true; @@ -522,6 +525,7 @@ public class CallLogAdapter extends GroupingListAdapter viewHolder.callLogEntryView.setTag(viewHolder); viewHolder.primaryActionView.setTag(viewHolder); + viewHolder.quickContactView.setTag(viewHolder); return viewHolder; } @@ -630,7 +634,7 @@ public class CallLogAdapter extends GroupingListAdapter @Override protected Boolean doInBackground(Void... params) { views.blockId = - mFilteredNumberAsyncQueryHandler.getBlockedIdSynchronousForCalllogOnly( + mFilteredNumberAsyncQueryHandler.getBlockedIdSynchronous( views.number, views.countryIso); details.isBlocked = views.blockId != null; if (isCancelled()) { @@ -872,14 +876,25 @@ public class CallLogAdapter extends GroupingListAdapter } views.info = info; - views.numberType = - (String) - Phone.getTypeLabel(mActivity.getResources(), details.numberType, details.numberLabel); + views.numberType = getNumberType(mActivity.getResources(), details); mCallLogListItemHelper.updatePhoneCallDetails(details); return true; } + private static String getNumberType(Resources res, PhoneCallDetails details) { + // Label doesn't make much sense if the information is coming from CNAP or Cequint Caller ID. + if (details.sourceType == ContactSource.Type.SOURCE_TYPE_CNAP + || details.sourceType == ContactSource.Type.SOURCE_TYPE_CEQUINT_CALLER_ID) { + return ""; + } + // Returns empty label instead of "custom" if the custom label is empty. + if (details.numberType == Phone.TYPE_CUSTOM && TextUtils.isEmpty(details.numberLabel)) { + return ""; + } + return (String) Phone.getTypeLabel(res, details.numberType, details.numberLabel); + } + /** * Render item view given position. This is running on UI thread so DO NOT put any expensive * operation into it. diff --git a/java/com/android/dialer/app/calllog/CallLogAsyncTaskUtil.java b/java/com/android/dialer/app/calllog/CallLogAsyncTaskUtil.java index 2aedb6f17..a58357448 100644 --- a/java/com/android/dialer/app/calllog/CallLogAsyncTaskUtil.java +++ b/java/com/android/dialer/app/calllog/CallLogAsyncTaskUtil.java @@ -83,12 +83,7 @@ public class CallLogAsyncTaskUtil { new AsyncTask<Void, Void, Void>() { @Override public Void doInBackground(Void... params) { - ContentValues values = new ContentValues(); - values.put(Voicemails.DELETED, "1"); - context.getContentResolver().update(voicemailUri, values, null, null); - // TODO(b/35440541): check which source package is changed. Don't need - // to upload changes on foreign voicemails, they will get a PROVIDER_CHANGED - uploadVoicemailLocalChangesToServer(context); + deleteVoicemailSynchronous(context, voicemailUri); return null; } @@ -101,6 +96,15 @@ public class CallLogAsyncTaskUtil { }); } + public static void deleteVoicemailSynchronous(Context context, Uri voicemailUri) { + ContentValues values = new ContentValues(); + values.put(Voicemails.DELETED, "1"); + context.getContentResolver().update(voicemailUri, values, null, null); + // TODO(b/35440541): check which source package is changed. Don't need + // to upload changes on foreign voicemails, they will get a PROVIDER_CHANGED + uploadVoicemailLocalChangesToServer(context); + } + public static void markCallAsRead(@NonNull final Context context, @NonNull final long[] callIds) { if (!PermissionsUtil.hasPhonePermissions(context)) { return; diff --git a/java/com/android/dialer/app/calllog/CallLogFragment.java b/java/com/android/dialer/app/calllog/CallLogFragment.java index fcc34ebef..874aeeac8 100644 --- a/java/com/android/dialer/app/calllog/CallLogFragment.java +++ b/java/com/android/dialer/app/calllog/CallLogFragment.java @@ -41,7 +41,6 @@ import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import com.android.contacts.common.GeoUtil; import com.android.dialer.app.Bindings; import com.android.dialer.app.R; import com.android.dialer.app.calllog.calllogcache.CallLogCache; @@ -56,6 +55,7 @@ import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.database.CallLogQueryHandler; +import com.android.dialer.location.GeoUtil; import com.android.dialer.phonenumbercache.ContactInfoHelper; import com.android.dialer.util.PermissionsUtil; @@ -376,6 +376,7 @@ public class CallLogFragment extends Fragment super.onStop(); mAdapter.onStop(); + mContactInfoCache.stop(); } @Override @@ -398,8 +399,6 @@ public class CallLogFragment extends Fragment outState.putBoolean(KEY_HAS_READ_CALL_LOG_PERMISSION, mHasReadCallLogPermission); outState.putBoolean(KEY_REFRESH_DATA_REQUIRED, mRefreshDataRequired); - mContactInfoCache.stop(); - mAdapter.onSaveInstanceState(outState); } diff --git a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java index b57f9b04a..278caba92 100644 --- a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java +++ b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java @@ -17,6 +17,7 @@ package com.android.dialer.app.calllog; import android.app.Activity; +import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.content.res.Resources; @@ -26,6 +27,7 @@ import android.provider.CallLog; import android.provider.CallLog.Calls; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.support.v7.widget.CardView; import android.support.v7.widget.RecyclerView; @@ -43,6 +45,7 @@ import android.widget.ImageButton; import android.widget.ImageView; import android.widget.QuickContactBadge; import android.widget.TextView; +import android.widget.Toast; import com.android.contacts.common.ClipboardUtils; import com.android.contacts.common.ContactPhotoManager; import com.android.contacts.common.compat.PhoneNumberUtilsCompat; @@ -182,7 +185,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder * The name or number associated with the call. Cached here for use when setting content * descriptions on buttons in the actions ViewStub when it is inflated. */ - public CharSequence nameOrNumber; + @Nullable public CharSequence nameOrNumber; /** * The call type or Location associated with the call. Cached here for use when setting text for a * voicemail log's call button @@ -257,6 +260,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder primaryActionView.setOnClickListener(mExpandCollapseListener); if (mVoicemailPlaybackPresenter != null) { primaryActionView.setOnLongClickListener(longPressListener); + quickContactView.setOnLongClickListener(longPressListener); } else { primaryActionView.setOnCreateContextMenuListener(this); } @@ -788,17 +792,38 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder mVoicemailPlaybackPresenter.shareVoicemail(); } else { logCallLogAction(view.getId()); + final IntentProvider intentProvider = (IntentProvider) view.getTag(); - if (intentProvider != null) { - final Intent intent = intentProvider.getIntent(mContext); - // See IntentProvider.getCallDetailIntentProvider() for why this may be null. - if (intent != null) { - DialerUtils.startActivityWithErrorToast(mContext, intent); - } + if (intentProvider == null) { + return; + } + + final Intent intent = intentProvider.getIntent(mContext); + // See IntentProvider.getCallDetailIntentProvider() for why this may be null. + if (intent == null) { + return; + } + + // We check to see if we are starting a Lightbringer intent. The reason is Lightbringer + // intents need to be started using startActivityForResult instead of the usual startActivity + String packageName = intent.getPackage(); + if (packageName != null && packageName.equals(getLightbringer().getPackageName(mContext))) { + startLightbringerActivity(intent); + } else { + DialerUtils.startActivityWithErrorToast(mContext, intent); } } } + private void startLightbringerActivity(Intent intent) { + try { + Activity activity = (Activity) mContext; + activity.startActivityForResult(intent, DialtactsActivity.ACTIVITY_REQUEST_CODE_LIGHTBRINGER); + } catch (ActivityNotFoundException e) { + Toast.makeText(mContext, R.string.activity_not_available, Toast.LENGTH_SHORT).show(); + } + } + private CallComposerContact buildContact() { CallComposerContact.Builder contact = CallComposerContact.newBuilder(); contact.setPhotoId(info.photoId); @@ -808,7 +833,9 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder if (info.lookupUri != null) { contact.setContactUri(info.lookupUri.toString()); } - contact.setNameOrNumber((String) nameOrNumber); + if (nameOrNumber != null) { + contact.setNameOrNumber((String) nameOrNumber); + } contact.setContactType(getContactType()); contact.setNumber(number); /* second line of contact view. */ diff --git a/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java b/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java index 79a32afe3..4127d1f0b 100644 --- a/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java +++ b/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java @@ -32,10 +32,10 @@ import android.support.annotation.WorkerThread; import android.support.v4.os.UserManagerCompat; import android.telephony.PhoneNumberUtils; import android.text.TextUtils; -import com.android.contacts.common.GeoUtil; import com.android.dialer.app.R; import com.android.dialer.calllogutils.PhoneNumberDisplayUtil; import com.android.dialer.common.LogUtil; +import com.android.dialer.location.GeoUtil; import com.android.dialer.notification.GroupedNotificationUtil; import com.android.dialer.phonenumbercache.ContactInfo; import com.android.dialer.phonenumbercache.ContactInfoHelper; diff --git a/java/com/android/dialer/app/calllog/DefaultVoicemailNotifier.java b/java/com/android/dialer/app/calllog/DefaultVoicemailNotifier.java index 0007d1863..d67f12266 100644 --- a/java/com/android/dialer/app/calllog/DefaultVoicemailNotifier.java +++ b/java/com/android/dialer/app/calllog/DefaultVoicemailNotifier.java @@ -31,6 +31,7 @@ import android.os.PersistableBundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; +import android.support.annotation.WorkerThread; import android.support.v4.os.BuildCompat; import android.support.v4.util.Pair; import android.telecom.PhoneAccount; @@ -48,6 +49,7 @@ import com.android.dialer.app.R; import com.android.dialer.app.calllog.CallLogNotificationsQueryHelper.NewCall; import com.android.dialer.app.contactinfo.ContactPhotoLoader; import com.android.dialer.app.list.DialtactsPagerAdapter; +import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler; import com.android.dialer.blocking.FilteredNumbersUtil; import com.android.dialer.calllogutils.PhoneAccountUtils; import com.android.dialer.common.Assert; @@ -76,17 +78,24 @@ public class DefaultVoicemailNotifier { private final Context context; private final CallLogNotificationsQueryHelper queryHelper; + private final FilteredNumberAsyncQueryHandler filteredNumberAsyncQueryHandler; @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) - DefaultVoicemailNotifier(Context context, CallLogNotificationsQueryHelper queryHelper) { + DefaultVoicemailNotifier( + Context context, + CallLogNotificationsQueryHelper queryHelper, + FilteredNumberAsyncQueryHandler filteredNumberAsyncQueryHandler) { this.context = context; this.queryHelper = queryHelper; + this.filteredNumberAsyncQueryHandler = filteredNumberAsyncQueryHandler; } /** Returns an instance of {@link DefaultVoicemailNotifier}. */ public static DefaultVoicemailNotifier getInstance(Context context) { return new DefaultVoicemailNotifier( - context, CallLogNotificationsQueryHelper.getInstance(context)); + context, + CallLogNotificationsQueryHelper.getInstance(context), + new FilteredNumberAsyncQueryHandler(context)); } /** @@ -97,7 +106,9 @@ public class DefaultVoicemailNotifier { * * <p>It is not safe to call this method from the main thread. */ + @WorkerThread public void updateNotification() { + Assert.isWorkerThread(); // Lookup the list of new voicemails to include in the notification. final List<NewCall> newCalls = queryHelper.getNewVoicemails(); @@ -121,13 +132,15 @@ public class DefaultVoicemailNotifier { NewCall newCall = itr.next(); // Skip notifying for numbers which are blocked. - if (FilteredNumbersUtil.shouldBlockVoicemail( - context, newCall.number, newCall.countryIso, newCall.dateMs)) { + if (!FilteredNumbersUtil.hasRecentEmergencyCall(context) + && filteredNumberAsyncQueryHandler.getBlockedIdSynchronous( + newCall.number, newCall.countryIso) + != null) { itr.remove(); if (newCall.voicemailUri != null) { // Delete the voicemail. - context.getContentResolver().delete(newCall.voicemailUri, null, null); + CallLogAsyncTaskUtil.deleteVoicemailSynchronous(context, newCall.voicemailUri); } continue; } diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java b/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java index 7c25e7d39..1440218fb 100644 --- a/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java +++ b/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java @@ -46,22 +46,18 @@ public class VisualVoicemailCallLogFragment extends CallLogFragment { } @Override - public void onCreate(Bundle state) { - super.onCreate(state); - mVoicemailPlaybackPresenter = VoicemailPlaybackPresenter.getInstance(getActivity(), state); - getActivity() - .getContentResolver() - .registerContentObserver( - VoicemailContract.Status.CONTENT_URI, true, mVoicemailStatusObserver); - } - - @Override protected VoicemailPlaybackPresenter getVoicemailPlaybackPresenter() { return mVoicemailPlaybackPresenter; } @Override public void onActivityCreated(Bundle savedInstanceState) { + mVoicemailPlaybackPresenter = + VoicemailPlaybackPresenter.getInstance(getActivity(), savedInstanceState); + getActivity() + .getContentResolver() + .registerContentObserver( + VoicemailContract.Status.CONTENT_URI, true, mVoicemailStatusObserver); super.onActivityCreated(savedInstanceState); mVoicemailErrorManager = new VoicemailErrorManager(getContext(), getAdapter().getAlertManager(), mModalAlertManager); @@ -132,9 +128,6 @@ public class VisualVoicemailCallLogFragment extends CallLogFragment { public void onNotVisible() { LogUtil.enterBlock("VisualVoicemailCallLogFragment.onPageUnselected"); super.onNotVisible(); - if (getAdapter() != null && getAdapter().mActionMode != null) { - getAdapter().mActionMode.finish(); - } if (getActivity() != null) { getActivity().setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE); } |