Search in sources :

Example 36 with AppCompatEditText

use of android.support.v7.widget.AppCompatEditText in project Roblu by wdavies973.

the class RMetricToUI method getTextfield.

/**
 * Gets the Textfield UI card from an RTextfield reference
 * @param textfield RTextfield reference to be set to the UI
 * @return a UI CardView
 */
public CardView getTextfield(final RTextfield textfield) {
    RelativeLayout layout = new RelativeLayout(activity);
    TextView textView = new TextView(activity);
    textView.setTextColor(rui.getText());
    textView.setText(textfield.getTitle());
    textView.setId(Utils.generateViewId());
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.BELOW, textView.getId());
    AppCompatEditText et = new AppCompatEditText(activity);
    Utils.setCursorColor(et, rui.getAccent());
    et.setText(textfield.getText());
    et.setEnabled(editable);
    et.setTextColor(rui.getText());
    if (textfield.isNumericalOnly())
        et.setInputType(InputType.TYPE_CLASS_NUMBER);
    if (textfield.isOneLine()) {
        et.setInputType(InputType.TYPE_CLASS_TEXT);
        et.setSingleLine();
        et.setMaxLines(1);
    }
    et.setHighlightColor(rui.getAccent());
    Drawable d = et.getBackground();
    d.setColorFilter(rui.getText(), PorterDuff.Mode.SRC_ATOP);
    et.setBackground(d);
    et.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            textfield.setText(charSequence.toString());
            listener.changeMade(textfield);
        }

        @Override
        public void afterTextChanged(Editable editable) {
        }
    });
    et.setSingleLine(false);
    et.setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION);
    et.setFocusableInTouchMode(true);
    et.setLayoutParams(params);
    layout.addView(textView);
    layout.addView(et);
    return getCard(layout);
}
Also used : AppCompatEditText(android.support.v7.widget.AppCompatEditText) RelativeLayout(android.widget.RelativeLayout) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextView(android.widget.TextView) Paint(android.graphics.Paint) Point(android.graphics.Point)

Example 37 with AppCompatEditText

use of android.support.v7.widget.AppCompatEditText in project Roblu by wdavies973.

the class Drawing method changeWidth.

private void changeWidth() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    final AppCompatEditText input = new AppCompatEditText(this);
    Utils.setInputTextLayoutColor(rui.getAccent(), null, input);
    input.setHighlightColor(rui.getAccent());
    input.setHintTextColor(rui.getText());
    input.setTextColor(rui.getText());
    input.setInputType(InputType.TYPE_CLASS_NUMBER);
    InputFilter[] FilterArray = new InputFilter[1];
    FilterArray[0] = new InputFilter.LengthFilter(30);
    input.setFilters(FilterArray);
    layout.addView(input);
    builder.setView(layout);
    builder.setPositiveButton("Set", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            canvas.setPaintStrokeWidth(Float.parseFloat(input.getText().toString()));
            dialog.dismiss();
        }
    });
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    TextView view = new TextView(this);
    view.setTextSize(Utils.DPToPX(getApplicationContext(), 5));
    view.setPadding(Utils.DPToPX(this, 18), Utils.DPToPX(this, 18), Utils.DPToPX(this, 18), Utils.DPToPX(this, 18));
    view.setText(R.string.set_line_width);
    view.setTextColor(rui.getText());
    AlertDialog dialog = builder.create();
    dialog.setCustomTitle(view);
    if (dialog.getWindow() != null) {
        dialog.getWindow().getAttributes().windowAnimations = rui.getDialogDirection();
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(rui.getBackground()));
    }
    dialog.show();
    dialog.getButton(Dialog.BUTTON_NEGATIVE).setTextColor(rui.getAccent());
    dialog.getButton(Dialog.BUTTON_POSITIVE).setTextColor(rui.getAccent());
}
Also used : AlertDialog(android.app.AlertDialog) InputFilter(android.text.InputFilter) DialogInterface(android.content.DialogInterface) AppCompatEditText(android.support.v7.widget.AppCompatEditText) ColorDrawable(android.graphics.drawable.ColorDrawable) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Example 38 with AppCompatEditText

use of android.support.v7.widget.AppCompatEditText in project Roblu by wdavies973.

the class TeamsView method showTeamCreateDialog.

/**
 * Shows the team create dialog where the user can manually create a team
 */
private void showTeamCreateDialog() {
    if (eventDrawerManager.getEvent() == null)
        return;
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    final AppCompatEditText input = new AppCompatEditText(this);
    Utils.setInputTextLayoutColor(settings.getRui().getAccent(), null, input);
    input.setHighlightColor(settings.getRui().getAccent());
    input.setHintTextColor(settings.getRui().getText());
    input.setTextColor(settings.getRui().getText());
    input.setInputType(InputType.TYPE_CLASS_TEXT);
    input.setHint("Team name");
    InputFilter[] FilterArray = new InputFilter[1];
    FilterArray[0] = new InputFilter.LengthFilter(30);
    input.setFilters(FilterArray);
    layout.addView(input);
    final AppCompatEditText input2 = new AppCompatEditText(this);
    Utils.setInputTextLayoutColor(settings.getRui().getAccent(), null, input2);
    input2.setHighlightColor(settings.getRui().getAccent());
    input2.setHintTextColor(settings.getRui().getText());
    input2.setTextColor(settings.getRui().getText());
    input2.setInputType(InputType.TYPE_CLASS_NUMBER);
    input2.setHint("Team number");
    InputFilter[] FilterArray2 = new InputFilter[1];
    FilterArray2[0] = new InputFilter.LengthFilter(6);
    input2.setFilters(FilterArray2);
    layout.addView(input2);
    builder.setView(layout);
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (input2.getText().toString().equals(""))
                input2.setText("0");
            RTeam team = new RTeam(input.getText().toString(), Integer.parseInt(input2.getText().toString()), io.getNewTeamID(eventDrawerManager.getEvent().getID()));
            /*
                 * Package for cloud
                 */
            if (eventDrawerManager.getEvent() != null && eventDrawerManager.getEvent().isCloudEnabled()) {
                team.verify(io.loadForm(eventDrawerManager.getEvent().getID()));
                RCheckout checkout = new RCheckout(team);
                checkout.setStatus(0);
                io.savePendingCheckout(checkout);
            }
            io.saveTeam(eventDrawerManager.getEvent().getID(), team);
            executeLoadTeamsTask(lastFilter, true);
        }
    });
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    TextView view = new TextView(this);
    view.setTextSize(Utils.DPToPX(getApplicationContext(), 5));
    view.setPadding(Utils.DPToPX(this, 18), Utils.DPToPX(this, 18), Utils.DPToPX(this, 18), Utils.DPToPX(this, 18));
    view.setText(R.string.create_team);
    view.setTextColor(settings.getRui().getText());
    AlertDialog dialog = builder.create();
    dialog.setCustomTitle(view);
    if (dialog.getWindow() != null) {
        dialog.getWindow().getAttributes().windowAnimations = settings.getRui().getAnimation();
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(settings.getRui().getBackground()));
    }
    dialog.show();
    dialog.getButton(Dialog.BUTTON_NEGATIVE).setTextColor(settings.getRui().getAccent());
    dialog.getButton(Dialog.BUTTON_POSITIVE).setTextColor(settings.getRui().getAccent());
}
Also used : AlertDialog(android.app.AlertDialog) InputFilter(android.text.InputFilter) RTeam(com.cpjd.roblu.models.RTeam) DialogInterface(android.content.DialogInterface) AppCompatEditText(android.support.v7.widget.AppCompatEditText) ColorDrawable(android.graphics.drawable.ColorDrawable) RCheckout(com.cpjd.roblu.models.RCheckout) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Example 39 with AppCompatEditText

use of android.support.v7.widget.AppCompatEditText in project 91Pop by DanteAndroid.

the class ProxySettingActivity method onClick.

@Override
public void onClick(View v) {
    switch(v.getId()) {
        case R.id.bt_proxy_setting_test:
            if (presenter.isSetPorn91VideoAddress()) {
                Logger.t(TAG).d("木有设置地址呀");
                showNeedSetAddressFirstDialog();
                return;
            }
            isTestSuccess = false;
            String proxyIpAddress = etDialogProxySettingIpAddress.getIpAddressStr();
            String portStr = etDialogProxySettingPort.getText().toString().trim();
            if (TextUtils.isEmpty(portStr) || TextUtils.isEmpty(proxyIpAddress) || !TextUtils.isDigitsOnly(portStr)) {
                showMessage("端口号或IP地址不正确", TastyToast.WARNING);
                return;
            }
            int proxyPort = Integer.parseInt(portStr);
            presenter.testProxy(proxyIpAddress, proxyPort);
            QMUIKeyboardHelper.hideKeyboard(v);
            break;
        case R.id.bt_proxy_setting_reset:
            etDialogProxySettingIpAddress.setIpAddressStr("");
            etDialogProxySettingPort.setText("");
            View view = getCurrentFocus();
            if (view instanceof AppCompatEditText || view instanceof EditText) {
                QMUIKeyboardHelper.showKeyboard((EditText) view, QMUIKeyboardHelper.SHOW_KEYBOARD_DELAY_TIME);
            }
            break;
        default:
    }
}
Also used : IpInputEditText(com.dante.widget.IpInputEditText) AppCompatEditText(android.support.v7.widget.AppCompatEditText) EditText(android.widget.EditText) AppCompatEditText(android.support.v7.widget.AppCompatEditText) BindView(butterknife.BindView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Example 40 with AppCompatEditText

use of android.support.v7.widget.AppCompatEditText in project Rashr by DsLNeXuS.

the class BackupActivity method showPopup.

public void showPopup(final View v, final File file) {
    PopupMenu popup = new PopupMenu(mActivity, v);
    popup.getMenuInflater().inflate(R.menu.bakmgr_menu, popup.getMenu());
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(final MenuItem menuItem) {
            final AppCompatDialog dialog = new AppCompatDialog(mActivity);
            dialog.setTitle(R.string.setname);
            dialog.setContentView(R.layout.dialog_input);
            final AppCompatButton bGo = dialog.findViewById(R.id.bGoBackup);
            final AppCompatEditText etFileName = dialog.findViewById(R.id.etFileName);
            if (bGo == null || etFileName == null)
                return false;
            // If current item is 0 (first item) a recovery backup will be edited or created
            final File path = mPager.getCurrentItem() == 0 ? App.PathToRecoveryBackups : App.PathToKernelBackups;
            try {
                switch(menuItem.getItemId()) {
                    case R.id.iRestore:
                        FlashUtil RestoreUtil = new FlashUtil(mActivity, file, mPager.getCurrentItem() == 0 ? FlashUtil.JOB_RESTORE_RECOVERY : FlashUtil.JOB_RESTORE_KERNEL);
                        RestoreUtil.execute();
                        return true;
                    case R.id.iRename:
                        etFileName.setHint(file.getName());
                        bGo.setOnClickListener(new View.OnClickListener() {

                            @Override
                            public void onClick(View v) {
                                String Name;
                                if (etFileName.getText() != null && etFileName.isEnabled() && !etFileName.getText().toString().equals("")) {
                                    // User has defined a name for the backup. Use it.
                                    Name = etFileName.getText().toString();
                                } else {
                                    // Use hint as backup name. Normally the correct version
                                    // and Recovery System (if Rashr could read it out of
                                    // "/cache/recovery/last_log"
                                    Name = String.valueOf(etFileName.getHint());
                                }
                                if (!Name.endsWith(App.Device.getRecoveryExt())) {
                                    // Append extension
                                    Name += App.Device.getRecoveryExt();
                                }
                                File renamedBackup = new File(path, Name);
                                if (renamedBackup.exists()) {
                                    Toast.makeText(mActivity, R.string.backupalready, Toast.LENGTH_SHORT).show();
                                    // if backup already exists, let the user chose a new name
                                    onMenuItemClick(menuItem);
                                } else {
                                    if (file.renameTo(renamedBackup)) {
                                        mAdapter.loadBackups();
                                    } else {
                                        Toast.makeText(mActivity, R.string.rename_failed, Toast.LENGTH_SHORT).show();
                                    }
                                }
                                dialog.dismiss();
                            }
                        });
                        dialog.show();
                        return true;
                    case R.id.iDeleteBackup:
                        if (file.delete()) {
                            Toast.makeText(mActivity, mContext.getString(R.string.bak_deleted), Toast.LENGTH_SHORT).show();
                        }
                        mAdapter.loadBackups();
                        return true;
                    default:
                        return false;
                }
            } catch (Exception e) {
                if (e.getMessage().contains("EINVAL") && file.getName().contains(":")) {
                    AlertDialog.Builder adialog = new AlertDialog.Builder(mContext);
                    adialog.setMessage(R.string.check_name);
                    adialog.setMessage(R.string.ok);
                    adialog.show();
                }
                App.ERRORS.add(App.TAG + " " + e);
                return false;
            }
        }
    });
    popup.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) MenuItem(android.view.MenuItem) BindView(butterknife.BindView) View(android.view.View) AppCompatTextView(android.support.v7.widget.AppCompatTextView) RecyclerView(android.support.v7.widget.RecyclerView) AppCompatButton(android.support.v7.widget.AppCompatButton) AppCompatEditText(android.support.v7.widget.AppCompatEditText) AppCompatDialog(android.support.v7.app.AppCompatDialog) File(java.io.File) PopupMenu(android.support.v7.widget.PopupMenu)

Aggregations

AppCompatEditText (android.support.v7.widget.AppCompatEditText)37 View (android.view.View)20 DialogInterface (android.content.DialogInterface)16 AlertDialog (android.support.v7.app.AlertDialog)13 TextView (android.widget.TextView)11 Editable (android.text.Editable)10 AppCompatButton (android.support.v7.widget.AppCompatButton)8 TextWatcher (android.text.TextWatcher)7 LinearLayout (android.widget.LinearLayout)7 File (java.io.File)7 Context (android.content.Context)6 TextInputLayout (android.support.design.widget.TextInputLayout)6 AppCompatCheckBox (android.support.v7.widget.AppCompatCheckBox)6 AppCompatTextView (android.support.v7.widget.AppCompatTextView)6 ColorDrawable (android.graphics.drawable.ColorDrawable)5 AdapterView (android.widget.AdapterView)5 SuppressLint (android.annotation.SuppressLint)4 AppCompatDialog (android.support.v7.app.AppCompatDialog)4 RelativeLayout (android.widget.RelativeLayout)4 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)4