summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/DialtactsActivity.java3
-rw-r--r--src/com/android/dialer/list/RegularSearchFragment.java23
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;
+ }
}