diff options
author | Yorke Lee <yorkelee@google.com> | 2015-10-12 20:50:37 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-10-12 20:50:37 +0000 |
commit | f49c817d525ca3f3a85ccea10f8e94d397c7feb5 (patch) | |
tree | cb17b8702fcdee725527414507e2839238632834 | |
parent | 7f3e03d5593e8f48c5462f4c385317e42b6ce796 (diff) | |
parent | 46959e92623e635967fb264ab72b77f93e86002c (diff) |
Merge "Fix crash in BlockedNumberSearchActivity" into ub-contactsdialer-a-dev
-rw-r--r-- | src/com/android/dialer/DialtactsActivity.java | 3 | ||||
-rw-r--r-- | src/com/android/dialer/list/RegularSearchFragment.java | 23 |
2 files changed, 23 insertions, 3 deletions
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index 4bfd56594..d44e8e7cf 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -110,7 +110,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O ListsFragment.HostInterface, SpeedDialFragment.HostInterface, SearchFragment.HostInterface, - RegularSearchFragment.HostInterface, + RegularSearchFragment.CapabilityChecker, OnDragDropListener, OnPhoneNumberPickerActionListener, PopupMenu.OnMenuItemClickListener, @@ -607,6 +607,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O } else if (fragment instanceof SearchFragment) { mRegularSearchFragment = (RegularSearchFragment) fragment; mRegularSearchFragment.setOnPhoneNumberPickerActionListener(this); + mRegularSearchFragment.setCapabilityChecker(this); } else if (fragment instanceof ListsFragment) { mListsFragment = (ListsFragment) fragment; mListsFragment.addOnPageChangeListener(this); diff --git a/src/com/android/dialer/list/RegularSearchFragment.java b/src/com/android/dialer/list/RegularSearchFragment.java index 0b8703399..33ce95f78 100644 --- a/src/com/android/dialer/list/RegularSearchFragment.java +++ b/src/com/android/dialer/list/RegularSearchFragment.java @@ -29,6 +29,7 @@ import com.android.contacts.common.util.PermissionsUtil; import com.android.contacts.commonbind.analytics.AnalyticsUtil; import com.android.dialerbind.ObjectFactory; import com.android.incallui.Call.LogState; + import com.android.dialer.R; import com.android.dialer.service.CachedNumberLookupService; import com.android.dialer.widget.EmptyContentView; @@ -44,11 +45,12 @@ public class RegularSearchFragment extends SearchFragment private static final CachedNumberLookupService mCachedNumberLookupService = ObjectFactory.newCachedNumberLookupService(); - public interface HostInterface { + public interface CapabilityChecker { public boolean isNearbyPlacesSearchEnabled(); } private String mPermissionToRequest; + private CapabilityChecker mCapabilityChecker; public RegularSearchFragment() { configureDirectorySearch(); @@ -60,6 +62,12 @@ public class RegularSearchFragment extends SearchFragment AnalyticsUtil.sendScreenView(this); } + @Override + public void onDetach() { + mCapabilityChecker = null; + super.onDetach(); + } + public void configureDirectorySearch() { setDirectorySearchEnabled(true); setDirectoryResultLimit(SEARCH_DIRECTORY_RESULT_LIMIT); @@ -102,7 +110,7 @@ public class RegularSearchFragment extends SearchFragment descriptionResource = R.string.permission_no_search; listener = this; mPermissionToRequest = READ_CONTACTS; - } else if (((HostInterface) getActivity()).isNearbyPlacesSearchEnabled() + } else if (isNearbyPlacesSearchEnabled() && !PermissionsUtil.hasPermission(getActivity(), ACCESS_FINE_LOCATION)) { imageResource = R.drawable.empty_contacts; actionLabelResource = R.string.permission_single_turn_on; @@ -156,4 +164,15 @@ public class RegularSearchFragment extends SearchFragment return isRemoteDirectory ? LogState.INITIATION_REMOTE_DIRECTORY : LogState.INITIATION_REGULAR_SEARCH; } + + public void setCapabilityChecker(CapabilityChecker capabilityChecker) { + mCapabilityChecker = capabilityChecker; + } + + private boolean isNearbyPlacesSearchEnabled() { + if (mCapabilityChecker != null) { + return mCapabilityChecker.isNearbyPlacesSearchEnabled(); + } + return false; + } } |