From 719341fb552ddb1b1e955e0f8ace79ffc0491b67 Mon Sep 17 00:00:00 2001 From: linyuh Date: Mon, 26 Feb 2018 10:56:21 -0800 Subject: Implement logic of bottom sheet options related to spam numbers. Bug: 70989605 Test: ShowBlockReportSpamDialogNotifierEndToEndTest + Manual PiperOrigin-RevId: 187047450 Change-Id: I23c3929135bcfe5c14fe317ef65f628dc126027f --- .../app/calllog/BlockReportSpamListener.java | 2 +- .../dialer/blocking/BlockReportSpamDialogs.java | 305 --------------------- .../res/layout/block_report_spam_dialog.xml | 36 --- .../android/dialer/blocking/res/values/colors.xml | 3 - .../android/dialer/blocking/res/values/dimens.xml | 18 -- .../android/dialer/blocking/res/values/strings.xml | 88 +++--- .../dialer/blockreportspam/AndroidManifest.xml | 18 ++ .../blockreportspam/BlockReportSpamDialogs.java | 288 +++++++++++++++++++ .../ShowBlockReportSpamDialogNotifier.java | 76 +++++ .../ShowBlockReportSpamDialogReceiver.java | 171 ++++++++++++ .../res/layout/block_report_spam_dialog.xml | 36 +++ .../dialer/blockreportspam/res/values/colors.xml | 21 ++ .../dialer/blockreportspam/res/values/dimens.xml | 18 ++ .../dialer/blockreportspam/res/values/strings.xml | 63 +++++ .../android/dialer/calllog/ui/menu/Modules.java | 4 +- .../dialer/contactactions/SharedModules.java | 64 +++-- java/com/android/dialer/main/MainActivityPeer.java | 2 + .../com/android/dialer/main/impl/MainActivity.java | 6 + .../dialer/main/impl/NewMainActivityPeer.java | 17 +- .../dialer/main/impl/OldMainActivityPeer.java | 3 + .../dialer/voicemail/listui/menu/Modules.java | 4 +- .../incallui/spam/SpamNotificationActivity.java | 2 +- packages.mk | 1 + 23 files changed, 803 insertions(+), 443 deletions(-) delete mode 100644 java/com/android/dialer/blocking/BlockReportSpamDialogs.java delete mode 100644 java/com/android/dialer/blocking/res/layout/block_report_spam_dialog.xml delete mode 100644 java/com/android/dialer/blocking/res/values/dimens.xml create mode 100644 java/com/android/dialer/blockreportspam/AndroidManifest.xml create mode 100644 java/com/android/dialer/blockreportspam/BlockReportSpamDialogs.java create mode 100644 java/com/android/dialer/blockreportspam/ShowBlockReportSpamDialogNotifier.java create mode 100644 java/com/android/dialer/blockreportspam/ShowBlockReportSpamDialogReceiver.java create mode 100644 java/com/android/dialer/blockreportspam/res/layout/block_report_spam_dialog.xml create mode 100644 java/com/android/dialer/blockreportspam/res/values/colors.xml create mode 100644 java/com/android/dialer/blockreportspam/res/values/dimens.xml create mode 100644 java/com/android/dialer/blockreportspam/res/values/strings.xml diff --git a/java/com/android/dialer/app/calllog/BlockReportSpamListener.java b/java/com/android/dialer/app/calllog/BlockReportSpamListener.java index 092c0982e..c8f8f0cf4 100644 --- a/java/com/android/dialer/app/calllog/BlockReportSpamListener.java +++ b/java/com/android/dialer/app/calllog/BlockReportSpamListener.java @@ -20,8 +20,8 @@ import android.app.FragmentManager; import android.content.Context; import android.support.annotation.NonNull; import android.support.v7.widget.RecyclerView; -import com.android.dialer.blocking.BlockReportSpamDialogs; import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler; +import com.android.dialer.blockreportspam.BlockReportSpamDialogs; import com.android.dialer.common.LogUtil; import com.android.dialer.logging.ContactSource; import com.android.dialer.logging.DialerImpression; diff --git a/java/com/android/dialer/blocking/BlockReportSpamDialogs.java b/java/com/android/dialer/blocking/BlockReportSpamDialogs.java deleted file mode 100644 index 255d7cbf9..000000000 --- a/java/com/android/dialer/blocking/BlockReportSpamDialogs.java +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dialer.blocking; - -import android.app.Activity; -import android.app.AlertDialog; -import android.app.Dialog; -import android.app.DialogFragment; -import android.content.Context; -import android.content.DialogInterface; -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.view.View; -import android.widget.CheckBox; -import android.widget.CompoundButton; -import android.widget.TextView; - -/** Helper class for creating block/report dialog fragments. */ -public class BlockReportSpamDialogs { - - public static final String BLOCK_REPORT_SPAM_DIALOG_TAG = "BlockReportSpamDialog"; - public static final String BLOCK_DIALOG_TAG = "BlockDialog"; - public static final String UNBLOCK_DIALOG_TAG = "UnblockDialog"; - public static final String NOT_SPAM_DIALOG_TAG = "NotSpamDialog"; - - /** Creates a dialog with the default cancel button listener (dismisses dialog). */ - private static AlertDialog.Builder createDialogBuilder( - Activity activity, final DialogFragment fragment) { - return new AlertDialog.Builder(activity, R.style.AlertDialogTheme) - .setCancelable(true) - .setNegativeButton( - android.R.string.cancel, - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - fragment.dismiss(); - } - }); - } - - /** - * Creates a generic click listener which dismisses the fragment and then calls the actual - * listener. - */ - private static DialogInterface.OnClickListener createGenericOnClickListener( - final DialogFragment fragment, final OnConfirmListener listener) { - return new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - fragment.dismiss(); - listener.onClick(); - } - }; - } - - private static String getBlockMessage(Context context) { - String message; - if (FilteredNumberCompat.useNewFiltering(context)) { - message = context.getString(R.string.block_number_confirmation_message_new_filtering); - } else { - message = context.getString(R.string.block_report_number_alert_details); - } - return message; - } - - /** - * Listener passed to block/report spam dialog for positive click in {@link - * BlockReportSpamDialogFragment}. - */ - public interface OnSpamDialogClickListener { - - /** - * Called when user clicks on positive button in block/report spam dialog. - * - * @param isSpamChecked Whether the spam checkbox is checked. - */ - void onClick(boolean isSpamChecked); - } - - /** Listener passed to all dialogs except the block/report spam dialog for positive click. */ - public interface OnConfirmListener { - - /** Called when user clicks on positive button in the dialog. */ - void onClick(); - } - - /** Contains the common attributes between all block/unblock/report dialog fragments. */ - private static class CommonDialogsFragment extends DialogFragment { - - /** The number to display in the dialog title. */ - protected String displayNumber; - - /** Called when dialog positive button is pressed. */ - protected OnConfirmListener positiveListener; - - /** Called when dialog is dismissed. */ - @Nullable protected DialogInterface.OnDismissListener dismissListener; - - @Override - public void onDismiss(DialogInterface dialog) { - if (dismissListener != null) { - dismissListener.onDismiss(dialog); - } - super.onDismiss(dialog); - } - - @Override - public void onPause() { - // The dialog is dismissed onPause, i.e. rotation. - dismiss(); - dismissListener = null; - positiveListener = null; - displayNumber = null; - super.onPause(); - } - } - - /** Dialog for block/report spam with the mark as spam checkbox. */ - public static class BlockReportSpamDialogFragment extends CommonDialogsFragment { - - /** Called when dialog positive button is pressed. */ - private OnSpamDialogClickListener positiveListener; - - /** Whether the mark as spam checkbox is checked before displaying the dialog. */ - private boolean spamChecked; - - public static DialogFragment newInstance( - String displayNumber, - boolean spamChecked, - OnSpamDialogClickListener positiveListener, - @Nullable DialogInterface.OnDismissListener dismissListener) { - BlockReportSpamDialogFragment fragment = new BlockReportSpamDialogFragment(); - fragment.spamChecked = spamChecked; - fragment.displayNumber = displayNumber; - fragment.positiveListener = positiveListener; - fragment.dismissListener = dismissListener; - return fragment; - } - - @Override - public Dialog onCreateDialog(Bundle savedInstanceState) { - super.onCreateDialog(savedInstanceState); - View dialogView = View.inflate(getActivity(), R.layout.block_report_spam_dialog, null); - final CheckBox isSpamCheckbox = - (CheckBox) dialogView.findViewById(R.id.report_number_as_spam_action); - // Listen for changes on the checkbox and update if orientation changes - isSpamCheckbox.setChecked(spamChecked); - isSpamCheckbox.setOnCheckedChangeListener( - new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - spamChecked = isChecked; - } - }); - - TextView details = (TextView) dialogView.findViewById(R.id.block_details); - details.setText(getBlockMessage(getContext())); - - AlertDialog.Builder alertDialogBuilder = createDialogBuilder(getActivity(), this); - Dialog dialog = - alertDialogBuilder - .setView(dialogView) - .setTitle(getString(R.string.block_report_number_alert_title, displayNumber)) - .setPositiveButton( - R.string.block_number_ok, - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - dismiss(); - positiveListener.onClick(isSpamCheckbox.isChecked()); - } - }) - .create(); - dialog.setCanceledOnTouchOutside(true); - return dialog; - } - } - - /** Dialog for blocking a number. */ - public static class BlockDialogFragment extends CommonDialogsFragment { - - private boolean isSpamEnabled; - - public static DialogFragment newInstance( - String displayNumber, - boolean isSpamEnabled, - OnConfirmListener positiveListener, - @Nullable DialogInterface.OnDismissListener dismissListener) { - BlockDialogFragment fragment = new BlockDialogFragment(); - fragment.displayNumber = displayNumber; - fragment.positiveListener = positiveListener; - fragment.dismissListener = dismissListener; - fragment.isSpamEnabled = isSpamEnabled; - return fragment; - } - - @Override - public Dialog onCreateDialog(Bundle savedInstanceState) { - super.onCreateDialog(savedInstanceState); - // Return the newly created dialog - AlertDialog.Builder alertDialogBuilder = createDialogBuilder(getActivity(), this); - Dialog dialog = - alertDialogBuilder - .setTitle(getString(R.string.block_number_confirmation_title, displayNumber)) - .setMessage( - isSpamEnabled - ? getString( - R.string.block_number_alert_details, getBlockMessage(getContext())) - : getString(R.string.block_report_number_alert_details)) - .setPositiveButton( - R.string.block_number_ok, createGenericOnClickListener(this, positiveListener)) - .create(); - dialog.setCanceledOnTouchOutside(true); - return dialog; - } - } - - /** Dialog for unblocking a number. */ - public static class UnblockDialogFragment extends CommonDialogsFragment { - - /** Whether or not the number is spam. */ - private boolean isSpam; - - public static DialogFragment newInstance( - String displayNumber, - boolean isSpam, - OnConfirmListener positiveListener, - @Nullable DialogInterface.OnDismissListener dismissListener) { - UnblockDialogFragment fragment = new UnblockDialogFragment(); - fragment.displayNumber = displayNumber; - fragment.isSpam = isSpam; - fragment.positiveListener = positiveListener; - fragment.dismissListener = dismissListener; - return fragment; - } - - @Override - public Dialog onCreateDialog(Bundle savedInstanceState) { - super.onCreateDialog(savedInstanceState); - // Return the newly created dialog - AlertDialog.Builder alertDialogBuilder = createDialogBuilder(getActivity(), this); - if (isSpam) { - alertDialogBuilder - .setMessage(R.string.unblock_number_alert_details) - .setTitle(getString(R.string.unblock_report_number_alert_title, displayNumber)); - } else { - alertDialogBuilder.setMessage( - getString(R.string.unblock_report_number_alert_title, displayNumber)); - } - Dialog dialog = - alertDialogBuilder - .setPositiveButton( - R.string.unblock_number_ok, createGenericOnClickListener(this, positiveListener)) - .create(); - dialog.setCanceledOnTouchOutside(true); - return dialog; - } - } - - /** Dialog for reporting a number as not spam. */ - public static class ReportNotSpamDialogFragment extends CommonDialogsFragment { - - public static DialogFragment newInstance( - String displayNumber, - OnConfirmListener positiveListener, - @Nullable DialogInterface.OnDismissListener dismissListener) { - ReportNotSpamDialogFragment fragment = new ReportNotSpamDialogFragment(); - fragment.displayNumber = displayNumber; - fragment.positiveListener = positiveListener; - fragment.dismissListener = dismissListener; - return fragment; - } - - @Override - public Dialog onCreateDialog(Bundle savedInstanceState) { - super.onCreateDialog(savedInstanceState); - // Return the newly created dialog - AlertDialog.Builder alertDialogBuilder = createDialogBuilder(getActivity(), this); - Dialog dialog = - alertDialogBuilder - .setTitle(R.string.report_not_spam_alert_title) - .setMessage(getString(R.string.report_not_spam_alert_details, displayNumber)) - .setPositiveButton( - R.string.report_not_spam_alert_button, - createGenericOnClickListener(this, positiveListener)) - .create(); - dialog.setCanceledOnTouchOutside(true); - return dialog; - } - } -} diff --git a/java/com/android/dialer/blocking/res/layout/block_report_spam_dialog.xml b/java/com/android/dialer/blocking/res/layout/block_report_spam_dialog.xml deleted file mode 100644 index 82e8d80b3..000000000 --- a/java/com/android/dialer/blocking/res/layout/block_report_spam_dialog.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - diff --git a/java/com/android/dialer/blocking/res/values/colors.xml b/java/com/android/dialer/blocking/res/values/colors.xml index d1a567d9e..374ba8d14 100644 --- a/java/com/android/dialer/blocking/res/values/colors.xml +++ b/java/com/android/dialer/blocking/res/values/colors.xml @@ -15,9 +15,6 @@ --> - - #de000000 - #A52714 diff --git a/java/com/android/dialer/blocking/res/values/dimens.xml b/java/com/android/dialer/blocking/res/values/dimens.xml deleted file mode 100644 index cd7cfe2fd..000000000 --- a/java/com/android/dialer/blocking/res/values/dimens.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - 16sp - diff --git a/java/com/android/dialer/blocking/res/values/strings.xml b/java/com/android/dialer/blocking/res/values/strings.xml index 8abff4561..a660731b4 100644 --- a/java/com/android/dialer/blocking/res/values/strings.xml +++ b/java/com/android/dialer/blocking/res/values/strings.xml @@ -24,54 +24,59 @@ Allow - - @android:string/cancel + + @android:string/cancel + - Block - %1$s? + + Block%1$s? + - - Calls from this number will be blocked and voicemails will be automatically deleted. - + + Calls from this number will be blocked and voicemails will be automatically deleted. + - - Calls from this number will be blocked, but the caller may still be able to leave you voicemails. - + + Calls from this number will be blocked, but the caller may still be able to leave you voicemails. + - - You will no longer receive calls or texts from this number. - + + You will no longer receive calls or texts from this number. + BLOCK - Unblock - %1$s? + + Unblock%1$s? + UNBLOCK - %1$s - is invalid. + + %1$sis invalid. + - - %1$s blocked + + %1$s blocked + - - %1$s - unblocked + + %1$sunblocked + UNDO @@ -81,42 +86,15 @@ - - Call blocking disabled for 48 hours - + + Call blocking disabled for 48 hours + - - Disabled because an emergency call was made. - - - - Block %1$s? - - - You will no longer receive calls from this number. - - - %1$s This call will be reported as spam. - - - This number will be unblocked and reported as not spam. Future calls won\'t be identified as spam. - - - Unblock %1$s? - - - Report - - - Report a mistake? - - - Future calls from %1$s will no longer be identified as spam. - - - Report call as spam + + Disabled because an emergency call was made. + diff --git a/java/com/android/dialer/blockreportspam/AndroidManifest.xml b/java/com/android/dialer/blockreportspam/AndroidManifest.xml new file mode 100644 index 000000000..6e08043de --- /dev/null +++ b/java/com/android/dialer/blockreportspam/AndroidManifest.xml @@ -0,0 +1,18 @@ + + + + \ No newline at end of file diff --git a/java/com/android/dialer/blockreportspam/BlockReportSpamDialogs.java b/java/com/android/dialer/blockreportspam/BlockReportSpamDialogs.java new file mode 100644 index 000000000..b75669fa3 --- /dev/null +++ b/java/com/android/dialer/blockreportspam/BlockReportSpamDialogs.java @@ -0,0 +1,288 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.dialer.blockreportspam; + +import android.app.Activity; +import android.app.AlertDialog; +import android.app.Dialog; +import android.app.DialogFragment; +import android.content.Context; +import android.content.DialogInterface; +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.view.View; +import android.widget.CheckBox; +import android.widget.TextView; +import com.android.dialer.blocking.FilteredNumberCompat; + +/** + * Helper class for creating dialog fragments to block a number and/or report it as spam/not spam. + */ +public final class BlockReportSpamDialogs { + + public static final String BLOCK_REPORT_SPAM_DIALOG_TAG = "BlockReportSpamDialog"; + public static final String BLOCK_DIALOG_TAG = "BlockDialog"; + public static final String UNBLOCK_DIALOG_TAG = "UnblockDialog"; + public static final String NOT_SPAM_DIALOG_TAG = "NotSpamDialog"; + + /** Creates a dialog with the default cancel button listener (dismisses dialog). */ + private static AlertDialog.Builder createDialogBuilder( + Activity activity, final DialogFragment fragment) { + return new AlertDialog.Builder(activity, R.style.AlertDialogTheme) + .setCancelable(true) + .setNegativeButton(android.R.string.cancel, (dialog, which) -> fragment.dismiss()); + } + + /** + * Creates a generic click listener which dismisses the fragment and then calls the actual + * listener. + */ + private static DialogInterface.OnClickListener createGenericOnClickListener( + final DialogFragment fragment, final OnConfirmListener listener) { + return (dialog, which) -> { + fragment.dismiss(); + listener.onClick(); + }; + } + + private static String getBlockMessage(Context context) { + String message; + if (FilteredNumberCompat.useNewFiltering(context)) { + message = context.getString(R.string.block_number_confirmation_message_new_filtering); + } else { + message = context.getString(R.string.block_report_number_alert_details); + } + return message; + } + + /** + * Listener passed to block/report spam dialog for positive click in {@link + * BlockReportSpamDialogFragment}. + */ + public interface OnSpamDialogClickListener { + + /** + * Called when user clicks on positive button in block/report spam dialog. + * + * @param isSpamChecked Whether the spam checkbox is checked. + */ + void onClick(boolean isSpamChecked); + } + + /** Listener passed to all dialogs except the block/report spam dialog for positive click. */ + public interface OnConfirmListener { + + /** Called when user clicks on positive button in the dialog. */ + void onClick(); + } + + /** Contains the common attributes between all block/unblock/report spam dialog fragments. */ + private abstract static class CommonDialogsFragment extends DialogFragment { + + /** The number to display in the dialog title. */ + protected String displayNumber; + + /** Called when dialog positive button is pressed. */ + protected OnConfirmListener positiveListener; + + /** Called when dialog is dismissed. */ + @Nullable protected DialogInterface.OnDismissListener dismissListener; + + @Override + public void onDismiss(DialogInterface dialog) { + if (dismissListener != null) { + dismissListener.onDismiss(dialog); + } + super.onDismiss(dialog); + } + + @Override + public void onPause() { + // The dialog is dismissed onPause, i.e. rotation. + dismiss(); + dismissListener = null; + positiveListener = null; + displayNumber = null; + super.onPause(); + } + } + + /** Dialog for block/report spam with the mark as spam checkbox. */ + public static class BlockReportSpamDialogFragment extends CommonDialogsFragment { + + /** Called when dialog positive button is pressed. */ + private OnSpamDialogClickListener onSpamDialogClickListener; + + /** Whether the mark as spam checkbox is checked before displaying the dialog. */ + private boolean spamChecked; + + public static DialogFragment newInstance( + String displayNumber, + boolean spamChecked, + OnSpamDialogClickListener onSpamDialogClickListener, + @Nullable DialogInterface.OnDismissListener dismissListener) { + BlockReportSpamDialogFragment fragment = new BlockReportSpamDialogFragment(); + fragment.spamChecked = spamChecked; + fragment.displayNumber = displayNumber; + fragment.onSpamDialogClickListener = onSpamDialogClickListener; + fragment.dismissListener = dismissListener; + return fragment; + } + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + super.onCreateDialog(savedInstanceState); + View dialogView = View.inflate(getActivity(), R.layout.block_report_spam_dialog, null); + final CheckBox isSpamCheckbox = + (CheckBox) dialogView.findViewById(R.id.report_number_as_spam_action); + // Listen for changes on the checkbox and update if orientation changes + isSpamCheckbox.setChecked(spamChecked); + isSpamCheckbox.setOnCheckedChangeListener((buttonView, isChecked) -> spamChecked = isChecked); + + TextView details = (TextView) dialogView.findViewById(R.id.block_details); + details.setText(getBlockMessage(getContext())); + + AlertDialog.Builder alertDialogBuilder = createDialogBuilder(getActivity(), this); + Dialog blockReportSpamDialog = + alertDialogBuilder + .setView(dialogView) + .setTitle(getString(R.string.block_report_number_alert_title, displayNumber)) + .setPositiveButton( + R.string.block_number_ok, + (dialog, which) -> { + dismiss(); + onSpamDialogClickListener.onClick(isSpamCheckbox.isChecked()); + }) + .create(); + blockReportSpamDialog.setCanceledOnTouchOutside(true); + return blockReportSpamDialog; + } + } + + /** Dialog for blocking a number. */ + public static class BlockDialogFragment extends CommonDialogsFragment { + + private boolean isSpamEnabled; + + public static DialogFragment newInstance( + String displayNumber, + boolean isSpamEnabled, + OnConfirmListener positiveListener, + @Nullable DialogInterface.OnDismissListener dismissListener) { + BlockDialogFragment fragment = new BlockDialogFragment(); + fragment.displayNumber = displayNumber; + fragment.positiveListener = positiveListener; + fragment.dismissListener = dismissListener; + fragment.isSpamEnabled = isSpamEnabled; + return fragment; + } + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + super.onCreateDialog(savedInstanceState); + // Return the newly created dialog + AlertDialog.Builder alertDialogBuilder = createDialogBuilder(getActivity(), this); + Dialog dialog = + alertDialogBuilder + .setTitle(getString(R.string.block_number_confirmation_title, displayNumber)) + .setMessage( + isSpamEnabled + ? getString( + R.string.block_number_alert_details, getBlockMessage(getContext())) + : getString(R.string.block_report_number_alert_details)) + .setPositiveButton( + R.string.block_number_ok, createGenericOnClickListener(this, positiveListener)) + .create(); + dialog.setCanceledOnTouchOutside(true); + return dialog; + } + } + + /** Dialog for unblocking a number. */ + public static class UnblockDialogFragment extends CommonDialogsFragment { + + /** Whether or not the number is spam. */ + private boolean isSpam; + + public static DialogFragment newInstance( + String displayNumber, + boolean isSpam, + OnConfirmListener positiveListener, + @Nullable DialogInterface.OnDismissListener dismissListener) { + UnblockDialogFragment fragment = new UnblockDialogFragment(); + fragment.displayNumber = displayNumber; + fragment.isSpam = isSpam; + fragment.positiveListener = positiveListener; + fragment.dismissListener = dismissListener; + return fragment; + } + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + super.onCreateDialog(savedInstanceState); + // Return the newly created dialog + AlertDialog.Builder alertDialogBuilder = createDialogBuilder(getActivity(), this); + if (isSpam) { + alertDialogBuilder + .setMessage(R.string.unblock_number_alert_details) + .setTitle(getString(R.string.unblock_report_number_alert_title, displayNumber)); + } else { + alertDialogBuilder.setMessage( + getString(R.string.unblock_report_number_alert_title, displayNumber)); + } + Dialog dialog = + alertDialogBuilder + .setPositiveButton( + R.string.unblock_number_ok, createGenericOnClickListener(this, positiveListener)) + .create(); + dialog.setCanceledOnTouchOutside(true); + return dialog; + } + } + + /** Dialog for reporting a number as not spam. */ + public static class ReportNotSpamDialogFragment extends CommonDialogsFragment { + + public static DialogFragment newInstance( + String displayNumber, + OnConfirmListener positiveListener, + @Nullable DialogInterface.OnDismissListener dismissListener) { + ReportNotSpamDialogFragment fragment = new ReportNotSpamDialogFragment(); + fragment.displayNumber = displayNumber; + fragment.positiveListener = positiveListener; + fragment.dismissListener = dismissListener; + return fragment; + } + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + super.onCreateDialog(savedInstanceState); + // Return the newly created dialog + AlertDialog.Builder alertDialogBuilder = createDialogBuilder(getActivity(), this); + Dialog dialog = + alertDialogBuilder + .setTitle(R.string.report_not_spam_alert_title) + .setMessage(getString(R.string.report_not_spam_alert_details, displayNumber)) + .setPositiveButton( + R.string.report_not_spam_alert_button, + createGenericOnClickListener(this, positiveListener)) + .create(); + dialog.setCanceledOnTouchOutside(true); + return dialog; + } + } +} diff --git a/java/com/android/dialer/blockreportspam/ShowBlockReportSpamDialogNotifier.java b/java/com/android/dialer/blockreportspam/ShowBlockReportSpamDialogNotifier.java new file mode 100644 index 000000000..fd6a807cc --- /dev/null +++ b/java/com/android/dialer/blockreportspam/ShowBlockReportSpamDialogNotifier.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.dialer.blockreportspam; + +import android.content.Context; +import android.content.Intent; +import android.support.v4.content.LocalBroadcastManager; +import com.android.dialer.common.LogUtil; + +/** + * Notifies that a dialog for blocking a number and/or marking it as spam/not spam should be shown. + */ +public final class ShowBlockReportSpamDialogNotifier { + + private ShowBlockReportSpamDialogNotifier() {} + + /** + * Notifies that a dialog for blocking a number and optionally report it as spam should be shown. + * + * @param context Context + * @param normalizedNumber The number to be blocked/marked as spam + * @param countryIso The ISO 3166-1 two letters country code for the number + * @param callType Call type defined in {@link android.provider.CallLog.Calls} + */ + public static void notifyShowDialogToBlockNumberAndOptionallyReportSpam( + Context context, String normalizedNumber, String countryIso, int callType) { + LogUtil.enterBlock( + "ShowBlockReportSpamDialogNotifier.notifyShowDialogToBlockNumberAndOptionallyReportSpam"); + + Intent intent = new Intent(); + intent.setAction( + ShowBlockReportSpamDialogReceiver + .ACTION_SHOW_DIALOG_TO_BLOCK_NUMBER_AND_OPTIONALLY_REPORT_SPAM); + + intent.putExtra(ShowBlockReportSpamDialogReceiver.EXTRA_NUMBER, normalizedNumber); + intent.putExtra(ShowBlockReportSpamDialogReceiver.EXTRA_COUNTRY_ISO, countryIso); + intent.putExtra(ShowBlockReportSpamDialogReceiver.EXTRA_CALL_TYPE, callType); + + LocalBroadcastManager.getInstance(context).sendBroadcast(intent); + } + + /** + * Notifies that a dialog for reporting a number as not spam should be shown. + * + * @param context Context + * @param normalizedNumber The number to be reported as not spam + * @param countryIso The ISO 3166-1 two letters country code for the number + * @param callType Call type defined in {@link android.provider.CallLog.Calls} + */ + public static void notifyShowDialogToReportNotSpam( + Context context, String normalizedNumber, String countryIso, int callType) { + LogUtil.enterBlock("ShowBlockReportSpamDialogNotifier.notifyShowDialogToReportNotSpam"); + + Intent intent = new Intent(); + intent.setAction(ShowBlockReportSpamDialogReceiver.ACTION_SHOW_DIALOG_TO_REPORT_NOT_SPAM); + intent.putExtra(ShowBlockReportSpamDialogReceiver.EXTRA_NUMBER, normalizedNumber); + intent.putExtra(ShowBlockReportSpamDialogReceiver.EXTRA_COUNTRY_ISO, countryIso); + intent.putExtra(ShowBlockReportSpamDialogReceiver.EXTRA_CALL_TYPE, callType); + + LocalBroadcastManager.getInstance(context).sendBroadcast(intent); + } +} diff --git a/java/com/android/dialer/blockreportspam/ShowBlockReportSpamDialogReceiver.java b/java/com/android/dialer/blockreportspam/ShowBlockReportSpamDialogReceiver.java new file mode 100644 index 000000000..9642468cb --- /dev/null +++ b/java/com/android/dialer/blockreportspam/ShowBlockReportSpamDialogReceiver.java @@ -0,0 +1,171 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.dialer.blockreportspam; + +import android.app.FragmentManager; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.widget.Toast; +import com.android.dialer.blockreportspam.BlockReportSpamDialogs.OnConfirmListener; +import com.android.dialer.blockreportspam.BlockReportSpamDialogs.OnSpamDialogClickListener; +import com.android.dialer.common.Assert; +import com.android.dialer.common.LogUtil; +import com.android.dialer.logging.ContactSource; +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; +import java.util.Locale; + +/** + * A {@link BroadcastReceiver} that shows an appropriate dialog upon receiving notifications from + * {@link ShowBlockReportSpamDialogNotifier}. + */ +public final class ShowBlockReportSpamDialogReceiver extends BroadcastReceiver { + + static final String ACTION_SHOW_DIALOG_TO_BLOCK_NUMBER_AND_OPTIONALLY_REPORT_SPAM = + "show_dialog_to_block_number_and_optionally_report_spam"; + static final String ACTION_SHOW_DIALOG_TO_REPORT_NOT_SPAM = "show_dialog_to_report_not_spam"; + static final String EXTRA_NUMBER = "number"; + static final String EXTRA_COUNTRY_ISO = "country_iso"; + static final String EXTRA_CALL_TYPE = "call_type"; + + /** {@link FragmentManager} needed to show a {@link android.app.DialogFragment}. */ + private final FragmentManager fragmentManager; + + /** Returns an {@link IntentFilter} containing all actions accepted by this broadcast receiver. */ + public static IntentFilter getIntentFilter() { + IntentFilter intentFilter = new IntentFilter(); + intentFilter.addAction(ACTION_SHOW_DIALOG_TO_BLOCK_NUMBER_AND_OPTIONALLY_REPORT_SPAM); + intentFilter.addAction(ACTION_SHOW_DIALOG_TO_REPORT_NOT_SPAM); + return intentFilter; + } + + public ShowBlockReportSpamDialogReceiver(FragmentManager fragmentManager) { + this.fragmentManager = fragmentManager; + } + + @Override + public void onReceive(Context context, Intent intent) { + LogUtil.enterBlock("ShowBlockReportSpamDialogReceiver.onReceive"); + + String action = intent.getAction(); + + switch (Assert.isNotNull(action)) { + case ACTION_SHOW_DIALOG_TO_BLOCK_NUMBER_AND_OPTIONALLY_REPORT_SPAM: + showDialogToBlockNumberAndOptionallyReportSpam(context, intent); + break; + case ACTION_SHOW_DIALOG_TO_REPORT_NOT_SPAM: + showDialogToReportNotSpam(context, intent); + break; + default: + throw new IllegalStateException("Unsupported action: " + action); + } + } + + private void showDialogToBlockNumberAndOptionallyReportSpam(Context context, Intent intent) { + LogUtil.enterBlock( + "ShowBlockReportSpamDialogReceiver.showDialogToBlockNumberAndOptionallyReportSpam"); + + Assert.checkArgument(intent.hasExtra(EXTRA_NUMBER)); + Assert.checkArgument(intent.hasExtra(EXTRA_COUNTRY_ISO)); + Assert.checkArgument(intent.hasExtra(EXTRA_CALL_TYPE)); + + String normalizedNumber = intent.getStringExtra(EXTRA_NUMBER); + String countryIso = intent.getStringExtra(EXTRA_COUNTRY_ISO); + int callType = intent.getIntExtra(EXTRA_CALL_TYPE, 0); + + Spam spam = SpamComponent.get(context).spam(); + + // Set up the positive listener for the dialog. + OnSpamDialogClickListener onSpamDialogClickListener = + reportSpam -> { + LogUtil.i( + "ShowBlockReportSpamDialogReceiver.showDialogToBlockNumberAndOptionallyReportSpam", + "confirmed"); + + if (reportSpam && spam.isSpamEnabled()) { + LogUtil.i( + "ShowBlockReportSpamDialogReceiver.showDialogToBlockNumberAndOptionallyReportSpam", + "report spam"); + Logger.get(context) + .logImpression( + DialerImpression.Type + .REPORT_CALL_AS_SPAM_VIA_CALL_LOG_BLOCK_REPORT_SPAM_SENT_VIA_BLOCK_NUMBER_DIALOG); + spam.reportSpamFromCallHistory( + normalizedNumber, + countryIso, + callType, + ReportingLocation.Type.UNKNOWN_REPORTING_LOCATION /* TODO(a bug): Fix. */, + ContactSource.Type.UNKNOWN_SOURCE_TYPE /* TODO(a bug): Fix. */); + } + + // TODO(a bug): Block the number. + Toast.makeText( + context, + String.format(Locale.ENGLISH, "TODO: " + "Block number %s.", normalizedNumber), + Toast.LENGTH_SHORT) + .show(); + }; + + // Create and show the dialog. + BlockReportSpamDialogs.BlockReportSpamDialogFragment.newInstance( + normalizedNumber, + spam.isDialogReportSpamCheckedByDefault(), + onSpamDialogClickListener, + /* dismissListener = */ null) + .show(fragmentManager, BlockReportSpamDialogs.BLOCK_REPORT_SPAM_DIALOG_TAG); + } + + private void showDialogToReportNotSpam(Context context, Intent intent) { + LogUtil.enterBlock("ShowBlockReportSpamDialogReceiver.showDialogToReportNotSpam"); + + Assert.checkArgument(intent.hasExtra(EXTRA_NUMBER)); + Assert.checkArgument(intent.hasExtra(EXTRA_COUNTRY_ISO)); + Assert.checkArgument(intent.hasExtra(EXTRA_CALL_TYPE)); + + String normalizedNumber = intent.getStringExtra(EXTRA_NUMBER); + String countryIso = intent.getStringExtra(EXTRA_COUNTRY_ISO); + int callType = intent.getIntExtra(EXTRA_CALL_TYPE, 0); + + // Set up the positive listener for the dialog. + OnConfirmListener onConfirmListener = + () -> { + LogUtil.i("ShowBlockReportSpamDialogReceiver.showDialogToReportNotSpam", "confirmed"); + + Spam spam = SpamComponent.get(context).spam(); + if (spam.isSpamEnabled()) { + Logger.get(context) + .logImpression(DialerImpression.Type.DIALOG_ACTION_CONFIRM_NUMBER_NOT_SPAM); + spam.reportNotSpamFromCallHistory( + normalizedNumber, + countryIso, + callType, + ReportingLocation.Type.UNKNOWN_REPORTING_LOCATION /* TODO(a bug): Fix. */, + ContactSource.Type.UNKNOWN_SOURCE_TYPE /* TODO(a bug): Fix. */); + } + }; + + // Create & show the dialog. + BlockReportSpamDialogs.ReportNotSpamDialogFragment.newInstance( + normalizedNumber, onConfirmListener, /* dismissListener = */ null) + .show(fragmentManager, BlockReportSpamDialogs.NOT_SPAM_DIALOG_TAG); + } +} diff --git a/java/com/android/dialer/blockreportspam/res/layout/block_report_spam_dialog.xml b/java/com/android/dialer/blockreportspam/res/layout/block_report_spam_dialog.xml new file mode 100644 index 000000000..82e8d80b3 --- /dev/null +++ b/java/com/android/dialer/blockreportspam/res/layout/block_report_spam_dialog.xml @@ -0,0 +1,36 @@ + + + + + + + diff --git a/java/com/android/dialer/blockreportspam/res/values/colors.xml b/java/com/android/dialer/blockreportspam/res/values/colors.xml new file mode 100644 index 000000000..5fa45eba3 --- /dev/null +++ b/java/com/android/dialer/blockreportspam/res/values/colors.xml @@ -0,0 +1,21 @@ + + + + + #de000000 + + diff --git a/java/com/android/dialer/blockreportspam/res/values/dimens.xml b/java/com/android/dialer/blockreportspam/res/values/dimens.xml new file mode 100644 index 000000000..cd7cfe2fd --- /dev/null +++ b/java/com/android/dialer/blockreportspam/res/values/dimens.xml @@ -0,0 +1,18 @@ + + + 16sp + diff --git a/java/com/android/dialer/blockreportspam/res/values/strings.xml b/java/com/android/dialer/blockreportspam/res/values/strings.xml new file mode 100644 index 000000000..e803a162f --- /dev/null +++ b/java/com/android/dialer/blockreportspam/res/values/strings.xml @@ -0,0 +1,63 @@ + + + + + + + Block%1$s? + + + + + You will no longer receive calls or texts from this number. + + + + BLOCK + + + UNBLOCK + + + Block %1$s? + + + You will no longer receive calls from this number. + + + %1$s This call will be reported as spam. + + + This number will be unblocked and reported as not spam. Future calls won\'t be identified as spam. + + + Unblock %1$s? + + + Report + + + Report a mistake? + + + Future calls from %1$s will no longer be identified as spam. + + + Report call as spam + + diff --git a/java/com/android/dialer/calllog/ui/menu/Modules.java b/java/com/android/dialer/calllog/ui/menu/Modules.java index a13f2e333..48de03e60 100644 --- a/java/com/android/dialer/calllog/ui/menu/Modules.java +++ b/java/com/android/dialer/calllog/ui/menu/Modules.java @@ -75,7 +75,9 @@ final class Modules { SharedModules.addModulesHandlingBlockedOrSpamNumber( context, modules, - normalizedNumber, + row.number().getNormalizedNumber(), + row.number().getCountryIso(), + row.callType(), row.numberAttributes().getIsBlocked(), row.numberAttributes().getIsSpam()); SharedModules.maybeAddModuleForCopyingNumber(context, modules, normalizedNumber); diff --git a/java/com/android/dialer/contactactions/SharedModules.java b/java/com/android/dialer/contactactions/SharedModules.java index 6d97fcb61..0689f98fc 100644 --- a/java/com/android/dialer/contactactions/SharedModules.java +++ b/java/com/android/dialer/contactactions/SharedModules.java @@ -24,6 +24,7 @@ import android.support.annotation.Nullable; import android.text.TextUtils; import android.widget.Toast; import com.android.dialer.DialerPhoneNumber; +import com.android.dialer.blockreportspam.ShowBlockReportSpamDialogNotifier; import com.android.dialer.clipboard.ClipboardUtils; import com.android.dialer.util.IntentUtil; import com.android.dialer.util.UriUtils; @@ -38,7 +39,7 @@ public class SharedModules { public static void maybeAddModuleForAddingToContacts( Context context, List modules, - DialerPhoneNumber number, + DialerPhoneNumber dialerPhoneNumber, String name, String lookupUri, boolean isBlocked, @@ -54,7 +55,7 @@ public class SharedModules { } // Skip showing the menu item if there is no number. - String normalizedNumber = number.getNormalizedNumber(); + String normalizedNumber = dialerPhoneNumber.getNormalizedNumber(); if (TextUtils.isEmpty(normalizedNumber)) { return; } @@ -111,17 +112,26 @@ public class SharedModules { } } + /** + * Add modules related to blocking/unblocking a number and/or reporting it as spam/not spam. + * + * @param normalizedNumber The number to be blocked / unblocked / marked as spam/not spam + * @param countryIso The ISO 3166-1 two letters country code for the number + * @param callType Call type defined in {@link android.provider.CallLog.Calls} + */ public static void addModulesHandlingBlockedOrSpamNumber( Context context, List modules, String normalizedNumber, + String countryIso, + int callType, boolean isBlocked, boolean isSpam) { // For a spam number, add two options: // (1) "Not spam" and "Block", or // (2) "Not spam" and "Unblock". if (isSpam) { - addModuleForMarkingNumberAsNonSpam(context, modules, normalizedNumber); + addModuleForMarkingNumberAsNonSpam(context, modules, normalizedNumber, countryIso, callType); addModuleForBlockingOrUnblockingNumber(context, modules, normalizedNumber, isBlocked); return; } @@ -133,11 +143,23 @@ public class SharedModules { } // For a number that is neither a spam number nor blocked, add "Block/Report spam" option. - addModuleForBlockingNumberAndOptionallyReportingSpam(context, modules, normalizedNumber); + addModuleForBlockingNumberAndOptionallyReportingSpam( + context, modules, normalizedNumber, countryIso, callType); } + /** + * Add "Not spam" module. + * + * @param normalizedNumber The number to be marked as not spam + * @param countryIso The ISO 3166-1 two letters country code for the number + * @param callType Call type defined in {@link android.provider.CallLog.Calls} + */ private static void addModuleForMarkingNumberAsNonSpam( - Context context, List modules, String normalizedNumber) { + Context context, + List modules, + String normalizedNumber, + String countryIso, + int callType) { modules.add( new ContactActionModule() { @Override @@ -152,12 +174,8 @@ public class SharedModules { @Override public boolean onClick() { - // TODO(a bug): implement this method. - Toast.makeText( - context, - String.format(Locale.ENGLISH, "TODO: Report %s as non-spam", normalizedNumber), - Toast.LENGTH_SHORT) - .show(); + ShowBlockReportSpamDialogNotifier.notifyShowDialogToReportNotSpam( + context, normalizedNumber, countryIso, callType); return true; // Close the bottom sheet. } }); @@ -198,8 +216,19 @@ public class SharedModules { }); } + /** + * Add "Block/Report spam" module + * + * @param normalizedNumber The number to be blocked / unblocked / marked as spam/not spam + * @param countryIso The ISO 3166-1 two letters country code for the number + * @param callType Call type defined in {@link android.provider.CallLog.Calls} + */ private static void addModuleForBlockingNumberAndOptionallyReportingSpam( - Context context, List modules, String normalizedNumber) { + Context context, + List modules, + String normalizedNumber, + String countryIso, + int callType) { modules.add( new ContactActionModule() { @Override @@ -214,15 +243,8 @@ public class SharedModules { @Override public boolean onClick() { - // TODO(a bug): implement this method. - Toast.makeText( - context, - String.format( - Locale.ENGLISH, - "TODO: Block and optionally report as spam %s.", - normalizedNumber), - Toast.LENGTH_SHORT) - .show(); + ShowBlockReportSpamDialogNotifier.notifyShowDialogToBlockNumberAndOptionallyReportSpam( + context, normalizedNumber, countryIso, callType); return true; // Close the bottom sheet. } }); diff --git a/java/com/android/dialer/main/MainActivityPeer.java b/java/com/android/dialer/main/MainActivityPeer.java index 9c5627be8..31af9adbd 100644 --- a/java/com/android/dialer/main/MainActivityPeer.java +++ b/java/com/android/dialer/main/MainActivityPeer.java @@ -28,6 +28,8 @@ public interface MainActivityPeer { void onUserLeaveHint(); + void onActivityPause(); + void onActivityStop(); void onActivityDestroyed(); diff --git a/java/com/android/dialer/main/impl/MainActivity.java b/java/com/android/dialer/main/impl/MainActivity.java index 1646becf4..fbcbeff38 100644 --- a/java/com/android/dialer/main/impl/MainActivity.java +++ b/java/com/android/dialer/main/impl/MainActivity.java @@ -98,6 +98,12 @@ public class MainActivity extends TransactionSafeActivity activePeer.onUserLeaveHint(); } + @Override + protected void onPause() { + super.onPause(); + activePeer.onActivityPause(); + } + @Override protected void onStop() { super.onStop(); diff --git a/java/com/android/dialer/main/impl/NewMainActivityPeer.java b/java/com/android/dialer/main/impl/NewMainActivityPeer.java index 6f5c18623..081559a2b 100644 --- a/java/com/android/dialer/main/impl/NewMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/NewMainActivityPeer.java @@ -22,6 +22,8 @@ import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; +import android.support.v4.content.LocalBroadcastManager; +import com.android.dialer.blockreportspam.ShowBlockReportSpamDialogReceiver; import com.android.dialer.calllog.CallLogComponent; import com.android.dialer.calllog.ui.NewCallLogFragment; import com.android.dialer.common.concurrent.DefaultFutureCallback; @@ -37,9 +39,12 @@ import com.google.common.util.concurrent.MoreExecutors; public class NewMainActivityPeer implements MainActivityPeer { private final MainActivity mainActivity; + private final ShowBlockReportSpamDialogReceiver showBlockReportSpamDialogReceiver; public NewMainActivityPeer(MainActivity mainActivity) { this.mainActivity = mainActivity; + this.showBlockReportSpamDialogReceiver = + new ShowBlockReportSpamDialogReceiver(mainActivity.getFragmentManager()); } @Override @@ -54,11 +59,21 @@ public class NewMainActivityPeer implements MainActivityPeer { } @Override - public void onActivityResume() {} + public void onActivityResume() { + LocalBroadcastManager.getInstance(mainActivity) + .registerReceiver( + showBlockReportSpamDialogReceiver, ShowBlockReportSpamDialogReceiver.getIntentFilter()); + } @Override public void onUserLeaveHint() {} + @Override + public void onActivityPause() { + LocalBroadcastManager.getInstance(mainActivity) + .unregisterReceiver(showBlockReportSpamDialogReceiver); + } + @Override public void onActivityStop() {} diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java index cdbab5cc1..9ceea28bf 100644 --- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java @@ -397,6 +397,9 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen searchController.onUserLeaveHint(); } + @Override + public void onActivityPause() {} + @Override public void onActivityStop() { lastTabController.onActivityStop(); diff --git a/java/com/android/dialer/voicemail/listui/menu/Modules.java b/java/com/android/dialer/voicemail/listui/menu/Modules.java index 7254ad651..84921bd65 100644 --- a/java/com/android/dialer/voicemail/listui/menu/Modules.java +++ b/java/com/android/dialer/voicemail/listui/menu/Modules.java @@ -56,7 +56,9 @@ final class Modules { SharedModules.addModulesHandlingBlockedOrSpamNumber( context, modules, - normalizedNumber, + voicemailEntry.number().getNormalizedNumber(), + voicemailEntry.number().getCountryIso(), + voicemailEntry.callType(), voicemailEntry.numberAttributes().getIsBlocked(), voicemailEntry.numberAttributes().getIsSpam()); diff --git a/java/com/android/incallui/spam/SpamNotificationActivity.java b/java/com/android/incallui/spam/SpamNotificationActivity.java index f6da2a3b0..6ba7c30f8 100644 --- a/java/com/android/incallui/spam/SpamNotificationActivity.java +++ b/java/com/android/incallui/spam/SpamNotificationActivity.java @@ -28,10 +28,10 @@ import android.provider.ContactsContract; import android.support.v4.app.FragmentActivity; import android.telephony.PhoneNumberUtils; import com.android.contacts.common.compat.PhoneNumberUtilsCompat; -import com.android.dialer.blocking.BlockReportSpamDialogs; import com.android.dialer.blocking.BlockedNumbersMigrator; import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler; import com.android.dialer.blocking.FilteredNumberCompat; +import com.android.dialer.blockreportspam.BlockReportSpamDialogs; import com.android.dialer.common.LogUtil; import com.android.dialer.location.GeoUtil; import com.android.dialer.logging.ContactLookupResult; diff --git a/packages.mk b/packages.mk index 304db49fe..abe9eb51e 100644 --- a/packages.mk +++ b/packages.mk @@ -13,6 +13,7 @@ LOCAL_AAPT_FLAGS := \ com.android.dialer.binary.aosp.testing \ com.android.dialer.binary.google \ com.android.dialer.blocking \ + com.android.dialer.blockreportspam \ com.android.dialer.callcomposer \ com.android.dialer.callcomposer.camera \ com.android.dialer.callcomposer.camera.camerafocus \ -- cgit v1.2.3