Beispiel #1
0
 public void onClick(View v) {
   mApp.callWhenServiceConnected(
       mHandler,
       new Runnable() {
         public void run() {
           inviteBuddies();
         }
       });
 }
Beispiel #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mApp = ImApp.getApplication(this);
    mHandler = new SimpleAlertHandler(this);
    resolveIntent(getIntent());

    setContentView(R.layout.add_contact_activity);

    BrandingResources brandingRes = mApp.getBrandingResource(mProviderId);
    setTitle(brandingRes.getString(BrandingResourceIDs.STRING_ADD_CONTACT_TITLE));

    BhoTextView label = (BhoTextView) findViewById(R.id.input_contact_label);
    label.setText(brandingRes.getString(BrandingResourceIDs.STRING_LABEL_INPUT_CONTACT));

    mAddressList = (MultiAutoCompleteTextView) findViewById(R.id.email);
    mAddressList.setAdapter(new EmailAddressAdapter(this));
    mAddressList.setTokenizer(new Rfc822Tokenizer());
    mAddressList.addTextChangedListener(mTextWatcher);

    mListSpinner = (Spinner) findViewById(R.id.choose_list);

    Cursor c = queryContactLists();
    int initSelection =
        searchInitListPos(c, getIntent().getStringExtra(ImServiceConstants.EXTRA_INTENT_LIST_NAME));
    SimpleCursorAdapter adapter =
        new SimpleCursorAdapter(
            this,
            android.R.layout.simple_spinner_item,
            c,
            new String[] {Imps.ContactList.NAME},
            new int[] {android.R.id.text1});
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mListSpinner.setAdapter(adapter);
    mListSpinner.setSelection(initSelection);

    mInviteButton = (BhoButton) findViewById(R.id.invite);
    mInviteButton.setText(brandingRes.getString(BrandingResourceIDs.STRING_BUTTON_ADD_CONTACT));
    mInviteButton.setOnClickListener(mButtonHandler);
    mInviteButton.setEnabled(false);
  }
Beispiel #3
0
 void inviteBuddies() {
   Rfc822Token[] recipients = Rfc822Tokenizer.tokenize(mAddressList.getText());
   try {
     IImConnection conn = mApp.getConnection(mProviderId);
     IContactList list = getContactList(conn);
     if (list == null) {
       Log.e(
           ImApp.LOG_TAG,
           "<AddContactActivity> can't find given contact list:" + getSelectedListName());
       finish();
     } else {
       boolean fail = false;
       for (Rfc822Token recipient : recipients) {
         String username = recipient.getAddress();
         if (mDefaultDomain != null && username.indexOf('@') == -1) {
           username = username + "@" + mDefaultDomain;
         }
         if (Log.isLoggable(ImApp.LOG_TAG, Log.DEBUG)) {
           log("addContact:" + username);
         }
         int res = list.addContact(username);
         if (res != ImErrorInfo.NO_ERROR) {
           fail = true;
           mHandler.showAlert(
               R.string.error, ErrorResUtils.getErrorRes(getResources(), res, username));
         }
       }
       // close the screen if there's no error.
       if (!fail) {
         finish();
       }
     }
   } catch (RemoteException ex) {
     Log.e(ImApp.LOG_TAG, "<AddContactActivity> inviteBuddies: caught " + ex);
   }
 }