Search in sources :

Example 91 with InputMethodManager

use of android.view.inputmethod.InputMethodManager in project actor-platform by actorapp.

the class ShortcutActivity method handeleIntent.

private void handeleIntent(Intent i) {
    final Peer p = Peer.fromUniqueId(i.getLongExtra("peer", 0));
    String text = i.getStringExtra("text");
    final String name = users().get(p.getPeerId()).getName().get();
    if (text.contains("{input}") || text.contains("{input/num}")) {
        boolean num = text.contains("{input/num}");
        if (num) {
            text = text.replace("{input/num}", "{input}");
        }
        AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AlertDialogStyle);
        String title = text.replace("{input}", "") + " → " + name;
        builder.setTitle(title);
        LinearLayout ll = new LinearLayout(this);
        ll.setPadding(Screen.dp(20), 0, Screen.dp(20), 0);
        input = new EditText(this);
        if (num) {
            input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED);
        }
        input.setTextColor(Color.BLACK);
        ll.addView(input, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        builder.setView(ll);
        final String finalText = text;
        builder.setPositiveButton(getString(R.string.dialog_ok), new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                send(p, finalText.replace("{input}", input.getText().toString()), name);
            }
        });
        builder.setNegativeButton(R.string.dialog_cancel, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
            }
        });
        builder.setOnDismissListener(this);
        AlertDialog ad = builder.create();
        ad.setOnShowListener(new DialogInterface.OnShowListener() {

            @Override
            public void onShow(DialogInterface dialog) {
                InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
                input.requestFocus();
                inputMethodManager.showSoftInput(input, 0);
            }
        });
        ad.show();
    } else if (text.contains("{choose}") && text.contains("{/choose}")) {
        final String rawVars = text.substring(text.indexOf("{choose}") + 8, text.indexOf("{/choose}"));
        final String[] vars = rawVars.split("/");
        AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AlertDialogStyle);
        final String rawCommand = text.replace(rawVars, "").replace("{choose}", "").replace("{/choose}", "");
        builder.setTitle(rawCommand + " → " + name);
        textToSend = rawCommand + vars[0];
        builder.setSingleChoiceItems(vars, 0, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                textToSend = rawCommand + vars[which];
            }
        });
        builder.setPositiveButton(getString(R.string.dialog_ok), new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                send(p, textToSend, name);
            }
        });
        builder.setNegativeButton(R.string.dialog_cancel, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
            }
        });
        builder.setOnDismissListener(this);
        builder.show();
    } else {
        send(p, text, name);
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) EditText(android.widget.EditText) DialogInterface(android.content.DialogInterface) Peer(im.actor.core.entity.Peer) InputMethodManager(android.view.inputmethod.InputMethodManager) LinearLayout(android.widget.LinearLayout)

Example 92 with InputMethodManager

use of android.view.inputmethod.InputMethodManager in project GT by Tencent.

the class GTLogFragment method cancelFilterMsgInput.

private void cancelFilterMsgInput(View v) {
    btn_msg_input_cancel.setVisibility(View.GONE);
    btn_level.setVisibility(View.VISIBLE);
    btn_tag.setVisibility(View.VISIBLE);
    btn_level_toast.setVisibility(View.VISIBLE);
    btn_tag_toast.setVisibility(View.VISIBLE);
    LayoutParams laParams = (LayoutParams) et_Msg.getLayoutParams();
    laParams.width = (int) (displayWidth / 2.74);
    et_Msg.setLayoutParams(laParams);
    InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(v.getApplicationWindowToken(), 0);
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) InputMethodManager(android.view.inputmethod.InputMethodManager)

Example 93 with InputMethodManager

use of android.view.inputmethod.InputMethodManager in project GT by Tencent.

the class GTLogSearchActivity method cancelFilterMsgInput.

private void cancelFilterMsgInput(View v) {
    InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(v.getApplicationWindowToken(), 0);
}
Also used : InputMethodManager(android.view.inputmethod.InputMethodManager)

Example 94 with InputMethodManager

use of android.view.inputmethod.InputMethodManager in project GT by Tencent.

the class GTOpMulPerfActivity method cancelFilterMsgInput.

private void cancelFilterMsgInput(View v) {
    InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(v.getApplicationWindowToken(), 0);
}
Also used : InputMethodManager(android.view.inputmethod.InputMethodManager)

Example 95 with InputMethodManager

use of android.view.inputmethod.InputMethodManager in project GT by Tencent.

the class GTOpSinglePerfActivity method cancelFilterMsgInput.

private void cancelFilterMsgInput(View v) {
    InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(v.getApplicationWindowToken(), 0);
}
Also used : InputMethodManager(android.view.inputmethod.InputMethodManager)

Aggregations

InputMethodManager (android.view.inputmethod.InputMethodManager)631 View (android.view.View)120 TextView (android.widget.TextView)67 Paint (android.graphics.Paint)43 Spannable (android.text.Spannable)34 Editable (android.text.Editable)33 EditText (android.widget.EditText)33 ImageView (android.widget.ImageView)31 Intent (android.content.Intent)29 RemoteException (android.os.RemoteException)23 KeyEvent (android.view.KeyEvent)22 TextPaint (android.text.TextPaint)21 Point (android.graphics.Point)18 InputMethodInfo (android.view.inputmethod.InputMethodInfo)18 AdapterView (android.widget.AdapterView)18 Button (android.widget.Button)16 RemoteView (android.widget.RemoteViews.RemoteView)16 Resources (android.content.res.Resources)15 ListView (android.widget.ListView)15 InputMethodSubtype (android.view.inputmethod.InputMethodSubtype)14