当前位置: 首页>>代码示例>>Java>>正文


Java ContactAccessor类代码示例

本文整理汇总了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());
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:20,代码来源:AdvancedPreferenceFragment.java

示例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();
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:27,代码来源:MultiDeviceContactUpdateJob.java

示例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();
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:23,代码来源:ContactSelectionListFragment.java

示例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;
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:18,代码来源:NewConversationActivity.java

示例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);
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:23,代码来源:ContactSelectionRecentFragment.java

示例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);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:8,代码来源:ConversationActivity.java

示例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);
    }
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:8,代码来源:SingleRecipientPanel.java

示例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();
  }
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:31,代码来源:MultiDeviceContactUpdateJob.java

示例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;
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:34,代码来源:GroupCreateActivity.java

示例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);
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:13,代码来源:PushContactSelectionListFragment.java

示例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);
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:9,代码来源:PushContactSelectionListFragment.java

示例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();
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:12,代码来源:ConversationListLoader.java

示例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;
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:13,代码来源:ContactSelectionGroupsFragment.java

示例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);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:5,代码来源:ConversationListLoader.java

示例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();
      }
    }
  });
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:52,代码来源:WebRtcCallService.java


注:本文中的org.thoughtcrime.securesms.contacts.ContactAccessor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。