Example usage for android.view.inputmethod InputMethodManager RESULT_UNCHANGED_SHOWN

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

Introduction

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

Prototype

int RESULT_UNCHANGED_SHOWN

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

Click Source Link

Document

Flag for the ResultReceiver result code from #showSoftInput(View,int,ResultReceiver) and #hideSoftInputFromWindow(IBinder,int,ResultReceiver) : the state of the soft input window was unchanged and remains shown.

Usage

From source file:org.secuso.privacyfriendlypasswordgenerator.dialogs.UpdatePasswordDialog.java

public Dialog onCreateDialog(Bundle savedInstanceState) {

    LayoutInflater inflater = getActivity().getLayoutInflater();
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    rootView = inflater.inflate(R.layout.dialog_update_passwords, null);

    visibility = false;/*from  ww  w.  ja va 2s .  c om*/

    spinnerOld = (ProgressBar) rootView.findViewById(R.id.oldProgressBar);
    spinnerOld.setVisibility(View.GONE);

    spinnerNew = (ProgressBar) rootView.findViewById(R.id.newProgressBar);
    spinnerNew.setVisibility(View.GONE);

    Bundle bundle = getArguments();

    position = bundle.getInt("position");
    bindToDevice_enabled = bundle.getBoolean("bindToDevice_enabled");
    hashAlgorithm = bundle.getString("hash_algorithm");
    setOldMetaData(bundle);
    number_iterations = bundle.getInt("number_iterations");

    database = MetaDataSQLiteHelper.getInstance(getActivity());

    builder.setView(rootView);

    builder.setIcon(R.mipmap.ic_drawer);

    builder.setTitle(getActivity().getString(R.string.passwords_heading));

    Button displayButton = (Button) rootView.findViewById(R.id.displayButton);
    displayButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            InputMethodManager inputManager = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);

            inputManager.hideSoftInputFromWindow(view.getWindowToken(),
                    InputMethodManager.RESULT_UNCHANGED_SHOWN);

            displayPasswords();
        }
    });

    ImageButton copyOldButton = (ImageButton) rootView.findViewById(R.id.copyOldButton);
    ImageButton copyNewButton = (ImageButton) rootView.findViewById(R.id.copyNewButton);

    copyOldButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            TextView oldPassword = (TextView) rootView.findViewById(R.id.textViewOldPassword);
            ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText("", oldPassword.getText());
            clipboard.setPrimaryClip(clip);
            Toast.makeText(getActivity(), getActivity().getString(R.string.copy_clipboar_old),
                    Toast.LENGTH_SHORT).show();
        }
    });

    copyNewButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            TextView newPassword = (TextView) rootView.findViewById(R.id.textViewNewPassword);
            ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText("", newPassword.getText());
            clipboard.setPrimaryClip(clip);
            Toast.makeText(getActivity(), getActivity().getString(R.string.copy_clipboar_new),
                    Toast.LENGTH_SHORT).show();
        }
    });

    builder.setPositiveButton(getActivity().getString(R.string.done), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            onClickDone();
        }
    });

    visibilityButton = (ImageButton) rootView.findViewById(R.id.visibilityButton);

    visibilityButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            editTextUpdateMasterpassword = (EditText) rootView.findViewById(R.id.editTextUpdateMasterpassword);

            if (!visibility) {
                visibilityButton.setImageResource(R.drawable.ic_visibility_off);
                editTextUpdateMasterpassword.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
                editTextUpdateMasterpassword.setSelection(editTextUpdateMasterpassword.getText().length());
                visibility = true;
            } else {
                visibilityButton.setImageResource(R.drawable.ic_visibility);
                editTextUpdateMasterpassword
                        .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
                editTextUpdateMasterpassword.setSelection(editTextUpdateMasterpassword.getText().length());
                visibility = false;
            }
        }
    });

    return builder.create();
}

From source file:org.secuso.privacyfriendlypasswordgenerator.dialogs.GeneratePasswordDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    LayoutInflater inflater = getActivity().getLayoutInflater();
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    rootView = inflater.inflate(R.layout.dialog_generate_password, null);

    Bundle bundle = getArguments();/* w w  w.  j a v a2s .  com*/

    position = bundle.getInt("position");
    clipboard_enabled = bundle.getBoolean("clipboard_enabled");
    bindToDevice_enabled = bundle.getBoolean("bindToDevice_enabled");
    hashAlgorithm = bundle.getString("hash_algorithm");
    number_iterations = bundle.getInt("number_iterations");
    visibility = false;

    spinner = (ProgressBar) rootView.findViewById(R.id.progressBar);
    spinner.setVisibility(View.GONE);

    database = MetaDataSQLiteHelper.getInstance(getActivity());
    metaData = database.getMetaData(position);

    TextView domain = (TextView) rootView.findViewById(R.id.domainHeadingTextView);
    domain.setText(metaData.getDOMAIN());

    TextView username = (TextView) rootView.findViewById(R.id.domainUsernameTextView);

    username.setText(metaData.getUSERNAME());

    TextView iteration = (TextView) rootView.findViewById(R.id.textViewIteration);
    iteration.setText(String.valueOf(metaData.getITERATION()));

    builder.setView(rootView);
    builder.setIcon(R.mipmap.ic_drawer);
    builder.setTitle(getActivity().getString(R.string.generate_heading));
    builder.setPositiveButton(getActivity().getString(R.string.done), null);

    Button generateButton = (Button) rootView.findViewById(R.id.generatorButton);
    generateButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            TextView textViewPassword = (TextView) rootView.findViewById(R.id.textViewPassword);
            textViewPassword.setText("");

            InputMethodManager inputManager = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);

            inputManager.hideSoftInputFromWindow(view.getWindowToken(),
                    InputMethodManager.RESULT_UNCHANGED_SHOWN);

            editTextMasterpassword = (EditText) rootView.findViewById(R.id.editTextMasterpassword);

            if (editTextMasterpassword.getText().toString().length() == 0) {
                Toast toast = Toast.makeText(getActivity().getBaseContext(),
                        getString(R.string.enter_masterpassword), Toast.LENGTH_SHORT);
                toast.show();
            } else if (editTextMasterpassword.getText().toString().length() < 8) {
                Toast toast = Toast.makeText(getActivity().getBaseContext(),
                        getString(R.string.masterpassword_length), Toast.LENGTH_SHORT);
                toast.show();
            } else {

                spinner.setVisibility(View.VISIBLE);

                generatePassword();
            }
        }
    });

    ImageButton copyButton = (ImageButton) rootView.findViewById(R.id.copyButton);

    copyButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            TextView password = (TextView) rootView.findViewById(R.id.textViewPassword);

            if (password.getText().toString().length() > 0) {
                ClipboardManager clipboard = (ClipboardManager) getActivity()
                        .getSystemService(CLIPBOARD_SERVICE);
                ClipData clip = ClipData.newPlainText("", password.getText());
                clipboard.setPrimaryClip(clip);
                Toast.makeText(getActivity(), getActivity().getString(R.string.password_copied),
                        Toast.LENGTH_SHORT).show();
            }

        }
    });

    visibilityButton = (ImageButton) rootView.findViewById(R.id.visibilityButton);

    visibilityButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            editTextMasterpassword = (EditText) rootView.findViewById(R.id.editTextMasterpassword);

            if (!visibility) {
                visibilityButton.setImageResource(R.drawable.ic_visibility_off);
                editTextMasterpassword.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
                editTextMasterpassword.setSelection(editTextMasterpassword.getText().length());
                visibility = true;
            } else {
                visibilityButton.setImageResource(R.drawable.ic_visibility);
                editTextMasterpassword
                        .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
                editTextMasterpassword.setSelection(editTextMasterpassword.getText().length());
                visibility = false;
            }
        }
    });

    return builder.create();
}

From source file:ca.shoaib.ping.PingListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View rootView = inflater.inflate(R.layout.fragment_ping_list, container, false);

    mListView = (ListView) rootView.findViewById(R.id.list_ping);

    pingListAdapter = new PingListAdapter(getActivity(), R.layout.ping_row, pingList);
    mListView.setAdapter(pingListAdapter);
    //mListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override/*from  w w w . jav a  2 s  .c o  m*/
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mPingListCallback.onPingSelected(pingList.get(position));
            mActivatedPosition = position;
            setActivatedPosition(position);
            //Log.d(TAG, "ArtistId: " + artistList.get(position).getArtistId());
        }
    });

    pb = (ProgressBar) rootView.findViewById(R.id.progress_bar);
    et = (EditText) rootView.findViewById(R.id.ping_destination);
    tv = (TextView) rootView.findViewById(R.id.ping_result);
    btn = (Button) rootView.findViewById(R.id.ping_start);

    btn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            String stringUrl = et.getText().toString();

            ConnectivityManager connMgr = (ConnectivityManager) getActivity()
                    .getSystemService(Context.CONNECTIVITY_SERVICE);
            NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();

            if (networkInfo != null && networkInfo.isConnected()) {
                AsyncTask pingTask = new PingTask(getActivity(), pingList, pingListAdapter).execute(stringUrl);

            } else {
                tv.setTextSize(20);
                tv.setTextColor(Color.RED);
                tv.setText(R.string.no_internet);
            }

            InputMethodManager inputManager = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);

            inputManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(),
                    InputMethodManager.RESULT_UNCHANGED_SHOWN);
        }
    });

    et.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            final int DRAWABLE_LEFT = 0;
            final int DRAWABLE_TOP = 1;
            final int DRAWABLE_RIGHT = 2;
            final int DRAWABLE_BOTTOM = 3;

            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                if (event.getRawX() >= (et.getRight()
                        - et.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
                    et.setText("");
                    et.selectAll();

                    return true;
                }
            }
            return false;
        }
    });
    return rootView;
}

From source file:org.exoplatform.ui.social.ComposeMessageActivity.java

private void initLayout() {
    postDestinationView = (TextView) findViewById(R.id.post_destination_text_view);
    postDestinationIcon = (ImageView) findViewById(R.id.post_destination_image);
    composeEditText = (EditText) findViewById(R.id.compose_text_view);
    textFieldScrollView = (ScrollView) findViewById(R.id.compose_textfield_scroll);
    textFieldScrollView.setOnTouchListener(new View.OnTouchListener() {
        @Override//from w  w w.  ja  v a2s  .c om
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                mgr.showSoftInput(composeEditText, InputMethodManager.RESULT_UNCHANGED_SHOWN);
            }
            return false;
        }
    });

    fileAttachWrap = (LinearLayout) findViewById(R.id.compose_attach_file_wrap);
    sendButton = (Button) findViewById(R.id.compose_send_button);
    sendButton.setText(sendText);
    sendButton.setOnClickListener(this);
    cancelButton = (Button) findViewById(R.id.compose_cancel_button);
    cancelButton.setText(cancelText);
    cancelButton.setOnClickListener(this);
}

From source file:com.wit.and.dialog.LoginDialog.java

/**
 * <p>/*from   www  .j  ava 2  s. co m*/
 * Hides the soft keyboard using token of the given focused view.
 * </p>
 *
 * @param focusedView
 *            The view which currently has focus.
 * @return True if hiding was successful otherwise false.
 */
protected synchronized boolean hideSoftKeyboard(View focusedView) {
    // Check valid view
    if (focusedView == null || focusedView.getContext() == null)
        return false;

    // Get input method manager.
    InputMethodManager imm = (InputMethodManager) focusedView.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);

    // Now hide Keyboard from screen.
    imm.hideSoftInputFromWindow(focusedView.getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN);

    // Success.
    return true;
}

From source file:com.linkbubble.ui.ContentView.java

public void collapse() {
    if (null != mShareAlertDialog) {
        mShareAlertDialog.dismiss();//from   w w w  .java 2  s .co  m
        mShareAlertDialog = null;
    }
    InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(metUrl.getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN);
}