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.quantumbadger.redreader.activities.CaptchaActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { PrefsUtility.applyTheme(this); getSupportActionBar().setTitle(R.string.post_captcha_title); super.onCreate(savedInstanceState); final LoadingView loadingView = new LoadingView(this, R.string.download_waiting, true, true); setContentView(loadingView);//w w w .j a va 2 s . com final RedditAccount selectedAccount = RedditAccountManager.getInstance(this) .getAccount(getIntent().getStringExtra("username")); final CacheManager cm = CacheManager.getInstance(this); RedditAPI.newCaptcha(cm, new APIResponseHandler.NewCaptchaResponseHandler(this) { @Override protected void onSuccess(final String captchaId) { final URI captchaUrl = Constants.Reddit.getUri("/captcha/" + captchaId); cm.makeRequest(new CacheRequest(captchaUrl, RedditAccountManager.getAnon(), null, Constants.Priority.CAPTCHA, 0, CacheRequest.DownloadType.FORCE, Constants.FileType.CAPTCHA, false, false, true, CaptchaActivity.this) { @Override protected void onCallbackException(Throwable t) { BugReportActivity.handleGlobalError(CaptchaActivity.this, t); } @Override protected void onDownloadNecessary() { } @Override protected void onDownloadStarted() { loadingView.setIndeterminate(R.string.download_downloading); } @Override protected void onFailure(RequestFailureType type, Throwable t, StatusLine status, String readableMessage) { final RRError error = General.getGeneralErrorForFailure(CaptchaActivity.this, type, t, status, url.toString()); General.showResultDialog(CaptchaActivity.this, error); finish(); } @Override protected void onProgress(long bytesRead, long totalBytes) { loadingView.setProgress(R.string.download_downloading, (float) ((double) bytesRead / (double) totalBytes)); } @Override protected void onSuccess(final CacheManager.ReadableCacheFile cacheFile, long timestamp, UUID session, boolean fromCache, String mimetype) { final Bitmap image; try { image = BitmapFactory.decodeStream(cacheFile.getInputStream()); } catch (IOException e) { BugReportActivity.handleGlobalError(CaptchaActivity.this, e); return; } new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { final LinearLayout ll = new LinearLayout(CaptchaActivity.this); ll.setOrientation(LinearLayout.VERTICAL); final ImageView captchaImg = new ImageView(CaptchaActivity.this); ll.addView(captchaImg); final LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) captchaImg .getLayoutParams(); layoutParams.setMargins(20, 20, 20, 20); layoutParams.height = General.dpToPixels(context, 100); captchaImg.setScaleType(ImageView.ScaleType.FIT_CENTER); final EditText captchaText = new EditText(CaptchaActivity.this); ll.addView(captchaText); ((LinearLayout.LayoutParams) captchaText.getLayoutParams()).setMargins(20, 0, 20, 20); captchaText.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS); captchaImg.setImageBitmap(image); final Button submitButton = new Button(CaptchaActivity.this); submitButton.setText(R.string.post_captcha_submit_button); ll.addView(submitButton); ((LinearLayout.LayoutParams) submitButton.getLayoutParams()).setMargins(20, 0, 20, 20); ((LinearLayout.LayoutParams) submitButton .getLayoutParams()).gravity = Gravity.RIGHT; ((LinearLayout.LayoutParams) submitButton .getLayoutParams()).width = LinearLayout.LayoutParams.WRAP_CONTENT; submitButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { final Intent result = new Intent(); result.putExtra("captchaId", captchaId); result.putExtra("captchaText", captchaText.getText().toString()); setResult(RESULT_OK, result); finish(); } }); final ScrollView sv = new ScrollView(CaptchaActivity.this); sv.addView(ll); setContentView(sv); } }); } }); } @Override protected void onCallbackException(Throwable t) { BugReportActivity.handleGlobalError(CaptchaActivity.this, t); } @Override protected void onFailure(RequestFailureType type, Throwable t, StatusLine status, String readableMessage) { final RRError error = General.getGeneralErrorForFailure(CaptchaActivity.this, type, t, status, null); General.showResultDialog(CaptchaActivity.this, error); finish(); } @Override protected void onFailure(APIFailureType type) { final RRError error = General.getGeneralErrorForFailure(CaptchaActivity.this, type); General.showResultDialog(CaptchaActivity.this, error); finish(); } }, selectedAccount, this); }
From source file:com.loloof64.android.capturing_audio.MainActivity.java
public void purposeFileRenaming(final File externalStorageDir, final File tempAudioFile, final Calendar captureStartDate) { AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); dialogBuilder.setTitle(R.string.renaming_temporary_file); final LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.HORIZONTAL); final TextView label = new TextView(this); label.setText(R.string.defining_file_name_label); layout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); final EditText input = new EditText(this); input.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); input.setInputType(InputType.TYPE_CLASS_TEXT); layout.addView(label);/* w ww.j a v a2 s . c om*/ layout.addView(input); dialogBuilder.setView(layout); dialogBuilder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String defaultNameRadix = new SimpleDateFormat(DEFAULT_FILE_NAME_FORMAT, Locale.getDefault()) .format(captureStartDate.getTime()); String nameRadix = input.getText().toString(); if (nameRadix.isEmpty()) { nameRadix = defaultNameRadix; } // Append a number to the name radix if necessary File testedFile = new File(externalStorageDir, String.format(FINAL_FILE_NAME_FORMAT, nameRadix)); boolean fileNameAlreadyUsed = testedFile.exists(); if (fileNameAlreadyUsed) { int number = 1; String chosenNameRadix; while (true) { chosenNameRadix = String.format(Locale.getDefault(), "%s%d", nameRadix, number); testedFile = new File(externalStorageDir, String.format(FINAL_FILE_NAME_FORMAT, chosenNameRadix)); fileNameAlreadyUsed = testedFile.exists(); if (!fileNameAlreadyUsed) break; number++; } nameRadix = chosenNameRadix; } String fileName = String.format(FINAL_FILE_NAME_FORMAT, nameRadix); File newFile = new File(externalStorageDir, fileName); boolean renameSuccess = tempAudioFile.renameTo(newFile); if (renameSuccess) { Toast.makeText(MainActivity.this, R.string.renamed_file, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(MainActivity.this, R.string.file_renaming_failure, Toast.LENGTH_SHORT).show(); } } }); dialogBuilder.show(); }
From source file:org.thoughtcrime.securesms.PassphrasePromptActivity.java
private void setPassphraseVisibility(boolean visibility) { int cursorPosition = passphraseText.getSelectionStart(); if (visibility) { passphraseText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); } else {//from w ww .j a va2 s .com passphraseText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); } passphraseText.setSelection(cursorPosition); }
From source file:org.mozilla.gecko.GeckoPreferences.java
private EditText getTextBox(int aHintText) { EditText input = new EditText(GeckoApp.mAppContext); int inputtype = InputType.TYPE_CLASS_TEXT; inputtype |= InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS; input.setInputType(inputtype);//from w w w . j av a 2s . c om String hint = getResources().getString(aHintText); input.setHint(aHintText); return input; }
From source file:com.nttec.everychan.chans.fourchan.FourchanModule.java
private void addPasscodePreference(PreferenceGroup preferenceGroup) { final Context context = preferenceGroup.getContext(); PreferenceScreen passScreen = preferenceGroup.getPreferenceManager().createPreferenceScreen(context); passScreen.setTitle("4chan pass"); EditTextPreference passTokenPreference = new EditTextPreference(context); EditTextPreference passPINPreference = new EditTextPreference(context); Preference passLoginPreference = new Preference(context); Preference passClearPreference = new Preference(context); passTokenPreference.setTitle("Token"); passTokenPreference.setDialogTitle("Token"); passTokenPreference.setKey(getSharedKey(PREF_KEY_PASS_TOKEN)); passTokenPreference.getEditText().setSingleLine(); passTokenPreference.getEditText()//from ww w .j av a 2s. com .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); passPINPreference.setTitle("PIN"); passPINPreference.setDialogTitle("PIN"); passPINPreference.setKey(getSharedKey(PREF_KEY_PASS_PIN)); passPINPreference.getEditText().setSingleLine(); passPINPreference.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER); passLoginPreference.setTitle("Log In"); passLoginPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { if (!useHttps()) Toast.makeText(context, "Using HTTPS even if HTTP is selected", Toast.LENGTH_SHORT).show(); final String token = preferences.getString(getSharedKey(PREF_KEY_PASS_TOKEN), ""); final String pin = preferences.getString(getSharedKey(PREF_KEY_PASS_PIN), ""); final String authUrl = "https://sys.4chan.org/auth"; //only https final CancellableTask passAuthTask = new CancellableTask.BaseCancellableTask(); final ProgressDialog passAuthProgressDialog = new ProgressDialog(context); passAuthProgressDialog.setMessage("Logging in"); passAuthProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { passAuthTask.cancel(); } }); passAuthProgressDialog.setCanceledOnTouchOutside(false); passAuthProgressDialog.show(); Async.runAsync(new Runnable() { @Override public void run() { try { if (passAuthTask.isCancelled()) return; setPasscodeCookie(null, true); List<NameValuePair> pairs = new ArrayList<NameValuePair>(); pairs.add(new BasicNameValuePair("act", "do_login")); pairs.add(new BasicNameValuePair("id", token)); pairs.add(new BasicNameValuePair("pin", pin)); HttpRequestModel request = HttpRequestModel.builder() .setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).build(); String response = HttpStreamer.getInstance().getStringFromUrl(authUrl, request, httpClient, null, passAuthTask, false); if (passAuthTask.isCancelled()) return; if (response.contains("Your device is now authorized")) { String passId = null; for (Cookie cookie : httpClient.getCookieStore().getCookies()) { if (cookie.getName().equals("pass_id")) { String value = cookie.getValue(); if (!value.equals("0")) { passId = value; break; } } } if (passId == null) { showToast("Could not get pass id"); } else { setPasscodeCookie(passId, true); showToast("Success! Your device is now authorized."); } } else if (response.contains("Your Token must be exactly 10 characters")) { showToast("Incorrect token"); } else if (response.contains("You have left one or more fields blank")) { showToast("You have left one or more fields blank"); } else if (response.contains("Incorrect Token or PIN")) { showToast("Incorrect Token or PIN"); } else { Matcher m = Pattern .compile("<strong style=\"color: red; font-size: larger;\">(.*?)</strong>") .matcher(response); if (m.find()) { showToast(m.group(1)); } else { showWebView(response); } } } catch (Exception e) { showToast(e.getMessage() == null ? resources.getString(R.string.error_unknown) : e.getMessage()); } finally { passAuthProgressDialog.dismiss(); } } private void showToast(final String message) { if (context instanceof Activity) { ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(context, message, Toast.LENGTH_LONG).show(); } }); } } private void showWebView(final String html) { if (context instanceof Activity) { ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { WebView webView = new WebView(context); webView.getSettings().setSupportZoom(true); webView.loadData(html, "text/html", null); new AlertDialog.Builder(context).setView(webView) .setNeutralButton(android.R.string.ok, null).show(); } }); } } }); return true; } }); passClearPreference.setTitle("Reset pass cookie"); passClearPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { setPasscodeCookie(null, true); Toast.makeText(context, "Cookie is reset", Toast.LENGTH_LONG).show(); return true; } }); passScreen.addPreference(passTokenPreference); passScreen.addPreference(passPINPreference); passScreen.addPreference(passLoginPreference); passScreen.addPreference(passClearPreference); preferenceGroup.addPreference(passScreen); }
From source file:support.plus.reportit.SettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // Default config if (savedInstanceState != null) { // Restore value of members from saved state userName = savedInstanceState.getString(userName); userBossName = savedInstanceState.getString(userBossName); } else {/*from w w w. j ava 2 s . co m*/ // Probably initialize members with default values for a new instance } super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); Toolbar toolbar = (Toolbar) findViewById(R.id.settings_toolbar); setSupportActionBar(toolbar); toolbar.setTitle(R.string.app_name); toolbar.setNavigationIcon(R.drawable.ic_back); final TextView TextuserName = (TextView) findViewById(R.id.userName); final TextView TextuserBossName = (TextView) findViewById(R.id.userBossName); final EditText inuserName = (EditText) findViewById(R.id.inuserName); final EditText inuserBossName = (EditText) findViewById(R.id.inuserBossName); final Switch sNoti = (Switch) findViewById(R.id.sNoti); final Button btimePick = (Button) findViewById(R.id.btimePick); final Button bSave = (Button) findViewById(R.id.bSave); final Switch sfingerprint_activ = (Switch) findViewById(R.id.sfingerprint_activ); final Button bsetpassword = (Button) findViewById(R.id.bsetpassword); final Switch sdarkTheme = (Switch) findViewById(R.id.sdarkTheme); final Button bchooseRingtone = (Button) findViewById(R.id.bringtonePick); final SharedPreferences pref3 = getSharedPreferences("Theme", Context.MODE_PRIVATE); Boolean themeDark = pref3.getBoolean("darkTheme", false); if (themeDark == true) { sdarkTheme.setChecked(true); } else { sdarkTheme.setChecked(false); } sdarkTheme.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { final SharedPreferences pref3 = getSharedPreferences("Theme", Context.MODE_PRIVATE); SharedPreferences.Editor editor = pref3.edit(); editor.putBoolean("darkTheme", true); editor.commit(); getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES); // Now recreate for it to take effect // startActivity(getIntent()); recreate(); } else { SharedPreferences.Editor editor = pref3.edit(); editor.putBoolean("darkTheme", false); editor.commit(); getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_AUTO); // Now recreate for it to take effect // startActivity(getIntent()); recreate(); } } }); /* SECURITY SETTINGS */ final SharedPreferences pref1 = getSharedPreferences("Fingerprint", Context.MODE_PRIVATE); Boolean fingerprintSet = pref1.getBoolean("fingerprintSet", false); if (fingerprintSet == true) { sfingerprint_activ.setChecked(true); bsetpassword.setVisibility(View.VISIBLE); } else { sfingerprint_activ.setChecked(false); bsetpassword.setVisibility(View.GONE); } sfingerprint_activ.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { SharedPreferences.Editor editor = pref1.edit(); editor.putBoolean("fingerprintSet", true); editor.commit(); bsetpassword.setVisibility(View.VISIBLE); } else { SharedPreferences.Editor editor = pref1.edit(); editor.putBoolean("fingerprintSet", false); editor.commit(); bsetpassword.setVisibility(View.GONE); } } }); bsetpassword.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new MaterialDialog.Builder(SettingsActivity.this).title(R.string.set_password) .content(R.string.set_password_desc) .inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD) .inputRange(1, 10) .input(getString(R.string.password), "", new MaterialDialog.InputCallback() { @Override public void onInput(MaterialDialog dialog, CharSequence input) { String name = String.valueOf(input); SharedPreferences pref1 = getSharedPreferences("Fingerprint", Context.MODE_PRIVATE); SharedPreferences.Editor editor = pref1.edit(); editor.putString("passwordSet", name); editor.commit(); return; } }).positiveText(R.string.set_password).negativeText(R.string.cancel).cancelable(false) .show(); } }); /* END SECURITY SETTINGS */ /* NOTIFICATION SETTINGS */ btimePick.setVisibility(View.GONE); sNoti.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { btimePick.setVisibility(View.VISIBLE); bchooseRingtone.setVisibility(View.VISIBLE); } else { btimePick.setVisibility(View.GONE); bchooseRingtone.setVisibility(View.GONE); } } }); final SharedPreferences pref4 = getApplicationContext().getSharedPreferences("userNotification", MODE_PRIVATE); Boolean notificationSet = pref4.getBoolean("alarmSet", false); if (notificationSet == true) { sNoti.setChecked(true); btimePick.setVisibility(View.VISIBLE); bchooseRingtone.setVisibility(View.VISIBLE); } else { sNoti.setChecked(false); btimePick.setVisibility(View.GONE); bchooseRingtone.setVisibility(View.GONE); } sNoti.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { SharedPreferences.Editor editor = pref4.edit(); editor.putBoolean("alarmSet", true); editor.commit(); btimePick.setVisibility(View.VISIBLE); bchooseRingtone.setVisibility(View.VISIBLE); } else { SharedPreferences.Editor editor = pref4.edit(); editor.putBoolean("alarmSet", false); editor.commit(); btimePick.setVisibility(View.GONE); bchooseRingtone.setVisibility(View.GONE); } } }); bchooseRingtone.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, R.string.choose_ringtone); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null); startActivityForResult(intent, 5); } }); btimePick.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DialogFragment newFragment = new TimePickerFragment(); newFragment.show(getSupportFragmentManager(), "timePicker"); } }); /* END NOTIFICATION SETTINGS */ /* SAVE SETTINGS */ bSave.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String saveworkplace = "Student"; String saveuserBossName = "Boss"; saveworkplace = inuserName.getText().toString(); saveuserBossName = inuserBossName.getText().toString(); TextuserName.setText(getString(R.string.firm_name) + String.valueOf(saveworkplace)); TextuserBossName.setText(getString(R.string.instructor_name) + String.valueOf(saveuserBossName)); final SharedPreferences pref2 = getApplicationContext().getSharedPreferences("userData", MODE_APPEND); SharedPreferences.Editor editor = pref2.edit(); editor.putString("userName", saveworkplace); editor.putString("userBoss", saveuserBossName); editor.putBoolean("data_saved", true); editor.commit(); Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content), "Data saved. Restart the app to see changes.", Snackbar.LENGTH_LONG); snackbar.show(); // finish(); startActivity(getIntent()); } }); final SharedPreferences pref2 = getApplicationContext().getSharedPreferences("userData", MODE_APPEND); if (pref2.getBoolean("data_saved", true)) { String TextuserNameString = pref2.getString("userName", ""); String TextuserBossNameString = pref2.getString("userBoss", ""); TextuserName.setText(getString(R.string.firm_name) + String.valueOf(TextuserNameString)); TextuserBossName.setText(getString(R.string.instructor_name) + String.valueOf(TextuserBossNameString)); inuserName.setVisibility(View.GONE); inuserBossName.setVisibility(View.GONE); bSave.setVisibility(View.GONE); } else { Toast toast = Toast.makeText(this, "No data saved", Toast.LENGTH_SHORT); toast.show(); } /* END SAVE SETTINGS */ }
From source file:com.nttec.everychan.chans.dvach.DvachModule.java
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { Context context = preferenceGroup.getContext(); addPasswordPreference(preferenceGroup); CheckBoxPreference onionPref = new LazyPreferences.CheckBoxPreference(context); onionPref.setTitle(R.string.pref_use_onion); onionPref.setSummary(R.string.pref_use_onion_summary); onionPref.setKey(getSharedKey(PREF_KEY_USE_ONION)); onionPref.setDefaultValue(false);//from w ww .ja v a2 s . com onionPref.setDisableDependentsState(true); preferenceGroup.addPreference(onionPref); EditTextPreference domainPref = new EditTextPreference(context); domainPref.setTitle(R.string.pref_domain); domainPref.setDialogTitle(R.string.pref_domain); domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT)); 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); preferenceGroup.addPreference(domainPref); domainPref.setDependency(getSharedKey(PREF_KEY_USE_ONION)); addProxyPreferences(preferenceGroup); }
From source file:com.simplealertdialog.sample.demos.SupportActivity.java
protected void initButtons() { findViewById(R.id.btn_message).setOnClickListener(new View.OnClickListener() { @Override//from w w w. j a v a 2s . c o m public void onClick(final View v) { new SimpleAlertDialogSupportFragment.Builder().setMessage("Hello world!") .setPositiveButton(android.R.string.ok).create() .show(getSupportFragmentManager(), "dialog"); } }); findViewById(R.id.btn_message_title).setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { TypedArray a = getTheme().obtainStyledAttributes(new int[] { R.attr.icon }); int iconResId = a.getResourceId(0, 0); a.recycle(); new SimpleAlertDialogSupportFragment.Builder().setTitle("Hello world!").setIcon(iconResId) .setMessage("Hello world!").setPositiveButton(android.R.string.ok).create() .show(getSupportFragmentManager(), "dialog"); } }); findViewById(R.id.btn_buttons).setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { new SimpleAlertDialogSupportFragment.Builder().setTitle("Hello world!").setMessage("Hello world!") .setPositiveButton(android.R.string.ok).setNegativeButton(android.R.string.cancel) .setRequestCode(REQUEST_CODE_BUTTONS).create().show(getSupportFragmentManager(), "dialog"); } }); findViewById(R.id.btn_3_buttons).setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { new SimpleAlertDialogSupportFragment.Builder().setTitle("Hello world!").setMessage("Hello world!") .setPositiveButton(android.R.string.ok).setNegativeButton(android.R.string.cancel) .setNeutralButton(R.string.neutral).setRequestCode(REQUEST_CODE_3_BUTTONS).create() .show(getSupportFragmentManager(), "dialog"); } }); findViewById(R.id.btn_items).setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { new SimpleAlertDialogSupportFragment.Builder().setTitle("Choose one") .setItems(R.array.single_choice).setRequestCode(REQUEST_CODE_ITEMS).create() .show(getSupportFragmentManager(), "dialog"); } }); findViewById(R.id.btn_icon_items).setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { new SimpleAlertDialogSupportFragment.Builder().setTitle("Choose one") .setItems(R.array.icon_items, getIcons()).setRequestCode(REQUEST_CODE_ICON_ITEMS).create() .show(getSupportFragmentManager(), "dialog"); } }); findViewById(R.id.btn_single_choice_list).setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { new SimpleAlertDialogSupportFragment.Builder().setTitle("Choose one").setSingleChoiceCheckedItem(0) .setRequestCode(REQUEST_CODE_SINGLE_CHOICE_LIST).create() .show(getSupportFragmentManager(), "dialog"); } }); findViewById(R.id.btn_adapter).setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { new SimpleAlertDialogSupportFragment.Builder().setTitle("Choose your favorite").setUseAdapter(true) .setRequestCode(REQUEST_CODE_ADAPTER).create().show(getSupportFragmentManager(), "dialog"); } }); findViewById(R.id.btn_view).setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { new SimpleAlertDialogSupportFragment.Builder().setTitle("Enter something").setUseView(true) .setPositiveButton(android.R.string.ok).setRequestCode(REQUEST_CODE_VIEW).create() .show(getSupportFragmentManager(), "dialog"); } }); findViewById(R.id.btn_edit_text).setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { new SimpleAlertDialogSupportFragment.Builder().setTitle("Enter password") .setEditText("", InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD) .setPositiveButton(android.R.string.ok).setRequestCode(REQUEST_CODE_EDIT_TEXT).create() .show(getSupportFragmentManager(), "dialog"); } }); findViewById(R.id.btn_themed).setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { new SimpleAlertDialogSupportFragment.Builder().setTheme(R.style.SimpleAlertDialogCustomTheme) .setMessage("Hello world!").setPositiveButton(android.R.string.ok).create() .show(getSupportFragmentManager(), "dialog"); } }); }
From source file:org.openmrs.mobile.activities.login.LoginFragment.java
private void initListeners() { mLoginSyncButton.setOnClickListener(new View.OnClickListener() { @Override//from www .j a va 2s . c o m public void onClick(View view) { final SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(OpenMRS.getInstance()); boolean syncState = prefs.getBoolean("sync", true); SharedPreferences.Editor editor = PreferenceManager .getDefaultSharedPreferences(OpenMRS.getInstance()).edit(); editor.putBoolean("sync", !syncState); editor.commit(); setSyncButtonState(!syncState); } }); loginValidatorWatcher = new LoginValidatorWatcher(mUrl, mUsername, mPassword, mDropdownLocation, mLoginButton); mUrl.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean b) { if (StringUtils.notEmpty(mUrl.getText().toString()) && !view.isFocused() && loginValidatorWatcher.isUrlChanged() || (loginValidatorWatcher.isUrlChanged() && !view.isFocused() && loginValidatorWatcher.isLocationErrorOccurred()) || (!loginValidatorWatcher.isUrlChanged() && !view.isFocused())) { ((LoginFragment) getActivity().getSupportFragmentManager() .findFragmentById(R.id.loginContentFrame)).setUrl(mUrl.getText().toString()); loginValidatorWatcher.setUrlChanged(false); } } }); mLoginButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mPresenter.login(mUsername.getText().toString(), mPassword.getText().toString(), mUrl.getText().toString(), initialUrl); } }); mForgotPass.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { forgotPassword(); } }); mShowPassword.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { mPassword.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); } else { mPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); } } }); }
From source file:eu.codeplumbers.cosi.fragments.LoyaltyCardListFragment.java
private void showLoyaltyCardDetailsDialog(final Barcode barcode) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(getString(R.string.lbl_loyalty_card_new)); // Set up the input final EditText cardName = new EditText(getActivity()); // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text cardName.setInputType(InputType.TYPE_CLASS_TEXT); builder.setView(cardName);//from ww w.j a v a 2s . c o m // Set up the buttons builder.setPositiveButton(getString(R.string.SAVE), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String m_Text = cardName.getText().toString(); if (m_Text.isEmpty()) { cardName.setError(getString(R.string.lbl_loyalty_cards_name_empty)); } else { Log.d(TAG, barcode.rawValue); LoyaltyCard loyaltyCard = LoyaltyCard.getByRawValue(barcode.rawValue); if (loyaltyCard == null) { loyaltyCard = new LoyaltyCard(); loyaltyCard.setCode(barcode.format); loyaltyCard.setCreationDate(DateUtils.formatDate(new Date().getTime())); loyaltyCard.setLabel(m_Text); loyaltyCard.setRawValue(barcode.rawValue); loyaltyCard.setRemoteId(""); loyaltyCard.setDeviceId(Device.registeredDevice().getLogin()); loyaltyCard.save(); } } } }); builder.setNegativeButton(getString(R.string.CANCEL), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.show(); }