Example usage for android.text InputType TYPE_CLASS_TEXT

List of usage examples for android.text InputType TYPE_CLASS_TEXT

Introduction

In this page you can find the example usage for android.text InputType TYPE_CLASS_TEXT.

Prototype

int TYPE_CLASS_TEXT

To view the source code for android.text InputType TYPE_CLASS_TEXT.

Click Source Link

Document

Class for normal text.

Usage

From source file:im.vector.fragments.VectorSettingsPreferencesFragment.java

private void addButtons() {
    // display the "add email" entry
    EditTextPreference addEmailPreference = new EditTextPreference(getActivity());
    addEmailPreference.setTitle(R.string.settings_add_email_address);
    addEmailPreference.setDialogTitle(R.string.settings_add_email_address);
    addEmailPreference.setKey(ADD_EMAIL_PREFERENCE_KEY);
    addEmailPreference.setIcon(CommonActivityUtils.tintDrawable(getActivity(),
            ContextCompat.getDrawable(getActivity(), R.drawable.ic_add_black),
            R.attr.settings_icon_tint_color));
    addEmailPreference.setOrder(100);//from   w w  w  . j a  v  a  2s . c  om
    addEmailPreference.getEditText()
            .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);

    addEmailPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            final String email = (null == newValue) ? null : ((String) newValue).trim();

            getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    addEmail(email);
                }
            });

            return false;
        }
    });

    mUserSettingsCategory.addPreference(addEmailPreference);

    // display the "add phone number" entry
    Preference addPhoneNumberPreference = new Preference(getActivity());
    addPhoneNumberPreference.setKey(ADD_PHONE_NUMBER_PREFERENCE_KEY);
    addPhoneNumberPreference.setIcon(CommonActivityUtils.tintDrawable(getActivity(),
            ContextCompat.getDrawable(getActivity(), R.drawable.ic_add_black),
            R.attr.settings_icon_tint_color));
    addPhoneNumberPreference.setTitle(R.string.settings_add_phone_number);
    addPhoneNumberPreference.setOrder(200);

    addPhoneNumberPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Intent intent = PhoneNumberAdditionActivity.getIntent(getActivity(),
                    mSession.getCredentials().userId);
            startActivityForResult(intent, REQUEST_NEW_PHONE_NUMBER);
            return true;
        }
    });

    mUserSettingsCategory.addPreference(addPhoneNumberPreference);
}

From source file:edu.oakland.festinfo.activities.MapPageActivity.java

@Click(R.id.search_for_marker)
public void searchForMarker() {
    AlertDialog.Builder searchInput = new AlertDialog.Builder(MapPageActivity.this);
    searchInput.setTitle("Enter Search Text: ");
    final EditText changeInput = new EditText(MapPageActivity.this);
    changeInput.setInputType(InputType.TYPE_CLASS_TEXT);
    searchInput.setView(changeInput);/*from w  w w.  j a  v a2  s . c  o  m*/
    searchInput.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            boolean foundMarker = false;
            if (changeInput.getText().toString().matches("")) {
                Toast.makeText(getApplicationContext(), "No Input Entered!", Toast.LENGTH_SHORT).show();
            } else {
                for (int i = 0; i < combinedArray.size(); i++) {
                    if (combinedArray.get(i).getMarker().getTitle().toLowerCase()
                            .equals(changeInput.getText().toString().toLowerCase())) {
                        LatLng point = combinedArray.get(i).getMarker().getPosition();
                        map.animateCamera(CameraUpdateFactory.newLatLng(point));
                        combinedArray.get(i).getMarker().showInfoWindow();
                        foundMarker = true;
                        break;
                    }
                }
                if (foundMarker == false) {
                    Toast.makeText(MapPageActivity.this, "Cannot find marker", Toast.LENGTH_SHORT).show();
                }
            }
        }
    });
    searchInput.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    searchInput.show();
}

From source file:org.de.jmg.learn.MainActivity.java

private void uploadtoQuizlet() {
    if (vok.getGesamtzahl() < 3)
        return;//w w w  .  j  a v  a2 s.c om
    try {
        if (this.QuizletAccessToken == null) {
            this.QuizletAccessToken = prefs.getString("QuizletAccessToken", null);
            this.QuizletUser = prefs.getString("QuizletUser", null);
            if (QuizletAccessToken != null) {
                final CountDownLatch l = new CountDownLatch(1);
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            _blnVerifyToken = org.liberty.android.fantastischmemo.downloader.quizlet.lib
                                    .verifyAccessToken(new String[] { QuizletAccessToken, QuizletUser });
                        } catch (Exception e) {
                            e.printStackTrace();
                            _blnVerifyToken = false;
                        }
                        l.countDown();
                    }
                }).start();
                l.await();
                if (!_blnVerifyToken) {
                    QuizletAccessToken = null;
                    QuizletUser = null;
                }
            }
        }
        if (this.QuizletAccessToken == null) {
            this.LoginQuizlet(true);
        } else {

            final AlertDialog.Builder A = new AlertDialog.Builder(context);
            final CharSequence[] items = { MainActivity.this.getString(R.string.Private),
                    MainActivity.this.getString(R.string.Public) };
            A.setSingleChoiceItems(items, _blnPrivate ? 0 : 1, new DialogInterface.OnClickListener() {

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

                    _blnPrivate = which == 0;

                }
            });

            final EditText input = new EditText(context);
            //final LinearLayout ll = new LinearLayout(context);
            //ll.addView(input);
            A.setPositiveButton(context.getString(R.string.ok), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    String userId = MainActivity.this.QuizletUser;
                    if (!_blnPrivate) {
                        userId = "";
                    } else {
                        if (lib.ShowMessageOKCancel(MainActivity.this,
                                MainActivity.this.getString(R.string.msgPrivateNotSupported), "",
                                false) == yesnoundefined.no)
                            return;
                    }
                    new UploadToQuzletTask().execute(input.getText().toString(), userId);
                    lib.removeDlg(dlg);

                }
            });
            A.setNegativeButton(context.getString(R.string.cancel), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    lib.removeDlg(dlg);
                }
            });
            String name = "";
            if (vok.getURI() != null) {
                name = vok.getURI().getLastPathSegment();
            }
            if (!libString.IsNullOrEmpty(vok.getFileName())) {
                try {
                    name = new File(vok.getFileName()).getName();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
            A.setTitle(String.format(getString(R.string.UploadToQuizlet), name));

            //A.setTitle(getString(R.string.Search));
            // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
            input.setInputType(InputType.TYPE_CLASS_TEXT);
            input.setText("");
            /*
            android.widget.LinearLayout.LayoutParams params
                  = (android.widget.LinearLayout.LayoutParams) input.getLayoutParams();
            params.topMargin = lib.dpToPx(20);
            input.setLayoutParams(params);
            */
            A.setView(input);
            /*
            int PT =  input.getPaddingTop();
            int PL = input.getPaddingLeft();
            int PR = input.getPaddingRight();
            int PB = input.getPaddingBottom();
            //int PE = input.getPaddingEnd();
            //int PS = input.getPaddingStart();
            input.setPadding(PL,PT*3,PR,PB);
            */
            dlg = A.create();
            dlg.show();

            dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialog) {
                    lib.removeDlg(dlg);
                }
            });
            lib.OpenDialogs.add(dlg);
        }

    } catch (Exception ex) {
        lib.ShowException(this, ex);
    }

}

From source file:com.tandong.sa.sherlock.widget.SearchView.java

/**
 * Updates the auto-complete text view./*w  w  w.  j a v a  2 s .c  om*/
 */
private void updateSearchAutoComplete() {
    // TODO mQueryTextView.setDropDownAnimationStyle(0); // no animation
    mQueryTextView.setThreshold(mSearchable.getSuggestThreshold());
    mQueryTextView.setImeOptions(mSearchable.getImeOptions());
    int inputType = mSearchable.getInputType();
    // We only touch this if the input type is set up for text (which it
    // almost certainly
    // should be, in the case of search!)
    if ((inputType & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_TEXT) {
        // The existence of a suggestions authority is the proxy for
        // "suggestions
        // are available here"
        inputType &= ~InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
        if (mSearchable.getSuggestAuthority() != null) {
            inputType |= InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
            // TYPE_TEXT_FLAG_AUTO_COMPLETE means that the text editor is
            // performing
            // auto-completion based on its own semantics, which it will
            // present to the user
            // as they type. This generally means that the input method
            // should not show its
            // own candidates, and the spell checker should not be in
            // action. The text editor
            // supplies its candidates by calling
            // InputMethodManager.displayCompletions(),
            // which in turn will call
            // InputMethodSession.displayCompletions().
            inputType |= InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
        }
    }
    mQueryTextView.setInputType(inputType);
    if (mSuggestionsAdapter != null) {
        mSuggestionsAdapter.changeCursor(null);
    }
    // attach the suggestions adapter, if suggestions are available
    // The existence of a suggestions authority is the proxy for
    // "suggestions available here"
    if (mSearchable.getSuggestAuthority() != null) {
        mSuggestionsAdapter = new SuggestionsAdapter(getContext(), this, mSearchable, mOutsideDrawablesCache);
        mQueryTextView.setAdapter(mSuggestionsAdapter);
        ((SuggestionsAdapter) mSuggestionsAdapter).setQueryRefinement(
                mQueryRefinement ? SuggestionsAdapter.REFINE_ALL : SuggestionsAdapter.REFINE_BY_ENTRY);
    }
}

From source file:org.de.jmg.learn.MainActivity.java

private void searchQuizlet() {
    try {//  ww  w  .  ja v  a2s .c om
        if (this.QuizletAccessToken == null) {
            this.QuizletAccessToken = prefs.getString("QuizletAccessToken", null);
            this.QuizletUser = prefs.getString("QuizletUser", null);
            if (QuizletAccessToken != null) {
                final CountDownLatch l = new CountDownLatch(1);
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            _blnVerifyToken = org.liberty.android.fantastischmemo.downloader.quizlet.lib
                                    .verifyAccessToken(new String[] { QuizletAccessToken, QuizletUser });
                        } catch (Exception e) {
                            e.printStackTrace();
                            _blnVerifyToken = false;
                        }
                        l.countDown();
                    }
                }).start();
                l.await();
                if (!_blnVerifyToken) {
                    QuizletAccessToken = null;
                    QuizletUser = null;
                }
            }
        }
        if (this.QuizletAccessToken == null) {
            this.LoginQuizlet(false);
        } else if (fPA != null && fPA.fragQuizlet != null) {

            final AlertDialog.Builder A = new AlertDialog.Builder(context);
            final CharSequence[] items = { MainActivity.this.getString(R.string.Private),
                    MainActivity.this.getString(R.string.Public) };
            A.setSingleChoiceItems(items, _blnPrivate ? 0 : 1, new DialogInterface.OnClickListener() {

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

                    _blnPrivate = which == 0;

                }
            });

            final EditText input = new EditText(context);
            //final LinearLayout ll = new LinearLayout(context);
            //ll.addView(input);
            A.setPositiveButton(context.getString(R.string.ok), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (_blnPrivate || !libString.IsNullOrEmpty(input.getText().toString())) {
                        fPA.fragQuizlet.setSearchPhrase(input.getText().toString());
                        fPA.fragQuizlet.blnPrivate = _blnPrivate;
                        fPA.fragQuizlet.Load();
                        lib.removeDlg(dlg);
                        //fPA.fragQuizlet.Login();
                    }
                }
            });
            A.setNegativeButton(context.getString(R.string.cancel), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    lib.removeDlg(dlg);
                }
            });

            A.setTitle(getString(R.string.SearchQuizlet));
            //A.setTitle(getString(R.string.Search));
            // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
            input.setInputType(InputType.TYPE_CLASS_TEXT);
            input.setText(fPA.fragQuizlet.getOriginalSearchPhrase());
            /*
            android.widget.LinearLayout.LayoutParams params
                  = (android.widget.LinearLayout.LayoutParams) input.getLayoutParams();
            params.topMargin = lib.dpToPx(20);
            input.setLayoutParams(params);
            */
            A.setView(input);
            /*
            int PT =  input.getPaddingTop();
            int PL = input.getPaddingLeft();
            int PR = input.getPaddingRight();
            int PB = input.getPaddingBottom();
            //int PE = input.getPaddingEnd();
            //int PS = input.getPaddingStart();
            input.setPadding(PL,PT*3,PR,PB);
            */
            dlg = A.create();
            dlg.show();

            dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialog) {
                    lib.removeDlg(dlg);
                }
            });
            lib.OpenDialogs.add(dlg);
        }

    } catch (Exception ex) {
        lib.ShowException(this, ex);
    }

}

From source file:com.max2idea.android.limbo.main.LimboActivity.java

public void promptVNCAllowExternal(final Activity activity) {
    final AlertDialog alertDialog;
    alertDialog = new AlertDialog.Builder(activity).create();
    alertDialog.setTitle("Enable VNC server");

    TextView textView = new TextView(activity);
    textView.setVisibility(View.VISIBLE);
    textView.setId(201012010);/*from  ww w.  java  2 s.c o  m*/
    textView.setText("VNC Server: " + this.getLocalIpAddress() + ":" + "5901\n"
            + "Warning: VNC is not secure make sure you're on a private network!\n");

    EditText passwdView = new EditText(activity);
    passwdView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    passwdView.setHint("Password");
    passwdView.setEnabled(true);
    passwdView.setVisibility(View.VISIBLE);
    passwdView.setId(11111);
    passwdView.setSingleLine();

    RelativeLayout mLayout = new RelativeLayout(this);
    mLayout.setId(12222);

    RelativeLayout.LayoutParams textViewParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    textViewParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, mLayout.getId());
    mLayout.addView(textView, textViewParams);

    RelativeLayout.LayoutParams passwordViewParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

    passwordViewParams.addRule(RelativeLayout.BELOW, textView.getId());
    // passwordViewParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,
    // mLayout.getId());
    mLayout.addView(passwdView, passwordViewParams);

    alertDialog.setView(mLayout);

    final Handler handler = this.handler;

    alertDialog.setButton("Set", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {

            // UIUtils.log("Searching...");
            EditText a = (EditText) alertDialog.findViewById(11111);

            if (a.getText().toString().trim().equals("")) {
                Toast.makeText(getApplicationContext(), "Password cannot be empty!", Toast.LENGTH_SHORT).show();
                vnc_passwd = null;
                vnc_allow_external = 0;
                mVNCAllowExternal.setChecked(false);
                // LimboSettingsManager.setVNCAllowExternal(activity, false);
                return;
            } else {
                sendHandlerMessage(handler, Const.VNC_PASSWORD, "vnc_passwd", "passwd");
                vnc_passwd = a.getText().toString();
                vnc_allow_external = 1;
                // LimboSettingsManager.setVNCAllowExternal(activity, true);
            }

        }
    });
    alertDialog.setButton2("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            vnc_passwd = null;
            vnc_allow_external = 0;
            mVNCAllowExternal.setChecked(false);
            // LimboSettingsManager.setVNCAllowExternal(activity, false);
            return;
        }
    });
    alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            mVNCAllowExternal.setChecked(false);
            // LimboSettingsManager.setVNCAllowExternal(activity, false);
            vnc_passwd = null;
            vnc_allow_external = 0;
        }
    });
    alertDialog.show();

}

From source file:org.telegram.ui.PassportActivity.java

private void createPasswordInterface(Context context) {
    TLRPC.User botUser = null;/*from  w w  w.j  a  v  a  2  s  .  c om*/
    if (currentForm != null) {
        for (int a = 0; a < currentForm.users.size(); a++) {
            TLRPC.User user = currentForm.users.get(a);
            if (user.id == currentBotId) {
                botUser = user;
                break;
            }
        }
    } else {
        botUser = UserConfig.getInstance(currentAccount).getCurrentUser();
    }

    FrameLayout frameLayout = (FrameLayout) fragmentView;

    actionBar.setTitle(LocaleController.getString("TelegramPassport", R.string.TelegramPassport));

    emptyView = new EmptyTextProgressView(context);
    emptyView.showProgress();
    frameLayout.addView(emptyView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    passwordAvatarContainer = new FrameLayout(context);
    linearLayout2.addView(passwordAvatarContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 100));

    BackupImageView avatarImageView = new BackupImageView(context);
    avatarImageView.setRoundRadius(AndroidUtilities.dp(32));
    passwordAvatarContainer.addView(avatarImageView,
            LayoutHelper.createFrame(64, 64, Gravity.CENTER, 0, 8, 0, 0));

    AvatarDrawable avatarDrawable = new AvatarDrawable(botUser);
    TLRPC.FileLocation photo = null;
    if (botUser.photo != null) {
        photo = botUser.photo.photo_small;
    }
    avatarImageView.setImage(photo, "50_50", avatarDrawable, botUser);

    passwordRequestTextView = new TextInfoPrivacyCell(context);
    passwordRequestTextView.getTextView().setGravity(Gravity.CENTER_HORIZONTAL);
    if (currentBotId == 0) {
        passwordRequestTextView
                .setText(LocaleController.getString("PassportSelfRequest", R.string.PassportSelfRequest));
    } else {
        passwordRequestTextView.setText(AndroidUtilities.replaceTags(LocaleController
                .formatString("PassportRequest", R.string.PassportRequest, UserObject.getFirstName(botUser))));
    }
    ((FrameLayout.LayoutParams) passwordRequestTextView.getTextView()
            .getLayoutParams()).gravity = Gravity.CENTER_HORIZONTAL;
    linearLayout2.addView(passwordRequestTextView,
            LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT,
                    (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 21, 0, 21, 0));

    noPasswordImageView = new ImageView(context);
    noPasswordImageView.setImageResource(R.drawable.no_password);
    noPasswordImageView.setColorFilter(new PorterDuffColorFilter(
            Theme.getColor(Theme.key_chat_messagePanelIcons), PorterDuff.Mode.MULTIPLY));
    linearLayout2.addView(noPasswordImageView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT,
            LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 13, 0, 0));

    noPasswordTextView = new TextView(context);
    noPasswordTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    noPasswordTextView.setGravity(Gravity.CENTER_HORIZONTAL);
    noPasswordTextView.setPadding(AndroidUtilities.dp(21), AndroidUtilities.dp(10), AndroidUtilities.dp(21),
            AndroidUtilities.dp(17));
    noPasswordTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText4));
    noPasswordTextView.setText(LocaleController.getString("TelegramPassportCreatePasswordInfo",
            R.string.TelegramPassportCreatePasswordInfo));
    linearLayout2.addView(noPasswordTextView,
            LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT,
                    (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 21, 10, 21, 0));

    noPasswordSetTextView = new TextView(context);
    noPasswordSetTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText5));
    noPasswordSetTextView.setGravity(Gravity.CENTER);
    noPasswordSetTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    noPasswordSetTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    noPasswordSetTextView.setText(LocaleController.getString("TelegramPassportCreatePassword",
            R.string.TelegramPassportCreatePassword));
    linearLayout2.addView(noPasswordSetTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 24,
            (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 21, 9, 21, 0));
    noPasswordSetTextView.setOnClickListener(v -> {
        TwoStepVerificationActivity activity = new TwoStepVerificationActivity(currentAccount, 1);
        activity.setCloseAfterSet(true);
        activity.setCurrentPasswordInfo(new byte[0], currentPassword);
        presentFragment(activity);
    });

    inputFields = new EditTextBoldCursor[1];
    inputFieldContainers = new ViewGroup[1];
    for (int a = 0; a < 1; a++) {
        inputFieldContainers[a] = new FrameLayout(context);
        linearLayout2.addView(inputFieldContainers[a],
                LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 50));
        inputFieldContainers[a].setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));

        inputFields[a] = new EditTextBoldCursor(context);
        inputFields[a].setTag(a);
        inputFields[a].setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
        inputFields[a].setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
        inputFields[a].setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
        inputFields[a].setBackgroundDrawable(null);
        inputFields[a].setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
        inputFields[a].setCursorSize(AndroidUtilities.dp(20));
        inputFields[a].setCursorWidth(1.5f);
        inputFields[a].setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        inputFields[a].setMaxLines(1);
        inputFields[a].setLines(1);
        inputFields[a].setSingleLine(true);
        inputFields[a].setTransformationMethod(PasswordTransformationMethod.getInstance());
        inputFields[a].setTypeface(Typeface.DEFAULT);
        inputFields[a].setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
        inputFields[a].setPadding(0, 0, 0, AndroidUtilities.dp(6));
        inputFields[a].setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
        inputFieldContainers[a].addView(inputFields[a], LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
                LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 21, 12, 21, 6));

        inputFields[a].setOnEditorActionListener((textView, i, keyEvent) -> {
            if (i == EditorInfo.IME_ACTION_NEXT || i == EditorInfo.IME_ACTION_DONE) {
                doneItem.callOnClick();
                return true;
            }
            return false;
        });
        inputFields[a].setCustomSelectionActionModeCallback(new ActionMode.Callback() {
            public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            public void onDestroyActionMode(ActionMode mode) {
            }

            public boolean onCreateActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
                return false;
            }
        });
    }

    passwordInfoRequestTextView = new TextInfoPrivacyCell(context);
    passwordInfoRequestTextView.setBackgroundDrawable(Theme.getThemedDrawable(context,
            R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
    passwordInfoRequestTextView.setText(
            LocaleController.formatString("PassportRequestPasswordInfo", R.string.PassportRequestPasswordInfo));
    linearLayout2.addView(passwordInfoRequestTextView,
            LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

    passwordForgotButton = new TextView(context);
    passwordForgotButton.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText4));
    passwordForgotButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    passwordForgotButton.setText(LocaleController.getString("ForgotPassword", R.string.ForgotPassword));
    passwordForgotButton.setPadding(0, 0, 0, 0);
    linearLayout2.addView(passwordForgotButton, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 30,
            (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 21, 0, 21, 0));
    passwordForgotButton.setOnClickListener(v -> {
        if (currentPassword.has_recovery) {
            needShowProgress();
            TLRPC.TL_auth_requestPasswordRecovery req = new TLRPC.TL_auth_requestPasswordRecovery();
            int reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req,
                    (response, error) -> AndroidUtilities.runOnUIThread(() -> {
                        needHideProgress();
                        if (error == null) {
                            final TLRPC.TL_auth_passwordRecovery res = (TLRPC.TL_auth_passwordRecovery) response;
                            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                            builder.setMessage(LocaleController.formatString("RestoreEmailSent",
                                    R.string.RestoreEmailSent, res.email_pattern));
                            builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
                            builder.setPositiveButton(LocaleController.getString("OK", R.string.OK),
                                    (dialogInterface, i) -> {
                                        TwoStepVerificationActivity fragment = new TwoStepVerificationActivity(
                                                currentAccount, 1);
                                        fragment.setRecoveryParams(currentPassword);
                                        currentPassword.email_unconfirmed_pattern = res.email_pattern;
                                        presentFragment(fragment);
                                    });
                            Dialog dialog = showDialog(builder.create());
                            if (dialog != null) {
                                dialog.setCanceledOnTouchOutside(false);
                                dialog.setCancelable(false);
                            }
                        } else {
                            if (error.text.startsWith("FLOOD_WAIT")) {
                                int time = Utilities.parseInt(error.text);
                                String timeString;
                                if (time < 60) {
                                    timeString = LocaleController.formatPluralString("Seconds", time);
                                } else {
                                    timeString = LocaleController.formatPluralString("Minutes", time / 60);
                                }
                                showAlertWithText(LocaleController.getString("AppName", R.string.AppName),
                                        LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime,
                                                timeString));
                            } else {
                                showAlertWithText(LocaleController.getString("AppName", R.string.AppName),
                                        error.text);
                            }
                        }
                    }), ConnectionsManager.RequestFlagFailOnServerErrors
                            | ConnectionsManager.RequestFlagWithoutLogin);
            ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid);
        } else {
            if (getParentActivity() == null) {
                return;
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
            builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
            builder.setNegativeButton(
                    LocaleController.getString("RestorePasswordResetAccount",
                            R.string.RestorePasswordResetAccount),
                    (dialog, which) -> Browser.openUrl(getParentActivity(),
                            "https://telegram.org/deactivate?phone="
                                    + UserConfig.getInstance(currentAccount).getClientPhone()));
            builder.setTitle(LocaleController.getString("RestorePasswordNoEmailTitle",
                    R.string.RestorePasswordNoEmailTitle));
            builder.setMessage(LocaleController.getString("RestorePasswordNoEmailText",
                    R.string.RestorePasswordNoEmailText));
            showDialog(builder.create());
        }
    });

    updatePasswordInterface();
}

From source file:com.eveningoutpost.dexdrip.Home.java

public void showNoteTextInputDialog(View myitem, final long timestamp, final double position) {
    Log.d(TAG, "showNoteTextInputDialog: ts:" + timestamp + " pos:" + position);
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
    LayoutInflater inflater = this.getLayoutInflater();
    final View dialogView = inflater.inflate(R.layout.note_dialog_phone, null);
    dialogBuilder.setView(dialogView);//from w  ww.ja  va  2  s  . c  o m

    final EditText edt = (EditText) dialogView.findViewById(R.id.treatment_note_edit_text);
    final CheckBox cbx = (CheckBox) dialogView.findViewById(R.id.default_to_voice_input);
    cbx.setChecked(getPreferencesBooleanDefaultFalse("default_to_voice_notes"));

    dialogBuilder.setTitle(R.string.treatment_note);
    //dialogBuilder.setMessage("Enter text below");
    dialogBuilder.setPositiveButton("Done", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            String treatment_text = edt.getText().toString().trim();
            Log.d(TAG, "Got treatment note: " + treatment_text);
            Treatments.create_note(treatment_text, timestamp, position); // timestamp?
            Home.staticRefreshBGCharts();

            if (treatment_text.length() > 0) {
                // display snackbar of the snackbar
                final View.OnClickListener mOnClickListener = new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Home.startHomeWithExtra(xdrip.getAppContext(), Home.CREATE_TREATMENT_NOTE,
                                Long.toString(timestamp), Double.toString(position));
                    }
                };
                Home.snackBar(getString(R.string.added) + ":    " + treatment_text, mOnClickListener,
                        mActivity);
            }

            if (getPreferencesBooleanDefaultFalse("default_to_voice_notes"))
                showcasemenu(SHOWCASE_NOTE_LONG);
            dialog = null;
        }
    });
    dialogBuilder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            if (getPreferencesBooleanDefaultFalse("default_to_voice_notes"))
                showcasemenu(SHOWCASE_NOTE_LONG);
            dialog = null;

        }
    });
    dialog = dialogBuilder.create();
    edt.setInputType(InputType.TYPE_CLASS_TEXT);
    edt.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                if (dialog != null)
                    dialog.getWindow()
                            .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
            }
        }
    });

    dialog.show();

}

From source file:com.android.mms.ui.ComposeMessageActivity.java

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

    // OLD: get notified of presence updates to update the titlebar.
    // NEW: we are using ContactHeaderWidget which displays presence, but updating presence
    //      there is out of our control.
    //Contact.startPresenceObserver();

    addRecipientsListeners();//from   w  w w  .j av a2s  .c om

    if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
        log("update title, mConversation=" + mConversation.toString());
    }

    // There seems to be a bug in the framework such that setting the title
    // here gets overwritten to the original title.  Do this delayed as a
    // workaround.
    mMessageListItemHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            ContactList recipients = isRecipientsEditorVisible()
                    ? mRecipientsEditor.constructContactsFromInput(false)
                    : getRecipients();
            updateTitle(recipients);
        }
    }, 100);

    // Load the selected input type
    SharedPreferences prefs = PreferenceManager
            .getDefaultSharedPreferences((Context) ComposeMessageActivity.this);
    mInputMethod = Integer.parseInt(prefs.getString(MessagingPreferenceActivity.INPUT_TYPE,
            Integer.toString(InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE)));
    mTextEditor.setInputType(InputType.TYPE_CLASS_TEXT | mInputMethod | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT
            | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE);

    TelephonyManager tm = (TelephonyManager) getSystemService(Service.TELEPHONY_SERVICE);
    if (MessagingPreferenceActivity.getSmartCallEnabled((Context) ComposeMessageActivity.this)
            && tm.getCallState() == TelephonyManager.CALL_STATE_IDLE) {
        mMultiSensorManager.enable();
    }

    mIsRunning = true;
    updateThreadIdIfRunning();
    mConversation.markAsRead(true);
}

From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java

final static private void setCompareEditTextAttr(GlobalParameters mGlblParms, String c_tgt, EditText et_value1,
        EditText et_value2) {/*from   ww w  . j a  v  a2s  .com*/
    if (c_tgt.equals(PROFILE_ACTION_TYPE_COMPARE_TARGET_BLUETOOTH)) {
        et_value1.setInputType(InputType.TYPE_CLASS_TEXT);
        et_value2.setInputType(InputType.TYPE_CLASS_TEXT);
    } else if (c_tgt.equals(PROFILE_ACTION_TYPE_COMPARE_TARGET_WIFI)) {
        et_value1.setInputType(InputType.TYPE_CLASS_TEXT);
        et_value2.setInputType(InputType.TYPE_CLASS_TEXT);
    } else if (c_tgt.equals(PROFILE_ACTION_TYPE_COMPARE_TARGET_BATTERY)) {
        try {
            Integer.parseInt(et_value1.getText().toString());
        } catch (NumberFormatException e) {
            et_value1.setText("");
        }
        try {
            Integer.parseInt(et_value2.getText().toString());
        } catch (NumberFormatException e) {
            et_value2.setText("");
        }
        et_value1.setInputType(InputType.TYPE_CLASS_NUMBER);
        et_value2.setInputType(InputType.TYPE_CLASS_NUMBER);
    } else if (c_tgt.equals(PROFILE_ACTION_TYPE_COMPARE_TARGET_LIGHT)) {
        try {
            Integer.parseInt(et_value1.getText().toString());
        } catch (NumberFormatException e) {
            et_value1.setText("");
        }
        try {
            Integer.parseInt(et_value2.getText().toString());
        } catch (NumberFormatException e) {
            et_value2.setText("");
        }
        et_value1.setInputType(InputType.TYPE_CLASS_NUMBER);
        et_value2.setInputType(InputType.TYPE_CLASS_NUMBER);
    } else if (c_tgt.equals(PROFILE_ACTION_TYPE_COMPARE_TARGET_TIME)) {
        try {
            Integer.parseInt(et_value1.getText().toString());
        } catch (NumberFormatException e) {
            et_value1.setText("");
        }
        try {
            Integer.parseInt(et_value2.getText().toString());
        } catch (NumberFormatException e) {
            et_value2.setText("");
        }
        et_value1.setInputType(InputType.TYPE_CLASS_NUMBER);
        et_value2.setInputType(InputType.TYPE_CLASS_NUMBER);
    }
}