Exemplo n.º 1
0
  @Override
  @RunsOnMainThread
  public void onGetOrCreateConversationSucceeded(
      final ActionMonitor monitor, final Object data, final String conversationId) {
    Assert.isTrue(monitor == mMonitor);
    Assert.isTrue(conversationId != null);

    mRecipientTextView.setInputType(
        InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_CLASS_TEXT);
    mHost.onGetOrCreateNewConversation(conversationId);

    mMonitor = null;
  }
Exemplo n.º 2
0
 @Override
 @RunsOnMainThread
 public void onGetOrCreateConversationFailed(final ActionMonitor monitor, final Object data) {
   Assert.isTrue(monitor == mMonitor);
   LogUtil.e(LogUtil.BUGLE_TAG, "onGetOrCreateConversationFailed");
   mMonitor = null;
 }
Exemplo n.º 3
0
 /**
  * {@inheritDoc}
  *
  * <p>Called when the host activity has been created. At this point, the host activity should have
  * set the contact picking mode for us so that we may update our visuals.
  */
 @Override
 public void onActivityCreated(final Bundle savedInstanceState) {
   super.onActivityCreated(savedInstanceState);
   Assert.isTrue(mContactPickingMode != MODE_UNDEFINED);
   updateVisualsForContactPickingMode(false /* animate */);
   mHost.invalidateActionBar();
 }
Exemplo n.º 4
0
  private void determineLayout(final Iterable<MessagePartData> attachments, final int count) {
    Assert.isTrue(attachments != null);
    final boolean isRtl = AccessibilityUtil.isLayoutRtl(getRootView());
    if (isRtl) {
      mCurrentLayout =
          ATTACHMENT_RTL_LAYOUTS_BY_COUNT[
              Math.min(count, ATTACHMENT_RTL_LAYOUTS_BY_COUNT.length - 1)];
    } else {
      mCurrentLayout =
          ATTACHMENT_LAYOUTS_BY_COUNT[Math.min(count, ATTACHMENT_LAYOUTS_BY_COUNT.length - 1)];
    }

    // We must have a valid layout for the current configuration.
    Assert.notNull(mCurrentLayout);

    mPlusNumber = count - mCurrentLayout.tiles.size();
    Assert.isTrue(mPlusNumber >= 0);
  }
Exemplo n.º 5
0
  public void setContactPickingMode(final int mode, final boolean animate) {
    if (mContactPickingMode != mode) {
      // Guard against impossible transitions.
      Assert.isTrue(
          // We may start from undefined mode to any mode when we are restoring state.
          (mContactPickingMode == MODE_UNDEFINED)
              || (mContactPickingMode == MODE_PICK_INITIAL_CONTACT && mode == MODE_CHIPS_ONLY)
              || (mContactPickingMode == MODE_CHIPS_ONLY && mode == MODE_PICK_MORE_CONTACTS)
              || (mContactPickingMode == MODE_PICK_MORE_CONTACTS
                  && mode == MODE_PICK_MAX_PARTICIPANTS)
              || (mContactPickingMode == MODE_PICK_MAX_PARTICIPANTS
                  && mode == MODE_PICK_MORE_CONTACTS));

      mContactPickingMode = mode;
      updateVisualsForContactPickingMode(animate);
    }
  }
Exemplo n.º 6
0
  /**
   * Watches changes in contact chips to determine possible state transitions (e.g. creating the
   * initial conversation, adding more participants or finish the current conversation)
   */
  @Override
  public void onContactChipsChanged(final int oldCount, final int newCount) {
    Assert.isTrue(oldCount != newCount);
    if (mContactPickingMode == MODE_PICK_INITIAL_CONTACT) {
      // Initial picking mode. Start a conversation once a recipient has been picked.
      maybeGetOrCreateConversation();
    } else if (mContactPickingMode == MODE_CHIPS_ONLY) {
      // oldCount == 0 means we are restoring from savedInstanceState to add the existing
      // chips, don't switch to "add more participants" mode in this case.
      if (oldCount > 0 && mRecipientTextView.isFocused()) {
        // Chips only mode. The user may have picked an additional contact or deleted the
        // only existing contact. Either way, switch to picking more participants mode.
        mHost.onInitiateAddMoreParticipants();
      }
    }
    mHost.onParticipantCountChanged(ContactPickerData.getCanAddMoreParticipants(newCount));

    // Refresh our local copy of the selected chips set to keep it up-to-date.
    mSelectedPhoneNumbers = mRecipientTextView.getSelectedDestinations();
    invalidateContactLists();
  }
Exemplo n.º 7
0
 /**
  * Listens for notification that invalid contacts have been removed during resolving them. These
  * contacts were not local contacts, valid email, or valid phone numbers
  */
 @Override
 public void onInvalidContactChipsPruned(final int prunedCount) {
   Assert.isTrue(prunedCount > 0);
   UiUtils.showToast(R.plurals.add_invalid_contact_error, prunedCount);
 }
 @VisibleForTesting
 public void setDatabaseForTest(final DatabaseWrapper db) {
   Assert.isTrue(BugleApplication.isRunningTests());
   mDatabaseWrapper = db;
 }