コード例 #1
0
  /**
   * Method fired when "add" button is clicked.
   *
   * @param v add button's <tt>View</tt>
   */
  public void onAddClicked(View v) {
    Spinner accountsSpiner = (Spinner) findViewById(R.id.selectAccountSpinner);

    Account selectedAcc = (Account) accountsSpiner.getSelectedItem();
    if (selectedAcc == null) {
      logger.error("No account selected");
      return;
    }

    ProtocolProviderService pps = selectedAcc.getProtocolProvider();
    if (pps == null) {
      logger.error("No provider registered for account " + selectedAcc.getAccountName());
      return;
    }

    View content = findViewById(android.R.id.content);
    String contactAddress = ViewUtil.getTextViewValue(content, R.id.editContactName);

    String displayName = ViewUtil.getTextViewValue(content, R.id.editDisplayName);
    if (displayName != null && displayName.length() > 0) {
      addRenameListener(pps, null, contactAddress, displayName);
    }

    Spinner groupSpinner = (Spinner) findViewById(R.id.selectGroupSpinner);
    ContactListUtils.addContact(
        pps, (MetaContactGroup) groupSpinner.getSelectedItem(), contactAddress);
    finish();
  }
コード例 #2
0
  /** {@inheritDoc} */
  @Override
  protected void onDestroy() {
    super.onDestroy();

    if (!cancelled) {
      View content = findViewById(android.R.id.content);
      authWindow.setUsername(ViewUtil.getTextViewValue(content, R.id.username));
      authWindow.setPassword(ViewUtil.getTextViewValue(content, R.id.password));
      authWindow.setRememberPassword(ViewUtil.isCompoundChecked(content, R.id.store_password));
    }

    if (!paused) {
      authWindow.setCanceled(cancelled);

      authWindow.windowClosed();
    }
  }
コード例 #3
0
  /** {@inheritDoc} */
  @Override
  protected void onResume() {
    super.onResume();

    // Update add to contacts status
    updateAddToContactsStatus(ViewUtil.isCompoundChecked(getContentView(), R.id.addToContacts));

    flagPaused = false;
  }
コード例 #4
0
  /** {@inheritDoc} */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.authorization_requested);

    long requestId = getIntent().getLongExtra(EXTRA_REQUEST_ID, -1);

    if (requestId == -1) throw new IllegalArgumentException();

    this.request = AuthorizationHandlerImpl.getRequest(requestId);

    View content = findViewById(android.R.id.content);

    ViewUtil.setTextViewValue(
        content,
        R.id.requestInfo,
        getString(
            R.string.service_gui_AUTHORIZATION_REQUESTED_INFO, request.contact.getDisplayName()));

    ViewUtil.setTextViewValue(
        content,
        R.id.addToContacts,
        getString(R.string.service_gui_ADD_AUTHORIZED_CONTACT, request.contact.getDisplayName()));

    Spinner contactGroupSpinner = (Spinner) findViewById(R.id.selectGroupSpinner);

    contactGroupSpinner.setAdapter(new MetaContactGroupAdapter(this));

    CompoundButton addToContactsCb = (CompoundButton) findViewById(R.id.addToContacts);

    addToContactsCb.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            updateAddToContactsStatus(isChecked);
          }
        });
  }
コード例 #5
0
  /** {@inheritDoc} */
  @Override
  protected void onDestroy() {
    super.onDestroy();

    if (flagPaused) {
      return;
    }

    if (ViewUtil.isCompoundChecked(getContentView(), R.id.addToContacts)
        && responseCode.equals(AuthorizationResponse.ACCEPT)) {
      // Add to contacts
      Spinner groupSpinner = (Spinner) findViewById(R.id.selectGroupSpinner);

      ContactListUtils.addContact(
          request.contact.getProtocolProvider(),
          (MetaContactGroup) groupSpinner.getSelectedItem(),
          request.contact.getAddress());
    }

    request.notifyResponseReceived(responseCode);
  }
コード例 #6
0
  /** {@inheritDoc} */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    long requestId = getIntent().getLongExtra(REQUEST_ID_EXTRA, -1);
    if (requestId == -1) throw new IllegalArgumentException();

    this.authWindow = AuthWindowServiceImpl.getAuthWindow(requestId);

    // Content view
    setContentView(R.layout.auth_window);
    View content = findViewById(android.R.id.content);

    // Server name
    String server = authWindow.getServer();

    // Title
    String title = authWindow.getWindowTitle();
    if (title == null) {
      title = getString(R.string.service_gui_AUTHENTICATION_WINDOW_TITLE, server);
    }
    setTitle(title);

    // Message
    String text = authWindow.getWindowText();
    if (text == null) {
      text = getString(R.string.service_gui_AUTHENTICATION_REQUESTED_SERVER, server);
    }
    ViewUtil.setTextViewValue(content, R.id.text, text);

    // Username filed and label
    if (authWindow.getUsernameLabel() != null)
      ViewUtil.setTextViewValue(content, R.id.username_label, authWindow.getUsernameLabel());

    ViewUtil.ensureEnabled(content, R.id.username, authWindow.isUserNameEditable());

    // Password filed and label
    if (authWindow.getPasswordLabel() != null)
      ViewUtil.setTextViewValue(content, R.id.password_label, authWindow.getPasswordLabel());

    ViewUtil.setCompoundChecked(content, R.id.store_password, authWindow.isRememberPassword());
    ViewUtil.ensureVisible(content, R.id.store_password, authWindow.isAllowSavePassword());
  }
コード例 #7
0
 /**
  * Updates select group spinner status based on add to contact list checkbox state.
  *
  * @param isChecked <tt>true</tt> if "add to contacts" checkbox is checked.
  */
 private void updateAddToContactsStatus(boolean isChecked) {
   ViewUtil.ensureEnabled(getContentView(), R.id.selectGroupSpinner, isChecked);
 }