From fcecacedc1837673321f516673c6d68fd82e63ce Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Wed, 28 Oct 2015 17:36:49 -0700 Subject: Rename FilterNumberDialogFragment. It bugged me how it was inconsistently named to other classes (ie. FilterNumber vs FilteredNumber). It's also specific to blocked numbers, for now, so it felt more appropriate to name it accordingly. Bug: 25343277 Change-Id: I33e2f9fd933d117326690901ec71e3e8c0e3bbd3 --- src/com/android/dialer/CallDetailActivity.java | 6 +- src/com/android/dialer/calllog/CallLogAdapter.java | 4 +- .../dialer/calllog/CallLogListItemViewHolder.java | 10 +- .../filterednumber/BlockNumberDialogFragment.java | 283 +++++++++++++++++++++ .../filterednumber/BlockedNumberAdapter.java | 2 +- .../filterednumber/FilterNumberDialogFragment.java | 279 -------------------- .../dialer/list/BlockedListSearchFragment.java | 8 +- 7 files changed, 298 insertions(+), 294 deletions(-) create mode 100644 src/com/android/dialer/filterednumber/BlockNumberDialogFragment.java delete mode 100644 src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java (limited to 'src/com/android/dialer') diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java index 2121e988d..773938cdf 100644 --- a/src/com/android/dialer/CallDetailActivity.java +++ b/src/com/android/dialer/CallDetailActivity.java @@ -55,7 +55,7 @@ import com.android.dialer.calllog.ContactInfoHelper; import com.android.dialer.calllog.PhoneAccountUtils; import com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnCheckBlockedListener; import com.android.dialer.database.FilteredNumberAsyncQueryHandler; -import com.android.dialer.filterednumber.FilterNumberDialogFragment; +import com.android.dialer.filterednumber.BlockNumberDialogFragment; import com.android.dialer.filterednumber.FilteredNumbersUtil; import com.android.dialer.util.DialerUtils; import com.android.dialer.util.IntentUtil.CallIntentBuilder; @@ -71,7 +71,7 @@ import com.android.incallui.Call.LogState; */ public class CallDetailActivity extends AppCompatActivity implements MenuItem.OnMenuItemClickListener, View.OnClickListener, - FilterNumberDialogFragment.Callback { + BlockNumberDialogFragment.Callback { private static final String TAG = CallDetailActivity.class.getSimpleName(); /** A long array extra containing ids of call log entries to display. */ @@ -358,7 +358,7 @@ public class CallDetailActivity extends AppCompatActivity public void onClick(View view) { switch(view.getId()) { case R.id.call_detail_action_block: - FilterNumberDialogFragment.show( + BlockNumberDialogFragment.show( mBlockedNumberId, null /* normalizedNumber */, mNumber, diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index 01af982f3..d846c654d 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -50,7 +50,7 @@ import com.android.dialer.contactinfo.ContactInfoCache.OnContactInfoChangedListe import com.android.dialer.contactinfo.NumberWithCountryIso; import com.android.dialer.database.FilteredNumberAsyncQueryHandler; import com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnCheckBlockedListener; -import com.android.dialer.filterednumber.FilterNumberDialogFragment; +import com.android.dialer.filterednumber.BlockNumberDialogFragment; import com.android.dialer.util.PhoneNumberUtil; import com.android.dialer.voicemail.VoicemailPlaybackPresenter; @@ -63,7 +63,7 @@ import java.util.Map; public class CallLogAdapter extends GroupingListAdapter implements CallLogGroupBuilder.GroupCreator, VoicemailPlaybackPresenter.OnVoicemailDeletedListener, - FilterNumberDialogFragment.Callback { + BlockNumberDialogFragment.Callback { /** Interface used to initiate a refresh of the content. */ public interface CallFetcher { diff --git a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java index 1bc44108d..d07f05a65 100644 --- a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java +++ b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java @@ -48,7 +48,7 @@ import com.android.contacts.common.util.UriUtils; import com.android.dialer.DialtactsActivity; import com.android.dialer.R; import com.android.dialer.database.FilteredNumberAsyncQueryHandler; -import com.android.dialer.filterednumber.FilterNumberDialogFragment; +import com.android.dialer.filterednumber.BlockNumberDialogFragment; import com.android.dialer.filterednumber.FilteredNumbersUtil; import com.android.dialer.util.DialerUtils; import com.android.dialer.util.PhoneNumberUtil; @@ -184,7 +184,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder private final CallLogListItemHelper mCallLogListItemHelper; private final VoicemailPlaybackPresenter mVoicemailPlaybackPresenter; private final FilteredNumberAsyncQueryHandler mFilteredNumberAsyncQueryHandler; - private final FilterNumberDialogFragment.Callback mFilteredNumberDialogCallback; + private final BlockNumberDialogFragment.Callback mFilteredNumberDialogCallback; private final int mPhotoSize; @@ -198,7 +198,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder CallLogListItemHelper callLogListItemHelper, VoicemailPlaybackPresenter voicemailPlaybackPresenter, FilteredNumberAsyncQueryHandler filteredNumberAsyncQueryHandler, - FilterNumberDialogFragment.Callback filteredNumberDialogCallback, + BlockNumberDialogFragment.Callback filteredNumberDialogCallback, View rootView, QuickContactBadge quickContactView, View primaryActionView, @@ -247,7 +247,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder CallLogListItemHelper callLogListItemHelper, VoicemailPlaybackPresenter voicemailPlaybackPresenter, FilteredNumberAsyncQueryHandler filteredNumberAsyncQueryHandler, - FilterNumberDialogFragment.Callback filteredNumberDialogCallback) { + BlockNumberDialogFragment.Callback filteredNumberDialogCallback) { return new CallLogListItemViewHolder( context, @@ -327,7 +327,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.context_menu_block_number: - FilterNumberDialogFragment.show( + BlockNumberDialogFragment.show( blockId, info.normalizedNumber, number, diff --git a/src/com/android/dialer/filterednumber/BlockNumberDialogFragment.java b/src/com/android/dialer/filterednumber/BlockNumberDialogFragment.java new file mode 100644 index 000000000..fcd74f368 --- /dev/null +++ b/src/com/android/dialer/filterednumber/BlockNumberDialogFragment.java @@ -0,0 +1,283 @@ +/* + * Copyright (C) 2015 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.filterednumber; + +import android.app.AlertDialog; +import android.app.Dialog; +import android.app.DialogFragment; +import android.app.FragmentManager; +import android.content.ContentValues; +import android.content.Context; +import android.content.DialogInterface; +import android.content.res.Resources; +import android.net.Uri; +import android.os.Bundle; +import android.support.design.widget.Snackbar; +import android.telephony.PhoneNumberUtils; +import android.text.TextUtils; +import android.view.View; +import android.widget.Toast; + +import com.android.dialer.R; +import com.android.dialer.database.FilteredNumberAsyncQueryHandler; +import com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnBlockNumberListener; +import com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnUnblockNumberListener; + +/** + * Fragment for confirming and enacting blocking/unblocking a number. Also invokes snackbar + * providing undo functionality. + */ +public class BlockNumberDialogFragment extends DialogFragment { + + /** + * Use a callback interface to update UI after success/undo. Favor this approach over other + * more standard paradigms because of the variety of scenarios in which the DialogFragment + * can be invoked (by an Activity, by a fragment, by an adapter, by an adapter list item). + * Because of this, we do NOT support retaining state on rotation, and will dismiss the dialog + * upon rotation instead. + */ + public interface Callback { + public void onChangeFilteredNumberSuccess(); + public void onChangeFilteredNumberUndo(); + } + + private static final String BLOCK_DIALOG_FRAGMENT = "BlockNumberDialog"; + + private static final String ARG_BLOCK_ID = "argBlockId"; + private static final String ARG_NORMALIZED_NUMBER = "argNormalizedNumber"; + private static final String ARG_NUMBER = "argNumber"; + private static final String ARG_COUNTRY_ISO = "argCountryIso"; + private static final String ARG_DISPLAY_NUMBER = "argDisplayNumber"; + private static final String ARG_PARENT_VIEW_ID = "parentViewId"; + + private String mNumber; + private String mDisplayNumber; + private String mNormalizedNumber; + private String mCountryIso; + + private FilteredNumberAsyncQueryHandler mHandler; + private View mParentView; + private Callback mCallback; + + public static void show( + Integer blockId, + String normalizedNumber, + String number, + String countryIso, + String displayNumber, + Integer parentViewId, + FragmentManager fragmentManager, + Callback callback) { + final BlockNumberDialogFragment newFragment = BlockNumberDialogFragment.newInstance( + blockId, normalizedNumber, number, countryIso, displayNumber, parentViewId); + + newFragment.setCallback(callback); + newFragment.show(fragmentManager, BlockNumberDialogFragment.BLOCK_DIALOG_FRAGMENT); + } + + private static BlockNumberDialogFragment newInstance( + Integer blockId, + String normalizedNumber, + String number, + String countryIso, + String displayNumber, + Integer parentViewId) { + final BlockNumberDialogFragment fragment = new BlockNumberDialogFragment(); + final Bundle args = new Bundle(); + if (blockId != null) { + args.putInt(ARG_BLOCK_ID, blockId.intValue()); + } + if (parentViewId != null) { + args.putInt(ARG_PARENT_VIEW_ID, parentViewId.intValue()); + } + args.putString(ARG_NORMALIZED_NUMBER, normalizedNumber); + args.putString(ARG_NUMBER, number); + args.putString(ARG_COUNTRY_ISO, countryIso); + args.putString(ARG_DISPLAY_NUMBER, displayNumber); + fragment.setArguments(args); + return fragment; + } + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + super.onCreateDialog(savedInstanceState); + final boolean isBlocked = getArguments().containsKey(ARG_BLOCK_ID); + + mNumber = getArguments().getString(ARG_NUMBER); + mDisplayNumber = getArguments().getString(ARG_DISPLAY_NUMBER); + mNormalizedNumber = getArguments().getString(ARG_NORMALIZED_NUMBER); + mCountryIso = getArguments().getString(ARG_COUNTRY_ISO); + + if (TextUtils.isEmpty(mNormalizedNumber)) { + mNormalizedNumber = PhoneNumberUtils.formatNumberToE164(mNumber, mCountryIso); + } + if (TextUtils.isEmpty(mDisplayNumber)) { + mDisplayNumber = mNumber; + } + + mHandler = new FilteredNumberAsyncQueryHandler(getContext().getContentResolver()); + mParentView = getActivity().findViewById(getArguments().getInt(ARG_PARENT_VIEW_ID)); + + String message; + String okText; + if (isBlocked) { + message = getString(R.string.unblockNumberConfirmation, mDisplayNumber); + okText = getString(R.string.unblockNumberOk); + } else { + message = getString(R.string.blockNumberConfirmation, mDisplayNumber); + okText = getString(R.string.blockNumberOk); + } + + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()) + .setMessage(message) + .setPositiveButton(okText, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + if (isBlocked) { + unblockNumber(); + } else { + blockNumber(); + } + } + }) + .setNegativeButton(android.R.string.cancel, null); + return builder.create(); + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + if (!FilteredNumbersUtil.canBlockNumber(getActivity(), mNormalizedNumber)) { + dismiss(); + Toast.makeText(getContext(), getString(R.string.invalidNumber, mDisplayNumber), + Toast.LENGTH_SHORT).show(); + } + } + + @Override + public void onPause() { + // Dismiss on rotation. + dismiss(); + mCallback = null; + + super.onPause(); + } + + public void setCallback(Callback callback) { + mCallback = callback; + } + + private String getBlockedMessage() { + return getString(R.string.snackbar_number_blocked, mDisplayNumber); + } + + private String getUnblockedMessage() { + return getString(R.string.snackbar_number_unblocked, mDisplayNumber); + } + + private int getActionTextColor() { + return getContext().getResources().getColor(R.color.dialer_snackbar_action_text_color); + } + + private void blockNumber() { + final String message = getBlockedMessage(); + final String undoMessage = getUnblockedMessage(); + final Callback callback = mCallback; + final int actionTextColor = getActionTextColor(); + final Context context = getContext(); + + final OnUnblockNumberListener onUndoListener = new OnUnblockNumberListener() { + @Override + public void onUnblockComplete(int rows, ContentValues values) { + Snackbar.make(mParentView, undoMessage, Snackbar.LENGTH_LONG).show(); + if (callback != null) { + callback.onChangeFilteredNumberUndo(); + } + } + }; + + final OnBlockNumberListener onBlockNumberListener = new OnBlockNumberListener() { + @Override + public void onBlockComplete(final Uri uri) { + final View.OnClickListener undoListener = new View.OnClickListener() { + @Override + public void onClick(View view) { + // Delete the newly created row on 'undo'. + mHandler.unblock(onUndoListener, uri); + } + }; + + Snackbar.make(mParentView, message, Snackbar.LENGTH_LONG) + .setAction(R.string.block_number_undo, undoListener) + .setActionTextColor(actionTextColor) + .show(); + + if (callback != null) { + callback.onChangeFilteredNumberSuccess(); + } + + if (context != null && FilteredNumbersUtil.hasRecentEmergencyCall(context)) { + FilteredNumbersUtil.maybeNotifyCallBlockingDisabled(context); + } + } + }; + + mHandler.blockNumber( + onBlockNumberListener, + mNormalizedNumber, + mNumber, + mCountryIso); + } + + private void unblockNumber() { + final String message = getUnblockedMessage(); + final String undoMessage = getBlockedMessage(); + final Callback callback = mCallback; + final int actionTextColor = getActionTextColor(); + + final OnBlockNumberListener onUndoListener = new OnBlockNumberListener() { + @Override + public void onBlockComplete(final Uri uri) { + Snackbar.make(mParentView, undoMessage, Snackbar.LENGTH_LONG).show(); + if (callback != null) { + callback.onChangeFilteredNumberUndo(); + } + } + }; + + mHandler.unblock(new OnUnblockNumberListener() { + @Override + public void onUnblockComplete(int rows, final ContentValues values) { + final View.OnClickListener undoListener = new View.OnClickListener() { + @Override + public void onClick(View view) { + // Re-insert the row on 'undo', with a new ID. + mHandler.blockNumber(onUndoListener, values); + } + }; + + Snackbar.make(mParentView, message, Snackbar.LENGTH_LONG) + .setAction(R.string.block_number_undo, undoListener) + .setActionTextColor(actionTextColor) + .show(); + + if (callback != null) { + callback.onChangeFilteredNumberSuccess(); + } + } + }, getArguments().getInt(ARG_BLOCK_ID)); + } +} diff --git a/src/com/android/dialer/filterednumber/BlockedNumberAdapter.java b/src/com/android/dialer/filterednumber/BlockedNumberAdapter.java index 7777aeb71..76fc74320 100644 --- a/src/com/android/dialer/filterednumber/BlockedNumberAdapter.java +++ b/src/com/android/dialer/filterednumber/BlockedNumberAdapter.java @@ -59,7 +59,7 @@ public class BlockedNumberAdapter extends NumberAdapter { deleteButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - FilterNumberDialogFragment.show( + BlockNumberDialogFragment.show( id, normalizedNumber, number, diff --git a/src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java b/src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java deleted file mode 100644 index d7608d8f9..000000000 --- a/src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java +++ /dev/null @@ -1,279 +0,0 @@ -/* - * Copyright (C) 2015 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.filterednumber; - -import android.app.AlertDialog; -import android.app.Dialog; -import android.app.DialogFragment; -import android.app.FragmentManager; -import android.content.ContentValues; -import android.content.Context; -import android.content.DialogInterface; -import android.content.res.Resources; -import android.net.Uri; -import android.os.Bundle; -import android.support.design.widget.Snackbar; -import android.telephony.PhoneNumberUtils; -import android.text.TextUtils; -import android.view.View; -import android.widget.Toast; - -import com.android.dialer.R; -import com.android.dialer.database.FilteredNumberAsyncQueryHandler; -import com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnBlockNumberListener; -import com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnUnblockNumberListener; - -public class FilterNumberDialogFragment extends DialogFragment { - - /** - * Use a callback interface to update UI after success/undo. Favor this approach over other - * more standard paradigms because of the variety of scenarios in which the DialogFragment - * can be invoked (by an Activity, by a fragment, by an adapter, by an adapter list item). - * Because of this, we do NOT support retaining state on rotation, and will dismiss the dialog - * upon rotation instead. - */ - public interface Callback { - public void onChangeFilteredNumberSuccess(); - public void onChangeFilteredNumberUndo(); - } - - private static final String BLOCK_DIALOG_FRAGMENT = "blockUnblockNumberDialog"; - - private static final String ARG_BLOCK_ID = "argBlockId"; - private static final String ARG_NORMALIZED_NUMBER = "argNormalizedNumber"; - private static final String ARG_NUMBER = "argNumber"; - private static final String ARG_COUNTRY_ISO = "argCountryIso"; - private static final String ARG_DISPLAY_NUMBER = "argDisplayNumber"; - private static final String ARG_PARENT_VIEW_ID = "parentViewId"; - - private String mNumber; - private String mDisplayNumber; - private String mNormalizedNumber; - private String mCountryIso; - - private FilteredNumberAsyncQueryHandler mHandler; - private View mParentView; - private Callback mCallback; - - public static void show( - Integer blockId, - String normalizedNumber, - String number, - String countryIso, - String displayNumber, - Integer parentViewId, - FragmentManager fragmentManager, - Callback callback) { - final FilterNumberDialogFragment newFragment = FilterNumberDialogFragment.newInstance( - blockId, normalizedNumber, number, countryIso, displayNumber, parentViewId); - - newFragment.setCallback(callback); - newFragment.show(fragmentManager, FilterNumberDialogFragment.BLOCK_DIALOG_FRAGMENT); - } - - private static FilterNumberDialogFragment newInstance( - Integer blockId, - String normalizedNumber, - String number, - String countryIso, - String displayNumber, - Integer parentViewId) { - final FilterNumberDialogFragment fragment = new FilterNumberDialogFragment(); - final Bundle args = new Bundle(); - if (blockId != null) { - args.putInt(ARG_BLOCK_ID, blockId.intValue()); - } - if (parentViewId != null) { - args.putInt(ARG_PARENT_VIEW_ID, parentViewId.intValue()); - } - args.putString(ARG_NORMALIZED_NUMBER, normalizedNumber); - args.putString(ARG_NUMBER, number); - args.putString(ARG_COUNTRY_ISO, countryIso); - args.putString(ARG_DISPLAY_NUMBER, displayNumber); - fragment.setArguments(args); - return fragment; - } - - @Override - public Dialog onCreateDialog(Bundle savedInstanceState) { - super.onCreateDialog(savedInstanceState); - final boolean isBlocked = getArguments().containsKey(ARG_BLOCK_ID); - - mNumber = getArguments().getString(ARG_NUMBER); - mDisplayNumber = getArguments().getString(ARG_DISPLAY_NUMBER); - mNormalizedNumber = getArguments().getString(ARG_NORMALIZED_NUMBER); - mCountryIso = getArguments().getString(ARG_COUNTRY_ISO); - - if (TextUtils.isEmpty(mNormalizedNumber)) { - mNormalizedNumber = PhoneNumberUtils.formatNumberToE164(mNumber, mCountryIso); - } - if (TextUtils.isEmpty(mDisplayNumber)) { - mDisplayNumber = mNumber; - } - - mHandler = new FilteredNumberAsyncQueryHandler(getContext().getContentResolver()); - mParentView = getActivity().findViewById(getArguments().getInt(ARG_PARENT_VIEW_ID)); - - String message; - String okText; - if (isBlocked) { - message = getString(R.string.unblockNumberConfirmation, mDisplayNumber); - okText = getString(R.string.unblockNumberOk); - } else { - message = getString(R.string.blockNumberConfirmation, mDisplayNumber); - okText = getString(R.string.blockNumberOk); - } - - AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()) - .setMessage(message) - .setPositiveButton(okText, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - if (isBlocked) { - unblockNumber(); - } else { - blockNumber(); - } - } - }) - .setNegativeButton(android.R.string.cancel, null); - return builder.create(); - } - - @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - if (!FilteredNumbersUtil.canBlockNumber(getActivity(), mNormalizedNumber)) { - dismiss(); - Toast.makeText(getContext(), getString(R.string.invalidNumber, mDisplayNumber), - Toast.LENGTH_SHORT).show(); - } - } - - @Override - public void onPause() { - // Dismiss on rotation. - dismiss(); - mCallback = null; - - super.onPause(); - } - - public void setCallback(Callback callback) { - mCallback = callback; - } - - private String getBlockedMessage() { - return getString(R.string.snackbar_number_blocked, mDisplayNumber); - } - - private String getUnblockedMessage() { - return getString(R.string.snackbar_number_unblocked, mDisplayNumber); - } - - private int getActionTextColor() { - return getContext().getResources().getColor(R.color.dialer_snackbar_action_text_color); - } - - private void blockNumber() { - final String message = getBlockedMessage(); - final String undoMessage = getUnblockedMessage(); - final Callback callback = mCallback; - final int actionTextColor = getActionTextColor(); - final Context context = getContext(); - - final OnUnblockNumberListener onUndoListener = new OnUnblockNumberListener() { - @Override - public void onUnblockComplete(int rows, ContentValues values) { - Snackbar.make(mParentView, undoMessage, Snackbar.LENGTH_LONG).show(); - if (callback != null) { - callback.onChangeFilteredNumberUndo(); - } - } - }; - - final OnBlockNumberListener onBlockNumberListener = new OnBlockNumberListener() { - @Override - public void onBlockComplete(final Uri uri) { - final View.OnClickListener undoListener = new View.OnClickListener() { - @Override - public void onClick(View view) { - // Delete the newly created row on 'undo'. - mHandler.unblock(onUndoListener, uri); - } - }; - - Snackbar.make(mParentView, message, Snackbar.LENGTH_LONG) - .setAction(R.string.block_number_undo, undoListener) - .setActionTextColor(actionTextColor) - .show(); - - if (callback != null) { - callback.onChangeFilteredNumberSuccess(); - } - - if (context != null && FilteredNumbersUtil.hasRecentEmergencyCall(context)) { - FilteredNumbersUtil.maybeNotifyCallBlockingDisabled(context); - } - } - }; - - mHandler.blockNumber( - onBlockNumberListener, - mNormalizedNumber, - mNumber, - mCountryIso); - } - - private void unblockNumber() { - final String message = getUnblockedMessage(); - final String undoMessage = getBlockedMessage(); - final Callback callback = mCallback; - final int actionTextColor = getActionTextColor(); - - final OnBlockNumberListener onUndoListener = new OnBlockNumberListener() { - @Override - public void onBlockComplete(final Uri uri) { - Snackbar.make(mParentView, undoMessage, Snackbar.LENGTH_LONG).show(); - if (callback != null) { - callback.onChangeFilteredNumberUndo(); - } - } - }; - - mHandler.unblock(new OnUnblockNumberListener() { - @Override - public void onUnblockComplete(int rows, final ContentValues values) { - final View.OnClickListener undoListener = new View.OnClickListener() { - @Override - public void onClick(View view) { - // Re-insert the row on 'undo', with a new ID. - mHandler.blockNumber(onUndoListener, values); - } - }; - - Snackbar.make(mParentView, message, Snackbar.LENGTH_LONG) - .setAction(R.string.block_number_undo, undoListener) - .setActionTextColor(actionTextColor) - .show(); - - if (callback != null) { - callback.onChangeFilteredNumberSuccess(); - } - } - }, getArguments().getInt(ARG_BLOCK_ID)); - } -} diff --git a/src/com/android/dialer/list/BlockedListSearchFragment.java b/src/com/android/dialer/list/BlockedListSearchFragment.java index 852e7c916..805d969a3 100644 --- a/src/com/android/dialer/list/BlockedListSearchFragment.java +++ b/src/com/android/dialer/list/BlockedListSearchFragment.java @@ -34,12 +34,12 @@ import com.android.contacts.common.list.ContactListItemView; import com.android.dialer.R; import com.android.dialer.database.FilteredNumberAsyncQueryHandler; import com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnCheckBlockedListener; -import com.android.dialer.filterednumber.FilterNumberDialogFragment; +import com.android.dialer.filterednumber.BlockNumberDialogFragment; import com.android.dialer.filterednumber.ManageBlockedNumbersActivity; import com.android.dialer.widget.SearchEditTextLayout; public class BlockedListSearchFragment extends RegularSearchFragment - implements FilterNumberDialogFragment.Callback { + implements BlockNumberDialogFragment.Callback { private static final String TAG = BlockedListSearchFragment.class.getSimpleName(); private static final String KEY_SEARCH_QUERY = "search_query"; @@ -175,7 +175,7 @@ public class BlockedListSearchFragment extends RegularSearchFragment @Override public void onCheckComplete(Integer id) { if (id == null) { - FilterNumberDialogFragment.show( + BlockNumberDialogFragment.show( id, null, number, @@ -224,7 +224,7 @@ public class BlockedListSearchFragment extends RegularSearchFragment return; } - FilterNumberDialogFragment.show( + BlockNumberDialogFragment.show( blockId, null, number, -- cgit v1.2.3