Example usage for android.view.inputmethod InputMethodManager SHOW_FORCED

List of usage examples for android.view.inputmethod InputMethodManager SHOW_FORCED

Introduction

In this page you can find the example usage for android.view.inputmethod InputMethodManager SHOW_FORCED.

Prototype

int SHOW_FORCED

To view the source code for android.view.inputmethod InputMethodManager SHOW_FORCED.

Click Source Link

Document

Flag for #showSoftInput to indicate that the user has forced the input method open (such as by long-pressing menu) so it should not be closed until they explicitly do so.

Usage

From source file:org.transdroid.core.gui.search.UrlEntryDialog.java

/**
 * Opens a dialog that allows entry of a single URL string, which (on confirmation) will be supplied to the calling
 * activity's {@link TorrentsActivity#addTorrentByUrl(String, String) method}.
 * @param activity The activity that opens (and owns) this dialog
 *//* ww w  .j  a  v a2s.  com*/
@SuppressLint("ValidFragment")
public static void startUrlEntry(final TorrentsActivity activity) {
    new DialogFragment() {
        public android.app.Dialog onCreateDialog(android.os.Bundle savedInstanceState) {
            final EditText urlInput = new EditText(activity);
            urlInput.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
            ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE))
                    .toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
            return new AlertDialog.Builder(activity).setView(urlInput)
                    .setPositiveButton(android.R.string.ok, new OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            // Assume text entry box input as URL and treat the filename (after the last /) as title
                            String url = urlInput.getText().toString();
                            Uri uri = Uri.parse(url);
                            if (activity != null && !TextUtils.isEmpty(url)) {
                                String title = NavigationHelper.extractNameFromUri(uri);
                                if (uri.getScheme() != null && uri.getScheme().equals("magnet")) {
                                    activity.addTorrentByMagnetUrl(url, title);
                                } else {
                                    activity.addTorrentByUrl(url, title);
                                }
                            }
                        }
                    }).setNegativeButton(android.R.string.cancel, null).create();
        };
    }.show(activity.getSupportFragmentManager(), "urlentry");
}

From source file:com.lixplor.fastutil.utils.control.KeyboardUtil.java

public static void show(@NonNull View view) {
    view.requestFocus();
    sInputMethodManager.showSoftInput(view, InputMethodManager.SHOW_FORCED);
}

From source file:org.mitre.svmp.client.IntentHandler.java

public static void inspect(SVMPProtocol.Response response, Context context) {
    SVMPProtocol.Intent intent = response.getIntent();
    switch (intent.getAction()) {
    case ACTION_DIAL:
        Log.d(TAG, String.format("Received 'call' Intent for number '%s'", intent.getData()));
        int telephonyEnabled = isTelephonyEnabled(context);
        if (telephonyEnabled == 0) {
            Intent call = new Intent(Intent.ACTION_CALL);
            call.setData(Uri.parse(intent.getData()));
            context.startActivity(call);
        } else {//from   w w w  .  ja  v a 2  s  . co m
            // phone calls are not supported on this device; send a Toast to
            // the user to let them know
            Toast toast = Toast.makeText(context, telephonyEnabled, Toast.LENGTH_LONG);
            toast.show();
        }
        break;
    case ACTION_VIEW:
        String jsonStr = intent.getData().toString();
        JSONObject jObj = null;
        String message = null;
        try {
            jObj = new JSONObject(jsonStr);
            message = jObj.getString("message");

            if (jObj != null && message != null) {
                switch (message) {
                case "keyboardStarted":

                    InputMethodManager imm = (InputMethodManager) context
                            .getSystemService(context.INPUT_METHOD_SERVICE);
                    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
                    break;

                case "appInstalled":

                    String success = jObj.getString("success");
                    String packageName = jObj.getString("packageId");

                    if (success != null) {
                        if (success.equals("true"))
                            startApp(packageName, context);
                    }
                    break;

                default:
                    break;
                }
            }

        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        break;
    default:
        break;
    }
}

From source file:org.openmidaas.app.activities.EnterURLDialogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.dialog_fragment, container, false);
    mActivity = getActivity();/*  www  .j  av  a 2  s  . c  o m*/

    imgr = (InputMethodManager) mActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
    imgr.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
    edUrl = (EditText) view.findViewById(R.id.edDialogFragment);
    edUrl.requestFocus();
    mParentScrollView = (ScrollView) view.findViewById(R.id.svParentURLFragment);
    onTapOutsideBehaviour(mParentScrollView);

    btnPositive = (Button) view.findViewById(R.id.btnOkayDialogFragment);
    btnPositive.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            //Get the URL
            View tv = getActivity().findViewById(R.id.edDialogFragment);
            String merchantUrl = ((EditText) tv).getText().toString();
            ((MainTabActivity) getActivity()).processUrl(merchantUrl);
        }
    });

    btnClear = (Button) view.findViewById(R.id.btnClearDialogFragment);
    btnClear.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            //Clear the text to set it to default
            View ed = getActivity().findViewById(R.id.edDialogFragment);
            ((EditText) ed).setText(getResources().getString(R.string.enterUrlHint));
            ((EditText) ed).setSelection(((EditText) ed).getText().length());
        }
    });
    return view;
}

From source file:org.badreader.client.fragments.BaseFragment.java

protected void showKeyboard(final Activity _context, final EditText _edit) {
    final InputMethodManager imm = (InputMethodManager) _context.getSystemService(Context.INPUT_METHOD_SERVICE);

    if (android.os.Build.VERSION.SDK_INT < 11) {
        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
    }//ww  w. jav  a 2  s .  co m

    _edit.postDelayed(new Runnable() {
        public void run() {
            _edit.requestFocus();
            imm.showSoftInput(_edit, 0);
        }
    }, 100);
}

From source file:io.trigger.forge.android.modules.keyboard.API.java

public static void show() {
    InputMethodManager mgr = getKeyboard();
    mgr.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
}

From source file:org.akvo.caddisfly.sensor.ec.EditSensorIdentity.java

@NonNull
@Override//w w w.j a  va 2 s  .c o m
public Dialog onCreateDialog(Bundle savedInstanceState) {

    final Context context = getActivity();

    LayoutInflater i = getActivity().getLayoutInflater();

    @SuppressLint("InflateParams")
    View view = i.inflate(R.layout.fragment_edit_sensor_identity, null);

    editId = (EditText) view.findViewById(R.id.editId);

    editId.requestFocus();

    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);

    AlertDialog.Builder b = new AlertDialog.Builder(getActivity()).setTitle(R.string.sensorDetails)
            .setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {

                }
            }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    closeKeyboard(context, editId);
                    dismiss();
                }
            });

    b.setView(view);
    return b.create();
}

From source file:de.grobox.liberario.favorites.trips.SpecialLocationFragment.java

@Override
public void onResume() {
    super.onResume();

    getDialog().setCanceledOnTouchOutside(true);

    // set width to match parent
    Window window = getDialog().getWindow();
    if (window != null) {
        window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
        window.setGravity(Gravity.TOP);/*from   w  w  w. j a va 2 s  . c om*/
    }

    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(loc, InputMethodManager.SHOW_FORCED);
}

From source file:com.andrew.apollo.menu.BasePlaylistDialog.java

/**
 * Opens the soft keyboard//from   w w  w .  j  a v  a 2 s.  c  o  m
 */
protected void openKeyboard() {
    final InputMethodManager mInputMethodManager = (InputMethodManager) getActivity()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    mInputMethodManager.toggleSoftInputFromWindow(mPlaylist.getApplicationWindowToken(),
            InputMethodManager.SHOW_FORCED, 0);
}

From source file:com.fbartnitzek.tasteemall.filter.AttributeFilterTextTabFragment.java

@Nullable
@Override// w  ww  .j  a va 2  s .  c  om
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {

    super.onCreateView(inflater, container, savedInstanceState);

    mEditFilter = (EditText) mRootView.findViewById(R.id.attribute_filter);
    mEditFilter.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

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

        }

        @Override
        public void afterTextChanged(Editable s) {
            mAttributeFilter = s.toString();
            //                Log.v(LOG_TAG, "afterTextChanged, hashCode=" + this.hashCode() + ", " + "s = [" + s + "]");
            getLoaderManager().restartLoader(ATTRIBUTE_VALUES_LOADER_ID, null,
                    AttributeFilterTextTabFragment.this);
        }
    });

    mEditFilter.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            //                Log.v(LOG_TAG, "onEditorAction, hashCode=" + this.hashCode() + ", " + "v = [" + v + "], actionId = [" + actionId + "], event = [" + event + "]");
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                InputMethodManager imm = (InputMethodManager) getContext()
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(mEditFilter.getWindowToken(), 0);
                return true;
            }
            return false;
        }
    });

    // focus editFilter - thx for: http://stackoverflow.com/a/26012003/5477716
    mEditFilter.requestFocus();
    InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);

    mValuesRecycler = (RecyclerView) mRootView.findViewById(R.id.attribute_filter_list);
    mValuesRecycler.setLayoutManager(new LinearLayoutManager(getContext()));

    mAttributeValuesAdapter = new AttributeValuesAdapter(this);
    mValuesRecycler.setAdapter(mAttributeValuesAdapter);

    return mRootView;
}