summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/blocking/BlockReportSpamDialogs.java
diff options
context:
space:
mode:
authorEric Erfanian <erfanian@google.com>2017-02-22 16:32:36 -0800
committerEric Erfanian <erfanian@google.com>2017-03-01 09:56:52 -0800
commitccca31529c07970e89419fb85a9e8153a5396838 (patch)
treea7034c0a01672b97728c13282a2672771cd28baa /java/com/android/dialer/blocking/BlockReportSpamDialogs.java
parente7ae4624ba6f25cb8e648db74e0d64c0113a16ba (diff)
Update dialer sources.
Test: Built package and system image. This change clobbers the old source, and is an export from an internal Google repository. The internal repository was forked form Android in March, and this change includes modifications since then, to near the v8 release. Since the fork, we've moved code from monolithic to independent modules. In addition, we've switched to Blaze/Bazel as the build sysetm. This export, however, still uses make. New dependencies have been added: - Dagger - Auto-Value - Glide - Libshortcutbadger Going forward, development will still be in Google3, and the Gerrit release will become an automated export, with the next drop happening in ~ two weeks. Android.mk includes local modifications from ToT. Abridged changelog: Bug fixes ● Not able to mute, add a call when using Phone app in multiwindow mode ● Double tap on keypad triggering multiple key and tones ● Reported spam numbers not showing as spam in the call log ● Crash when user tries to block number while Phone app is not set as default ● Crash when user picks a number from search auto-complete list Visual Voicemail (VVM) improvements ● Share Voicemail audio via standard exporting mechanisms that support file attachment (email, MMS, etc.) ● Make phone number, email and web sites in VVM transcript clickable ● Set PIN before declining VVM Terms of Service {Carrier} ● Set client type for outbound visual voicemail SMS {Carrier} New incoming call and incall UI on older devices (Android M) ● Updated Phone app icon ● New incall UI (large buttons, button labels) ● New and animated Answer/Reject gestures Accessibility ● Add custom answer/decline call buttons on answer screen for touch exploration accessibility services ● Increase size of touch target ● Add verbal feedback when a Voicemail fails to load ● Fix pressing of Phone buttons while in a phone call using Switch Access ● Fix selecting and opening contacts in talkback mode ● Split focus for ‘Learn More’ link in caller id & spam to help distinguish similar text Other ● Backup & Restore for App Preferences ● Prompt user to enable Wi-Fi calling if the call ends due to out of service and Wi-Fi is connected ● Rename “Dialpad” to “Keypad” ● Show "Private number" for restricted calls ● Delete unused items (vcard, add contact, call history) from Phone menu Change-Id: I2a7e53532a24c21bf308bf0a6d178d7ddbca4958
Diffstat (limited to 'java/com/android/dialer/blocking/BlockReportSpamDialogs.java')
-rw-r--r--java/com/android/dialer/blocking/BlockReportSpamDialogs.java305
1 files changed, 305 insertions, 0 deletions
diff --git a/java/com/android/dialer/blocking/BlockReportSpamDialogs.java b/java/com/android/dialer/blocking/BlockReportSpamDialogs.java
new file mode 100644
index 000000000..b5f81fcc5
--- /dev/null
+++ b/java/com/android/dialer/blocking/BlockReportSpamDialogs.java
@@ -0,0 +1,305 @@
+/*
+ * 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 mDisplayNumber;
+
+ /** Called when dialog positive button is pressed. */
+ protected OnConfirmListener mPositiveListener;
+
+ /** Called when dialog is dismissed. */
+ @Nullable protected DialogInterface.OnDismissListener mDismissListener;
+
+ @Override
+ public void onDismiss(DialogInterface dialog) {
+ if (mDismissListener != null) {
+ mDismissListener.onDismiss(dialog);
+ }
+ super.onDismiss(dialog);
+ }
+
+ @Override
+ public void onPause() {
+ // The dialog is dismissed onPause, i.e. rotation.
+ dismiss();
+ mDismissListener = null;
+ mPositiveListener = null;
+ mDisplayNumber = 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 mPositiveListener;
+
+ /** Whether the mark as spam checkbox is checked before displaying the dialog. */
+ private boolean mSpamChecked;
+
+ public static DialogFragment newInstance(
+ String displayNumber,
+ boolean spamChecked,
+ OnSpamDialogClickListener positiveListener,
+ @Nullable DialogInterface.OnDismissListener dismissListener) {
+ BlockReportSpamDialogFragment fragment = new BlockReportSpamDialogFragment();
+ fragment.mSpamChecked = spamChecked;
+ fragment.mDisplayNumber = displayNumber;
+ fragment.mPositiveListener = positiveListener;
+ fragment.mDismissListener = 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(mSpamChecked);
+ isSpamCheckbox.setOnCheckedChangeListener(
+ new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ mSpamChecked = 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, mDisplayNumber))
+ .setPositiveButton(
+ R.string.block_number_ok,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dismiss();
+ mPositiveListener.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.mDisplayNumber = displayNumber;
+ fragment.mPositiveListener = positiveListener;
+ fragment.mDismissListener = 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, mDisplayNumber))
+ .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, mPositiveListener))
+ .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 mIsSpam;
+
+ public static DialogFragment newInstance(
+ String displayNumber,
+ boolean isSpam,
+ OnConfirmListener positiveListener,
+ @Nullable DialogInterface.OnDismissListener dismissListener) {
+ UnblockDialogFragment fragment = new UnblockDialogFragment();
+ fragment.mDisplayNumber = displayNumber;
+ fragment.mIsSpam = isSpam;
+ fragment.mPositiveListener = positiveListener;
+ fragment.mDismissListener = dismissListener;
+ return fragment;
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ super.onCreateDialog(savedInstanceState);
+ // Return the newly created dialog
+ AlertDialog.Builder alertDialogBuilder = createDialogBuilder(getActivity(), this);
+ if (mIsSpam) {
+ alertDialogBuilder
+ .setMessage(R.string.unblock_number_alert_details)
+ .setTitle(getString(R.string.unblock_report_number_alert_title, mDisplayNumber));
+ } else {
+ alertDialogBuilder.setMessage(
+ getString(R.string.unblock_report_number_alert_title, mDisplayNumber));
+ }
+ Dialog dialog =
+ alertDialogBuilder
+ .setPositiveButton(
+ R.string.unblock_number_ok, createGenericOnClickListener(this, mPositiveListener))
+ .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.mDisplayNumber = displayNumber;
+ fragment.mPositiveListener = positiveListener;
+ fragment.mDismissListener = 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, mDisplayNumber))
+ .setPositiveButton(
+ R.string.report_not_spam_alert_button,
+ createGenericOnClickListener(this, mPositiveListener))
+ .create();
+ dialog.setCanceledOnTouchOutside(true);
+ return dialog;
+ }
+ }
+}