diff options
Diffstat (limited to 'java/com/android/dialer/app/calllog')
15 files changed, 713 insertions, 718 deletions
diff --git a/java/com/android/dialer/app/calllog/BlockReportSpamListener.java b/java/com/android/dialer/app/calllog/BlockReportSpamListener.java index 05fb2b345..092c0982e 100644 --- a/java/com/android/dialer/app/calllog/BlockReportSpamListener.java +++ b/java/com/android/dialer/app/calllog/BlockReportSpamListener.java @@ -33,10 +33,10 @@ import com.android.dialer.spam.SpamComponent; /** Listener to show dialogs for block and report spam actions. */ public class BlockReportSpamListener implements CallLogListItemViewHolder.OnClickListener { - private final Context mContext; - private final FragmentManager mFragmentManager; - private final RecyclerView.Adapter mAdapter; - private final FilteredNumberAsyncQueryHandler mFilteredNumberAsyncQueryHandler; + private final Context context; + private final FragmentManager fragmentManager; + private final RecyclerView.Adapter adapter; + private final FilteredNumberAsyncQueryHandler filteredNumberAsyncQueryHandler; private final Spam spam; public BlockReportSpamListener( @@ -44,10 +44,10 @@ public class BlockReportSpamListener implements CallLogListItemViewHolder.OnClic FragmentManager fragmentManager, RecyclerView.Adapter adapter, FilteredNumberAsyncQueryHandler filteredNumberAsyncQueryHandler) { - mContext = context; - mFragmentManager = fragmentManager; - mAdapter = adapter; - mFilteredNumberAsyncQueryHandler = filteredNumberAsyncQueryHandler; + this.context = context; + this.fragmentManager = fragmentManager; + this.adapter = adapter; + this.filteredNumberAsyncQueryHandler = filteredNumberAsyncQueryHandler; spam = SpamComponent.get(context).spam(); } @@ -64,7 +64,7 @@ public class BlockReportSpamListener implements CallLogListItemViewHolder.OnClic isSpamChecked -> { LogUtil.i("BlockReportSpamListener.onBlockReportSpam", "onClick"); if (isSpamChecked && spam.isSpamEnabled()) { - Logger.get(mContext) + Logger.get(context) .logImpression( DialerImpression.Type .REPORT_CALL_AS_SPAM_VIA_CALL_LOG_BLOCK_REPORT_SPAM_SENT_VIA_BLOCK_NUMBER_DIALOG); @@ -75,17 +75,17 @@ public class BlockReportSpamListener implements CallLogListItemViewHolder.OnClic ReportingLocation.Type.CALL_LOG_HISTORY, contactSourceType); } - mFilteredNumberAsyncQueryHandler.blockNumber( + filteredNumberAsyncQueryHandler.blockNumber( uri -> { - Logger.get(mContext) + Logger.get(context) .logImpression(DialerImpression.Type.USER_ACTION_BLOCKED_NUMBER); - mAdapter.notifyDataSetChanged(); + adapter.notifyDataSetChanged(); }, number, countryIso); }, null) - .show(mFragmentManager, BlockReportSpamDialogs.BLOCK_REPORT_SPAM_DIALOG_TAG); + .show(fragmentManager, BlockReportSpamDialogs.BLOCK_REPORT_SPAM_DIALOG_TAG); } @Override @@ -101,7 +101,7 @@ public class BlockReportSpamListener implements CallLogListItemViewHolder.OnClic () -> { LogUtil.i("BlockReportSpamListener.onBlock", "onClick"); if (spam.isSpamEnabled()) { - Logger.get(mContext) + Logger.get(context) .logImpression( DialerImpression.Type .DIALOG_ACTION_CONFIRM_NUMBER_SPAM_INDIRECTLY_VIA_BLOCK_NUMBER); @@ -112,17 +112,17 @@ public class BlockReportSpamListener implements CallLogListItemViewHolder.OnClic ReportingLocation.Type.CALL_LOG_HISTORY, contactSourceType); } - mFilteredNumberAsyncQueryHandler.blockNumber( + filteredNumberAsyncQueryHandler.blockNumber( uri -> { - Logger.get(mContext) + Logger.get(context) .logImpression(DialerImpression.Type.USER_ACTION_BLOCKED_NUMBER); - mAdapter.notifyDataSetChanged(); + adapter.notifyDataSetChanged(); }, number, countryIso); }, null) - .show(mFragmentManager, BlockReportSpamDialogs.BLOCK_DIALOG_TAG); + .show(fragmentManager, BlockReportSpamDialogs.BLOCK_DIALOG_TAG); } @Override @@ -140,7 +140,7 @@ public class BlockReportSpamListener implements CallLogListItemViewHolder.OnClic () -> { LogUtil.i("BlockReportSpamListener.onUnblock", "onClick"); if (isSpam && spam.isSpamEnabled()) { - Logger.get(mContext) + Logger.get(context) .logImpression(DialerImpression.Type.REPORT_AS_NOT_SPAM_VIA_UNBLOCK_NUMBER); spam.reportNotSpamFromCallHistory( number, @@ -149,16 +149,16 @@ public class BlockReportSpamListener implements CallLogListItemViewHolder.OnClic ReportingLocation.Type.CALL_LOG_HISTORY, contactSourceType); } - mFilteredNumberAsyncQueryHandler.unblock( + filteredNumberAsyncQueryHandler.unblock( (rows, values) -> { - Logger.get(mContext) + Logger.get(context) .logImpression(DialerImpression.Type.USER_ACTION_UNBLOCKED_NUMBER); - mAdapter.notifyDataSetChanged(); + adapter.notifyDataSetChanged(); }, blockId); }, null) - .show(mFragmentManager, BlockReportSpamDialogs.UNBLOCK_DIALOG_TAG); + .show(fragmentManager, BlockReportSpamDialogs.UNBLOCK_DIALOG_TAG); } @Override @@ -173,7 +173,7 @@ public class BlockReportSpamListener implements CallLogListItemViewHolder.OnClic () -> { LogUtil.i("BlockReportSpamListener.onReportNotSpam", "onClick"); if (spam.isSpamEnabled()) { - Logger.get(mContext) + Logger.get(context) .logImpression(DialerImpression.Type.DIALOG_ACTION_CONFIRM_NUMBER_NOT_SPAM); spam.reportNotSpamFromCallHistory( number, @@ -182,9 +182,9 @@ public class BlockReportSpamListener implements CallLogListItemViewHolder.OnClic ReportingLocation.Type.CALL_LOG_HISTORY, contactSourceType); } - mAdapter.notifyDataSetChanged(); + adapter.notifyDataSetChanged(); }, null) - .show(mFragmentManager, BlockReportSpamDialogs.NOT_SPAM_DIALOG_TAG); + .show(fragmentManager, BlockReportSpamDialogs.NOT_SPAM_DIALOG_TAG); } } diff --git a/java/com/android/dialer/app/calllog/CallLogActivity.java b/java/com/android/dialer/app/calllog/CallLogActivity.java index 4b65ed934..99e11b06c 100644 --- a/java/com/android/dialer/app/calllog/CallLogActivity.java +++ b/java/com/android/dialer/app/calllog/CallLogActivity.java @@ -52,13 +52,13 @@ public class CallLogActivity extends TransactionSafeActivity @VisibleForTesting static final int TAB_INDEX_ALL = 0; @VisibleForTesting static final int TAB_INDEX_MISSED = 1; private static final int TAB_INDEX_COUNT = 2; - private ViewPager mViewPager; - private ViewPagerTabs mViewPagerTabs; - private ViewPagerAdapter mViewPagerAdapter; - private CallLogFragment mAllCallsFragment; - private CallLogFragment mMissedCallsFragment; - private String[] mTabTitles; - private boolean mIsResumed; + private ViewPager viewPager; + private ViewPagerTabs viewPagerTabs; + private ViewPagerAdapter viewPagerAdapter; + private CallLogFragment allCallsFragment; + private CallLogFragment missedCallsFragment; + private String[] tabTitles; + private boolean isResumed; private int selectedPageIndex; @Override @@ -84,21 +84,21 @@ public class CallLogActivity extends TransactionSafeActivity } selectedPageIndex = startingTab; - mTabTitles = new String[TAB_INDEX_COUNT]; - mTabTitles[0] = getString(R.string.call_log_all_title); - mTabTitles[1] = getString(R.string.call_log_missed_title); + tabTitles = new String[TAB_INDEX_COUNT]; + tabTitles[0] = getString(R.string.call_log_all_title); + tabTitles[1] = getString(R.string.call_log_missed_title); - mViewPager = (ViewPager) findViewById(R.id.call_log_pager); + viewPager = (ViewPager) findViewById(R.id.call_log_pager); - mViewPagerAdapter = new ViewPagerAdapter(getFragmentManager()); - mViewPager.setAdapter(mViewPagerAdapter); - mViewPager.setOffscreenPageLimit(1); - mViewPager.setOnPageChangeListener(this); + viewPagerAdapter = new ViewPagerAdapter(getFragmentManager()); + viewPager.setAdapter(viewPagerAdapter); + viewPager.setOffscreenPageLimit(1); + viewPager.setOnPageChangeListener(this); - mViewPagerTabs = (ViewPagerTabs) findViewById(R.id.viewpager_header); + viewPagerTabs = (ViewPagerTabs) findViewById(R.id.viewpager_header); - mViewPagerTabs.setViewPager(mViewPager); - mViewPager.setCurrentItem(startingTab); + viewPagerTabs.setViewPager(viewPager); + viewPager.setCurrentItem(startingTab); } @Override @@ -110,23 +110,23 @@ public class CallLogActivity extends TransactionSafeActivity PerformanceReport.startRecording(); } - mIsResumed = true; + isResumed = true; super.onResume(); sendScreenViewForChildFragment(); } @Override protected void onPause() { - mIsResumed = false; + isResumed = false; super.onPause(); } @Override protected void onStop() { - if (!isChangingConfigurations() && mViewPager != null) { + if (!isChangingConfigurations() && viewPager != null) { // Make sure current index != selectedPageIndex selectedPageIndex = -1; - updateMissedCalls(mViewPager.getCurrentItem()); + updateMissedCalls(viewPager.getCurrentItem()); } super.onStop(); } @@ -141,9 +141,9 @@ public class CallLogActivity extends TransactionSafeActivity @Override public boolean onPrepareOptionsMenu(Menu menu) { final MenuItem itemDeleteAll = menu.findItem(R.id.delete_all); - if (mAllCallsFragment != null && itemDeleteAll != null) { + if (allCallsFragment != null && itemDeleteAll != null) { // If onPrepareOptionsMenu is called before fragments are loaded, don't do anything. - final CallLogAdapter adapter = mAllCallsFragment.getAdapter(); + final CallLogAdapter adapter = allCallsFragment.getAdapter(); itemDeleteAll.setVisible(adapter != null && !adapter.isEmpty()); } return true; @@ -170,22 +170,22 @@ public class CallLogActivity extends TransactionSafeActivity @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { - mViewPagerTabs.onPageScrolled(position, positionOffset, positionOffsetPixels); + viewPagerTabs.onPageScrolled(position, positionOffset, positionOffsetPixels); } @Override public void onPageSelected(int position) { updateMissedCalls(position); selectedPageIndex = position; - if (mIsResumed) { + if (isResumed) { sendScreenViewForChildFragment(); } - mViewPagerTabs.onPageSelected(position); + viewPagerTabs.onPageSelected(position); } @Override public void onPageScrollStateChanged(int state) { - mViewPagerTabs.onPageScrollStateChanged(state); + viewPagerTabs.onPageScrollStateChanged(state); } private void sendScreenViewForChildFragment() { @@ -194,7 +194,7 @@ public class CallLogActivity extends TransactionSafeActivity private int getRtlPosition(int position) { if (ViewUtil.isRtl()) { - return mViewPagerAdapter.getCount() - 1 - position; + return viewPagerAdapter.getCount() - 1 - position; } return position; } @@ -205,13 +205,13 @@ public class CallLogActivity extends TransactionSafeActivity } switch (getRtlPosition(position)) { case TAB_INDEX_ALL: - if (mAllCallsFragment != null) { - mAllCallsFragment.markMissedCallsAsReadAndRemoveNotifications(); + if (allCallsFragment != null) { + allCallsFragment.markMissedCallsAsReadAndRemoveNotifications(); } break; case TAB_INDEX_MISSED: - if (mMissedCallsFragment != null) { - mMissedCallsFragment.markMissedCallsAsReadAndRemoveNotifications(); + if (missedCallsFragment != null) { + missedCallsFragment.markMissedCallsAsReadAndRemoveNotifications(); } break; default: @@ -255,10 +255,10 @@ public class CallLogActivity extends TransactionSafeActivity final CallLogFragment fragment = (CallLogFragment) super.instantiateItem(container, position); switch (getRtlPosition(position)) { case TAB_INDEX_ALL: - mAllCallsFragment = fragment; + allCallsFragment = fragment; break; case TAB_INDEX_MISSED: - mMissedCallsFragment = fragment; + missedCallsFragment = fragment; break; default: throw Assert.createIllegalStateFailException("Invalid position: " + position); @@ -268,7 +268,7 @@ public class CallLogActivity extends TransactionSafeActivity @Override public CharSequence getPageTitle(int position) { - return mTabTitles[position]; + return tabTitles[position]; } @Override diff --git a/java/com/android/dialer/app/calllog/CallLogAdapter.java b/java/com/android/dialer/app/calllog/CallLogAdapter.java index f3d04d935..261b0ec94 100644 --- a/java/com/android/dialer/app/calllog/CallLogAdapter.java +++ b/java/com/android/dialer/app/calllog/CallLogAdapter.java @@ -116,54 +116,54 @@ public class CallLogAdapter extends GroupingListAdapter public static final String ENABLE_CALL_LOG_MULTI_SELECT = "enable_call_log_multiselect"; public static final boolean ENABLE_CALL_LOG_MULTI_SELECT_FLAG = true; - protected final Activity mActivity; - protected final VoicemailPlaybackPresenter mVoicemailPlaybackPresenter; + protected final Activity activity; + protected final VoicemailPlaybackPresenter voicemailPlaybackPresenter; /** Cache for repeated requests to Telecom/Telephony. */ - protected final CallLogCache mCallLogCache; + protected final CallLogCache callLogCache; - private final CallFetcher mCallFetcher; - private final OnActionModeStateChangedListener mActionModeStateChangedListener; - private final MultiSelectRemoveView mMultiSelectRemoveView; - @NonNull private final FilteredNumberAsyncQueryHandler mFilteredNumberAsyncQueryHandler; - private final int mActivityType; + private final CallFetcher callFetcher; + private final OnActionModeStateChangedListener actionModeStateChangedListener; + private final MultiSelectRemoveView multiSelectRemoveView; + @NonNull private final FilteredNumberAsyncQueryHandler filteredNumberAsyncQueryHandler; + private final int activityType; /** Instance of helper class for managing views. */ - private final CallLogListItemHelper mCallLogListItemHelper; + private final CallLogListItemHelper callLogListItemHelper; /** Helper to group call log entries. */ - private final CallLogGroupBuilder mCallLogGroupBuilder; + private final CallLogGroupBuilder callLogGroupBuilder; - private final AsyncTaskExecutor mAsyncTaskExecutor = AsyncTaskExecutors.createAsyncTaskExecutor(); - private ContactInfoCache mContactInfoCache; + private final AsyncTaskExecutor asyncTaskExecutor = AsyncTaskExecutors.createAsyncTaskExecutor(); + private ContactInfoCache contactInfoCache; // Tracks the position of the currently expanded list item. - private int mCurrentlyExpandedPosition = RecyclerView.NO_POSITION; + private int currentlyExpandedPosition = RecyclerView.NO_POSITION; // Tracks the rowId of the currently expanded list item, so the position can be updated if there // are any changes to the call log entries, such as additions or removals. - private long mCurrentlyExpandedRowId = NO_EXPANDED_LIST_ITEM; + private long currentlyExpandedRowId = NO_EXPANDED_LIST_ITEM; - private final CallLogAlertManager mCallLogAlertManager; + private final CallLogAlertManager callLogAlertManager; - public ActionMode mActionMode = null; + public ActionMode actionMode = null; public boolean selectAllMode = false; public boolean deselectAllMode = false; private final SparseArray<String> selectedItems = new SparseArray<>(); - private final ActionMode.Callback mActionModeCallback = + private final ActionMode.Callback actionModeCallback = new ActionMode.Callback() { // Called when the action mode is created; startActionMode() was called @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { - if (mActivity != null) { + if (activity != null) { announceforAccessibility( - mActivity.getCurrentFocus(), - mActivity.getString(R.string.description_entering_bulk_action_mode)); + activity.getCurrentFocus(), + activity.getString(R.string.description_entering_bulk_action_mode)); } - mActionMode = mode; + actionMode = mode; // Inflate a menu resource providing context menu items MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.actionbar_delete, menu); - mMultiSelectRemoveView.showMultiSelectRemoveView(true); - mActionModeStateChangedListener.onActionModeStateChanged(true); + multiSelectRemoveView.showMultiSelectRemoveView(true); + actionModeStateChangedListener.onActionModeStateChanged(true); return true; } @@ -178,7 +178,7 @@ public class CallLogAdapter extends GroupingListAdapter @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { if (item.getItemId() == R.id.action_bar_delete_menu_item) { - Logger.get(mActivity).logImpression(DialerImpression.Type.MULTISELECT_TAP_DELETE_ICON); + Logger.get(activity).logImpression(DialerImpression.Type.MULTISELECT_TAP_DELETE_ICON); if (selectedItems.size() > 0) { showDeleteSelectedItemsDialog(); } @@ -191,27 +191,27 @@ public class CallLogAdapter extends GroupingListAdapter // Called when the user exits the action mode @Override public void onDestroyActionMode(ActionMode mode) { - if (mActivity != null) { + if (activity != null) { announceforAccessibility( - mActivity.getCurrentFocus(), - mActivity.getString(R.string.description_leaving_bulk_action_mode)); + activity.getCurrentFocus(), + activity.getString(R.string.description_leaving_bulk_action_mode)); } selectedItems.clear(); - mActionMode = null; + actionMode = null; selectAllMode = false; deselectAllMode = false; - mMultiSelectRemoveView.showMultiSelectRemoveView(false); - mActionModeStateChangedListener.onActionModeStateChanged(false); + multiSelectRemoveView.showMultiSelectRemoveView(false); + actionModeStateChangedListener.onActionModeStateChanged(false); notifyDataSetChanged(); } }; private void showDeleteSelectedItemsDialog() { SparseArray<String> voicemailsToDeleteOnConfirmation = selectedItems.clone(); - new AlertDialog.Builder(mActivity, R.style.AlertDialogCustom) + new AlertDialog.Builder(activity, R.style.AlertDialogCustom) .setCancelable(true) .setTitle( - mActivity + activity .getResources() .getQuantityString( R.plurals.delete_voicemails_confirmation_dialog_title, selectedItems.size())) @@ -224,9 +224,9 @@ public class CallLogAdapter extends GroupingListAdapter "CallLogAdapter.showDeleteSelectedItemsDialog", "onClick, these items to delete " + voicemailsToDeleteOnConfirmation); deleteSelectedItems(voicemailsToDeleteOnConfirmation); - mActionMode.finish(); + actionMode.finish(); dialog.cancel(); - Logger.get(mActivity) + Logger.get(activity) .logImpression( DialerImpression.Type.MULTISELECT_DELETE_ENTRY_VIA_CONFIRMATION_DIALOG); } @@ -235,7 +235,7 @@ public class CallLogAdapter extends GroupingListAdapter new OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) { - Logger.get(mActivity) + Logger.get(activity) .logImpression( DialerImpression.Type .MULTISELECT_CANCEL_CONFIRMATION_DIALOG_VIA_CANCEL_TOUCH); @@ -247,7 +247,7 @@ public class CallLogAdapter extends GroupingListAdapter new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int button) { - Logger.get(mActivity) + Logger.get(activity) .logImpression( DialerImpression.Type .MULTISELECT_CANCEL_CONFIRMATION_DIALOG_VIA_CANCEL_BUTTON); @@ -255,7 +255,7 @@ public class CallLogAdapter extends GroupingListAdapter } }) .show(); - Logger.get(mActivity) + Logger.get(activity) .logImpression(DialerImpression.Type.MULTISELECT_DISPLAY_DELETE_CONFIRMATION_DIALOG); } @@ -263,30 +263,30 @@ public class CallLogAdapter extends GroupingListAdapter for (int i = 0; i < voicemailsToDelete.size(); i++) { String voicemailUri = voicemailsToDelete.get(voicemailsToDelete.keyAt(i)); LogUtil.i("CallLogAdapter.deleteSelectedItems", "deleting uri:" + voicemailUri); - CallLogAsyncTaskUtil.deleteVoicemail(mActivity, Uri.parse(voicemailUri), null); + CallLogAsyncTaskUtil.deleteVoicemail(activity, Uri.parse(voicemailUri), null); } } - private final View.OnLongClickListener mLongPressListener = + private final View.OnLongClickListener longPressListener = new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (ConfigProviderBindings.get(v.getContext()) .getBoolean(ENABLE_CALL_LOG_MULTI_SELECT, ENABLE_CALL_LOG_MULTI_SELECT_FLAG) - && mVoicemailPlaybackPresenter != null) { + && voicemailPlaybackPresenter != null) { if (v.getId() == R.id.primary_action_view || v.getId() == R.id.quick_contact_photo) { - if (mActionMode == null) { - Logger.get(mActivity) + if (actionMode == null) { + Logger.get(activity) .logImpression( DialerImpression.Type.MULTISELECT_LONG_PRESS_ENTER_MULTI_SELECT_MODE); - mActionMode = v.startActionMode(mActionModeCallback); + actionMode = v.startActionMode(actionModeCallback); } - Logger.get(mActivity) + Logger.get(activity) .logImpression(DialerImpression.Type.MULTISELECT_LONG_PRESS_TAP_ENTRY); CallLogListItemViewHolder viewHolder = (CallLogListItemViewHolder) v.getTag(); viewHolder.quickContactView.setVisibility(View.GONE); viewHolder.checkBoxView.setVisibility(View.VISIBLE); - mExpandCollapseListener.onClick(v); + expandCollapseListener.onClick(v); return true; } } @@ -296,11 +296,11 @@ public class CallLogAdapter extends GroupingListAdapter @VisibleForTesting public View.OnClickListener getExpandCollapseListener() { - return mExpandCollapseListener; + return expandCollapseListener; } /** The OnClickListener used to expand or collapse the action buttons of a call log entry. */ - private final View.OnClickListener mExpandCollapseListener = + private final View.OnClickListener expandCollapseListener = new View.OnClickListener() { @Override public void onClick(View v) { @@ -310,17 +310,17 @@ public class CallLogAdapter extends GroupingListAdapter if (viewHolder == null) { return; } - if (mActionMode != null && viewHolder.voicemailUri != null) { + if (actionMode != null && viewHolder.voicemailUri != null) { selectAllMode = false; deselectAllMode = false; - mMultiSelectRemoveView.setSelectAllModeToFalse(); + multiSelectRemoveView.setSelectAllModeToFalse(); int id = getVoicemailId(viewHolder.voicemailUri); if (selectedItems.get(id) != null) { - Logger.get(mActivity) + Logger.get(activity) .logImpression(DialerImpression.Type.MULTISELECT_SINGLE_PRESS_UNSELECT_ENTRY); uncheckMarkCallLogEntry(viewHolder, id); } else { - Logger.get(mActivity) + Logger.get(activity) .logImpression(DialerImpression.Type.MULTISELECT_SINGLE_PRESS_SELECT_ENTRY); checkMarkCallLogEntry(viewHolder); // select all check box logic @@ -330,15 +330,15 @@ public class CallLogAdapter extends GroupingListAdapter "getitem count %d is equal to items select count %d, check select all box", getItemCount(), selectedItems.size()); - mMultiSelectRemoveView.tapSelectAll(); + multiSelectRemoveView.tapSelectAll(); } } return; } - if (mVoicemailPlaybackPresenter != null) { + if (voicemailPlaybackPresenter != null) { // Always reset the voicemail playback state on expand or collapse. - mVoicemailPlaybackPresenter.resetAll(); + voicemailPlaybackPresenter.resetAll(); } // If enriched call capabilities were unknown on the initial load, @@ -368,16 +368,16 @@ public class CallLogAdapter extends GroupingListAdapter getEnrichedCallManager().requestCapabilities(viewHolder.number); } - if (viewHolder.rowId == mCurrentlyExpandedRowId) { + if (viewHolder.rowId == currentlyExpandedRowId) { // Hide actions, if the clicked item is the expanded item. viewHolder.showActions(false); - mCurrentlyExpandedPosition = RecyclerView.NO_POSITION; - mCurrentlyExpandedRowId = NO_EXPANDED_LIST_ITEM; + currentlyExpandedPosition = RecyclerView.NO_POSITION; + currentlyExpandedRowId = NO_EXPANDED_LIST_ITEM; } else { if (viewHolder.callType == CallLog.Calls.MISSED_TYPE) { - CallLogAsyncTaskUtil.markCallAsRead(mActivity, viewHolder.callIds); - if (mActivityType == ACTIVITY_TYPE_DIALTACTS) { + CallLogAsyncTaskUtil.markCallAsRead(activity, viewHolder.callIds); + if (activityType == ACTIVITY_TYPE_DIALTACTS) { ((DialtactsActivity) v.getContext()).updateTabUnreadCounts(); } } @@ -400,7 +400,7 @@ public class CallLogAdapter extends GroupingListAdapter if (intentProvider == null) { return false; } - return DuoConstants.PACKAGE_NAME.equals(intentProvider.getIntent(mActivity).getPackage()); + return DuoConstants.PACKAGE_NAME.equals(intentProvider.getIntent(activity).getPackage()); } }; @@ -411,8 +411,8 @@ public class CallLogAdapter extends GroupingListAdapter private void checkMarkCallLogEntry(CallLogListItemViewHolder viewHolder) { announceforAccessibility( - mActivity.getCurrentFocus(), - mActivity.getString( + activity.getCurrentFocus(), + activity.getString( R.string.description_selecting_bulk_action_mode, viewHolder.nameOrNumber)); viewHolder.quickContactView.setVisibility(View.GONE); viewHolder.checkBoxView.setVisibility(View.VISIBLE); @@ -427,14 +427,14 @@ public class CallLogAdapter extends GroupingListAdapter } private void updateActionBar() { - if (mActionMode == null && selectedItems.size() > 0) { - Logger.get(mActivity) + if (actionMode == null && selectedItems.size() > 0) { + Logger.get(activity) .logImpression(DialerImpression.Type.MULTISELECT_ROTATE_AND_SHOW_ACTION_MODE); - mActivity.startActionMode(mActionModeCallback); + activity.startActionMode(actionModeCallback); } - if (mActionMode != null) { - mActionMode.setTitle( - mActivity + if (actionMode != null) { + actionMode.setTitle( + activity .getResources() .getString( R.string.voicemailMultiSelectActionBarTitle, @@ -444,8 +444,8 @@ public class CallLogAdapter extends GroupingListAdapter private void uncheckMarkCallLogEntry(CallLogListItemViewHolder viewHolder, int id) { announceforAccessibility( - mActivity.getCurrentFocus(), - mActivity.getString( + activity.getCurrentFocus(), + activity.getString( R.string.description_unselecting_bulk_action_mode, viewHolder.nameOrNumber)); selectedItems.delete(id); viewHolder.checkBoxView.setVisibility(View.GONE); @@ -464,7 +464,7 @@ public class CallLogAdapter extends GroupingListAdapter * if removing an item, it will be shown as an invisible view. This simplifies the calculation of * item position. */ - @NonNull private Set<Long> mHiddenRowIds = new ArraySet<>(); + @NonNull private Set<Long> hiddenRowIds = new ArraySet<>(); /** * Holds a list of URIs that are pending deletion or undo. If the activity ends before the undo * timeout, all of the pending URIs will be deleted. @@ -473,9 +473,9 @@ public class CallLogAdapter extends GroupingListAdapter * VisualVoicemailCallLogFragment}. The CallLogAdapter does not need to know about what to do with * hidden item or what to hide. */ - @NonNull private final Set<Uri> mHiddenItemUris = new ArraySet<>(); + @NonNull private final Set<Uri> hiddenItemUris = new ArraySet<>(); - private CallLogListItemViewHolder.OnClickListener mBlockReportSpamListener; + private CallLogListItemViewHolder.OnClickListener blockReportSpamListener; /** * Map, keyed by call ID, used to track the callback action for a call. Calls associated with the @@ -483,7 +483,7 @@ public class CallLogAdapter extends GroupingListAdapter * com.android.dialer.app.calllog.CallLogGroupBuilder}. This information is used to set the * callback icon and trigger the corresponding action. */ - private final Map<Long, Integer> mCallbackActions = new ArrayMap<>(); + private final Map<Long, Integer> callbackActions = new ArrayMap<>(); /** * Map, keyed by call ID, used to track the day group for a call. As call log entries are put into @@ -497,12 +497,12 @@ public class CallLogAdapter extends GroupingListAdapter * previous day group without having to reverse the cursor to the start of the previous day call * log entry. */ - private final Map<Long, Integer> mDayGroups = new ArrayMap<>(); + private final Map<Long, Integer> dayGroups = new ArrayMap<>(); - private boolean mLoading = true; - private ContactsPreferences mContactsPreferences; + private boolean loading = true; + private ContactsPreferences contactsPreferences; - private boolean mIsSpamEnabled; + private boolean isSpamEnabled; public CallLogAdapter( Activity activity, @@ -517,58 +517,58 @@ public class CallLogAdapter extends GroupingListAdapter int activityType) { super(); - mActivity = activity; - mCallFetcher = callFetcher; - mActionModeStateChangedListener = actionModeStateChangedListener; - mMultiSelectRemoveView = multiSelectRemoveView; - mVoicemailPlaybackPresenter = voicemailPlaybackPresenter; - if (mVoicemailPlaybackPresenter != null) { - mVoicemailPlaybackPresenter.setOnVoicemailDeletedListener(this); + this.activity = activity; + this.callFetcher = callFetcher; + this.actionModeStateChangedListener = actionModeStateChangedListener; + this.multiSelectRemoveView = multiSelectRemoveView; + this.voicemailPlaybackPresenter = voicemailPlaybackPresenter; + if (this.voicemailPlaybackPresenter != null) { + this.voicemailPlaybackPresenter.setOnVoicemailDeletedListener(this); } - mActivityType = activityType; + this.activityType = activityType; - mContactInfoCache = contactInfoCache; + this.contactInfoCache = contactInfoCache; if (!PermissionsUtil.hasContactsReadPermissions(activity)) { - mContactInfoCache.disableRequestProcessing(); + this.contactInfoCache.disableRequestProcessing(); } - Resources resources = mActivity.getResources(); + Resources resources = this.activity.getResources(); - mCallLogCache = callLogCache; + this.callLogCache = callLogCache; PhoneCallDetailsHelper phoneCallDetailsHelper = - new PhoneCallDetailsHelper(mActivity, resources, mCallLogCache); - mCallLogListItemHelper = - new CallLogListItemHelper(phoneCallDetailsHelper, resources, mCallLogCache); - mCallLogGroupBuilder = new CallLogGroupBuilder(this); - mFilteredNumberAsyncQueryHandler = Assert.isNotNull(filteredNumberAsyncQueryHandler); + new PhoneCallDetailsHelper(this.activity, resources, this.callLogCache); + callLogListItemHelper = + new CallLogListItemHelper(phoneCallDetailsHelper, resources, this.callLogCache); + callLogGroupBuilder = new CallLogGroupBuilder(this); + this.filteredNumberAsyncQueryHandler = Assert.isNotNull(filteredNumberAsyncQueryHandler); - mContactsPreferences = new ContactsPreferences(mActivity); + contactsPreferences = new ContactsPreferences(this.activity); - mBlockReportSpamListener = + blockReportSpamListener = new BlockReportSpamListener( - mActivity, - ((Activity) mActivity).getFragmentManager(), + this.activity, + ((Activity) this.activity).getFragmentManager(), this, - mFilteredNumberAsyncQueryHandler); + this.filteredNumberAsyncQueryHandler); setHasStableIds(true); - mCallLogAlertManager = - new CallLogAlertManager(this, LayoutInflater.from(mActivity), alertContainer); + callLogAlertManager = + new CallLogAlertManager(this, LayoutInflater.from(this.activity), alertContainer); } private void expandViewHolderActions(CallLogListItemViewHolder viewHolder) { if (!TextUtils.isEmpty(viewHolder.voicemailUri)) { - Logger.get(mActivity).logImpression(DialerImpression.Type.VOICEMAIL_EXPAND_ENTRY); + Logger.get(activity).logImpression(DialerImpression.Type.VOICEMAIL_EXPAND_ENTRY); } - int lastExpandedPosition = mCurrentlyExpandedPosition; + int lastExpandedPosition = currentlyExpandedPosition; // Show the actions for the clicked list item. viewHolder.showActions(true); - mCurrentlyExpandedPosition = viewHolder.getAdapterPosition(); - mCurrentlyExpandedRowId = viewHolder.rowId; + currentlyExpandedPosition = viewHolder.getAdapterPosition(); + currentlyExpandedRowId = viewHolder.rowId; // If another item is expanded, notify it that it has changed. Its actions will be // hidden when it is re-binded because we change mCurrentlyExpandedRowId above. @@ -578,8 +578,8 @@ public class CallLogAdapter extends GroupingListAdapter } public void onSaveInstanceState(Bundle outState) { - outState.putInt(KEY_EXPANDED_POSITION, mCurrentlyExpandedPosition); - outState.putLong(KEY_EXPANDED_ROW_ID, mCurrentlyExpandedRowId); + outState.putInt(KEY_EXPANDED_POSITION, currentlyExpandedPosition); + outState.putLong(KEY_EXPANDED_ROW_ID, currentlyExpandedRowId); ArrayList<String> listOfSelectedItems = new ArrayList<>(); @@ -603,9 +603,9 @@ public class CallLogAdapter extends GroupingListAdapter public void onRestoreInstanceState(Bundle savedInstanceState) { if (savedInstanceState != null) { - mCurrentlyExpandedPosition = + currentlyExpandedPosition = savedInstanceState.getInt(KEY_EXPANDED_POSITION, RecyclerView.NO_POSITION); - mCurrentlyExpandedRowId = + currentlyExpandedRowId = savedInstanceState.getLong(KEY_EXPANDED_ROW_ID, NO_EXPANDED_LIST_ITEM); // Restoring multi selected entries ArrayList<String> listOfSelectedItems = @@ -642,15 +642,15 @@ public class CallLogAdapter extends GroupingListAdapter /** Requery on background thread when {@link Cursor} changes. */ @Override protected void onContentChanged() { - mCallFetcher.fetchCalls(); + callFetcher.fetchCalls(); } public void setLoading(boolean loading) { - mLoading = loading; + this.loading = loading; } public boolean isEmpty() { - if (mLoading) { + if (loading) { // We don't want the empty state to show when loading. return false; } else { @@ -659,15 +659,15 @@ public class CallLogAdapter extends GroupingListAdapter } public void clearFilteredNumbersCache() { - mFilteredNumberAsyncQueryHandler.clearCache(); + filteredNumberAsyncQueryHandler.clearCache(); } public void onResume() { - if (PermissionsUtil.hasPermission(mActivity, android.Manifest.permission.READ_CONTACTS)) { - mContactInfoCache.start(); + if (PermissionsUtil.hasPermission(activity, android.Manifest.permission.READ_CONTACTS)) { + contactInfoCache.start(); } - mContactsPreferences.refreshValue(ContactsPreferences.DISPLAY_ORDER_KEY); - mIsSpamEnabled = SpamComponent.get(mActivity).spam().isSpamEnabled(); + contactsPreferences.refreshValue(ContactsPreferences.DISPLAY_ORDER_KEY); + isSpamEnabled = SpamComponent.get(activity).spam().isSpamEnabled(); getDuo().registerListener(this); notifyDataSetChanged(); } @@ -675,8 +675,8 @@ public class CallLogAdapter extends GroupingListAdapter public void onPause() { getDuo().unregisterListener(this); pauseCache(); - for (Uri uri : mHiddenItemUris) { - CallLogAsyncTaskUtil.deleteVoicemail(mActivity, uri, null); + for (Uri uri : hiddenItemUris) { + CallLogAsyncTaskUtil.deleteVoicemail(activity, uri, null); } } @@ -685,24 +685,24 @@ public class CallLogAdapter extends GroupingListAdapter } public CallLogAlertManager getAlertManager() { - return mCallLogAlertManager; + return callLogAlertManager; } @VisibleForTesting /* package */ void pauseCache() { - mContactInfoCache.stop(); - mCallLogCache.reset(); + contactInfoCache.stop(); + callLogCache.reset(); } @Override protected void addGroups(Cursor cursor) { - mCallLogGroupBuilder.addGroups(cursor); + callLogGroupBuilder.addGroups(cursor); } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { if (viewType == VIEW_TYPE_ALERT) { - return mCallLogAlertManager.createViewHolder(parent); + return callLogAlertManager.createViewHolder(parent); } return createCallLogEntryViewHolder(parent); } @@ -714,19 +714,19 @@ public class CallLogAdapter extends GroupingListAdapter * @return The {@link ViewHolder}. */ private ViewHolder createCallLogEntryViewHolder(ViewGroup parent) { - LayoutInflater inflater = LayoutInflater.from(mActivity); + LayoutInflater inflater = LayoutInflater.from(activity); View view = inflater.inflate(R.layout.call_log_list_item, parent, false); CallLogListItemViewHolder viewHolder = CallLogListItemViewHolder.create( view, - mActivity, - mBlockReportSpamListener, - mExpandCollapseListener, - mLongPressListener, - mActionModeStateChangedListener, - mCallLogCache, - mCallLogListItemHelper, - mVoicemailPlaybackPresenter); + activity, + blockReportSpamListener, + expandCollapseListener, + longPressListener, + actionModeStateChangedListener, + callLogCache, + callLogListItemHelper, + voicemailPlaybackPresenter); viewHolder.callLogEntryView.setTag(viewHolder); @@ -802,7 +802,7 @@ public class CallLogAdapter extends GroupingListAdapter int groupSize = getGroupSize(position); CallDetailsEntries callDetailsEntries = createCallDetailsEntries(c, groupSize); PhoneCallDetails details = createPhoneCallDetails(c, groupSize, views); - if (mHiddenRowIds.contains(c.getLong(CallLogQuery.ID))) { + if (hiddenRowIds.contains(c.getLong(CallLogQuery.ID))) { views.callLogEntryView.setVisibility(View.GONE); views.dayGroupHeader.setVisibility(View.GONE); return; @@ -810,7 +810,7 @@ public class CallLogAdapter extends GroupingListAdapter views.callLogEntryView.setVisibility(View.VISIBLE); // dayGroupHeader will be restored after loadAndRender() if it is needed. } - if (mCurrentlyExpandedRowId == views.rowId) { + if (currentlyExpandedRowId == views.rowId) { views.inflateActionViewStub(); } loadAndRender(views, views.rowId, details, callDetailsEntries); @@ -849,19 +849,19 @@ public class CallLogAdapter extends GroupingListAdapter @Override protected Boolean doInBackground(Void... params) { viewHolder.blockId = - mFilteredNumberAsyncQueryHandler.getBlockedIdSynchronous( + filteredNumberAsyncQueryHandler.getBlockedIdSynchronous( viewHolder.number, viewHolder.countryIso); details.isBlocked = viewHolder.blockId != null; if (isCancelled()) { return false; } - if (mIsSpamEnabled) { + if (isSpamEnabled) { viewHolder.isSpamFeatureEnabled = true; // Only display the call as a spam call if there are incoming calls in the list. // Call log cards with only outgoing calls should never be displayed as spam. viewHolder.isSpam = details.hasIncomingCalls() - && SpamComponent.get(mActivity) + && SpamComponent.get(activity) .spam() .checkSpamStatusSynchronous(viewHolder.number, viewHolder.countryIso); details.isSpam = viewHolder.isSpam; @@ -887,7 +887,7 @@ public class CallLogAdapter extends GroupingListAdapter }; viewHolder.asyncTask = loadDataTask; - mAsyncTaskExecutor.submit(LOAD_DATA_TASK_IDENTIFIER, loadDataTask); + asyncTaskExecutor.submit(LOAD_DATA_TASK_IDENTIFIER, loadDataTask); } @MainThread @@ -1011,8 +1011,7 @@ public class CallLogAdapter extends GroupingListAdapter final PhoneAccountHandle accountHandle = PhoneAccountUtils.getAccount(details.accountComponentName, details.accountId); - final boolean isVoicemailNumber = - mCallLogCache.isVoicemailNumber(accountHandle, details.number); + final boolean isVoicemailNumber = callLogCache.isVoicemailNumber(accountHandle, details.number); // Note: Binding of the action buttons is done as required in configureActionViews when the // user expands the actions ViewStub. @@ -1024,19 +1023,19 @@ public class CallLogAdapter extends GroupingListAdapter // Only do remote lookup in first 5 rows. int position = views.getAdapterPosition(); info = - mContactInfoCache.getValue( + contactInfoCache.getValue( details.number + details.postDialDigits, details.countryIso, details.cachedContactInfo, position - < ConfigProviderBindings.get(mActivity) + < ConfigProviderBindings.get(activity) .getLong("number_of_call_to_do_remote_lookup", 5L)); } CharSequence formattedNumber = info.formattedNumber == null ? null : PhoneNumberUtilsCompat.createTtsSpannable(info.formattedNumber); - details.updateDisplayNumber(mActivity, formattedNumber, isVoicemailNumber); + details.updateDisplayNumber(activity, formattedNumber, isVoicemailNumber); views.displayNumber = details.displayNumber; views.accountHandle = accountHandle; @@ -1046,7 +1045,7 @@ public class CallLogAdapter extends GroupingListAdapter details.contactUri = info.lookupUri; details.namePrimary = info.name; details.nameAlternative = info.nameAlternative; - details.nameDisplayOrder = mContactsPreferences.getDisplayOrder(); + details.nameDisplayOrder = contactsPreferences.getDisplayOrder(); details.numberType = info.type; details.numberLabel = info.label; details.photoUri = info.photoUri; @@ -1067,9 +1066,9 @@ public class CallLogAdapter extends GroupingListAdapter } views.info = info; - views.numberType = getNumberType(mActivity.getResources(), details); + views.numberType = getNumberType(activity.getResources(), details); - mCallLogListItemHelper.updatePhoneCallDetails(details); + callLogListItemHelper.updatePhoneCallDetails(details); return true; } @@ -1119,11 +1118,11 @@ public class CallLogAdapter extends GroupingListAdapter views.checkBoxView.setVisibility(View.GONE); views.quickContactView.setVisibility(View.VISIBLE); } - mCallLogListItemHelper.setPhoneCallDetails(views, details); - if (mCurrentlyExpandedRowId == views.rowId) { + callLogListItemHelper.setPhoneCallDetails(views, details); + if (currentlyExpandedRowId == views.rowId) { // In case ViewHolders were added/removed, update the expanded position if the rowIds // match so that we can restore the correct expanded state on rebind. - mCurrentlyExpandedPosition = views.getAdapterPosition(); + currentlyExpandedPosition = views.getAdapterPosition(); views.showActions(true); } else { views.showActions(false); @@ -1134,12 +1133,12 @@ public class CallLogAdapter extends GroupingListAdapter @Override public int getItemCount() { - return super.getItemCount() + (mCallLogAlertManager.isEmpty() ? 0 : 1); + return super.getItemCount() + (callLogAlertManager.isEmpty() ? 0 : 1); } @Override public int getItemViewType(int position) { - if (position == ALERT_POSITION && !mCallLogAlertManager.isEmpty()) { + if (position == ALERT_POSITION && !callLogAlertManager.isEmpty()) { return VIEW_TYPE_ALERT; } return VIEW_TYPE_CALLLOG; @@ -1153,7 +1152,7 @@ public class CallLogAdapter extends GroupingListAdapter */ @Override public Object getItem(int position) { - return super.getItem(position - (mCallLogAlertManager.isEmpty() ? 0 : 1)); + return super.getItem(position - (callLogAlertManager.isEmpty() ? 0 : 1)); } @Override @@ -1168,11 +1167,11 @@ public class CallLogAdapter extends GroupingListAdapter @Override public int getGroupSize(int position) { - return super.getGroupSize(position - (mCallLogAlertManager.isEmpty() ? 0 : 1)); + return super.getGroupSize(position - (callLogAlertManager.isEmpty() ? 0 : 1)); } protected boolean isCallLogActivity() { - return mActivityType == ACTIVITY_TYPE_CALL_LOG; + return activityType == ACTIVITY_TYPE_CALL_LOG; } /** @@ -1183,9 +1182,9 @@ public class CallLogAdapter extends GroupingListAdapter */ @Override public void onVoicemailDeleted(CallLogListItemViewHolder viewHolder, Uri uri) { - mHiddenRowIds.add(viewHolder.rowId); + hiddenRowIds.add(viewHolder.rowId); // Save the new hidden item uri in case the activity is suspend before the undo has timed out. - mHiddenItemUris.add(uri); + hiddenItemUris.add(uri); collapseExpandedCard(); notifyItemChanged(viewHolder.getAdapterPosition()); @@ -1194,20 +1193,20 @@ public class CallLogAdapter extends GroupingListAdapter } private void collapseExpandedCard() { - mCurrentlyExpandedRowId = NO_EXPANDED_LIST_ITEM; - mCurrentlyExpandedPosition = RecyclerView.NO_POSITION; + currentlyExpandedRowId = NO_EXPANDED_LIST_ITEM; + currentlyExpandedPosition = RecyclerView.NO_POSITION; } /** When the list is changing all stored position is no longer valid. */ public void invalidatePositions() { - mCurrentlyExpandedPosition = RecyclerView.NO_POSITION; + currentlyExpandedPosition = RecyclerView.NO_POSITION; } /** When the user clicks "undo", the hidden item is unhidden. */ @Override public void onVoicemailDeleteUndo(long rowId, int adapterPosition, Uri uri) { - mHiddenItemUris.remove(uri); - mHiddenRowIds.remove(rowId); + hiddenItemUris.remove(uri); + hiddenRowIds.remove(rowId); notifyItemChanged(adapterPosition); // The next item might have to update its day group label notifyItemChanged(adapterPosition + 1); @@ -1216,7 +1215,7 @@ public class CallLogAdapter extends GroupingListAdapter /** This callback signifies that a database deletion has completed. */ @Override public void onVoicemailDeletedInDatabase(long rowId, Uri uri) { - mHiddenItemUris.remove(uri); + hiddenItemUris.remove(uri); } /** @@ -1240,7 +1239,7 @@ public class CallLogAdapter extends GroupingListAdapter } private void moveToPreviousNonHiddenRow(Cursor cursor) { - while (cursor.moveToPrevious() && mHiddenRowIds.contains(cursor.getLong(CallLogQuery.ID))) {} + while (cursor.moveToPrevious() && hiddenRowIds.contains(cursor.getLong(CallLogQuery.ID))) {} } /** @@ -1252,7 +1251,7 @@ public class CallLogAdapter extends GroupingListAdapter */ @MainThread private int getCallbackAction(long callId) { - Integer result = mCallbackActions.get(callId); + Integer result = callbackActions.get(callId); if (result != null) { return result; } @@ -1268,7 +1267,7 @@ public class CallLogAdapter extends GroupingListAdapter */ @MainThread private int getDayGroup(long callId) { - Integer result = mDayGroups.get(callId); + Integer result = dayGroups.get(callId); if (result != null) { return result; } @@ -1320,13 +1319,13 @@ public class CallLogAdapter extends GroupingListAdapter @VisibleForTesting void disableRequestProcessingForTest() { // TODO: Remove this and test the cache directly. - mContactInfoCache.disableRequestProcessing(); + contactInfoCache.disableRequestProcessing(); } @VisibleForTesting void injectContactInfoForTest(String number, String countryIso, ContactInfo contactInfo) { // TODO: Remove this and test the cache directly. - mContactInfoCache.injectContactInfoForTest(number, countryIso, contactInfo); + contactInfoCache.injectContactInfoForTest(number, countryIso, contactInfo); } /** @@ -1338,7 +1337,7 @@ public class CallLogAdapter extends GroupingListAdapter @Override @MainThread public void setCallbackAction(long rowId, @CallbackAction int callbackAction) { - mCallbackActions.put(rowId, callbackAction); + callbackActions.put(rowId, callbackAction); } /** @@ -1350,14 +1349,14 @@ public class CallLogAdapter extends GroupingListAdapter @Override @MainThread public void setDayGroup(long rowId, int dayGroup) { - mDayGroups.put(rowId, dayGroup); + dayGroups.put(rowId, dayGroup); } /** Clears the day group associations on re-bind of the call log. */ @Override @MainThread public void clearDayGroups() { - mDayGroups.clear(); + dayGroups.clear(); } /** @@ -1388,22 +1387,22 @@ public class CallLogAdapter extends GroupingListAdapter */ private CharSequence getGroupDescription(int group) { if (group == CallLogGroupBuilder.DAY_GROUP_TODAY) { - return mActivity.getResources().getString(R.string.call_log_header_today); + return activity.getResources().getString(R.string.call_log_header_today); } else if (group == CallLogGroupBuilder.DAY_GROUP_YESTERDAY) { - return mActivity.getResources().getString(R.string.call_log_header_yesterday); + return activity.getResources().getString(R.string.call_log_header_yesterday); } else { - return mActivity.getResources().getString(R.string.call_log_header_other); + return activity.getResources().getString(R.string.call_log_header_other); } } @NonNull private EnrichedCallManager getEnrichedCallManager() { - return EnrichedCallComponent.get(mActivity).getEnrichedCallManager(); + return EnrichedCallComponent.get(activity).getEnrichedCallManager(); } @NonNull private Duo getDuo() { - return DuoComponent.get(mActivity).getDuo(); + return DuoComponent.get(activity).getDuo(); } @Override diff --git a/java/com/android/dialer/app/calllog/CallLogAsync.java b/java/com/android/dialer/app/calllog/CallLogAsync.java index f62deca89..26435f311 100644 --- a/java/com/android/dialer/app/calllog/CallLogAsync.java +++ b/java/com/android/dialer/app/calllog/CallLogAsync.java @@ -65,10 +65,10 @@ public class CallLogAsync { /** AsyncTask to get the last outgoing call from the DB. */ private class GetLastOutgoingCallTask extends AsyncTask<GetLastOutgoingCallArgs, Void, String> { - private final OnLastOutgoingCallComplete mCallback; + private final OnLastOutgoingCallComplete callback; public GetLastOutgoingCallTask(OnLastOutgoingCallComplete callback) { - mCallback = callback; + this.callback = callback; } // Happens on a background thread. We cannot run the callback @@ -90,7 +90,7 @@ public class CallLogAsync { @Override protected void onPostExecute(String number) { Assert.isMainThread(); - mCallback.lastOutgoingCall(number); + callback.lastOutgoingCall(number); } } } diff --git a/java/com/android/dialer/app/calllog/CallLogAsyncTaskUtil.java b/java/com/android/dialer/app/calllog/CallLogAsyncTaskUtil.java index c0d30f53a..08f5585b0 100644 --- a/java/com/android/dialer/app/calllog/CallLogAsyncTaskUtil.java +++ b/java/com/android/dialer/app/calllog/CallLogAsyncTaskUtil.java @@ -38,20 +38,20 @@ import com.android.voicemail.VoicemailClient; public class CallLogAsyncTaskUtil { private static final String TAG = "CallLogAsyncTaskUtil"; - private static AsyncTaskExecutor sAsyncTaskExecutor; + private static AsyncTaskExecutor asyncTaskExecutor; private static void initTaskExecutor() { - sAsyncTaskExecutor = AsyncTaskExecutors.createThreadPoolExecutor(); + asyncTaskExecutor = AsyncTaskExecutors.createThreadPoolExecutor(); } public static void markVoicemailAsRead( @NonNull final Context context, @NonNull final Uri voicemailUri) { LogUtil.enterBlock("CallLogAsyncTaskUtil.markVoicemailAsRead, voicemailUri: " + voicemailUri); - if (sAsyncTaskExecutor == null) { + if (asyncTaskExecutor == null) { initTaskExecutor(); } - sAsyncTaskExecutor.submit( + asyncTaskExecutor.submit( Tasks.MARK_VOICEMAIL_READ, new AsyncTask<Void, Void, Void>() { @Override @@ -77,11 +77,11 @@ public class CallLogAsyncTaskUtil { @NonNull final Context context, final Uri voicemailUri, @Nullable final CallLogAsyncTaskListener callLogAsyncTaskListener) { - if (sAsyncTaskExecutor == null) { + if (asyncTaskExecutor == null) { initTaskExecutor(); } - sAsyncTaskExecutor.submit( + asyncTaskExecutor.submit( Tasks.DELETE_VOICEMAIL, new AsyncTask<Void, Void, Void>() { @Override @@ -113,11 +113,11 @@ public class CallLogAsyncTaskUtil { || !PermissionsUtil.hasCallLogWritePermissions(context)) { return; } - if (sAsyncTaskExecutor == null) { + if (asyncTaskExecutor == null) { initTaskExecutor(); } - sAsyncTaskExecutor.submit( + asyncTaskExecutor.submit( Tasks.MARK_CALL_READ, new AsyncTask<Void, Void, Void>() { @Override diff --git a/java/com/android/dialer/app/calllog/CallLogFragment.java b/java/com/android/dialer/app/calllog/CallLogFragment.java index 6910f1918..4f5035fc6 100644 --- a/java/com/android/dialer/app/calllog/CallLogFragment.java +++ b/java/com/android/dialer/app/calllog/CallLogFragment.java @@ -101,47 +101,47 @@ public class CallLogFragment extends Fragment private static final int EVENT_UPDATE_DISPLAY = 1; private static final long MILLIS_IN_MINUTE = 60 * 1000; - private final Handler mHandler = new Handler(); + private final Handler handler = new Handler(); // See issue 6363009 - private final ContentObserver mCallLogObserver = new CustomContentObserver(); - private final ContentObserver mContactsObserver = new CustomContentObserver(); - private View mMultiSelectUnSelectAllViewContent; - private TextView mSelectUnselectAllViewText; - private ImageView mSelectUnselectAllIcon; - private RecyclerView mRecyclerView; - private LinearLayoutManager mLayoutManager; - private CallLogAdapter mAdapter; - private CallLogQueryHandler mCallLogQueryHandler; - private boolean mScrollToTop; - private EmptyContentView mEmptyListView; - private ContactInfoCache mContactInfoCache; - private final OnContactInfoChangedListener mOnContactInfoChangedListener = + private final ContentObserver callLogObserver = new CustomContentObserver(); + private final ContentObserver contactsObserver = new CustomContentObserver(); + private View multiSelectUnSelectAllViewContent; + private TextView selectUnselectAllViewText; + private ImageView selectUnselectAllIcon; + private RecyclerView recyclerView; + private LinearLayoutManager layoutManager; + private CallLogAdapter adapter; + private CallLogQueryHandler callLogQueryHandler; + private boolean scrollToTop; + private EmptyContentView emptyListView; + private ContactInfoCache contactInfoCache; + private final OnContactInfoChangedListener onContactInfoChangedListener = new OnContactInfoChangedListener() { @Override public void onContactInfoChanged() { - if (mAdapter != null) { - mAdapter.notifyDataSetChanged(); + if (adapter != null) { + adapter.notifyDataSetChanged(); } } }; - private boolean mRefreshDataRequired; - private boolean mHasReadCallLogPermission; + private boolean refreshDataRequired; + private boolean hasReadCallLogPermission; // Exactly same variable is in Fragment as a package private. - private boolean mMenuVisible = true; + private boolean menuVisible = true; // Default to all calls. - private int mCallTypeFilter = CallLogQueryHandler.CALL_TYPE_ALL; + private int callTypeFilter = CallLogQueryHandler.CALL_TYPE_ALL; // Log limit - if no limit is specified, then the default in {@link CallLogQueryHandler} // will be used. - private int mLogLimit = NO_LOG_LIMIT; + private int logLimit = NO_LOG_LIMIT; // Date limit (in millis since epoch) - when non-zero, only calls which occurred on or after // the date filter are included. If zero, no date-based filtering occurs. - private long mDateLimit = NO_DATE_LIMIT; + private long dateLimit = NO_DATE_LIMIT; /* * True if this instance of the CallLogFragment shown in the CallLogActivity. */ - private boolean mIsCallLogActivity = false; + private boolean isCallLogActivity = false; private boolean selectAllMode; - private final Handler mDisplayUpdateHandler = + private final Handler displayUpdateHandler = new Handler() { @Override public void handleMessage(Message msg) { @@ -155,8 +155,8 @@ public class CallLogFragment extends Fragment } } }; - protected CallLogModalAlertManager mModalAlertManager; - private ViewGroup mModalAlertView; + protected CallLogModalAlertManager modalAlertManager; + private ViewGroup modalAlertView; public CallLogFragment() { this(CallLogQueryHandler.CALL_TYPE_ALL, NO_LOG_LIMIT); @@ -168,7 +168,7 @@ public class CallLogFragment extends Fragment public CallLogFragment(int filterType, boolean isCallLogActivity) { this(filterType, NO_LOG_LIMIT); - mIsCallLogActivity = isCallLogActivity; + this.isCallLogActivity = isCallLogActivity; } public CallLogFragment(int filterType, int logLimit) { @@ -195,38 +195,38 @@ public class CallLogFragment extends Fragment * @param dateLimit limits results to calls occurring on or after the specified date. */ public CallLogFragment(int filterType, int logLimit, long dateLimit) { - mCallTypeFilter = filterType; - mLogLimit = logLimit; - mDateLimit = dateLimit; + callTypeFilter = filterType; + this.logLimit = logLimit; + this.dateLimit = dateLimit; } @Override public void onCreate(Bundle state) { LogUtil.enterBlock("CallLogFragment.onCreate"); super.onCreate(state); - mRefreshDataRequired = true; + refreshDataRequired = true; if (state != null) { - mCallTypeFilter = state.getInt(KEY_FILTER_TYPE, mCallTypeFilter); - mLogLimit = state.getInt(KEY_LOG_LIMIT, mLogLimit); - mDateLimit = state.getLong(KEY_DATE_LIMIT, mDateLimit); - mIsCallLogActivity = state.getBoolean(KEY_IS_CALL_LOG_ACTIVITY, mIsCallLogActivity); - mHasReadCallLogPermission = state.getBoolean(KEY_HAS_READ_CALL_LOG_PERMISSION, false); - mRefreshDataRequired = state.getBoolean(KEY_REFRESH_DATA_REQUIRED, mRefreshDataRequired); + callTypeFilter = state.getInt(KEY_FILTER_TYPE, callTypeFilter); + logLimit = state.getInt(KEY_LOG_LIMIT, logLimit); + dateLimit = state.getLong(KEY_DATE_LIMIT, dateLimit); + isCallLogActivity = state.getBoolean(KEY_IS_CALL_LOG_ACTIVITY, isCallLogActivity); + hasReadCallLogPermission = state.getBoolean(KEY_HAS_READ_CALL_LOG_PERMISSION, false); + refreshDataRequired = state.getBoolean(KEY_REFRESH_DATA_REQUIRED, refreshDataRequired); selectAllMode = state.getBoolean(KEY_SELECT_ALL_MODE, false); } final Activity activity = getActivity(); final ContentResolver resolver = activity.getContentResolver(); - mCallLogQueryHandler = new CallLogQueryHandler(activity, resolver, this, mLogLimit); + callLogQueryHandler = new CallLogQueryHandler(activity, resolver, this, logLimit); if (PermissionsUtil.hasCallLogReadPermissions(getContext())) { - resolver.registerContentObserver(CallLog.CONTENT_URI, true, mCallLogObserver); + resolver.registerContentObserver(CallLog.CONTENT_URI, true, callLogObserver); } else { LogUtil.w("CallLogFragment.onCreate", "call log permission not available"); } if (PermissionsUtil.hasContactsReadPermissions(getContext())) { resolver.registerContentObserver( - ContactsContract.Contacts.CONTENT_URI, true, mContactsObserver); + ContactsContract.Contacts.CONTENT_URI, true, contactsObserver); } else { LogUtil.w("CallLogFragment.onCreate", "contacts permission not available."); } @@ -240,49 +240,49 @@ public class CallLogFragment extends Fragment // Return false; we did not take ownership of the cursor return false; } - mAdapter.invalidatePositions(); - mAdapter.setLoading(false); - mAdapter.changeCursor(cursor); + adapter.invalidatePositions(); + adapter.setLoading(false); + adapter.changeCursor(cursor); // This will update the state of the "Clear call log" menu item. getActivity().invalidateOptionsMenu(); if (cursor != null && cursor.getCount() > 0) { - mRecyclerView.setPaddingRelative( - mRecyclerView.getPaddingStart(), + recyclerView.setPaddingRelative( + recyclerView.getPaddingStart(), 0, - mRecyclerView.getPaddingEnd(), + recyclerView.getPaddingEnd(), getResources().getDimensionPixelSize(R.dimen.floating_action_button_list_bottom_padding)); - mEmptyListView.setVisibility(View.GONE); + emptyListView.setVisibility(View.GONE); } else { - mRecyclerView.setPaddingRelative( - mRecyclerView.getPaddingStart(), 0, mRecyclerView.getPaddingEnd(), 0); - mEmptyListView.setVisibility(View.VISIBLE); + recyclerView.setPaddingRelative( + recyclerView.getPaddingStart(), 0, recyclerView.getPaddingEnd(), 0); + emptyListView.setVisibility(View.VISIBLE); } - if (mScrollToTop) { + if (scrollToTop) { // The smooth-scroll animation happens over a fixed time period. // As a result, if it scrolls through a large portion of the list, // each frame will jump so far from the previous one that the user // will not experience the illusion of downward motion. Instead, // if we're not already near the top of the list, we instantly jump // near the top, and animate from there. - if (mLayoutManager.findFirstVisibleItemPosition() > 5) { + if (layoutManager.findFirstVisibleItemPosition() > 5) { // TODO: Jump to near the top, then begin smooth scroll. - mRecyclerView.smoothScrollToPosition(0); + recyclerView.smoothScrollToPosition(0); } // Workaround for framework issue: the smooth-scroll doesn't // occur if setSelection() is called immediately before. - mHandler.post( + handler.post( new Runnable() { @Override public void run() { if (getActivity() == null || getActivity().isFinishing()) { return; } - mRecyclerView.smoothScrollToPosition(0); + recyclerView.smoothScrollToPosition(0); } }); - mScrollToTop = false; + scrollToTop = false; } return true; } @@ -304,57 +304,57 @@ public class CallLogFragment extends Fragment } protected void setupView(View view) { - mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view); - mRecyclerView.setHasFixedSize(true); - mLayoutManager = new LinearLayoutManager(getActivity()); - mRecyclerView.setLayoutManager(mLayoutManager); - PerformanceReport.logOnScrollStateChange(mRecyclerView); - mEmptyListView = (EmptyContentView) view.findViewById(R.id.empty_list_view); - mEmptyListView.setImage(R.drawable.empty_call_log); - mEmptyListView.setActionClickedListener(this); - mModalAlertView = (ViewGroup) view.findViewById(R.id.modal_message_container); - mModalAlertManager = - new CallLogModalAlertManager(LayoutInflater.from(getContext()), mModalAlertView, this); - mMultiSelectUnSelectAllViewContent = + recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view); + recyclerView.setHasFixedSize(true); + layoutManager = new LinearLayoutManager(getActivity()); + recyclerView.setLayoutManager(layoutManager); + PerformanceReport.logOnScrollStateChange(recyclerView); + emptyListView = (EmptyContentView) view.findViewById(R.id.empty_list_view); + emptyListView.setImage(R.drawable.empty_call_log); + emptyListView.setActionClickedListener(this); + modalAlertView = (ViewGroup) view.findViewById(R.id.modal_message_container); + modalAlertManager = + new CallLogModalAlertManager(LayoutInflater.from(getContext()), modalAlertView, this); + multiSelectUnSelectAllViewContent = view.findViewById(R.id.multi_select_select_all_view_content); - mSelectUnselectAllViewText = (TextView) view.findViewById(R.id.select_all_view_text); - mSelectUnselectAllIcon = (ImageView) view.findViewById(R.id.select_all_view_icon); - mMultiSelectUnSelectAllViewContent.setOnClickListener(null); - mSelectUnselectAllIcon.setOnClickListener(this); - mSelectUnselectAllViewText.setOnClickListener(this); + selectUnselectAllViewText = (TextView) view.findViewById(R.id.select_all_view_text); + selectUnselectAllIcon = (ImageView) view.findViewById(R.id.select_all_view_icon); + multiSelectUnSelectAllViewContent.setOnClickListener(null); + selectUnselectAllIcon.setOnClickListener(this); + selectUnselectAllViewText.setOnClickListener(this); } protected void setupData() { int activityType = - mIsCallLogActivity + isCallLogActivity ? CallLogAdapter.ACTIVITY_TYPE_CALL_LOG : CallLogAdapter.ACTIVITY_TYPE_DIALTACTS; String currentCountryIso = GeoUtil.getCurrentCountryIso(getActivity()); - mContactInfoCache = + contactInfoCache = new ContactInfoCache( ExpirableCacheHeadlessFragment.attach((AppCompatActivity) getActivity()) .getRetainedCache(), new ContactInfoHelper(getActivity(), currentCountryIso), - mOnContactInfoChangedListener); - mAdapter = + onContactInfoChangedListener); + adapter = Bindings.getLegacy(getActivity()) .newCallLogAdapter( getActivity(), - mRecyclerView, + recyclerView, this, this, activityType == CallLogAdapter.ACTIVITY_TYPE_DIALTACTS ? (CallLogAdapter.OnActionModeStateChangedListener) getActivity() : null, new CallLogCache(getActivity()), - mContactInfoCache, + contactInfoCache, getVoicemailPlaybackPresenter(), new FilteredNumberAsyncQueryHandler(getActivity()), activityType); - mRecyclerView.setAdapter(mAdapter); - if (mAdapter.getOnScrollListener() != null) { - mRecyclerView.addOnScrollListener(mAdapter.getOnScrollListener()); + recyclerView.setAdapter(adapter); + if (adapter.getOnScrollListener() != null) { + recyclerView.addOnScrollListener(adapter.getOnScrollListener()); } fetchCalls(); } @@ -370,7 +370,7 @@ public class CallLogFragment extends Fragment super.onActivityCreated(savedInstanceState); setupData(); updateSelectAllState(savedInstanceState); - mAdapter.onRestoreInstanceState(savedInstanceState); + adapter.onRestoreInstanceState(savedInstanceState); } private void updateSelectAllState(Bundle savedInstanceState) { @@ -384,7 +384,7 @@ public class CallLogFragment extends Fragment @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - updateEmptyMessage(mCallTypeFilter); + updateEmptyMessage(callTypeFilter); } @Override @@ -393,23 +393,23 @@ public class CallLogFragment extends Fragment super.onResume(); final boolean hasReadCallLogPermission = PermissionsUtil.hasPermission(getActivity(), READ_CALL_LOG); - if (!mHasReadCallLogPermission && hasReadCallLogPermission) { + if (!this.hasReadCallLogPermission && hasReadCallLogPermission) { // We didn't have the permission before, and now we do. Force a refresh of the call log. // Note that this code path always happens on a fresh start, but mRefreshDataRequired // is already true in that case anyway. - mRefreshDataRequired = true; - updateEmptyMessage(mCallTypeFilter); + refreshDataRequired = true; + updateEmptyMessage(callTypeFilter); } - mHasReadCallLogPermission = hasReadCallLogPermission; + this.hasReadCallLogPermission = hasReadCallLogPermission; /* * Always clear the filtered numbers cache since users could have blocked/unblocked numbers * from the settings page */ - mAdapter.clearFilteredNumbersCache(); + adapter.clearFilteredNumbersCache(); refreshData(); - mAdapter.onResume(); + adapter.onResume(); rescheduleDisplayUpdate(); // onResume() may also be called as a "side" page on the ViewPager, which is not visible. @@ -425,7 +425,7 @@ public class CallLogFragment extends Fragment onNotVisible(); } cancelDisplayUpdate(); - mAdapter.onPause(); + adapter.onPause(); super.onPause(); } @@ -437,48 +437,48 @@ public class CallLogFragment extends Fragment if (CequintCallerIdManager.isCequintCallerIdEnabled(getContext())) { cequintCallerIdManager = CequintCallerIdManager.createInstanceForCallLog(); } - mContactInfoCache.setCequintCallerIdManager(cequintCallerIdManager); + contactInfoCache.setCequintCallerIdManager(cequintCallerIdManager); } @Override public void onStop() { LogUtil.enterBlock("CallLogFragment.onStop"); super.onStop(); - mAdapter.onStop(); - mContactInfoCache.stop(); + adapter.onStop(); + contactInfoCache.stop(); } @Override public void onDestroy() { LogUtil.enterBlock("CallLogFragment.onDestroy"); - if (mAdapter != null) { - mAdapter.changeCursor(null); + if (adapter != null) { + adapter.changeCursor(null); } - getActivity().getContentResolver().unregisterContentObserver(mCallLogObserver); - getActivity().getContentResolver().unregisterContentObserver(mContactsObserver); + getActivity().getContentResolver().unregisterContentObserver(callLogObserver); + getActivity().getContentResolver().unregisterContentObserver(contactsObserver); super.onDestroy(); } @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - outState.putInt(KEY_FILTER_TYPE, mCallTypeFilter); - outState.putInt(KEY_LOG_LIMIT, mLogLimit); - outState.putLong(KEY_DATE_LIMIT, mDateLimit); - outState.putBoolean(KEY_IS_CALL_LOG_ACTIVITY, mIsCallLogActivity); - outState.putBoolean(KEY_HAS_READ_CALL_LOG_PERMISSION, mHasReadCallLogPermission); - outState.putBoolean(KEY_REFRESH_DATA_REQUIRED, mRefreshDataRequired); + outState.putInt(KEY_FILTER_TYPE, callTypeFilter); + outState.putInt(KEY_LOG_LIMIT, logLimit); + outState.putLong(KEY_DATE_LIMIT, dateLimit); + outState.putBoolean(KEY_IS_CALL_LOG_ACTIVITY, isCallLogActivity); + outState.putBoolean(KEY_HAS_READ_CALL_LOG_PERMISSION, hasReadCallLogPermission); + outState.putBoolean(KEY_REFRESH_DATA_REQUIRED, refreshDataRequired); outState.putBoolean(KEY_SELECT_ALL_MODE, selectAllMode); - if (mAdapter != null) { - mAdapter.onSaveInstanceState(outState); + if (adapter != null) { + adapter.onSaveInstanceState(outState); } } @Override public void fetchCalls() { - mCallLogQueryHandler.fetchCalls(mCallTypeFilter, mDateLimit); - if (!mIsCallLogActivity) { + callLogQueryHandler.fetchCalls(callTypeFilter, dateLimit); + if (!isCallLogActivity) { ((ListsFragment) getParentFragment()).updateTabUnreadCounts(); } } @@ -490,8 +490,8 @@ public class CallLogFragment extends Fragment } if (!PermissionsUtil.hasPermission(context, READ_CALL_LOG)) { - mEmptyListView.setDescription(R.string.permission_no_calllog); - mEmptyListView.setActionLabel(R.string.permission_single_turn_on); + emptyListView.setDescription(R.string.permission_no_calllog); + emptyListView.setActionLabel(R.string.permission_single_turn_on); return; } @@ -510,25 +510,25 @@ public class CallLogFragment extends Fragment throw new IllegalArgumentException( "Unexpected filter type in CallLogFragment: " + filterType); } - mEmptyListView.setDescription(messageId); - if (mIsCallLogActivity) { - mEmptyListView.setActionLabel(EmptyContentView.NO_LABEL); + emptyListView.setDescription(messageId); + if (isCallLogActivity) { + emptyListView.setActionLabel(EmptyContentView.NO_LABEL); } else if (filterType == CallLogQueryHandler.CALL_TYPE_ALL) { - mEmptyListView.setActionLabel(R.string.call_log_all_empty_action); + emptyListView.setActionLabel(R.string.call_log_all_empty_action); } else { - mEmptyListView.setActionLabel(EmptyContentView.NO_LABEL); + emptyListView.setActionLabel(EmptyContentView.NO_LABEL); } } public CallLogAdapter getAdapter() { - return mAdapter; + return adapter; } @Override public void setMenuVisibility(boolean menuVisible) { super.setMenuVisibility(menuVisible); - if (mMenuVisible != menuVisible) { - mMenuVisible = menuVisible; + if (this.menuVisible != menuVisible) { + this.menuVisible = menuVisible; if (menuVisible && isResumed()) { refreshData(); } @@ -538,19 +538,19 @@ public class CallLogFragment extends Fragment /** Requests updates to the data to be shown. */ private void refreshData() { // Prevent unnecessary refresh. - if (mRefreshDataRequired) { + if (refreshDataRequired) { // Mark all entries in the contact info cache as out of date, so they will be looked up // again once being shown. - mContactInfoCache.invalidate(); - mAdapter.setLoading(true); + contactInfoCache.invalidate(); + adapter.setLoading(true); fetchCalls(); - mCallLogQueryHandler.fetchVoicemailStatus(); - mCallLogQueryHandler.fetchMissedCallsUnreadCount(); - mRefreshDataRequired = false; + callLogQueryHandler.fetchVoicemailStatus(); + callLogQueryHandler.fetchMissedCallsUnreadCount(); + refreshDataRequired = false; } else { // Refresh the display of the existing data to update the timestamp text descriptions. - mAdapter.notifyDataSetChanged(); + adapter.notifyDataSetChanged(); } } @@ -569,7 +569,7 @@ public class CallLogFragment extends Fragment "CallLogFragment.onEmptyViewActionButtonClicked", "Requesting permissions: " + Arrays.toString(deniedPermissions)); FragmentCompat.requestPermissions(this, deniedPermissions, PHONE_PERMISSIONS_REQUEST_CODE); - } else if (!mIsCallLogActivity) { + } else if (!isCallLogActivity) { LogUtil.i("CallLogFragment.onEmptyViewActionButtonClicked", "showing dialpad"); // Show dialpad if we are not in the call log activity. ((HostInterface) activity).showDialpad(); @@ -582,32 +582,32 @@ public class CallLogFragment extends Fragment if (requestCode == PHONE_PERMISSIONS_REQUEST_CODE) { if (grantResults.length >= 1 && PackageManager.PERMISSION_GRANTED == grantResults[0]) { // Force a refresh of the data since we were missing the permission before this. - mRefreshDataRequired = true; + refreshDataRequired = true; } } } /** Schedules an update to the relative call times (X mins ago). */ private void rescheduleDisplayUpdate() { - if (!mDisplayUpdateHandler.hasMessages(EVENT_UPDATE_DISPLAY)) { + if (!displayUpdateHandler.hasMessages(EVENT_UPDATE_DISPLAY)) { long time = System.currentTimeMillis(); // This value allows us to change the display relatively close to when the time changes // from one minute to the next. long millisUtilNextMinute = MILLIS_IN_MINUTE - (time % MILLIS_IN_MINUTE); - mDisplayUpdateHandler.sendEmptyMessageDelayed(EVENT_UPDATE_DISPLAY, millisUtilNextMinute); + displayUpdateHandler.sendEmptyMessageDelayed(EVENT_UPDATE_DISPLAY, millisUtilNextMinute); } } /** Cancels any pending update requests to update the relative call times (X mins ago). */ private void cancelDisplayUpdate() { - mDisplayUpdateHandler.removeMessages(EVENT_UPDATE_DISPLAY); + displayUpdateHandler.removeMessages(EVENT_UPDATE_DISPLAY); } /** Mark all missed calls as read if Keyguard not locked and possible. */ void markMissedCallsAsReadAndRemoveNotifications() { - if (mCallLogQueryHandler != null + if (callLogQueryHandler != null && !getContext().getSystemService(KeyguardManager.class).isKeyguardLocked()) { - mCallLogQueryHandler.markMissedCallsAsRead(); + callLogQueryHandler.markMissedCallsAsRead(); CallLogNotificationsService.cancelAllMissedCalls(getContext()); } } @@ -621,7 +621,7 @@ public class CallLogFragment extends Fragment } public boolean isModalAlertVisible() { - return mModalAlertManager != null && !mModalAlertManager.isEmpty(); + return modalAlertManager != null && !modalAlertManager.isEmpty(); } @CallSuper @@ -640,14 +640,14 @@ public class CallLogFragment extends Fragment getAdapter().notifyDataSetChanged(); HostInterface hostInterface = (HostInterface) getActivity(); if (show) { - mRecyclerView.setVisibility(View.GONE); - mModalAlertView.setVisibility(View.VISIBLE); + recyclerView.setVisibility(View.GONE); + modalAlertView.setVisibility(View.VISIBLE); if (hostInterface != null && getUserVisibleHint()) { hostInterface.enableFloatingButton(false); } } else { - mRecyclerView.setVisibility(View.VISIBLE); - mModalAlertView.setVisibility(View.GONE); + recyclerView.setVisibility(View.VISIBLE); + modalAlertView.setVisibility(View.GONE); if (hostInterface != null && getUserVisibleHint()) { hostInterface.enableFloatingButton(true); } @@ -656,16 +656,16 @@ public class CallLogFragment extends Fragment @Override public void showMultiSelectRemoveView(boolean show) { - mMultiSelectUnSelectAllViewContent.setVisibility(show ? View.VISIBLE : View.GONE); - mMultiSelectUnSelectAllViewContent.setAlpha(show ? 0 : 1); - mMultiSelectUnSelectAllViewContent.animate().alpha(show ? 1 : 0).start(); + multiSelectUnSelectAllViewContent.setVisibility(show ? View.VISIBLE : View.GONE); + multiSelectUnSelectAllViewContent.setAlpha(show ? 0 : 1); + multiSelectUnSelectAllViewContent.animate().alpha(show ? 1 : 0).start(); ((ListsFragment) getParentFragment()).showMultiSelectRemoveView(show); } @Override public void setSelectAllModeToFalse() { selectAllMode = false; - mSelectUnselectAllIcon.setImageDrawable( + selectUnselectAllIcon.setImageDrawable( getContext().getDrawable(R.drawable.ic_empty_check_mark_white_24dp)); } @@ -689,11 +689,11 @@ public class CallLogFragment extends Fragment private void updateSelectAllIcon() { if (selectAllMode) { - mSelectUnselectAllIcon.setImageDrawable( + selectUnselectAllIcon.setImageDrawable( getContext().getDrawable(R.drawable.ic_check_mark_blue_24dp)); getAdapter().onAllSelected(); } else { - mSelectUnselectAllIcon.setImageDrawable( + selectUnselectAllIcon.setImageDrawable( getContext().getDrawable(R.drawable.ic_empty_check_mark_white_24dp)); getAdapter().onAllDeselected(); } @@ -709,12 +709,12 @@ public class CallLogFragment extends Fragment protected class CustomContentObserver extends ContentObserver { public CustomContentObserver() { - super(mHandler); + super(handler); } @Override public void onChange(boolean selfChange) { - mRefreshDataRequired = true; + refreshDataRequired = true; } } } diff --git a/java/com/android/dialer/app/calllog/CallLogGroupBuilder.java b/java/com/android/dialer/app/calllog/CallLogGroupBuilder.java index a48de0f51..4c0c63408 100644 --- a/java/com/android/dialer/app/calllog/CallLogGroupBuilder.java +++ b/java/com/android/dialer/app/calllog/CallLogGroupBuilder.java @@ -57,15 +57,15 @@ public class CallLogGroupBuilder { /** Instance of the time object used for time calculations. */ private static final Time TIME = new Time(); /** The object on which the groups are created. */ - private final GroupCreator mGroupCreator; + private final GroupCreator groupCreator; public CallLogGroupBuilder(GroupCreator groupCreator) { - mGroupCreator = groupCreator; + this.groupCreator = groupCreator; } /** * Finds all groups of adjacent entries in the call log which should be grouped together and calls - * {@link GroupCreator#addGroup(int, int)} on {@link #mGroupCreator} for each of them. + * {@link GroupCreator#addGroup(int, int)} on {@link #groupCreator} for each of them. * * <p>For entries that are not grouped with others, we do not need to create a group of size one. * @@ -80,7 +80,7 @@ public class CallLogGroupBuilder { } // Clear any previous day grouping information. - mGroupCreator.clearDayGroups(); + groupCreator.clearDayGroups(); // Get current system time, used for calculating which day group calls belong to. long currentTime = System.currentTimeMillis(); @@ -90,7 +90,7 @@ public class CallLogGroupBuilder { final long firstDate = cursor.getLong(CallLogQuery.DATE); final long firstRowId = cursor.getLong(CallLogQuery.ID); int groupDayGroup = getDayGroup(firstDate, currentTime); - mGroupCreator.setDayGroup(firstRowId, groupDayGroup); + groupCreator.setDayGroup(firstRowId, groupDayGroup); // Determine the callback action for the first call in the cursor. String groupNumber = cursor.getString(CallLogQuery.NUMBER); @@ -99,7 +99,7 @@ public class CallLogGroupBuilder { int groupCallbackAction = CallbackActionHelper.getCallbackAction( groupNumber, groupFeatures, groupAccountComponentName); - mGroupCreator.setCallbackAction(firstRowId, groupCallbackAction); + groupCreator.setCallbackAction(firstRowId, groupCallbackAction); // Instantiate other group values to those of the first call in the cursor. String groupAccountId = cursor.getString(CallLogQuery.ACCOUNT_ID); @@ -164,7 +164,7 @@ public class CallLogGroupBuilder { // Create a group for the previous group of calls, which does not include the // current call. - mGroupCreator.addGroup(cursor.getPosition() - groupSize, groupSize); + groupCreator.addGroup(cursor.getPosition() - groupSize, groupSize); // Start a new group; it will include at least the current call. groupSize = 1; @@ -181,12 +181,12 @@ public class CallLogGroupBuilder { // Save the callback action and the day group associated with the current call. final long currentCallId = cursor.getLong(CallLogQuery.ID); - mGroupCreator.setCallbackAction(currentCallId, groupCallbackAction); - mGroupCreator.setDayGroup(currentCallId, groupDayGroup); + groupCreator.setCallbackAction(currentCallId, groupCallbackAction); + groupCreator.setDayGroup(currentCallId, groupDayGroup); } // Create a group for the last set of calls. - mGroupCreator.addGroup(count - groupSize, groupSize); + groupCreator.addGroup(count - groupSize, groupSize); } /** diff --git a/java/com/android/dialer/app/calllog/CallLogListItemHelper.java b/java/com/android/dialer/app/calllog/CallLogListItemHelper.java index ac43b9ea7..13ee9a41f 100644 --- a/java/com/android/dialer/app/calllog/CallLogListItemHelper.java +++ b/java/com/android/dialer/app/calllog/CallLogListItemHelper.java @@ -32,11 +32,11 @@ import com.android.dialer.compat.AppCompatConstants; /* package */ class CallLogListItemHelper { /** Helper for populating the details of a phone call. */ - private final PhoneCallDetailsHelper mPhoneCallDetailsHelper; + private final PhoneCallDetailsHelper phoneCallDetailsHelper; /** Resources to look up strings. */ - private final Resources mResources; + private final Resources resources; - private final CallLogCache mCallLogCache; + private final CallLogCache callLogCache; /** * Creates a new helper instance. @@ -49,9 +49,9 @@ import com.android.dialer.compat.AppCompatConstants; PhoneCallDetailsHelper phoneCallDetailsHelper, Resources resources, CallLogCache callLogCache) { - mPhoneCallDetailsHelper = phoneCallDetailsHelper; - mResources = resources; - mCallLogCache = callLogCache; + this.phoneCallDetailsHelper = phoneCallDetailsHelper; + this.resources = resources; + this.callLogCache = callLogCache; } /** @@ -63,7 +63,7 @@ import com.android.dialer.compat.AppCompatConstants; @WorkerThread public void updatePhoneCallDetails(PhoneCallDetails details) { Assert.isWorkerThread(); - details.callLocationAndDate = mPhoneCallDetailsHelper.getCallLocationAndDate(details); + details.callLocationAndDate = phoneCallDetailsHelper.getCallLocationAndDate(details); details.callDescription = getCallDescription(details); } @@ -74,7 +74,7 @@ import com.android.dialer.compat.AppCompatConstants; * @param details the details of a phone call needed to fill in the data */ public void setPhoneCallDetails(CallLogListItemViewHolder views, PhoneCallDetails details) { - mPhoneCallDetailsHelper.setPhoneCallDetails(views.phoneCallDetailsViews, details); + phoneCallDetailsHelper.setPhoneCallDetails(views.phoneCallDetailsViews, details); // Set the accessibility text for the contact badge views.quickContactView.setContentDescription(getContactBadgeDescription(details)); @@ -88,7 +88,7 @@ import com.android.dialer.compat.AppCompatConstants; // The call type or Location associated with the call. Use when setting text for a // voicemail log's call button - views.callTypeOrLocation = mPhoneCallDetailsHelper.getCallTypeOrLocation(details); + views.callTypeOrLocation = phoneCallDetailsHelper.getCallTypeOrLocation(details); // Cache country iso. Used for number filtering. views.countryIso = details.countryIso; @@ -114,20 +114,20 @@ import com.android.dialer.compat.AppCompatConstants; views.videoCallButtonView.setContentDescription( TextUtils.expandTemplate( - mResources.getString(R.string.description_video_call_action), nameOrNumber)); + resources.getString(R.string.description_video_call_action), nameOrNumber)); views.createNewContactButtonView.setContentDescription( TextUtils.expandTemplate( - mResources.getString(R.string.description_create_new_contact_action), nameOrNumber)); + resources.getString(R.string.description_create_new_contact_action), nameOrNumber)); views.addToExistingContactButtonView.setContentDescription( TextUtils.expandTemplate( - mResources.getString(R.string.description_add_to_existing_contact_action), + resources.getString(R.string.description_add_to_existing_contact_action), nameOrNumber)); views.detailsButtonView.setContentDescription( TextUtils.expandTemplate( - mResources.getString(R.string.description_details_action), nameOrNumber)); + resources.getString(R.string.description_details_action), nameOrNumber)); } /** @@ -138,10 +138,10 @@ import com.android.dialer.compat.AppCompatConstants; */ private CharSequence getContactBadgeDescription(PhoneCallDetails details) { if (details.isSpam) { - return mResources.getString( + return resources.getString( R.string.description_spam_contact_details, getNameOrNumber(details)); } - return mResources.getString(R.string.description_contact_details, getNameOrNumber(details)); + return resources.getString(R.string.description_contact_details, getNameOrNumber(details)); } /** @@ -178,32 +178,32 @@ import com.android.dialer.compat.AppCompatConstants; final CharSequence nameOrNumber = getNameOrNumber(details); // Get the call type or location of the caller; null if not applicable - final CharSequence typeOrLocation = mPhoneCallDetailsHelper.getCallTypeOrLocation(details); + final CharSequence typeOrLocation = phoneCallDetailsHelper.getCallTypeOrLocation(details); // Get the time/date of the call - final CharSequence timeOfCall = mPhoneCallDetailsHelper.getCallDate(details); + final CharSequence timeOfCall = phoneCallDetailsHelper.getCallDate(details); SpannableStringBuilder callDescription = new SpannableStringBuilder(); // Add number of calls if more than one. if (details.callTypes.length > 1) { callDescription.append( - mResources.getString(R.string.description_num_calls, details.callTypes.length)); + resources.getString(R.string.description_num_calls, details.callTypes.length)); } // If call had video capabilities, add the "Video Call" string. if ((details.features & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO) { - callDescription.append(mResources.getString(R.string.description_video_call)); + callDescription.append(resources.getString(R.string.description_video_call)); } - String accountLabel = mCallLogCache.getAccountLabel(details.accountHandle); + String accountLabel = callLogCache.getAccountLabel(details.accountHandle); CharSequence onAccountLabel = - PhoneCallDetails.createAccountLabelDescription(mResources, details.viaNumber, accountLabel); + PhoneCallDetails.createAccountLabelDescription(resources, details.viaNumber, accountLabel); int stringID = getCallDescriptionStringID(details.callTypes, details.isRead); callDescription.append( TextUtils.expandTemplate( - mResources.getString(stringID), + resources.getString(stringID), nameOrNumber, typeOrLocation == null ? "" : typeOrLocation, timeOfCall, diff --git a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java index 15c4b5850..f8d3a4cd8 100644 --- a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java +++ b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java @@ -132,13 +132,13 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder /** The actionable view which places a call to the number corresponding to the call log row. */ public final ImageView primaryActionButtonView; - private final Context mContext; - @Nullable private final PhoneAccountHandle mDefaultPhoneAccountHandle; - private final CallLogCache mCallLogCache; - private final CallLogListItemHelper mCallLogListItemHelper; - private final CachedNumberLookupService mCachedNumberLookupService; - private final VoicemailPlaybackPresenter mVoicemailPlaybackPresenter; - private final OnClickListener mBlockReportListener; + private final Context context; + @Nullable private final PhoneAccountHandle defaultPhoneAccountHandle; + private final CallLogCache callLogCache; + private final CallLogListItemHelper callLogListItemHelper; + private final CachedNumberLookupService cachedNumberLookupService; + private final VoicemailPlaybackPresenter voicemailPlaybackPresenter; + private final OnClickListener blockReportListener; @HostUi private final int hostUi; /** Whether the data fields are populated by the worker thread, ready to be shown. */ public boolean isLoaded; @@ -233,10 +233,10 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder public boolean isCallComposerCapable; - private View.OnClickListener mExpandCollapseListener; + private View.OnClickListener expandCollapseListener; private final OnActionModeStateChangedListener onActionModeStateChangedListener; private final View.OnLongClickListener longPressListener; - private boolean mVoicemailPrimaryActionButtonClicked; + private boolean voicemailPrimaryActionButtonClicked; public int callbackAction; public int dayGroupHeaderVisibility; @@ -264,18 +264,18 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder ImageView primaryActionButtonView) { super(rootView); - mContext = context; - mExpandCollapseListener = expandCollapseListener; + this.context = context; + this.expandCollapseListener = expandCollapseListener; onActionModeStateChangedListener = actionModeStateChangedListener; longPressListener = longClickListener; - mCallLogCache = callLogCache; - mCallLogListItemHelper = callLogListItemHelper; - mVoicemailPlaybackPresenter = voicemailPlaybackPresenter; - mBlockReportListener = blockReportListener; - mCachedNumberLookupService = PhoneNumberCache.get(mContext).getCachedNumberLookupService(); + this.callLogCache = callLogCache; + this.callLogListItemHelper = callLogListItemHelper; + this.voicemailPlaybackPresenter = voicemailPlaybackPresenter; + this.blockReportListener = blockReportListener; + cachedNumberLookupService = PhoneNumberCache.get(this.context).getCachedNumberLookupService(); // Cache this to avoid having to look it up each time we bind to a call log entry - mDefaultPhoneAccountHandle = + defaultPhoneAccountHandle = TelecomUtil.getDefaultOutgoingPhoneAccount(context, PhoneAccount.SCHEME_TEL); this.rootView = rootView; @@ -292,19 +292,19 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder phoneCallDetailsViews.nameView.setElegantTextHeight(false); phoneCallDetailsViews.callLocationAndDate.setElegantTextHeight(false); - if (mContext instanceof CallLogActivity) { + if (this.context instanceof CallLogActivity) { hostUi = HostUi.CALL_HISTORY; - Logger.get(mContext) + Logger.get(this.context) .logQuickContactOnTouch( quickContactView, InteractionEvent.Type.OPEN_QUICK_CONTACT_FROM_CALL_HISTORY, true); - } else if (mVoicemailPlaybackPresenter == null) { + } else if (this.voicemailPlaybackPresenter == null) { hostUi = HostUi.CALL_LOG; - Logger.get(mContext) + Logger.get(this.context) .logQuickContactOnTouch( quickContactView, InteractionEvent.Type.OPEN_QUICK_CONTACT_FROM_CALL_LOG, true); } else { hostUi = HostUi.VOICEMAIL; - Logger.get(mContext) + Logger.get(this.context) .logQuickContactOnTouch( quickContactView, InteractionEvent.Type.OPEN_QUICK_CONTACT_FROM_VOICEMAIL, false); } @@ -314,16 +314,16 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder quickContactView.setPrioritizedMimeType(Phone.CONTENT_ITEM_TYPE); } primaryActionButtonView.setOnClickListener(this); - primaryActionView.setOnClickListener(mExpandCollapseListener); - if (mVoicemailPlaybackPresenter != null - && ConfigProviderBindings.get(mContext) + primaryActionView.setOnClickListener(this.expandCollapseListener); + if (this.voicemailPlaybackPresenter != null + && ConfigProviderBindings.get(this.context) .getBoolean( CallLogAdapter.ENABLE_CALL_LOG_MULTI_SELECT, CallLogAdapter.ENABLE_CALL_LOG_MULTI_SELECT_FLAG)) { primaryActionView.setOnLongClickListener(longPressListener); quickContactView.setOnLongClickListener(longPressListener); quickContactView.setMulitSelectListeners( - mExpandCollapseListener, onActionModeStateChangedListener); + this.expandCollapseListener, onActionModeStateChangedListener); } else { primaryActionView.setOnCreateContextMenuListener(this); } @@ -400,51 +400,50 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder public boolean onMenuItemClick(MenuItem item) { int resId = item.getItemId(); if (resId == R.id.context_menu_copy_to_clipboard) { - ClipboardUtils.copyText(mContext, null, number, true); + ClipboardUtils.copyText(context, null, number, true); return true; } else if (resId == R.id.context_menu_copy_transcript_to_clipboard) { ClipboardUtils.copyText( - mContext, null, phoneCallDetailsViews.voicemailTranscriptionView.getText(), true); + context, null, phoneCallDetailsViews.voicemailTranscriptionView.getText(), true); return true; } else if (resId == R.id.context_menu_edit_before_call) { final Intent intent = new Intent(Intent.ACTION_DIAL, CallUtil.getCallUri(number)); - intent.setClass(mContext, DialtactsActivity.class); - DialerUtils.startActivityWithErrorToast(mContext, intent); + intent.setClass(context, DialtactsActivity.class); + DialerUtils.startActivityWithErrorToast(context, intent); return true; } else if (resId == R.id.context_menu_block_report_spam) { - Logger.get(mContext) + Logger.get(context) .logImpression(DialerImpression.Type.CALL_LOG_CONTEXT_MENU_BLOCK_REPORT_SPAM); maybeShowBlockNumberMigrationDialog( new BlockedNumbersMigrator.Listener() { @Override public void onComplete() { - mBlockReportListener.onBlockReportSpam( + blockReportListener.onBlockReportSpam( displayNumber, number, countryIso, callType, info.sourceType); } }); } else if (resId == R.id.context_menu_block) { - Logger.get(mContext).logImpression(DialerImpression.Type.CALL_LOG_CONTEXT_MENU_BLOCK_NUMBER); + Logger.get(context).logImpression(DialerImpression.Type.CALL_LOG_CONTEXT_MENU_BLOCK_NUMBER); maybeShowBlockNumberMigrationDialog( new BlockedNumbersMigrator.Listener() { @Override public void onComplete() { - mBlockReportListener.onBlock( + blockReportListener.onBlock( displayNumber, number, countryIso, callType, info.sourceType); } }); } else if (resId == R.id.context_menu_unblock) { - Logger.get(mContext) - .logImpression(DialerImpression.Type.CALL_LOG_CONTEXT_MENU_UNBLOCK_NUMBER); - mBlockReportListener.onUnblock( + Logger.get(context).logImpression(DialerImpression.Type.CALL_LOG_CONTEXT_MENU_UNBLOCK_NUMBER); + blockReportListener.onUnblock( displayNumber, number, countryIso, callType, info.sourceType, isSpam, blockId); } else if (resId == R.id.context_menu_report_not_spam) { - Logger.get(mContext) + Logger.get(context) .logImpression(DialerImpression.Type.CALL_LOG_CONTEXT_MENU_REPORT_AS_NOT_SPAM); - mBlockReportListener.onReportNotSpam( + blockReportListener.onReportNotSpam( displayNumber, number, countryIso, callType, info.sourceType); } else if (resId == R.id.context_menu_delete) { AsyncTaskExecutors.createAsyncTaskExecutor() - .submit(TASK_DELETE, new DeleteCallTask(mContext, callIds)); + .submit(TASK_DELETE, new DeleteCallTask(context, callIds)); } return false; } @@ -526,7 +525,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder primaryActionButtonView.setImageResource(R.drawable.quantum_ic_play_arrow_white_24); primaryActionButtonView.setContentDescription( TextUtils.expandTemplate( - mContext.getString(R.string.description_voicemail_action), validNameOrNumber)); + context.getString(R.string.description_voicemail_action), validNameOrNumber)); primaryActionButtonView.setVisibility(View.VISIBLE); } else { primaryActionButtonView.setVisibility(View.GONE); @@ -547,7 +546,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder IntentProvider.getReturnVideoCallIntentProvider(number, accountHandle)); primaryActionButtonView.setContentDescription( TextUtils.expandTemplate( - mContext.getString(R.string.description_video_call_action), validNameOrNumber)); + context.getString(R.string.description_video_call_action), validNameOrNumber)); primaryActionButtonView.setImageResource(R.drawable.quantum_ic_videocam_vd_theme_24); primaryActionButtonView.setVisibility(View.VISIBLE); break; @@ -560,20 +559,20 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder } primaryActionButtonView.setContentDescription( TextUtils.expandTemplate( - mContext.getString(R.string.description_video_call_action), validNameOrNumber)); + context.getString(R.string.description_video_call_action), validNameOrNumber)); primaryActionButtonView.setImageResource(R.drawable.quantum_ic_videocam_vd_theme_24); primaryActionButtonView.setVisibility(View.VISIBLE); break; case CallbackAction.VOICE: - if (mCallLogCache.isVoicemailNumber(accountHandle, number)) { + if (callLogCache.isVoicemailNumber(accountHandle, number)) { // Call to generic voicemail number, in case there are multiple accounts primaryActionButtonView.setTag(IntentProvider.getReturnVoicemailCallIntentProvider(null)); } else if (canSupportAssistedDialing()) { primaryActionButtonView.setTag( IntentProvider.getAssistedDialIntentProvider( number + postDialDigits, - mContext, - mContext.getSystemService(TelephonyManager.class))); + context, + context.getSystemService(TelephonyManager.class))); } else { primaryActionButtonView.setTag( IntentProvider.getReturnCallIntentProvider(number + postDialDigits)); @@ -581,7 +580,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder primaryActionButtonView.setContentDescription( TextUtils.expandTemplate( - mContext.getString(R.string.description_call_action), validNameOrNumber)); + context.getString(R.string.description_call_action), validNameOrNumber)); primaryActionButtonView.setImageResource(R.drawable.quantum_ic_call_vd_theme_24); primaryActionButtonView.setVisibility(View.VISIBLE); break; @@ -622,14 +621,14 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder voicemailPlaybackView.setVisibility(View.VISIBLE); Uri uri = Uri.parse(voicemailUri); - mVoicemailPlaybackPresenter.setPlaybackView( + voicemailPlaybackPresenter.setPlaybackView( voicemailPlaybackView, rowId, uri, - mVoicemailPrimaryActionButtonClicked, + voicemailPrimaryActionButtonClicked, sendVoicemailButtonView); - mVoicemailPrimaryActionButtonClicked = false; - CallLogAsyncTaskUtil.markVoicemailAsRead(mContext, uri); + voicemailPrimaryActionButtonClicked = false; + CallLogAsyncTaskUtil.markVoicemailAsRead(context, uri); return; } @@ -640,7 +639,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder if (canSupportAssistedDialing()) { callButtonView.setTag( IntentProvider.getAssistedDialIntentProvider( - number, mContext, mContext.getSystemService(TelephonyManager.class))); + number, context, context.getSystemService(TelephonyManager.class))); } else { callButtonView.setTag(IntentProvider.getReturnCallIntentProvider(number)); } @@ -651,7 +650,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder ((TextView) callButtonView.findViewById(R.id.call_action_text)) .setText( TextUtils.expandTemplate( - mContext.getString(R.string.call_log_action_call), + context.getString(R.string.call_log_action_call), nameOrNumber == null ? "" : nameOrNumber)); if (callType == Calls.VOICEMAIL_TYPE && !TextUtils.isEmpty(callTypeOrLocation)) { @@ -661,7 +660,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder callButtonView.setVisibility(View.VISIBLE); } - boolean isVoicemailNumber = mCallLogCache.isVoicemailNumber(accountHandle, number); + boolean isVoicemailNumber = callLogCache.isVoicemailNumber(accountHandle, number); switch (callbackAction) { case CallbackAction.IMS_VIDEO: @@ -672,10 +671,10 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder videoCallButtonView.setVisibility(View.GONE); break; case CallbackAction.VOICE: - Duo duo = DuoComponent.get(mContext).getDuo(); + Duo duo = DuoComponent.get(context).getDuo(); // For a voice call, set the secondary callback action to be an IMS video call if it is // available. Otherwise try to set it as a Duo call. - if (CallUtil.isVideoEnabled(mContext) + if (CallUtil.isVideoEnabled(context) && (hasPlacedCarrierVideoCall() || canSupportCarrierVideoCall())) { videoCallButtonView.setTag(IntentProvider.getReturnVideoCallIntentProvider(number)); videoCallButtonView.setVisibility(View.VISIBLE); @@ -687,24 +686,24 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder } boolean identifiedSpamCall = isSpamFeatureEnabled && isSpam; - if (duo.isReachable(mContext, number)) { + if (duo.isReachable(context, number)) { videoCallButtonView.setTag(IntentProvider.getDuoVideoIntentProvider(number)); videoCallButtonView.setVisibility(View.VISIBLE); - } else if (duo.isActivated(mContext) && !identifiedSpamCall) { - if (ConfigProviderBindings.get(mContext) + } else if (duo.isActivated(context) && !identifiedSpamCall) { + if (ConfigProviderBindings.get(context) .getBoolean("enable_call_log_duo_invite_button", false)) { inviteVideoButtonView.setTag(IntentProvider.getDuoInviteIntentProvider(number)); inviteVideoButtonView.setVisibility(View.VISIBLE); } - } else if (duo.isEnabled(mContext) && !identifiedSpamCall) { - if (!duo.isInstalled(mContext)) { - if (ConfigProviderBindings.get(mContext) + } else if (duo.isEnabled(context) && !identifiedSpamCall) { + if (!duo.isInstalled(context)) { + if (ConfigProviderBindings.get(context) .getBoolean("enable_call_log_install_duo_button", false)) { setUpVideoButtonView.setTag(IntentProvider.getInstallDuoIntentProvider()); setUpVideoButtonView.setVisibility(View.VISIBLE); } } else { - if (ConfigProviderBindings.get(mContext) + if (ConfigProviderBindings.get(context) .getBoolean("enable_call_log_activate_duo_button", false)) { setUpVideoButtonView.setTag(IntentProvider.getSetUpDuoIntentProvider()); setUpVideoButtonView.setVisibility(View.VISIBLE); @@ -719,19 +718,19 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder // For voicemail calls, show the voicemail playback layout; hide otherwise. if (callType == Calls.VOICEMAIL_TYPE - && mVoicemailPlaybackPresenter != null + && voicemailPlaybackPresenter != null && !TextUtils.isEmpty(voicemailUri)) { voicemailPlaybackView.setVisibility(View.VISIBLE); Uri uri = Uri.parse(voicemailUri); - mVoicemailPlaybackPresenter.setPlaybackView( + voicemailPlaybackPresenter.setPlaybackView( voicemailPlaybackView, rowId, uri, - mVoicemailPrimaryActionButtonClicked, + voicemailPrimaryActionButtonClicked, sendVoicemailButtonView); - mVoicemailPrimaryActionButtonClicked = false; - CallLogAsyncTaskUtil.markVoicemailAsRead(mContext, uri); + voicemailPrimaryActionButtonClicked = false; + CallLogAsyncTaskUtil.markVoicemailAsRead(context, uri); } else { voicemailPlaybackView.setVisibility(View.GONE); sendVoicemailButtonView.setVisibility(View.GONE); @@ -742,8 +741,8 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder } else { detailsButtonView.setVisibility(View.VISIBLE); boolean canReportCallerId = - mCachedNumberLookupService != null - && mCachedNumberLookupService.canReportAsInvalid(info.sourceType, info.objectId); + cachedNumberLookupService != null + && cachedNumberLookupService.canReportAsInvalid(info.sourceType, info.objectId); detailsButtonView.setTag( IntentProvider.getCallDetailIntentProvider( callDetailsEntries, buildContact(), canReportCallerId, canSupportAssistedDialing())); @@ -773,9 +772,9 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder sendMessageView.setVisibility(View.GONE); } - mCallLogListItemHelper.setActionContentDescriptions(this); + callLogListItemHelper.setActionContentDescriptions(this); - boolean supportsCallSubject = mCallLogCache.doesAccountSupportCallSubject(accountHandle); + boolean supportsCallSubject = callLogCache.doesAccountSupportCallSubject(accountHandle); callWithNoteButtonView.setVisibility( supportsCallSubject && !isVoicemailNumber && info != null ? View.VISIBLE : View.GONE); @@ -796,7 +795,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder private boolean showDuoPrimaryButton() { return accountHandle != null && accountHandle.getComponentName().equals(DuoConstants.PHONE_ACCOUNT_COMPONENT_NAME) - && DuoComponent.get(mContext).getDuo().isReachable(mContext, number); + && DuoComponent.get(context).getDuo().isReachable(context, number); } private static boolean hasDialableChar(CharSequence number) { @@ -818,10 +817,10 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder if (accountHandle == null) { return false; } - if (mDefaultPhoneAccountHandle == null) { + if (defaultPhoneAccountHandle == null) { return false; } - return accountHandle.getComponentName().equals(mDefaultPhoneAccountHandle.getComponentName()); + return accountHandle.getComponentName().equals(defaultPhoneAccountHandle.getComponentName()); } private boolean canSupportAssistedDialing() { @@ -829,7 +828,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder } private boolean canSupportCarrierVideoCall() { - return mCallLogCache.canRelyOnVideoPresence() + return callLogCache.canRelyOnVideoPresence() && info != null && (info.carrierPresence & Phone.CARRIER_PRESENCE_VT_CAPABLE) != 0; } @@ -907,12 +906,12 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder quickContactView.assignContactUri(info.lookupUri); if (isSpamFeatureEnabled && isSpam) { - quickContactView.setImageDrawable(mContext.getDrawable(R.drawable.blocked_contact)); + quickContactView.setImageDrawable(context.getDrawable(R.drawable.blocked_contact)); return; } final String displayName = TextUtils.isEmpty(info.name) ? displayNumber : info.name; - ContactPhotoManager.getInstance(mContext) + ContactPhotoManager.getInstance(context) .loadDialerThumbnailOrPhoto( quickContactView, info.lookupUri, @@ -924,10 +923,9 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder private @ContactType int getContactType() { return LetterTileDrawable.getContactTypeFromPrimitives( - mCallLogCache.isVoicemailNumber(accountHandle, number), + callLogCache.isVoicemailNumber(accountHandle, number), isSpam, - mCachedNumberLookupService != null - && mCachedNumberLookupService.isBusiness(info.sourceType), + cachedNumberLookupService != null && cachedNumberLookupService.isBusiness(info.sourceType), numberPresentation, false); } @@ -935,19 +933,19 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder @Override public void onClick(View view) { if (view.getId() == R.id.primary_action_button) { - CallLogAsyncTaskUtil.markCallAsRead(mContext, callIds); + CallLogAsyncTaskUtil.markCallAsRead(context, callIds); } if (view.getId() == R.id.primary_action_button && !TextUtils.isEmpty(voicemailUri)) { - Logger.get(mContext).logImpression(DialerImpression.Type.VOICEMAIL_PLAY_AUDIO_DIRECTLY); - mVoicemailPrimaryActionButtonClicked = true; - mExpandCollapseListener.onClick(primaryActionView); + Logger.get(context).logImpression(DialerImpression.Type.VOICEMAIL_PLAY_AUDIO_DIRECTLY); + voicemailPrimaryActionButtonClicked = true; + expandCollapseListener.onClick(primaryActionView); return; } if (view.getId() == R.id.call_with_note_action) { CallSubjectDialog.start( - (Activity) mContext, + (Activity) context, info.photoId, info.photoUri, info.lookupUri, @@ -962,12 +960,12 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder } if (view.getId() == R.id.block_report_action) { - Logger.get(mContext).logImpression(DialerImpression.Type.CALL_LOG_BLOCK_REPORT_SPAM); + Logger.get(context).logImpression(DialerImpression.Type.CALL_LOG_BLOCK_REPORT_SPAM); maybeShowBlockNumberMigrationDialog( new BlockedNumbersMigrator.Listener() { @Override public void onComplete() { - mBlockReportListener.onBlockReportSpam( + blockReportListener.onBlockReportSpam( displayNumber, number, countryIso, callType, info.sourceType); } }); @@ -975,12 +973,12 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder } if (view.getId() == R.id.block_action) { - Logger.get(mContext).logImpression(DialerImpression.Type.CALL_LOG_BLOCK_NUMBER); + Logger.get(context).logImpression(DialerImpression.Type.CALL_LOG_BLOCK_NUMBER); maybeShowBlockNumberMigrationDialog( new BlockedNumbersMigrator.Listener() { @Override public void onComplete() { - mBlockReportListener.onBlock( + blockReportListener.onBlock( displayNumber, number, countryIso, callType, info.sourceType); } }); @@ -988,23 +986,23 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder } if (view.getId() == R.id.unblock_action) { - Logger.get(mContext).logImpression(DialerImpression.Type.CALL_LOG_UNBLOCK_NUMBER); - mBlockReportListener.onUnblock( + Logger.get(context).logImpression(DialerImpression.Type.CALL_LOG_UNBLOCK_NUMBER); + blockReportListener.onUnblock( displayNumber, number, countryIso, callType, info.sourceType, isSpam, blockId); return; } if (view.getId() == R.id.report_not_spam_action) { - Logger.get(mContext).logImpression(DialerImpression.Type.CALL_LOG_REPORT_AS_NOT_SPAM); - mBlockReportListener.onReportNotSpam( + Logger.get(context).logImpression(DialerImpression.Type.CALL_LOG_REPORT_AS_NOT_SPAM); + blockReportListener.onReportNotSpam( displayNumber, number, countryIso, callType, info.sourceType); return; } if (view.getId() == R.id.call_compose_action) { LogUtil.i("CallLogListItemViewHolder.onClick", "share and call pressed"); - Logger.get(mContext).logImpression(DialerImpression.Type.CALL_LOG_SHARE_AND_CALL); - Activity activity = (Activity) mContext; + Logger.get(context).logImpression(DialerImpression.Type.CALL_LOG_SHARE_AND_CALL); + Activity activity = (Activity) context; activity.startActivityForResult( CallComposerActivity.newIntent(activity, buildContact()), ActivityRequestCodes.DIALTACTS_CALL_COMPOSER); @@ -1012,8 +1010,8 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder } if (view.getId() == R.id.share_voicemail) { - Logger.get(mContext).logImpression(DialerImpression.Type.VVM_SHARE_PRESSED); - mVoicemailPlaybackPresenter.shareVoicemail(); + Logger.get(context).logImpression(DialerImpression.Type.VVM_SHARE_PRESSED); + voicemailPlaybackPresenter.shareVoicemail(); return; } @@ -1024,7 +1022,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder return; } - final Intent intent = intentProvider.getIntent(mContext); + final Intent intent = intentProvider.getIntent(context); // See IntentProvider.getCallDetailIntentProvider() for why this may be null. if (intent == null) { return; @@ -1037,19 +1035,19 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder startDuoActivity(intent); } else if (CallDetailsActivity.isLaunchIntent(intent)) { PerformanceReport.recordClick(UiAction.Type.OPEN_CALL_DETAIL); - ((Activity) mContext) + ((Activity) context) .startActivityForResult(intent, ActivityRequestCodes.DIALTACTS_CALL_DETAILS); } else { if (Intent.ACTION_CALL.equals(intent.getAction()) && intent.getIntExtra(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, -1) == VideoProfile.STATE_BIDIRECTIONAL) { - Logger.get(mContext).logImpression(DialerImpression.Type.IMS_VIDEO_REQUESTED_FROM_CALL_LOG); + Logger.get(context).logImpression(DialerImpression.Type.IMS_VIDEO_REQUESTED_FROM_CALL_LOG); } else if (intent.getDataString() != null && intent.getDataString().contains(DuoConstants.PACKAGE_NAME)) { - Logger.get(mContext).logImpression(DialerImpression.Type.DUO_CALL_LOG_SET_UP_INSTALL); + Logger.get(context).logImpression(DialerImpression.Type.DUO_CALL_LOG_SET_UP_INSTALL); } - DialerUtils.startActivityWithErrorToast(mContext, intent); + DialerUtils.startActivityWithErrorToast(context, intent); } } @@ -1062,14 +1060,14 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder private void startDuoActivity(Intent intent) { if (DuoConstants.DUO_ACTIVATE_ACTION.equals(intent.getAction())) { - Logger.get(mContext).logImpression(DialerImpression.Type.DUO_CALL_LOG_SET_UP_ACTIVATE); + Logger.get(context).logImpression(DialerImpression.Type.DUO_CALL_LOG_SET_UP_ACTIVATE); } else if (DuoConstants.DUO_INVITE_ACTION.equals(intent.getAction())) { - Logger.get(mContext).logImpression(DialerImpression.Type.DUO_CALL_LOG_INVITE); + Logger.get(context).logImpression(DialerImpression.Type.DUO_CALL_LOG_INVITE); } else if (DuoConstants.DUO_CALL_ACTION.equals(intent.getAction())) { - Logger.get(mContext) + Logger.get(context) .logImpression(DialerImpression.Type.LIGHTBRINGER_VIDEO_REQUESTED_FROM_CALL_LOG); if (isNonContactEntry(info)) { - Logger.get(mContext) + Logger.get(context) .logImpression( DialerImpression.Type.LIGHTBRINGER_NON_CONTACT_VIDEO_REQUESTED_FROM_CALL_LOG); } @@ -1079,10 +1077,10 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder } try { - Activity activity = (Activity) mContext; + Activity activity = (Activity) context; activity.startActivityForResult(intent, ActivityRequestCodes.DIALTACTS_DUO); } catch (ActivityNotFoundException e) { - Toast.makeText(mContext, R.string.activity_not_available, Toast.LENGTH_SHORT).show(); + Toast.makeText(context, R.string.activity_not_available, Toast.LENGTH_SHORT).show(); } } @@ -1115,10 +1113,10 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder contact.setNumberLabel(numberType); /* third line of contact view. */ - String accountLabel = mCallLogCache.getAccountLabel(accountHandle); + String accountLabel = callLogCache.getAccountLabel(accountHandle); if (!TextUtils.isEmpty(accountLabel)) { SimDetails.Builder simDetails = SimDetails.newBuilder().setNetwork(accountLabel); - simDetails.setColor(mCallLogCache.getAccountColor(accountHandle)); + simDetails.setColor(callLogCache.getAccountColor(accountHandle)); contact.setSimDetails(simDetails.build()); } return contact.build(); @@ -1126,36 +1124,35 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder private void logCallLogAction(int id) { if (id == R.id.send_message_action) { - Logger.get(mContext).logImpression(DialerImpression.Type.CALL_LOG_SEND_MESSAGE); + Logger.get(context).logImpression(DialerImpression.Type.CALL_LOG_SEND_MESSAGE); } else if (id == R.id.add_to_existing_contact_action) { - Logger.get(mContext).logImpression(DialerImpression.Type.CALL_LOG_ADD_TO_CONTACT); + Logger.get(context).logImpression(DialerImpression.Type.CALL_LOG_ADD_TO_CONTACT); switch (hostUi) { case HostUi.CALL_HISTORY: - Logger.get(mContext) + Logger.get(context) .logImpression(DialerImpression.Type.ADD_TO_A_CONTACT_FROM_CALL_HISTORY); break; case HostUi.CALL_LOG: - Logger.get(mContext).logImpression(DialerImpression.Type.ADD_TO_A_CONTACT_FROM_CALL_LOG); + Logger.get(context).logImpression(DialerImpression.Type.ADD_TO_A_CONTACT_FROM_CALL_LOG); break; case HostUi.VOICEMAIL: - Logger.get(mContext).logImpression(DialerImpression.Type.ADD_TO_A_CONTACT_FROM_VOICEMAIL); + Logger.get(context).logImpression(DialerImpression.Type.ADD_TO_A_CONTACT_FROM_VOICEMAIL); break; default: throw Assert.createIllegalStateFailException(); } } else if (id == R.id.create_new_contact_action) { - Logger.get(mContext).logImpression(DialerImpression.Type.CALL_LOG_CREATE_NEW_CONTACT); + Logger.get(context).logImpression(DialerImpression.Type.CALL_LOG_CREATE_NEW_CONTACT); switch (hostUi) { case HostUi.CALL_HISTORY: - Logger.get(mContext) + Logger.get(context) .logImpression(DialerImpression.Type.CREATE_NEW_CONTACT_FROM_CALL_HISTORY); break; case HostUi.CALL_LOG: - Logger.get(mContext) - .logImpression(DialerImpression.Type.CREATE_NEW_CONTACT_FROM_CALL_LOG); + Logger.get(context).logImpression(DialerImpression.Type.CREATE_NEW_CONTACT_FROM_CALL_LOG); break; case HostUi.VOICEMAIL: - Logger.get(mContext) + Logger.get(context) .logImpression(DialerImpression.Type.CREATE_NEW_CONTACT_FROM_VOICEMAIL); break; default: @@ -1166,7 +1163,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder private void maybeShowBlockNumberMigrationDialog(BlockedNumbersMigrator.Listener listener) { if (!FilteredNumberCompat.maybeShowBlockNumberMigrationDialog( - mContext, ((Activity) mContext).getFragmentManager(), listener)) { + context, ((Activity) context).getFragmentManager(), listener)) { listener.onComplete(); } } @@ -1179,8 +1176,8 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder reportNotSpamView.setVisibility(View.GONE); String e164Number = PhoneNumberUtils.formatNumberToE164(number, countryIso); if (isVoicemailNumber - || !FilteredNumbersUtil.canBlockNumber(mContext, e164Number, number) - || !FilteredNumberCompat.canAttemptBlockOperations(mContext)) { + || !FilteredNumbersUtil.canBlockNumber(context, e164Number, number) + || !FilteredNumberCompat.canAttemptBlockOperations(context)) { return; } boolean isBlocked = blockId != null; @@ -1217,7 +1214,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder } if (callType == CallLog.Calls.VOICEMAIL_TYPE) { - menu.setHeaderTitle(mContext.getResources().getText(R.string.voicemail)); + menu.setHeaderTitle(context.getResources().getText(R.string.voicemail)); } else { menu.setHeaderTitle( PhoneNumberUtilsCompat.createTtsSpannable( @@ -1237,7 +1234,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder // 3) Number is a SIP address if (PhoneNumberHelper.canPlaceCallsTo(number, numberPresentation) - && !mCallLogCache.isVoicemailNumber(accountHandle, number) + && !callLogCache.isVoicemailNumber(accountHandle, number) && !PhoneNumberHelper.isSipNumber(number)) { menu.add( ContextMenu.NONE, @@ -1258,10 +1255,10 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder } String e164Number = PhoneNumberUtils.formatNumberToE164(number, countryIso); - boolean isVoicemailNumber = mCallLogCache.isVoicemailNumber(accountHandle, number); + boolean isVoicemailNumber = callLogCache.isVoicemailNumber(accountHandle, number); if (!isVoicemailNumber - && FilteredNumbersUtil.canBlockNumber(mContext, e164Number, number) - && FilteredNumberCompat.canAttemptBlockOperations(mContext)) { + && FilteredNumbersUtil.canBlockNumber(context, e164Number, number) + && FilteredNumberCompat.canAttemptBlockOperations(context)) { boolean isBlocked = blockId != null; if (isBlocked) { menu.add( @@ -1309,7 +1306,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder .setOnMenuItemClickListener(this); } - Logger.get(mContext).logScreenView(ScreenEvent.Type.CALL_LOG_CONTEXT_MENU, (Activity) mContext); + Logger.get(context).logScreenView(ScreenEvent.Type.CALL_LOG_CONTEXT_MENU, (Activity) context); } /** Specifies where the view holder belongs. */ diff --git a/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java b/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java index 3a4bf8766..d20ddd0e5 100644 --- a/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java +++ b/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java @@ -57,20 +57,20 @@ public class CallLogNotificationsQueryHelper { static final String CONFIG_NEW_VOICEMAIL_NOTIFICATION_THRESHOLD_OFFSET = "new_voicemail_notification_threshold"; - private final Context mContext; - private final NewCallsQuery mNewCallsQuery; - private final ContactInfoHelper mContactInfoHelper; - private final String mCurrentCountryIso; + private final Context context; + private final NewCallsQuery newCallsQuery; + private final ContactInfoHelper contactInfoHelper; + private final String currentCountryIso; CallLogNotificationsQueryHelper( Context context, NewCallsQuery newCallsQuery, ContactInfoHelper contactInfoHelper, String countryIso) { - mContext = context; - mNewCallsQuery = newCallsQuery; - mContactInfoHelper = contactInfoHelper; - mCurrentCountryIso = countryIso; + this.context = context; + this.newCallsQuery = newCallsQuery; + this.contactInfoHelper = contactInfoHelper; + currentCountryIso = countryIso; } /** Returns an instance of {@link CallLogNotificationsQueryHelper}. */ @@ -146,7 +146,7 @@ public class CallLogNotificationsQueryHelper { } NewCallsQuery getNewCallsQuery() { - return mNewCallsQuery; + return newCallsQuery; } /** @@ -156,10 +156,10 @@ public class CallLogNotificationsQueryHelper { */ @Nullable public List<NewCall> getNewVoicemails() { - return mNewCallsQuery.query( + return newCallsQuery.query( Calls.VOICEMAIL_TYPE, System.currentTimeMillis() - - ConfigProviderBindings.get(mContext) + - ConfigProviderBindings.get(context) .getLong( CONFIG_NEW_VOICEMAIL_NOTIFICATION_THRESHOLD_OFFSET, TimeUnit.DAYS.toMillis(7))); } @@ -171,7 +171,7 @@ public class CallLogNotificationsQueryHelper { */ @Nullable public List<NewCall> getNewMissedCalls() { - return mNewCallsQuery.query(Calls.MISSED_TYPE); + return newCallsQuery.query(Calls.MISSED_TYPE); } /** @@ -193,7 +193,7 @@ public class CallLogNotificationsQueryHelper { public ContactInfo getContactInfo( @Nullable String number, int numberPresentation, @Nullable String countryIso) { if (countryIso == null) { - countryIso = mCurrentCountryIso; + countryIso = currentCountryIso; } number = (number == null) ? "" : number; @@ -205,14 +205,14 @@ public class CallLogNotificationsQueryHelper { // 1. Special number representation. contactInfo.name = - PhoneNumberDisplayUtil.getDisplayName(mContext, number, numberPresentation, false) + PhoneNumberDisplayUtil.getDisplayName(context, number, numberPresentation, false) .toString(); if (!TextUtils.isEmpty(contactInfo.name)) { return contactInfo; } // 2. Look it up in the cache. - ContactInfo cachedContactInfo = mContactInfoHelper.lookupNumber(number, countryIso); + ContactInfo cachedContactInfo = contactInfoHelper.lookupNumber(number, countryIso); if (cachedContactInfo != null && !TextUtils.isEmpty(cachedContactInfo.name)) { return cachedContactInfo; @@ -226,7 +226,7 @@ public class CallLogNotificationsQueryHelper { contactInfo.name = number; } else { // 5. Otherwise, it's unknown number. - contactInfo.name = mContext.getResources().getString(R.string.unknown); + contactInfo.name = context.getResources().getString(R.string.unknown); } return contactInfo; } @@ -330,12 +330,12 @@ public class CallLogNotificationsQueryHelper { private static final int DATE_COLUMN_INDEX = 8; private static final int TRANSCRIPTION_STATE_COLUMN_INDEX = 9; - private final ContentResolver mContentResolver; - private final Context mContext; + private final ContentResolver contentResolver; + private final Context context; private DefaultNewCallsQuery(Context context, ContentResolver contentResolver) { - mContext = context; - mContentResolver = contentResolver; + this.context = context; + this.contentResolver = contentResolver; } @Override @@ -350,7 +350,7 @@ public class CallLogNotificationsQueryHelper { @TargetApi(Build.VERSION_CODES.M) @SuppressWarnings("MissingPermission") public List<NewCall> query(int type, long thresholdMillis) { - if (!PermissionsUtil.hasPermission(mContext, Manifest.permission.READ_CALL_LOG)) { + if (!PermissionsUtil.hasPermission(context, Manifest.permission.READ_CALL_LOG)) { LogUtil.w( "CallLogNotificationsQueryHelper.DefaultNewCallsQuery.query", "no READ_CALL_LOG permission, returning null for calls lookup."); @@ -382,7 +382,7 @@ public class CallLogNotificationsQueryHelper { } Selection selection = selectionBuilder.build(); try (Cursor cursor = - mContentResolver.query( + contentResolver.query( Calls.CONTENT_URI_WITH_VOICEMAIL, (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) ? PROJECTION_O : PROJECTION, selection.getSelection(), @@ -407,7 +407,7 @@ public class CallLogNotificationsQueryHelper { @Nullable @Override public NewCall query(Uri callsUri) { - if (!PermissionsUtil.hasPermission(mContext, Manifest.permission.READ_CALL_LOG)) { + if (!PermissionsUtil.hasPermission(context, Manifest.permission.READ_CALL_LOG)) { LogUtil.w( "CallLogNotificationsQueryHelper.DefaultNewCallsQuery.query", "No READ_CALL_LOG permission, returning null for calls lookup."); @@ -415,7 +415,7 @@ public class CallLogNotificationsQueryHelper { } final String selection = String.format("%s = '%s'", Calls.VOICEMAIL_URI, callsUri.toString()); try (Cursor cursor = - mContentResolver.query( + contentResolver.query( Calls.CONTENT_URI_WITH_VOICEMAIL, (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) ? PROJECTION_O : PROJECTION, selection, diff --git a/java/com/android/dialer/app/calllog/DialerQuickContactBadge.java b/java/com/android/dialer/app/calllog/DialerQuickContactBadge.java index a3aac41fa..81aed8baa 100644 --- a/java/com/android/dialer/app/calllog/DialerQuickContactBadge.java +++ b/java/com/android/dialer/app/calllog/DialerQuickContactBadge.java @@ -27,7 +27,7 @@ import com.android.dialer.logging.Logger; /** Allows us to click the contact badge for non multi select mode. */ class DialerQuickContactBadge extends QuickContactBadge { - private View.OnClickListener mExtraOnClickListener; + private View.OnClickListener extraOnClickListener; private OnActionModeStateChangedListener onActionModeStateChangeListener; public DialerQuickContactBadge(Context context) { @@ -44,11 +44,11 @@ class DialerQuickContactBadge extends QuickContactBadge { @Override public void onClick(View v) { - if (mExtraOnClickListener != null + if (extraOnClickListener != null && onActionModeStateChangeListener.isActionModeStateEnabled()) { Logger.get(v.getContext()) .logImpression(DialerImpression.Type.MULTISELECT_SINGLE_PRESS_TAP_VIA_CONTACT_BADGE); - mExtraOnClickListener.onClick(v); + extraOnClickListener.onClick(v); } else { super.onClick(v); } @@ -57,7 +57,7 @@ class DialerQuickContactBadge extends QuickContactBadge { public void setMulitSelectListeners( View.OnClickListener extraOnClickListener, OnActionModeStateChangedListener actionModeStateChangeListener) { - mExtraOnClickListener = extraOnClickListener; + this.extraOnClickListener = extraOnClickListener; onActionModeStateChangeListener = actionModeStateChangeListener; } } diff --git a/java/com/android/dialer/app/calllog/GroupingListAdapter.java b/java/com/android/dialer/app/calllog/GroupingListAdapter.java index d1157206f..29a4d4e4a 100644 --- a/java/com/android/dialer/app/calllog/GroupingListAdapter.java +++ b/java/com/android/dialer/app/calllog/GroupingListAdapter.java @@ -32,7 +32,7 @@ import android.util.SparseIntArray; */ abstract class GroupingListAdapter extends RecyclerView.Adapter { - protected ContentObserver mChangeObserver = + protected ContentObserver changeObserver = new ContentObserver(new Handler()) { @Override public boolean deliverSelfNotifications() { @@ -44,21 +44,21 @@ abstract class GroupingListAdapter extends RecyclerView.Adapter { onContentChanged(); } }; - protected DataSetObserver mDataSetObserver = + protected DataSetObserver dataSetObserver = new DataSetObserver() { @Override public void onChanged() { notifyDataSetChanged(); } }; - private Cursor mCursor; + private Cursor cursor; /** * SparseIntArray, which maps the cursor position of the first element of a group to the size of * the group. The index of a key in this map corresponds to the list position of that group. */ - private SparseIntArray mGroupMetadata; + private SparseIntArray groupMetadata; - private int mItemCount; + private int itemCount; public GroupingListAdapter() { reset(); @@ -72,28 +72,28 @@ abstract class GroupingListAdapter extends RecyclerView.Adapter { protected abstract void onContentChanged(); public void changeCursor(Cursor cursor) { - if (cursor == mCursor) { + if (cursor == this.cursor) { return; } - if (mCursor != null) { - mCursor.unregisterContentObserver(mChangeObserver); - mCursor.unregisterDataSetObserver(mDataSetObserver); - mCursor.close(); + if (this.cursor != null) { + this.cursor.unregisterContentObserver(changeObserver); + this.cursor.unregisterDataSetObserver(dataSetObserver); + this.cursor.close(); } // Reset whenever the cursor is changed. reset(); - mCursor = cursor; + this.cursor = cursor; if (cursor != null) { - addGroups(mCursor); + addGroups(this.cursor); // Calculate the item count by subtracting group child counts from the cursor count. - mItemCount = mGroupMetadata.size(); + itemCount = groupMetadata.size(); - cursor.registerContentObserver(mChangeObserver); - cursor.registerDataSetObserver(mDataSetObserver); + cursor.registerContentObserver(changeObserver); + cursor.registerDataSetObserver(dataSetObserver); notifyDataSetChanged(); } } @@ -103,18 +103,18 @@ abstract class GroupingListAdapter extends RecyclerView.Adapter { * #addGroups} method. */ public void addGroup(int cursorPosition, int groupSize) { - int lastIndex = mGroupMetadata.size() - 1; - if (lastIndex < 0 || cursorPosition <= mGroupMetadata.keyAt(lastIndex)) { - mGroupMetadata.put(cursorPosition, groupSize); + int lastIndex = groupMetadata.size() - 1; + if (lastIndex < 0 || cursorPosition <= groupMetadata.keyAt(lastIndex)) { + groupMetadata.put(cursorPosition, groupSize); } else { // Optimization to avoid binary search if adding groups in ascending cursor position. - mGroupMetadata.append(cursorPosition, groupSize); + groupMetadata.append(cursorPosition, groupSize); } } @Override public int getItemCount() { - return mItemCount; + return itemCount; } /** @@ -122,11 +122,11 @@ abstract class GroupingListAdapter extends RecyclerView.Adapter { * position. */ public int getGroupSize(int listPosition) { - if (listPosition < 0 || listPosition >= mGroupMetadata.size()) { + if (listPosition < 0 || listPosition >= groupMetadata.size()) { return 0; } - return mGroupMetadata.valueAt(listPosition); + return groupMetadata.valueAt(listPosition); } /** @@ -134,20 +134,20 @@ abstract class GroupingListAdapter extends RecyclerView.Adapter { * corresponding to that position. */ public Object getItem(int listPosition) { - if (mCursor == null || listPosition < 0 || listPosition >= mGroupMetadata.size()) { + if (cursor == null || listPosition < 0 || listPosition >= groupMetadata.size()) { return null; } - int cursorPosition = mGroupMetadata.keyAt(listPosition); - if (mCursor.moveToPosition(cursorPosition)) { - return mCursor; + int cursorPosition = groupMetadata.keyAt(listPosition); + if (cursor.moveToPosition(cursorPosition)) { + return cursor; } else { return null; } } private void reset() { - mItemCount = 0; - mGroupMetadata = new SparseIntArray(); + itemCount = 0; + groupMetadata = new SparseIntArray(); } } diff --git a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java index 794b759f2..fa1f7ab2c 100644 --- a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java +++ b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java @@ -55,17 +55,17 @@ public class PhoneCallDetailsHelper /** The maximum number of icons will be shown to represent the call types in a group. */ private static final int MAX_CALL_TYPE_ICONS = 3; - private final Context mContext; - private final Resources mResources; - private final CallLogCache mCallLogCache; + private final Context context; + private final Resources resources; + private final CallLogCache callLogCache; /** Calendar used to construct dates */ - private final Calendar mCalendar; + private final Calendar calendar; /** The injected current time in milliseconds since the epoch. Used only by tests. */ - private Long mCurrentTimeMillisForTest; + private Long currentTimeMillisForTest; - private CharSequence mPhoneTypeLabelForTest; + private CharSequence phoneTypeLabelForTest; /** List of items to be concatenated together for accessibility descriptions */ - private ArrayList<CharSequence> mDescriptionItems = new ArrayList<>(); + private ArrayList<CharSequence> descriptionItems = new ArrayList<>(); /** * Creates a new instance of the helper. @@ -75,10 +75,10 @@ public class PhoneCallDetailsHelper * @param resources used to look up strings */ public PhoneCallDetailsHelper(Context context, Resources resources, CallLogCache callLogCache) { - mContext = context; - mResources = resources; - mCallLogCache = callLogCache; - mCalendar = Calendar.getInstance(); + this.context = context; + this.resources = resources; + this.callLogCache = callLogCache; + calendar = Calendar.getInstance(); } /** Fills the call details views with content. */ @@ -100,7 +100,7 @@ public class PhoneCallDetailsHelper views.callTypeIcons.setShowHd( (details.features & Calls.FEATURES_HD_CALL) == Calls.FEATURES_HD_CALL); views.callTypeIcons.setShowWifi( - MotorolaUtils.shouldShowWifiIconInCallLog(mContext, details.features)); + MotorolaUtils.shouldShowWifiIconInCallLog(context, details.features)); views.callTypeIcons.requestLayout(); views.callTypeIcons.setVisibility(View.VISIBLE); @@ -116,23 +116,23 @@ public class PhoneCallDetailsHelper setDetailText(views, callCount, details); // Set the account label if it exists. - String accountLabel = mCallLogCache.getAccountLabel(details.accountHandle); + String accountLabel = callLogCache.getAccountLabel(details.accountHandle); if (!TextUtils.isEmpty(details.viaNumber)) { if (!TextUtils.isEmpty(accountLabel)) { accountLabel = - mResources.getString( + resources.getString( R.string.call_log_via_number_phone_account, accountLabel, details.viaNumber); } else { - accountLabel = mResources.getString(R.string.call_log_via_number, details.viaNumber); + accountLabel = resources.getString(R.string.call_log_via_number, details.viaNumber); } } if (!TextUtils.isEmpty(accountLabel)) { views.callAccountLabel.setVisibility(View.VISIBLE); views.callAccountLabel.setText(accountLabel); - int color = mCallLogCache.getAccountColor(details.accountHandle); + int color = callLogCache.getAccountColor(details.accountHandle); if (color == PhoneAccount.NO_HIGHLIGHT_COLOR) { int defaultColor = R.color.dialer_secondary_text_color; - views.callAccountLabel.setTextColor(mContext.getResources().getColor(defaultColor)); + views.callAccountLabel.setTextColor(context.getResources().getColor(defaultColor)); } else { views.callAccountLabel.setTextColor(color); } @@ -171,23 +171,22 @@ public class PhoneCallDetailsHelper showRatingPrompt = true; } else if (details.transcriptionState == VoicemailCompat.TRANSCRIPTION_AVAILABLE || details.transcriptionState == VoicemailCompat.TRANSCRIPTION_AVAILABLE_AND_RATED) { - branding = mResources.getString(R.string.voicemail_transcription_branding_text); + branding = resources.getString(R.string.voicemail_transcription_branding_text); } } else { switch (details.transcriptionState) { case VoicemailCompat.TRANSCRIPTION_IN_PROGRESS: - branding = mResources.getString(R.string.voicemail_transcription_in_progress); + branding = resources.getString(R.string.voicemail_transcription_in_progress); break; case VoicemailCompat.TRANSCRIPTION_FAILED_NO_SPEECH_DETECTED: - branding = mResources.getString(R.string.voicemail_transcription_failed_no_speech); + branding = resources.getString(R.string.voicemail_transcription_failed_no_speech); break; case VoicemailCompat.TRANSCRIPTION_FAILED_LANGUAGE_NOT_SUPPORTED: branding = - mResources.getString( - R.string.voicemail_transcription_failed_language_not_supported); + resources.getString(R.string.voicemail_transcription_failed_language_not_supported); break; case VoicemailCompat.TRANSCRIPTION_FAILED: - branding = mResources.getString(R.string.voicemail_transcription_failed); + branding = resources.getString(R.string.voicemail_transcription_failed); break; default: break; // Fall through @@ -228,7 +227,7 @@ public class PhoneCallDetailsHelper views.callLocationAndDate.setTypeface(typeface); views.callLocationAndDate.setTextColor( ContextCompat.getColor( - mContext, + context, details.isRead ? R.color.call_log_detail_color : R.color.call_log_unread_text_color)); } @@ -236,16 +235,16 @@ public class PhoneCallDetailsHelper int transcriptionState, PhoneAccountHandle account) { // TODO(mdooley): add a configurable random element here? return transcriptionState == VoicemailCompat.TRANSCRIPTION_AVAILABLE - && VoicemailComponent.get(mContext) + && VoicemailComponent.get(context) .getVoicemailClient() - .isVoicemailDonationEnabled(mContext, account); + .isVoicemailDonationEnabled(context, account); } private void recordTranscriptionRating( TranscriptionRatingValue ratingValue, PhoneCallDetails details) { LogUtil.enterBlock("PhoneCallDetailsHelper.recordTranscriptionRating"); TranscriptionRatingHelper.sendRating( - mContext, + context, ratingValue, Uri.parse(details.voicemailUri), this::onRatingSuccess, @@ -256,7 +255,7 @@ public class PhoneCallDetailsHelper public void onRatingSuccess(Uri voicemailUri) { LogUtil.enterBlock("PhoneCallDetailsHelper.onRatingSuccess"); Toast toast = - Toast.makeText(mContext, R.string.voicemail_transcription_rating_thanks, Toast.LENGTH_LONG); + Toast.makeText(context, R.string.voicemail_transcription_rating_thanks, Toast.LENGTH_LONG); toast.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 50); toast.show(); } @@ -274,7 +273,7 @@ public class PhoneCallDetailsHelper * @return The call location and date string. */ public CharSequence getCallLocationAndDate(PhoneCallDetails details) { - mDescriptionItems.clear(); + descriptionItems.clear(); if (details.callTypes[0] != Calls.VOICEMAIL_TYPE) { // Get type of call (ie mobile, home, etc) if known, or the caller's location. @@ -283,15 +282,15 @@ public class PhoneCallDetailsHelper // Only add the call type or location if its not empty. It will be empty for unknown // callers. if (!TextUtils.isEmpty(callTypeOrLocation)) { - mDescriptionItems.add(callTypeOrLocation); + descriptionItems.add(callTypeOrLocation); } } // The date of this call - mDescriptionItems.add(getCallDate(details)); + descriptionItems.add(getCallDate(details)); // Create a comma separated list from the call type or location, and call date. - return DialerUtils.join(mDescriptionItems); + return DialerUtils.join(descriptionItems); } /** @@ -304,16 +303,16 @@ public class PhoneCallDetailsHelper */ public CharSequence getCallTypeOrLocation(PhoneCallDetails details) { if (details.isSpam) { - return mResources.getString(R.string.spam_number_call_log_label); + return resources.getString(R.string.spam_number_call_log_label); } else if (details.isBlocked) { - return mResources.getString(R.string.blocked_number_call_log_label); + return resources.getString(R.string.blocked_number_call_log_label); } CharSequence numberFormattedLabel = null; // Only show a label if the number is shown and it is not a SIP address. if (!TextUtils.isEmpty(details.number) && !PhoneNumberHelper.isUriNumber(details.number.toString()) - && !mCallLogCache.isVoicemailNumber(details.accountHandle, details.number)) { + && !callLogCache.isVoicemailNumber(details.accountHandle, details.number)) { if (shouldShowLocation(details)) { numberFormattedLabel = details.geocode; @@ -321,9 +320,9 @@ public class PhoneCallDetailsHelper && TextUtils.isEmpty(details.numberLabel))) { // Get type label only if it will not be "Custom" because of an empty number label. numberFormattedLabel = - mPhoneTypeLabelForTest != null - ? mPhoneTypeLabelForTest - : Phone.getTypeLabel(mResources, details.numberType, details.numberLabel); + phoneTypeLabelForTest != null + ? phoneTypeLabelForTest + : Phone.getTypeLabel(resources, details.numberType, details.numberLabel); } } @@ -350,7 +349,7 @@ public class PhoneCallDetailsHelper } public void setPhoneTypeLabelForTest(CharSequence phoneTypeLabel) { - this.mPhoneTypeLabelForTest = phoneTypeLabel; + this.phoneTypeLabelForTest = phoneTypeLabel; } /** @@ -385,10 +384,10 @@ public class PhoneCallDetailsHelper * @return String representing when the call occurred */ public CharSequence getGranularDateTime(PhoneCallDetails details) { - return mResources.getString( + return resources.getString( R.string.voicemailCallLogDateTimeFormat, getGranularDate(details.date), - DateUtils.formatDateTime(mContext, details.date, DateUtils.FORMAT_SHOW_TIME)); + DateUtils.formatDateTime(context, details.date, DateUtils.FORMAT_SHOW_TIME)); } /** @@ -396,10 +395,10 @@ public class PhoneCallDetailsHelper */ private String getGranularDate(long date) { if (DateUtils.isToday(date)) { - return mResources.getString(R.string.voicemailCallLogToday); + return resources.getString(R.string.voicemailCallLogToday); } return DateUtils.formatDateTime( - mContext, + context, date, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH @@ -412,10 +411,10 @@ public class PhoneCallDetailsHelper * @return {@code true} if date is within the current year, {@code false} otherwise */ private boolean shouldShowYear(long date) { - mCalendar.setTimeInMillis(getCurrentTimeMillis()); - int currentYear = mCalendar.get(Calendar.YEAR); - mCalendar.setTimeInMillis(date); - return currentYear != mCalendar.get(Calendar.YEAR); + calendar.setTimeInMillis(getCurrentTimeMillis()); + int currentYear = calendar.get(Calendar.YEAR); + calendar.setTimeInMillis(date); + return currentYear != calendar.get(Calendar.YEAR); } /** Sets the text of the header view for the details page of a phone call. */ @@ -426,14 +425,14 @@ public class PhoneCallDetailsHelper } else if (!TextUtils.isEmpty(details.displayNumber)) { nameText = details.displayNumber; } else { - nameText = mResources.getString(R.string.unknown); + nameText = resources.getString(R.string.unknown); } nameView.setText(nameText); } public void setCurrentTimeForTest(long currentTimeMillis) { - mCurrentTimeMillisForTest = currentTimeMillis; + currentTimeMillisForTest = currentTimeMillis; } /** @@ -442,10 +441,10 @@ public class PhoneCallDetailsHelper * <p>It can be injected in tests using {@link #setCurrentTimeForTest(long)}. */ private long getCurrentTimeMillis() { - if (mCurrentTimeMillisForTest == null) { + if (currentTimeMillisForTest == null) { return System.currentTimeMillis(); } else { - return mCurrentTimeMillisForTest; + return currentTimeMillisForTest; } } @@ -456,14 +455,14 @@ public class PhoneCallDetailsHelper CharSequence dateText = details.callLocationAndDate; final CharSequence text; if (callCount != null) { - text = mResources.getString(R.string.call_log_item_count_and_date, callCount, dateText); + text = resources.getString(R.string.call_log_item_count_and_date, callCount, dateText); } else { text = dateText; } if (details.callTypes[0] == Calls.VOICEMAIL_TYPE && details.duration > 0) { views.callLocationAndDate.setText( - mResources.getString( + resources.getString( R.string.voicemailCallLogDateTimeFormatWithDuration, text, getVoicemailDuration(details))); @@ -478,6 +477,6 @@ public class PhoneCallDetailsHelper if (minutes > 99) { minutes = 99; } - return mResources.getString(R.string.voicemailDurationFormat, minutes, seconds); + return resources.getString(R.string.voicemailDurationFormat, minutes, seconds); } } diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java b/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java index 33fcba002..d38ec57a4 100644 --- a/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java +++ b/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java @@ -46,11 +46,11 @@ import java.util.List; public class VisualVoicemailCallLogFragment extends CallLogFragment { - private final ContentObserver mVoicemailStatusObserver = new CustomContentObserver(); - private VoicemailPlaybackPresenter mVoicemailPlaybackPresenter; - private DialerExecutor<Context> mPreSyncVoicemailStatusCheckExecutor; + private final ContentObserver voicemailStatusObserver = new CustomContentObserver(); + private VoicemailPlaybackPresenter voicemailPlaybackPresenter; + private DialerExecutor<Context> preSyncVoicemailStatusCheckExecutor; - private VoicemailErrorManager mVoicemailErrorManager; + private VoicemailErrorManager voicemailErrorManager; public VisualVoicemailCallLogFragment() { super(CallLog.Calls.VOICEMAIL_TYPE); @@ -58,19 +58,19 @@ public class VisualVoicemailCallLogFragment extends CallLogFragment { @Override protected VoicemailPlaybackPresenter getVoicemailPlaybackPresenter() { - return mVoicemailPlaybackPresenter; + return voicemailPlaybackPresenter; } @Override public void onActivityCreated(Bundle savedInstanceState) { - mVoicemailPlaybackPresenter = + voicemailPlaybackPresenter = VoicemailPlaybackPresenter.getInstance(getActivity(), savedInstanceState); if (PermissionsUtil.hasReadVoicemailPermissions(getContext()) && PermissionsUtil.hasAddVoicemailPermissions(getContext())) { getActivity() .getContentResolver() .registerContentObserver( - VoicemailContract.Status.CONTENT_URI, true, mVoicemailStatusObserver); + VoicemailContract.Status.CONTENT_URI, true, voicemailStatusObserver); } else { LogUtil.w( "VisualVoicemailCallLogFragment.onActivityCreated", @@ -78,7 +78,7 @@ public class VisualVoicemailCallLogFragment extends CallLogFragment { } super.onActivityCreated(savedInstanceState); - mPreSyncVoicemailStatusCheckExecutor = + preSyncVoicemailStatusCheckExecutor = DialerExecutorComponent.get(getContext()) .dialerExecutorFactory() .createUiTaskBuilder( @@ -88,8 +88,8 @@ public class VisualVoicemailCallLogFragment extends CallLogFragment { .onSuccess(this::onPreSyncVoicemailStatusChecked) .build(); - mVoicemailErrorManager = - new VoicemailErrorManager(getContext(), getAdapter().getAlertManager(), mModalAlertManager); + voicemailErrorManager = + new VoicemailErrorManager(getContext(), getAdapter().getAlertManager(), modalAlertManager); if (PermissionsUtil.hasReadVoicemailPermissions(getContext()) && PermissionsUtil.hasAddVoicemailPermissions(getContext())) { @@ -98,7 +98,7 @@ public class VisualVoicemailCallLogFragment extends CallLogFragment { .registerContentObserver( VoicemailContract.Status.CONTENT_URI, true, - mVoicemailErrorManager.getContentObserver()); + voicemailErrorManager.getContentObserver()); } else { LogUtil.w( "VisualVoicemailCallLogFragment.onActivityCreated", @@ -116,14 +116,14 @@ public class VisualVoicemailCallLogFragment extends CallLogFragment { @Override public void onResume() { super.onResume(); - mVoicemailPlaybackPresenter.onResume(); - mVoicemailErrorManager.onResume(); + voicemailPlaybackPresenter.onResume(); + voicemailErrorManager.onResume(); } @Override public void onPause() { - mVoicemailPlaybackPresenter.onPause(); - mVoicemailErrorManager.onPause(); + voicemailPlaybackPresenter.onPause(); + voicemailErrorManager.onPause(); super.onPause(); } @@ -132,10 +132,10 @@ public class VisualVoicemailCallLogFragment extends CallLogFragment { if (isAdded()) { getActivity() .getContentResolver() - .unregisterContentObserver(mVoicemailErrorManager.getContentObserver()); - mVoicemailPlaybackPresenter.onDestroy(); - mVoicemailErrorManager.onDestroy(); - getActivity().getContentResolver().unregisterContentObserver(mVoicemailStatusObserver); + .unregisterContentObserver(voicemailErrorManager.getContentObserver()); + voicemailPlaybackPresenter.onDestroy(); + voicemailErrorManager.onDestroy(); + getActivity().getContentResolver().unregisterContentObserver(voicemailStatusObserver); } super.onDestroy(); } @@ -143,8 +143,8 @@ public class VisualVoicemailCallLogFragment extends CallLogFragment { @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - if (mVoicemailPlaybackPresenter != null) { - mVoicemailPlaybackPresenter.onSaveInstanceState(outState); + if (voicemailPlaybackPresenter != null) { + voicemailPlaybackPresenter.onSaveInstanceState(outState); } } @@ -159,7 +159,7 @@ public class VisualVoicemailCallLogFragment extends CallLogFragment { LogUtil.enterBlock("VisualVoicemailCallLogFragment.onVisible"); super.onVisible(); if (getActivity() != null) { - mPreSyncVoicemailStatusCheckExecutor.executeParallel(getActivity()); + preSyncVoicemailStatusCheckExecutor.executeParallel(getActivity()); Logger.get(getActivity()).logImpression(DialerImpression.Type.VVM_TAB_VIEWED); getActivity().setVolumeControlStream(VoicemailAudioManager.PLAYBACK_STREAM); } diff --git a/java/com/android/dialer/app/calllog/calllogcache/CallLogCache.java b/java/com/android/dialer/app/calllog/calllogcache/CallLogCache.java index 15de14318..f45537ca8 100644 --- a/java/com/android/dialer/app/calllog/calllogcache/CallLogCache.java +++ b/java/com/android/dialer/app/calllog/calllogcache/CallLogCache.java @@ -42,24 +42,24 @@ public class CallLogCache { // TODO: Dialer should be fixed so as not to check isVoicemail() so often but at the time of // this writing, that was a much larger undertaking than creating this cache. - protected final Context mContext; + protected final Context context; - private boolean mHasCheckedForVideoAvailability; - private int mVideoAvailability; - private final Map<PhoneAccountHandle, String> mPhoneAccountLabelCache = new ArrayMap<>(); - private final Map<PhoneAccountHandle, Integer> mPhoneAccountColorCache = new ArrayMap<>(); - private final Map<PhoneAccountHandle, Boolean> mPhoneAccountCallWithNoteCache = new ArrayMap<>(); + private boolean hasCheckedForVideoAvailability; + private int videoAvailability; + private final Map<PhoneAccountHandle, String> phoneAccountLabelCache = new ArrayMap<>(); + private final Map<PhoneAccountHandle, Integer> phoneAccountColorCache = new ArrayMap<>(); + private final Map<PhoneAccountHandle, Boolean> phoneAccountCallWithNoteCache = new ArrayMap<>(); public CallLogCache(Context context) { - mContext = context; + this.context = context; } public synchronized void reset() { - mPhoneAccountLabelCache.clear(); - mPhoneAccountColorCache.clear(); - mPhoneAccountCallWithNoteCache.clear(); - mHasCheckedForVideoAvailability = false; - mVideoAvailability = 0; + phoneAccountLabelCache.clear(); + phoneAccountColorCache.clear(); + phoneAccountCallWithNoteCache.clear(); + hasCheckedForVideoAvailability = false; + videoAvailability = 0; } /** @@ -71,7 +71,7 @@ public class CallLogCache { if (TextUtils.isEmpty(number)) { return false; } - return TelecomUtil.isVoicemailNumber(mContext, accountHandle, number.toString()); + return TelecomUtil.isVoicemailNumber(context, accountHandle, number.toString()); } /** @@ -79,31 +79,31 @@ public class CallLogCache { * {@link android.provider.ContactsContract.CommonDataKinds.Phone#CARRIER_PRESENCE} column. */ public boolean canRelyOnVideoPresence() { - if (!mHasCheckedForVideoAvailability) { - mVideoAvailability = CallUtil.getVideoCallingAvailability(mContext); - mHasCheckedForVideoAvailability = true; + if (!hasCheckedForVideoAvailability) { + videoAvailability = CallUtil.getVideoCallingAvailability(context); + hasCheckedForVideoAvailability = true; } - return (mVideoAvailability & CallUtil.VIDEO_CALLING_PRESENCE) != 0; + return (videoAvailability & CallUtil.VIDEO_CALLING_PRESENCE) != 0; } /** Extract account label from PhoneAccount object. */ public synchronized String getAccountLabel(PhoneAccountHandle accountHandle) { - if (mPhoneAccountLabelCache.containsKey(accountHandle)) { - return mPhoneAccountLabelCache.get(accountHandle); + if (phoneAccountLabelCache.containsKey(accountHandle)) { + return phoneAccountLabelCache.get(accountHandle); } else { - String label = PhoneAccountUtils.getAccountLabel(mContext, accountHandle); - mPhoneAccountLabelCache.put(accountHandle, label); + String label = PhoneAccountUtils.getAccountLabel(context, accountHandle); + phoneAccountLabelCache.put(accountHandle, label); return label; } } /** Extract account color from PhoneAccount object. */ public synchronized int getAccountColor(PhoneAccountHandle accountHandle) { - if (mPhoneAccountColorCache.containsKey(accountHandle)) { - return mPhoneAccountColorCache.get(accountHandle); + if (phoneAccountColorCache.containsKey(accountHandle)) { + return phoneAccountColorCache.get(accountHandle); } else { - Integer color = PhoneAccountUtils.getAccountColor(mContext, accountHandle); - mPhoneAccountColorCache.put(accountHandle, color); + Integer color = PhoneAccountUtils.getAccountColor(context, accountHandle); + phoneAccountColorCache.put(accountHandle, color); return color; } } @@ -116,12 +116,12 @@ public class CallLogCache { * @return {@code true} if calling with a note is supported, {@code false} otherwise. */ public synchronized boolean doesAccountSupportCallSubject(PhoneAccountHandle accountHandle) { - if (mPhoneAccountCallWithNoteCache.containsKey(accountHandle)) { - return mPhoneAccountCallWithNoteCache.get(accountHandle); + if (phoneAccountCallWithNoteCache.containsKey(accountHandle)) { + return phoneAccountCallWithNoteCache.get(accountHandle); } else { Boolean supportsCallWithNote = - PhoneAccountUtils.getAccountSupportsCallSubject(mContext, accountHandle); - mPhoneAccountCallWithNoteCache.put(accountHandle, supportsCallWithNote); + PhoneAccountUtils.getAccountSupportsCallSubject(context, accountHandle); + phoneAccountCallWithNoteCache.put(accountHandle, supportsCallWithNote); return supportsCallWithNote; } } |