From 862822f31471305d67fe54e3b41cb462b7b2b827 Mon Sep 17 00:00:00 2001 From: Ta-wei Yen Date: Mon, 9 Nov 2015 11:47:45 -0800 Subject: Remove VVM status update for BlockNumberDialogFragment dialog messages. Simplify code as this should be needed very rarely, since all activities that call BlockNumberDialogFragment already need to update the status themselves. + Removed param context in BlockNumberDialogFragment.show() Change-Id: I21f51292208fe59d8dec02d306782df1822b8834 --- src/com/android/dialer/CallDetailActivity.java | 7 ++-- .../dialer/calllog/CallLogListItemViewHolder.java | 7 ++-- .../filterednumber/BlockNumberDialogFragment.java | 40 +++++----------------- .../filterednumber/BlockedNumbersAdapter.java | 1 - .../dialer/list/BlockedListSearchFragment.java | 2 -- 5 files changed, 15 insertions(+), 42 deletions(-) (limited to 'src/com/android') diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java index f63fcf3b0..6df2346c2 100644 --- a/src/com/android/dialer/CallDetailActivity.java +++ b/src/com/android/dialer/CallDetailActivity.java @@ -40,21 +40,21 @@ import android.widget.Toast; import com.android.contacts.common.CallUtil; import com.android.contacts.common.ClipboardUtils; -import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest; import com.android.contacts.common.ContactPhotoManager; +import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest; import com.android.contacts.common.GeoUtil; import com.android.contacts.common.interactions.TouchPointManager; import com.android.contacts.common.preference.ContactsPreferences; import com.android.contacts.common.testing.NeededForTesting; import com.android.contacts.common.util.UriUtils; import com.android.dialer.calllog.CallDetailHistoryAdapter; -import com.android.dialer.calllog.CallLogAsyncTaskUtil.CallLogAsyncTaskListener; import com.android.dialer.calllog.CallLogAsyncTaskUtil; +import com.android.dialer.calllog.CallLogAsyncTaskUtil.CallLogAsyncTaskListener; import com.android.dialer.calllog.CallTypeHelper; 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.database.FilteredNumberAsyncQueryHandler.OnCheckBlockedListener; import com.android.dialer.filterednumber.BlockNumberDialogFragment; import com.android.dialer.filterednumber.FilteredNumbersUtil; import com.android.dialer.util.DialerUtils; @@ -358,7 +358,6 @@ public class CallDetailActivity extends AppCompatActivity switch(view.getId()) { case R.id.call_detail_action_block: BlockNumberDialogFragment.show( - this, mBlockedNumberId, mNumber, mDetails.countryIso, diff --git a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java index 89596f2e1..07700c030 100644 --- a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java +++ b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java @@ -18,8 +18,8 @@ package com.android.dialer.calllog; import android.app.Activity; import android.content.Context; -import android.content.res.Resources; import android.content.Intent; +import android.content.res.Resources; import android.net.Uri; import android.provider.CallLog; import android.provider.CallLog.Calls; @@ -34,8 +34,8 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.view.ViewStub; -import android.widget.QuickContactBadge; import android.widget.ImageView; +import android.widget.QuickContactBadge; import android.widget.TextView; import com.android.contacts.common.CallUtil; @@ -52,8 +52,8 @@ import com.android.dialer.filterednumber.BlockNumberDialogFragment; import com.android.dialer.filterednumber.FilteredNumbersUtil; import com.android.dialer.util.DialerUtils; import com.android.dialer.util.PhoneNumberUtil; -import com.android.dialer.voicemail.VoicemailPlaybackPresenter; import com.android.dialer.voicemail.VoicemailPlaybackLayout; +import com.android.dialer.voicemail.VoicemailPlaybackPresenter; /** * This is an object containing references to views contained by the call log list item. This @@ -328,7 +328,6 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder switch (item.getItemId()) { case R.id.context_menu_block_number: BlockNumberDialogFragment.show( - mContext, blockId, number, countryIso, diff --git a/src/com/android/dialer/filterednumber/BlockNumberDialogFragment.java b/src/com/android/dialer/filterednumber/BlockNumberDialogFragment.java index 91d4d121d..21746eecc 100644 --- a/src/com/android/dialer/filterednumber/BlockNumberDialogFragment.java +++ b/src/com/android/dialer/filterednumber/BlockNumberDialogFragment.java @@ -41,8 +41,7 @@ import com.android.dialer.voicemail.VisualVoicemailEnabledChecker; * Fragment for confirming and enacting blocking/unblocking a number. Also invokes snackbar * providing undo functionality. */ -public class BlockNumberDialogFragment extends DialogFragment - implements VisualVoicemailEnabledChecker.Callback{ +public class BlockNumberDialogFragment extends DialogFragment { /** * Use a callback interface to update UI after success/undo. Favor this approach over other @@ -72,10 +71,8 @@ public class BlockNumberDialogFragment extends DialogFragment private View mParentView; private VisualVoicemailEnabledChecker mVoicemailEnabledChecker; private Callback mCallback; - private AlertDialog mAlertDialog; public static void show( - Context context, Integer blockId, String number, String countryIso, @@ -84,14 +81,13 @@ public class BlockNumberDialogFragment extends DialogFragment FragmentManager fragmentManager, Callback callback) { final BlockNumberDialogFragment newFragment = BlockNumberDialogFragment.newInstance( - context, blockId, number, countryIso, displayNumber, parentViewId); + blockId, number, countryIso, displayNumber, parentViewId); newFragment.setCallback(callback); newFragment.show(fragmentManager, BlockNumberDialogFragment.BLOCK_DIALOG_FRAGMENT); } private static BlockNumberDialogFragment newInstance( - Context context, Integer blockId, String number, String countryIso, @@ -109,8 +105,6 @@ public class BlockNumberDialogFragment extends DialogFragment args.putString(ARG_COUNTRY_ISO, countryIso); args.putString(ARG_DISPLAY_NUMBER, displayNumber); fragment.setArguments(args); - fragment.mVoicemailEnabledChecker = new VisualVoicemailEnabledChecker(context,fragment); - fragment.mVoicemailEnabledChecker.asyncUpdate(); return fragment; } @@ -128,6 +122,11 @@ public class BlockNumberDialogFragment extends DialogFragment } mHandler = new FilteredNumberAsyncQueryHandler(getContext().getContentResolver()); + mVoicemailEnabledChecker = new VisualVoicemailEnabledChecker(getActivity(), null); + /** + * Choose not to update VoicemailEnabledChecker, as checks should already been done in + * all current use cases. + */ mParentView = getActivity().findViewById(getArguments().getInt(ARG_PARENT_VIEW_ID)); CharSequence title; @@ -162,16 +161,10 @@ public class BlockNumberDialogFragment extends DialogFragment } else { blockNumber(); } - mAlertDialog = null; } }) - .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - mAlertDialog = null; - } - }); - mAlertDialog = builder.create(); - return mAlertDialog; + .setNegativeButton(android.R.string.cancel, null); + return builder.create(); } @Override @@ -300,19 +293,4 @@ public class BlockNumberDialogFragment extends DialogFragment } }, getArguments().getInt(ARG_BLOCK_ID)); } - - @Override - public void onVisualVoicemailEnabledStatusChanged(boolean newStatus){ - updateActiveVoicemailProvider(); - } - - private void updateActiveVoicemailProvider(){ - if(mAlertDialog != null) { - if (mVoicemailEnabledChecker.isVisualVoicemailEnabled()) { - mAlertDialog.setMessage(getString(R.string.block_number_confirmation_message_vvm)); - } else { - mAlertDialog.setMessage(getString(R.string.block_number_confirmation_message_no_vvm)); - } - } - } } diff --git a/src/com/android/dialer/filterednumber/BlockedNumbersAdapter.java b/src/com/android/dialer/filterednumber/BlockedNumbersAdapter.java index be83df723..827d3bffc 100644 --- a/src/com/android/dialer/filterednumber/BlockedNumbersAdapter.java +++ b/src/com/android/dialer/filterednumber/BlockedNumbersAdapter.java @@ -60,7 +60,6 @@ public class BlockedNumbersAdapter extends NumbersAdapter { @Override public void onClick(View view) { BlockNumberDialogFragment.show( - context, id, number, countryIso, diff --git a/src/com/android/dialer/list/BlockedListSearchFragment.java b/src/com/android/dialer/list/BlockedListSearchFragment.java index 717cf9e46..88ab0f531 100644 --- a/src/com/android/dialer/list/BlockedListSearchFragment.java +++ b/src/com/android/dialer/list/BlockedListSearchFragment.java @@ -171,7 +171,6 @@ public class BlockedListSearchFragment extends RegularSearchFragment public void onCheckComplete(Integer id) { if (id == null) { BlockNumberDialogFragment.show( - getContext(), id, number, countryIso, @@ -220,7 +219,6 @@ public class BlockedListSearchFragment extends RegularSearchFragment } BlockNumberDialogFragment.show( - getContext(), blockId, number, GeoUtil.getCurrentCountryIso(getContext()), -- cgit v1.2.3