diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-12-11 21:48:29 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-12-11 21:48:29 +0000 |
commit | 04e88264e69ec2b6974a4d9d6acfa7cd27934e5a (patch) | |
tree | 8d3fe7e8212bfaf312bb5159f898b56a7004f84e /java/com/android/dialer/app | |
parent | aab6dc9f075fd8576ffc78c1f983b8fb1d3e77fa (diff) | |
parent | 9ad8a72f81d9868e50e27199bbca248090e7aba9 (diff) |
Merge "Update Spam module to use Dagger"
Diffstat (limited to 'java/com/android/dialer/app')
-rw-r--r-- | java/com/android/dialer/app/calllog/BlockReportSpamListener.java | 174 | ||||
-rw-r--r-- | java/com/android/dialer/app/calllog/CallLogAdapter.java | 7 |
2 files changed, 79 insertions, 102 deletions
diff --git a/java/com/android/dialer/app/calllog/BlockReportSpamListener.java b/java/com/android/dialer/app/calllog/BlockReportSpamListener.java index 28082df2b..05fb2b345 100644 --- a/java/com/android/dialer/app/calllog/BlockReportSpamListener.java +++ b/java/com/android/dialer/app/calllog/BlockReportSpamListener.java @@ -17,9 +17,7 @@ package com.android.dialer.app.calllog; import android.app.FragmentManager; -import android.content.ContentValues; import android.content.Context; -import android.net.Uri; import android.support.annotation.NonNull; import android.support.v7.widget.RecyclerView; import com.android.dialer.blocking.BlockReportSpamDialogs; @@ -30,6 +28,7 @@ import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.logging.ReportingLocation; import com.android.dialer.spam.Spam; +import com.android.dialer.spam.SpamComponent; /** Listener to show dialogs for block and report spam actions. */ public class BlockReportSpamListener implements CallLogListItemViewHolder.OnClickListener { @@ -38,6 +37,7 @@ public class BlockReportSpamListener implements CallLogListItemViewHolder.OnClic private final FragmentManager mFragmentManager; private final RecyclerView.Adapter mAdapter; private final FilteredNumberAsyncQueryHandler mFilteredNumberAsyncQueryHandler; + private final Spam spam; public BlockReportSpamListener( Context context, @@ -48,6 +48,7 @@ public class BlockReportSpamListener implements CallLogListItemViewHolder.OnClic mFragmentManager = fragmentManager; mAdapter = adapter; mFilteredNumberAsyncQueryHandler = filteredNumberAsyncQueryHandler; + spam = SpamComponent.get(context).spam(); } @Override @@ -59,36 +60,29 @@ public class BlockReportSpamListener implements CallLogListItemViewHolder.OnClic @NonNull final ContactSource.Type contactSourceType) { BlockReportSpamDialogs.BlockReportSpamDialogFragment.newInstance( displayNumber, - Spam.get(mContext).isDialogReportSpamCheckedByDefault(), - new BlockReportSpamDialogs.OnSpamDialogClickListener() { - @Override - public void onClick(boolean isSpamChecked) { - LogUtil.i("BlockReportSpamListener.onBlockReportSpam", "onClick"); - if (isSpamChecked && Spam.get(mContext).isSpamEnabled()) { - Logger.get(mContext) - .logImpression( - DialerImpression.Type - .REPORT_CALL_AS_SPAM_VIA_CALL_LOG_BLOCK_REPORT_SPAM_SENT_VIA_BLOCK_NUMBER_DIALOG); - Spam.get(mContext) - .reportSpamFromCallHistory( - number, - countryIso, - callType, - ReportingLocation.Type.CALL_LOG_HISTORY, - contactSourceType); - } - mFilteredNumberAsyncQueryHandler.blockNumber( - new FilteredNumberAsyncQueryHandler.OnBlockNumberListener() { - @Override - public void onBlockComplete(Uri uri) { - Logger.get(mContext) - .logImpression(DialerImpression.Type.USER_ACTION_BLOCKED_NUMBER); - mAdapter.notifyDataSetChanged(); - } - }, + spam.isDialogReportSpamCheckedByDefault(), + isSpamChecked -> { + LogUtil.i("BlockReportSpamListener.onBlockReportSpam", "onClick"); + if (isSpamChecked && spam.isSpamEnabled()) { + Logger.get(mContext) + .logImpression( + DialerImpression.Type + .REPORT_CALL_AS_SPAM_VIA_CALL_LOG_BLOCK_REPORT_SPAM_SENT_VIA_BLOCK_NUMBER_DIALOG); + spam.reportSpamFromCallHistory( number, - countryIso); + countryIso, + callType, + ReportingLocation.Type.CALL_LOG_HISTORY, + contactSourceType); } + mFilteredNumberAsyncQueryHandler.blockNumber( + uri -> { + Logger.get(mContext) + .logImpression(DialerImpression.Type.USER_ACTION_BLOCKED_NUMBER); + mAdapter.notifyDataSetChanged(); + }, + number, + countryIso); }, null) .show(mFragmentManager, BlockReportSpamDialogs.BLOCK_REPORT_SPAM_DIALOG_TAG); @@ -103,36 +97,29 @@ public class BlockReportSpamListener implements CallLogListItemViewHolder.OnClic @NonNull final ContactSource.Type contactSourceType) { BlockReportSpamDialogs.BlockDialogFragment.newInstance( displayNumber, - Spam.get(mContext).isSpamEnabled(), - new BlockReportSpamDialogs.OnConfirmListener() { - @Override - public void onClick() { - LogUtil.i("BlockReportSpamListener.onBlock", "onClick"); - if (Spam.get(mContext).isSpamEnabled()) { - Logger.get(mContext) - .logImpression( - DialerImpression.Type - .DIALOG_ACTION_CONFIRM_NUMBER_SPAM_INDIRECTLY_VIA_BLOCK_NUMBER); - Spam.get(mContext) - .reportSpamFromCallHistory( - number, - countryIso, - callType, - ReportingLocation.Type.CALL_LOG_HISTORY, - contactSourceType); - } - mFilteredNumberAsyncQueryHandler.blockNumber( - new FilteredNumberAsyncQueryHandler.OnBlockNumberListener() { - @Override - public void onBlockComplete(Uri uri) { - Logger.get(mContext) - .logImpression(DialerImpression.Type.USER_ACTION_BLOCKED_NUMBER); - mAdapter.notifyDataSetChanged(); - } - }, + spam.isSpamEnabled(), + () -> { + LogUtil.i("BlockReportSpamListener.onBlock", "onClick"); + if (spam.isSpamEnabled()) { + Logger.get(mContext) + .logImpression( + DialerImpression.Type + .DIALOG_ACTION_CONFIRM_NUMBER_SPAM_INDIRECTLY_VIA_BLOCK_NUMBER); + spam.reportSpamFromCallHistory( number, - countryIso); + countryIso, + callType, + ReportingLocation.Type.CALL_LOG_HISTORY, + contactSourceType); } + mFilteredNumberAsyncQueryHandler.blockNumber( + uri -> { + Logger.get(mContext) + .logImpression(DialerImpression.Type.USER_ACTION_BLOCKED_NUMBER); + mAdapter.notifyDataSetChanged(); + }, + number, + countryIso); }, null) .show(mFragmentManager, BlockReportSpamDialogs.BLOCK_DIALOG_TAG); @@ -150,32 +137,25 @@ public class BlockReportSpamListener implements CallLogListItemViewHolder.OnClic BlockReportSpamDialogs.UnblockDialogFragment.newInstance( displayNumber, isSpam, - new BlockReportSpamDialogs.OnConfirmListener() { - @Override - public void onClick() { - LogUtil.i("BlockReportSpamListener.onUnblock", "onClick"); - if (isSpam && Spam.get(mContext).isSpamEnabled()) { - Logger.get(mContext) - .logImpression(DialerImpression.Type.REPORT_AS_NOT_SPAM_VIA_UNBLOCK_NUMBER); - Spam.get(mContext) - .reportNotSpamFromCallHistory( - number, - countryIso, - callType, - ReportingLocation.Type.CALL_LOG_HISTORY, - contactSourceType); - } - mFilteredNumberAsyncQueryHandler.unblock( - new FilteredNumberAsyncQueryHandler.OnUnblockNumberListener() { - @Override - public void onUnblockComplete(int rows, ContentValues values) { - Logger.get(mContext) - .logImpression(DialerImpression.Type.USER_ACTION_UNBLOCKED_NUMBER); - mAdapter.notifyDataSetChanged(); - } - }, - blockId); + () -> { + LogUtil.i("BlockReportSpamListener.onUnblock", "onClick"); + if (isSpam && spam.isSpamEnabled()) { + Logger.get(mContext) + .logImpression(DialerImpression.Type.REPORT_AS_NOT_SPAM_VIA_UNBLOCK_NUMBER); + spam.reportNotSpamFromCallHistory( + number, + countryIso, + callType, + ReportingLocation.Type.CALL_LOG_HISTORY, + contactSourceType); } + mFilteredNumberAsyncQueryHandler.unblock( + (rows, values) -> { + Logger.get(mContext) + .logImpression(DialerImpression.Type.USER_ACTION_UNBLOCKED_NUMBER); + mAdapter.notifyDataSetChanged(); + }, + blockId); }, null) .show(mFragmentManager, BlockReportSpamDialogs.UNBLOCK_DIALOG_TAG); @@ -190,23 +170,19 @@ public class BlockReportSpamListener implements CallLogListItemViewHolder.OnClic final ContactSource.Type contactSourceType) { BlockReportSpamDialogs.ReportNotSpamDialogFragment.newInstance( displayNumber, - new BlockReportSpamDialogs.OnConfirmListener() { - @Override - public void onClick() { - LogUtil.i("BlockReportSpamListener.onReportNotSpam", "onClick"); - if (Spam.get(mContext).isSpamEnabled()) { - Logger.get(mContext) - .logImpression(DialerImpression.Type.DIALOG_ACTION_CONFIRM_NUMBER_NOT_SPAM); - Spam.get(mContext) - .reportNotSpamFromCallHistory( - number, - countryIso, - callType, - ReportingLocation.Type.CALL_LOG_HISTORY, - contactSourceType); - } - mAdapter.notifyDataSetChanged(); + () -> { + LogUtil.i("BlockReportSpamListener.onReportNotSpam", "onClick"); + if (spam.isSpamEnabled()) { + Logger.get(mContext) + .logImpression(DialerImpression.Type.DIALOG_ACTION_CONFIRM_NUMBER_NOT_SPAM); + spam.reportNotSpamFromCallHistory( + number, + countryIso, + callType, + ReportingLocation.Type.CALL_LOG_HISTORY, + contactSourceType); } + mAdapter.notifyDataSetChanged(); }, null) .show(mFragmentManager, BlockReportSpamDialogs.NOT_SPAM_DIALOG_TAG); diff --git a/java/com/android/dialer/app/calllog/CallLogAdapter.java b/java/com/android/dialer/app/calllog/CallLogAdapter.java index f4565550a..0459519d5 100644 --- a/java/com/android/dialer/app/calllog/CallLogAdapter.java +++ b/java/com/android/dialer/app/calllog/CallLogAdapter.java @@ -89,7 +89,7 @@ import com.android.dialer.phonenumbercache.CallLogQuery; import com.android.dialer.phonenumbercache.ContactInfo; import com.android.dialer.phonenumbercache.ContactInfoHelper; import com.android.dialer.phonenumberutil.PhoneNumberHelper; -import com.android.dialer.spam.Spam; +import com.android.dialer.spam.SpamComponent; import com.android.dialer.util.PermissionsUtil; import java.util.ArrayList; import java.util.Map; @@ -667,7 +667,7 @@ public class CallLogAdapter extends GroupingListAdapter mContactInfoCache.start(); } mContactsPreferences.refreshValue(ContactsPreferences.DISPLAY_ORDER_KEY); - mIsSpamEnabled = Spam.get(mActivity).isSpamEnabled(); + mIsSpamEnabled = SpamComponent.get(mActivity).spam().isSpamEnabled(); getDuo().registerListener(this); notifyDataSetChanged(); } @@ -862,7 +862,8 @@ public class CallLogAdapter extends GroupingListAdapter // Call log cards with only outgoing calls should never be displayed as spam. viewHolder.isSpam = details.hasIncomingCalls() - && Spam.get(mActivity) + && SpamComponent.get(mActivity) + .spam() .checkSpamStatusSynchronous(viewHolder.number, viewHolder.countryIso); details.isSpam = viewHolder.isSpam; } |