Java Code Examples for android.widget.EditText#setOnTouchListener()

The following examples show how to use android.widget.EditText#setOnTouchListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SearchActivity.java    From QuickNews with MIT License 6 votes vote down vote up
private void initView(){
    mIvBack= (ImageView) findViewById(R.id.ivBack);
    mEtInput= (EditText) findViewById(R.id.etInput);
    mIvClear= (ImageView) findViewById(R.id.ivClearText);
    mTvSearch= (TextView) findViewById(R.id.tvSearchEnsure);
    mLvSearchResult= (ListView) findViewById(R.id.lvSearchResult);
    mProgressBar= (ProgressBar) findViewById(R.id.pbSearchProgress);

    mTvSearch.setClickable(true);
    mTvSearch.setOnClickListener(this);
    mIvClear.setOnClickListener(this);
    mIvBack.setOnClickListener(this);

    mEtInput.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            mEtInput.setFocusable(true);
            mEtInput.setFocusableInTouchMode(true);
            mEtInput.requestFocus();
            return false;
        }
    });
}
 
Example 2
Source File: Pinview.java    From Pinview with MIT License 5 votes vote down vote up
/**
 * Takes care of styling the editText passed in the param.
 * tag is the index of the editText.
 *
 * @param styleEditText
 * @param tag
 */
private void generateOneEditText(EditText styleEditText, String tag) {
    params.setMargins(mSplitWidth / 2, mSplitWidth / 2, mSplitWidth / 2, mSplitWidth / 2);
    filters[0] = new InputFilter.LengthFilter(1);
    styleEditText.setFilters(filters);
    styleEditText.setLayoutParams(params);
    styleEditText.setGravity(Gravity.CENTER);
    styleEditText.setCursorVisible(mCursorVisible);

    if (!mCursorVisible) {
        styleEditText.setClickable(false);
        styleEditText.setHint(mHint);

        styleEditText.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                // When back space is pressed it goes to delete mode and when u click on an edit Text it should get out of the delete mode
                mDelPressed = false;
                return false;
            }
        });
    }
    styleEditText.setBackgroundResource(mPinBackground);
    styleEditText.setPadding(0, 0, 0, 0);
    styleEditText.setTag(tag);
    styleEditText.setInputType(getKeyboardInputType());
    styleEditText.addTextChangedListener(this);
    styleEditText.setOnFocusChangeListener(this);
    styleEditText.setOnKeyListener(this);
}
 
Example 3
Source File: LockActivity.java    From AppLocker with Apache License 2.0 5 votes vote down vote up
protected void setupEditText(EditText editText) {
	editText.setInputType(InputType.TYPE_NULL);
	editText.setFilters(filters);
	editText.setOnTouchListener(touchListener);
	editText.setTransformationMethod(PasswordTransformationMethod
			.getInstance());
}
 
Example 4
Source File: LabelDetailsFragment.java    From science-journal with Apache License 2.0 5 votes vote down vote up
protected void setupCaption(View rootView) {
  caption = (EditText) rootView.findViewById(R.id.caption);
  caption.setText(originalLabel.getCaptionText());
  caption.setImeOptions(EditorInfo.IME_ACTION_DONE);
  caption.setRawInputType(InputType.TYPE_CLASS_TEXT);
  caption.setOnEditorActionListener(
      (textView, i, keyEvent) -> {
        if (i == EditorInfo.IME_ACTION_DONE) {
          caption.clearFocus();
          caption.setFocusable(false);
        }
        return false;
      });
  caption.setOnTouchListener(
      (v, motionEvent) -> {
        caption.setFocusableInTouchMode(true);
        caption.requestFocus();
        return false;
      });

  caption.setEnabled(false);
  experiment
      .firstElement()
      .subscribe(
          experiment -> {
            caption.setEnabled(true);
            // Move the cursor to the end
            caption.post(() -> caption.setSelection(caption.getText().toString().length()));

            saved
                .happens()
                .subscribe(o -> saveCaptionChanges(experiment, caption.getText().toString()));
          });
}
 
Example 5
Source File: LockActivity.java    From AppLocker with Apache License 2.0 5 votes vote down vote up
protected void setupEditText(EditText editText) {
	editText.setInputType(InputType.TYPE_NULL);
	editText.setFilters(filters);
	editText.setOnTouchListener(touchListener);
	editText.setTransformationMethod(PasswordTransformationMethod
			.getInstance());
}
 
Example 6
Source File: SecKeyboardView.java    From AndroidSecurityKeyboard with Apache License 2.0 5 votes vote down vote up
public SecKeyboardView(Activity act, final EditText editText, KeyboardView keyboardView) {

        Activity activity = act;
        this.ed = editText;
        this.mKeyboardView = keyboardView;

        alphabetKeyBoard = new Keyboard(activity, R.xml.qwerty);
        numberKeyBoard = new Keyboard(activity, R.xml.number);
        symbolKeyBoard = new Keyboard(activity, R.xml.symbols);

        mImm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);

        mKeyboardView.setKeyboard(alphabetKeyBoard);
        mKeyboardView.setEnabled(true);
        mKeyboardView.setPreviewEnabled(false);
        mKeyboardView.setOnKeyboardActionListener(listener);

        editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View view, boolean b) {
                if (!b) {
                    hideKeyboard();
                } else {
                    mImm.hideSoftInputFromWindow(view.getWindowToken(), 0); //强制隐藏键盘
                }
            }
        });
        editText.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                int inputType = editText.getInputType();
                hideSoftInputMethod(editText);
                showKeyboard();
                editText.setInputType(inputType);
                return false;
            }
        });
    }
 
Example 7
Source File: EntryKeyboardView.java    From bither-android with Apache License 2.0 5 votes vote down vote up
public EntryKeyboardView registerEditText(EditText... ets) {
    for (EditText et : ets) {
        et.setOnFocusChangeListener(this);
        et.setOnClickListener(this);
        et.setOnTouchListener(this);
    }
    return this;
}
 
Example 8
Source File: AddUrlDialog.java    From dttv-android with GNU General Public License v3.0 5 votes vote down vote up
private void findView() {
    ed_coupon_no=(EditText) findViewById(R.id.ed_coupon_no);
    dialog_button_ok=(Button) findViewById(R.id.dialog_button_ok);
    dialog_button_sdp = (Button)findViewById(R.id.dialog_button_sdp);
    ed_coupon_no.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return false;
        }
    });

}
 
Example 9
Source File: ControlHelper.java    From android_maplibui with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void setClearAction(final EditText target)
{
    target.setOnTouchListener(new View.OnTouchListener()
    {
        final int RIGHT = 2;

        @Override
        public boolean onTouch(
                View view,
                MotionEvent event)
        {
            if (event.getAction() == MotionEvent.ACTION_UP) {
                int leftEdgeOfRightDrawable =
                        view.getRight() - target.getCompoundDrawables()[RIGHT].getBounds()
                                .width();
                // when EditBox has padding, adjust leftEdge like
                // leftEdgeOfRightDrawable -= getResources().getDimension(R.dimen.edittext_padding_left_right);
                if (event.getRawX() >= leftEdgeOfRightDrawable) {
                    // clicked on clear icon
                    target.setText("");
                    target.clearFocus();
                    return false;
                }
            }
            return false;
        }
    });
}
 
Example 10
Source File: AppLockActivity.java    From AppLock with Apache License 2.0 5 votes vote down vote up
protected void setupEditText(EditText editText) {
	editText.setInputType(InputType.TYPE_NULL);
	editText.setFilters(filters);
	editText.setOnTouchListener(touchListener);
	editText.setTransformationMethod(PasswordTransformationMethod
			.getInstance());
}
 
Example 11
Source File: EditDirectMessageActivity.java    From YiBo with Apache License 2.0 5 votes vote down vote up
private void bindEvent() {
	Button btnBack = (Button) this.findViewById(R.id.btnBack);
	btnBack.setOnClickListener(new GoBackClickListener());

	Button btnSend = (Button) this.findViewById(R.id.btnOperate);
	btnSend.setText(R.string.label_send);
	btnSend.setVisibility(View.VISIBLE);
	btnSend.setOnClickListener(new EditDirectMessageSendClickListener(this));

	Button btnUserSelector = (Button) this.findViewById(R.id.btnUserSelector);
	//btnUserSelector.setOnClickListener(new EditDirectMessageUserSelectorClickListener(this));
	EditMicroBlogMentionClickListener userSelectorListener = new EditMicroBlogMentionClickListener();
	userSelectorListener.setRequestCode(Constants.REQUEST_CODE_USER_SELECTOR_MESSAGE);
	userSelectorListener.setSelectMode(SelectMode.Single);
	userSelectorListener.setTitleId(R.string.title_select_recipient);
	btnUserSelector.setOnClickListener(userSelectorListener);

	EditText etText = (EditText) this.findViewById(R.id.etText);
	etText.addTextChangedListener(new MicroBlogTextWatcher(this));
	etText.setOnTouchListener(hideEmotionGridListener);

	Button btnTopic = (Button) this.findViewById(R.id.btnTopic);
	btnTopic.setOnClickListener(new EditMicroBlogTopicClickListener(this));

	Button btnEmotion = (Button) this.findViewById(R.id.btnEmotion);
	btnEmotion.setOnClickListener(new EditMicroBlogEmotionClickListener(this));

    Button btnMention = (Button) this.findViewById(R.id.btnMention);
    btnMention.setOnClickListener(new EditMicroBlogMentionClickListener());

    Button btnTextCount = (Button) this.findViewById(R.id.btnTextCount);
    btnTextCount.setOnClickListener(new EditMicroBlogTextDeleteClickListener(this));
}
 
Example 12
Source File: AbstractPasscodeKeyboardActivity.java    From narrate-android with Apache License 2.0 4 votes vote down vote up
protected void setupPinItem(EditText item){
    item.setInputType(InputType.TYPE_NULL);
    item.setFilters(filters);
    item.setOnTouchListener(otl);
    item.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
 
Example 13
Source File: AuthenticatorActivity.java    From Cirrus_depricated with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 
 * @param savedInstanceState        Saved activity state, as in {{@link #onCreate(Bundle)}
 */
private void initAuthorizationPreFragment(Bundle savedInstanceState) {
    
    /// step 0 - get UI elements in layout
    mOAuth2Check = (CheckBox) findViewById(R.id.oauth_onOff_check);
    mOAuthAuthEndpointText = (TextView)findViewById(R.id.oAuthEntryPoint_1);
    mOAuthTokenEndpointText = (TextView)findViewById(R.id.oAuthEntryPoint_2);
    mUsernameInput = (EditText) findViewById(R.id.account_username);
    mPasswordInput = (EditText) findViewById(R.id.account_password);
    mPasswordInput.setTypeface(mUsernameInput.getTypeface());
    mAuthStatusView = (TextView) findViewById(R.id.auth_status_text); 
    
    /// step 1 - load and process relevant inputs (resources, intent, savedInstanceState)
    String presetUserName = null;
    boolean isPasswordExposed = false;
    if (savedInstanceState == null) {
        if (mAccount != null) {
            presetUserName = mAccount.name.substring(0, mAccount.name.lastIndexOf('@'));
        }
        
    } else {
        isPasswordExposed = savedInstanceState.getBoolean(KEY_PASSWORD_EXPOSED, false);
        mAuthStatusText = savedInstanceState.getInt(KEY_AUTH_STATUS_TEXT);
        mAuthStatusIcon = savedInstanceState.getInt(KEY_AUTH_STATUS_ICON);
        mAuthToken = savedInstanceState.getString(KEY_AUTH_TOKEN);
    }
    
    /// step 2 - set properties of UI elements (text, visibility, enabled...)
    mOAuth2Check.setChecked(
            AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType())
                .equals(mAuthTokenType));
    if (presetUserName != null) {
        mUsernameInput.setText(presetUserName);
    }
    if (mAction != ACTION_CREATE) {
        mUsernameInput.setEnabled(false);
        mUsernameInput.setFocusable(false);
    }
    mPasswordInput.setText(""); // clean password to avoid social hacking
    if (isPasswordExposed) {
        showPassword();
    }
    updateAuthenticationPreFragmentVisibility();
    showAuthStatus();
    mOkButton.setEnabled(mServerIsValid);

    
    /// step 3 - bind listeners
    // bindings for password input field
    mPasswordInput.setOnFocusChangeListener(this);
    mPasswordInput.setImeOptions(EditorInfo.IME_ACTION_DONE);
    mPasswordInput.setOnEditorActionListener(this);
    mPasswordInput.setOnTouchListener(new RightDrawableOnTouchListener() {
        @Override
        public boolean onDrawableTouch(final MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
                AuthenticatorActivity.this.onViewPasswordClick();
            }
            return true;
        }
    });
    
}
 
Example 14
Source File: LoginDialogFragment.java    From openshop.io-android with MIT License 4 votes vote down vote up
private void prepareInputBoxes(View view) {
    // Registration form
    loginRegistrationEmailWrapper = view.findViewById(R.id.login_registration_email_wrapper);
    loginRegistrationPasswordWrapper = view.findViewById(R.id.login_registration_password_wrapper);
    loginRegistrationGenderWoman = view.findViewById(R.id.login_registration_sex_woman);
    EditText registrationPassword = loginRegistrationPasswordWrapper.getEditText();
    if (registrationPassword != null) {
        registrationPassword.setOnTouchListener(new OnTouchPasswordListener(registrationPassword));
    }


    // Login email form
    loginEmailEmailWrapper = view.findViewById(R.id.login_email_email_wrapper);
    EditText loginEmail = loginEmailEmailWrapper.getEditText();
    if (loginEmail != null) loginEmail.setText(SettingsMy.getUserEmailHint());
    loginEmailPasswordWrapper = view.findViewById(R.id.login_email_password_wrapper);
    EditText emailPassword = loginEmailPasswordWrapper.getEditText();
    if (emailPassword != null) {
        emailPassword.setOnTouchListener(new OnTouchPasswordListener(emailPassword));
        emailPassword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_SEND || actionId == 124) {
                    invokeLoginWithEmail();
                    return true;
                }
                return false;
            }
        });
    }

    loginEmailForgottenEmailWrapper = view.findViewById(R.id.login_email_forgotten_email_wrapper);
    EditText emailForgottenPassword = loginEmailForgottenEmailWrapper.getEditText();
    if (emailForgottenPassword != null)
        emailForgottenPassword.setText(SettingsMy.getUserEmailHint());

    // Simple accounts whisperer.
    Account[] accounts = AccountManager.get(getActivity()).getAccounts();
    String[] addresses = new String[accounts.length];
    for (int i = 0; i < accounts.length; i++) {
        addresses[i] = accounts[i].name;
        Timber.e("Sets autocompleteEmails: %s", accounts[i].name);
    }

    ArrayAdapter<String> emails = new ArrayAdapter<>(getActivity(), android.R.layout.simple_dropdown_item_1line, addresses);
    AutoCompleteTextView textView = view.findViewById(R.id.login_registration_email_text_auto);
    textView.setAdapter(emails);
}
 
Example 15
Source File: AbstractPasscodeKeyboardActivity.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
protected void setupPinItem(EditText item){
    item.setInputType(InputType.TYPE_NULL); 
    item.setFilters(filters); 
    item.setOnTouchListener(otl);
    item.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
 
Example 16
Source File: AbstractPasscodeKeyboardActivity.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
protected void setupPinItem(EditText item){
    item.setInputType(InputType.TYPE_NULL); 
    item.setFilters(filters); 
    item.setOnTouchListener(otl);
    item.setTransformationMethod(PasswordTransformationMethod.getInstance());
}