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


Java GroupUtil.isEncodedGroup方法代碼示例

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


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

示例1: toNumberStringArray

import org.thoughtcrime.securesms.util.GroupUtil; //導入方法依賴的package包/類
public @NonNull String[] toNumberStringArray(boolean scrub) {
  String[] recipientsArray     = new String[recipients.size()];
  Iterator<Recipient> iterator = recipients.iterator();
  int i                        = 0;

  while (iterator.hasNext()) {
    String number = iterator.next().getNumber();

    if (scrub && number != null &&
        !Patterns.EMAIL_ADDRESS.matcher(number).matches() &&
        !GroupUtil.isEncodedGroup(number))
    {
      number = number.replaceAll("[^0-9+]", "");
    }

    recipientsArray[i++] = number;
  }

  return recipientsArray;
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:21,代碼來源:Recipients.java

示例2: toNumberStringArray

import org.thoughtcrime.securesms.util.GroupUtil; //導入方法依賴的package包/類
public String[] toNumberStringArray(boolean scrub) {
  String[] recipientsArray     = new String[recipients.size()];
  Iterator<Recipient> iterator = recipients.iterator();
  int i                        = 0;

  while (iterator.hasNext()) {
    String number = iterator.next().getNumber();

    if (scrub && number != null &&
        !Patterns.EMAIL_ADDRESS.matcher(number).matches() &&
        !GroupUtil.isEncodedGroup(number))
    {
      number = number.replaceAll("[^0-9+]", "");
    }

    recipientsArray[i++] = number;
  }

  return recipientsArray;
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:21,代碼來源:Recipients.java

示例3: isSmsFallbackSupported

import org.thoughtcrime.securesms.util.GroupUtil; //導入方法依賴的package包/類
protected static boolean isSmsFallbackSupported(Context context, String destination, boolean media) {
  try {
    String e164number = Util.canonicalizeNumber(context, destination);

    if (GroupUtil.isEncodedGroup(e164number)) {
      return false;
    }

    if (!TextSecurePreferences.isFallbackSmsAllowed(context)) {
      return false;
    }

    if (media && !TextSecurePreferences.isFallbackMmsEnabled(context)) {
      return false;
    }

    TextSecureDirectory directory = TextSecureDirectory.getInstance(context);
    return directory.isSmsFallbackSupported(e164number);
  } catch (InvalidNumberException e) {
    Log.w(TAG, e);
    return false;
  }
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:24,代碼來源:PushSendJob.java

示例4: isNumberAddress

import org.thoughtcrime.securesms.util.GroupUtil; //導入方法依賴的package包/類
@VisibleForTesting
static boolean isNumberAddress(@NonNull String number) {
  if (number.contains("@"))             return false;
  if (GroupUtil.isEncodedGroup(number)) return false;

  final String networkNumber = PhoneNumberUtils.extractNetworkPortion(number);

  if (TextUtils.isEmpty(networkNumber)) return false;
  if (networkNumber.length() < 3)       return false;

  return PhoneNumberUtils.isWellFormedSmsAddress(number);
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:13,代碼來源:CanonicalAddressDatabase.java

示例5: incrementDeliveryReceiptCount

import org.thoughtcrime.securesms.util.GroupUtil; //導入方法依賴的package包/類
public void incrementDeliveryReceiptCount(String address, long timestamp) {
  MmsAddressDatabase addressDatabase = DatabaseFactory.getMmsAddressDatabase(context);
  SQLiteDatabase     database        = databaseHelper.getWritableDatabase();
  Cursor             cursor          = null;

  try {
    cursor = database.query(TABLE_NAME, new String[] {ID, THREAD_ID, MESSAGE_BOX}, DATE_SENT + " = ?", new String[] {String.valueOf(timestamp / 1000)}, null, null, null, null);

    while (cursor.moveToNext()) {
      if (Types.isOutgoingMessageType(cursor.getLong(cursor.getColumnIndexOrThrow(MESSAGE_BOX)))) {
        List<String> addresses = addressDatabase.getAddressesForId(cursor.getLong(cursor.getColumnIndexOrThrow(ID)));

        for (String storedAddress : addresses) {
          try {
            String ourAddress   = canonicalizeNumber(context, address);
            String theirAddress = canonicalizeNumberOrGroup(context, storedAddress);

            if (ourAddress.equals(theirAddress) || GroupUtil.isEncodedGroup(theirAddress)) {
              long id       = cursor.getLong(cursor.getColumnIndexOrThrow(ID));
              long threadId = cursor.getLong(cursor.getColumnIndexOrThrow(THREAD_ID));

              database.execSQL("UPDATE " + TABLE_NAME + " SET " +
                               RECEIPT_COUNT + " = " + RECEIPT_COUNT + " + 1 WHERE " + ID + " = ?",
                               new String[] {String.valueOf(id)});

              notifyConversationListeners(threadId);
            }
          } catch (InvalidNumberException e) {
            Log.w("MmsDatabase", e);
          }
        }
      }
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:39,代碼來源:MmsDatabase.java

示例6: isNumberAddress

import org.thoughtcrime.securesms.util.GroupUtil; //導入方法依賴的package包/類
@VisibleForTesting
static boolean isNumberAddress(String number) {
  if (number.contains("@"))
    return false;
  if (GroupUtil.isEncodedGroup(number))
    return false;

  final String networkNumber = PhoneNumberUtils.extractNetworkPortion(number);
  if (TextUtils.isEmpty(networkNumber))
    return false;
  if (networkNumber.length() < 3)
    return false;

  return PhoneNumberUtils.isWellFormedSmsAddress(number);
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:16,代碼來源:CanonicalAddressDatabase.java

示例7: getSynchronousRecipient

import org.thoughtcrime.securesms.util.GroupUtil; //導入方法依賴的package包/類
private Recipient getSynchronousRecipient(final Context context, final long recipientId) {
  Log.w("RecipientProvider", "Cache miss [SYNC]!");

  final Recipient recipient;
  RecipientDetails details;
  String number = CanonicalAddressDatabase.getInstance(context).getAddressFromId(recipientId);
  final boolean isGroupRecipient = GroupUtil.isEncodedGroup(number);

  if (isGroupRecipient) details = getGroupRecipientDetails(context, number);
  else                  details = getRecipientDetails(context, number);

  if (details != null) {
    recipient = new Recipient(details.name, details.number, recipientId, details.contactUri, details.avatar,
                              details.croppedAvatar);
  } else {
    final Bitmap defaultPhoto        = isGroupRecipient
                                         ? ContactPhotoFactory.getDefaultGroupPhoto(context)
                                         : ContactPhotoFactory.getDefaultContactPhoto(context);
    final Bitmap defaultCroppedPhoto = isGroupRecipient
                                         ? ContactPhotoFactory.getDefaultGroupPhotoCropped(context)
                                         : ContactPhotoFactory.getDefaultContactPhotoCropped(context);

    recipient = new Recipient(null, number, recipientId, null, defaultPhoto, defaultCroppedPhoto);
  }

  recipientCache.put(recipientId, recipient);
  return recipient;
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:29,代碼來源:RecipientProvider.java

示例8: getAsynchronousRecipient

import org.thoughtcrime.securesms.util.GroupUtil; //導入方法依賴的package包/類
private Recipient getAsynchronousRecipient(final Context context, final long recipientId) {
  Log.w("RecipientProvider", "Cache miss [ASYNC]!");

  final String number = CanonicalAddressDatabase.getInstance(context).getAddressFromId(recipientId);
  final boolean isGroupRecipient = GroupUtil.isEncodedGroup(number);

  Callable<RecipientDetails> task = new Callable<RecipientDetails>() {
    @Override
    public RecipientDetails call() throws Exception {
      if (isGroupRecipient) return getGroupRecipientDetails(context, number);
      else                  return getRecipientDetails(context, number);
    }
  };

  ListenableFutureTask<RecipientDetails> future = new ListenableFutureTask<RecipientDetails>(task);

  asyncRecipientResolver.submit(future);

  Bitmap contactPhoto;
  Bitmap contactPhotoCropped;

  if (isGroupRecipient) {
    contactPhoto        = ContactPhotoFactory.getDefaultGroupPhoto(context);
    contactPhotoCropped = ContactPhotoFactory.getDefaultGroupPhotoCropped(context);
  } else {
    contactPhoto        = ContactPhotoFactory.getDefaultContactPhoto(context);
    contactPhotoCropped = ContactPhotoFactory.getDefaultContactPhotoCropped(context);
  }

  Recipient recipient = new Recipient(number, contactPhoto, contactPhotoCropped, recipientId, future);
  recipientCache.put(recipientId, recipient);

  return recipient;
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:35,代碼來源:RecipientProvider.java

示例9: setTimestampRead

import org.thoughtcrime.securesms.util.GroupUtil; //導入方法依賴的package包/類
public List<Pair<Long, Long>> setTimestampRead(SyncMessageId messageId, long expireStarted) {
  MmsAddressDatabase     addressDatabase = DatabaseFactory.getMmsAddressDatabase(context);
  SQLiteDatabase         database        = databaseHelper.getWritableDatabase();
  List<Pair<Long, Long>> expiring        = new LinkedList<>();
  Cursor                 cursor          = null;

  try {
    cursor = database.query(TABLE_NAME, new String[] {ID, THREAD_ID, MESSAGE_BOX, EXPIRES_IN}, DATE_SENT + " = ?", new String[] {String.valueOf(messageId.getTimetamp())}, null, null, null, null);

    while (cursor.moveToNext()) {
      List<String> addresses = addressDatabase.getAddressesListForId(cursor.getLong(cursor.getColumnIndexOrThrow(ID)));

      for (String storedAddress : addresses) {
        try {
          String ourAddress   = canonicalizeNumber(context, messageId.getAddress());
          String theirAddress = canonicalizeNumberOrGroup(context, storedAddress);

          if (ourAddress.equals(theirAddress) || GroupUtil.isEncodedGroup(theirAddress)) {
            long id        = cursor.getLong(cursor.getColumnIndexOrThrow(ID));
            long threadId  = cursor.getLong(cursor.getColumnIndexOrThrow(THREAD_ID));
            long expiresIn = cursor.getLong(cursor.getColumnIndexOrThrow(EXPIRES_IN));

            ContentValues values = new ContentValues();
            values.put(READ, 1);

            if (expiresIn > 0) {
              values.put(EXPIRE_STARTED, expireStarted);
              expiring.add(new Pair<>(id, expiresIn));
            }

            database.update(TABLE_NAME, values, ID_WHERE, new String[]{String.valueOf(id)});

            DatabaseFactory.getThreadDatabase(context).updateReadState(threadId);
            DatabaseFactory.getThreadDatabase(context).setLastSeen(threadId);
            notifyConversationListeners(threadId);
          }
        } catch (InvalidNumberException e) {
          Log.w("MmsDatabase", e);
        }
      }
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  return expiring;
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:49,代碼來源:MmsDatabase.java

示例10: isGroupRecipient

import org.thoughtcrime.securesms.util.GroupUtil; //導入方法依賴的package包/類
public boolean isGroupRecipient() {
  return GroupUtil.isEncodedGroup(number);
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:4,代碼來源:Recipient.java

示例11: isGroupRecipient

import org.thoughtcrime.securesms.util.GroupUtil; //導入方法依賴的package包/類
public boolean isGroupRecipient() {
  return isSingleRecipient() && GroupUtil.isEncodedGroup(recipients.get(0).getNumber());
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:4,代碼來源:Recipients.java

示例12: getRecipientDetailsSync

import org.thoughtcrime.securesms.util.GroupUtil; //導入方法依賴的package包/類
private @NonNull RecipientDetails getRecipientDetailsSync(Context context, long recipientId, @NonNull String number) {
  if (GroupUtil.isEncodedGroup(number)) return getGroupRecipientDetails(context, number);
  else                                  return getIndividualRecipientDetails(context, recipientId, number);
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:5,代碼來源:RecipientProvider.java

示例13: isGroupPushSend

import org.thoughtcrime.securesms.util.GroupUtil; //導入方法依賴的package包/類
private static boolean isGroupPushSend(Recipients recipients) {
  return GroupUtil.isEncodedGroup(recipients.getPrimaryRecipient().getNumber());
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:4,代碼來源:MessageSender.java


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