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

Commit 95eb620c authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Implement logic of bottom sheet options related to spam numbers."

parents 19a126b0 719341fb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;
+0 −3
Original line number Diff line number Diff line
@@ -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>

+33 −55
Original line number 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]-->
  <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] -->
@@ -53,25 +55,28 @@
  <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>
    <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>
    <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>
@@ -92,31 +97,4 @@
    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>

</resources>
+18 −0
Original line number 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 Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

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

import android.app.Activity;
import android.app.AlertDialog;
@@ -26,11 +26,13 @@ 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;
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_DIALOG_TAG = "BlockDialog";
@@ -42,14 +44,7 @@ public class BlockReportSpamDialogs {
      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();
              }
            });
        .setNegativeButton(android.R.string.cancel, (dialog, which) -> fragment.dismiss());
  }

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

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

  /** Contains the common attributes between all block/unblock/report dialog fragments. */
  private static class CommonDialogsFragment extends DialogFragment {
  /** 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;
@@ -133,7 +125,7 @@ public class BlockReportSpamDialogs {
  public static class BlockReportSpamDialogFragment extends CommonDialogsFragment {

    /** 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. */
    private boolean spamChecked;
@@ -141,12 +133,12 @@ public class BlockReportSpamDialogs {
    public static DialogFragment newInstance(
        String displayNumber,
        boolean spamChecked,
        OnSpamDialogClickListener positiveListener,
        OnSpamDialogClickListener onSpamDialogClickListener,
        @Nullable DialogInterface.OnDismissListener dismissListener) {
      BlockReportSpamDialogFragment fragment = new BlockReportSpamDialogFragment();
      fragment.spamChecked = spamChecked;
      fragment.displayNumber = displayNumber;
      fragment.positiveListener = positiveListener;
      fragment.onSpamDialogClickListener = onSpamDialogClickListener;
      fragment.dismissListener = dismissListener;
      return fragment;
    }
@@ -159,34 +151,25 @@ public class BlockReportSpamDialogs {
          (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;
            }
          });
      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 dialog =
      Dialog blockReportSpamDialog =
          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) {
                  (dialog, which) -> {
                    dismiss();
                      positiveListener.onClick(isSpamCheckbox.isChecked());
                    }
                    onSpamDialogClickListener.onClick(isSpamCheckbox.isChecked());
                  })
              .create();
      dialog.setCanceledOnTouchOutside(true);
      return dialog;
      blockReportSpamDialog.setCanceledOnTouchOutside(true);
      return blockReportSpamDialog;
    }
  }

Loading