diff options
Diffstat (limited to 'src/com/android/dialer/list/RegularSearchFragment.java')
-rw-r--r-- | src/com/android/dialer/list/RegularSearchFragment.java | 23 |
1 files changed, 21 insertions, 2 deletions
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; + } } |