Example usage for android.view.inputmethod EditorInfo IME_ACTION_SEND

List of usage examples for android.view.inputmethod EditorInfo IME_ACTION_SEND

Introduction

In this page you can find the example usage for android.view.inputmethod EditorInfo IME_ACTION_SEND.

Prototype

int IME_ACTION_SEND

To view the source code for android.view.inputmethod EditorInfo IME_ACTION_SEND.

Click Source Link

Document

Bits of #IME_MASK_ACTION : the action key performs a "send" operation, delivering the text to its target.

Usage

From source file:com.soomla.example.ExampleSocialActivity.java

/**
 * {@inheritDoc}/*from  w ww .ja  v a  2s .  c o m*/
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_social);

    //        SoomlaConfig.logDebug = true;

    mProgressDialog = new ProgressDialog(this);

    final Bundle extras = getIntent().getExtras();
    if (extras != null) {
        final String provider = extras.getString("provider");
        mProvider = IProvider.Provider.getEnum(provider);
        mItemId = extras.getString("id");
        mItemAmount = extras.getInt("amount", 1);
        mItemName = extras.getString("name");
        mItemResId = extras.getInt("iconResId", R.drawable.ic_launcher);

        // set the social provider logo if possible
        final int resourceId = getResources().getIdentifier(provider, "drawable", getPackageName());
        Drawable drawableLogo = getResources().getDrawable(resourceId);
        if (drawableLogo != null) {
            final TextView topBarTextView = (TextView) findViewById(R.id.textview);
            if (topBarTextView != null) {
                topBarTextView.setCompoundDrawablesWithIntrinsicBounds(drawableLogo, null, null, null);
            }
        }
    }

    final TextView vItemDisplay = (TextView) findViewById(R.id.vItem);
    if (vItemDisplay != null) {
        vItemDisplay.setText(mItemName);
        vItemDisplay.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(mItemResId), null,
                null);
    }

    mProfileBar = (ViewGroup) findViewById(R.id.profile_bar);
    mProfileAvatar = (ImageView) findViewById(R.id.prof_avatar);
    mProfileName = (TextView) findViewById(R.id.prof_name);

    mPnlStatusUpdate = (ViewGroup) findViewById(R.id.pnlStatusUpdate);
    mEdtStatusText = (EditText) findViewById(R.id.edtStatusText);

    mEdtStatusText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            boolean handled = false;
            if (actionId == EditorInfo.IME_ACTION_SEND) {
                doUpdateStatus();
                handled = true;
            }

            return handled;
        }
    });

    mBtnUpdateStatus = (Button) findViewById(R.id.btnStatusUpdate);
    mBtnUpdateStatus.setEnabled(false);
    mBtnUpdateStatus.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            doUpdateStatus();
        }
    });

    mPnlUploadImage = (ViewGroup) findViewById(R.id.pnlUploadImage);
    mImagePreview = (ImageView) findViewById(R.id.imagePreview);
    mEdtImageText = (EditText) findViewById(R.id.edtImageText);

    mEdtImageText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            boolean handled = false;
            if (actionId == EditorInfo.IME_ACTION_SEND) {
                doUpdateStatus();
                handled = true;
            }

            return handled;
        }
    });

    mBtnChooseImage = (ImageView) findViewById(R.id.btnChooseImage);
    mBtnChooseImage.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            chooseImageFile();
        }
    });

    mBtnUploadImage = (Button) findViewById(R.id.btnUploadImage);
    mBtnUploadImage.setEnabled(false);
    mBtnUploadImage.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            doUploadImage();
        }
    });

    mPnlStoryUpdate = (ViewGroup) findViewById(R.id.pnlStoryUpdate);
    mEdtStoryText = (EditText) findViewById(R.id.edtStoryText);

    mEdtStoryText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            boolean handled = false;
            if (actionId == EditorInfo.IME_ACTION_SEND) {
                doUpdateStory();
                handled = true;
            }

            return handled;
        }
    });

    mBtnUpdateStory = (Button) findViewById(R.id.btnStoryUpdate);
    mBtnUpdateStory.setEnabled(false);
    mBtnUpdateStory.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            doUpdateStory();
        }
    });

    mBtnShare = (Button) findViewById(R.id.btnShare);

    if (!SoomlaProfile.getInstance().isLoggedIn(this, mProvider)) {
        SoomlaProfile.getInstance().login(this, mProvider, gameLoginReward);

        mProgressDialog.setMessage("logging in...");
        mProgressDialog.show();
    } else {
        applyLoggedInUser(mProvider);
    }
}

From source file:org.sandholm.max.juttele.activity.ConversationActivity.java

/**
 * On create//ww  w .j  a v a2s . c  om
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    serverId = getIntent().getExtras().getInt("serverId");
    server = Yaaic.getInstance().getServerById(serverId);
    Settings settings = new Settings(this);

    // Finish activity if server does not exist anymore - See #55
    if (server == null) {
        this.finish();
    }

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    setTitle(server.getTitle());

    setContentView(R.layout.conversations);

    boolean isLandscape = (getResources()
            .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);

    EditText input = (EditText) findViewById(R.id.input);
    input.setOnKeyListener(inputKeyListener);

    input.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEND) {
                sendMessage(v.getText().toString());

                // Workaround for a race condition in EditText
                // Instead of calling input.setText("");
                // See:
                // - https://github.com/pocmo/Yaaic/issues/67
                // - http://code.google.com/p/android/issues/detail?id=17508
                TextKeyListener.clear(v.getEditableText());
                return true;
            } else {
                return false;
            }
        }

    });
    input.setHint(server.getIdentity().getNickname());

    pager = (ViewPager) findViewById(R.id.pager);

    pagerAdapter = new ConversationPagerAdapter(this, server);
    pager.setAdapter(pagerAdapter);

    final float density = getResources().getDisplayMetrics().density;

    indicator = (ConversationIndicator) findViewById(R.id.titleIndicator);
    indicator.setServer(server);
    //indicator.setTypeface(Typeface.MONOSPACE);
    indicator.setViewPager(pager);

    //indicator.setFooterColor(0xFF31B6E7);
    indicator.setFooterLineHeight(1 * density);
    indicator.setFooterIndicatorHeight(3 * density);
    indicator.setFooterIndicatorStyle(IndicatorStyle.Underline);
    indicator.setSelectedColor(0xFFFFFFFF);
    indicator.setSelectedBold(true);
    //indicator.setBackgroundColor(0xFF181818);

    historySize = settings.getHistorySize();

    if (server.getStatus() == Status.PRE_CONNECTING) {
        server.clearConversations();
        pagerAdapter.clearConversations();
        server.getConversation(ServerInfo.DEFAULT_NAME).setHistorySize(historySize);
    }

    float fontSize = settings.getFontSize();
    indicator.setTextSize(fontSize * density);

    input.setTextSize(settings.getFontSize());
    //input.setTypeface(Typeface.MONOSPACE);

    // Optimization : cache field lookups
    Collection<Conversation> mConversations = server.getConversations();

    for (Conversation conversation : mConversations) {
        // Only scroll to new conversation if it was selected before
        if (conversation.getStatus() == Conversation.STATUS_SELECTED) {
            onNewConversation(conversation.getName());
        } else {
            createNewConversation(conversation.getName());
        }
    }

    int setInputTypeFlags = 0;

    setInputTypeFlags |= InputType.TYPE_TEXT_FLAG_AUTO_CORRECT;

    if (settings.autoCapSentences()) {
        setInputTypeFlags |= InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
    }

    if (isLandscape && settings.imeExtract()) {
        setInputTypeFlags |= InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE;
    }

    if (!settings.imeExtract()) {
        input.setImeOptions(input.getImeOptions() | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    }

    input.setInputType(input.getInputType() | setInputTypeFlags);

    // Create a new scrollback history
    scrollback = new Scrollback();
}

From source file:edu.stanford.mobisocial.dungbeetle.ui.fragments.AppsViewFragment.java

@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_ACTION_DONE) {
        mSendStatus.onClick(v);//from   w w  w .  j a  v  a  2 s.  c  o m
    }
    return true;
}

From source file:edu.cmu.cylab.starslinger.view.ComposeFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View vFrag = inflater.inflate(R.layout.send, container, false);
    mTextViewSenderName = (TextView) vFrag.findViewById(R.id.SendTextViewSenderName);
    mTextViewSenderKey = (TextView) vFrag.findViewById(R.id.SendTextViewSenderKey);
    mImageViewSenderPhoto = (ImageView) vFrag.findViewById(R.id.SendImageViewSenderPhoto);
    mTextViewRecipName = (TextView) vFrag.findViewById(R.id.SendTextViewRecipName);
    mTextViewRecipKey = (TextView) vFrag.findViewById(R.id.SendTextViewRecipKey);
    mImageViewRecipPhoto = (ImageView) vFrag.findViewById(R.id.SendImageViewRecipPhoto);
    mTextViewFile = (TextView) vFrag.findViewById(R.id.SendTextViewFile);
    mTextViewFileSize = (TextView) vFrag.findViewById(R.id.SendTextViewFileSize);
    mButtonFile = (Button) vFrag.findViewById(R.id.SendButtonFile);
    mButtonSend = (Button) vFrag.findViewById(R.id.SendButtonSend);
    mImageViewFile = (ImageView) vFrag.findViewById(R.id.SendImageViewFile);
    mEditTextMessage = (EditText) vFrag.findViewById(R.id.SendEditTextMessage);
    mButtonSender = (Button) vFrag.findViewById(R.id.SendButtonSender);
    mButtonRecip = (Button) vFrag.findViewById(R.id.SendButtonRecipient);

    updateValues(savedInstanceState);//from www .j ava  2s  . c  om

    OnClickListener clickFile = new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (TextUtils.isEmpty(mFilePath)) {
                doFileSelect();
            } else {
                showChangeFileOptions();
            }
        }
    };
    mButtonFile.setOnClickListener(clickFile);

    OnClickListener clickRecip = new OnClickListener() {

        @Override
        public void onClick(View v) {
            doClickRecipient();
        }
    };
    mButtonRecip.setOnClickListener(clickRecip);

    OnClickListener clickSender = new OnClickListener() {

        @Override
        public void onClick(View v) {
            doChangeUser();
        }
    };
    mButtonSender.setOnClickListener(clickSender);

    mButtonSend.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            if (isSendableText() || !TextUtils.isEmpty(mFilePath)) {
                doSend(mEditTextMessage.getText().toString());
            }
        }

    });

    mEditTextMessage.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEND) {
                if (isSendableText() || !TextUtils.isEmpty(mFilePath)) {
                    doSend(mEditTextMessage.getText().toString());
                }
                return true;
            }
            return false;
        }
    });

    return vFrag;
}

From source file:com.irccloud.android.activity.QuickReplyActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_quick_reply);

    if (getIntent().hasExtra("cid") && getIntent().hasExtra("bid")) {
        onNewIntent(getIntent());/* w  w  w .  j  a v  a 2 s.  c  o  m*/
    } else {
        finish();
        return;
    }

    final ImageButton send = (ImageButton) findViewById(R.id.sendBtn);
    final EditText message = (EditText) findViewById(R.id.messageTxt);
    message.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
            if (actionId == EditorInfo.IME_ACTION_SEND && message.getText() != null
                    && message.getText().length() > 0)
                send.performClick();
            return true;
        }
    });
    message.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View view, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER
                    && message.getText() != null && message.getText().length() > 0)
                send.performClick();
            return false;
        }
    });
    send.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (message.getText() != null && message.getText().length() > 0) {
                Intent i = new Intent(RemoteInputService.ACTION_REPLY);
                i.setComponent(new ComponentName(getPackageName(), RemoteInputService.class.getName()));
                i.putExtras(getIntent());
                i.putExtra("reply", message.getText().toString());
                startService(i);
                finish();
            }
        }
    });

    ListView listView = (ListView) findViewById(R.id.conversation);
    listView.setAdapter(adapter);
}

From source file:com.pixplicity.castdemo.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    CastProxy.init(getApplicationContext(), new HelloWorldChannel(getApplicationContext()));

    ActionBar actionBar = getSupportActionBar();
    actionBar.setBackgroundDrawable(new ColorDrawable(android.R.color.transparent));

    // Sends the message over the channel
    mBtSend = (ImageButton) findViewById(R.id.bt_send);
    mBtSend.setOnClickListener(new OnClickListener() {

        @Override//  w  w  w . jav  a 2 s.c  om
        public void onClick(View v) {
            sendTextMessage(mEtMessage);
        }
    });

    // When the user clicks on the "speak" button, use Android voice recognition to get text
    mBtSpeak = (ImageButton) findViewById(R.id.bt_speak);
    mBtSpeak.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            startVoiceRecognitionActivity();
        }
    });

    mEtMessage = (EditText) findViewById(R.id.et_message);
    mEtMessage.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            switch (actionId) {
            case EditorInfo.IME_ACTION_SEND:
                sendTextMessage(mEtMessage);
                return true;
            }
            return false;
        }
    });

    mLvMessages = (ListView) findViewById(R.id.lv_messages);

    mVgLogo = (ViewGroup) findViewById(R.id.vg_logo);

    setConnected(false);
}

From source file:org.bombusim.lime.fragments.ChatFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.chat, container, false);

    contactBar = (ContactBar) v.findViewById(R.id.contact_head);
    mMessageBox = (ChatEditText) v.findViewById(R.id.messageBox);
    mSendButton = (ImageButton) v.findViewById(R.id.sendButton);
    mSmileButton = (ImageButton) v.findViewById(R.id.smileButton);
    chatListView = (ListView) v.findViewById(R.id.chatListView);

    mChatActive = v.findViewById(R.id.chatActive);
    mChatInactive = v.findViewById(R.id.chatInactive);

    if (!getChatFragmentListener().isTabMode()) {
        contactBar.setVisibility(View.GONE);

        View abCustomView = getSherlockActivity().getSupportActionBar().getCustomView();

        contactBar = (ContactBar) abCustomView.findViewById(R.id.contactHeadActionbar);
        contactBar.removeBackground();/*from  ww  w.j  ava2 s .  c om*/
    }

    registerForContextMenu(chatListView);
    enableTrackballTraversing();

    mSendButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            sendMessage();
        }
    });

    mSmileButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mMessageBox.showAddSmileDialog();
        }
    });

    //TODO: optional
    mMessageBox.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {

            if (event.getAction() != KeyEvent.ACTION_DOWN)
                return false; //filtering only KEY_DOWN

            if (keyCode != KeyEvent.KEYCODE_ENTER)
                return false;
            //if (event.isShiftPressed()) return false; //typing multiline messages with SHIFT+ENTER
            sendMessage();
            return true; //Key was processed
        }
    });

    mMessageBox.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            if (s.length() > 0)
                sendChatState(ChatStates.COMPOSING);
        }
    });

    //TODO: optional behavior
    //messageBox.setImeActionLabel("Send", EditorInfo.IME_ACTION_SEND); //Keeps IME opened
    mMessageBox.setImeActionLabel(getString(R.string.sendMessage), EditorInfo.IME_ACTION_DONE); //Closes IME

    mMessageBox.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            switch (actionId) {
            case EditorInfo.IME_ACTION_SEND:
                sendMessage();
                return true;
            case EditorInfo.IME_ACTION_DONE:
                sendMessage();
                return false; //let IME to be closed
            }
            return false;
        }
    });

    contactBar.getContactIconView().setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            new ContactResourceSwitcher().showResources(getActivity(), visavis);
        }
    });

    return v;
}

From source file:io.plaidapp.ui.PostNewDesignerNewsStory.java

@OnEditorAction({ R.id.new_story_url, R.id.new_story_comment })
protected boolean onEditorAction(TextView textView, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_SEND) {
        postNewStory();// w w w.j a v  a2  s  . c om
        return true;
    }
    return false;
}

From source file:de.azapps.mirakel.new_ui.fragments.TaskFragment.java

private void initTaskNameEdit() {
    taskNameEdit.setText(task.getName());
    // Show Keyboard if stub
    if (task.isStub()) {
        taskNameViewSwitcher.showNext();
        taskNameEdit.selectAll();/*  w  w  w.  j  a  v  a 2  s . c om*/
        taskNameEdit.requestFocus();
        toggleKeyboard();
    }
    taskNameEdit.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(final View v, final boolean hasFocus) {
            if (hasFocus) {
                toggleKeyboard();
            }
        }
    });
    taskNameEdit.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) {
            switch (actionId) {
            case EditorInfo.IME_ACTION_DONE:
            case EditorInfo.IME_ACTION_SEND:
                updateName();
                return true;
            }
            return false;
        }
    });
    taskNameEdit.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(final View v, final int keyCode, final KeyEvent event) {
            // If the event is a key-down event on the "enter" button
            if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                updateName();
                return true;
            }
            return false;
        }
    });
}

From source file:org.droid2droid.ui.contacts.AbstractSMSFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mMain = inflater.inflate(R.layout.expose_sms, container, false);

    mUsage = (TextView) mMain.findViewById(R.id.usage);

    mEditText = (EditText) mMain.findViewById(R.id.numberEditText);
    mEditText.addTextChangedListener(this);
    mEditText.setOnEditorActionListener(new OnEditorActionListener() {
        @Override//  w  w w. j a  v  a  2 s .c  o m
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEND) {
                final String receiver = mEditText.getText().toString();
                if (mSendedData != null || receiver != null)
                    if (receiver.matches("[0123456789#*()\\- ]*"))
                        sendData(receiver);
                return true;
            }
            return false;
        }
    });

    mList = (ListView) mMain.findViewById(android.R.id.list);
    mList.setOnScrollListener(this);
    mList.setFastScrollEnabled(true);
    mList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    mList.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapter, View view, int position, long arg3) {
            final long id = ((Cursor) adapter.getItemAtPosition(position)).getLong(POS_ID);
            if (id > 0) {
                RAApplication.hideSoftKeyboard(getActivity());
                final PhoneDisambigDialog phoneDialog = new PhoneDisambigDialog(getActivity(),
                        AbstractSMSFragment.this, id);
                phoneDialog.show();
            }
        }
    });
    return mMain;
}