本文整理汇总了Java中org.thoughtcrime.securesms.contacts.ContactAccessor类的典型用法代码示例。如果您正苦于以下问题:Java ContactAccessor类的具体用法?Java ContactAccessor怎么用?Java ContactAccessor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ContactAccessor类属于org.thoughtcrime.securesms.contacts包,在下文中一共展示了ContactAccessor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeIdentitySelection
import org.thoughtcrime.securesms.contacts.ContactAccessor; //导入依赖的package包/类
private void initializeIdentitySelection() {
ContactIdentityManager identity = ContactIdentityManager.getInstance(getActivity());
Preference preference = this.findPreference(TextSecurePreferences.IDENTITY_PREF);
if (identity.isSelfIdentityAutoDetected()) {
this.getPreferenceScreen().removePreference(preference);
} else {
Uri contactUri = identity.getSelfIdentityUri();
if (contactUri != null) {
String contactName = ContactAccessor.getInstance().getNameFromContact(getActivity(), contactUri);
preference.setSummary(String.format(getString(R.string.ApplicationPreferencesActivity_currently_s),
contactName));
}
preference.setOnPreferenceClickListener(new IdentityPreferenceClickListener());
}
}
示例2: generateFullContactUpdate
import org.thoughtcrime.securesms.contacts.ContactAccessor; //导入依赖的package包/类
private void generateFullContactUpdate()
throws IOException, UntrustedIdentityException, NetworkException
{
SignalServiceMessageSender messageSender = messageSenderFactory.create();
File contactDataFile = createTempFile("multidevice-contact-update");
try {
DeviceContactsOutputStream out = new DeviceContactsOutputStream(new FileOutputStream(contactDataFile));
Collection<ContactData> contacts = ContactAccessor.getInstance().getContactsWithPush(context);
for (ContactData contactData : contacts) {
Uri contactUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, String.valueOf(contactData.id));
String number = contactData.numbers.get(0).number;
Optional<String> name = Optional.fromNullable(contactData.name);
Optional<String> color = getColor(number);
out.write(new DeviceContact(number, name, getAvatar(contactUri), color));
}
out.close();
sendUpdate(messageSender, contactDataFile);
} finally {
if (contactDataFile != null) contactDataFile.delete();
}
}
示例3: handleSelectAll
import org.thoughtcrime.securesms.contacts.ContactAccessor; //导入依赖的package包/类
private void handleSelectAll() {
selectedContacts.clear();
Cursor cursor = null;
try {
cursor = ContactAccessor.getInstance().getCursorForContactsWithNumbers(getActivity());
while (cursor != null && cursor.moveToNext()) {
ContactData contactData = ContactAccessor.getInstance().getContactData(getActivity(), cursor);
if (contactData.numbers.isEmpty()) continue;
else if (contactData.numbers.size() == 1) addSingleNumberContact(contactData);
else addMultipleNumberContact(contactData, null);
}
} finally {
if (cursor != null)
cursor.close();
}
((CursorAdapter)getListView().getAdapter()).notifyDataSetChanged();
}
示例4: contactDataToRecipients
import org.thoughtcrime.securesms.contacts.ContactAccessor; //导入依赖的package包/类
private Recipients contactDataToRecipients(ContactData contactData) {
if (contactData == null || contactData.numbers == null) return null;
Recipients recipients = new Recipients(new LinkedList<Recipient>());
for (ContactAccessor.NumberData numberData : contactData.numbers) {
if (NumberUtil.isValidSmsOrEmailOrGroup(numberData.number)) {
try {
Recipients recipientsForNumber = RecipientFactory.getRecipientsFromString(NewConversationActivity.this,
numberData.number,
false);
recipients.getRecipientsList().addAll(recipientsForNumber.getRecipientsList());
} catch (RecipientFormattingException rfe) {
Log.w(TAG, "Caught RecipientFormattingException when trying to convert a selected number to a Recipient.", rfe);
}
}
}
return recipients;
}
示例5: set
import org.thoughtcrime.securesms.contacts.ContactAccessor; //导入依赖的package包/类
public void set(long id, String name, String label, String number, int type, long date) {
if( name == null ) {
name = ContactAccessor.getInstance().getNameForNumber(getActivity(), number);
}
this.line1.setText((name == null || name.equals("")) ? number : name);
this.number.setText((name == null || name.equals("")) ? "" : number);
this.label.setText(label);
this.date.setText(DateUtils.getRelativeDateTimeString(context, date, System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE));
if (type == Calls.INCOMING_TYPE || type == RedPhoneCallTypes.INCOMING) callTypeIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_call_log_list_incoming_call));
else if (type == Calls.OUTGOING_TYPE || type == RedPhoneCallTypes.OUTGOING) callTypeIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_call_log_list_outgoing_call));
else if (type == Calls.MISSED_TYPE || type == RedPhoneCallTypes.MISSED) callTypeIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_call_log_list_missed_call));
this.contactData = new ContactData(id, name);
this.contactData.numbers.add(new NumberData(null, number));
if (selectedContacts.containsKey(id))
this.line1.setChecked(true);
else
this.line1.setChecked(false);
}
示例6: addAttachmentContactInfo
import org.thoughtcrime.securesms.contacts.ContactAccessor; //导入依赖的package包/类
private void addAttachmentContactInfo(Uri contactUri) {
ContactAccessor contactDataList = ContactAccessor.getInstance();
ContactData contactData = contactDataList.getContactData(this, contactUri);
if (contactData.numbers.size() == 1) composeText.append(contactData.numbers.get(0).number);
else if (contactData.numbers.size() > 1) selectContactInfo(contactData);
}
示例7: addContacts
import org.thoughtcrime.securesms.contacts.ContactAccessor; //导入依赖的package包/类
public void addContacts(List<ContactAccessor.ContactData> contacts) {
for (ContactAccessor.ContactData contact : contacts) {
for (ContactAccessor.NumberData number : contact.numbers) {
addRecipient(contact.name, number.number);
}
}
}
示例8: generateFullContactUpdate
import org.thoughtcrime.securesms.contacts.ContactAccessor; //导入依赖的package包/类
private void generateFullContactUpdate()
throws IOException, UntrustedIdentityException, NetworkException
{
SignalServiceMessageSender messageSender = messageSenderFactory.create();
File contactDataFile = createTempFile("multidevice-contact-update");
try {
DeviceContactsOutputStream out = new DeviceContactsOutputStream(new FileOutputStream(contactDataFile));
Collection<ContactData> contacts = ContactAccessor.getInstance().getContactsWithPush(context);
for (ContactData contactData : contacts) {
Uri contactUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, String.valueOf(contactData.id));
String number = Util.canonicalizeNumber(context, contactData.numbers.get(0).number);
Recipient recipient = RecipientFactory.getRecipientsFromString(context, number, true).getPrimaryRecipient();
Optional<IdentityDatabase.IdentityRecord> identity = DatabaseFactory.getIdentityDatabase(context).getIdentity(recipient.getRecipientId());
Optional<VerifiedMessage> verified = getVerifiedMessage(recipient, identity);
Optional<String> name = Optional.fromNullable(contactData.name);
Optional<String> color = getColor(number);
out.write(new DeviceContact(number, name, getAvatar(contactUri), color, verified));
}
out.close();
sendUpdate(messageSender, contactDataFile, true);
} catch(InvalidNumberException e) {
Log.w(TAG, e);
} finally {
if (contactDataFile != null) contactDataFile.delete();
}
}
示例9: onActivityResult
import org.thoughtcrime.securesms.contacts.ContactAccessor; //导入依赖的package包/类
@Override
public void onActivityResult(int reqCode, int resultCode, Intent data) {
super.onActivityResult(reqCode, resultCode, data);
if (data == null || resultCode != Activity.RESULT_OK)
return;
switch (reqCode) {
case PICK_CONTACT:
List<ContactData> selected = data.getParcelableArrayListExtra("contacts");
for (ContactData contact : selected) {
for (ContactAccessor.NumberData numberData : contact.numbers) {
try {
Recipient recipient = RecipientFactory.getRecipientsFromString(this, numberData.number, false)
.getPrimaryRecipient();
if (!selectedContacts.contains(recipient)
&& (existingContacts == null || !existingContacts.contains(recipient))) {
addSelectedContact(recipient);
}
} catch (RecipientFormattingException e) {
Log.w(TAG, e);
}
}
}
syncAdapterWithSelectedContacts();
break;
case PICK_AVATAR:
new DecodeCropAndSetAsyncTask(data.getData()).execute();
break;
}
}
示例10: addContact
import org.thoughtcrime.securesms.contacts.ContactAccessor; //导入依赖的package包/类
private void addContact(DataHolder data) {
final ContactData contactData = new ContactData(data.id, data.name);
final CharSequence label = ContactsContract.CommonDataKinds.Phone.getTypeLabel(getResources(),
data.numberType, "");
contactData.numbers.add(new ContactAccessor.NumberData(label.toString(), data.number));
if (multi) {
selectedContacts.put(contactData.id, contactData);
}
if (onContactSelectedListener != null) {
onContactSelectedListener.onContactSelected(contactData);
}
}
示例11: onCreateLoader
import org.thoughtcrime.securesms.contacts.ContactAccessor; //导入依赖的package包/类
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
if (getActivity().getIntent().getBooleanExtra(PushContactSelectionActivity.PUSH_ONLY_EXTRA, false)) {
return ContactAccessor.getInstance().getCursorLoaderForPushContacts(getActivity(), cursorFilter);
} else {
return ContactAccessor.getInstance().getCursorLoaderForContacts(getActivity(), cursorFilter);
}
}
示例12: getCursor
import org.thoughtcrime.securesms.contacts.ContactAccessor; //导入依赖的package包/类
@Override
public Cursor getCursor() {
if (filter != null && filter.trim().length() != 0) {
List<String> numbers = ContactAccessor.getInstance()
.getNumbersForThreadSearchFilter(filter, context.getContentResolver());
return DatabaseFactory.getThreadDatabase(context).getFilteredConversationList(numbers);
} else {
return DatabaseFactory.getThreadDatabase(context).getConversationList();
}
}
示例13: getSelectedContacts
import org.thoughtcrime.securesms.contacts.ContactAccessor; //导入依赖的package包/类
public List<ContactData> getSelectedContacts(Context context) {
List<ContactData> contacts = new LinkedList<ContactData>();
for (GroupData groupData : selectedGroups.values()) {
List<ContactData> contactDataList = ContactAccessor.getInstance()
.getGroupMembership(context, groupData.id);
contacts.addAll(contactDataList);
}
return contacts;
}
示例14: getFilteredConversationList
import org.thoughtcrime.securesms.contacts.ContactAccessor; //导入依赖的package包/类
private Cursor getFilteredConversationList(String filter) {
List<String> numbers = ContactAccessor.getInstance().getNumbersForThreadSearchFilter(context, filter);
return DatabaseFactory.getThreadDatabase(context).getFilteredConversationList(numbers);
}
示例15: handleIncomingCall
import org.thoughtcrime.securesms.contacts.ContactAccessor; //导入依赖的package包/类
private void handleIncomingCall(final Intent intent) {
Log.w(TAG, "handleIncomingCall()");
if (callState != CallState.STATE_IDLE) throw new IllegalStateException("Incoming on non-idle");
final String offer = intent.getStringExtra(EXTRA_REMOTE_DESCRIPTION);
this.callState = CallState.STATE_ANSWERING;
this.callId = intent.getLongExtra(EXTRA_CALL_ID, -1);
this.recipient = getRemoteRecipient(intent);
if (isIncomingMessageExpired(intent)) {
insertMissedCall(this.recipient, true);
terminate();
return;
}
timeoutExecutor.schedule(new TimeoutRunnable(this.callId), 2, TimeUnit.MINUTES);
initializeVideo();
retrieveTurnServers().addListener(new SuccessOnlyListener<List<PeerConnection.IceServer>>(this.callState, this.callId) {
@Override
public void onSuccessContinue(List<PeerConnection.IceServer> result) {
try {
boolean isSystemContact = ContactAccessor.getInstance().isSystemContact(WebRtcCallService.this, recipient.getNumber());
boolean isAlwaysTurn = TextSecurePreferences.isTurnOnly(WebRtcCallService.this);
WebRtcCallService.this.peerConnection = new PeerConnectionWrapper(WebRtcCallService.this, peerConnectionFactory, WebRtcCallService.this, localRenderer, result, !isSystemContact || isAlwaysTurn);
WebRtcCallService.this.peerConnection.setRemoteDescription(new SessionDescription(SessionDescription.Type.OFFER, offer));
WebRtcCallService.this.lockManager.updatePhoneState(LockManager.PhoneState.PROCESSING);
SessionDescription sdp = WebRtcCallService.this.peerConnection.createAnswer(new MediaConstraints());
Log.w(TAG, "Answer SDP: " + sdp.description);
WebRtcCallService.this.peerConnection.setLocalDescription(sdp);
ListenableFutureTask<Boolean> listenableFutureTask = sendMessage(recipient, SignalServiceCallMessage.forAnswer(new AnswerMessage(WebRtcCallService.this.callId, sdp.description)));
listenableFutureTask.addListener(new FailureListener<Boolean>(WebRtcCallService.this.callState, WebRtcCallService.this.callId) {
@Override
public void onFailureContinue(Throwable error) {
Log.w(TAG, error);
terminate();
}
});
} catch (PeerConnectionException e) {
Log.w(TAG, e);
terminate();
}
}
});
}