android.text.InputType Java Examples

The following examples show how to use android.text.InputType. 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: GridPasswordView.java    From AndroidFrame with Apache License 2.0 6 votes vote down vote up
@Override
public void setPasswordType(PasswordType passwordType) {
    boolean visible = getPassWordVisibility();
    int inputType = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD;
    switch (passwordType) {

        case TEXT:
            inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
            break;

        case TEXTVISIBLE:
            inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
            break;

        case TEXTWEB:
            inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD;
            break;
    }

    for (TextView textView : mViewArr)
        textView.setInputType(inputType);

    setPasswordVisibility(visible);
}
 
Example #2
Source File: RegisterActivity.java    From Gizwits-SmartSocket_Android with MIT License 6 votes vote down vote up
/**
 * Inits the events.
 */
private void initEvents() {
	btnGetCaptchaCode.setOnClickListener(this);
	//
	btnGetCode.setOnClickListener(this);
	btnReGetCode.setOnClickListener(this);
	btnSure.setOnClickListener(this);
	tvPhoneSwitch.setOnClickListener(this);
	ivBack.setOnClickListener(this);
	tbPswFlag.setOnCheckedChangeListener(new OnCheckedChangeListener() {

		@Override
		public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
			if (isChecked) {
				etInputPsw.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
			} else {
				etInputPsw.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
			}

		}

	});
}
 
Example #3
Source File: ForgetPswActivity.java    From Gizwits-SmartSocket_Android with MIT License 6 votes vote down vote up
/**
 * Inits the events.
 */
private void initEvents() {
	btnReGetCaptchaCode_farget.setOnClickListener(this);
	//
	rlDialog.setOnClickListener(this);
	btnGetCode.setOnClickListener(this);
	btnReGetCode.setOnClickListener(this);
	btnSureEmail.setOnClickListener(this);
	btnSure.setOnClickListener(this);
	btnPhoneReset.setOnClickListener(this);
	btnEmailReset.setOnClickListener(this);
	// tvPhoneSwitch.setOnClickListener(this);
	ivBack.setOnClickListener(this);
	tbPswFlag.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

		@Override
		public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
			if (isChecked) {
				etInputPsw.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
			} else {
				etInputPsw.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
			}
		}

	});
}
 
Example #4
Source File: NumberPicker.java    From ticdesign with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the values to be displayed.
 *
 * @param displayedValues The displayed values.
 *
 * <strong>Note:</strong> The length of the displayed values array
 * must be equal to the range of selectable numbers which is equal to
 * {@link #getMaxValue()} - {@link #getMinValue()} + 1.
 */
public void setDisplayedValues(String[] displayedValues) {
    if (mDisplayedValues == displayedValues) {
        return;
    }
    mDisplayedValues = displayedValues;
    if (mDisplayedValues != null) {
        // Allow text entry rather than strictly numeric entry.
        mInputText.setRawInputType(InputType.TYPE_CLASS_TEXT
                | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    } else {
        mInputText.setRawInputType(InputType.TYPE_CLASS_NUMBER);
    }
    updateInputTextView();
    initializeSelectorWheelIndices();
    tryComputeMaxWidth();
}
 
Example #5
Source File: UserTextDialog.java    From Android-Application-ZJB with Apache License 2.0 6 votes vote down vote up
/**
 * 根据 hint 来判断 type
 */
private void initHint() {
    if ("请输入QQ号".equals(hintTextStr)) {
        dialogType = TYPE_QQ;
        setMaxLength(18);
        mEditText.setInputType(InputType.TYPE_CLASS_NUMBER);
    } else if ("请输入手机号".equals(hintTextStr)) {
        dialogType = TYPE_PHONE;
        setMaxLength(11);
        mEditText.setInputType(InputType.TYPE_CLASS_NUMBER);
    } else if ("请输入常去考场".equals(hintTextStr) || "请输入常练车地址".equals(hintTextStr)) {
        setMaxLength(28);
    } else {
        setMaxLength(23);
    }
    mEditText.setHint(hintTextStr);
    mEditText.setText(realTextStr);
    mEditText.setSelection(realTextStr.length());
}
 
Example #6
Source File: ModuleActivity.java    From ncalc with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle(R.string.module);
    mHint1.setHint("A = ");
    mHint2.setVisibility(View.VISIBLE);
    mHint2.setHint("B = ");
    mBtnEvaluate.setText("A mod B");

    mInputFormula.setInputType(InputType.TYPE_CLASS_NUMBER |
            InputType.TYPE_NUMBER_FLAG_SIGNED);
    mInputFormula2.setInputType(InputType.TYPE_CLASS_NUMBER |
            InputType.TYPE_NUMBER_FLAG_SIGNED);

    getIntentData();

    boolean isStarted = mPreferences.getBoolean(STARTED, false);
    if (!isStarted || DLog.UI_TESTING_MODE) {
        if (isDataNull) {
            mInputFormula.setText("100");
            mInputFormula2.setText("20");
        }
    }

}
 
Example #7
Source File: ReactTextInputPropertyTest.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Test
public void testPasswordInput() {
  ReactEditText view = mManager.createViewInstance(mThemedContext);

  mManager.updateProperties(view, buildStyles());
  assertThat(view.getInputType() & InputType.TYPE_TEXT_VARIATION_PASSWORD).isZero();

  mManager.updateProperties(view, buildStyles("secureTextEntry", false));
  assertThat(view.getInputType() & InputType.TYPE_TEXT_VARIATION_PASSWORD).isZero();

  mManager.updateProperties(view, buildStyles("secureTextEntry", true));
  assertThat(view.getInputType() & InputType.TYPE_TEXT_VARIATION_PASSWORD).isNotZero();

  mManager.updateProperties(view, buildStyles("secureTextEntry", null));
  assertThat(view.getInputType() & InputType.TYPE_TEXT_VARIATION_PASSWORD).isZero();
}
 
Example #8
Source File: Utility.java    From MuslimMateAndroid with GNU General Public License v3.0 6 votes vote down vote up
public static void getInput(Context context, String title, DialogInterface.OnClickListener onOkListener)
{
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(title);

    final EditText input = new EditText(context);
    input.setInputType(InputType.TYPE_CLASS_TEXT);
    input.setId(R.id.text1);
    builder.setView(input);

    builder.setPositiveButton("OK", onOkListener);

    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    builder.show();
}
 
Example #9
Source File: Mobex.java    From CSipSimple with GNU General Public License v3.0 6 votes vote down vote up
/**
* {@inheritDoc}
*/
  @Override
  public void fillLayout(SipProfile account) {
      super.fillLayout(account);
      accountUsername.getEditText().setInputType(InputType.TYPE_CLASS_PHONE);
      
      if(TextUtils.isEmpty(account.username)){
          accountUsername.setText(USUAL_PREFIX);
      }

      //Get wizard specific row
      customWizardText = (TextView) parent.findViewById(R.id.custom_wizard_text);
      customWizard = (LinearLayout) parent.findViewById(R.id.custom_wizard_row);
      

      updateAccountInfos(account);
  }
 
Example #10
Source File: Utils.java    From jellyfin-androidtv with GNU General Public License v2.0 6 votes vote down vote up
public static void processPasswordEntry(final Activity activity, final UserDto user, final String directItemId) {
    if (TvApp.getApplication().getUserPreferences().get(UserPreferences.Companion.getPasswordDPadEnabled())) {
        Intent pwIntent = new Intent(activity, DpadPwActivity.class);
        pwIntent.putExtra("User", SerializerRepository.INSTANCE.getSerializer().SerializeToString(user));
        pwIntent.putExtra("ItemId", directItemId);
        pwIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        activity.startActivity(pwIntent);
    } else {
        Timber.d("Requesting dialog...");
        final EditText password = new EditText(activity);
        password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        new AlertDialog.Builder(activity)
                .setTitle("Enter Password")
                .setMessage("Please enter password for " + user.getName())
                .setView(password)
                .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        String pw = password.getText().toString();
                        AuthenticationHelper.loginUser(user.getName(), pw, TvApp.getApplication().getLoginApiClient(), activity, directItemId);
                    }
                }).show();
    }
}
 
Example #11
Source File: PowerHalFragment.java    From SmartPack-Kernel-Manager with GNU General Public License v3.0 6 votes vote down vote up
private void powerhalTunablesInit(List<RecyclerViewItem> items) {
    TitleView powerhal = new TitleView();
    powerhal.setText(getString(R.string.powerhal_tunables));
    items.add(powerhal);

    for (int i = 0; i < VoxPopuli.VoxpopuliTunablesize(); i++) {
        if (VoxPopuli.VoxpopuliTunableexists(i)) {
            GenericSelectView tunables = new GenericSelectView();
            tunables.setSummary(VoxPopuli.getVoxpopuliTunableName(i));
            tunables.setValue(VoxPopuli.getVoxpopuliTunableValue(i));
            tunables.setValueRaw(tunables.getValue());
            tunables.setInputType(InputType.TYPE_CLASS_NUMBER);
            final int position = i;
            tunables.setOnGenericValueListener((genericSelectView, value) -> {
                VoxPopuli.setVoxpopuliTunableValue(value, position, getActivity());
                genericSelectView.setValue(value);
            });

            items.add(tunables);
        }
    }
}
 
Example #12
Source File: ArticleReportFragment.java    From tysq-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void initView(View view) {
    String name = String.format(getString(R.string.article_report_person), articleTitle);
    tvTitle.setText(name);
    initReportType();

    adapter = new ArticleReportAdapter(getContext(), articleReportResps, this);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.setAdapter(adapter);


    getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    etDescription.setInputType(InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE);
    etDescription.setSingleLine(false);
    etDescription.setHorizontallyScrolling(false);
    etDescription.addTextChangedListener(this);

    btnReport.setOnClickListener(this);
}
 
Example #13
Source File: SearchActivity.java    From Conversations with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
	getMenuInflater().inflate(R.menu.activity_search, menu);
	final MenuItem searchActionMenuItem = menu.findItem(R.id.action_search);
	final EditText searchField = searchActionMenuItem.getActionView().findViewById(R.id.search_field);
	final String term = pendingSearchTerm.pop();
	if (term != null) {
		searchField.append(term);
		List<String> searchTerm = FtsUtils.parse(term);
		if (xmppConnectionService != null) {
			if (currentSearch.watch(searchTerm)) {
				xmppConnectionService.search(searchTerm, this);
			}
		} else {
			pendingSearch.push(searchTerm);
		}
	}
	searchField.addTextChangedListener(this);
	searchField.setHint(R.string.search_messages);
	searchField.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
	if (term == null) {
		showKeyboard(searchField);
	}
	return super.onCreateOptionsMenu(menu);
}
 
Example #14
Source File: MainActivity.java    From Quran-For-My-Android with Apache License 2.0 6 votes vote down vote up
private void setSearchModeOn() {
	if(PRIMARY_TEXT_INDEX==Word_Info_Index){
		Toast.makeText(this, "Searching Cannot Be Done In Word By Word Text Mode."
				+ "\nChange Primary Text.", Toast.LENGTH_LONG).show();
		return;
		
	}
	if((Search_Operand_Text_Id==Search_Operand_Only_English
			|| Search_Operand_Text_Id==Search_Operand_All)
			&& allQuranTexts[English_Text_Index]==null){
		new TextUpdatingTask(this,"English Text").execute(English_Text_Index);
		//update text info, that is, search operand text is allQText[english text index]
	}
	isInSearchMode = true;
	commandText.setInputType(InputType.TYPE_CLASS_TEXT);
	commandText.setHint(R.string.hint_commandTextToSearch);
	
	invalidateOptionsMenu();
}
 
Example #15
Source File: TextProcessor.java    From CodeEditor with Apache License 2.0 5 votes vote down vote up
/**
 * Обновление типа ввода. Если в настройках отключены подсказки на клавиатуре,
 * то они не будут отображаться.
 */
public void refreshInputType() {
    if (defaultSetting.getImeKeyboard())
        setInputType(InputType.TYPE_CLASS_TEXT
                | InputType.TYPE_TEXT_FLAG_MULTI_LINE
                | InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE);
    else
        setInputType(InputType.TYPE_CLASS_TEXT
                | InputType.TYPE_TEXT_FLAG_MULTI_LINE
                | InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE
                | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
}
 
Example #16
Source File: Advancefone.java    From CSipSimple with GNU General Public License v3.0 5 votes vote down vote up
/**
    * {@inheritDoc}
    */
@Override
public void fillLayout(final SipProfile account) {
	super.fillLayout(account);
       accountUsername.getEditText().setInputType(InputType.TYPE_CLASS_PHONE);

       if(TextUtils.isEmpty(account.username)){
           accountUsername.setText(USUAL_PREFIX);
       }
}
 
Example #17
Source File: DialogInit.java    From talk-android with MIT License 5 votes vote down vote up
private static void setupInputDialog(final TalkDialog dialog) {
    final TalkDialog.Builder builder = dialog.mBuilder;
    dialog.input = (EditText) dialog.view.findViewById(android.R.id.input);
    if (dialog.input == null) return;
    dialog.setTypeface(dialog.input, builder.regularFont);
    if (builder.inputPrefill != null)
        dialog.input.setText(builder.inputPrefill);
    dialog.setInternalInputCallback();
    dialog.input.setHint(builder.inputHint);
    dialog.input.setSingleLine();
    dialog.input.setTextColor(builder.contentColor);
    dialog.input.setHintTextColor(DialogUtils.adjustAlpha(builder.contentColor, 0.3f));
    MDTintHelper.setTint(dialog.input, dialog.mBuilder.widgetColor);

    if (builder.inputType != -1) {
        dialog.input.setInputType(builder.inputType);
        if ((builder.inputType & InputType.TYPE_TEXT_VARIATION_PASSWORD) == InputType.TYPE_TEXT_VARIATION_PASSWORD) {
            // If the flags contain TYPE_TEXT_VARIATION_PASSWORD, apply the password transformation method automatically
            dialog.input.setTransformationMethod(PasswordTransformationMethod.getInstance());
        }
    }

    dialog.inputMinMax = (TextView) dialog.view.findViewById(R.id.minMax);
    if (builder.inputMaxLength > -1) {
        dialog.invalidateInputMinMaxIndicator(dialog.input.getText().toString().length(),
                !builder.inputAllowEmpty);
    } else {
        dialog.inputMinMax.setVisibility(View.GONE);
        dialog.inputMinMax = null;
    }
}
 
Example #18
Source File: EditTextViewModel.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NonNull
@Override
public FieldViewModel setMandatory() {
    return new AutoValue_EditTextViewModel(uid(), label(), true,
            value(), programStageSection(), null, editable(), null,
            description(), objectStyle(), fieldMask(), hint(), maxLines(), InputType.TYPE_CLASS_TEXT, valueType(), warning(), error(),
            fieldRendering());
}
 
Example #19
Source File: SettingsPageInflater.java    From k3pler with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
private void showEditDialog(String title, String currentItem, final String DATA){
    if(currentItem.equals(defaultBufferNum)){currentItem=defaultBuffer;}
    final String currentItem1 = currentItem;
    AlertDialog.Builder builder = new AlertDialog.Builder(context, android.R.style.Theme_DeviceDefault_Dialog);
    builder.setTitle(title);
    final EditText editText = new EditText(context);
    editText.setText(currentItem);
    editText.setInputType(InputType.TYPE_CLASS_TEXT);
    LinearLayout parentLayout = new LinearLayout(context);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT);
    layoutParams.setMargins(dpToPx(20), dpToPx(10), dpToPx(20), 0);
    editText.setLayoutParams(layoutParams);
    parentLayout.addView(editText);
    builder.setView(parentLayout);
    builder.setPositiveButton(context.getString(R.string.OK), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String item = editText.getText().toString();
            if(item.length() > 3) {
                sqliteDBHelper = new SqliteDBHelper(context,
                        new SQLiteSettings(context).getWritableDatabase(),
                        DATA, SQLiteSettings.TABLE_NAME);
                sqliteDBHelper.update(currentItem1, item);
                sqliteDBHelper.close();
                setValues();
            }
        }
    });
    AlertDialog alertDialog = builder.create();
    alertDialog.getWindow().setType(new RequestDialog().getWindowType());
    alertDialog.show();
}
 
Example #20
Source File: ReactAztecText.java    From react-native-aztec with GNU General Public License v2.0 5 votes vote down vote up
public ReactAztecText(ThemedReactContext reactContext) {
    super(reactContext);
    this.setAztecKeyListener(new ReactAztecText.OnAztecKeyListener() {
        @Override
        public boolean onEnterKey() {
            if (shouldHandleOnEnter) {
                return onEnter();
            }
            return false;
        }
        @Override
        public boolean onBackspaceKey() {
            if (shouldHandleOnBackspace) {
                return onBackspace();
            }
            return false;
        }
    });
    mInputMethodManager = (InputMethodManager)
            Assertions.assertNotNull(getContext().getSystemService(Context.INPUT_METHOD_SERVICE));
    this.setOnSelectionChangedListener(new OnSelectionChangedListener() {
        @Override
        public void onSelectionChanged(int selStart, int selEnd) {
            ReactAztecText.this.updateToolbarButtons(selStart, selEnd);
            ReactAztecText.this.propagateSelectionChanges(selStart, selEnd);
        }
    });
    this.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
}
 
Example #21
Source File: FreeScrollingTextField.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
    outAttrs.inputType = InputType.TYPE_CLASS_TEXT
            | InputType.TYPE_TEXT_FLAG_MULTI_LINE;
    outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_ENTER_ACTION
            | EditorInfo.IME_ACTION_DONE
            | EditorInfo.IME_FLAG_NO_EXTRACT_UI;
    if (_inputConnection == null) {
        _inputConnection = this.new TextFieldInputConnection(this);
    } else {
        _inputConnection.resetComposingState();
    }
    return _inputConnection;
}
 
Example #22
Source File: SettingsActivity.java    From alltv with MIT License 5 votes vote down vote up
@Override
public void onCreateActions(@NonNull List<GuidedAction> actions,
                            Bundle savedInstanceState) {

    SettingsData.TvingSettingsData tvingSettings = mSettings.mTvingSettings;

    boolean enabled = tvingSettings.mEnable;
    addCheckedAction(getContext(), actions, GuidedId.TvingEnable.ordinal(),
            getStringById(R.string.channel_enable), "", enabled);

    boolean cjoneid = tvingSettings.mCJOneId;
    addCheckedAction(getContext(), actions, GuidedId.TvingCjOneId.ordinal(),
            getStringById(R.string.cjoneid), getStringById(R.string.tvingid_dec), cjoneid);

    String id = tvingSettings.mId == null ? "" : tvingSettings.mId;
    String pw = tvingSettings.mPassword == null ? "" : tvingSettings.mPassword;

    addEditableAction(getContext(), actions, GuidedId.TvingId.ordinal(),
            getStringById(R.string.id), id, InputType.TYPE_CLASS_TEXT);

    addEditablePasswordAction(getContext(), actions, GuidedId.TvingPw.ordinal(),
            getStringById(R.string.password), "", pw);

    ArrayList<GuidedAction> qualityList = new ArrayList<>();

    qualityList.add(new GuidedAction.Builder(getContext()).
            title(getStringById(R.string.mobile)).id(GuidedId.TvingMD.ordinal()).build());
    qualityList.add(new GuidedAction.Builder(getContext()).
            title(getStringById(R.string.sd)).id(GuidedId.TvingSD.ordinal()).build());
    qualityList.add(new GuidedAction.Builder(getContext()).
            title(getStringById(R.string.hd)).id(GuidedId.TvingHD.ordinal()).build());
    qualityList.add(new GuidedAction.Builder(getContext()).
            title(getStringById(R.string.fullhd)).id(GuidedId.TvingFHD.ordinal()).build());

    addDropDownAction(getContext(), actions, GuidedId.TvingQuality.ordinal(),
            getStringById(R.string.quality_set), "", qualityList);
}
 
Example #23
Source File: FieldValidator.java    From tapchat-android with Apache License 2.0 5 votes vote down vote up
private static boolean validateEditText(EditText editText) {
    boolean valid = true;

    String text = editText.getText().toString();

    boolean isEmail   = (editText.getInputType() & InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS) == InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
    boolean isNumeric = (editText.getInputType() & InputType.TYPE_NUMBER_FLAG_DECIMAL) == InputType.TYPE_NUMBER_FLAG_DECIMAL;

    if (TextUtils.isEmpty(text)) {
        if (!isNumeric || !TextUtils.isDigitsOnly(editText.getHint())) {
            valid = false;
        }

    } else if (isEmail) {
        valid = android.util.Patterns.EMAIL_ADDRESS.matcher(text).matches();
    }

    if (!valid) {
        Context context = editText.getContext();
        if (isEmail) {
            editText.setError(context.getString(R.string.error_invalid_email));
        } else {
            editText.setError(context.getString(R.string.error_blank));
        }
        return false;
    }

    editText.setError(null);
    return true;
}
 
Example #24
Source File: SettingsFragment.java    From KernelAdiutor with GNU General Public License v3.0 5 votes vote down vote up
private void deletePasswordDialog(final String password) {
    if (password.isEmpty()) {
        Utils.toast(getString(R.string.set_password_first), getActivity());
        return;
    }

    mDeletePassword = password;

    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setGravity(Gravity.CENTER);
    int padding = Math.round(getResources().getDimension(R.dimen.dialog_padding));
    linearLayout.setPadding(padding, padding, padding, padding);

    final AppCompatEditText mPassword = new AppCompatEditText(getActivity());
    mPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    mPassword.setHint(getString(R.string.password));
    linearLayout.addView(mPassword);

    new Dialog(getActivity()).setView(linearLayout)
            .setPositiveButton(getString(R.string.ok), (dialogInterface, i) -> {
                if (!mPassword.getText().toString().equals(Utils.decodeString(password))) {
                    Utils.toast(getString(R.string.password_wrong), getActivity());
                    return;
                }

                AppSettings.resetPassword(getActivity());
                if (mFingerprint != null) {
                    mFingerprint.setEnabled(false);
                }
            })
            .setOnDismissListener(dialogInterface -> mDeletePassword = null).show();
}
 
Example #25
Source File: LockViewActivity.java    From android-project-wo2b with Apache License 2.0 5 votes vote down vote up
@Override
protected void initView()
{
	grid_number = (GridView) findViewById(R.id.grid_number);

	generateKeyboard();

	mOldPwd = XPreferenceManager.getString(RockyKeyValues.Keys.ENTRY_PASSWORD, "");
	

	pwd_content = (LinearLayout) findViewById(R.id.pwd_content);
	final int pwd_count = pwd_content.getChildCount();
	pwd_items = new EditText[pwd_count];
	for (int i = 0; i < pwd_count; i++)
	{
		pwd_items[i] = (EditText) pwd_content.getChildAt(i);
		if (mMode == LOCK_MODE_DECODE)
		{
			// 解密
			pwd_items[i].setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
		}
		else
		{
			pwd_items[i].setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
		}

		ViewUtils.hideSoftInput(this, pwd_items[i]);
	}

	pwd_items[0].requestFocus();
	pwd_items[pwd_count - 1].addTextChangedListener(new OnTextInputCompleted());
}
 
Example #26
Source File: RegisterActivity.java    From AndroidWallet with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void initData() {
    binding.edtRegisterPwd.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
    binding.edtRegisterConfirmPwd.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
    pwdVisibleControl2(binding.edtRegisterPwd, binding.edtRegisterConfirmPwd, binding.ivPwdVisible);
    binding.ivPwdVisible.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            pwdVisibleControl2(binding.edtRegisterPwd, binding.edtRegisterConfirmPwd, binding.ivPwdVisible);
        }
    });
}
 
Example #27
Source File: FragmentPassCodeViewModel.java    From iGap-Android with GNU Affero General Public License v3.0 5 votes vote down vote up
public void onClickTogglePassCode(View v) {

        edtSetPasswordText.set("");
        if (realmUserInfo != null) isPassCode = realmUserInfo.isPassCode();

        if (!isPassCode) {
            page = 0;
            vgTogglePassCodeVisibility.set(View.GONE);
            rootEnterPassword.set(View.VISIBLE);
            rootSettingPassword.set(View.GONE);
            rippleOkVisibility.set(View.VISIBLE);
            //txtSetPassword.setText(G.fragmentActivity.getResources().getString(R.string.enter_a_password));
            //titlePassCode.set("PIN");
            txtSetPassword.set(G.fragmentActivity.getResources().getString(R.string.enter_a_password));
            titlePassCodeVisibility.set(View.GONE);
            layoutModePassCode.set(View.VISIBLE);
            if (kindPassword == PIN) {
                edtSetPasswordInput.set(InputType.TYPE_CLASS_NUMBER);
            } else {
                edtSetPasswordInput.set(InputType.TYPE_CLASS_TEXT);
            }
        } else {

            disablePassCode();

        }

    }
 
Example #28
Source File: AndroidSpellCheckerService.java    From openboard with GNU General Public License v3.0 5 votes vote down vote up
private KeyboardLayoutSet createKeyboardSetForSpellChecker(final InputMethodSubtype subtype) {
    final EditorInfo editorInfo = new EditorInfo();
    editorInfo.inputType = InputType.TYPE_CLASS_TEXT;
    final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder(this, editorInfo);
    builder.setKeyboardGeometry(
            SPELLCHECKER_DUMMY_KEYBOARD_WIDTH, SPELLCHECKER_DUMMY_KEYBOARD_HEIGHT);
    builder.setSubtype(RichInputMethodSubtype.getRichInputMethodSubtype(subtype));
    builder.setIsSpellChecker(true /* isSpellChecker */);
    builder.disableTouchPositionCorrectionData();
    return builder.build();
}
 
Example #29
Source File: SearchPreference.java    From SearchPreference with MIT License 5 votes vote down vote up
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    EditText searchText = (EditText) holder.findViewById(R.id.search);
    searchText.setFocusable(false);
    searchText.setInputType(InputType.TYPE_NULL);
    searchText.setOnClickListener(this);

    if (hint != null) {
        searchText.setHint(hint);
    }

    holder.findViewById(R.id.search_card).setOnClickListener(this);
    holder.itemView.setOnClickListener(this);
    holder.itemView.setBackgroundColor(0x0);
}
 
Example #30
Source File: MonitorActivity.java    From secureit with MIT License 5 votes vote down vote up
/**
 * Shows a dialog prompting the unlock code
 */
private void createUnlockDialog() {
	final AlertDialog.Builder builder = new AlertDialog.Builder(this);
	builder.setTitle("Stop monitoring?");
	final EditText input = new EditText(this);
	input.setHint("Unlock code");
	input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
	builder.setView(input);

	builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
		public void onClick(DialogInterface dialog, int whichButton) {
			if (input.getText().toString().equals(preferences.getUnlockCode())) {
				Log.i("MonitorActivity", "INPUT "+input.getText().toString());
				Log.i("MonitorActivity", "STORED "+preferences.getUnlockCode());
				dialog.dismiss();
				close();
			} else {
				dialog.dismiss();
				Toast.makeText(
						getApplicationContext(), 
						"Wrong unlock code", 
						Toast.LENGTH_SHORT).show();
	        }
		}
	});

	builder.show();
}