當前位置: 首頁>>代碼示例>>Java>>正文


Java TextSecurePreferences.getLocalNumber方法代碼示例

本文整理匯總了Java中org.thoughtcrime.securesms.util.TextSecurePreferences.getLocalNumber方法的典型用法代碼示例。如果您正苦於以下問題:Java TextSecurePreferences.getLocalNumber方法的具體用法?Java TextSecurePreferences.getLocalNumber怎麽用?Java TextSecurePreferences.getLocalNumber使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.thoughtcrime.securesms.util.TextSecurePreferences的用法示例。


在下文中一共展示了TextSecurePreferences.getLocalNumber方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleExpirationUpdate

import org.thoughtcrime.securesms.util.TextSecurePreferences; //導入方法依賴的package包/類
private void handleExpirationUpdate(@NonNull MasterSecretUnion masterSecret,
                                    @NonNull SignalServiceEnvelope envelope,
                                    @NonNull SignalServiceDataMessage message,
                                    @NonNull Optional<Long> smsMessageId)
    throws MmsException
{
  MmsDatabase          database     = DatabaseFactory.getMmsDatabase(context);
  String               localNumber  = TextSecurePreferences.getLocalNumber(context);
  Recipients           recipients   = getMessageDestination(envelope, message);
  IncomingMediaMessage mediaMessage = new IncomingMediaMessage(masterSecret, envelope.getSource(),
                                                               localNumber, message.getTimestamp(), -1,
                                                               message.getExpiresInSeconds() * 1000, true,
                                                               Optional.fromNullable(envelope.getRelay()),
                                                               Optional.<String>absent(), message.getGroupInfo(),
                                                               Optional.<List<SignalServiceAttachment>>absent());



  database.insertSecureDecryptedMessageInbox(masterSecret, mediaMessage, -1);

  DatabaseFactory.getRecipientPreferenceDatabase(context).setExpireMessages(recipients, message.getExpiresInSeconds());

  if (smsMessageId.isPresent()) {
    DatabaseFactory.getSmsDatabase(context).deleteMessage(smsMessageId.get());
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:27,代碼來源:PushDecryptJob.java

示例2: isTrustedIdentity

import org.thoughtcrime.securesms.util.TextSecurePreferences; //導入方法依賴的package包/類
@Override
public boolean isTrustedIdentity(SignalProtocolAddress address, IdentityKey identityKey, Direction direction) {
  synchronized (LOCK) {
    IdentityDatabase identityDatabase = DatabaseFactory.getIdentityDatabase(context);
    long             recipientId      = RecipientFactory.getRecipientsFromString(context, address.getName(), true).getPrimaryRecipient().getRecipientId();
    String           ourNumber        = TextSecurePreferences.getLocalNumber(context);
    long             ourRecipientId   = RecipientFactory.getRecipientsFromString(context, ourNumber, true).getPrimaryRecipient().getRecipientId();

    if (ourRecipientId == recipientId || ourNumber.equals(address.getName())) {
      return identityKey.equals(IdentityKeyUtil.getIdentityKey(context));
    }

    switch (direction) {
      case SENDING:   return isTrustedForSending(identityKey, identityDatabase.getIdentity(recipientId));
      case RECEIVING: return true;
      default:        throw new AssertionError("Unknown direction: " + direction);
    }
  }
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:20,代碼來源:TextSecureIdentityKeyStore.java

示例3: removeLocalRecipient

import org.thoughtcrime.securesms.util.TextSecurePreferences; //導入方法依賴的package包/類
private static void removeLocalRecipient(Context context, Set<Recipient> recipients) {
  String localNumber = TextSecurePreferences.getLocalNumber(context);
  for (Recipient recipient : recipients) {
    if(localNumber.equals(Util.canonicalizeNumber(context, recipient.getNumber(), recipient.getNumber()))) {
      recipients.remove(recipients.remove(recipient));
      break;
    }
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:10,代碼來源:GroupManager.java

示例4: display

import org.thoughtcrime.securesms.util.TextSecurePreferences; //導入方法依賴的package包/類
public void display() {
  String localNumber   = TextSecurePreferences.getLocalNumber(activity);
  boolean isLocalOwner = activity.getAdapter().isOwnerNumber(localNumber);
  boolean isLocalAdmin = activity.getAdapter().isAdminNumber(localNumber);
  if(!Util.isOwnNumber(activity, wrapper.getRecipient().getNumber()) &&
          !wrapper.isOwner() && (isLocalOwner || isLocalAdmin)) {
    List<String> actions = new LinkedList<>();
    actions.add(activity.getString(R.string.GroupCreateActivity_menu_remove_member,
            wrapper.getRecipientNameOrNumber()));
    if(isLocalOwner) {
      if(wrapper.isAdmin()) {
        actions.add(activity.getString(R.string.GroupCreateActivity_menu_revoke_group_admin));
      } else {
        actions.add(activity.getString(R.string.GroupCreateActivity_menu_make_group_admin));
      }
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setCancelable(true);
    builder.setItems(actions.toArray(new String[actions.size()]), new DialogInterface.OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int which) {
        switch (which) {
          case 0:
            handleRemoveRecipient(wrapper.getRecipient());
            break;
          case 1:
            if(wrapper.isAdmin()) {
              handleRevokeAdmin(wrapper.getRecipient().getNumber());
            } else {
              handleMakeAdmin(wrapper.getRecipient().getNumber());
            }
            break;
        }
      }
    });
    builder.show();
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:39,代碼來源:GroupCreateActivity.java

示例5: isLocalNumber

import org.thoughtcrime.securesms.util.TextSecurePreferences; //導入方法依賴的package包/類
public boolean isLocalNumber(Recipient recipient) {
  try {
    String localNumber = TextSecurePreferences.getLocalNumber(context);
    String e164Number  = Util.canonicalizeNumber(context, recipient.getNumber());

    return e164Number != null && e164Number.equals(localNumber);
  } catch (InvalidNumberException e) {
    Log.w(TAG, e);
    return false;
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:12,代碼來源:GroupMembersDialog.java

示例6: getGroupMembers

import org.thoughtcrime.securesms.util.TextSecurePreferences; //導入方法依賴的package包/類
public @NonNull Recipients getGroupMembers(byte[] groupId, boolean includeSelf) {
  String          localNumber = TextSecurePreferences.getLocalNumber(context);
  List<String>    members     = getCurrentMembers(groupId);
  List<Recipient> recipients  = new LinkedList<>();

  for (String member : members) {
    if (!includeSelf && member.equals(localNumber))
      continue;

    recipients.addAll(RecipientFactory.getRecipientsFromString(context, member, false)
                                      .getRecipientsList());
  }

  return RecipientFactory.getRecipientsFor(context, recipients, false);
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:16,代碼來源:GroupDatabase.java

示例7: getCanonicalAddressId

import org.thoughtcrime.securesms.util.TextSecurePreferences; //導入方法依賴的package包/類
public long getCanonicalAddressId(@NonNull String address) {
  try {
    long   canonicalAddressId;
    String formattedAddress;

    if ((formattedAddress = formattedAddressCache.get(address)) == null) {
      String localNumber = TextSecurePreferences.getLocalNumber(context);

      if (!isNumberAddress(address)                        ||
          !TextSecurePreferences.isPushRegistered(context) ||
          ShortCodeUtil.isShortCode(localNumber, address))
      {
        formattedAddress = address;
      } else {
        formattedAddress = PhoneNumberFormatter.formatNumber(address, localNumber);
      }

      formattedAddressCache.put(address, formattedAddress);
    }

    if ((canonicalAddressId = getCanonicalAddressFromCache(formattedAddress)) == -1) {
      canonicalAddressId = getCanonicalAddressIdFromDatabase(formattedAddress);
    }

    idCache.put(canonicalAddressId, formattedAddress);
    addressCache.put(formattedAddress, canonicalAddressId);

    return canonicalAddressId;
  } catch (InvalidNumberException e) {
    throw new AssertionError(e);
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:33,代碼來源:CanonicalAddressDatabase.java

示例8: handleMediaMessage

import org.thoughtcrime.securesms.util.TextSecurePreferences; //導入方法依賴的package包/類
private void handleMediaMessage(@NonNull MasterSecretUnion masterSecret,
                                @NonNull SignalServiceEnvelope envelope,
                                @NonNull SignalServiceDataMessage message,
                                @NonNull Optional<Long> smsMessageId)
    throws MmsException
{
  MmsDatabase          database     = DatabaseFactory.getMmsDatabase(context);
  String               localNumber  = TextSecurePreferences.getLocalNumber(context);
  Recipients           recipients   = getMessageDestination(envelope, message);
  IncomingMediaMessage mediaMessage = new IncomingMediaMessage(masterSecret, envelope.getSource(),
                                                               localNumber, message.getTimestamp(), -1,
                                                               message.getExpiresInSeconds() * 1000, false,
                                                               Optional.fromNullable(envelope.getRelay()),
                                                               message.getBody(),
                                                               message.getGroupInfo(),
                                                               message.getAttachments());

  if (message.getExpiresInSeconds() != recipients.getExpireMessages()) {
    handleExpirationUpdate(masterSecret, envelope, message, Optional.<Long>absent());
  }

  Optional<InsertResult> insertResult = database.insertSecureDecryptedMessageInbox(masterSecret, mediaMessage, -1);

  if (insertResult.isPresent()) {
    List<DatabaseAttachment> attachments = DatabaseFactory.getAttachmentDatabase(context).getAttachmentsForMessage(insertResult.get().getMessageId());

    for (DatabaseAttachment attachment : attachments) {
      ApplicationContext.getInstance(context)
                        .getJobManager()
                        .add(new AttachmentDownloadJob(context, insertResult.get().getMessageId(),
                                                       attachment.getAttachmentId()));
    }

    if (smsMessageId.isPresent()) {
      DatabaseFactory.getSmsDatabase(context).deleteMessage(smsMessageId.get());
    }

    MessageNotifier.updateNotification(context, masterSecret.getMasterSecret().orNull(), insertResult.get().getThreadId());
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:41,代碼來源:PushDecryptJob.java

示例9: isLocalNumber

import org.thoughtcrime.securesms.util.TextSecurePreferences; //導入方法依賴的package包/類
private boolean isLocalNumber(Recipient recipient) {
  try {
    String localNumber = TextSecurePreferences.getLocalNumber(context);
    String e164Number  = Util.canonicalizeNumber(context, recipient.getNumber());

    return e164Number != null && e164Number.equals(localNumber);
  } catch (InvalidNumberException e) {
    Log.w(TAG, e);
    return false;
  }
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:12,代碼來源:GroupMembersDialog.java

示例10: createManager

import org.thoughtcrime.securesms.util.TextSecurePreferences; //導入方法依賴的package包/類
public static SignalServiceAccountManager createManager(Context context) {
  return new SignalServiceAccountManager(new SignalServiceNetworkAccess(context).getConfiguration(context),
                                         TextSecurePreferences.getLocalNumber(context),
                                         TextSecurePreferences.getPushServerPassword(context),
                                         BuildConfig.USER_AGENT);
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:7,代碼來源:AccountManagerFactory.java

示例11: getConfiguration

import org.thoughtcrime.securesms.util.TextSecurePreferences; //導入方法依賴的package包/類
public SignalServiceUrl[] getConfiguration(Context context) {
  String localNumber = TextSecurePreferences.getLocalNumber(context);
  return getConfiguration(localNumber);
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:5,代碼來源:SignalServiceNetworkAccess.java

示例12: provideSignalAccountManager

import org.thoughtcrime.securesms.util.TextSecurePreferences; //導入方法依賴的package包/類
@Provides SignalServiceAccountManager provideSignalAccountManager() {
  return new SignalServiceAccountManager(networkAccess.getConfiguration(context),
                                         TextSecurePreferences.getLocalNumber(context),
                                         TextSecurePreferences.getPushServerPassword(context),
                                         BuildConfig.USER_AGENT);
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:7,代碼來源:SignalCommunicationModule.java

示例13: getUser

import org.thoughtcrime.securesms.util.TextSecurePreferences; //導入方法依賴的package包/類
@Override
public String getUser() {
  return TextSecurePreferences.getLocalNumber(context);
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:5,代碼來源:SignalCommunicationModule.java

示例14: handleMediaMessage

import org.thoughtcrime.securesms.util.TextSecurePreferences; //導入方法依賴的package包/類
private void handleMediaMessage(@NonNull MasterSecretUnion masterSecret,
                                @NonNull SignalServiceEnvelope envelope,
                                @NonNull SignalServiceDataMessage message,
                                @NonNull Optional<Long> smsMessageId)
    throws MmsException
{
  MmsDatabase          database     = DatabaseFactory.getMmsDatabase(context);
  String               localNumber  = TextSecurePreferences.getLocalNumber(context);
  Recipients           recipients   = getMessageDestination(envelope, message);
  IncomingMediaMessage mediaMessage = new IncomingMediaMessage(masterSecret, envelope.getSource(),
                                                               localNumber, message.getTimestamp(), -1,
                                                               message.getExpiresInSeconds() * 1000, false,
                                                               Optional.fromNullable(envelope.getRelay()),
                                                               message.getBody(),
                                                               message.getGroupInfo(),
                                                               message.getAttachments());

  if (message.getExpiresInSeconds() != recipients.getExpireMessages()) {
    handleExpirationUpdate(masterSecret, envelope, message, Optional.<Long>absent());
  }

  Optional<InsertResult> insertResult = database.insertSecureDecryptedMessageInbox(masterSecret, mediaMessage, -1);

  if (insertResult.isPresent()) {
    List<DatabaseAttachment> attachments = DatabaseFactory.getAttachmentDatabase(context).getAttachmentsForMessage(null, insertResult.get().getMessageId());

    for (DatabaseAttachment attachment : attachments) {
      ApplicationContext.getInstance(context)
                        .getJobManager()
                        .add(new AttachmentDownloadJob(context, insertResult.get().getMessageId(),
                                                       attachment.getAttachmentId()));

      if (!masterSecret.getMasterSecret().isPresent()) {
        ApplicationContext.getInstance(context)
                          .getJobManager()
                          .add(new AttachmentFileNameJob(context, masterSecret.getAsymmetricMasterSecret().get(), attachment, mediaMessage));
      }
    }

    if (smsMessageId.isPresent()) {
      DatabaseFactory.getSmsDatabase(context).deleteMessage(smsMessageId.get());
    }

    MessageNotifier.updateNotification(context, masterSecret.getMasterSecret().orNull(), insertResult.get().getThreadId());
  }
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:47,代碼來源:PushDecryptJob.java


注:本文中的org.thoughtcrime.securesms.util.TextSecurePreferences.getLocalNumber方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。