Пример #1
0
 @Override
 public void onBackPressed() {
   if (emojiDrawer.getVisibility() == View.VISIBLE) {
     emojiDrawer.setVisibility(View.GONE);
     emojiToggle.toggle();
   } else {
     super.onBackPressed();
   }
 }
Пример #2
0
  private void initializeResources() {
    recipients =
        RecipientFactory.getRecipientsForIds(
            this, getIntent().getStringExtra(RECIPIENTS_EXTRA), true);
    threadId = getIntent().getLongExtra(THREAD_ID_EXTRA, -1);
    distributionType =
        getIntent().getIntExtra(DISTRIBUTION_TYPE_EXTRA, ThreadDatabase.DistributionTypes.DEFAULT);
    sendButton = (ImageButton) findViewById(R.id.send_button);
    composeText = (EditText) findViewById(R.id.embedded_text_editor);
    masterSecret = getIntent().getParcelableExtra(MASTER_SECRET_EXTRA);
    charactersLeft = (TextView) findViewById(R.id.space_left);
    emojiDrawer = (EmojiDrawer) findViewById(R.id.emoji_drawer);
    emojiToggle = (EmojiToggle) findViewById(R.id.emoji_toggle);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      emojiToggle.setVisibility(View.GONE);
    }

    attachmentAdapter = new AttachmentTypeSelectorAdapter(this);
    attachmentManager = new AttachmentManager(this, this);

    SendButtonListener sendButtonListener = new SendButtonListener();
    ComposeKeyPressedListener composeKeyPressedListener = new ComposeKeyPressedListener();

    sendButton.setOnClickListener(sendButtonListener);
    sendButton.setEnabled(true);
    composeText.setOnKeyListener(composeKeyPressedListener);
    composeText.addTextChangedListener(composeKeyPressedListener);
    composeText.setOnEditorActionListener(sendButtonListener);
    composeText.setOnClickListener(composeKeyPressedListener);
    emojiDrawer.setComposeEditText(composeText);
    emojiToggle.setOnClickListener(new EmojiToggleListener());

    recipients.addListener(
        new RecipientModifiedListener() {
          @Override
          public void onModified(Recipient recipient) {
            initializeTitleBar();
          }
        });

    registerForContextMenu(sendButton);
  }