List of usage examples for android.text InputType TYPE_CLASS_TEXT
int TYPE_CLASS_TEXT
To view the source code for android.text InputType TYPE_CLASS_TEXT.
Click Source Link
From source file:com.manning.androidhacks.hack017.CreateAccountAdapter.java
private void populateFourthForm(LinearLayout formLayout) { formLayout.addView(createTitle(mContext.getString(R.string.account_create_zip_title))); EditText zipEditText = createEditText(mContext.getString(R.string.account_create_zip_hint), InputType.TYPE_CLASS_TEXT, EditorInfo.IME_ACTION_GO, true, ZIP_KEY); if (mFormData.get(ZIP_KEY) != null) { zipEditText.setText(mFormData.get(ZIP_KEY)); }/* w w w . ja v a 2 s. c om*/ formLayout.addView(zipEditText); formLayout.addView(createErrorView(ZIP_KEY)); }
From source file:jp.watnow.plugins.dialog.Notification.java
/** * Builds and shows a native Android prompt dialog with given title, message, buttons. * This dialog only shows up to 3 buttons. Any labels after that will be ignored. * The following results are returned to the JavaScript callback identified by callbackId: * buttonIndex Index number of the button selected * input1 The text entered in the prompt dialog box * * @param message The message the dialog should display * @param title The title of the dialog * @param buttonLabels A comma separated list of button labels (Up to 3 buttons) * @param callbackContext The callback context. */// w w w . ja v a 2 s .co m public synchronized void prompt(final String message, final String title, final JSONArray buttonLabels, final String defaultText, final String dialogType, final CallbackContext callbackContext) { final CordovaInterface cordova = this.cordova; Runnable runnable = new Runnable() { public void run() { final EditText promptInput = new EditText(cordova.getActivity()); promptInput.setHint(defaultText); Log.d("DialogPlugin", dialogType); if (dialogType.equals(INPUT_SECURE)) { promptInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); } AlertDialog.Builder dlg = createDialog(cordova); // new AlertDialog.Builder(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT); dlg.setMessage(message); dlg.setTitle(title); dlg.setCancelable(false); dlg.setView(promptInput); final JSONObject result = new JSONObject(); // First button if (buttonLabels.length() > 0) { try { dlg.setNegativeButton(buttonLabels.getString(0), new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); try { result.put("buttonIndex", 1); result.put("input1", promptInput.getText().toString().trim().length() == 0 ? defaultText : promptInput.getText()); } catch (JSONException e) { e.printStackTrace(); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); } catch (JSONException e) { } } // Second button if (buttonLabels.length() > 1) { try { dlg.setNeutralButton(buttonLabels.getString(1), new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); try { result.put("buttonIndex", 2); result.put("input1", promptInput.getText().toString().trim().length() == 0 ? defaultText : promptInput.getText()); } catch (JSONException e) { e.printStackTrace(); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); } catch (JSONException e) { } } // Third button if (buttonLabels.length() > 2) { try { dlg.setPositiveButton(buttonLabels.getString(2), new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); try { result.put("buttonIndex", 3); result.put("input1", promptInput.getText().toString().trim().length() == 0 ? defaultText : promptInput.getText()); } catch (JSONException e) { e.printStackTrace(); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); } catch (JSONException e) { } } dlg.setOnCancelListener(new AlertDialog.OnCancelListener() { public void onCancel(DialogInterface dialog) { dialog.dismiss(); try { result.put("buttonIndex", 0); result.put("input1", promptInput.getText().toString().trim().length() == 0 ? defaultText : promptInput.getText()); } catch (JSONException e) { e.printStackTrace(); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); changeTextDirection(dlg); }; }; this.cordova.getActivity().runOnUiThread(runnable); }
From source file:com.cryart.sabbathschool.viewmodel.SSReadingViewModel.java
public void promptForEditSuggestion() { if (ssReads.size() > 0) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); final String name = prefs.getString(SSConstants.SS_USER_NAME_INDEX, context.getString(R.string.ss_menu_anonymous_name)); final String email = prefs.getString(SSConstants.SS_USER_EMAIL_INDEX, context.getString(R.string.ss_menu_anonymous_email)); new MaterialDialog.Builder(context).title(context.getString(R.string.ss_reading_suggest_edit)) .inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES) .input(context.getString(R.string.ss_reading_suggest_edit_hint), "", new MaterialDialog.InputCallback() { @Override public void onInput(MaterialDialog dialog, CharSequence input) { mDatabase.child(SSConstants.SS_FIREBASE_SUGGESTIONS_DATABASE) .child(ssFirebaseAuth.getCurrentUser().getUid()) .child(ssReads.get(ssReadingActivityBinding.ssReadingViewPager .getCurrentItem()).index) .setValue(new SSSuggestion(name, email, input.toString())); Toast.makeText(context, context.getString(R.string.ss_reading_suggest_edit_done), Toast.LENGTH_LONG).show(); }/*from w ww. j av a 2 s . c om*/ }) .show(); } }
From source file:nz.ac.otago.psyanlab.common.designer.program.stage.EditPropPropertiesFragment.java
/** * Creates an edit text entry field that allows the user to enter a string. * /*from w w w . j ava2 s . c om*/ * @return EditText */ private View newStringInputView(String s) { EditText view = new EditText(getActivity()); view.setInputType(InputType.TYPE_CLASS_TEXT); view.setSingleLine(); view.setText(s); return view; }
From source file:com.mendhak.gpslogger.common.PrefsIO.java
public void AskFileName() { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(R.string.AskFileName); final EditText input = new EditText(context); input.setInputType(InputType.TYPE_CLASS_TEXT); int pos = curFileName.lastIndexOf(File.separator) + 1; String filename = ""; if (pos > 0) filename = curFileName.substring(pos); pos = filename.lastIndexOf(extension); if (pos > 1) input.setText(filename.substring(0, pos - 1)); else// ww w . j a va2 s. c om input.setText(defFileName); Utilities.LogDebug("Asking user the filename to use for export of settings"); builder.setView(input); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String str = input.getText().toString(); String fname = ""; if (str.length() > 0) fname = str.replaceAll(filter, ""); if (fname.length() != 0) { curFileName = defPath + File.separator + fname + "." + extension; ExportFile(); } } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.show(); }
From source file:nya.miku.wishmaster.api.AbstractChanModule.java
/** * ( ?/ ) ? ?-?/*w w w . j a v a 2 s. c om*/ * @param group , ??? */ protected void addProxyPreferences(PreferenceGroup group) { final Context context = group.getContext(); PreferenceCategory proxyCat = new PreferenceCategory(context); //? ? ? proxyCat.setTitle(R.string.pref_cat_proxy); group.addPreference(proxyCat); CheckBoxPreference useProxyPref = new CheckBoxPreference(context); //? "? ? " useProxyPref.setTitle(R.string.pref_use_proxy); useProxyPref.setSummary(R.string.pref_use_proxy_summary); useProxyPref.setKey(getSharedKey(PREF_KEY_USE_PROXY)); useProxyPref.setDefaultValue(false); useProxyPref.setOnPreferenceChangeListener(updateHttpListener); proxyCat.addPreference(useProxyPref); EditTextPreference proxyHostPref = new EditTextPreference(context); // ? ?-? proxyHostPref.setTitle(R.string.pref_proxy_host); proxyHostPref.setDialogTitle(R.string.pref_proxy_host); proxyHostPref.setSummary(R.string.pref_proxy_host_summary); proxyHostPref.setKey(getSharedKey(PREF_KEY_PROXY_HOST)); proxyHostPref.setDefaultValue(DEFAULT_PROXY_HOST); proxyHostPref.getEditText().setSingleLine(); proxyHostPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); proxyHostPref.setOnPreferenceChangeListener(updateHttpListener); proxyCat.addPreference(proxyHostPref); proxyHostPref.setDependency(getSharedKey(PREF_KEY_USE_PROXY)); EditTextPreference proxyHostPort = new EditTextPreference(context); // ?-? proxyHostPort.setTitle(R.string.pref_proxy_port); proxyHostPort.setDialogTitle(R.string.pref_proxy_port); proxyHostPort.setSummary(R.string.pref_proxy_port_summary); proxyHostPort.setKey(getSharedKey(PREF_KEY_PROXY_PORT)); proxyHostPort.setDefaultValue(DEFAULT_PROXY_PORT); proxyHostPort.getEditText().setSingleLine(); proxyHostPort.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER); proxyHostPort.setOnPreferenceChangeListener(updateHttpListener); proxyCat.addPreference(proxyHostPort); proxyHostPort.setDependency(getSharedKey(PREF_KEY_USE_PROXY)); }
From source file:export.UploadManager.java
private void askUsernamePassword(final Uploader l, boolean showPassword) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(l.getName());//from w w w . j a v a2 s . c o m // Get the layout inflater LayoutInflater inflater = activity.getLayoutInflater(); final View view = inflater.inflate(R.layout.userpass, null); final CheckBox cb = (CheckBox) view.findViewById(R.id.showpass); final TextView tv1 = (TextView) view.findViewById(R.id.username); final TextView tv2 = (TextView) view.findViewById(R.id.password_input); String authConfigStr = l.getAuthConfig(); final JSONObject authConfig = newObj(authConfigStr); String username = authConfig.optString("username", ""); String password = authConfig.optString("password", ""); tv1.setText(username); tv2.setText(password); cb.setChecked(showPassword); tv2.setInputType(InputType.TYPE_CLASS_TEXT | (showPassword ? 0 : InputType.TYPE_TEXT_VARIATION_PASSWORD)); cb.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { tv2.setInputType( InputType.TYPE_CLASS_TEXT | (isChecked ? 0 : InputType.TYPE_TEXT_VARIATION_PASSWORD)); } }); // Inflate and set the layout for the dialog // Pass null as the parent view because its going in the dialog layout builder.setView(view); builder.setPositiveButton("OK", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { authConfig.put("username", tv1.getText()); authConfig.put("password", tv2.getText()); } catch (JSONException e) { e.printStackTrace(); } testUserPass(l, authConfig, cb.isChecked()); } }); builder.setNeutralButton("Skip", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handleAuthComplete(l, Status.SKIP); } }); builder.setNegativeButton("Cancel", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handleAuthComplete(l, Status.SKIP); } }); final AlertDialog dialog = builder.create(); dialog.show(); }
From source file:com.example.android.naradaoffline.DatagramFragment.java
/** * Set up the UI and background operations for chat. */// www . ja v a 2s . c o m private void setupChat() { Log.d(TAG); // Initialize the array adapter for the conversation thread mConversationArrayAdapter = new ArrayAdapter<String>(getActivity(), R.layout.message); //mConversationView.setAdapter(mConversationArrayAdapter); // Initialize the compose field with a listener for the return key // mOutEditText.setOnEditorActionListener(mWriteListener); // Initialize the send button with a listener that for click events mGetNewsPaper.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Send a message using content of the edit text widget View view = getView(); if (null != view) { // TextView textView = (TextView) view.findViewById(R.id.edit_text_out); DatagramRequest d = new DatagramRequest(DatagramRequestType.GET_NEWSPAPER, mConnectedDeviceName); sendDatagramRequest(d); } } }); // Initialize the send button with a listener that for click events mGetEmail.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Send a message using content of the edit text widget View view = getView(); if (null != view) { // TextView textView = (TextView) view.findViewById(R.id.edit_text_out); Log.i(TAG, "button clicked"); AlertDialog.Builder builder = new AlertDialog.Builder(DatagramFragment.this.getContext()); builder.setTitle("Write your email here"); LinearLayout layout = new LinearLayout(getContext()); layout.setOrientation(LinearLayout.VERTICAL); // Set up the input final EditText email = new EditText(DatagramFragment.this.getContext()); email.setHint("Recipient e-mail address"); // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text email.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); layout.addView(email); final EditText input = new EditText(DatagramFragment.this.getContext()); // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text input.setHint("Type your e-mail here"); input.setInputType(InputType.TYPE_CLASS_TEXT); layout.addView(input); builder.setView(layout); // Set up the buttons builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mEmail = email.getText().toString(); mText = input.getText().toString(); DatagramRequest d = new DatagramRequest(DatagramRequestType.SEND_EMAIL, mConnectedDeviceName, "", mEmail, mText); sendDatagramRequest(d); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.show(); } } }); // Initialize the BluetoothDatagramService to perform bluetooth connections mChatService = new BluetoothDatagramService(getActivity(), mHandler); // Initialize the buffer for outgoing messages mOutStringBuffer = new StringBuffer(""); }
From source file:com.ruesga.rview.widget.TagEditTextView.java
private void init(Context ctx, AttributeSet attrs, int defStyleAttr) { mHandler = new Handler(mTagMessenger); mTriggerTagCreationThreshold = CREATE_CHIP_DEFAULT_DELAYED_TIMEOUT; Resources.Theme theme = ctx.getTheme(); TypedArray a = theme.obtainStyledAttributes(attrs, R.styleable.TagEditTextView, defStyleAttr, 0); mReadOnly = a.getBoolean(R.styleable.TagEditTextView_readonly, false); mDefaultTagMode = TAG_MODE.HASH;// w w w .j a v a 2 s . c o m // Create the internal EditText that holds the tag logic mTagEdit = mReadOnly ? new TagEditText(ctx, attrs, defStyleAttr) : new TagEditText(ctx, attrs); mTagEdit.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 0)); mTagEdit.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); mTagEdit.addTextChangedListener(mEditListener); mTagEdit.setTextIsSelectable(false); mTagEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE); mTagEdit.setOnFocusChangeListener((v, hasFocus) -> { // Remove any pending message mHandler.removeMessages(MESSAGE_CREATE_CHIP); }); mTagEdit.setCustomSelectionActionModeCallback(new ActionMode.Callback() { @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { return false; } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { return false; } @Override public void onDestroyActionMode(ActionMode mode) { } }); addView(mTagEdit); // Configure the window mode for landscape orientation, to disallow hide the // EditText control, and show characters instead of chips int orientation = ctx.getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_LANDSCAPE) { if (ctx instanceof Activity) { Window window = ((Activity) ctx).getWindow(); if (window != null) { window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); mTagEdit.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); } } } // Save the keyListener for later restore mEditModeKeyListener = mTagEdit.getKeyListener(); // Initialize resources for chips mChipBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mChipFgPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); mChipFgPaint.setTextSize(mTagEdit.getTextSize() * (mReadOnly ? 1 : 0.8f)); if (CHIP_TYPEFACE != null) { mChipFgPaint.setTypeface(CHIP_TYPEFACE); } mChipFgPaint.setTextAlign(Paint.Align.LEFT); // Calculate the width area used to remove the tag in the chip mChipRemoveAreaWidth = (int) (mChipFgPaint.measureText(CHIP_REMOVE_TEXT) + 0.5f); if (ONE_PIXEL <= 0) { Resources res = getResources(); ONE_PIXEL = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, res.getDisplayMetrics()); } int n = a.getIndexCount(); for (int i = 0; i < n; i++) { int attr = a.getIndex(i); switch (attr) { case R.styleable.TagEditTextView_supportUserTags: setSupportsUserTags(a.getBoolean(attr, false)); break; case R.styleable.TagEditTextView_chipBackgroundColor: mChipBackgroundColor = a.getColor(attr, mChipBackgroundColor); break; case R.styleable.TagEditTextView_chipTextColor: mChipFgPaint.setColor(a.getColor(attr, Color.WHITE)); break; } } a.recycle(); }
From source file:org.runnerup.export.UploadManager.java
private void askUsernamePassword(final Uploader l, boolean showPassword) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(l.getName());/*from www .j a va2 s .co m*/ // Get the layout inflater LayoutInflater inflater = activity.getLayoutInflater(); final View view = inflater.inflate(R.layout.userpass, null); final CheckBox cb = (CheckBox) view.findViewById(R.id.showpass); final TextView tv1 = (TextView) view.findViewById(R.id.username); final TextView tv2 = (TextView) view.findViewById(R.id.password_input); String authConfigStr = l.getAuthConfig(); final JSONObject authConfig = newObj(authConfigStr); String username = authConfig.optString("username", ""); String password = authConfig.optString("password", ""); tv1.setText(username); tv2.setText(password); cb.setChecked(showPassword); tv2.setInputType(InputType.TYPE_CLASS_TEXT | (showPassword ? 0 : InputType.TYPE_TEXT_VARIATION_PASSWORD)); cb.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { tv2.setInputType( InputType.TYPE_CLASS_TEXT | (isChecked ? 0 : InputType.TYPE_TEXT_VARIATION_PASSWORD)); } }); // Inflate and set the layout for the dialog // Pass null as the parent view because its going in the dialog layout builder.setView(view); builder.setPositiveButton(getResources().getString(R.string.ok), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { authConfig.put("username", tv1.getText()); authConfig.put("password", tv2.getText()); } catch (JSONException e) { e.printStackTrace(); } testUserPass(l, authConfig, cb.isChecked()); } }); builder.setNeutralButton("Skip", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handleAuthComplete(l, Status.SKIP); } }); builder.setNegativeButton(getResources().getString(R.string.cancel), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handleAuthComplete(l, Status.SKIP); } }); final AlertDialog dialog = builder.create(); dialog.show(); }