diff options
Diffstat (limited to 'java/com/android/dialer/app/calllog')
7 files changed, 125 insertions, 244 deletions
diff --git a/java/com/android/dialer/app/calllog/CallLogAdapter.java b/java/com/android/dialer/app/calllog/CallLogAdapter.java index 3357ee2f1..2f8a58c8a 100644 --- a/java/com/android/dialer/app/calllog/CallLogAdapter.java +++ b/java/com/android/dialer/app/calllog/CallLogAdapter.java @@ -86,7 +86,6 @@ 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; @@ -106,12 +105,11 @@ 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 = true; + public static final boolean ENABLE_CALL_LOG_MULTI_SELECT_FLAG = false; protected final Activity mActivity; protected final VoicemailPlaybackPresenter mVoicemailPlaybackPresenter; @@ -119,7 +117,6 @@ 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; @@ -139,8 +136,6 @@ 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 = @@ -149,16 +144,10 @@ 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; } @@ -176,6 +165,7 @@ public class CallLogAdapter extends GroupingListAdapter if (selectedItems.size() > 0) { showDeleteSelectedItemsDialog(); } + mode.finish(); return true; } else { return false; @@ -185,16 +175,8 @@ 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(); } }; @@ -220,7 +202,6 @@ public class CallLogAdapter extends GroupingListAdapter @Override public void onClick(DialogInterface dialog, int id) { deleteSelectedItems(voicemailsToDeleteOnConfirmation); - mActionMode.finish(); dialog.cancel(); } }); @@ -277,15 +258,22 @@ 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) { - uncheckMarkCallLogEntry(viewHolder, id); + selectedItems.delete(id); + viewHolder.checkBoxView.setVisibility(View.GONE); + viewHolder.quickContactView.setVisibility(View.VISIBLE); } else { - checkMarkCallLogEntry(viewHolder); + viewHolder.quickContactView.setVisibility(View.GONE); + viewHolder.checkBoxView.setVisibility(View.VISIBLE); + selectedItems.put(getVoicemailId(viewHolder.voicemailUri), viewHolder.voicemailUri); + } + + if (selectedItems.size() == 0) { + mActionMode.finish(); + return; } + mActionMode.setTitle(Integer.toString(selectedItems.size())); return; } @@ -324,48 +312,6 @@ 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); @@ -412,7 +358,6 @@ public class CallLogAdapter extends GroupingListAdapter Activity activity, ViewGroup alertContainer, CallFetcher callFetcher, - MultiSelectRemoveView multiSelectRemoveView, CallLogCache callLogCache, ContactInfoCache contactInfoCache, VoicemailPlaybackPresenter voicemailPlaybackPresenter, @@ -422,7 +367,6 @@ public class CallLogAdapter extends GroupingListAdapter mActivity = activity; mCallFetcher = callFetcher; - mMultiSelectRemoveView = multiSelectRemoveView; mVoicemailPlaybackPresenter = voicemailPlaybackPresenter; if (mVoicemailPlaybackPresenter != null) { mVoicemailPlaybackPresenter.setOnVoicemailDeletedListener(this); @@ -482,14 +426,6 @@ 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) { @@ -498,18 +434,6 @@ 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(); - } } } @@ -635,8 +559,6 @@ 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); } @@ -669,8 +591,6 @@ public class CallLogAdapter extends GroupingListAdapter return; } CallLogListItemViewHolder views = (CallLogListItemViewHolder) viewHolder; - updateCheckMarkedStatusOfEntry(views); - views.isLoaded = false; int groupSize = getGroupSize(position); CallDetailsEntries callDetailsEntries = createCallDetailsEntries(c, groupSize); @@ -689,17 +609,6 @@ 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, @@ -1008,12 +917,6 @@ 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); @@ -1022,6 +925,7 @@ 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 @@ -1288,41 +1192,9 @@ 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 1571c1aef..6e4b23fc1 100644 --- a/java/com/android/dialer/app/calllog/CallLogFragment.java +++ b/java/com/android/dialer/app/calllog/CallLogFragment.java @@ -49,16 +49,15 @@ 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 @@ -67,7 +66,6 @@ import com.android.dialer.widget.EmptyContentView.OnEmptyViewActionButtonClicked public class CallLogFragment extends Fragment implements CallLogQueryHandler.Listener, CallLogAdapter.CallFetcher, - CallLogAdapter.MultiSelectRemoveView, OnEmptyViewActionButtonClickedListener, FragmentCompat.OnRequestPermissionsResultCallback, CallLogModalAlertManager.Listener { @@ -319,7 +317,6 @@ public class CallLogFragment extends Fragment getActivity(), mRecyclerView, this, - this, CallLogCache.getCallLogCache(getActivity()), mContactInfoCache, getVoicemailPlaybackPresenter(), @@ -383,16 +380,6 @@ 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(); @@ -464,8 +451,6 @@ 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); } } @@ -604,16 +589,6 @@ 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 a9a4d1d42..1daccd1a4 100644 --- a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java +++ b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java @@ -17,7 +17,6 @@ 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; @@ -32,6 +31,7 @@ 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,13 +44,10 @@ 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; @@ -61,16 +58,15 @@ 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; @@ -255,20 +251,6 @@ 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); @@ -485,7 +467,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_vd_theme_24); + primaryActionButtonView.setImageResource(R.drawable.quantum_ic_call_white_24); primaryActionButtonView.setVisibility(View.VISIBLE); } else { primaryActionButtonView.setTag(null); @@ -735,14 +717,19 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder getContactType()); } - private @ContactType int getContactType() { - return LetterTileDrawable.getContactTypeFromPrimitives( - mCallLogCache.isVoicemailNumber(accountHandle, number), - isSpam, - mCachedNumberLookupService != null - && mCachedNumberLookupService.isBusiness(info.sourceType), - numberPresentation, - false); + 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; } @Override @@ -808,40 +795,19 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder mVoicemailPlaybackPresenter.shareVoicemail(); } else { logCallLogAction(view.getId()); - final IntentProvider intentProvider = (IntentProvider) view.getTag(); - 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); + 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); + } } } } - 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 DialerContact buildContact() { - DialerContact.Builder contact = DialerContact.newBuilder(); + private CallComposerContact buildContact() { + CallComposerContact.Builder contact = CallComposerContact.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 1f45f7086..58fe6fa2c 100644 --- a/java/com/android/dialer/app/calllog/DefaultVoicemailNotifier.java +++ b/java/com/android/dialer/app/calllog/DefaultVoicemailNotifier.java @@ -225,18 +225,14 @@ public class DefaultVoicemailNotifier implements Worker<Void, Void> { int count, String voicemailNumber, PendingIntent callVoicemailIntent, - PendingIntent voicemailSettingIntent, - boolean isRefresh) { + PendingIntent voicemailSettingIntent) { Assert.isNotNull(phoneAccountHandle); Assert.checkArgument(BuildCompat.isAtLeastO()); TelephonyManager telephonyManager = context .getSystemService(TelephonyManager.class) .createForPhoneAccountHandle(phoneAccountHandle); - if (telephonyManager == null) { - LogUtil.e(TAG, "invalid PhoneAccountHandle, ignoring"); - return; - } + Assert.isNotNull(telephonyManager); LogUtil.i(TAG, "Creating legacy voicemail notification"); PersistableBundle carrierConfig = telephonyManager.getCarrierConfig(); @@ -279,8 +275,7 @@ public class DefaultVoicemailNotifier implements Worker<Void, Void> { .setSound(telephonyManager.getVoicemailRingtoneUri(phoneAccountHandle)) .setOngoing( carrierConfig.getBoolean( - CarrierConfigManager.KEY_VOICEMAIL_NOTIFICATION_PERSISTENT_BOOL)) - .setOnlyAlertOnce(isRefresh); + CarrierConfigManager.KEY_VOICEMAIL_NOTIFICATION_PERSISTENT_BOOL)); 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 9c3c18b60..a94c6781e 100644 --- a/java/com/android/dialer/app/calllog/IntentProvider.java +++ b/java/com/android/dialer/app/calllog/IntentProvider.java @@ -24,14 +24,12 @@ 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; @@ -70,7 +68,6 @@ 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) @@ -83,8 +80,6 @@ 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); } }; @@ -117,7 +112,7 @@ public abstract class IntentProvider { * @return The call details intent provider. */ public static IntentProvider getCallDetailIntentProvider( - CallDetailsEntries callDetailsEntries, DialerContact contact) { + CallDetailsEntries callDetailsEntries, CallComposerContact 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 6728dfb38..7645a333e 100644 --- a/java/com/android/dialer/app/calllog/calllogcache/CallLogCache.java +++ b/java/com/android/dialer/app/calllog/calllogcache/CallLogCache.java @@ -19,6 +19,7 @@ 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; /** @@ -45,7 +46,10 @@ public abstract class CallLogCache { /** Return the most compatible version of the TelecomCallLogCache. */ public static CallLogCache getCallLogCache(Context context) { - return new CallLogCacheLollipopMr1(context); + if (CompatUtils.isClassAvailable("android.telecom.PhoneAccountHandle")) { + return new CallLogCacheLollipopMr1(context); + } + return new CallLogCacheLollipop(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 new file mode 100644 index 000000000..78aaa4193 --- /dev/null +++ b/java/com/android/dialer/app/calllog/calllogcache/CallLogCacheLollipop.java @@ -0,0 +1,74 @@ +/* + * 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; + } +} |