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:org.xbmc.kore.ui.SendTextDialogFragment.java

/**
 * Create the dialog/*from  w  w w . ja v  a 2 s . c om*/
 * @param savedInstanceState Saved state
 * @return Created dialog
 */
@Override
@SuppressWarnings("InflateParams")
public Dialog onCreateDialog(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    final String title = getArguments().getString(TITLE_KEY, getString(R.string.send_text));
    View dialogView = getActivity().getLayoutInflater().inflate(R.layout.dialog_send_text, null);

    textToSend = (EditText) dialogView.findViewById(R.id.text_to_send);
    finishAfterSend = (CheckBox) dialogView.findViewById(R.id.send_text_done);

    builder.setTitle(title).setView(dialogView)
            .setPositiveButton(R.string.send, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {

                    mListener.onSendTextFinished(textToSend.getText().toString(), finishAfterSend.isChecked());
                }
            }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mListener.onSendTextCancel();
                }
            });

    final Dialog dialog = builder.create();
    textToSend.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
            }
        }
    });
    textToSend.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEND) {
                onSendTextFinished();
            } // handles enter key on external keyboard, issue #99
            else if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED
                    && (event != null && event.getAction() == KeyEvent.ACTION_DOWN
                            && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
                onSendTextFinished();
            }
            dialog.dismiss();
            return false;
        }

        private void onSendTextFinished() {
            mListener.onSendTextFinished(textToSend.getText().toString(), finishAfterSend.isChecked());
        }
    });
    return dialog;
}

From source file:com.syncedsynapse.kore2.ui.SendTextDialogFragment.java

/**
 * Create the dialog/*from w  ww . j a v a2  s  . c  o  m*/
 * @param savedInstanceState Saved state
 * @return Created dialog
 */
@Override
@SuppressWarnings("InflateParams")
public Dialog onCreateDialog(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    final String title = getArguments().getString(TITLE_KEY, getString(R.string.send_text));
    View dialogView = getActivity().getLayoutInflater().inflate(R.layout.dialog_send_text, null);

    textToSend = (EditText) dialogView.findViewById(R.id.text_to_send);
    finishAfterSend = (CheckBox) dialogView.findViewById(R.id.send_text_done);

    builder.setTitle(title).setView(dialogView)
            .setPositiveButton(R.string.send, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {

                    mListener.onSendTextFinished(textToSend.getText().toString(), finishAfterSend.isChecked());
                }
            }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mListener.onSendTextCancel();
                }
            });

    final Dialog dialog = builder.create();
    textToSend.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
            }
        }
    });
    textToSend.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEND) {
                mListener.onSendTextFinished(textToSend.getText().toString(), finishAfterSend.isChecked());
            }
            dialog.dismiss();
            return false;
        }
    });
    return dialog;
}

From source file:org.xbmc.kore.ui.generic.SendTextDialogFragment.java

/**
 * Create the dialog/*from   w  ww . ja  va 2 s  .c o m*/
 * @param savedInstanceState Saved state
 * @return Created dialog
 */
@NonNull
@Override
@SuppressWarnings("InflateParams")
public Dialog onCreateDialog(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    final String title = getArguments().getString(TITLE_KEY, getString(R.string.send_text));
    View dialogView = getActivity().getLayoutInflater().inflate(R.layout.dialog_send_text, null);

    textToSend = (EditText) dialogView.findViewById(R.id.text_to_send);
    finishAfterSend = (CheckBox) dialogView.findViewById(R.id.send_text_done);

    builder.setTitle(title).setView(dialogView)
            .setPositiveButton(R.string.send, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {

                    mListener.onSendTextFinished(textToSend.getText().toString(), finishAfterSend.isChecked());
                }
            }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mListener.onSendTextCancel();
                }
            });

    final Dialog dialog = builder.create();
    textToSend.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
            }
        }
    });
    textToSend.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEND) {
                onSendTextFinished();
            } // handles enter key on external keyboard, issue #99
            else if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED
                    && (event != null && event.getAction() == KeyEvent.ACTION_DOWN
                            && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
                onSendTextFinished();
            }
            dialog.dismiss();
            return false;
        }

        private void onSendTextFinished() {
            mListener.onSendTextFinished(textToSend.getText().toString(), finishAfterSend.isChecked());
        }
    });
    return dialog;
}

From source file:com.trellmor.berrytubechat.ChatActivity.java

@SuppressLint("NewApi")
@Override/*w ww .  ja va  2  s.  co m*/
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_chat);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        getActionBar().setDisplayHomeAsUpEnabled(false);
    }

    mEditChatMsg = (EditText) findViewById(R.id.edit_chat_msg);
    TextView.OnEditorActionListener chatMsgListener = new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEND) {
                sendChatMsg();
            } else if (actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_UP
                    && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
                sendChatMsg();
            }
            return true;
        }
    };
    mEditChatMsg.setOnEditorActionListener(chatMsgListener);

    mTextDrinks = (TextView) findViewById(R.id.text_drinks);
    registerForContextMenu(mTextDrinks);

    mCurrentVideo = (TextView) findViewById(R.id.text_video);
    mCurrentVideo.setMovementMethod(LinkMovementMethod.getInstance());

    mTextNick = (TextView) findViewById(R.id.text_nick);
    mTextNick.setText("Anonymous");

    mListChat = (ListView) findViewById(R.id.list_chat);

    Intent intent = getIntent();
    mUsername = intent.getStringExtra(MainActivity.KEY_USERNAME);
    mPassword = intent.getStringExtra(MainActivity.KEY_PASSWORD);

    if (savedInstanceState != null) {
        mDrinkCount = savedInstanceState.getInt(KEY_DRINKCOUT);
        mMyDrinkCount = savedInstanceState.getInt(KEY_MYDRINKCOUNT);
        if (mUsername == null)
            mUsername = savedInstanceState.getString(MainActivity.KEY_USERNAME);
        if (mPassword == null)
            mPassword = savedInstanceState.getString(MainActivity.KEY_PASSWORD);
    }

    startService(new Intent(this, BerryTube.class));
    bindService(new Intent(this, BerryTube.class), mService, BIND_ABOVE_CLIENT);
}

From source file:com.activiti.android.ui.fragments.comment.CommentsFoundationFragment.java

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

    init(getRootView(), R.string.task_help_add_comment);

    commentText = (EditText) viewById(R.id.comment_value);

    bAdd = (ImageButton) viewById(R.id.send_comment);
    bAdd.setEnabled(false);/*  w  w w  . ja va  2s.c  o m*/

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

    commentText.addTextChangedListener(new TextWatcher() {
        public void afterTextChanged(Editable s) {
            activateSend();
        }

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

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

    commentText.setImeOptions(EditorInfo.IME_ACTION_SEND);
    commentText.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (event != null && (event.getAction() == KeyEvent.ACTION_DOWN)
                    && ((actionId == EditorInfo.IME_ACTION_SEND))) {
                addcomment();
                return true;
            }
            return false;
        }
    });

    gv.setSelector(android.R.color.transparent);
    gv.setCacheColorHint(getResources().getColor(android.R.color.transparent));

    return getRootView();
}

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

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View vFrag = inflater.inflate(R.layout.sendinvite, container, false);
    mTextViewRecipName1 = (TextView) vFrag.findViewById(R.id.SendTextViewRecipName1);
    mTextViewRecipKey1 = (TextView) vFrag.findViewById(R.id.SendTextViewRecipKey1);
    mImageViewRecipPhoto1 = (ImageView) vFrag.findViewById(R.id.SendImageViewRecipPhoto1);
    mTextViewRecipName2 = (TextView) vFrag.findViewById(R.id.SendTextViewRecipName2);
    mTextViewRecipKey2 = (TextView) vFrag.findViewById(R.id.SendTextViewRecipKey2);
    mImageViewRecipPhoto2 = (ImageView) vFrag.findViewById(R.id.SendImageViewRecipPhoto2);
    mButtonSend = (Button) vFrag.findViewById(R.id.SendButtonSend);
    mEditTextMessage1 = (EditText) vFrag.findViewById(R.id.TextView1);
    mEditTextMessage2 = (EditText) vFrag.findViewById(R.id.TextView2);
    mButtonRecip1 = (Button) vFrag.findViewById(R.id.SendButtonRecipient1);
    mButtonRecip2 = (Button) vFrag.findViewById(R.id.SendButtonRecipient2);

    updateValues(savedInstanceState);/*  ww  w .j av  a 2s .  com*/

    OnClickListener clickSender = new OnClickListener() {

        @Override
        public void onClick(View v) {
            doClickRecipient1();
        }
    };
    mButtonRecip1.setOnClickListener(clickSender);

    OnClickListener clickRecip = new OnClickListener() {

        @Override
        public void onClick(View v) {
            doClickRecipient2();
        }
    };
    mButtonRecip2.setOnClickListener(clickRecip);

    mButtonSend.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            sendResultToHost(RESULT_SEND, resultIntent().getExtras());
        }
    });

    mEditTextMessage2.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEND) {
                sendResultToHost(RESULT_SEND, resultIntent().getExtras());
                return true;
            }
            return false;
        }
    });

    return vFrag;
}

From source file:com.acceleratedio.pac_n_zoom.PickAnmActivity.java

private void dsply_thumbnails(String tags) {
    // tags is a string that holds a 3 dimension array with a different delimiter
    // for each dimension. The most significant dimension is delimited with '|'.
    // The second dimension is delimited with a comma. The least dimension 
    // significant is '/' for [0][] and ' ' for [1][].
    top_dim = tags.split("\\|");
    fil_nams = top_dim[0].split("\\,");

    if (req_str.equals(""))
        orgnl_tags = top_dim[1]; // Used when saving animation

    GridView gv = (GridView) findViewById(R.id.tnview);
    gv.setAdapter(new ImageAdapter(this));

    gv.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override/*from  w ww. java 2  s  .com*/
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            if (mod_str.equals("animation")) {
                Intent intent = new Intent(PickAnmActivity.this,
                        com.acceleratedio.pac_n_zoom.AnimActivity.class);
                intent.putExtra("position", position);
                startActivity(intent);
            } else {
                Intent intent = new Intent(PickAnmActivity.this, com.acceleratedio.pac_n_zoom.ViewVideos.class);
                intent.putExtra("position", position);
                startActivity(intent);
            }
        }
    });

    searchEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

            boolean handled = false;
            req_str = searchEditText.getText().toString();

            if (actionId == EditorInfo.IME_ACTION_SEND) {

                MakePostRequest get_tags = new MakePostRequest();
                get_tags.execute(req_str);
                handled = true;
            }

            return handled;
        }
    });
}

From source file:com.mozilla.simplepush.simplepushdemoapp.MainActivity.java

/** Initialize the app from the saved state
 *
 * @param savedInstanceState The previously stored instance
 *//*  www.  j  a v a  2 s.  c o m*/
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Properties config;
    try {
        config = loadProperties();
        SENDER_ID = config.getProperty("sender_id");
        if (SENDER_ID == null) {
            Log.e(TAG, "sender_id not definied in configuration file. Aborting");
            return;
        }
    } catch (IOException x) {
        Log.e(TAG, "Could not load properties");
        return;
    }
    setContentView(R.layout.activity_main);

    // Set the convenience globals.
    mDisplay = (TextView) findViewById(R.id.display);
    hostUrl = (EditText) findViewById(R.id.host_edit);
    pingData = (EditText) findViewById(R.id.message);
    sendButton = (Button) findViewById(R.id.send);
    connectButton = (Button) findViewById(R.id.connect);

    context = getApplicationContext();
    // Check that GCM is available on this device.
    if (checkPlayServices()) {
        gcm = GoogleCloudMessaging.getInstance(this);
        regid = getRegistrationId(context);
    } else {
        Log.i(TAG, "No valid Google Play Services APK found");
    }

    // detect the "enter/submit" key for the editor views.
    hostUrl.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            boolean handled = false;
            // yes, be very careful about this, else you can send multiple actions.
            if (actionId == EditorInfo.IME_ACTION_SEND || (actionId == EditorInfo.IME_ACTION_UNSPECIFIED
                    && event.getKeyCode() == KeyEvent.KEYCODE_ENTER
                    && event.getAction() == KeyEvent.ACTION_DOWN)) {
                registerInBackground();
                handled = true;
            }
            return handled;
        }
    });

    pingData.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            boolean handled = false;
            if (actionId == EditorInfo.IME_ACTION_SEND || (actionId == EditorInfo.IME_ACTION_UNSPECIFIED
                    && event.getKeyCode() == KeyEvent.KEYCODE_ENTER
                    && event.getAction() == KeyEvent.ACTION_DOWN)) {
                SendNotification(getMessage());
                handled = true;
            }
            return handled;
        }
    });
}

From source file:com.waz.zclient.pages.main.popup.QuickReplyFragment.java

@Override
public boolean onEditorAction(TextView textView, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_SEND || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER
            && event.getAction() == KeyEvent.ACTION_DOWN)) {
        final String sendText = textView.getText().toString();
        if (TextUtils.isEmpty(sendText)) {
            return false;
        }//  www  .java  2s.c  om
        conversation.sendMessage(new MessageContent.Text(sendText));

        TrackingUtils.onSentTextMessage(getControllerFactory().getTrackingController(),
                getStoreFactory().getConversationStore().getCurrentConversation());
        getActivity().finish();
        return true;
    }
    return false;
}

From source file:com.amberfog.countryflagsdemo.BaseFlagFragment.java

protected void initUI(View rootView) {
    mSpinner = (Spinner) rootView.findViewById(R.id.spinner);
    mSpinner.setOnItemSelectedListener(mOnItemSelectedListener);

    mAdapter = new CountryAdapter(getActivity());

    mSpinner.setAdapter(mAdapter);/*from   w w  w.  j  a  va 2  s. co m*/

    mPhoneEdit = (EditText) rootView.findViewById(R.id.phone);
    mPhoneEdit.addTextChangedListener(new CustomPhoneNumberFormattingTextWatcher(mOnPhoneChangedListener));
    InputFilter filter = new InputFilter() {
        public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
                int dend) {
            for (int i = start; i < end; i++) {
                char c = source.charAt(i);
                if (dstart > 0 && !Character.isDigit(c)) {
                    return "";
                }
            }
            return null;
        }
    };

    mPhoneEdit.setFilters(new InputFilter[] { filter });

    mPhoneEdit.setImeOptions(EditorInfo.IME_ACTION_SEND);
    mPhoneEdit.setImeActionLabel(getString(R.string.label_send), EditorInfo.IME_ACTION_SEND);
    mPhoneEdit.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEND) {
                send();
                return true;
            }
            return false;
        }
    });

}