use of com.android.contacts.common.list.DirectoryPartition in project android_packages_apps_Dialer by LineageOS.
the class LookupProvider method getExtendedDirectories.
public static List<DirectoryPartition> getExtendedDirectories(Context context) {
ArrayList<DirectoryPartition> list = new ArrayList<DirectoryPartition>();
if (LookupSettings.isPeopleLookupEnabled(context)) {
DirectoryPartition dp = new DirectoryPartition(false, true);
dp.setContentUri(PEOPLE_LOOKUP_URI.toString());
dp.setLabel(context.getString(R.string.people));
dp.setPriorityDirectory(false);
dp.setPhotoSupported(true);
dp.setDisplayNumber(false);
dp.setResultLimit(3);
list.add(dp);
} else {
Log.i(TAG, "Forward lookup (people) is disabled");
}
if (LookupSettings.isForwardLookupEnabled(context)) {
DirectoryPartition dp = new DirectoryPartition(false, true);
dp.setContentUri(NEARBY_LOOKUP_URI.toString());
dp.setLabel(context.getString(R.string.nearby_places));
dp.setPriorityDirectory(false);
dp.setPhotoSupported(true);
dp.setDisplayNumber(false);
dp.setResultLimit(3);
list.add(dp);
} else {
Log.i(TAG, "Forward lookup (nearby places) is disabled");
}
return list;
}
use of com.android.contacts.common.list.DirectoryPartition in project android_packages_apps_Dialer by MoKee.
the class ExtendedLookupDirectories method getExtendedDirectories.
/**
* Return a list of extended directories to add. May return null if no directories are to be
* added.
*/
@Override
public List<DirectoryPartition> getExtendedDirectories(Context context) {
ArrayList<DirectoryPartition> list = new ArrayList<DirectoryPartition>();
if (LookupSettings.isPeopleLookupEnabled(context)) {
DirectoryPartition dp = new DirectoryPartition(false, true);
dp.setContentUri(LookupProvider.PEOPLE_LOOKUP_URI.toString());
dp.setLabel(context.getString(R.string.people));
dp.setPriorityDirectory(false);
dp.setPhotoSupported(true);
dp.setDisplayNumber(false);
dp.setResultLimit(3);
list.add(dp);
} else {
Log.i(TAG, "Forward lookup (people) is disabled");
}
if (LookupSettings.isForwardLookupEnabled(context)) {
DirectoryPartition dp = new DirectoryPartition(false, true);
dp.setContentUri(LookupProvider.NEARBY_LOOKUP_URI.toString());
dp.setLabel(context.getString(R.string.nearby_places));
dp.setPriorityDirectory(false);
dp.setPhotoSupported(true);
dp.setDisplayNumber(false);
dp.setResultLimit(3);
list.add(dp);
} else {
Log.i(TAG, "Forward lookup (nearby places) is disabled");
}
return list;
}
use of com.android.contacts.common.list.DirectoryPartition in project packages_apps_Contacts by AOKP.
the class ContactBrowseListFragment method checkSelection.
private void checkSelection() {
if (mSelectionVerified) {
return;
}
if (mRefreshingContactUri) {
return;
}
if (isLoadingDirectoryList()) {
return;
}
ContactListAdapter adapter = getAdapter();
if (adapter == null) {
return;
}
boolean directoryLoading = true;
int count = adapter.getPartitionCount();
for (int i = 0; i < count; i++) {
Partition partition = adapter.getPartition(i);
if (partition instanceof DirectoryPartition) {
DirectoryPartition directory = (DirectoryPartition) partition;
if (directory.getDirectoryId() == mSelectedContactDirectoryId) {
directoryLoading = directory.isLoading();
break;
}
}
}
if (directoryLoading) {
return;
}
adapter.setSelectedContact(mSelectedContactDirectoryId, mSelectedContactLookupKey, mSelectedContactId);
final int selectedPosition = adapter.getSelectedContactPosition();
if (selectedPosition != -1) {
mLastSelectedPosition = selectedPosition;
} else {
if (isSearchMode()) {
if (mDelaySelection) {
selectFirstFoundContactAfterDelay();
if (mListener != null) {
mListener.onSelectionChange();
}
return;
}
} else if (mSelectionRequired) {
// A specific contact was requested, but it's not in the loaded list.
// Try reconfiguring and reloading the list that will hopefully contain
// the requested contact. Only take one attempt to avoid an infinite loop
// in case the contact cannot be found at all.
mSelectionRequired = false;
// FILTER_TYPE cases.
if (mFilter != null && (mFilter.filterType == ContactListFilter.FILTER_TYPE_SINGLE_CONTACT || mFilter.filterType == ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS)) {
reloadData();
} else {
// Otherwise, call the listener, which will adjust the filter.
notifyInvalidSelection();
}
return;
} else if (mFilter != null && mFilter.filterType == ContactListFilter.FILTER_TYPE_SINGLE_CONTACT) {
// If we were trying to load a specific contact, but that contact no longer
// exists, call the listener, which will adjust the filter.
notifyInvalidSelection();
return;
}
saveSelectedUri(null);
selectDefaultContact();
}
mSelectionRequired = false;
mSelectionVerified = true;
if (mSelectionPersistenceRequested) {
saveSelectedUri(mSelectedContactUri);
mSelectionPersistenceRequested = false;
}
if (mSelectionToScreenRequested) {
requestSelectionToScreen(selectedPosition);
}
getListView().invalidateViews();
if (mListener != null) {
mListener.onSelectionChange();
}
}
use of com.android.contacts.common.list.DirectoryPartition in project android_packages_apps_Dialer by LineageOS.
the class RegularSearchListAdapter method getContactInfo.
public CachedContactInfo getContactInfo(CachedNumberLookupService lookupService, int position) {
ContactInfo info = new ContactInfo();
CachedContactInfo cacheInfo = lookupService.buildCachedContactInfo(info);
final Cursor item = (Cursor) getItem(position);
if (item != null) {
final DirectoryPartition partition = (DirectoryPartition) getPartition(getPartitionForPosition(position));
final long directoryId = partition.getDirectoryId();
final boolean isExtendedDirectory = isExtendedDirectory(directoryId);
info.name = item.getString(PhoneQuery.DISPLAY_NAME);
info.type = item.getInt(PhoneQuery.PHONE_TYPE);
info.label = item.getString(PhoneQuery.PHONE_LABEL);
info.number = item.getString(PhoneQuery.PHONE_NUMBER);
final String photoUriStr = item.getString(PhoneQuery.PHOTO_URI);
info.photoUri = photoUriStr == null ? null : Uri.parse(photoUriStr);
/*
* An extended directory is custom directory in the app, but not a directory provided by
* framework. So it can't be USER_TYPE_WORK.
*
* When a search result is selected, RegularSearchFragment calls getContactInfo and
* cache the resulting @{link ContactInfo} into local db. Set usertype to USER_TYPE_WORK
* only if it's NOT extended directory id and is enterprise directory.
*/
info.userType = !isExtendedDirectory && DirectoryCompat.isEnterpriseDirectoryId(directoryId) ? ContactsUtils.USER_TYPE_WORK : ContactsUtils.USER_TYPE_CURRENT;
cacheInfo.setLookupKey(item.getString(PhoneQuery.LOOKUP_KEY));
final String sourceName = partition.getLabel();
if (isExtendedDirectory) {
cacheInfo.setExtendedSource(sourceName, directoryId);
} else {
cacheInfo.setDirectorySource(sourceName, directoryId);
}
}
return cacheInfo;
}
use of com.android.contacts.common.list.DirectoryPartition in project android_packages_apps_Dialer by MoKee.
the class RegularSearchListAdapter method getContactInfo.
public CachedContactInfo getContactInfo(CachedNumberLookupService lookupService, int position) {
ContactInfo info = new ContactInfo();
CachedContactInfo cacheInfo = lookupService.buildCachedContactInfo(info);
final Cursor item = (Cursor) getItem(position);
if (item != null) {
final DirectoryPartition partition = (DirectoryPartition) getPartition(getPartitionForPosition(position));
final long directoryId = partition.getDirectoryId();
final boolean isExtendedDirectory = isExtendedDirectory(directoryId);
info.name = item.getString(PhoneQuery.DISPLAY_NAME);
info.type = item.getInt(PhoneQuery.PHONE_TYPE);
info.label = item.getString(PhoneQuery.PHONE_LABEL);
info.number = item.getString(PhoneQuery.PHONE_NUMBER);
final String photoUriStr = item.getString(PhoneQuery.PHOTO_URI);
info.photoUri = photoUriStr == null ? null : Uri.parse(photoUriStr);
/*
* An extended directory is custom directory in the app, but not a directory provided by
* framework. So it can't be USER_TYPE_WORK.
*
* When a search result is selected, RegularSearchFragment calls getContactInfo and
* cache the resulting @{link ContactInfo} into local db. Set usertype to USER_TYPE_WORK
* only if it's NOT extended directory id and is enterprise directory.
*/
info.userType = !isExtendedDirectory && DirectoryCompat.isEnterpriseDirectoryId(directoryId) ? ContactsUtils.USER_TYPE_WORK : ContactsUtils.USER_TYPE_CURRENT;
cacheInfo.setLookupKey(item.getString(PhoneQuery.LOOKUP_KEY));
final String sourceName = partition.getLabel();
if (isExtendedDirectory) {
cacheInfo.setExtendedSource(sourceName, directoryId);
} else {
cacheInfo.setDirectorySource(sourceName, directoryId);
}
}
return cacheInfo;
}
Aggregations