コード例 #1
0
  private Set<String> getE164Numbers(Set<Recipient> recipients) throws InvalidNumberException {
    Set<String> results = new HashSet<String>();

    for (Recipient recipient : recipients) {
      results.add(Util.canonicalizeNumber(this, recipient.getNumber()));
    }

    return results;
  }
コード例 #2
0
 private static boolean isActiveInDirectory(Context context, Recipient recipient) {
   try {
     if (!TextSecureDirectory.getInstance(context)
         .isActiveNumber(Util.canonicalizeNumber(context, recipient.getNumber()))) {
       return false;
     }
   } catch (NotInDirectoryException e) {
     return false;
   } catch (InvalidNumberException e) {
     return false;
   }
   return true;
 }
コード例 #3
0
  private void initializeResources() {
    groupRecipient =
        RecipientFactory.getRecipientForId(
            this, getIntent().getLongExtra(GROUP_RECIPIENT_EXTRA, -1), true);
    groupThread = getIntent().getLongExtra(GROUP_THREAD_EXTRA, -1);
    if (groupRecipient != null) {
      final String encodedGroupId = groupRecipient.getNumber();
      if (encodedGroupId != null) {
        try {
          groupId = GroupUtil.getDecodedId(encodedGroupId);
        } catch (IOException ioe) {
          Log.w(TAG, "Couldn't decode the encoded groupId passed in via intent", ioe);
          groupId = null;
        }
        if (groupId != null) {
          new FillExistingGroupInfoAsyncTask().execute();
        }
      }
    }

    lv = (ListView) findViewById(R.id.selected_contacts_list);
    avatar = (ImageView) findViewById(R.id.avatar);
    groupName = (EditText) findViewById(R.id.group_name);
    creatingText = (TextView) findViewById(R.id.creating_group_text);
    recipientsPanel = (PushRecipientsPanel) findViewById(R.id.recipients);

    groupName.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {}

          @Override
          public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {}

          @Override
          public void afterTextChanged(Editable editable) {
            final int prefixResId =
                (groupId != null)
                    ? R.string.GroupCreateActivity_actionbar_update_title
                    : R.string.GroupCreateActivity_actionbar_title;
            if (editable.length() > 0) {
              getSupportActionBar().setTitle(getString(prefixResId) + ": " + editable.toString());
            } else {
              getSupportActionBar().setTitle(prefixResId);
            }
          }
        });

    SelectedRecipientsAdapter adapter =
        new SelectedRecipientsAdapter(
            this, android.R.id.text1, new ArrayList<SelectedRecipientsAdapter.RecipientWrapper>());
    adapter.setOnRecipientDeletedListener(
        new SelectedRecipientsAdapter.OnRecipientDeletedListener() {
          @Override
          public void onRecipientDeleted(Recipient recipient) {
            removeSelectedContact(recipient);
          }
        });
    lv.setAdapter(adapter);

    recipientsPanel.setPanelChangeListener(
        new PushRecipientsPanel.RecipientsPanelChangedListener() {
          @Override
          public void onRecipientsPanelUpdate(Recipients recipients) {
            Log.i(TAG, "onRecipientsPanelUpdate received.");
            if (recipients != null) {
              addAllSelectedContacts(recipients.getRecipientsList());
              syncAdapterWithSelectedContacts();
            }
          }
        });
    (findViewById(R.id.contacts_button)).setOnClickListener(new AddRecipientButtonListener());

    avatar.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Crop.pickImage(GroupCreateActivity.this);
          }
        });

    ((RecipientsEditor) findViewById(R.id.recipients_text))
        .setHint(R.string.recipients_panel__add_member);
  }