Search in sources :

Example 6 with Editable

use of android.text.Editable in project MaterialSearchView by MiguelCatalan.

the class MaterialSearchView method initSearchView.

private void initSearchView() {
    mSearchSrcTextView.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            onSubmitQuery();
            return true;
        }
    });
    mSearchSrcTextView.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            mUserQuery = s;
            startFilter(s);
            MaterialSearchView.this.onTextChanged(s);
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    mSearchSrcTextView.setOnFocusChangeListener(new OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                showKeyboard(mSearchSrcTextView);
                showSuggestions();
            }
        }
    });
}
Also used : KeyEvent(android.view.KeyEvent) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Example 7 with Editable

use of android.text.Editable in project CoCoin by Nightonke.

the class AccountBookSettingActivity method userRegister.

private void userRegister() {
    registerDialog = new MaterialDialog.Builder(this).title(R.string.go_register).typeface(CoCoinUtil.GetTypeface(), CoCoinUtil.GetTypeface()).customView(R.layout.dialog_user_register, true).build();
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
    registerDialogView = registerDialog.getCustomView();
    registerDialogButton = (CircularProgressButton) registerDialogView.findViewById(R.id.button);
    registerDialogButton.setTypeface(CoCoinUtil.GetTypeface());
    registerDialogButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            registerDialogButton.setProgress(1);
            registerDialog.setCancelable(false);
            // User register, a new user////////////////////////////////////////////////////////////////////////
            final User user = new User();
            // basic info
            user.setUsername(registerUserName.getText().toString());
            user.setPassword(registerPassword.getText().toString());
            user.setEmail(registerUserEmail.getText().toString());
            user.setAndroidId(CoCoinApplication.getAndroidId());
            if (BuildConfig.DEBUG)
                Log.d("CoCoin", "Android Id: " + user.getAndroidId());
            // settings info
            // user.setLogo();
            user.setIsMonthLimit(SettingManager.getInstance().getIsMonthLimit());
            user.setMonthLimit(SettingManager.getInstance().getMonthLimit());
            user.setIsColorRemind(SettingManager.getInstance().getIsColorRemind());
            user.setMonthWarning(SettingManager.getInstance().getMonthWarning());
            user.setRemindColor(SettingManager.getInstance().getRemindColor());
            user.setIsForbidden(SettingManager.getInstance().getIsForbidden());
            user.setAccountBookName(SettingManager.getInstance().getAccountBookName());
            user.setAccountBookPassword(SettingManager.getInstance().getPassword());
            // Todo store tag order
            user.setShowPicture(SettingManager.getInstance().getShowPicture());
            user.setIsHollow(SettingManager.getInstance().getIsHollow());
            user.setLogoObjectId("");
            user.signUp(CoCoinApplication.getAppContext(), new SaveListener() {

                @Override
                public void onSuccess() {
                    registerDialogButton.setProgress(0);
                    registerDialog.setCancelable(true);
                    registerDialogButton.setIdleText(getResourceString(R.string.register_complete));
                    // if register successfully/////////////////////////////////////////////////////////////////////////
                    SettingManager.getInstance().setLoggenOn(true);
                    SettingManager.getInstance().setUserName(registerUserName.getText().toString());
                    SettingManager.getInstance().setUserEmail(registerUserEmail.getText().toString());
                    SettingManager.getInstance().setUserPassword(registerPassword.getText().toString());
                    showToast(4, registerUserName.getText().toString());
                    // if login successfully////////////////////////////////////////////////////////////////////////////
                    user.login(CoCoinApplication.getAppContext(), new SaveListener() {

                        @Override
                        public void onSuccess() {
                            SettingManager.getInstance().setTodayViewInfoShouldChange(true);
                            updateViews();
                        // use a new method
                        //                                RecordManager.updateOldRecordsToServer();
                        }

                        @Override
                        public void onFailure(int code, String msg) {
                        // if login failed//////////////////////////////////////////////////////////////////////////////////
                        }
                    });
                    final Handler handler = new Handler();
                    handler.postDelayed(new Runnable() {

                        @Override
                        public void run() {
                            if (registerDialog != null)
                                registerDialog.dismiss();
                            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                            imm.toggleSoftInput(InputMethodManager.HIDE_NOT_ALWAYS, 0);
                        }
                    }, 500);
                }

                // if register failed///////////////////////////////////////////////////////////////////////////////
                @Override
                public void onFailure(int code, String msg) {
                    if (BuildConfig.DEBUG)
                        Log.d("CoCoin", "Register failed: " + msg);
                    String tip = getResourceString(R.string.network_disconnection);
                    if (msg.charAt(1) == 's')
                        tip = getResourceString(R.string.user_name_exist);
                    if (msg.charAt(0) == 'e')
                        tip = getResourceString(R.string.user_email_exist);
                    if (msg.charAt(1) == 'n')
                        tip = getResourceString(R.string.user_mobile_exist);
                    registerDialogButton.setIdleText(tip);
                    registerDialogButton.setProgress(0);
                    registerDialog.setCancelable(true);
                }
            });
        }
    });
    final MDButton positiveAction = registerDialog.getActionButton(DialogAction.POSITIVE);
    positiveAction.setEnabled(false);
    final EmailValidator emailValidator = new EmailValidator();
    TextView userNameTV = (TextView) registerDialog.getCustomView().findViewById(R.id.register_user_name_text);
    TextView userEmailTV = (TextView) registerDialog.getCustomView().findViewById(R.id.register_user_email_text);
    TextView userPasswordTV = (TextView) registerDialog.getCustomView().findViewById(R.id.register_password_text);
    userNameTV.setTypeface(CoCoinUtil.GetTypeface());
    userEmailTV.setTypeface(CoCoinUtil.GetTypeface());
    userPasswordTV.setTypeface(CoCoinUtil.GetTypeface());
    registerUserName = (MaterialEditText) registerDialog.getCustomView().findViewById(R.id.register_user_name);
    registerUserEmail = (MaterialEditText) registerDialog.getCustomView().findViewById(R.id.register_user_email);
    registerPassword = (MaterialEditText) registerDialog.getCustomView().findViewById(R.id.register_password);
    registerUserName.setTypeface(CoCoinUtil.GetTypeface());
    registerUserName.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            boolean emailOK = emailValidator.validate(registerUserEmail.getText().toString());
            registerDialogButton.setEnabled(0 < registerUserName.getText().toString().length() && registerUserName.getText().toString().length() <= 16 && registerPassword.getText().toString().length() > 0 && emailOK);
            if (emailValidator.validate(registerUserEmail.getText().toString())) {
                registerUserEmail.validate();
            } else {
                registerUserEmail.invalidate();
            }
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    registerUserEmail.setTypeface(CoCoinUtil.GetTypeface());
    registerUserEmail.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            boolean emailOK = emailValidator.validate(registerUserEmail.getText().toString());
            registerDialogButton.setEnabled(0 < registerUserName.getText().toString().length() && registerUserName.getText().toString().length() <= 16 && registerPassword.getText().toString().length() > 0 && emailOK);
            if (emailValidator.validate(registerUserEmail.getText().toString())) {
                registerUserEmail.validate();
            } else {
                registerUserEmail.invalidate();
            }
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    registerPassword.setTypeface(CoCoinUtil.GetTypeface());
    registerPassword.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            boolean emailOK = emailValidator.validate(registerUserEmail.getText().toString());
            registerDialogButton.setEnabled(0 < registerUserName.getText().toString().length() && registerUserName.getText().toString().length() <= 16 && registerPassword.getText().toString().length() > 0 && emailOK);
            if (emailValidator.validate(registerUserEmail.getText().toString())) {
                registerUserEmail.validate();
            } else {
                registerUserEmail.invalidate();
            }
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    registerDialog.show();
}
Also used : SaveListener(cn.bmob.v3.listener.SaveListener) MDButton(com.afollestad.materialdialogs.internal.MDButton) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) BmobUser(cn.bmob.v3.BmobUser) User(com.nightonke.saver.model.User) EmailValidator(com.nightonke.saver.util.EmailValidator) Handler(android.os.Handler) InputMethodManager(android.view.inputmethod.InputMethodManager) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) RiseNumberTextView(com.nightonke.saver.ui.RiseNumberTextView) View(android.view.View) TextView(android.widget.TextView) MaterialIconView(net.steamcrafted.materialiconlib.MaterialIconView) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) RiseNumberTextView(com.nightonke.saver.ui.RiseNumberTextView) TextView(android.widget.TextView)

Example 8 with Editable

use of android.text.Editable in project CoCoin by Nightonke.

the class AccountBookSettingActivity method userLogin.

private void userLogin() {
    loginDialog = new MaterialDialog.Builder(this).title(R.string.go_login).typeface(CoCoinUtil.GetTypeface(), CoCoinUtil.GetTypeface()).customView(R.layout.dialog_user_login, true).build();
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
    loginDialogView = loginDialog.getCustomView();
    loginDialogButton = (CircularProgressButton) loginDialogView.findViewById(R.id.button);
    loginDialogButton.isIndeterminateProgressMode();
    loginDialogButton.setProgress(0);
    loginDialogButton.setTypeface(CoCoinUtil.GetTypeface());
    loginDialogButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            loginDialog.setCancelable(false);
            loginDialogButton.setProgress(1);
            // the user ask to login////////////////////////////////////////////////////////////////////////////
            final User user = new User();
            user.setUsername(loginUserName.getText().toString());
            user.setPassword(loginPassword.getText().toString());
            user.login(CoCoinApplication.getAppContext(), new SaveListener() {

                // try with user name///////////////////////////////////////////////////////////////////////////////
                @Override
                public void onSuccess() {
                    loginDialog.setCancelable(true);
                    loginDialogButton.setProgress(0);
                    loginDialogButton.setIdleText(getResourceString(R.string.login_complete));
                    // login successfully through user name/////////////////////////////////////////////////////////////
                    SettingManager.getInstance().setTodayViewInfoShouldChange(true);
                    User loginUser = BmobUser.getCurrentUser(CoCoinApplication.getAppContext(), User.class);
                    if (!CoCoinApplication.getAndroidId().equals(loginUser.getAndroidId())) {
                        // 2 users on one mobile////////////////////////////////////////////////////////////////////////////
                        showToast(7, "unique...");
                        return;
                    }
                    SettingManager.getInstance().setLoggenOn(true);
                    SettingManager.getInstance().setUserName(loginUserName.getText().toString());
                    SettingManager.getInstance().setUserEmail(loginUser.getEmail());
                    updateViews();
                    // use a new method
                    //                        RecordManager.updateOldRecordsToServer();
                    whetherSyncSettingsFromServer();
                    showToast(6, loginUserName.getText().toString());
                    final Handler handler = new Handler();
                    handler.postDelayed(new Runnable() {

                        @Override
                        public void run() {
                            if (loginDialog != null)
                                loginDialog.dismiss();
                            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                            imm.toggleSoftInput(InputMethodManager.HIDE_NOT_ALWAYS, 0);
                        }
                    }, 500);
                }

                // login fail through user name/////////////////////////////////////////////////////////////////////
                @Override
                public void onFailure(int code, String msg) {
                    // try with user email//////////////////////////////////////////////////////////////////////////////
                    user.setEmail(loginUserName.getText().toString());
                    user.login(CoCoinApplication.getAppContext(), new SaveListener() {

                        @Override
                        public void onSuccess() {
                            loginDialog.setCancelable(true);
                            loginDialogButton.setProgress(0);
                            loginDialogButton.setIdleText(getResourceString(R.string.login_complete));
                            // login successfully through user email////////////////////////////////////////////////////////////
                            SettingManager.getInstance().setTodayViewInfoShouldChange(true);
                            User loginUser = BmobUser.getCurrentUser(CoCoinApplication.getAppContext(), User.class);
                            if (!CoCoinApplication.getAndroidId().equals(loginUser.getAndroidId())) {
                                // 2 users on one mobile////////////////////////////////////////////////////////////////////////////
                                showToast(7, "unique...");
                                return;
                            }
                            String userName = loginUser.getUsername();
                            SettingManager.getInstance().setLoggenOn(true);
                            SettingManager.getInstance().setUserName(userName);
                            SettingManager.getInstance().setUserEmail(loginUserName.getText().toString());
                            SettingManager.getInstance().setUserPassword(loginPassword.getText().toString());
                            updateViews();
                            // use a new method
                            //                                RecordManager.updateOldRecordsToServer();
                            whetherSyncSettingsFromServer();
                            showToast(6, userName);
                            final Handler handler = new Handler();
                            handler.postDelayed(new Runnable() {

                                @Override
                                public void run() {
                                    if (loginDialog != null)
                                        loginDialog.dismiss();
                                    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                                    imm.toggleSoftInput(InputMethodManager.HIDE_NOT_ALWAYS, 0);
                                }
                            }, 500);
                        }

                        // login fail through user name and email///////////////////////////////////////////////////////////
                        @Override
                        public void onFailure(int code, String msg) {
                            loginDialog.setCancelable(true);
                            loginDialogButton.setProgress(0);
                            String tip = getResourceString(R.string.network_disconnection);
                            if (msg.charAt(0) == 'u')
                                tip = getResourceString(R.string.user_name_or_password_incorrect);
                            if (msg.charAt(1) == 'n')
                                tip = getResourceString(R.string.user_mobile_exist);
                            loginDialogButton.setIdleText(tip);
                        }
                    });
                }
            });
        }
    });
    final MDButton positiveAction = loginDialog.getActionButton(DialogAction.POSITIVE);
    positiveAction.setEnabled(false);
    TextView userNameTV = (TextView) loginDialog.getCustomView().findViewById(R.id.login_user_name_text);
    TextView userPasswordTV = (TextView) loginDialog.getCustomView().findViewById(R.id.login_password_text);
    userNameTV.setTypeface(CoCoinUtil.GetTypeface());
    userPasswordTV.setTypeface(CoCoinUtil.GetTypeface());
    loginUserName = (MaterialEditText) loginDialog.getCustomView().findViewById(R.id.login_user_name);
    loginPassword = (MaterialEditText) loginDialog.getCustomView().findViewById(R.id.login_password);
    loginUserName.setTypeface(CoCoinUtil.GetTypeface());
    loginUserName.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            loginDialogButton.setEnabled(0 < loginUserName.getText().toString().length() && 0 < loginPassword.getText().toString().length());
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    loginPassword.setTypeface(CoCoinUtil.GetTypeface());
    loginPassword.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            loginDialogButton.setEnabled(0 < loginUserName.getText().toString().length() && 0 < loginPassword.getText().toString().length());
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    loginDialog.show();
}
Also used : SaveListener(cn.bmob.v3.listener.SaveListener) MDButton(com.afollestad.materialdialogs.internal.MDButton) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) BmobUser(cn.bmob.v3.BmobUser) User(com.nightonke.saver.model.User) Handler(android.os.Handler) InputMethodManager(android.view.inputmethod.InputMethodManager) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) RiseNumberTextView(com.nightonke.saver.ui.RiseNumberTextView) View(android.view.View) TextView(android.widget.TextView) MaterialIconView(net.steamcrafted.materialiconlib.MaterialIconView) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) RiseNumberTextView(com.nightonke.saver.ui.RiseNumberTextView) TextView(android.widget.TextView)

Example 9 with Editable

use of android.text.Editable in project CoCoin by Nightonke.

the class HelpFeedbackFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mScrollView = (ObservableScrollView) view.findViewById(R.id.scrollView);
    MaterialViewPagerHelper.registerScrollView(getActivity(), mScrollView, null);
    title = (TextView) view.findViewById(R.id.title);
    title.setTypeface(CoCoinUtil.getInstance().typefaceLatoLight);
    input = (EditText) view.findViewById(R.id.edittext);
    input.setTypeface(CoCoinUtil.getInstance().typefaceLatoLight);
    help = (TextView) view.findViewById(R.id.helper);
    help.setTypeface(CoCoinUtil.getInstance().typefaceLatoLight);
    number = (TextView) view.findViewById(R.id.number);
    number.setTypeface(CoCoinUtil.getInstance().typefaceLatoLight);
    send = (TextView) view.findViewById(R.id.send);
    send.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (exceed) {
                new MaterialDialog.Builder(mContext).title(R.string.help_feedback_dialog_title).content(R.string.help_feedback_dialog_content).positiveText(R.string.ok_1).show();
            } else {
                CoCoinUtil.getInstance().showToast(CoCoinApplication.getAppContext(), CoCoinApplication.getAppContext().getResources().getString(R.string.help_feedback_sent));
                Feedback feedback = new Feedback();
                feedback.setContent(input.getText().toString());
                feedback.save(CoCoinApplication.getAppContext(), new SaveListener() {

                    @Override
                    public void onSuccess() {
                        CoCoinUtil.getInstance().showToast(CoCoinApplication.getAppContext(), CoCoinApplication.getAppContext().getResources().getString(R.string.help_feedback_sent_successfully));
                    }

                    @Override
                    public void onFailure(int code, String arg0) {
                        CoCoinUtil.getInstance().showToast(CoCoinApplication.getAppContext(), CoCoinApplication.getAppContext().getResources().getString(R.string.help_feedback_sent_fail));
                    }
                });
            }
        }
    });
    input.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            setNumberText();
            try {
                ((OnTextChangeListener) activity).onTextChange(input.getText().toString(), exceed);
            } catch (ClassCastException cce) {
                cce.printStackTrace();
            }
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    send.requestFocus();
    setNumberText();
}
Also used : SaveListener(cn.bmob.v3.listener.SaveListener) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) TextView(android.widget.TextView) ObservableScrollView(com.github.ksoichiro.android.observablescrollview.ObservableScrollView) View(android.view.View) Feedback(com.nightonke.saver.model.Feedback) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable)

Example 10 with Editable

use of android.text.Editable in project Anki-Android by Ramblurr.

the class CardEditor method initFieldEditText.

private void initFieldEditText(FieldEditText editText, int index, String[] values, Typeface customTypeface) {
    String name = values[0];
    String content = values[1];
    if (mPrefFixArabic) {
        content = ArabicUtilities.reshapeSentence(content);
    }
    editText.init(index, name, content);
    if (customTypeface != null) {
        editText.setTypeface(customTypeface);
    }
    if (index == 0) {
        editText.addTextChangedListener(new TextWatcher() {

            @Override
            public void afterTextChanged(Editable arg0) {
                mTimerHandler.removeCallbacks(checkDuplicatesRunnable);
                mTimerHandler.postDelayed(checkDuplicatesRunnable, WAIT_TIME_UNTIL_UPDATE);
            }

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

            @Override
            public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
            }
        });
    }
}
Also used : TextWatcher(android.text.TextWatcher) Editable(android.text.Editable)

Aggregations

Editable (android.text.Editable)881 TextWatcher (android.text.TextWatcher)414 View (android.view.View)293 TextView (android.widget.TextView)217 EditText (android.widget.EditText)144 Paint (android.graphics.Paint)102 ImageView (android.widget.ImageView)94 Intent (android.content.Intent)81 AdapterView (android.widget.AdapterView)81 KeyEvent (android.view.KeyEvent)74 TextPaint (android.text.TextPaint)69 InputMethodManager (android.view.inputmethod.InputMethodManager)64 ListView (android.widget.ListView)64 DialogInterface (android.content.DialogInterface)57 SuppressLint (android.annotation.SuppressLint)56 Spannable (android.text.Spannable)51 AlertDialog (android.app.AlertDialog)46 RecyclerView (android.support.v7.widget.RecyclerView)45 ArrayList (java.util.ArrayList)43 Button (android.widget.Button)41