diff options
author | Eric Erfanian <erfanian@google.com> | 2017-06-08 00:54:45 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-06-08 00:54:45 +0000 |
commit | 274b6d320edb3c33e7b3a95c43a811829486a777 (patch) | |
tree | b9bbc285430ffb5363a70eb27e382c38f5a85b7a /java/com/android/dialer/app/calllog | |
parent | 75233ff03785f24789b32039ac2c208805b7e506 (diff) | |
parent | 91ce7d2a476bd04fe525049a37a2f8b2824e9724 (diff) |
Update AOSP Dialer source from internal google3 repository at cl/158012278.
am: 91ce7d2a47
Change-Id: I1744a8bfca09eae5e9c0d7aac122515eca75bb8b
Diffstat (limited to 'java/com/android/dialer/app/calllog')
7 files changed, 244 insertions, 125 deletions
diff --git a/java/com/android/dialer/app/calllog/CallLogAdapter.java b/java/com/android/dialer/app/calllog/CallLogAdapter.java index 2f8a58c8a..3357ee2f1 100644 --- a/java/com/android/dialer/app/calllog/CallLogAdapter.java +++ b/java/com/android/dialer/app/calllog/CallLogAdapter.java @@ -86,6 +86,7 @@ import com.android.dialer.phonenumbercache.ContactInfoHelper; import com.android.dialer.phonenumberutil.PhoneNumberHelper; import com.android.dialer.spam.Spam; import com.android.dialer.util.PermissionsUtil; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; @@ -105,11 +106,12 @@ public class CallLogAdapter extends GroupingListAdapter private static final String KEY_EXPANDED_POSITION = "expanded_position"; private static final String KEY_EXPANDED_ROW_ID = "expanded_row_id"; + private static final String KEY_ACTION_MODE = "action_mode_selected_items"; public static final String LOAD_DATA_TASK_IDENTIFIER = "load_data"; public static final String ENABLE_CALL_LOG_MULTI_SELECT = "enable_call_log_multiselect"; - public static final boolean ENABLE_CALL_LOG_MULTI_SELECT_FLAG = false; + public static final boolean ENABLE_CALL_LOG_MULTI_SELECT_FLAG = true; protected final Activity mActivity; protected final VoicemailPlaybackPresenter mVoicemailPlaybackPresenter; @@ -117,6 +119,7 @@ public class CallLogAdapter extends GroupingListAdapter protected final CallLogCache mCallLogCache; private final CallFetcher mCallFetcher; + private final MultiSelectRemoveView mMultiSelectRemoveView; @NonNull private final FilteredNumberAsyncQueryHandler mFilteredNumberAsyncQueryHandler; private final int mActivityType; @@ -136,6 +139,8 @@ public class CallLogAdapter extends GroupingListAdapter private final CallLogAlertManager mCallLogAlertManager; public ActionMode mActionMode = null; + public boolean selectAllMode = false; + public boolean deselectAllMode = false; private final SparseArray<String> selectedItems = new SparseArray<>(); private final ActionMode.Callback mActionModeCallback = @@ -144,10 +149,16 @@ public class CallLogAdapter extends GroupingListAdapter // Called when the action mode is created; startActionMode() was called @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { + if (mActivity != null) { + announceforAccessibility( + mActivity.getCurrentFocus(), + mActivity.getString(R.string.description_entering_bulk_action_mode)); + } mActionMode = mode; // Inflate a menu resource providing context menu items MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.actionbar_delete, menu); + mMultiSelectRemoveView.showMultiSelectRemoveView(true); return true; } @@ -165,7 +176,6 @@ public class CallLogAdapter extends GroupingListAdapter if (selectedItems.size() > 0) { showDeleteSelectedItemsDialog(); } - mode.finish(); return true; } else { return false; @@ -175,8 +185,16 @@ public class CallLogAdapter extends GroupingListAdapter // Called when the user exits the action mode @Override public void onDestroyActionMode(ActionMode mode) { + if (mActivity != null) { + announceforAccessibility( + mActivity.getCurrentFocus(), + mActivity.getString(R.string.description_leaving_bulk_action_mode)); + } selectedItems.clear(); mActionMode = null; + selectAllMode = false; + deselectAllMode = false; + mMultiSelectRemoveView.showMultiSelectRemoveView(false); notifyDataSetChanged(); } }; @@ -202,6 +220,7 @@ public class CallLogAdapter extends GroupingListAdapter @Override public void onClick(DialogInterface dialog, int id) { deleteSelectedItems(voicemailsToDeleteOnConfirmation); + mActionMode.finish(); dialog.cancel(); } }); @@ -258,22 +277,15 @@ public class CallLogAdapter extends GroupingListAdapter return; } if (mActionMode != null && viewHolder.voicemailUri != null) { + selectAllMode = false; + deselectAllMode = false; + mMultiSelectRemoveView.setSelectAllModeToFalse(); int id = getVoicemailId(viewHolder.voicemailUri); if (selectedItems.get(id) != null) { - selectedItems.delete(id); - viewHolder.checkBoxView.setVisibility(View.GONE); - viewHolder.quickContactView.setVisibility(View.VISIBLE); + uncheckMarkCallLogEntry(viewHolder, id); } else { - viewHolder.quickContactView.setVisibility(View.GONE); - viewHolder.checkBoxView.setVisibility(View.VISIBLE); - selectedItems.put(getVoicemailId(viewHolder.voicemailUri), viewHolder.voicemailUri); - } - - if (selectedItems.size() == 0) { - mActionMode.finish(); - return; + checkMarkCallLogEntry(viewHolder); } - mActionMode.setTitle(Integer.toString(selectedItems.size())); return; } @@ -312,6 +324,48 @@ public class CallLogAdapter extends GroupingListAdapter } }; + private void checkMarkCallLogEntry(CallLogListItemViewHolder viewHolder) { + announceforAccessibility( + mActivity.getCurrentFocus(), + mActivity.getString( + R.string.description_selecting_bulk_action_mode, viewHolder.nameOrNumber)); + viewHolder.quickContactView.setVisibility(View.GONE); + viewHolder.checkBoxView.setVisibility(View.VISIBLE); + selectedItems.put(getVoicemailId(viewHolder.voicemailUri), viewHolder.voicemailUri); + updateActionBar(); + } + + private void announceforAccessibility(View view, String announcement) { + if (view != null) { + view.announceForAccessibility(announcement); + } + } + + private void updateActionBar() { + if (mActionMode == null && selectedItems.size() > 0) { + mActivity.startActionMode(mActionModeCallback); + } + if (mActionMode != null) { + mActionMode.setTitle( + mActivity + .getResources() + .getString( + R.string.voicemailMultiSelectActionBarTitle, + Integer.toString(selectedItems.size()))); + } + } + + private void uncheckMarkCallLogEntry(CallLogListItemViewHolder viewHolder, int id) { + announceforAccessibility( + mActivity.getCurrentFocus(), + mActivity.getString( + R.string.description_unselecting_bulk_action_mode, viewHolder.nameOrNumber)); + selectedItems.delete(id); + viewHolder.checkBoxView.setVisibility(View.GONE); + viewHolder.quickContactView.setVisibility(View.VISIBLE); + updateActionBar(); + } + private static int getVoicemailId(String voicemailUri) { Assert.checkArgument(voicemailUri != null); Assert.checkArgument(voicemailUri.length() > 0); @@ -358,6 +412,7 @@ public class CallLogAdapter extends GroupingListAdapter Activity activity, ViewGroup alertContainer, CallFetcher callFetcher, + MultiSelectRemoveView multiSelectRemoveView, CallLogCache callLogCache, ContactInfoCache contactInfoCache, VoicemailPlaybackPresenter voicemailPlaybackPresenter, @@ -367,6 +422,7 @@ public class CallLogAdapter extends GroupingListAdapter mActivity = activity; mCallFetcher = callFetcher; + mMultiSelectRemoveView = multiSelectRemoveView; mVoicemailPlaybackPresenter = voicemailPlaybackPresenter; if (mVoicemailPlaybackPresenter != null) { mVoicemailPlaybackPresenter.setOnVoicemailDeletedListener(this); @@ -426,6 +482,14 @@ public class CallLogAdapter extends GroupingListAdapter public void onSaveInstanceState(Bundle outState) { outState.putInt(KEY_EXPANDED_POSITION, mCurrentlyExpandedPosition); outState.putLong(KEY_EXPANDED_ROW_ID, mCurrentlyExpandedRowId); + + ArrayList<String> listOfSelectedItems = new ArrayList<>(); + if (selectedItems.size() > 0) { + for (int i = 0; i < selectedItems.size(); i++) { + listOfSelectedItems.add(Integer.toString(selectedItems.keyAt(i))); + } + } + outState.putStringArrayList(KEY_ACTION_MODE, listOfSelectedItems); } public void onRestoreInstanceState(Bundle savedInstanceState) { @@ -434,6 +498,18 @@ public class CallLogAdapter extends GroupingListAdapter savedInstanceState.getInt(KEY_EXPANDED_POSITION, RecyclerView.NO_POSITION); mCurrentlyExpandedRowId = savedInstanceState.getLong(KEY_EXPANDED_ROW_ID, NO_EXPANDED_LIST_ITEM); + + // Restoring multi selected entries + ArrayList<String> listOfSelectedItems = + savedInstanceState.getStringArrayList(KEY_ACTION_MODE); + if (!listOfSelectedItems.isEmpty()) { + for (int i = 0; i < listOfSelectedItems.size(); i++) { + String voicemailId = listOfSelectedItems.get(i); + int id = Integer.parseInt(voicemailId); + selectedItems.put(id, voicemailId); + } + updateActionBar(); + } } } @@ -559,6 +635,8 @@ public class CallLogAdapter extends GroupingListAdapter public void onViewRecycled(ViewHolder viewHolder) { if (viewHolder.getItemViewType() == VIEW_TYPE_CALLLOG) { CallLogListItemViewHolder views = (CallLogListItemViewHolder) viewHolder; + updateCheckMarkedStatusOfEntry(views); + if (views.asyncTask != null) { views.asyncTask.cancel(true); } @@ -591,6 +669,8 @@ public class CallLogAdapter extends GroupingListAdapter return; } CallLogListItemViewHolder views = (CallLogListItemViewHolder) viewHolder; + updateCheckMarkedStatusOfEntry(views); + views.isLoaded = false; int groupSize = getGroupSize(position); CallDetailsEntries callDetailsEntries = createCallDetailsEntries(c, groupSize); @@ -609,6 +689,17 @@ public class CallLogAdapter extends GroupingListAdapter loadAndRender(views, views.rowId, details, callDetailsEntries); } + private void updateCheckMarkedStatusOfEntry(CallLogListItemViewHolder views) { + if (selectedItems.size() > 0 && views.voicemailUri != null) { + int id = getVoicemailId(views.voicemailUri); + if (selectedItems.get(id) != null) { + checkMarkCallLogEntry(views); + } else { + uncheckMarkCallLogEntry(views, id); + } + } + } + private void loadAndRender( final CallLogListItemViewHolder views, final long rowId, @@ -917,6 +1008,12 @@ public class CallLogAdapter extends GroupingListAdapter views.workIconView.setVisibility( details.contactUserType == ContactsUtils.USER_TYPE_WORK ? View.VISIBLE : View.GONE); + if (selectAllMode && views.voicemailUri != null) { + selectedItems.put(getVoicemailId(views.voicemailUri), views.voicemailUri); + } + if (deselectAllMode && views.voicemailUri != null) { + selectedItems.delete(getVoicemailId(views.voicemailUri)); + } if (views.voicemailUri != null && selectedItems.get(getVoicemailId(views.voicemailUri)) != null) { views.checkBoxView.setVisibility(View.VISIBLE); @@ -925,7 +1022,6 @@ public class CallLogAdapter extends GroupingListAdapter views.checkBoxView.setVisibility(View.GONE); views.quickContactView.setVisibility(View.VISIBLE); } - mCallLogListItemHelper.setPhoneCallDetails(views, details); if (mCurrentlyExpandedRowId == views.rowId) { // In case ViewHolders were added/removed, update the expanded position if the rowIds @@ -1192,9 +1288,41 @@ public class CallLogAdapter extends GroupingListAdapter notifyDataSetChanged(); } + public void onAllSelected() { + selectAllMode = true; + deselectAllMode = false; + selectedItems.clear(); + for (int i = 0; i < getItemCount(); i++) { + Cursor c = (Cursor) getItem(i); + if (c != null) { + Assert.checkArgument(CallLogQuery.VOICEMAIL_URI == c.getColumnIndex("voicemail_uri")); + String voicemailUri = c.getString(CallLogQuery.VOICEMAIL_URI); + selectedItems.put(getVoicemailId(voicemailUri), voicemailUri); + } + } + updateActionBar(); + notifyDataSetChanged(); + } + + public void onAllDeselected() { + selectAllMode = false; + deselectAllMode = true; + selectedItems.clear(); + updateActionBar(); + notifyDataSetChanged(); + } + /** Interface used to initiate a refresh of the content. */ public interface CallFetcher { void fetchCalls(); } + + /** Interface used to hide the fragments. */ + public interface MultiSelectRemoveView { + + void showMultiSelectRemoveView(boolean show); + + void setSelectAllModeToFalse(); + } } diff --git a/java/com/android/dialer/app/calllog/CallLogFragment.java b/java/com/android/dialer/app/calllog/CallLogFragment.java index 6e4b23fc1..1571c1aef 100644 --- a/java/com/android/dialer/app/calllog/CallLogFragment.java +++ b/java/com/android/dialer/app/calllog/CallLogFragment.java @@ -49,15 +49,16 @@ import com.android.dialer.app.contactinfo.ContactInfoCache.OnContactInfoChangedL import com.android.dialer.app.contactinfo.ExpirableCacheHeadlessFragment; import com.android.dialer.app.list.ListsFragment; import com.android.dialer.app.voicemail.VoicemailPlaybackPresenter; -import com.android.dialer.app.widget.EmptyContentView; -import com.android.dialer.app.widget.EmptyContentView.OnEmptyViewActionButtonClickedListener; 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.oem.CequintCallerIdManager; import com.android.dialer.phonenumbercache.ContactInfoHelper; import com.android.dialer.util.PermissionsUtil; +import com.android.dialer.widget.EmptyContentView; +import com.android.dialer.widget.EmptyContentView.OnEmptyViewActionButtonClickedListener; /** * Displays a list of call log entries. To filter for a particular kind of call (all, missed or @@ -66,6 +67,7 @@ import com.android.dialer.util.PermissionsUtil; public class CallLogFragment extends Fragment implements CallLogQueryHandler.Listener, CallLogAdapter.CallFetcher, + CallLogAdapter.MultiSelectRemoveView, OnEmptyViewActionButtonClickedListener, FragmentCompat.OnRequestPermissionsResultCallback, CallLogModalAlertManager.Listener { @@ -317,6 +319,7 @@ public class CallLogFragment extends Fragment getActivity(), mRecyclerView, this, + this, CallLogCache.getCallLogCache(getActivity()), mContactInfoCache, getVoicemailPlaybackPresenter(), @@ -380,6 +383,16 @@ public class CallLogFragment extends Fragment } @Override + public void onStart() { + super.onStart(); + CequintCallerIdManager cequintCallerIdManager = null; + if (CequintCallerIdManager.isCequintCallerIdEnabled(getContext())) { + cequintCallerIdManager = CequintCallerIdManager.createInstanceForCallLog(); + } + mContactInfoCache.setCequintCallerIdManager(cequintCallerIdManager); + } + + @Override public void onStop() { updateOnTransition(); @@ -451,6 +464,8 @@ public class CallLogFragment extends Fragment mEmptyListView.setActionLabel(EmptyContentView.NO_LABEL); } else if (filterType == CallLogQueryHandler.CALL_TYPE_ALL) { mEmptyListView.setActionLabel(R.string.call_log_all_empty_action); + } else { + mEmptyListView.setActionLabel(EmptyContentView.NO_LABEL); } } @@ -589,6 +604,16 @@ public class CallLogFragment extends Fragment } } + @Override + public void showMultiSelectRemoveView(boolean show) { + ((ListsFragment) getParentFragment()).showMultiSelectRemoveView(show); + } + + @Override + public void setSelectAllModeToFalse() { + ((ListsFragment) getParentFragment()).setSelectAllModeToFalse(); + } + public interface HostInterface { void showDialpad(); diff --git a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java index 1daccd1a4..a9a4d1d42 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; @@ -31,7 +32,6 @@ import android.support.annotation.VisibleForTesting; import android.support.v7.widget.CardView; import android.support.v7.widget.RecyclerView; import android.telecom.PhoneAccountHandle; -import android.telecom.TelecomManager; import android.telephony.PhoneNumberUtils; import android.text.BidiFormatter; import android.text.TextDirectionHeuristics; @@ -44,10 +44,13 @@ 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; import com.android.contacts.common.dialog.CallSubjectDialog; +import com.android.contacts.common.lettertiles.LetterTileDrawable; +import com.android.contacts.common.lettertiles.LetterTileDrawable.ContactType; import com.android.contacts.common.util.UriUtils; import com.android.dialer.app.DialtactsActivity; import com.android.dialer.app.R; @@ -58,15 +61,16 @@ import com.android.dialer.blocking.BlockedNumbersMigrator; import com.android.dialer.blocking.FilteredNumberCompat; import com.android.dialer.blocking.FilteredNumbersUtil; import com.android.dialer.callcomposer.CallComposerActivity; -import com.android.dialer.callcomposer.CallComposerContact; import com.android.dialer.calldetails.CallDetailsEntries; import com.android.dialer.common.ConfigProviderBindings; import com.android.dialer.common.LogUtil; import com.android.dialer.compat.CompatUtils; +import com.android.dialer.dialercontact.DialerContact; import com.android.dialer.lightbringer.Lightbringer; import com.android.dialer.lightbringer.LightbringerComponent; import com.android.dialer.logging.ContactSource; import com.android.dialer.logging.DialerImpression; +import com.android.dialer.logging.InteractionEvent; import com.android.dialer.logging.Logger; import com.android.dialer.logging.ScreenEvent; import com.android.dialer.phonenumbercache.CachedNumberLookupService; @@ -251,6 +255,20 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder phoneCallDetailsViews.nameView.setElegantTextHeight(false); phoneCallDetailsViews.callLocationAndDate.setElegantTextHeight(false); + if (mContext instanceof CallLogActivity) { + Logger.get(mContext) + .logQuickContactOnTouch( + quickContactView, InteractionEvent.Type.OPEN_QUICK_CONTACT_FROM_CALL_HISTORY, true); + } else if (mVoicemailPlaybackPresenter == null) { + Logger.get(mContext) + .logQuickContactOnTouch( + quickContactView, InteractionEvent.Type.OPEN_QUICK_CONTACT_FROM_CALL_LOG, true); + } else { + Logger.get(mContext) + .logQuickContactOnTouch( + quickContactView, InteractionEvent.Type.OPEN_QUICK_CONTACT_FROM_VOICEMAIL, false); + } + quickContactView.setOverlay(null); if (CompatUtils.hasPrioritizedMimeType()) { quickContactView.setPrioritizedMimeType(Phone.CONTENT_ITEM_TYPE); @@ -467,7 +485,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder primaryActionButtonView.setContentDescription( TextUtils.expandTemplate( mContext.getString(R.string.description_call_action), validNameOrNumber)); - primaryActionButtonView.setImageResource(R.drawable.quantum_ic_call_white_24); + primaryActionButtonView.setImageResource(R.drawable.quantum_ic_call_vd_theme_24); primaryActionButtonView.setVisibility(View.VISIBLE); } else { primaryActionButtonView.setTag(null); @@ -717,19 +735,14 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder getContactType()); } - private int getContactType() { - int contactType = ContactPhotoManager.TYPE_DEFAULT; - if (mCallLogCache.isVoicemailNumber(accountHandle, number)) { - contactType = ContactPhotoManager.TYPE_VOICEMAIL; - } else if (isSpam) { - contactType = ContactPhotoManager.TYPE_SPAM; - } else if (mCachedNumberLookupService != null - && mCachedNumberLookupService.isBusiness(info.sourceType)) { - contactType = ContactPhotoManager.TYPE_BUSINESS; - } else if (numberPresentation == TelecomManager.PRESENTATION_RESTRICTED) { - contactType = ContactPhotoManager.TYPE_GENERIC_AVATAR; - } - return contactType; + private @ContactType int getContactType() { + return LetterTileDrawable.getContactTypeFromPrimitives( + mCallLogCache.isVoicemailNumber(accountHandle, number), + isSpam, + mCachedNumberLookupService != null + && mCachedNumberLookupService.isBusiness(info.sourceType), + numberPresentation, + false); } @Override @@ -795,19 +808,40 @@ 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(); + private DialerContact buildContact() { + DialerContact.Builder contact = DialerContact.newBuilder(); contact.setPhotoId(info.photoId); if (info.photoUri != null) { contact.setPhotoUri(info.photoUri.toString()); diff --git a/java/com/android/dialer/app/calllog/DefaultVoicemailNotifier.java b/java/com/android/dialer/app/calllog/DefaultVoicemailNotifier.java index 58fe6fa2c..1f45f7086 100644 --- a/java/com/android/dialer/app/calllog/DefaultVoicemailNotifier.java +++ b/java/com/android/dialer/app/calllog/DefaultVoicemailNotifier.java @@ -225,14 +225,18 @@ public class DefaultVoicemailNotifier implements Worker<Void, Void> { int count, String voicemailNumber, PendingIntent callVoicemailIntent, - PendingIntent voicemailSettingIntent) { + PendingIntent voicemailSettingIntent, + boolean isRefresh) { Assert.isNotNull(phoneAccountHandle); Assert.checkArgument(BuildCompat.isAtLeastO()); TelephonyManager telephonyManager = context .getSystemService(TelephonyManager.class) .createForPhoneAccountHandle(phoneAccountHandle); - Assert.isNotNull(telephonyManager); + if (telephonyManager == null) { + LogUtil.e(TAG, "invalid PhoneAccountHandle, ignoring"); + return; + } LogUtil.i(TAG, "Creating legacy voicemail notification"); PersistableBundle carrierConfig = telephonyManager.getCarrierConfig(); @@ -275,7 +279,8 @@ public class DefaultVoicemailNotifier implements Worker<Void, Void> { .setSound(telephonyManager.getVoicemailRingtoneUri(phoneAccountHandle)) .setOngoing( carrierConfig.getBoolean( - CarrierConfigManager.KEY_VOICEMAIL_NOTIFICATION_PERSISTENT_BOOL)); + CarrierConfigManager.KEY_VOICEMAIL_NOTIFICATION_PERSISTENT_BOOL)) + .setOnlyAlertOnce(isRefresh); if (telephonyManager.isVoicemailVibrationEnabled(phoneAccountHandle)) { builder.setDefaults(Notification.DEFAULT_VIBRATE); diff --git a/java/com/android/dialer/app/calllog/IntentProvider.java b/java/com/android/dialer/app/calllog/IntentProvider.java index a94c6781e..9c3c18b60 100644 --- a/java/com/android/dialer/app/calllog/IntentProvider.java +++ b/java/com/android/dialer/app/calllog/IntentProvider.java @@ -24,12 +24,14 @@ import android.provider.ContactsContract; import android.telecom.PhoneAccountHandle; import com.android.contacts.common.model.Contact; import com.android.contacts.common.model.ContactLoader; -import com.android.dialer.callcomposer.CallComposerContact; import com.android.dialer.calldetails.CallDetailsActivity; import com.android.dialer.calldetails.CallDetailsEntries; import com.android.dialer.callintent.CallInitiationType; import com.android.dialer.callintent.CallIntentBuilder; +import com.android.dialer.dialercontact.DialerContact; import com.android.dialer.lightbringer.LightbringerComponent; +import com.android.dialer.logging.DialerImpression; +import com.android.dialer.logging.Logger; import com.android.dialer.util.CallUtil; import com.android.dialer.util.IntentUtil; import java.util.ArrayList; @@ -68,6 +70,7 @@ public abstract class IntentProvider { return new IntentProvider() { @Override public Intent getIntent(Context context) { + Logger.get(context).logImpression(DialerImpression.Type.IMS_VIDEO_REQUESTED_FROM_CALL_LOG); return new CallIntentBuilder(number, CallInitiationType.Type.CALL_LOG) .setPhoneAccountHandle(accountHandle) .setIsVideoCall(true) @@ -80,6 +83,8 @@ public abstract class IntentProvider { return new IntentProvider() { @Override public Intent getIntent(Context context) { + Logger.get(context) + .logImpression(DialerImpression.Type.LIGHTBRINGER_VIDEO_REQUESTED_FROM_CALL_LOG); return LightbringerComponent.get(context).getLightbringer().getIntent(context, number); } }; @@ -112,7 +117,7 @@ public abstract class IntentProvider { * @return The call details intent provider. */ public static IntentProvider getCallDetailIntentProvider( - CallDetailsEntries callDetailsEntries, CallComposerContact contact) { + CallDetailsEntries callDetailsEntries, DialerContact contact) { return new IntentProvider() { @Override public Intent getIntent(Context context) { diff --git a/java/com/android/dialer/app/calllog/calllogcache/CallLogCache.java b/java/com/android/dialer/app/calllog/calllogcache/CallLogCache.java index 7645a333e..6728dfb38 100644 --- a/java/com/android/dialer/app/calllog/calllogcache/CallLogCache.java +++ b/java/com/android/dialer/app/calllog/calllogcache/CallLogCache.java @@ -19,7 +19,6 @@ package com.android.dialer.app.calllog.calllogcache; import android.content.Context; import android.telecom.PhoneAccountHandle; import com.android.dialer.app.calllog.CallLogAdapter; -import com.android.dialer.compat.CompatUtils; import com.android.dialer.util.CallUtil; /** @@ -46,10 +45,7 @@ public abstract class CallLogCache { /** Return the most compatible version of the TelecomCallLogCache. */ public static CallLogCache getCallLogCache(Context context) { - if (CompatUtils.isClassAvailable("android.telecom.PhoneAccountHandle")) { - return new CallLogCacheLollipopMr1(context); - } - return new CallLogCacheLollipop(context); + return new CallLogCacheLollipopMr1(context); } public void reset() { diff --git a/java/com/android/dialer/app/calllog/calllogcache/CallLogCacheLollipop.java b/java/com/android/dialer/app/calllog/calllogcache/CallLogCacheLollipop.java deleted file mode 100644 index 78aaa4193..000000000 --- a/java/com/android/dialer/app/calllog/calllogcache/CallLogCacheLollipop.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2015 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.dialer.app.calllog.calllogcache; - -import android.content.Context; -import android.telecom.PhoneAccount; -import android.telecom.PhoneAccountHandle; -import android.telephony.PhoneNumberUtils; -import android.text.TextUtils; - -/** - * This is a compatibility class for the CallLogCache for versions of dialer before Lollipop Mr1 - * (the introduction of phone accounts). - * - * <p>This class should not be initialized directly and instead be acquired from {@link - * CallLogCache#getCallLogCache}. - */ -class CallLogCacheLollipop extends CallLogCache { - - private String mVoicemailNumber; - - /* package */ CallLogCacheLollipop(Context context) { - super(context); - } - - @Override - public boolean isVoicemailNumber(PhoneAccountHandle accountHandle, CharSequence number) { - if (TextUtils.isEmpty(number)) { - return false; - } - - String numberString = number.toString(); - - if (!TextUtils.isEmpty(mVoicemailNumber)) { - return PhoneNumberUtils.compare(numberString, mVoicemailNumber); - } - - if (PhoneNumberUtils.isVoiceMailNumber(numberString)) { - mVoicemailNumber = numberString; - return true; - } - - return false; - } - - @Override - public String getAccountLabel(PhoneAccountHandle accountHandle) { - return null; - } - - @Override - public int getAccountColor(PhoneAccountHandle accountHandle) { - return PhoneAccount.NO_HIGHLIGHT_COLOR; - } - - @Override - public boolean doesAccountSupportCallSubject(PhoneAccountHandle accountHandle) { - return false; - } -} |