当前位置: 首页>>代码示例>>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;未经允许,请勿转载。