summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/DialtactsActivity.java6
-rw-r--r--src/com/android/dialer/list/RegularSearchFragment.java54
2 files changed, 49 insertions, 11 deletions
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index 455b09758..4bfd56594 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -110,6 +110,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
ListsFragment.HostInterface,
SpeedDialFragment.HostInterface,
SearchFragment.HostInterface,
+ RegularSearchFragment.HostInterface,
OnDragDropListener,
OnPhoneNumberPickerActionListener,
PopupMenu.OnMenuItemClickListener,
@@ -870,6 +871,11 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
}
}
+ @Override
+ public boolean isNearbyPlacesSearchEnabled() {
+ return false;
+ }
+
protected int getSearchBoxHint () {
return R.string.dialer_hint_find_contact;
}
diff --git a/src/com/android/dialer/list/RegularSearchFragment.java b/src/com/android/dialer/list/RegularSearchFragment.java
index ec771e8ef..0b8703399 100644
--- a/src/com/android/dialer/list/RegularSearchFragment.java
+++ b/src/com/android/dialer/list/RegularSearchFragment.java
@@ -16,6 +16,7 @@
package com.android.dialer.list;
import static android.Manifest.permission.READ_CONTACTS;
+import static android.Manifest.permission.ACCESS_FINE_LOCATION;
import android.app.Activity;
import android.content.pm.PackageManager;
@@ -36,13 +37,19 @@ import com.android.dialer.widget.EmptyContentView.OnEmptyViewActionButtonClicked
public class RegularSearchFragment extends SearchFragment
implements OnEmptyViewActionButtonClickedListener {
- private static final int READ_CONTACTS_PERMISSION_REQUEST_CODE = 1;
+ private static final int PERMISSION_REQUEST_CODE = 1;
private static final int SEARCH_DIRECTORY_RESULT_LIMIT = 5;
private static final CachedNumberLookupService mCachedNumberLookupService =
ObjectFactory.newCachedNumberLookupService();
+ public interface HostInterface {
+ public boolean isNearbyPlacesSearchEnabled();
+ }
+
+ private String mPermissionToRequest;
+
public RegularSearchFragment() {
configureDirectorySearch();
}
@@ -64,6 +71,7 @@ public class RegularSearchFragment extends SearchFragment
((PinnedHeaderListView) getListView()).setScrollToSectionOnHeaderTouch(true);
}
+ @Override
protected ContactEntryListAdapter createListAdapter() {
RegularSearchListAdapter adapter = new RegularSearchListAdapter(getActivity());
adapter.setDisplayPhotos(true);
@@ -84,15 +92,36 @@ public class RegularSearchFragment extends SearchFragment
@Override
protected void setupEmptyView() {
if (mEmptyView != null && getActivity() != null) {
+ final int imageResource;
+ final int actionLabelResource;
+ final int descriptionResource;
+ final OnEmptyViewActionButtonClickedListener listener;
if (!PermissionsUtil.hasPermission(getActivity(), READ_CONTACTS)) {
- mEmptyView.setImage(R.drawable.empty_contacts);
- mEmptyView.setActionLabel(R.string.permission_single_turn_on);
- mEmptyView.setDescription(R.string.permission_no_search);
- mEmptyView.setActionClickedListener(this);
+ imageResource = R.drawable.empty_contacts;
+ actionLabelResource = R.string.permission_single_turn_on;
+ descriptionResource = R.string.permission_no_search;
+ listener = this;
+ mPermissionToRequest = READ_CONTACTS;
+ } else if (((HostInterface) getActivity()).isNearbyPlacesSearchEnabled()
+ && !PermissionsUtil.hasPermission(getActivity(), ACCESS_FINE_LOCATION)) {
+ imageResource = R.drawable.empty_contacts;
+ actionLabelResource = R.string.permission_single_turn_on;
+ descriptionResource = R.string.permission_no_location_for_search;
+ listener = this;
+ mPermissionToRequest = ACCESS_FINE_LOCATION;
} else {
- mEmptyView.setImage(EmptyContentView.NO_IMAGE);
- mEmptyView.setActionLabel(EmptyContentView.NO_LABEL);
- mEmptyView.setDescription(EmptyContentView.NO_LABEL);
+ imageResource = EmptyContentView.NO_IMAGE;
+ actionLabelResource = EmptyContentView.NO_LABEL;
+ descriptionResource = EmptyContentView.NO_LABEL;
+ listener = null;
+ mPermissionToRequest = null;
+ }
+
+ mEmptyView.setImage(imageResource);
+ mEmptyView.setActionLabel(actionLabelResource);
+ mEmptyView.setDescription(descriptionResource);
+ if (listener != null) {
+ mEmptyView.setActionClickedListener(listener);
}
}
}
@@ -104,17 +133,20 @@ public class RegularSearchFragment extends SearchFragment
return;
}
- requestPermissions(new String[] {READ_CONTACTS}, READ_CONTACTS_PERMISSION_REQUEST_CODE);
+ if (READ_CONTACTS.equals(mPermissionToRequest)
+ || ACCESS_FINE_LOCATION.equals(mPermissionToRequest)) {
+ requestPermissions(new String[] {mPermissionToRequest}, PERMISSION_REQUEST_CODE);
+ }
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions,
int[] grantResults) {
- if (requestCode == READ_CONTACTS_PERMISSION_REQUEST_CODE) {
+ if (requestCode == PERMISSION_REQUEST_CODE) {
setupEmptyView();
if (grantResults != null && grantResults.length == 1
&& PackageManager.PERMISSION_GRANTED == grantResults[0]) {
- PermissionsUtil.notifyPermissionGranted(getActivity(), READ_CONTACTS);
+ PermissionsUtil.notifyPermissionGranted(getActivity(), mPermissionToRequest);
}
}
}