diff options
-rw-r--r-- | res/layout/blocked_number_fragment.xml | 1 | ||||
-rw-r--r-- | src/com/android/dialer/filterednumber/BlockedNumberFragment.java | 39 |
2 files changed, 37 insertions, 3 deletions
diff --git a/res/layout/blocked_number_fragment.xml b/res/layout/blocked_number_fragment.xml index c5760da3a..f8d303010 100644 --- a/res/layout/blocked_number_fragment.xml +++ b/res/layout/blocked_number_fragment.xml @@ -23,6 +23,7 @@ android:background="@color/blocked_number_background"> <android.support.v7.widget.CardView + android:id="@+id/hide_blocked_calls_setting" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" diff --git a/src/com/android/dialer/filterednumber/BlockedNumberFragment.java b/src/com/android/dialer/filterednumber/BlockedNumberFragment.java index 06ae0e084..cee7a0d4f 100644 --- a/src/com/android/dialer/filterednumber/BlockedNumberFragment.java +++ b/src/com/android/dialer/filterednumber/BlockedNumberFragment.java @@ -31,14 +31,20 @@ import android.view.View; import android.view.ViewGroup; import com.android.dialer.R; +import com.android.dialer.calllog.CallLogQueryHandler; import com.android.dialer.database.FilteredNumberContract; import com.android.dialer.filterednumber.FilteredNumbersUtil.CheckForSendToVoicemailContactListener; import com.android.dialer.filterednumber.FilteredNumbersUtil.ImportSendToVoicemailContactsListener; +import com.android.dialer.voicemail.VoicemailStatusHelper; +import com.android.dialer.voicemail.VoicemailStatusHelperImpl; -public class BlockedNumberFragment extends ListFragment implements - LoaderManager.LoaderCallbacks<Cursor>, View.OnClickListener { +public class BlockedNumberFragment extends ListFragment + implements LoaderManager.LoaderCallbacks<Cursor>, View.OnClickListener, + CallLogQueryHandler.Listener { private BlockedNumberAdapter mAdapter; + private CallLogQueryHandler mCallLogQueryHandler; + private VoicemailStatusHelper mVoicemailStatusHelper; private Switch mHideSettingSwitch; private View mImportSettings; @@ -54,6 +60,10 @@ public class BlockedNumberFragment extends ListFragment implements } setListAdapter(mAdapter); + mCallLogQueryHandler + = new CallLogQueryHandler(getContext(), getContext().getContentResolver(), this); + mVoicemailStatusHelper = new VoicemailStatusHelperImpl(); + mHideSettingSwitch = (Switch) getActivity().findViewById(R.id.hide_blocked_calls_switch); mHideSettingSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override @@ -101,7 +111,6 @@ public class BlockedNumberFragment extends ListFragment implements @Override public void onResume() { super.onResume(); - FilteredNumbersUtil.checkForSendToVoicemailContact( getActivity(), new CheckForSendToVoicemailContactListener() { @Override @@ -112,6 +121,7 @@ public class BlockedNumberFragment extends ListFragment implements }); mHideSettingSwitch.setChecked(FilteredNumbersUtil.shouldHideBlockedCalls(getActivity())); + mCallLogQueryHandler.fetchVoicemailStatus(); } @Override @@ -155,4 +165,27 @@ public class BlockedNumberFragment extends ListFragment implements manageBlockedNumbersActivity.enterSearchUi(); } } + + @Override + public void onVoicemailStatusFetched(Cursor cursor) { + final boolean hasVisualVoicemailSource = + mVoicemailStatusHelper.getNumberActivityVoicemailSources(cursor) > 0; + View hideSetting = getActivity().findViewById(R.id.hide_blocked_calls_setting); + if (hasVisualVoicemailSource) { + hideSetting.setVisibility(View.VISIBLE); + } else { + hideSetting.setVisibility(View.GONE); + } + } + + @Override + public void onVoicemailUnreadCountFetched(Cursor cursor) { + // Do nothing. + } + + @Override + public boolean onCallsFetched(Cursor cursor) { + // Do nothing. + return false; + } } |