diff options
author | linyuh <linyuh@google.com> | 2018-02-26 10:56:21 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-02-26 10:57:18 -0800 |
commit | 719341fb552ddb1b1e955e0f8ace79ffc0491b67 (patch) | |
tree | d570f076bea55bc2446a3edd3c50d1b6bc023d8a /java/com/android/dialer/blockreportspam | |
parent | 19a126b0c12c0ea93ffe7f60f3250e81aa305785 (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/blockreportspam')
8 files changed, 691 insertions, 0 deletions
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 @@ +<?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 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 @@ +<?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/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 @@ +<!-- + ~ 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> + + <!-- 87% black --> + <color name="block_report_spam_primary_text_color">#de000000</color> + +</resources> 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 @@ +<!-- + ~ 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/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 @@ +<!-- + ~ 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 + --> + +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + + <!-- 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> + + <!-- 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> + + <!-- Block number alert dialog button [CHAR LIMIT=32] --> + <string name="block_number_ok">BLOCK</string> + + <!-- Unblock number alert dialog button [CHAR LIMIT=32] --> + <string name="unblock_number_ok">UNBLOCK</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> |