List of usage examples for android.view Window setSoftInputMode
public void setSoftInputMode(int mode)
From source file:android.support.v7.preference.PreferenceDialogFragmentCompat.java
/** * Sets the required flags on the dialog window to enable input method window to show up. *//*from w w w . ja va 2s .c om*/ private void requestInputMethod(Dialog dialog) { Window window = dialog.getWindow(); window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); }
From source file:com.android.julia.todolist.ui.EditTaskDialogFragment.java
@NonNull @Override/* w w w. j av a2 s.c om*/ public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity()); alertDialogBuilder.setTitle(getString(R.string.title_edit_task_dialog)); alertDialogBuilder.setPositiveButton(getString(R.string.action_save_edit_task_dialog), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { onClickSaveTask(); } }); alertDialogBuilder.setNegativeButton(getString(R.string.action_cancel_edit_task_dialog), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); // Fetch arguments from bundle and set position, description, and priority mPosition = getArguments().getInt("position", 0); String description = getArguments().getString("description"); mPriority = getArguments().getInt("priority", 1); View v = View.inflate(getContext(), R.layout.fragment_edit_task, null); // Get field from view mTaskDescriptionEditText = (EditText) v.findViewById(R.id.editTextTaskDescription); // Set user's cursor in the text field at the end of the current text value // and focused by default mTaskDescriptionEditText.setText(""); mTaskDescriptionEditText.append(description); // Show soft keyboard automatically and request focus to field mTaskDescriptionEditText.requestFocus(); mHighRadioButton = (RadioButton) v.findViewById(R.id.radButton1); mMediumRadioButton = (RadioButton) v.findViewById(R.id.radButton2); mLowRadioButton = (RadioButton) v.findViewById(R.id.radButton3); mHighRadioButton.setOnClickListener(this); mMediumRadioButton.setOnClickListener(this); mLowRadioButton.setOnClickListener(this); if (mPriority == 1) { mHighRadioButton.setChecked(true); } else if (mPriority == 2) { mMediumRadioButton.setChecked(true); } else if (mPriority == 3) { mLowRadioButton.setChecked(true); } // Set to adjust screen height automatically, when soft keyboard appears on screen Window window = alertDialogBuilder.create().getWindow(); if (window != null) { window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); } alertDialogBuilder.setView(v); return alertDialogBuilder.create(); }
From source file:de.grobox.transportr.favorites.locations.SpecialLocationFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); getDialog().setCanceledOnTouchOutside(true); // set width to match parent and show keyboard Window window = getDialog().getWindow(); if (window != null) { window.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); window.setGravity(Gravity.TOP);/* w w w .j a va2s . co m*/ window.setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE); } }
From source file:com.zogamonline.laisiangthou.MaterialPreferenceLib.custom_preferences.DialogPreference.java
private void requestInputMethod(Dialog dialog) { Window window = dialog.getWindow(); window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); }
From source file:ca.rmen.android.scrumchatter.dialog.InputDialogFragment.java
@Override @NonNull//from w w w.j a v a 2s .c om public Dialog onCreateDialog(Bundle savedInstanceState) { Log.v(TAG, "onCreateDialog: savedInstanceState = " + savedInstanceState); if (savedInstanceState != null) mEnteredText = savedInstanceState.getString(DialogFragmentFactory.EXTRA_ENTERED_TEXT); Bundle arguments = getArguments(); final int actionId = arguments.getInt(DialogFragmentFactory.EXTRA_ACTION_ID); final InputDialogEditTextBinding binding = DataBindingUtil.inflate(LayoutInflater.from(getActivity()), R.layout.input_dialog_edit_text, null, false); final Bundle extras = arguments.getBundle(DialogFragmentFactory.EXTRA_EXTRAS); final Class<?> inputValidatorClass = (Class<?>) arguments .getSerializable(DialogFragmentFactory.EXTRA_INPUT_VALIDATOR_CLASS); final String prefilledText = arguments.getString(DialogFragmentFactory.EXTRA_ENTERED_TEXT); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(arguments.getString(DialogFragmentFactory.EXTRA_TITLE)); builder.setView(binding.getRoot()); binding.edit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS); binding.edit.setHint(arguments.getString(DialogFragmentFactory.EXTRA_INPUT_HINT)); binding.edit.setText(prefilledText); if (!TextUtils.isEmpty(mEnteredText)) binding.edit.setText(mEnteredText); // Notify the activity of the click on the OK button. OnClickListener listener = null; if ((getActivity() instanceof DialogInputListener)) { listener = (dialog, which) -> { FragmentActivity activity = getActivity(); if (activity == null) Log.w(TAG, "User clicked on dialog after it was detached from activity. Monkey?"); else ((DialogInputListener) activity).onInputEntered(actionId, binding.edit.getText().toString(), extras); }; } builder.setNegativeButton(android.R.string.cancel, null); builder.setPositiveButton(android.R.string.ok, listener); final AlertDialog dialog = builder.create(); // Show the keyboard when the EditText gains focus. binding.edit.setOnFocusChangeListener((v, hasFocus) -> { if (hasFocus) { Window window = dialog.getWindow(); if (window != null) { window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } } }); final Context context = getActivity(); try { final InputValidator validator = inputValidatorClass == null ? null : (InputValidator) inputValidatorClass.newInstance(); Log.v(TAG, "input validator = " + validator); // Validate the text as the user types. binding.edit.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { mEnteredText = binding.edit.getText().toString(); if (validator != null) validateText(context, dialog, binding.edit, validator, actionId, extras); } }); dialog.setOnShowListener(dialogInterface -> { Log.v(TAG, "onShow"); validateText(context, dialog, binding.edit, validator, actionId, extras); }); } catch (Exception e) { Log.e(TAG, "Could not instantiate validator " + inputValidatorClass + ": " + e.getMessage(), e); } return dialog; }
From source file:com.github.chilinh.android.form.Form.java
private void applyWindow(Window window) { window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); }
From source file:com.imagine.BaseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Window win = getWindow(); win.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR); super.onCreate(savedInstanceState); win.setBackgroundDrawable(null);/*www. j a va 2 s .c o m*/ win.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); if (android.os.Build.VERSION.SDK_INT >= 11) { // NativeActivity explicitly sets the window format to RGB_565, this is fine in Android 2.3 since we default to that // and call setFormat ourselves, but in >= 3.0 we only use ANativeWindow_setBuffersGeometry so set the format back to // the default value to avoid a spurious surface destroy & create the next time the window flags are set since it may // cause the screen to flash win.setFormat(PixelFormat.UNKNOWN); } // get rid of NativeActivity's view and layout listener, then add our custom view View nativeActivityView = findViewById(android.R.id.content); nativeActivityView.getViewTreeObserver().removeGlobalOnLayoutListener(this); View contentView; if (android.os.Build.VERSION.SDK_INT >= 24) contentView = new ContentViewV24(this); else if (android.os.Build.VERSION.SDK_INT >= 16) contentView = new ContentViewV16(this); else contentView = new ContentViewV9(this); setContentView(contentView); contentView.requestFocus(); }
From source file:ru.tinkoff.acquiring.sdk.EnterCardFragment.java
@Override public void onResume() { super.onResume(); boolean isUsingCustomKeyboard = ((PayFormActivity) getActivity()).shouldUseCustomKeyboard(); if (customKeyboard != null && isUsingCustomKeyboard) { customKeyboard.attachToView(ecvCard); Window window = getActivity().getWindow(); window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED); }//from w w w . jav a 2s . co m }
From source file:com.owncloud.android.ui.activity.ReceiveExternalFilesActivity.java
/** * Suggest a filename based on the extras in the intent. * Show soft keyboard when no filename could be suggested. * * @param alertDialog AlertDialog/*from w w w . j a va 2s . c om*/ * @param input EditText The view where to place the filename in. */ private void setFileNameFromIntent(AlertDialog alertDialog, EditText input) { String subject = getIntent().getStringExtra(Intent.EXTRA_SUBJECT); String title = getIntent().getStringExtra(Intent.EXTRA_TITLE); String fileName = subject != null ? subject : title; input.setText(fileName); input.selectAll(); if (fileName == null) { // Show soft keyboard Window window = alertDialog.getWindow(); if (window != null) window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); } }
From source file:ru.tinkoff.acquiring.sdk.EnterCardFragment.java
@Nullable @Override// ww w .j a va2 s . c om public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { int[] intTypes = getActivity().getIntent().getIntArrayExtra(PayFormActivity.EXTRA_DESIGN_CONFIGURATION); PayCellType[] cellTypes = PayCellType.toPayCellTypeArray(intTypes); View view = PayCellInflater.from(inflater, cellTypes).inflate(container); ecvCard = view.findViewById(R.id.ecv_card); tvSrcCardLabel = view.findViewById(R.id.tv_src_card_label); tvDescription = view.findViewById(R.id.tv_description); tvTitle = view.findViewById(R.id.tv_title); tvAmount = view.findViewById(R.id.tv_amount); tvChooseCardButton = view.findViewById(R.id.tv_src_card_choose_btn); btnPay = view.findViewById(R.id.btn_pay); btnGooglePay = view.findViewById(R.id.rl_google_play_button); if (btnGooglePay != null) { btnGooglePay.setEnabled(false); } srcCardChooser = view.findViewById(R.id.ll_src_card_chooser); etEmail = view.findViewById(R.id.et_email); final FragmentActivity activity = getActivity(); cardScanner = new FullCardScanner(this, (ICameraCardScanner) activity.getIntent() .getSerializableExtra(PayFormActivity.EXTRA_CAMERA_CARD_SCANNER)); ecvCard.setCardSystemIconsHolder(new ThemeCardLogoCache(activity)); ecvCard.setActions(cardScanner); if (!cardScanner.isScanEnable()) { ecvCard.setBtnScanIcon(View.NO_ID); } customKeyboard = view.findViewById(R.id.acq_keyboard); googlePayParams = activity.getIntent().getParcelableExtra(PayFormActivity.EXTRA_ANDROID_PAY_PARAMS); initGooglePayButton(); boolean isUsingCustomKeyboard = ((PayFormActivity) activity).shouldUseCustomKeyboard(); if (isUsingCustomKeyboard) { // disable soft keyboard while custom keyboard is not attached to edit card view Window window = getActivity().getWindow(); window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); ecvCard.disableCopyPaste(); } else { customKeyboard.hide(); } tvChooseCardButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Card[] cards = ((PayFormActivity) activity).getCards(); if (cards != null) { startChooseCard(); } } }); srcCardChooser.setVisibility(View.GONE); chargeMode = getArguments().getBoolean(PayFormActivity.EXTRA_CHARGE_MODE); if (chargeMode) { setRecurrentModeForCardView(true); ecvCard.setRecurrentPaymentMode(true); } if (amountPositionMode != AMOUNT_POSITION_OVER_FIELDS) { View amountLayout = view.findViewById(R.id.ll_price_layout); if (amountLayout != null) { amountLayout.setVisibility(View.GONE); } } resolveButtonAndIconsPosition(view); return view; }