本文整理汇总了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());
}
}
示例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);
}
}
}
示例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;
}
}
}
示例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();
}
}
示例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;
}
}
示例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);
}
示例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);
}
}
示例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());
}
}
示例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;
}
}
示例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);
}
示例11: getConfiguration
import org.thoughtcrime.securesms.util.TextSecurePreferences; //导入方法依赖的package包/类
public SignalServiceUrl[] getConfiguration(Context context) {
String localNumber = TextSecurePreferences.getLocalNumber(context);
return getConfiguration(localNumber);
}
示例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);
}
示例13: getUser
import org.thoughtcrime.securesms.util.TextSecurePreferences; //导入方法依赖的package包/类
@Override
public String getUser() {
return TextSecurePreferences.getLocalNumber(context);
}
示例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());
}
}