List of usage examples for android.text InputType TYPE_CLASS_TEXT
int TYPE_CLASS_TEXT
To view the source code for android.text InputType TYPE_CLASS_TEXT.
Click Source Link
From source file:org.openlmis.core.view.activity.LoginActivity.java
private void setPwdVisibility() { if (etPassword.getInputType() == (InputType.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD)) { ivVisibilityPwd.setImageResource(R.drawable.ic_visibility); etPassword.setInputType(InputType.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); } else {// w ww.j a v a 2 s . c o m etPassword.setInputType(InputType.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD); ivVisibilityPwd.setImageResource(R.drawable.ic_visibility_off); } etPassword.setSelection(etPassword.getText().length()); }
From source file:org.secuso.privacyfriendlypasswordgenerator.dialogs.UpdatePasswordDialog.java
public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = getActivity().getLayoutInflater(); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); rootView = inflater.inflate(R.layout.dialog_update_passwords, null); visibility = false;/*from w ww. j av a 2 s . co m*/ spinnerOld = (ProgressBar) rootView.findViewById(R.id.oldProgressBar); spinnerOld.setVisibility(View.GONE); spinnerNew = (ProgressBar) rootView.findViewById(R.id.newProgressBar); spinnerNew.setVisibility(View.GONE); Bundle bundle = getArguments(); position = bundle.getInt("position"); bindToDevice_enabled = bundle.getBoolean("bindToDevice_enabled"); hashAlgorithm = bundle.getString("hash_algorithm"); setOldMetaData(bundle); number_iterations = bundle.getInt("number_iterations"); database = MetaDataSQLiteHelper.getInstance(getActivity()); builder.setView(rootView); builder.setIcon(R.mipmap.ic_drawer); builder.setTitle(getActivity().getString(R.string.passwords_heading)); Button displayButton = (Button) rootView.findViewById(R.id.displayButton); displayButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN); displayPasswords(); } }); ImageButton copyOldButton = (ImageButton) rootView.findViewById(R.id.copyOldButton); ImageButton copyNewButton = (ImageButton) rootView.findViewById(R.id.copyNewButton); copyOldButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { TextView oldPassword = (TextView) rootView.findViewById(R.id.textViewOldPassword); ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("", oldPassword.getText()); clipboard.setPrimaryClip(clip); Toast.makeText(getActivity(), getActivity().getString(R.string.copy_clipboar_old), Toast.LENGTH_SHORT).show(); } }); copyNewButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { TextView newPassword = (TextView) rootView.findViewById(R.id.textViewNewPassword); ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("", newPassword.getText()); clipboard.setPrimaryClip(clip); Toast.makeText(getActivity(), getActivity().getString(R.string.copy_clipboar_new), Toast.LENGTH_SHORT).show(); } }); builder.setPositiveButton(getActivity().getString(R.string.done), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { onClickDone(); } }); visibilityButton = (ImageButton) rootView.findViewById(R.id.visibilityButton); visibilityButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { editTextUpdateMasterpassword = (EditText) rootView.findViewById(R.id.editTextUpdateMasterpassword); if (!visibility) { visibilityButton.setImageResource(R.drawable.ic_visibility_off); editTextUpdateMasterpassword.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); editTextUpdateMasterpassword.setSelection(editTextUpdateMasterpassword.getText().length()); visibility = true; } else { visibilityButton.setImageResource(R.drawable.ic_visibility); editTextUpdateMasterpassword .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); editTextUpdateMasterpassword.setSelection(editTextUpdateMasterpassword.getText().length()); visibility = false; } } }); return builder.create(); }
From source file:com.nttec.everychan.chans.nullchan.NullchanccModule.java
private void addDomainPreference(PreferenceGroup group) { Context context = group.getContext(); EditTextPreference domainPref = new EditTextPreference(context); domainPref.setTitle(R.string.pref_domain); domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT)); domainPref.setDialogTitle(R.string.pref_domain); domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN)); domainPref.getEditText().setHint(DEFAULT_DOMAIN); domainPref.getEditText().setSingleLine(); domainPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); group.addPreference(domainPref);/*from w ww. java 2s .c o m*/ }
From source file:org.linphone.ChatFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreate(savedInstanceState); instance = this; View view = inflater.inflate(R.layout.chat, container, false); LinphoneManager.addListener(this); // Retain the fragment across configuration changes setRetainInstance(true);//from w w w . ja va2 s. c o m //Retrieve parameter from intent sipUri = getArguments().getString("SipUri"); displayName = getArguments().getString("DisplayName"); pictureUri = getArguments().getString("PictureUri"); //Initialize UI contactName = (TextView) view.findViewById(R.id.contactName); contactPicture = (AvatarWithShadow) view.findViewById(R.id.contactPicture); messagesList = (ListView) view.findViewById(R.id.chatMessageList); textLayout = (RelativeLayout) view.findViewById(R.id.messageLayout); progressBar = (ProgressBar) view.findViewById(R.id.progressbar); topBar = (LinearLayout) view.findViewById(R.id.topbar); sendMessage = (TextView) view.findViewById(R.id.sendMessage); sendMessage.setOnClickListener(this); remoteComposing = (TextView) view.findViewById(R.id.remoteComposing); remoteComposing.setVisibility(View.GONE); uploadLayout = (RelativeLayout) view.findViewById(R.id.uploadLayout); uploadLayout.setVisibility(View.GONE); displayChatHeader(displayName, pictureUri); //Manage multiline message = (EditText) view.findViewById(R.id.message); if (!getResources().getBoolean(R.bool.allow_chat_multiline)) { message.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE); message.setMaxLines(1); } sendImage = (TextView) view.findViewById(R.id.sendPicture); if (!getResources().getBoolean(R.bool.disable_chat_send_file)) { sendImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { pickImage(); } }); //registerForContextMenu(sendImage); } else { sendImage.setEnabled(false); } back = (TextView) view.findViewById(R.id.back); if (back != null) { back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getActivity().finish(); } }); } cancelUpload = (ImageView) view.findViewById(R.id.cancelUpload); cancelUpload.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (currentMessageInFileTransferUploadState != null) { uploadLayout.setVisibility(View.GONE); textLayout.setVisibility(View.VISIBLE); progressBar.setProgress(0); currentMessageInFileTransferUploadState.cancelFileTransfer(); currentMessageInFileTransferUploadState = null; LinphoneManager.getInstance().setUploadPendingFileMessage(null); } } }); LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull(); if (lc != null) { chatRoom = lc.getOrCreateChatRoom(sipUri); //Only works if using liblinphone storage chatRoom.markAsRead(); } mListener = new LinphoneCoreListenerBase() { @Override public void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) { LinphoneAddress from = cr.getPeerAddress(); if (from.asStringUriOnly().equals(sipUri)) { invalidate(); messagesList.setSelection(adapter.getCount() - 1); } } @Override public void isComposingReceived(LinphoneCore lc, LinphoneChatRoom room) { if (chatRoom != null && room != null && chatRoom.getPeerAddress().asStringUriOnly() .equals(room.getPeerAddress().asStringUriOnly())) { remoteComposing.setVisibility(chatRoom.isRemoteComposing() ? View.VISIBLE : View.GONE); } } }; textWatcher = new TextWatcher() { public void afterTextChanged(Editable arg0) { } public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { if (message.getText().toString().equals("")) { sendMessage.setEnabled(false); } else { if (chatRoom != null) chatRoom.compose(); sendMessage.setEnabled(true); } } }; // Force hide keyboard getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); return view; }
From source file:be.brunoparmentier.wifikeyshare.ui.activities.WifiNetworkActivity.java
void showWifiPasswordDialog() { final LayoutInflater inflater = getLayoutInflater(); final View wifiPasswordDialogLayout = inflater.inflate(R.layout.dialog_wifi_password, null); final TextInputLayout wifiPasswordWrapper = (TextInputLayout) wifiPasswordDialogLayout .findViewById(R.id.wifi_key_wrapper); final EditText passwordEditText = (EditText) wifiPasswordDialogLayout.findViewById(R.id.wifi_key); //setPasswordRestrictions(passwordEditText); final CheckBox showPasswordCheckBox = (CheckBox) wifiPasswordDialogLayout .findViewById(R.id.show_password_checkbox); showPasswordCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override//from w ww.j a va 2s . com public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) { int selectionIndex = passwordEditText.getSelectionStart(); if (isChecked) { passwordEditText.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); } else { passwordEditText .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); } passwordEditText.setSelection(selectionIndex); } }); final AlertDialog wifiPasswordDialog = new AlertDialog.Builder(this) .setTitle(getString(R.string.wifi_dialog_password_title)) .setMessage(String.format(getString(R.string.wifi_dialog_password_msg), wifiNetwork.getSsid())) .setView(wifiPasswordDialogLayout) .setPositiveButton(getString(R.string.action_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { // this method gets overriden after we show the dialog } }).setNegativeButton(getString(R.string.action_cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { finish(); } }).setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) { finish(); } }).create(); passwordEditText.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) { } @Override public void afterTextChanged(Editable editable) { wifiPasswordDialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(editable.length() >= 5); if (wifiPasswordWrapper.getError() != null) { try { if (WifiNetwork.isValidKeyLength(wifiNetwork.getAuthType(), editable.toString())) { wifiPasswordWrapper.setError(null); } } catch (final WifiException e) { switch (e.getErrorCode()) { case WifiException.WEP_KEY_LENGTH_ERROR: wifiPasswordWrapper.setError(getString(R.string.error_wep_password_length)); break; case WifiException.WPA_KEY_LENGTH_ERROR: wifiPasswordWrapper.setError(getString(R.string.error_wpa_password_length)); break; default: wifiPasswordWrapper.setError(e.getMessage()); break; } } } } }); wifiPasswordDialog.show(); wifiPasswordDialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(false); // disabled by default wifiPasswordDialog.getButton(DialogInterface.BUTTON_POSITIVE) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { if (WifiNetwork.isValidKeyLength(wifiNetwork.getAuthType(), passwordEditText.getText().toString())) { wifiPasswordWrapper.setError(null); wifiNetwork.setKey(passwordEditText.getText().toString()); // Update QR code image FragmentManager fm = getSupportFragmentManager(); QrCodeFragment qrCodeFragment = (QrCodeFragment) fm.getFragments().get(0); qrCodeFragment.updateQrCode(wifiNetwork); WifiKeysDataSource.getInstance().insertWifiKey(wifiNetwork); Intent passwordResultIntent = new Intent(); passwordResultIntent.putExtra(KEY_NETWORK_ID, wifiNetworkId); setResult(RESULT_OK, passwordResultIntent); wifiPasswordDialog.dismiss(); } } catch (WifiException e) { switch (e.getErrorCode()) { case WifiException.WEP_KEY_LENGTH_ERROR: wifiPasswordWrapper.setError(getString(R.string.error_wep_password_length)); break; case WifiException.WPA_KEY_LENGTH_ERROR: wifiPasswordWrapper.setError(getString(R.string.error_wpa_password_length)); break; default: wifiPasswordWrapper.setError(null); break; } } } }); }
From source file:pw.dedominic.airc.App.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (toggle.onOptionsItemSelected(item)) return true; int menuid = item.getItemId(); switch (menuid) { case R.id.add_chan: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Add Channel"); final EditText input = new EditText(this); input.setInputType(InputType.TYPE_CLASS_TEXT); builder.setView(input);//from ww w.j a v a 2 s . com // Set up the buttons builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { channelAdded(input.getText().toString()); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.show(); break; case R.id.close_server: onDisconnectFromUser(); } return true; }
From source file:id.zelory.tanipedia.activity.TanyaActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tanya); toolbar = (Toolbar) findViewById(R.id.anim_toolbar); setSupportActionBar(toolbar);//w w w .ja v a 2 s .c o m getSupportActionBar().setDisplayHomeAsUpEnabled(true); CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); collapsingToolbar.setTitle("Tanya Tani"); animation = AnimationUtils.loadAnimation(this, R.anim.simple_grow); fabMargin = getResources().getDimensionPixelSize(R.dimen.fab_margin); drawerLayout = (DrawerLayout) findViewById(R.id.nav_drawer); setUpNavDrawer(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.getMenu().getItem(2).setChecked(true); TextView nama = (TextView) navigationView.findViewById(R.id.nama); nama.setText(PrefUtils.ambilString(this, "nama")); TextView email = (TextView) navigationView.findViewById(R.id.email); email.setText(PrefUtils.ambilString(this, "email")); navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { menuItem.setChecked(true); drawerLayout.closeDrawers(); Intent intent; switch (menuItem.getItemId()) { case R.id.cuaca: intent = new Intent(TanyaActivity.this, CuacaActivity.class); break; case R.id.berita: intent = new Intent(TanyaActivity.this, BeritaActivity.class); break; case R.id.tanya: return true; case R.id.harga: intent = new Intent(TanyaActivity.this, KomoditasActivity.class); break; case R.id.logout: PrefUtils.simpanString(TanyaActivity.this, "nama", null); intent = new Intent(TanyaActivity.this, LoginActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); return true; case R.id.tentang: intent = new Intent(TanyaActivity.this, TentangActivity.class); startActivity(intent); return true; default: return true; } startActivity(intent); finish(); return true; } }); recyclerView = (RecyclerView) findViewById(R.id.scrollableview); recyclerView.setHasFixedSize(true); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); recyclerView.setLayoutManager(linearLayoutManager); recyclerView.addOnScrollListener(new MyRecyclerScroll() { @Override public void show() { fab.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start(); } @Override public void hide() { fab.animate().translationY(fab.getHeight() + fabMargin) .setInterpolator(new AccelerateInterpolator(2)).start(); } }); tanyaGambar = (ImageView) findViewById(R.id.tanya_gambar); tanyaGambar.setVisibility(View.GONE); fab = (FrameLayout) findViewById(R.id.myfab_main); fab.setVisibility(View.GONE); fabBtn = (ImageButton) findViewById(R.id.myfab_main_btn); View fabShadow = findViewById(R.id.myfab_shadow); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { fabShadow.setVisibility(View.GONE); fabBtn.setBackground(getDrawable(R.drawable.ripple_accent)); } fabBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new MaterialDialog.Builder(TanyaActivity.this).title("TaniPedia").content("Kirim Pertanyaan") .inputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_CLASS_TEXT) .input("Ketik pertanyaan anda disini!", null, false, new MaterialDialog.InputCallback() { @Override public void onInput(MaterialDialog dialog, CharSequence input) { try { pertanyaan = URLEncoder.encode(input.toString(), "UTF-8"); new KirimSoal().execute(); } catch (UnsupportedEncodingException e) { Snackbar.make(fabBtn, "Terjadi kesalahan, silahkan coba lagi!", Snackbar.LENGTH_LONG).show(); e.printStackTrace(); } } }).positiveColorRes(R.color.primary_dark).positiveText("Kirim") .cancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { } }).negativeColorRes(R.color.primary_dark).negativeText("Batal").show(); } }); fabButton = (FabButton) findViewById(R.id.determinate); fabButton.showProgress(true); new DownloadData().execute(); fabButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { fabButton.showProgress(true); new DownloadData().execute(); } }); }
From source file:nl.hnogames.domoticz.Welcome.WelcomePage3.java
private void getLayoutReferences() { remote_server_input = (FloatingLabelEditText) v.findViewById(R.id.remote_server_input); remote_port_input = (FloatingLabelEditText) v.findViewById(R.id.remote_port_input); remote_username_input = (FloatingLabelEditText) v.findViewById(R.id.remote_username_input); remote_password_input = (FloatingLabelEditText) v.findViewById(R.id.remote_password_input); remote_directory_input = (FloatingLabelEditText) v.findViewById(R.id.remote_directory_input); remote_protocol_spinner = (Spinner) v.findViewById(R.id.remote_protocol_spinner); local_server_input = (FloatingLabelEditText) v.findViewById(R.id.local_server_input); local_port_input = (FloatingLabelEditText) v.findViewById(R.id.local_port_input); local_username_input = (FloatingLabelEditText) v.findViewById(R.id.local_username_input); local_password_input = (FloatingLabelEditText) v.findViewById(R.id.local_password_input); local_directory_input = (FloatingLabelEditText) v.findViewById(R.id.local_directory_input); local_protocol_spinner = (Spinner) v.findViewById(R.id.local_protocol_spinner); local_wifi_spinner = (MultiSelectionSpinner) v.findViewById(R.id.local_wifi); cbShowPassword = (CheckBox) v.findViewById(R.id.showpassword); cbShowPasswordLocal = (CheckBox) v.findViewById(R.id.showpasswordlocal); startScreen_spinner = (Spinner) v.findViewById(R.id.startScreen_spinner); btnManualSSID = (Button) v.findViewById(R.id.set_ssid); btnManualSSID.setOnClickListener(new View.OnClickListener() { @Override// w ww . jav a 2 s . c om public void onClick(View v) { new MaterialDialog.Builder(getContext()).title(R.string.welcome_ssid_button_prompt) .content(R.string.welcome_msg_no_ssid_found) .inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD) .input(null, null, new MaterialDialog.InputCallback() { @Override public void onInput(MaterialDialog dialog, CharSequence input) { Set<String> ssidFromPrefs = mServerUtil.getActiveServer().getLocalServerSsid(); final ArrayList<String> ssidListFromPrefs = new ArrayList<>(); if (ssidFromPrefs != null) { if (ssidFromPrefs.size() > 0) { for (String wifi : ssidFromPrefs) { ssidListFromPrefs.add(wifi); } } } ssidListFromPrefs.add(String.valueOf(input)); mServerUtil.getActiveServer().setLocalServerSsid(ssidListFromPrefs); setSsid_spinner(); } }).show(); } }); if (callingInstance == SETTINGS) { // Hide these settings if being called by settings (instead of welcome wizard) startScreen_spinner.setVisibility(View.GONE); v.findViewById(R.id.startScreen_title).setVisibility(View.GONE); v.findViewById(R.id.server_settings_title).setVisibility(View.GONE); } final LinearLayout localServerSettingsLayout = (LinearLayout) v.findViewById(R.id.local_server_settings); localServer_switch = (Switch) v.findViewById(R.id.localServer_switch); localServer_switch.setChecked(mSharedPrefs.isAdvancedSettingsEnabled()); localServer_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { if (checked) localServerSettingsLayout.setVisibility(View.VISIBLE); else localServerSettingsLayout.setVisibility(View.GONE); } }); final LinearLayout advancedSettings_layout = (LinearLayout) v.findViewById(R.id.advancedSettings_layout); advancedSettings_switch = (Switch) v.findViewById(R.id.advancedSettings_switch); advancedSettings_switch.setChecked(mSharedPrefs.isAdvancedSettingsEnabled()); if (mSharedPrefs.isAdvancedSettingsEnabled()) advancedSettings_layout.setVisibility(View.VISIBLE); advancedSettings_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mSharedPrefs.setAdvancedSettingsEnabled(isChecked); if (isChecked) advancedSettings_layout.setVisibility(View.VISIBLE); else advancedSettings_layout.setVisibility(View.GONE); } }); cbShowPassword.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (!isChecked) { remote_password_input.getInputWidget() .setTransformationMethod(PasswordTransformationMethod.getInstance()); } else { remote_password_input.getInputWidget() .setTransformationMethod(HideReturnsTransformationMethod.getInstance()); } } }); cbShowPasswordLocal.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (!isChecked) { local_password_input.getInputWidget() .setTransformationMethod(PasswordTransformationMethod.getInstance()); } else { local_password_input.getInputWidget() .setTransformationMethod(HideReturnsTransformationMethod.getInstance()); } } }); }
From source file:org.secuso.privacyfriendlypasswordgenerator.dialogs.GeneratePasswordDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = getActivity().getLayoutInflater(); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); rootView = inflater.inflate(R.layout.dialog_generate_password, null); Bundle bundle = getArguments();/*w ww.ja va2s . c o m*/ position = bundle.getInt("position"); clipboard_enabled = bundle.getBoolean("clipboard_enabled"); bindToDevice_enabled = bundle.getBoolean("bindToDevice_enabled"); hashAlgorithm = bundle.getString("hash_algorithm"); number_iterations = bundle.getInt("number_iterations"); visibility = false; spinner = (ProgressBar) rootView.findViewById(R.id.progressBar); spinner.setVisibility(View.GONE); database = MetaDataSQLiteHelper.getInstance(getActivity()); metaData = database.getMetaData(position); TextView domain = (TextView) rootView.findViewById(R.id.domainHeadingTextView); domain.setText(metaData.getDOMAIN()); TextView username = (TextView) rootView.findViewById(R.id.domainUsernameTextView); username.setText(metaData.getUSERNAME()); TextView iteration = (TextView) rootView.findViewById(R.id.textViewIteration); iteration.setText(String.valueOf(metaData.getITERATION())); builder.setView(rootView); builder.setIcon(R.mipmap.ic_drawer); builder.setTitle(getActivity().getString(R.string.generate_heading)); builder.setPositiveButton(getActivity().getString(R.string.done), null); Button generateButton = (Button) rootView.findViewById(R.id.generatorButton); generateButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { TextView textViewPassword = (TextView) rootView.findViewById(R.id.textViewPassword); textViewPassword.setText(""); InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN); editTextMasterpassword = (EditText) rootView.findViewById(R.id.editTextMasterpassword); if (editTextMasterpassword.getText().toString().length() == 0) { Toast toast = Toast.makeText(getActivity().getBaseContext(), getString(R.string.enter_masterpassword), Toast.LENGTH_SHORT); toast.show(); } else if (editTextMasterpassword.getText().toString().length() < 8) { Toast toast = Toast.makeText(getActivity().getBaseContext(), getString(R.string.masterpassword_length), Toast.LENGTH_SHORT); toast.show(); } else { spinner.setVisibility(View.VISIBLE); generatePassword(); } } }); ImageButton copyButton = (ImageButton) rootView.findViewById(R.id.copyButton); copyButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { TextView password = (TextView) rootView.findViewById(R.id.textViewPassword); if (password.getText().toString().length() > 0) { ClipboardManager clipboard = (ClipboardManager) getActivity() .getSystemService(CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("", password.getText()); clipboard.setPrimaryClip(clip); Toast.makeText(getActivity(), getActivity().getString(R.string.password_copied), Toast.LENGTH_SHORT).show(); } } }); visibilityButton = (ImageButton) rootView.findViewById(R.id.visibilityButton); visibilityButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { editTextMasterpassword = (EditText) rootView.findViewById(R.id.editTextMasterpassword); if (!visibility) { visibilityButton.setImageResource(R.drawable.ic_visibility_off); editTextMasterpassword.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); editTextMasterpassword.setSelection(editTextMasterpassword.getText().length()); visibility = true; } else { visibilityButton.setImageResource(R.drawable.ic_visibility); editTextMasterpassword .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); editTextMasterpassword.setSelection(editTextMasterpassword.getText().length()); visibility = false; } } }); return builder.create(); }
From source file:com.discord.chipsview.ChipsView.java
private void init() { mDensity = getResources().getDisplayMetrics().density; mChipsContainer = new RelativeLayout(getContext()); addView(mChipsContainer);/* w w w.j a v a2s. com*/ // Dummy item to prevent AutoCompleteTextView from receiving focus LinearLayout linearLayout = new LinearLayout(getContext()); ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(0, 0); linearLayout.setLayoutParams(params); linearLayout.setFocusable(true); linearLayout.setFocusableInTouchMode(true); mChipsContainer.addView(linearLayout); mEditText = new ChipsEditText(getContext(), this); final int chipHeightWithPadding = (int) ((CHIP_HEIGHT * mDensity) + mVerticalSpacing); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, chipHeightWithPadding); layoutParams.leftMargin = (int) (5 * mDensity); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); mEditText.setLayoutParams(layoutParams); mEditText.setPadding(0, 0, 0, mVerticalSpacing); mEditText.setBackgroundColor(Color.argb(0, 0, 0, 0)); mEditText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); mEditText.setInputType(InputType.TYPE_CLASS_TEXT); mEditText.setTextColor(mChipsSearchTextColor); mEditText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mChipsSearchTextSize); mChipsContainer.addView(mEditText); mRootChipsLayout = new ChipsVerticalLinearLayout(getContext(), chipHeightWithPadding); mRootChipsLayout.setOrientation(LinearLayout.VERTICAL); mRootChipsLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); mRootChipsLayout.setPadding(0, (int) (SPACING_TOP * mDensity), 0, 0); mChipsContainer.addView(mRootChipsLayout); initListener(); onChipsChanged(false); }