Example usage for android.view Window setSoftInputMode

List of usage examples for android.view Window setSoftInputMode

Introduction

In this page you can find the example usage for android.view Window setSoftInputMode.

Prototype

public void setSoftInputMode(int mode) 

Source Link

Document

Specify an explicit soft input mode to use for the window, as per WindowManager.LayoutParams#softInputMode WindowManager.LayoutParams.softInputMode .

Usage

From source file:Main.java

public static void showKeyboard(@NonNull Window window) {
    window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}

From source file:Main.java

public static void forceShowInputMethod(Activity activity) {
    Window window = activity.getWindow();
    window.setSoftInputMode(
            window.getAttributes().softInputMode | WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
}

From source file:cc.metapro.openct.utils.ActivityUtils.java

public static AlertDialog addViewToAlertDialog(@NonNull final AlertDialog.Builder builder,
        @NonNull final View view) {
    ViewGroup parent = (ViewGroup) view.getParent();
    if (parent != null) {
        parent.removeView(view);/*from  ww w .  ja  v  a  2 s.c o m*/
    }

    ScrollView scrollView = new ScrollView(builder.getContext());
    scrollView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    scrollView.addView(view);

    builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            InputMethodManager imm = (InputMethodManager) builder.getContext()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
        }
    });

    AlertDialog dialog = builder.setView(scrollView).create();
    Window window = dialog.getWindow();
    if (window != null) {
        window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    }
    return dialog;
}

From source file:com.waz.zclient.utils.ViewUtils.java

public static void setSoftInputMode(Window window, int softInputMode, String sender) {
    window.setSoftInputMode(softInputMode);
}

From source file:net.wequick.small.ApkBundleLauncher.java

/**
 * Apply plugin activity info with plugin's AndroidManifest.xml
 * @param activity/*from   ww w.  j a  v  a  2 s  .  com*/
 * @param ai
 */
private static void applyActivityInfo(Activity activity, ActivityInfo ai) {
    // Apply window attributes
    Window window = activity.getWindow();
    window.setSoftInputMode(ai.softInputMode);
    activity.setRequestedOrientation(ai.screenOrientation);
}

From source file:com.gbozza.android.stockhawk.ui.AddStockDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    LayoutInflater inflater = LayoutInflater.from(getActivity());
    @SuppressLint("InflateParams")
    View custom = inflater.inflate(R.layout.add_stock_dialog, null);

    ButterKnife.bind(this, custom);

    stock.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override//from  w ww  . ja  va  2s.  co m
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            addStock();
            return true;
        }
    });
    builder.setView(custom);

    builder.setMessage(getString(R.string.dialog_title));
    builder.setPositiveButton(getString(R.string.dialog_add), new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            addStock();
        }
    });
    builder.setNegativeButton(getString(R.string.dialog_cancel), null);

    Dialog dialog = builder.create();

    Window window = dialog.getWindow();
    if (window != null) {
        window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    }

    return dialog;
}

From source file:com.tomeokin.lspush.biz.auth.CountryCodePickerDialog.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    Window window = getDialog().getWindow();
    if (window != null) {
        window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN
                | WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    }//w  w  w . j ava 2  s . c  o m
}

From source file:org.mozilla.focus.fragment.AddToHomescreenDialogFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    final Dialog dialog = getDialog();
    if (dialog != null) {
        final Window window = dialog.getWindow();
        if (window != null) {
            window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
        }//w  w  w . j  a va2 s . c o  m
    }
}

From source file:com.ui.UiWindow.java

public void showProgressDialogKeyboard(Window window) {
    window.clearFlags(/*from w ww.  j ava2 s .c  o m*/
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
    window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
}

From source file:ca.rmen.android.poetassistant.main.dictionaries.FilterDialogFragment.java

/**
 * @return a Dialog with a title, message, an edit text, and ok/cancel buttons.
 *//*ww w  .  ja va2 s.c om*/
@Override
@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Log.v(TAG, "onCreateDialog: savedInstanceState = " + savedInstanceState);
    Context context = getActivity();
    LayoutInflater themedLayoutInflater = LayoutInflater
            .from(new ContextThemeWrapper(getActivity(), R.style.AppAlertDialog));
    final InputDialogEditTextBinding binding = DataBindingUtil.inflate(themedLayoutInflater,
            R.layout.input_dialog_edit_text, null, false);
    Bundle arguments = getArguments();
    binding.edit.setText(arguments.getString(EXTRA_TEXT));

    OnClickListener positiveListener = (dialog, which) -> {
        FilterDialogListener listener;
        Fragment parentFragment = getParentFragment();
        if (parentFragment instanceof FilterDialogListener)
            listener = (FilterDialogListener) parentFragment;
        else
            listener = (FilterDialogListener) getActivity();
        listener.onFilterSubmitted(binding.edit.getText().toString());
    };

    final Dialog dialog = new AlertDialog.Builder(context).setView(binding.getRoot())
            .setTitle(R.string.filter_title).setMessage(arguments.getString(EXTRA_MESSAGE))
            .setPositiveButton(android.R.string.ok, positiveListener)
            .setNegativeButton(android.R.string.cancel, null).create();

    binding.edit.setOnFocusChangeListener((v, hasFocus) -> {
        Window window = dialog.getWindow();
        if (window != null) {
            if (hasFocus) {
                window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
            } else {
                window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
            }
        }
    });

    return dialog;
}