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:nya.miku.wishmaster.chans.tirech.TirechModule.java

@Override
public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) {
    Context context = preferenceGroup.getContext();
    EditTextPreference domainPref = new EditTextPreference(context);
    domainPref.setTitle(R.string.pref_domain);
    domainPref.setDialogTitle(R.string.pref_domain);
    domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT));
    domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN));
    domainPref.getEditText().setHint(DEFAULT_DOMAIN);
    domainPref.getEditText().setSingleLine();
    domainPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
    preferenceGroup.addPreference(domainPref);
    addPasswordPreference(preferenceGroup);
    addCloudflareRecaptchaFallbackPreference(preferenceGroup);
    addProxyPreferences(preferenceGroup);
}

From source file:nl.hnogames.domoticz.SpeechSettingsActivity.java

private void showEditDialog(final SpeechInfo mSpeechInfo) {
    new MaterialDialog.Builder(this).title(R.string.Speech_edit).content(R.string.Speech_name)
            .inputType(InputType.TYPE_CLASS_TEXT).negativeText(R.string.cancel)
            .input(this.getString(R.string.category_Speech), mSpeechInfo.getName(),
                    new MaterialDialog.InputCallback() {
                        @Override
                        public void onInput(@NonNull MaterialDialog dialog, CharSequence input) {
                            if (!UsefulBits.isEmpty(String.valueOf(input))) {
                                mSpeechInfo.setName(String.valueOf(input));
                                updateSpeech(mSpeechInfo);
                            }/*from w  w w  .j  a v  a  2s.  c o m*/
                        }
                    })
            .show();
}

From source file:com.launcher.silverfish.launcher.appdrawer.TabbedAppDrawerFragment.java

private void promptRenameTab(final TabInfo tab, final int tab_index) {

    // Find which tab we're renaming
    String tabName = tab.getLabel();

    AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
    builder.setTitle(String.format(getString(R.string.text_renaming_tab), tabName));

    // Set up the input
    final EditText input = new EditText(getContext());
    // Specify the type of input expected
    input.setInputType(InputType.TYPE_CLASS_TEXT);
    builder.setView(input);//w  w  w  .  j a  v a 2  s . c o  m

    // Set up the buttons
    builder.setPositiveButton(getString(R.string.text_rename), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            try {
                tabHandler.renameTab(tab, tab_index, input.getText().toString());
            } catch (IllegalArgumentException e) {
                /* This means that the user entered an empty name */
                showToast(R.string.text_cannot_name_empty);
            }
        }
    });
    builder.setNegativeButton(getString(R.string.text_cancel), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    builder.show();
}

From source file:hcm.ssj.creator.dialogs.FileDialog.java

/**
 * @param savedInstanceState Bundle/* w  ww.j  a v  a2  s.  co  m*/
 * @return Dialog
 */
@Override
@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(titleMessage);
    builder.setPositiveButton(R.string.str_ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            switch (type) {
            case SAVE: {
                String fileName = editText.getText().toString().trim();
                File dir1 = new File(Environment.getExternalStorageDirectory(), Util.DIR_1);
                File dir2 = new File(dir1.getPath(), Util.DIR_2);
                if (!fileName.isEmpty() && (dir2.exists() || dir2.mkdirs())) {
                    if (!fileName.endsWith(Util.SUFFIX)) {
                        fileName += Util.SUFFIX;
                    }
                    File file = new File(dir2, fileName);
                    if (isValidFileName(file) && SaveLoad.save(file)) {
                        for (Listener listener : alListeners) {
                            listener.onPositiveEvent(null);
                        }
                        return;
                    }
                }
                for (Listener listener : alListeners) {
                    listener.onNegativeEvent(new Boolean[] { false });
                }
                return;
            }
            case LOAD:
            case DELETE: {
                if (xmlFiles != null && xmlFiles.length > 0) {
                    int pos = listView.getCheckedItemPosition();
                    if (pos > AbsListView.INVALID_POSITION) {
                        if (type == Type.DELETE && xmlFiles[pos].delete()) {
                            for (Listener listener : alListeners) {
                                listener.onPositiveEvent(null);
                            }
                            return;
                        } else if (type == Type.LOAD) {
                            if (SaveLoad.load(xmlFiles[pos])) {
                                for (Listener listener : alListeners) {
                                    listener.onPositiveEvent(null);
                                }
                                return;
                            }
                        }
                        for (Listener listener : alListeners) {
                            listener.onNegativeEvent(new Boolean[] { false });
                        }
                        return;
                    }
                }
                for (Listener listener : alListeners) {
                    listener.onNegativeEvent(null);
                }
                break;
            }
            }
        }
    });
    builder.setNegativeButton(R.string.str_cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            for (Listener listener : alListeners) {
                listener.onNegativeEvent(null);
            }
        }
    });
    //set up the input
    switch (type) {
    case SAVE: {
        editText = new EditText(getContext());
        editText.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
        editText.setInputType(InputType.TYPE_CLASS_TEXT);
        builder.setView(editText);
        break;
    }
    case LOAD:
    case DELETE: {
        listView = new ListView(getContext());
        listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        File dir1 = new File(Environment.getExternalStorageDirectory(), Util.DIR_1);
        File dir2 = new File(dir1.getPath(), Util.DIR_2);
        xmlFiles = dir2.listFiles(new FilenameFilter() {
            @Override
            public boolean accept(File folder, String name) {
                return name.toLowerCase().endsWith(Util.SUFFIX);
            }
        });
        if (xmlFiles != null && xmlFiles.length > 0) {
            String[] ids = new String[xmlFiles.length];
            for (int i = 0; i < ids.length; i++) {
                ids[i] = xmlFiles[i].getName();
            }
            listView.setAdapter(
                    new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_single_choice, ids));
        } else {
            listView.setAdapter(
                    new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_single_choice));
        }
        builder.setView(listView);
        break;
    }
    }
    return builder.create();
}

From source file:com.sim2dial.dialer.ChatFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    sipUri = getArguments().getString("SipUri");
    String displayName = getArguments().getString("DisplayName");
    String pictureUri = getArguments().getString("PictureUri");

    view = inflater.inflate(R.layout.chat, container, false);

    contactName = (TextView) view.findViewById(R.id.contactName);
    contactPicture = (AvatarWithShadow) view.findViewById(R.id.contactPicture);

    sendMessage = (TextView) view.findViewById(R.id.sendMessage);
    sendMessage.setOnClickListener(this);

    message = (EditText) view.findViewById(R.id.message);
    if (!getActivity().getResources().getBoolean(R.bool.allow_chat_multiline)) {
        message.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE);
        message.setMaxLines(1);/*ww  w. j  a v a2  s. c  o m*/
    }

    uploadLayout = (RelativeLayout) view.findViewById(R.id.uploadLayout);
    textLayout = (RelativeLayout) view.findViewById(R.id.messageLayout);

    messagesLayout = (RelativeLayout) view.findViewById(R.id.messages);
    messagesScrollView = (ScrollView) view.findViewById(R.id.chatScrollView);
    progressBar = (ProgressBar) view.findViewById(R.id.progressbar);

    sendImage = (TextView) view.findViewById(R.id.sendPicture);
    registerForContextMenu(sendImage);
    sendImage.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pickImage();
        }
    });

    cancelUpload = (ImageView) view.findViewById(R.id.cancelUpload);
    cancelUpload.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            uploadThread.interrupt();
            uploadLayout.setVisibility(View.GONE);
            textLayout.setVisibility(View.VISIBLE);
            progressBar.setProgress(0);
        }
    });

    displayChat(displayName, pictureUri);

    LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
    if (lc != null) {
        chatRoom = lc.createChatRoom(sipUri);
    }

    uploadServerUri = Engine.getPref().getString(getString(R.string.pref_image_sharing_server_key),
            getString(R.string.pref_image_sharing_server_default));

    textWatcher = new TextWatcher() {
        public void afterTextChanged(Editable arg0) {

        }

        public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {

        }

        public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
            if (message.getText().toString().equals("")) {
                sendMessage.setEnabled(false);
            } else {
                sendMessage.setEnabled(true);
            }
        }
    };

    // Force hide keyboard
    if (LinphoneActivity.isInstanciated()) {
        InputMethodManager imm = (InputMethodManager) LinphoneActivity.instance()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }

    // Workaround for SGS3 issue
    if (savedInstanceState != null) {
        fileToUploadPath = savedInstanceState.getString("fileToUploadPath");
        imageToUpload = savedInstanceState.getParcelable("imageToUpload");
    }
    if (fileToUploadPath != null || imageToUpload != null) {
        sendImage.post(new Runnable() {
            @Override
            public void run() {
                sendImage.showContextMenu();
            }
        });
    }

    return view;
}

From source file:com.app_software.chromisstock.StockChangeDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    // Get the layout inflater
    LayoutInflater inflater = getActivity().getLayoutInflater();

    // Inflate and set the layout for the dialog
    // Pass null as the parent view because its going in the dialog layout

    View v = inflater.inflate(R.layout.dialog_stock_change, null);

    // Set information given in the Intent
    m_txtProductName = (TextView) v.findViewById(R.id.txtProductName);
    m_txtField = (TextView) v.findViewById(R.id.txtField);
    m_editNewValue = (EditText) v.findViewById(R.id.editNewValue);
    m_rbIncrease = (RadioButton) v.findViewById(R.id.rbIncrease);
    m_rbDecrease = (RadioButton) v.findViewById(R.id.rbDecrease);
    m_rbSetValue = (RadioButton) v.findViewById(R.id.rbSetValue);

    m_rbIncrease.setEnabled(m_bAllowAdjust);
    m_rbDecrease.setEnabled(m_bAllowAdjust);

    DatabaseHandler db = DatabaseHandler.getInstance(getActivity());
    StockProduct product = db.getProduct(m_ProductID, true);
    if (product == null) {
        Log.e(TAG, "Product not found");
        m_txtProductName.setText("DATABASE ERROR!!");
    } else {//from  w  ww . j a v  a 2s.  c om

        m_ChromisID = product.getChromisId();
        String name;
        if (TextUtils.isEmpty(product.getValueString(StockProduct.NAME))) {
            name = getResources().getString(R.string.change_newproduct);
        } else {
            name = product.getValueString(StockProduct.NAME);
        }
        m_txtProductName.setText(name);
        m_txtField.setText(m_FieldLabel);

        if (m_ChangeType == DatabaseHandler.CHANGETYPE_ADJUSTVALUE) {
            Double d = new Double(m_Value);
            if (d < 0) {
                m_rbDecrease.setChecked(true);
                d = d * -1;
                m_Value = String.format("%.0f", d);
            } else {
                m_rbIncrease.setChecked(true);
            }
        } else {
            m_rbSetValue.setChecked(true);
        }

        if (m_bIsNumber) {
            m_editNewValue.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
        } else {
            m_editNewValue.setInputType(InputType.TYPE_CLASS_TEXT);
            m_editNewValue.setText(m_Value);
        }
        m_editNewValue.setHint(m_Value);
    }

    // Add action buttons
    builder.setView(v).setPositiveButton(R.string.label_ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            // Create a new change record
            createChangeRecord();
        }
    }).setNegativeButton(R.string.label_cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
        }
    });

    return builder.create();
}

From source file:com.example.anish.myapplication.MainActivity.java

private void showInputDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Change city");
    final EditText input = new EditText(this);
    input.setInputType(InputType.TYPE_CLASS_TEXT);
    builder.setView(input);//ww w  . ja v  a 2 s  .c om
    builder.setPositiveButton("Go", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            changeCity(input.getText().toString());
        }
    });
    builder.show();
}

From source file:com.brq.wallet.activity.export.DecryptBip38PrivateKeyActivity.java

private void setPasswordHideShow(boolean show) {
    if (show) {/*from  ww  w  . jav  a  2  s.  c o m*/
        // Show password in plaintext
        passwordEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
    } else {
        // Hide password
        passwordEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    }
    // Set cursor to last position
    passwordEdit.setSelection(passwordEdit.getText().length());
}

From source file:org.site_monitor.activity.SiteSettingsActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.action_refresh) {
        if (siteSettings.isChecking()) {
            return true;
        }//from   w  w w  .ja va 2s  .co m
        syncMenuItem.setEnabled(false);
        new CallSiteTask(this, siteSettingsFragment).execute(siteSettings.getSiteSettings());
        return true;
    }
    if (id == R.id.action_rename) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setTitle(R.string.action_rename);
        final EditText input = new EditText(context);
        input.setHint(R.string.hint_rename_site);
        input.setText(siteSettings.getName());
        input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
                | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
        builder.setView(input);
        builder.setPositiveButton(R.string.action_rename, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                String name = input.getText().toString().trim();
                if (name.isEmpty()) {
                    name = getString(R.string.no_name);
                }
                siteSettings.getSiteSettings().setName(name);
                setTitle(siteSettings.getName());
                try {
                    DBSiteSettings dbSiteSettings = dbHelper.getDBSiteSettings();
                    dbSiteSettings.update(siteSettings.getSiteSettings());
                    WidgetManager.refresh(context);
                } catch (SQLException e) {
                    Log.e(TAG, "rename", e);
                }

            }
        });
        builder.setNegativeButton(R.string.action_cancel, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
            }
        });
        builder.show();
        return true;
    }
    if (id == R.id.action_delete) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(R.string.remove_current_monitor);
        builder.setPositiveButton(R.string.action_delete, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                try {
                    DBSiteSettings dbSiteSettings = dbHelper.getDBSiteSettings();
                    dbSiteSettings.delete(siteSettings.getSiteSettings());
                    AlarmUtil.instance().stopAlarmIfNeeded(context);
                } catch (SQLException e) {
                    Log.e(TAG, "remove", e);
                }
                WidgetManager.refresh(context);
                finish();
            }
        });

        builder.setNegativeButton(R.string.action_cancel, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
            }
        });
        builder.show();
        return true;
    }
    if (id == R.id.action_add_internal_ip) {
        if (addInternalIpMenuItem.isChecked()) {
            try {
                siteSettings.getSiteSettings().setInternalUrl(null);
                DBSiteSettings dbSiteSettings = dbHelper.getDBSiteSettings();
                dbSiteSettings.update(siteSettings.getSiteSettings());
                addInternalIpMenuItem.setChecked(!addInternalIpMenuItem.isChecked());
                Snackbar.make(this.getCurrentFocus(), R.string.internal_url_removed, Snackbar.LENGTH_SHORT)
                        .show();
                siteSettingsFragment.setSiteSettings(siteSettings);
            } catch (SQLException e) {
                Log.e(TAG, "update", e);
            }
        } else {
            AlertDialog.Builder builder = new AlertDialog.Builder(context);
            builder.setTitle(R.string.add_internal_url);
            final EditText input = new EditText(context);
            input.setHint(R.string.hint_interval_site_url);
            input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
                    | InputType.TYPE_TEXT_VARIATION_URI);
            builder.setView(input);
            builder.setPositiveButton(R.string.action_add, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    String internalIp = input.getText().toString().trim();
                    if (internalIp.isEmpty()) {
                        return;
                    }
                    try {
                        siteSettings.getSiteSettings().setInternalUrl(internalIp);
                        DBSiteSettings dbSiteSettings = dbHelper.getDBSiteSettings();
                        dbSiteSettings.update(siteSettings.getSiteSettings());
                        addInternalIpMenuItem.setChecked(!addInternalIpMenuItem.isChecked());
                        Snackbar.make(context.getCurrentFocus(), R.string.internal_url_added,
                                Snackbar.LENGTH_SHORT).show();
                        siteSettingsFragment.setSiteSettings(siteSettings);
                    } catch (SQLException e) {
                        Log.e(TAG, "update", e);
                    }
                }
            });
            builder.setNegativeButton(R.string.action_cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            });
            builder.show();
        }
        return true;
    }
    return false;
}

From source file:au.org.ala.fielddata.mobile.SurveyBuilder.java

public View buildInput(Attribute attribute, ViewGroup parent) {
    Record record = model.getRecord();/*from www .j  a v a2  s  .  c  o m*/
    View view;

    switch (attribute.getType()) {
    case STRING:
        view = buildEditText(InputType.TYPE_CLASS_TEXT, parent);
        break;
    case INTEGER:
    case NUMBER:
        view = buildEditText(InputType.TYPE_CLASS_NUMBER, parent);
        break;
    case DECIMAL:
    case ACCURACY:
        view = buildEditText(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL, parent);
        break;
    case MULTI_SELECT:
    case POINT_SOURCE:
    case STRING_WITH_VALID_VALUES:
        view = buildSpinner(attribute, parent);
        break;
    case CATEGORIZED_MULTI_SELECT:
        view = buildCategorizedSpinner(attribute, parent);
        break;
    case NOTES:
        view = buildEditText(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE, parent);
        break;
    case WHEN:
        view = buildDatePicker(attribute, record, parent);
        break;
    case DWC_TIME:
        view = buildTimePicker(attribute, record, parent);
        break;
    case SPECIES_P:
        view = buildSpeciesPicker(attribute, parent);
        break;
    case POINT:
        view = buildLocationPicker(attribute, parent);
        break;
    case IMAGE:
        view = buildImagePicker(attribute, parent);
        break;
    case SINGLE_CHECKBOX:
        view = buildSingleCheckbox(attribute, parent);
        break;
    case MULTI_CHECKBOX:
        view = buildMultiSpinner(attribute, parent);
        break;
    default:
        view = buildEditText(InputType.TYPE_CLASS_TEXT, parent);
        break;
    }
    return view;
}