Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0b09ac2d authored by linyuh's avatar linyuh Committed by android-build-merger
Browse files

Merge "Implement logic of bottom sheet options related to spam numbers." am: 95eb620c

am: 1c7ab378

Change-Id: I316c409b0c66220fa649e846c679d8b9574a30cd
parents b5340da0 1c7ab378
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -20,8 +20,8 @@ import android.app.FragmentManager;
import android.content.Context;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView;
import com.android.dialer.blocking.BlockReportSpamDialogs;
import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler;
import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler;
import com.android.dialer.blockreportspam.BlockReportSpamDialogs;
import com.android.dialer.common.LogUtil;
import com.android.dialer.common.LogUtil;
import com.android.dialer.logging.ContactSource;
import com.android.dialer.logging.ContactSource;
import com.android.dialer.logging.DialerImpression;
import com.android.dialer.logging.DialerImpression;
+0 −3
Original line number Original line Diff line number Diff line
@@ -15,9 +15,6 @@
-->
-->
<resources>
<resources>


  <!-- 87% black -->
  <color name="block_report_spam_primary_text_color">#de000000</color>

  <!-- Note, this is also used by InCallUi. -->
  <!-- Note, this is also used by InCallUi. -->
  <color name="blocked_contact_background">#A52714</color>
  <color name="blocked_contact_background">#A52714</color>


+33 −55
Original line number Original line Diff line number Diff line
@@ -24,12 +24,14 @@
  <!-- Positive confirmation button for the dialog which opens when the user needs to migrate to the framework blocking implementation [CHAR LIMIT=NONE]-->
  <!-- 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>
  <string name="migrate_blocked_numbers_dialog_allow_button">Allow</string>


  <!-- Do not translate -->
  <string name="migrate_blocked_numbers_dialog_cancel_button" translatable="false">
  <string name="migrate_blocked_numbers_dialog_cancel_button">@android:string/cancel</string>
    @android:string/cancel
  </string>


  <!-- Confirmation dialog title for blocking a number. [CHAR LIMIT=NONE] -->
  <!-- Confirmation dialog title for blocking a number. [CHAR LIMIT=NONE] -->
    <string name="block_number_confirmation_title">Block
  <string name="block_number_confirmation_title">
        <xliff:g example="(555) 555-5555" id="number">%1$s</xliff:g>?</string>
    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.
  <!-- Confirmation dialog message for blocking a number with visual voicemail active.
       [CHAR LIMIT=NONE] -->
       [CHAR LIMIT=NONE] -->
@@ -53,25 +55,28 @@
  <string name="block_number_ok">BLOCK</string>
  <string name="block_number_ok">BLOCK</string>


  <!-- Confirmation dialog for unblocking a number. [CHAR LIMIT=NONE] -->
  <!-- Confirmation dialog for unblocking a number. [CHAR LIMIT=NONE] -->
    <string name="unblock_number_confirmation_title">Unblock
  <string name="unblock_number_confirmation_title">
        <xliff:g example="(555) 555-5555" id="number">%1$s</xliff:g>?</string>
    Unblock<xliff:g example="(555) 555-5555" id="number">%1$s</xliff:g>?
  </string>


  <!-- Unblock number alert dialog button [CHAR LIMIT=32] -->
  <!-- Unblock number alert dialog button [CHAR LIMIT=32] -->
  <string name="unblock_number_ok">UNBLOCK</string>
  <string name="unblock_number_ok">UNBLOCK</string>


  <!-- Error message shown when user tries to add invalid number to the block list.
  <!-- Error message shown when user tries to add invalid number to the block list.
      [CHAR LIMIT=64] -->
      [CHAR LIMIT=64] -->
    <string name="invalidNumber"><xliff:g example="(555) 555-5555" id="number">%1$s</xliff:g>
  <string name="invalidNumber">
        is invalid.</string>
    <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] -->
  <!-- Text for snackbar to undo blocking a number. [CHAR LIMIT=64] -->
  <string name="snackbar_number_blocked">
  <string name="snackbar_number_blocked">
        <xliff:g example="(555) 555-5555" id="number">%1$s</xliff:g> blocked</string>
    <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] -->
  <!-- Text for snackbar to undo unblocking a number. [CHAR LIMIT=64] -->
  <string name="snackbar_number_unblocked">
  <string name="snackbar_number_unblocked">
        <xliff:g example="(555) 555-5555" id="number">%1$s</xliff:g>
    <xliff:g example="(555) 555-5555" id="number">%1$s</xliff:g>unblocked
        unblocked</string>
  </string>


  <!-- Text for undo button in snackbar for blocking/unblocking number. [CHAR LIMIT=10] -->
  <!-- Text for undo button in snackbar for blocking/unblocking number. [CHAR LIMIT=10] -->
  <string name="block_number_undo">UNDO</string>
  <string name="block_number_undo">UNDO</string>
@@ -92,31 +97,4 @@
    Disabled because an emergency call was made.
    Disabled because an emergency call was made.
  </string>
  </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>

</resources>
</resources>
+18 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ 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
  -->

<manifest package="com.android.dialer.blockreportspam"/>
 No newline at end of file
+22 −39
Original line number Original line Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


package com.android.dialer.blocking;
package com.android.dialer.blockreportspam;


import android.app.Activity;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog;
@@ -26,11 +26,13 @@ import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
import android.widget.TextView;
import com.android.dialer.blocking.FilteredNumberCompat;


/** Helper class for creating block/report dialog fragments. */
/**
public class BlockReportSpamDialogs {
 * 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_REPORT_SPAM_DIALOG_TAG = "BlockReportSpamDialog";
  public static final String BLOCK_DIALOG_TAG = "BlockDialog";
  public static final String BLOCK_DIALOG_TAG = "BlockDialog";
@@ -42,14 +44,7 @@ public class BlockReportSpamDialogs {
      Activity activity, final DialogFragment fragment) {
      Activity activity, final DialogFragment fragment) {
    return new AlertDialog.Builder(activity, R.style.AlertDialogTheme)
    return new AlertDialog.Builder(activity, R.style.AlertDialogTheme)
        .setCancelable(true)
        .setCancelable(true)
        .setNegativeButton(
        .setNegativeButton(android.R.string.cancel, (dialog, which) -> fragment.dismiss());
            android.R.string.cancel,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                fragment.dismiss();
              }
            });
  }
  }


  /**
  /**
@@ -58,12 +53,9 @@ public class BlockReportSpamDialogs {
   */
   */
  private static DialogInterface.OnClickListener createGenericOnClickListener(
  private static DialogInterface.OnClickListener createGenericOnClickListener(
      final DialogFragment fragment, final OnConfirmListener listener) {
      final DialogFragment fragment, final OnConfirmListener listener) {
    return new DialogInterface.OnClickListener() {
    return (dialog, which) -> {
      @Override
      public void onClick(DialogInterface dialog, int which) {
      fragment.dismiss();
      fragment.dismiss();
      listener.onClick();
      listener.onClick();
      }
    };
    };
  }
  }


@@ -98,8 +90,8 @@ public class BlockReportSpamDialogs {
    void onClick();
    void onClick();
  }
  }


  /** Contains the common attributes between all block/unblock/report dialog fragments. */
  /** Contains the common attributes between all block/unblock/report spam dialog fragments. */
  private static class CommonDialogsFragment extends DialogFragment {
  private abstract static class CommonDialogsFragment extends DialogFragment {


    /** The number to display in the dialog title. */
    /** The number to display in the dialog title. */
    protected String displayNumber;
    protected String displayNumber;
@@ -133,7 +125,7 @@ public class BlockReportSpamDialogs {
  public static class BlockReportSpamDialogFragment extends CommonDialogsFragment {
  public static class BlockReportSpamDialogFragment extends CommonDialogsFragment {


    /** Called when dialog positive button is pressed. */
    /** Called when dialog positive button is pressed. */
    private OnSpamDialogClickListener positiveListener;
    private OnSpamDialogClickListener onSpamDialogClickListener;


    /** Whether the mark as spam checkbox is checked before displaying the dialog. */
    /** Whether the mark as spam checkbox is checked before displaying the dialog. */
    private boolean spamChecked;
    private boolean spamChecked;
@@ -141,12 +133,12 @@ public class BlockReportSpamDialogs {
    public static DialogFragment newInstance(
    public static DialogFragment newInstance(
        String displayNumber,
        String displayNumber,
        boolean spamChecked,
        boolean spamChecked,
        OnSpamDialogClickListener positiveListener,
        OnSpamDialogClickListener onSpamDialogClickListener,
        @Nullable DialogInterface.OnDismissListener dismissListener) {
        @Nullable DialogInterface.OnDismissListener dismissListener) {
      BlockReportSpamDialogFragment fragment = new BlockReportSpamDialogFragment();
      BlockReportSpamDialogFragment fragment = new BlockReportSpamDialogFragment();
      fragment.spamChecked = spamChecked;
      fragment.spamChecked = spamChecked;
      fragment.displayNumber = displayNumber;
      fragment.displayNumber = displayNumber;
      fragment.positiveListener = positiveListener;
      fragment.onSpamDialogClickListener = onSpamDialogClickListener;
      fragment.dismissListener = dismissListener;
      fragment.dismissListener = dismissListener;
      return fragment;
      return fragment;
    }
    }
@@ -159,34 +151,25 @@ public class BlockReportSpamDialogs {
          (CheckBox) dialogView.findViewById(R.id.report_number_as_spam_action);
          (CheckBox) dialogView.findViewById(R.id.report_number_as_spam_action);
      // Listen for changes on the checkbox and update if orientation changes
      // Listen for changes on the checkbox and update if orientation changes
      isSpamCheckbox.setChecked(spamChecked);
      isSpamCheckbox.setChecked(spamChecked);
      isSpamCheckbox.setOnCheckedChangeListener(
      isSpamCheckbox.setOnCheckedChangeListener((buttonView, isChecked) -> spamChecked = isChecked);
          new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
              spamChecked = isChecked;
            }
          });


      TextView details = (TextView) dialogView.findViewById(R.id.block_details);
      TextView details = (TextView) dialogView.findViewById(R.id.block_details);
      details.setText(getBlockMessage(getContext()));
      details.setText(getBlockMessage(getContext()));


      AlertDialog.Builder alertDialogBuilder = createDialogBuilder(getActivity(), this);
      AlertDialog.Builder alertDialogBuilder = createDialogBuilder(getActivity(), this);
      Dialog dialog =
      Dialog blockReportSpamDialog =
          alertDialogBuilder
          alertDialogBuilder
              .setView(dialogView)
              .setView(dialogView)
              .setTitle(getString(R.string.block_report_number_alert_title, displayNumber))
              .setTitle(getString(R.string.block_report_number_alert_title, displayNumber))
              .setPositiveButton(
              .setPositiveButton(
                  R.string.block_number_ok,
                  R.string.block_number_ok,
                  new DialogInterface.OnClickListener() {
                  (dialog, which) -> {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                    dismiss();
                    dismiss();
                      positiveListener.onClick(isSpamCheckbox.isChecked());
                    onSpamDialogClickListener.onClick(isSpamCheckbox.isChecked());
                    }
                  })
                  })
              .create();
              .create();
      dialog.setCanceledOnTouchOutside(true);
      blockReportSpamDialog.setCanceledOnTouchOutside(true);
      return dialog;
      return blockReportSpamDialog;
    }
    }
  }
  }


Loading