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:com.simplealertdialog.sample.demos.SampleSupportFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_sample_support, container, false);

    view.findViewById(R.id.btn_frag_message).setOnClickListener(new View.OnClickListener() {
        @Override//from   w  ww.  ja v  a  2  s  . co  m
        public void onClick(final View v) {
            new SimpleAlertDialogSupportFragment.Builder().setMessage("Hello world!")
                    .setPositiveButton(android.R.string.ok).setTargetFragment(SampleSupportFragment.this)
                    .create().show(getActivity().getSupportFragmentManager(), "dialog");
        }
    });

    view.findViewById(R.id.btn_frag_message_title).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            TypedArray a = getActivity().getTheme().obtainStyledAttributes(new int[] { R.attr.icon });
            int iconResId = a.getResourceId(0, 0);
            a.recycle();
            new SimpleAlertDialogSupportFragment.Builder().setTitle("Hello world!").setIcon(iconResId)
                    .setMessage("Hello world!").setPositiveButton(android.R.string.ok)
                    .setTargetFragment(SampleSupportFragment.this).create()
                    .show(getActivity().getSupportFragmentManager(), "dialog");
        }
    });

    view.findViewById(R.id.btn_frag_buttons).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            new SimpleAlertDialogSupportFragment.Builder().setTitle("Hello world!").setMessage("Hello world!")
                    .setPositiveButton(android.R.string.ok).setNegativeButton(android.R.string.cancel)
                    .setRequestCode(REQUEST_CODE_BUTTONS).setTargetFragment(SampleSupportFragment.this).create()
                    .show(getActivity().getSupportFragmentManager(), "dialog");
        }
    });

    view.findViewById(R.id.btn_frag_3_buttons).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            new SimpleAlertDialogSupportFragment.Builder().setTitle("Hello world!").setMessage("Hello world!")
                    .setPositiveButton(android.R.string.ok).setNeutralButton(R.string.neutral)
                    .setNegativeButton(android.R.string.cancel).setRequestCode(REQUEST_CODE_3_BUTTONS)
                    .setTargetFragment(SampleSupportFragment.this).create()
                    .show(getActivity().getSupportFragmentManager(), "dialog");
        }
    });

    view.findViewById(R.id.btn_frag_items).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            new SimpleAlertDialogSupportFragment.Builder().setTitle("Choose one")
                    .setItems(R.array.single_choice).setRequestCode(REQUEST_CODE_ITEMS)
                    .setTargetFragment(SampleSupportFragment.this).create()
                    .show(getActivity().getSupportFragmentManager(), "dialog");
        }
    });

    view.findViewById(R.id.btn_frag_icon_items).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            new SimpleAlertDialogSupportFragment.Builder().setTitle("Choose one")
                    .setItems(R.array.icon_items, getIcons()).setRequestCode(REQUEST_CODE_ICON_ITEMS)
                    .setTargetFragment(SampleSupportFragment.this).create()
                    .show(getActivity().getSupportFragmentManager(), "dialog");
        }
    });

    view.findViewById(R.id.btn_frag_single_choice_list).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            new SimpleAlertDialogSupportFragment.Builder().setTitle("Choose one").setSingleChoiceCheckedItem(0)
                    .setRequestCode(REQUEST_CODE_SINGLE_CHOICE_LIST)
                    .setTargetFragment(SampleSupportFragment.this).create()
                    .show(getActivity().getSupportFragmentManager(), "dialog");
        }
    });

    view.findViewById(R.id.btn_frag_adapter).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            new SimpleAlertDialogSupportFragment.Builder().setTitle("Choose your favorite").setUseAdapter(true)
                    .setRequestCode(REQUEST_CODE_ADAPTER).setTargetFragment(SampleSupportFragment.this).create()
                    .show(getActivity().getSupportFragmentManager(), "dialog");
        }
    });

    view.findViewById(R.id.btn_frag_view).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            new SimpleAlertDialogSupportFragment.Builder().setTitle("Enter something").setUseView(true)
                    .setPositiveButton(android.R.string.ok).setRequestCode(REQUEST_CODE_VIEW)
                    .setTargetFragment(SampleSupportFragment.this).create()
                    .show(getActivity().getSupportFragmentManager(), "dialog");
        }
    });

    view.findViewById(R.id.btn_frag_edit_text).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            new SimpleAlertDialogSupportFragment.Builder().setTitle("Enter password")
                    .setEditText("", InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD)
                    .setPositiveButton(android.R.string.ok).setRequestCode(REQUEST_CODE_EDIT_TEXT)
                    .setTargetFragment(SampleSupportFragment.this).create()
                    .show(getActivity().getSupportFragmentManager(), "dialog");
        }
    });

    view.findViewById(R.id.btn_frag_themed).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            new SimpleAlertDialogSupportFragment.Builder().setTheme(R.style.SimpleAlertDialogCustomTheme)
                    .setMessage("Hello world!").setPositiveButton(android.R.string.ok)
                    .setTargetFragment(SampleSupportFragment.this).create()
                    .show(getActivity().getSupportFragmentManager(), "dialog");
        }
    });

    return view;
}

From source file:br.com.thinkti.android.filechooserfrag.fragFileChooser.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    View v = info.targetView;//from ww w  .  j a va 2 s.c om
    final Option o = adapter.getItem((int) info.id);
    switch (item.getItemId()) {
    case R.id.mnuDelete:
        String msg = String.format(getString(R.string.txtReallyDelete), o.getName());
        if (lib.ShowMessageYesNo(_main, msg, _main.getString(R.string.question)) == lib.yesnoundefined.yes) {
            try {
                File F = new File(o.getPath());
                boolean delete = false;
                if (F.exists()) {
                    if (F.isDirectory()) {
                        String[] deleteCmd = { "rm", "-r", F.getPath() };
                        Runtime runtime = Runtime.getRuntime();
                        runtime.exec(deleteCmd);
                        delete = true;
                    } else {
                        delete = F.delete();
                    }
                }

                if (delete)
                    adapter.remove(o);

            } catch (Exception ex) {
                lib.ShowMessage(_main, ex.getMessage(), getString((R.string.Error)));
            }
        }
        //lib.ShowToast(_main,"delete " + t1.getText().toString() + " " + t2.getText().toString() + " " + o.getData() + " "  + o.getPath() + " " + o.getName());
        //editNote(info.id);
        return true;
    case R.id.mnuRename:
        String msg2 = String.format(getString(R.string.txtRenameFile), o.getName());
        AlertDialog.Builder A = new AlertDialog.Builder(_main);
        final EditText inputRename = new EditText(_main);
        A.setMessage(msg2);
        A.setTitle(getString(R.string.rename));

        // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
        inputRename.setInputType(InputType.TYPE_CLASS_TEXT);
        inputRename.setText(o.getName());
        A.setView(inputRename);
        A.setPositiveButton(_main.getString(R.string.ok), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                String name = inputRename.getText().toString();
                final String pattern = ".+\\.(((?i)v.{2})|((?i)k.{2})|((?i)dic))$";
                Pattern vok = Pattern.compile(pattern);
                if (lib.libString.IsNullOrEmpty(name))
                    return;
                if (vok.matcher(name).matches()) {
                    try {

                        File F = new File(o.getPath());
                        File F2 = new File(F.getParent(), name);
                        if (!F2.exists()) {
                            final boolean b = F.renameTo(F2);
                            if (b) {
                                o.setName(name);
                                o.setPath(F2.getPath());
                                adapter.notifyDataSetChanged();
                            }
                        } else {
                            lib.ShowMessage(_main, getString(R.string.msgFileExists), "");
                        }

                    } catch (Exception ex) {
                        lib.ShowMessage(_main, ex.getMessage(), getString((R.string.Error)));
                    }
                } else {
                    AlertDialog.Builder A = new AlertDialog.Builder(_main);
                    A.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {

                        }
                    });
                    A.setMessage(getString(R.string.msgWrongExt2));
                    A.setTitle(getString(R.string.message));
                    AlertDialog dlg = A.create();
                    dlg.show();

                }
            }
        });
        A.setNegativeButton(_main.getString(R.string.cancel), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });
        AlertDialog dlg = A.create();
        dlg.show();
        return true;
    case R.id.mnuCopy:
        _copiedFile = (o.getPath());
        _cutFile = null;
        return true;
    case R.id.mnuCut:
        _cutFile = (o.getPath());
        _cutOption = o;
        _copiedFile = null;
        return true;
    case R.id.mnuPaste:
        if (_cutFile != null && _copiedFile != null)
            return true;
        String path;
        File F = new File(o.getPath());
        if (F.isDirectory()) {
            path = F.getPath();
        } else {
            path = F.getParent();
        }
        if (_copiedFile != null) {
            File source = new File(_copiedFile);
            File dest = new File(path, source.getName());
            if (dest.exists()) {
                lib.ShowMessage(_main, getString(R.string.msgFileExists), "");
                return true;
            }
            String[] copyCmd;
            if (source.isDirectory()) {
                copyCmd = new String[] { "cp", "-r", _copiedFile, path };
            } else {
                copyCmd = new String[] { "cp", _copiedFile, path };
            }
            Runtime runtime = Runtime.getRuntime();
            try {
                runtime.exec(copyCmd);
                Option newOption;
                if (dest.getParent().equalsIgnoreCase(currentDir.getPath())) {
                    if (dest.isDirectory() && !dest.isHidden()) {
                        adapter.add(new Option(dest.getName(), getString(R.string.folder),
                                dest.getAbsolutePath(), true, false, false));
                    } else {
                        if (!dest.isHidden())
                            adapter.add(new Option(dest.getName(),
                                    getString(R.string.fileSize) + ": " + dest.length(), dest.getAbsolutePath(),
                                    false, false, false));
                    }
                }
            } catch (Exception ex) {
                lib.ShowMessage(_main, ex.getMessage(), getString((R.string.Error)));
            }

        } else if (_cutFile != null) {
            File source = new File(_cutFile);
            File dest = new File(path, source.getName());
            if (dest.exists()) {
                lib.ShowMessage(_main, getString(R.string.msgFileExists), "");
                return true;
            }
            String[] copyCmd;
            if (source.isDirectory()) {
                copyCmd = new String[] { "mv", "-r", _cutFile, path };
            } else {
                copyCmd = new String[] { "mv", _cutFile, path };
            }
            Runtime runtime = Runtime.getRuntime();
            _cutFile = null;
            try {
                runtime.exec(copyCmd);
                Option newOption;
                try {
                    adapter.remove(_cutOption);
                    _cutOption = null;
                } catch (Exception e) {

                }
                if (dest.getParent().equalsIgnoreCase(currentDir.getPath())) {
                    if (dest.isDirectory() && !dest.isHidden()) {
                        adapter.add(new Option(dest.getName(), getString(R.string.folder),
                                dest.getAbsolutePath(), true, false, false));
                    } else {
                        if (!dest.isHidden())
                            adapter.add(new Option(dest.getName(),
                                    getString(R.string.fileSize) + ": " + dest.length(), dest.getAbsolutePath(),
                                    false, false, false));
                    }
                }
            } catch (Exception ex) {
                lib.ShowMessage(_main, ex.getMessage(), getString((R.string.Error)));
            }
        }
        return true;
    case R.id.mnuNewFolder:
        A = new AlertDialog.Builder(_main);
        //final EditText input = new EditText(_main);
        final EditText inputNF = new EditText(_main);
        A.setMessage(getString(R.string.msgEnterNewFolderName));
        A.setTitle(getString(R.string.cmnuNewFolder));

        // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
        inputNF.setInputType(InputType.TYPE_CLASS_TEXT);
        inputNF.setText("");
        A.setView(inputNF);
        A.setPositiveButton(_main.getString(R.string.ok), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                String name = inputNF.getText().toString();
                if (lib.libString.IsNullOrEmpty(name))
                    return;
                String NFpath;
                File NF = new File(o.getPath());
                if (NF.isDirectory()) {
                    NFpath = NF.getPath();
                } else {
                    NFpath = NF.getParent();
                }
                try {
                    File NewFolder = new File(NFpath, name);
                    NewFolder.mkdir();
                    adapter.add(new Option(NewFolder.getName(), getString(R.string.folder),
                            NewFolder.getAbsolutePath(), true, false, false));

                } catch (Exception ex) {
                    lib.ShowException(_main, ex);
                }
            }
        });
        A.setNegativeButton(_main.getString(R.string.cancel), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });
        dlg = A.create();
        dlg.show();
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:com.mishiranu.dashchan.ui.navigator.DrawerForm.java

public DrawerForm(Context context, Context unstyledContext, Callback callback,
        WatcherService.Client watcherServiceClient) {
    this.context = context;
    this.unstyledContext = unstyledContext;
    this.callback = callback;
    this.watcherServiceClient = watcherServiceClient;
    float density = ResourceUtils.obtainDensity(context);
    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setLayoutParams(new SortableListView.LayoutParams(SortableListView.LayoutParams.MATCH_PARENT,
            SortableListView.LayoutParams.WRAP_CONTENT));
    LinearLayout editTextContainer = new LinearLayout(context);
    editTextContainer.setGravity(Gravity.CENTER_VERTICAL);
    linearLayout.addView(editTextContainer);
    searchEdit = new SafePasteEditText(context);
    searchEdit.setOnKeyListener((v, keyCode, event) -> {
        if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
            v.clearFocus();/*from   w  w  w.  j  a v a 2s  . c  o  m*/
        }
        return false;
    });
    searchEdit.setHint(context.getString(R.string.text_code_number_address));
    searchEdit.setOnEditorActionListener(this);
    searchEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
    searchEdit.setImeOptions(EditorInfo.IME_ACTION_GO | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    ImageView searchIcon = new ImageView(context, null, android.R.attr.buttonBarButtonStyle);
    searchIcon.setImageResource(ResourceUtils.getResourceId(context, R.attr.buttonForward, 0));
    searchIcon.setScaleType(ImageView.ScaleType.CENTER);
    searchIcon.setOnClickListener(this);
    editTextContainer.addView(searchEdit,
            new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1));
    editTextContainer.addView(searchIcon, (int) (40f * density), (int) (40f * density));
    if (C.API_LOLLIPOP) {
        editTextContainer.setPadding((int) (12f * density), (int) (8f * density), (int) (8f * density), 0);
    } else {
        editTextContainer.setPadding(0, (int) (2f * density), (int) (4f * density), (int) (2f * density));
    }
    LinearLayout selectorContainer = new LinearLayout(context);
    selectorContainer.setBackgroundResource(
            ResourceUtils.getResourceId(context, android.R.attr.selectableItemBackground, 0));
    selectorContainer.setOrientation(LinearLayout.HORIZONTAL);
    selectorContainer.setGravity(Gravity.CENTER_VERTICAL);
    selectorContainer.setOnClickListener(v -> {
        hideKeyboard();
        setChanSelectMode(!chanSelectMode);
    });
    linearLayout.addView(selectorContainer);
    selectorContainer.setMinimumHeight((int) (40f * density));
    if (C.API_LOLLIPOP) {
        selectorContainer.setPadding((int) (16f * density), 0, (int) (16f * density), 0);
        ((LinearLayout.LayoutParams) selectorContainer.getLayoutParams()).topMargin = (int) (4f * density);
    } else {
        selectorContainer.setPadding((int) (8f * density), 0, (int) (12f * density), 0);
    }
    chanNameView = new TextView(context, null, android.R.attr.textAppearanceListItem);
    chanNameView.setTextSize(TypedValue.COMPLEX_UNIT_SP, C.API_LOLLIPOP ? 14f : 16f);
    if (C.API_LOLLIPOP) {
        chanNameView.setTypeface(GraphicsUtils.TYPEFACE_MEDIUM);
    } else {
        chanNameView.setFilters(new InputFilter[] { new InputFilter.AllCaps() });
    }
    selectorContainer.addView(chanNameView,
            new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1));
    chanSelectorIcon = new ImageView(context);
    chanSelectorIcon.setImageResource(ResourceUtils.getResourceId(context, R.attr.buttonDropDownDrawer, 0));
    selectorContainer.addView(chanSelectorIcon, (int) (24f * density), (int) (24f * density));
    ((LinearLayout.LayoutParams) chanSelectorIcon.getLayoutParams()).gravity = Gravity.CENTER_VERTICAL
            | Gravity.END;
    headerView = linearLayout;
    inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    chans.add(new ListItem(ListItem.ITEM_DIVIDER, 0, 0, null));
    int color = ResourceUtils.getColor(context, R.attr.drawerIconColor);
    ChanManager manager = ChanManager.getInstance();
    Collection<String> availableChans = manager.getAvailableChanNames();
    for (String chanName : availableChans) {
        ChanConfiguration configuration = ChanConfiguration.get(chanName);
        if (configuration.getOption(ChanConfiguration.OPTION_READ_POSTS_COUNT)) {
            watcherSupportSet.add(chanName);
        }
        Drawable drawable = manager.getIcon(chanName, color);
        chanIcons.put(chanName, drawable);
        chans.add(
                new ListItem(ListItem.ITEM_CHAN, chanName, null, null, configuration.getTitle(), 0, drawable));
    }
    if (availableChans.size() == 1) {
        selectorContainer.setVisibility(View.GONE);
    }
}

From source file:co.beem.project.beem.ui.wizard.AccountConfigureFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.wizard_account_configure, container, false);

    mNextButton = (TextView) v.findViewById(R.id.next);
    mNextButton.setEnabled(false);// w w  w .j av a 2  s.c o m
    mNextButton.setOnClickListener(this);
    mErrorLabel = (TextView) v.findViewById(R.id.error_label);
    mSettingsWarningLabel = (TextView) v.findViewById(R.id.settings_warn_label);
    errorDivider = v.findViewById(R.id.error_divider);
    mAccountJID = (EditText) v.findViewById(R.id.account_username);
    mAccountJID.setOnFocusChangeListener(new OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            isAccountEdtFocused = hasFocus;
        }
    });
    mAccountPassword = (EditText) v.findViewById(R.id.account_password);
    mAccountPassword.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            isPasswordEdtFocused = hasFocus;
        }
    });
    //mAccountJID.setFilters(newFilters);
    mAccountJID.addTextChangedListener(mJidTextWatcher);
    mAccountPassword.addTextChangedListener(mPasswordTextWatcher);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) // true to disable the feature until ready
        v.findViewById(R.id.account_layout).setVisibility(View.GONE);
    mAccountPassword.setImeOptions(EditorInfo.IME_ACTION_DONE);
    mAccountPassword.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (event != null) {
                if (!event.isShiftPressed()) {
                    onClick(mNextButton);
                    return true;
                }
                return false;
            }
            onClick(mNextButton);
            return true;
        }
    });
    showBtn = (TextView) v.findViewById(R.id.login_show_btn);
    showBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!isPasswordShowing) {
                showBtn.setText(getText(R.string.hide));
                mAccountPassword.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
            } else {
                showBtn.setText(getText(R.string.show));
                mAccountPassword
                        .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
            }
            mAccountPassword.setSelection(mAccountPassword.length());
            isPasswordShowing = !isPasswordShowing;
        }
    });
    createNewAccountButton = (TextView) v.findViewById(R.id.create_new_account);
    createNewAccountButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            ((Account) getActivity()).pushFragment(
                    WebViewFragment.instanciate("https://m.facebook.com/r.php?loc=bottom&refid=8"));
        }
    });
    forgotPasswordTv = (TextView) v.findViewById(R.id.forgot_password_tv);
    forgotPasswordTv.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            ((Account) getActivity()).pushFragment(
                    WebViewFragment.instanciate("https://m.facebook.com/login/identify/?ctx=recover"));

        }
    });
    helpTextview = (TextView) v.findViewById(R.id.help_tv);
    helpTextview.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            ((Account) getActivity())
                    .pushFragment(WebViewFragment.instanciate("https://m.facebook.com/help/?refid=8"));
        }
    });
    return v;
}

From source file:com.zhangyp.higo.drawingboard.fragment.SketchFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mSketchView.setOnDrawChangedListener(this);

    stroke.setOnClickListener(new OnClickListener() {
        @Override/*from w w w  .j  a  v a2s .  c o  m*/
        public void onClick(View v) {

            if (mSketchView.getMode() == SketchView.STROKE) {
                showPopup(v, SketchView.STROKE);
            } else {
                mSketchView.setMode(SketchView.STROKE);
                setAlpha(eraser, 0.4f);
                setAlpha(stroke, 1f);
            }
        }
    });

    setAlpha(eraser, 0.4f);
    eraser.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mSketchView.getMode() == SketchView.ERASER) {
                showPopup(v, SketchView.ERASER);
            } else {
                mSketchView.setMode(SketchView.ERASER);
                setAlpha(stroke, 0.4f);
                setAlpha(eraser, 1f);
            }
        }
    });

    undo.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mSketchView.undo();
        }
    });

    redo.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mSketchView.redo();
        }
    });

    erase.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            askForErase();
        }

        private void askForErase() {
            new MaterialDialog.Builder(getActivity()).content("").positiveText("")
                    .callback(new MaterialDialog.ButtonCallback() {
                        @Override
                        public void onPositive(MaterialDialog dialog) {
                            mSketchView.erase();
                        }
                    }).build().show();
        }
    });

    sketchSave.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mSketchView.getPaths().size() == 0) {
                Toast.makeText(getActivity(), "", Toast.LENGTH_SHORT).show();
                return;
            }
            //?
            new MaterialDialog.Builder(getActivity()).title("?").content("")
                    .inputType(InputType.TYPE_CLASS_TEXT)
                    .input("??(.png)", "a.png", new MaterialDialog.InputCallback() {
                        @Override
                        public void onInput(MaterialDialog dialog, CharSequence input) {
                            // Do something
                            Log.i("AAA", input.toString());

                            save(input.toString());
                        }
                    }).show();

        }
    });
    sketchPhoto.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            //
            ImageConfig imageConfig = new ImageConfig.Builder(new ImageLoader() {
                @Override
                public void displayImage(Context context, String path, ImageView imageView) {
                    Glide.with(context).load(path)
                            .placeholder(com.yancy.imageselector.R.mipmap.imageselector_photo).centerCrop()
                            .into(imageView);
                }
            }).steepToolBarColor(getResources().getColor(R.color.blue))
                    .titleBgColor(getResources().getColor(R.color.blue))
                    .titleSubmitTextColor(getResources().getColor(R.color.white))
                    .titleTextColor(getResources().getColor(R.color.white))
                    //?
                    //                        .crop()
                    // ??   
                    .singleSelect()
                    // ?? 
                    .showCamera()
                    // ?? /temp/picture 
                    .filePath("/DrawingBoard/Pictures").build();

            ImageSelector.open(getActivity(), imageConfig); // ?
        }
    });

    // Inflate the popup_layout.xml
    LayoutInflater inflater = (LayoutInflater) getActivity()
            .getSystemService(ActionBarActivity.LAYOUT_INFLATER_SERVICE);
    popupLayout = inflater.inflate(R.layout.popup_sketch_stroke, null);
    // And the one for eraser
    LayoutInflater inflaterEraser = (LayoutInflater) getActivity()
            .getSystemService(ActionBarActivity.LAYOUT_INFLATER_SERVICE);
    popupEraserLayout = inflaterEraser.inflate(R.layout.popup_sketch_eraser, null);

    // Actual stroke shape size is retrieved
    strokeImageView = (ImageView) popupLayout.findViewById(R.id.stroke_circle);
    final Drawable circleDrawable = getResources().getDrawable(R.drawable.circle);
    size = circleDrawable.getIntrinsicWidth();
    // Actual eraser shape size is retrieved
    eraserImageView = (ImageView) popupEraserLayout.findViewById(R.id.stroke_circle);
    size = circleDrawable.getIntrinsicWidth();

    setSeekbarProgress(SketchView.DEFAULT_STROKE_SIZE, SketchView.STROKE);
    setSeekbarProgress(SketchView.DEFAULT_ERASER_SIZE, SketchView.ERASER);

    // Stroke color picker initialization and event managing
    mColorPicker = (ColorPicker) popupLayout.findViewById(R.id.stroke_color_picker);
    mColorPicker.addSVBar((SVBar) popupLayout.findViewById(R.id.svbar));
    mColorPicker.addOpacityBar((OpacityBar) popupLayout.findViewById(R.id.opacitybar));

    mColorPicker.setOnColorChangedListener(new ColorPicker.OnColorChangedListener() {
        @Override
        public void onColorChanged(int color) {
            mSketchView.setStrokeColor(color);
        }
    });
    mColorPicker.setColor(mSketchView.getStrokeColor());
    mColorPicker.setOldCenterColor(mSketchView.getStrokeColor());
}

From source file:nl.hnogames.domoticz.Welcome.SetupServerSettings.java

private void getLayoutReferences() {
    useSameAddress = (Switch) v.findViewById(R.id.localServer_switch);
    saveButton = (Button) v.findViewById(R.id.save_server);
    server_name_input = (FloatingLabelEditText) v.findViewById(R.id.server_name_input);
    remote_server_input = (FloatingLabelEditText) v.findViewById(R.id.remote_server_input);
    remote_port_input = (FloatingLabelEditText) v.findViewById(R.id.remote_port_input);
    remote_username_input = (FloatingLabelEditText) v.findViewById(R.id.remote_username_input);
    remote_password_input = (FloatingLabelEditText) v.findViewById(R.id.remote_password_input);
    remote_directory_input = (FloatingLabelEditText) v.findViewById(R.id.remote_directory_input);
    remote_protocol_spinner = (Spinner) v.findViewById(R.id.remote_protocol_spinner);
    local_server_input = (FloatingLabelEditText) v.findViewById(R.id.local_server_input);
    local_port_input = (FloatingLabelEditText) v.findViewById(R.id.local_port_input);
    local_username_input = (FloatingLabelEditText) v.findViewById(R.id.local_username_input);
    local_password_input = (FloatingLabelEditText) v.findViewById(R.id.local_password_input);
    local_directory_input = (FloatingLabelEditText) v.findViewById(R.id.local_directory_input);
    local_protocol_spinner = (Spinner) v.findViewById(R.id.local_protocol_spinner);
    local_wifi_spinner = (MultiSelectionSpinner) v.findViewById(R.id.local_wifi);
    cbShowPassword = (CheckBox) v.findViewById(R.id.showpassword);
    cbShowPasswordLocal = (CheckBox) v.findViewById(R.id.showpasswordlocal);

    startScreen_spinner = (Spinner) v.findViewById(R.id.startScreen_spinner);

    btnManualSSID = (Button) v.findViewById(R.id.set_ssid);
    btnManualSSID.setOnClickListener(new View.OnClickListener() {
        @Override/*from w w w. j  av a2  s .com*/
        public void onClick(View v) {
            new MaterialDialog.Builder(getContext()).title(R.string.welcome_ssid_button_prompt)
                    .content(R.string.welcome_msg_no_ssid_found)
                    .inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD)
                    .input(null, null, new MaterialDialog.InputCallback() {
                        @Override
                        public void onInput(MaterialDialog dialog, CharSequence input) {
                            Set<String> ssidFromPrefs = mServerUtil.getActiveServer().getLocalServerSsid();
                            final ArrayList<String> ssidListFromPrefs = new ArrayList<>();
                            if (ssidFromPrefs != null) {
                                if (ssidFromPrefs.size() > 0) {
                                    for (String wifi : ssidFromPrefs) {
                                        ssidListFromPrefs.add(wifi);
                                    }
                                }
                            }
                            ssidListFromPrefs.add(String.valueOf(input));
                            mServerUtil.getActiveServer().setLocalServerSsid(ssidListFromPrefs);

                            setSsid_spinner();
                        }
                    }).show();
        }
    });

    startScreen_spinner.setVisibility(View.GONE);
    v.findViewById(R.id.startScreen_title).setVisibility(View.GONE);
    v.findViewById(R.id.server_settings_title).setVisibility(View.GONE);

    useSameAddress.setChecked(false);
    final LinearLayout localServerSettingsLayout = (LinearLayout) v.findViewById(R.id.local_server_settings);
    localServer_switch = (Switch) v.findViewById(R.id.localServer_switch);
    localServer_switch.setChecked(false);//default setting
    localServer_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
            if (checked)
                localServerSettingsLayout.setVisibility(View.VISIBLE);
            else
                localServerSettingsLayout.setVisibility(View.GONE);
        }
    });

    final LinearLayout advancedSettings_layout = (LinearLayout) v.findViewById(R.id.advancedSettings_layout);
    advancedSettings_switch = (Switch) v.findViewById(R.id.advancedSettings_switch);
    advancedSettings_layout.setVisibility(View.INVISIBLE);
    advancedSettings_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mSharedPrefs.setAdvancedSettingsEnabled(isChecked);

            if (isChecked)
                advancedSettings_layout.setVisibility(View.VISIBLE);
            else
                advancedSettings_layout.setVisibility(View.GONE);
        }
    });
    advancedSettings_layout.setVisibility(View.GONE);
    advancedSettings_switch.setChecked(false);
    cbShowPassword.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (!isChecked) {
                remote_password_input.getInputWidget()
                        .setTransformationMethod(PasswordTransformationMethod.getInstance());
            } else {
                remote_password_input.getInputWidget()
                        .setTransformationMethod(HideReturnsTransformationMethod.getInstance());
            }
        }
    });
    cbShowPasswordLocal.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (!isChecked) {
                local_password_input.getInputWidget()
                        .setTransformationMethod(PasswordTransformationMethod.getInstance());
            } else {
                local_password_input.getInputWidget()
                        .setTransformationMethod(HideReturnsTransformationMethod.getInstance());
            }
        }
    });

    saveButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            checkConnectionData();
        }
    });
}

From source file:xyz.jamescarroll.genipass.MainActivity.java

private void toggleEditTextVisibility(int view) {
    if (mEditTextVisible) {
        ((EditText) findViewById(view)).setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
    } else {//from  ww w  . java  2 s . co  m
        ((EditText) findViewById(view))
                .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    }
}

From source file:arc.noaa.weather.activities.MainActivity.java

private void searchCities() {
    AlertDialog.Builder alert = new AlertDialog.Builder(this);
    alert.setTitle(this.getString(R.string.search_title));
    final EditText input = new EditText(this);
    input.setInputType(InputType.TYPE_CLASS_TEXT);
    input.setMaxLines(1);/*  w ww  .  j  a  v a2s . c  om*/
    input.setSingleLine(true);
    alert.setView(input, 32, 0, 32, 0);
    alert.setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            String result = input.getText().toString();
            if (!result.isEmpty()) {
                saveLocation(result);
            }
        }
    });
    alert.setNegativeButton(R.string.dialog_cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            // Cancelled
        }
    });
    alert.show();
}

From source file:com.example.run_tracker.ProfileFragment.java

@Override
public void onClick(View arg0) {
    Log.v(TAG, "click");
    AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());

    alert.setTitle("Enter Password");
    alert.setMessage("Please enter your password");

    // Set an EditText view to get user input
    final EditText input = new EditText(getActivity());
    input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    alert.setView(input);/*ww  w. ja  va 2  s. c o m*/

    alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            String password = input.getText().toString();
            String new_password = null;
            if (!mPassword1.getText().toString().equals(mPassword2.getText().toString())) {

                Toast.makeText(getActivity(), "Passwords dont match", Toast.LENGTH_LONG).show();
            } else {
                if (isEmpty(mPassword1) || (isEmpty(mPassword2))) {
                    new_password = password;
                } else {
                    new_password = mPassword1.getText().toString();
                }
                Make_edit_profile_request(password, new_password);
            }

        }
    });

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            // Canceled.
        }
    });

    alert.show();

}

From source file:tv.piratemedia.lightcontroler.controller.java

private void listWifiNetworks(final String[] Networks) {
    String[] ShowNetworks = new String[Networks.length - 4];
    for (int i = 2; i < Networks.length - 2; i++) {
        String[] NetworkInfo = Networks[i].split(",");
        ShowNetworks[i - 2] = NetworkInfo[1] + " - " + NetworkInfo[4] + "%";
    }/*from   w  ww  .  j  a v  a 2  s.  com*/

    // Set an EditText view to get user input
    final EditText input = new EditText(this);
    input.setHint("Password");
    input.setSingleLine(true);
    input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    final Context _this = this;
    new MaterialDialog.Builder(this).title("Controller Wifi Networks").theme(Theme.DARK).items(ShowNetworks)
            .itemsCallbackSingleChoice(-1, new MaterialDialog.ListCallbackSingleChoice() {
                @Override
                public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
                    final String[] NetworkInfo = Networks[which + 2].split(",");
                    if (NetworkInfo[3].equals("NONE")) {
                        Controller.setWifiNetwork(NetworkInfo[1]);
                    } else {
                        new MaterialDialog.Builder(_this).title("Password For: " + NetworkInfo[1])
                                .theme(Theme.DARK).customView(input, false)
                                .content("Please type the network password").positiveText("OK")
                                .negativeText("Cancel").onPositive(new MaterialDialog.SingleButtonCallback() {
                                    @Override
                                    public void onClick(@NonNull MaterialDialog dialog,
                                            @NonNull DialogAction which) {
                                        Controller.setWifiNetwork(NetworkInfo[1], "WPA2PSK", "AES",
                                                input.getText().toString());
                                    }
                                }).build().show();
                    }
                    return false;
                }
            }).positiveText("Select").negativeText("Cancel").build().show();
}