summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/blocking
diff options
context:
space:
mode:
authorlinyuh <linyuh@google.com>2018-02-26 10:56:21 -0800
committerCopybara-Service <copybara-piper@google.com>2018-02-26 10:57:18 -0800
commit719341fb552ddb1b1e955e0f8ace79ffc0491b67 (patch)
treed570f076bea55bc2446a3edd3c50d1b6bc023d8a /java/com/android/dialer/blocking
parent19a126b0c12c0ea93ffe7f60f3250e81aa305785 (diff)
Implement logic of bottom sheet options related to spam numbers.
Bug: 70989605 Test: ShowBlockReportSpamDialogNotifierEndToEndTest + Manual PiperOrigin-RevId: 187047450 Change-Id: I23c3929135bcfe5c14fe317ef65f628dc126027f
Diffstat (limited to 'java/com/android/dialer/blocking')
-rw-r--r--java/com/android/dialer/blocking/BlockReportSpamDialogs.java305
-rw-r--r--java/com/android/dialer/blocking/res/layout/block_report_spam_dialog.xml36
-rw-r--r--java/com/android/dialer/blocking/res/values/colors.xml3
-rw-r--r--java/com/android/dialer/blocking/res/values/dimens.xml18
-rw-r--r--java/com/android/dialer/blocking/res/values/strings.xml88
5 files changed, 33 insertions, 417 deletions
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 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 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.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:padding="25dp"
- android:orientation="vertical">
- <TextView
- android:id="@+id/block_details"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginBottom="10dp"
- android:text="@string/block_report_number_alert_details"
- android:textColor="@color/block_report_spam_primary_text_color"
- android:textSize="@dimen/blocked_report_spam_primary_text_size"/>
-
- <CheckBox
- android:id="@+id/report_number_as_spam_action"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/checkbox_report_as_spam_action"
- android:textSize="@dimen/blocked_report_spam_primary_text_size"/>
-</LinearLayout>
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 @@
-->
<resources>
- <!-- 87% black -->
- <color name="block_report_spam_primary_text_color">#de000000</color>
-
<!-- Note, this is also used by InCallUi. -->
<color name="blocked_contact_background">#A52714</color>
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 @@
-<!--
- ~ Copyright (C) 2012 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
--->
-<resources>
- <dimen name="blocked_report_spam_primary_text_size">16sp</dimen>
-</resources>
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 @@
<!-- Positive confirmation button for the dialog which opens when the user needs to migrate to the framework blocking implementation [CHAR LIMIT=NONE]-->
<string name="migrate_blocked_numbers_dialog_allow_button">Allow</string>
- <!-- Do not translate -->
- <string name="migrate_blocked_numbers_dialog_cancel_button">@android:string/cancel</string>
+ <string name="migrate_blocked_numbers_dialog_cancel_button" translatable="false">
+ @android:string/cancel
+ </string>
<!-- Confirmation dialog title for blocking a number. [CHAR LIMIT=NONE] -->
- <string name="block_number_confirmation_title">Block
- <xliff:g example="(555) 555-5555" id="number">%1$s</xliff:g>?</string>
+ <string name="block_number_confirmation_title">
+ Block<xliff:g example="(555) 555-5555" id="number">%1$s</xliff:g>?
+ </string>
<!-- Confirmation dialog message for blocking a number with visual voicemail active.
[CHAR LIMIT=NONE] -->
- <string name="block_number_confirmation_message_vvm">
- Calls from this number will be blocked and voicemails will be automatically deleted.
- </string>
+ <string name="block_number_confirmation_message_vvm">
+ Calls from this number will be blocked and voicemails will be automatically deleted.
+ </string>
<!-- Confirmation dialog message for blocking a number with no visual voicemail.
[CHAR LIMIT=NONE] -->
- <string name="block_number_confirmation_message_no_vvm">
- Calls from this number will be blocked, but the caller may still be able to leave you voicemails.
- </string>
+ <string name="block_number_confirmation_message_no_vvm">
+ Calls from this number will be blocked, but the caller may still be able to leave you voicemails.
+ </string>
<!-- Confirmation dialog message for blocking a number with new filtering enabled.
[CHAR LIMIT=NONE] -->
- <string name="block_number_confirmation_message_new_filtering">
- You will no longer receive calls or texts from this number.
- </string>
+ <string name="block_number_confirmation_message_new_filtering">
+ You will no longer receive calls or texts from this number.
+ </string>
<!-- Block number alert dialog button [CHAR LIMIT=32] -->
<string name="block_number_ok">BLOCK</string>
<!-- Confirmation dialog for unblocking a number. [CHAR LIMIT=NONE] -->
- <string name="unblock_number_confirmation_title">Unblock
- <xliff:g example="(555) 555-5555" id="number">%1$s</xliff:g>?</string>
+ <string name="unblock_number_confirmation_title">
+ Unblock<xliff:g example="(555) 555-5555" id="number">%1$s</xliff:g>?
+ </string>
<!-- Unblock number alert dialog button [CHAR LIMIT=32] -->
<string name="unblock_number_ok">UNBLOCK</string>
<!-- Error message shown when user tries to add invalid number to the block list.
[CHAR LIMIT=64] -->
- <string name="invalidNumber"><xliff:g example="(555) 555-5555" id="number">%1$s</xliff:g>
- is invalid.</string>
+ <string name="invalidNumber">
+ <xliff:g example="(555) 555-5555" id="number">%1$s</xliff:g>is invalid.
+ </string>
<!-- Text for snackbar to undo blocking a number. [CHAR LIMIT=64] -->
- <string name="snackbar_number_blocked">
- <xliff:g example="(555) 555-5555" id="number">%1$s</xliff:g> blocked</string>
+ <string name="snackbar_number_blocked">
+ <xliff:g example="(555) 555-5555" id="number">%1$s</xliff:g> blocked
+ </string>
<!-- Text for snackbar to undo unblocking a number. [CHAR LIMIT=64] -->
- <string name="snackbar_number_unblocked">
- <xliff:g example="(555) 555-5555" id="number">%1$s</xliff:g>
- unblocked</string>
+ <string name="snackbar_number_unblocked">
+ <xliff:g example="(555) 555-5555" id="number">%1$s</xliff:g>unblocked
+ </string>
<!-- Text for undo button in snackbar for blocking/unblocking number. [CHAR LIMIT=10] -->
<string name="block_number_undo">UNDO</string>
@@ -81,42 +86,15 @@
<!-- Title of notification telling the user that call blocking has been temporarily disabled.
[CHAR LIMIT=56] -->
- <string name="call_blocking_disabled_notification_title">
- Call blocking disabled for 48 hours
- </string>
+ <string name="call_blocking_disabled_notification_title">
+ Call blocking disabled for 48 hours
+ </string>
<!-- Text for notification which provides the reason that call blocking has been temporarily
disabled. Namely, we disable call blocking after an emergency call in case of return
phone calls made by emergency services. [CHAR LIMIT=64] -->
- <string name="call_blocking_disabled_notification_text">
- Disabled because an emergency call was made.
- </string>
-
- <!-- Title of alert dialog after clicking on Block/report as spam. [CHAR LIMIT=100] -->
- <string name="block_report_number_alert_title">Block <xliff:g id="number">%1$s</xliff:g>?</string>
-
- <!-- Text in alert dialog after clicking on Block/report as spam. [CHAR LIMIT=100] -->
- <string name="block_report_number_alert_details">You will no longer receive calls from this number.</string>
-
- <!-- Text in alert dialog after clicking on Block. [CHAR LIMIT=100] -->
- <string name="block_number_alert_details"><xliff:g id="text">%1$s</xliff:g> This call will be reported as spam.</string>
-
- <!-- Text in alert dialog after clicking on Unblock. [CHAR LIMIT=100] -->
- <string name="unblock_number_alert_details">This number will be unblocked and reported as not spam. Future calls won\'t be identified as spam.</string>
-
- <!-- Title of alert dialog after clicking on Unblock. [CHAR LIMIT=100] -->
- <string name="unblock_report_number_alert_title">Unblock <xliff:g id="number">%1$s</xliff:g>?</string>
-
- <!-- Report not spam number alert dialog button [CHAR LIMIT=32] -->
- <string name="report_not_spam_alert_button">Report</string>
-
- <!-- Title of alert dialog after clicking on Report as not spam. [CHAR LIMIT=100] -->
- <string name="report_not_spam_alert_title">Report a mistake?</string>
-
- <!-- Text in alert dialog after clicking on Report as not spam. [CHAR LIMIT=100] -->
- <string name="report_not_spam_alert_details">Future calls from <xliff:g id="number">%1$s</xliff:g> will no longer be identified as spam.</string>
-
- <!-- Label for checkbox in the Alert dialog to allow the user to report the number as spam as well. [CHAR LIMIT=30] -->
- <string name="checkbox_report_as_spam_action">Report call as spam</string>
+ <string name="call_blocking_disabled_notification_text">
+ Disabled because an emergency call was made.
+ </string>
</resources>