List of usage examples for android.view.inputmethod EditorInfo IME_ACTION_DONE
int IME_ACTION_DONE
To view the source code for android.view.inputmethod EditorInfo IME_ACTION_DONE.
Click Source Link
From source file:com.owncloud.android.authentication.AuthenticatorActivity.java
/** * {@inheritDoc}//from w ww . j av a 2 s. c o m * * IMPORTANT ENTRY POINT 1: activity is shown to the user */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.account_setup); mAuthMessage = (TextView) findViewById(R.id.auth_message); mHostUrlInput = (EditText) findViewById(R.id.hostUrlInput); mHostUrlInput.setText(getString(R.string.server_url)); // valid although // R.string.server_url // is an empty // string mUsernameInput = (EditText) findViewById(R.id.account_username); mPasswordInput = (EditText) findViewById(R.id.account_password); mPasswordInput2 = (EditText) findViewById(R.id.account_password2); mOAuthAuthEndpointText = (TextView) findViewById(R.id.oAuthEntryPoint_1); mOAuthTokenEndpointText = (TextView) findViewById(R.id.oAuthEntryPoint_2); mOAuth2Check = (CheckBox) findViewById(R.id.oauth_onOff_check); mOkButton = findViewById(R.id.buttonOK); mAuthStatusLayout = (TextView) findViewById(R.id.auth_status_text); // / set Host Url Input Enabled mHostUrlInputEnabled = getResources().getBoolean(R.bool.show_server_url_input); locationSpinner = (Spinner) findViewById(R.id.spinner1); // / complete label for 'register account' button Button b = (Button) findViewById(R.id.account_register); if (b != null) { b.setText(String.format(getString(R.string.auth_register), getString(R.string.app_name))); } // / initialization mAccountMgr = AccountManager.get(this); mNewCapturedUriFromOAuth2Redirection = null; mAction = getIntent().getByteExtra(EXTRA_ACTION, ACTION_CREATE); mAccount = null; mHostBaseUrl = ""; location = " ";//locationSpinner.getSelectedItem(); locationSpinner.setOnItemSelectedListener(this); boolean refreshButtonEnabled = false; // URL input configuration applied if (!mHostUrlInputEnabled) { findViewById(R.id.hostUrlFrame).setVisibility(View.GONE); mRefreshButton = findViewById(R.id.centeredRefreshButton); } else { mRefreshButton = findViewById(R.id.embeddedRefreshButton); } if (savedInstanceState == null) { mResumed = false; // / connection state and info mAuthMessageVisibility = View.GONE; mServerStatusText = mServerStatusIcon = 0; mServerIsValid = false; mServerIsChecked = false; mIsSslConn = false; mAuthStatusText = mAuthStatusIcon = 0; // / retrieve extras from intent mAccount = getIntent().getExtras().getParcelable(EXTRA_ACCOUNT); if (mAccount != null) { String ocVersion = mAccountMgr.getUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION); Log.d("!!!!!!!!!!!!!!!!!!!!!!!!! ", mAccount.name); if (ocVersion != null) { mDiscoveredVersion = new OwnCloudVersion(ocVersion); } mHostBaseUrl = normalizeUrl( mAccountMgr.getUserData(mAccount, AccountAuthenticator.KEY_OC_BASE_URL)); mHostUrlInput.setText(mHostBaseUrl); String userName = mAccount.name.substring(0, mAccount.name.lastIndexOf('@')); Log.d("!!!!!!!!!!!!!!!!!!!!!!!!!4234 ", userName); mUsernameInput.setText(userName); } initAuthorizationMethod(); // checks intent and setup.xml to // determine mCurrentAuthorizationMethod mJustCreated = true; if (mAction == ACTION_UPDATE_TOKEN || !mHostUrlInputEnabled) { checkOcServer(); } } else { mResumed = true; // / connection state and info mAuthMessageVisibility = savedInstanceState.getInt(KEY_AUTH_MESSAGE_VISIBILITY); mAuthMessageText = savedInstanceState.getString(KEY_AUTH_MESSAGE_TEXT); mServerIsValid = savedInstanceState.getBoolean(KEY_SERVER_VALID); mServerIsChecked = savedInstanceState.getBoolean(KEY_SERVER_CHECKED); mServerStatusText = savedInstanceState.getInt(KEY_SERVER_STATUS_TEXT); mServerStatusIcon = savedInstanceState.getInt(KEY_SERVER_STATUS_ICON); mIsSslConn = savedInstanceState.getBoolean(KEY_IS_SSL_CONN); mAuthStatusText = savedInstanceState.getInt(KEY_AUTH_STATUS_TEXT); mAuthStatusIcon = savedInstanceState.getInt(KEY_AUTH_STATUS_ICON); if (savedInstanceState.getBoolean(KEY_PASSWORD_VISIBLE, false)) { showPassword(); } // / server data String ocVersion = savedInstanceState.getString(KEY_OC_VERSION); if (ocVersion != null) { mDiscoveredVersion = new OwnCloudVersion(ocVersion); } mHostBaseUrl = savedInstanceState.getString(KEY_HOST_URL_TEXT); // account data, if updating mAccount = savedInstanceState.getParcelable(KEY_ACCOUNT); // Log.d("////////////////// ",mAccount.name); mAuthTokenType = savedInstanceState.getString(AccountAuthenticator.KEY_AUTH_TOKEN_TYPE); if (mAuthTokenType == null) { mAuthTokenType = AccountAuthenticator.AUTH_TOKEN_TYPE_PASSWORD; } // check if server check was interrupted by a configuration change if (savedInstanceState.getBoolean(KEY_SERVER_CHECK_IN_PROGRESS, false)) { checkOcServer(); } // refresh button enabled refreshButtonEnabled = savedInstanceState.getBoolean(KEY_REFRESH_BUTTON_ENABLED); } if (mAuthMessageVisibility == View.VISIBLE) { showAuthMessage(mAuthMessageText); } else { hideAuthMessage(); } adaptViewAccordingToAuthenticationMethod(); showServerStatus(); showAuthStatus(); if (mAction == ACTION_UPDATE_TOKEN) { // / lock things that should not change mHostUrlInput.setEnabled(false); mHostUrlInput.setFocusable(false); mUsernameInput.setEnabled(false); mUsernameInput.setFocusable(false); mOAuth2Check.setVisibility(View.GONE); } // if (mServerIsChecked && !mServerIsValid && mRefreshButtonEnabled) // showRefreshButton(); if (mServerIsChecked && !mServerIsValid && refreshButtonEnabled) showRefreshButton(); mOkButton.setEnabled(mServerIsValid); // state not automatically // recovered in configuration // changes if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mAuthTokenType) || !AUTH_OPTIONAL.equals(getString(R.string.auth_method_oauth2))) { mOAuth2Check.setVisibility(View.GONE); } mPasswordInput.setText(""); // clean password to avoid social hacking // (disadvantage: password in removed if the // device is turned aside) // / bind view elements to listeners and other friends mHostUrlInput.setOnFocusChangeListener(this); mHostUrlInput.setImeOptions(EditorInfo.IME_ACTION_NEXT); mHostUrlInput.setOnEditorActionListener(this); mHostUrlInput.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (!mHostBaseUrl.equals(normalizeUrl(mHostUrlInput.getText().toString()))) { mOkButton.setEnabled(false); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (!mResumed) { mAuthStatusIcon = 0; mAuthStatusText = 0; showAuthStatus(); } mResumed = false; } }); 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; } }); findViewById(R.id.scroll).setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mAuthTokenType) && mHostUrlInput.hasFocus()) { checkOcServer(); } } return false; } }); }
From source file:edu.usf.cutr.opentripplanner.android.fragments.MainFragment.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override/*from w w w.j a va 2 s . c o m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View mainView = inflater.inflate(R.layout.main, container, false); if (mainView != null) { ViewTreeObserver vto = mainView.getViewTreeObserver(); if (vto != null) { vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override public void onGlobalLayout() { MainFragment.removeOnGlobalLayoutListener(mainView, this); int locationTbEndLocation[] = new int[2]; mTbEndLocation.getLocationInWindow(locationTbEndLocation); int locationItinerarySelectionSpinner[] = new int[2]; mItinerarySelectionSpinner.getLocationInWindow(locationItinerarySelectionSpinner); int locationBtnHandle[] = new int[2]; mBtnHandle.getLocationInWindow(locationBtnHandle); DisplayMetrics metrics = MainFragment.this.getResources().getDisplayMetrics(); int windowHeight = metrics.heightPixels; int paddingMargin = MainFragment.this.getResources() .getInteger(R.integer.map_padding_margin); if (mMap != null) { mMap.setPadding(locationBtnHandle[0] + mBtnHandle.getWidth() / 2 + paddingMargin, locationTbEndLocation[1] + mTbEndLocation.getHeight() / 2 + paddingMargin, 0, windowHeight - locationItinerarySelectionSpinner[1] + paddingMargin); } } }); } else { Log.w(OTPApp.TAG, "Not possible to obtain exact element's positions on screen, some other" + "elements can be misplaced"); } mTbStartLocation = (EditText) mainView.findViewById(R.id.tbStartLocation); mTbEndLocation = (EditText) mainView.findViewById(R.id.tbEndLocation); mBtnPlanTrip = (ImageButton) mainView.findViewById(R.id.btnPlanTrip); mDdlOptimization = (ListView) mainView.findViewById(R.id.spinOptimization); mDdlTravelMode = (ListView) mainView.findViewById(R.id.spinTravelMode); mBikeTriangleParameters = new RangeSeekBar<Double>(OTPApp.BIKE_PARAMETERS_MIN_VALUE, OTPApp.BIKE_PARAMETERS_MAX_VALUE, this.getActivity().getApplicationContext(), R.color.sysRed, R.color.sysGreen, R.color.sysBlue, R.drawable.seek_thumb_normal, R.drawable.seek_thumb_pressed); // add RangeSeekBar to pre-defined layout mBikeTriangleParametersLayout = (ViewGroup) mainView.findViewById(R.id.bikeParametersLayout); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.BELOW, R.id.bikeParametersTags); mBikeTriangleParametersLayout.addView(mBikeTriangleParameters, params); mBtnMyLocation = (ImageButton) mainView.findViewById(R.id.btnMyLocation); mBtnDateDialog = (ImageButton) mainView.findViewById(R.id.btnDateDialog); mBtnDisplayDirection = (ImageButton) mainView.findViewById(R.id.btnDisplayDirection); mNavigationDrawerLeftPane = (ViewGroup) mainView.findViewById(R.id.navigationDrawerLeftPane); mPanelDisplayDirection = mainView.findViewById(R.id.panelDisplayDirection); mBtnHandle = (ImageButton) mainView.findViewById(R.id.btnHandle); mDrawerLayout = (DrawerLayout) mainView.findViewById(R.id.drawerLayout); mTbStartLocation.setImeOptions(EditorInfo.IME_ACTION_NEXT); mTbEndLocation.setImeOptions(EditorInfo.IME_ACTION_DONE); mTbEndLocation.requestFocus(); mItinerarySelectionSpinner = (Spinner) mainView.findViewById(R.id.itinerarySelection); Log.v(OTPApp.TAG, "finish onStart()"); if (Build.VERSION.SDK_INT > 11) { LayoutTransition l = new LayoutTransition(); ViewGroup mainButtons = (ViewGroup) mainView.findViewById(R.id.content_frame); mainButtons.setLayoutTransition(l); } return mainView; } else { Log.e(OTPApp.TAG, "Not possible to obtain main view, UI won't be correctly created"); return null; } }
From source file:com.brewcrewfoo.performance.fragments.MemSettings.java
public void openDialog(final int idx, int currentProgress, String title, final int min, final int max, final Preference pref, final String path, final String key) { Resources res = getActivity().getResources(); String cancel = res.getString(R.string.cancel); String ok = res.getString(R.string.ok); LayoutInflater factory = LayoutInflater.from(getActivity()); final View alphaDialog = factory.inflate(R.layout.seekbar_dialog, null); final SeekBar seekbar = (SeekBar) alphaDialog.findViewById(R.id.seek_bar); seekbar.setMax(max);// ww w .j av a 2 s .c o m seekbar.setProgress(currentProgress); settingText = (EditText) alphaDialog.findViewById(R.id.setting_text); settingText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { int val = Integer.parseInt(settingText.getText().toString()); seekbar.setProgress(val); return true; } return false; } }); settingText.setText(Integer.toString(currentProgress)); settingText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { try { int val = Integer.parseInt(s.toString()); if (val > max) { s.replace(0, s.length(), Integer.toString(max)); val = max; } seekbar.setProgress(val); } catch (NumberFormatException ex) { } } }); OnSeekBarChangeListener seekBarChangeListener = new OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekbar, int progress, boolean fromUser) { mSeekbarProgress = seekbar.getProgress(); if (fromUser) { settingText.setText(Integer.toString(mSeekbarProgress)); } } @Override public void onStopTrackingTouch(SeekBar seekbar) { } @Override public void onStartTrackingTouch(SeekBar seekbar) { } }; seekbar.setOnSeekBarChangeListener(seekBarChangeListener); new AlertDialog.Builder(getActivity()).setTitle(title).setView(alphaDialog) .setNegativeButton(cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // nothing } }).setPositiveButton(ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { int val = Integer.parseInt(settingText.getText().toString()); if (val < min) { val = min; } seekbar.setProgress(val); int newProgress = seekbar.getProgress(); values[idx] = Integer.toString(newProgress * 256); pref.setSummary(newProgress + " MB " + "(" + values[idx] + ")"); new CMDProcessor().su .runWaitFor("busybox echo " + implodeArray(values, ",") + " > " + path); final SharedPreferences.Editor editor = mPreferences.edit(); editor.putString(key, implodeArray(values, ",")); editor.commit(); } }).create().show(); }
From source file:com.joeyturczak.jtscanner.ui.ScannerFragment.java
@Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_NEXT) { if (mPrefAllowManual) { handleScanResult(v.getText().toString()); } else {/*from w w w . j a v a 2 s .c om*/ showScanToast(TOAST_NO_MANUAL, ""); } } return true; }
From source file:group.pals.android.lib.ui.filechooser.utils.ui.bookmark.BookmarkFragment.java
/** * Shows a dialog to let user enter new name or change current name of a * bookmark.//ww w. ja v a 2s .com * * @param context * {@link Context} * @param providerId * the provider ID. * @param id * the bookmark ID. * @param uri * the URI to the bookmark. * @param name * the name. To enter new name, this is the suggested name you * provide. To rename, this is the old name. */ public static void doEnterNewNameOrRenameBookmark(final Context context, final String providerId, final int id, final Uri uri, final String name) { final AlertDialog dialog = Dlg.newDlg(context); View view = LayoutInflater.from(context).inflate(R.layout.afc_simple_text_input_view, null); final EditText textName = (EditText) view.findViewById(R.id.afc_text1); textName.setText(name); textName.selectAll(); textName.setHint(R.string.afc_hint_new_name); textName.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { Ui.showSoftKeyboard(textName, false); Button btn = dialog.getButton(DialogInterface.BUTTON_POSITIVE); if (btn.isEnabled()) btn.performClick(); return true; } return false; }// onEditorAction() }); dialog.setView(view); dialog.setIcon(R.drawable.afc_bookmarks_dark); dialog.setTitle(id < 0 ? R.string.afc_title_new_bookmark : R.string.afc_title_rename); dialog.setButton(DialogInterface.BUTTON_POSITIVE, context.getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String newName = textName.getText().toString().trim(); if (android.text.TextUtils.isEmpty(newName)) { Dlg.toast(context, R.string.afc_msg_bookmark_name_is_invalid, Dlg._LengthShort); return; } Ui.showSoftKeyboard(textName, false); ContentValues values = new ContentValues(); values.put(BookmarkContract.Bookmark._ColumnName, newName); if (id >= 0) { values.put(BookmarkContract.Bookmark._ColumnModificationTime, DbUtils.formatNumber(new Date().getTime())); context.getContentResolver() .update(Uri.withAppendedPath(BookmarkContract.Bookmark._ContentIdUriBase, Uri.encode(Integer.toString(id))), values, null, null); } else { /* * Check if the URI exists or doesn't. If it exists, * update it instead of inserting the new one. */ Cursor cursor = context.getContentResolver().query( BookmarkContract.Bookmark._ContentUri, null, String.format("%s = %s AND %s LIKE %s", BookmarkContract.Bookmark._ColumnProviderId, DatabaseUtils.sqlEscapeString(providerId), BookmarkContract.Bookmark._ColumnUri, DatabaseUtils.sqlEscapeString(uri.toString())), null, null); try { if (cursor != null && cursor.moveToFirst()) { values.put(BookmarkContract.Bookmark._ColumnModificationTime, DbUtils.formatNumber(new Date().getTime())); context.getContentResolver().update( Uri.withAppendedPath(BookmarkContract.Bookmark._ContentIdUriBase, Uri.encode(cursor.getString( cursor.getColumnIndex(BookmarkContract.Bookmark._ID)))), values, null, null); } else { values.put(BookmarkContract.Bookmark._ColumnProviderId, providerId); values.put(BookmarkContract.Bookmark._ColumnUri, uri.toString()); context.getContentResolver().insert(BookmarkContract.Bookmark._ContentUri, values); } } finally { if (cursor != null) cursor.close(); } } Dlg.toast(context, context.getString(R.string.afc_msg_done), Dlg._LengthShort); }// onClick() }); dialog.show(); Ui.showSoftKeyboard(textName, true); final Button buttonOk = dialog.getButton(DialogInterface.BUTTON_POSITIVE); buttonOk.setEnabled(id < 0); textName.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { String newName = s.toString().trim(); boolean enabled = !android.text.TextUtils.isEmpty(newName); buttonOk.setEnabled(enabled); /* * If renaming, only enable button OK if new name is not equal * to the old one. */ if (enabled && id >= 0) buttonOk.setEnabled(!newName.equals(name)); } }); }
From source file:com.haibison.android.anhuu.utils.ui.bookmark.BookmarkFragment.java
/** * Shows a dialog to let the user enter new name or change current name of a * bookmark./*from w w w . ja va2s . c o m*/ * * @param context * {@link Context} * @param providerId * the provider ID. * @param id * the bookmark ID. * @param uri * the URI to the bookmark. * @param name * the name. To enter new name, this is the suggested name you * provide. To rename, this is the old name. */ public static void doEnterNewNameOrRenameBookmark(final Context context, final String providerId, final int id, final Uri uri, final String name) { final AlertDialog dialog = Dlg.newAlertDlg(context); View view = LayoutInflater.from(context).inflate(R.layout.anhuu_f5be488d_simple_text_input_view, null); final EditText textName = (EditText) view.findViewById(R.id.anhuu_f5be488d_text1); textName.setText(name); textName.selectAll(); textName.setHint(R.string.anhuu_f5be488d_hint_new_name); textName.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { UI.showSoftKeyboard(textName, false); Button btn = dialog.getButton(DialogInterface.BUTTON_POSITIVE); if (btn.isEnabled()) btn.performClick(); return true; } return false; }// onEditorAction() }); dialog.setView(view); dialog.setIcon(R.drawable.anhuu_f5be488d_bookmarks_dark); dialog.setTitle(id < 0 ? R.string.anhuu_f5be488d_title_new_bookmark : R.string.anhuu_f5be488d_title_rename); dialog.setButton(DialogInterface.BUTTON_POSITIVE, context.getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String newName = textName.getText().toString().trim(); if (android.text.TextUtils.isEmpty(newName)) { Dlg.toast(context, R.string.anhuu_f5be488d_msg_bookmark_name_is_invalid, Dlg.LENGTH_SHORT); return; } UI.showSoftKeyboard(textName, false); ContentValues values = new ContentValues(); values.put(BookmarkContract.COLUMN_NAME, newName); if (id >= 0) { values.put(BookmarkContract.COLUMN_MODIFICATION_TIME, DbUtils.formatNumber(new Date().getTime())); context.getContentResolver().update( ContentUris.withAppendedId(BookmarkContract.genContentIdUriBase(context), id), values, null, null); } else { /* * Check if the URI exists or doesn't. If it exists, * update it instead of inserting the new one. */ Cursor cursor = context.getContentResolver().query( BookmarkContract.genContentUri(context), null, String.format("%s = %s AND %s LIKE %s", BookmarkContract.COLUMN_PROVIDER_ID, DatabaseUtils.sqlEscapeString(providerId), BookmarkContract.COLUMN_URI, DatabaseUtils.sqlEscapeString(uri.toString())), null, null); try { if (cursor != null && cursor.moveToFirst()) { values.put(BookmarkContract.COLUMN_MODIFICATION_TIME, DbUtils.formatNumber(new Date().getTime())); context.getContentResolver().update( Uri.withAppendedPath(BookmarkContract.genContentIdUriBase(context), Uri.encode(cursor.getString( cursor.getColumnIndex(BookmarkContract._ID)))), values, null, null); } else { values.put(BookmarkContract.COLUMN_PROVIDER_ID, providerId); values.put(BookmarkContract.COLUMN_URI, uri.toString()); context.getContentResolver().insert(BookmarkContract.genContentUri(context), values); } } finally { if (cursor != null) cursor.close(); } } Dlg.toast(context, context.getString(R.string.anhuu_f5be488d_msg_done), Dlg.LENGTH_SHORT); }// onClick() }); dialog.show(); UI.showSoftKeyboard(textName, true); final Button buttonOk = dialog.getButton(DialogInterface.BUTTON_POSITIVE); buttonOk.setEnabled(id < 0); textName.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { String newName = s.toString().trim(); boolean enabled = !android.text.TextUtils.isEmpty(newName); buttonOk.setEnabled(enabled); /* * If renaming, only enable button OK if new name is not equal * to the old one. */ if (enabled && id >= 0) buttonOk.setEnabled(!newName.equals(name)); } }); }
From source file:org.akvo.caddisfly.ui.activity.MainActivity.java
public void onSaveCalibration() { final Context context = this; final MainApp mainApp = (MainApp) this.getApplicationContext(); final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context); final EditText input = new EditText(context); input.setInputType(InputType.TYPE_CLASS_TEXT); input.setFilters(new InputFilter[] { new InputFilter.LengthFilter(22) }); alertDialogBuilder.setView(input);/*from w w w . ja v a 2s. c om*/ alertDialogBuilder.setCancelable(false); alertDialogBuilder.setTitle(R.string.saveCalibration); alertDialogBuilder.setMessage(R.string.giveNameForCalibration); alertDialogBuilder.setPositiveButton(R.string.ok, null); alertDialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int i) { closeKeyboard(input); dialog.cancel(); } }); final AlertDialog alertDialog = alertDialogBuilder.create(); //create the box alertDialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { Button b = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE); b.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (!input.getText().toString().trim().isEmpty()) { final ArrayList<String> exportList = new ArrayList<String>(); for (ColorInfo aColorList : mainApp.colorList) { exportList.add(ColorUtils.getColorRgbString(aColorList.getColor())); } File external = Environment.getExternalStorageDirectory(); final String path = external.getPath() + Config.CALIBRATE_FOLDER_NAME; File file = new File(path + input.getText()); if (file.exists()) { AlertUtils.askQuestion(context, R.string.overwriteFile, R.string.nameAlreadyExists, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { FileUtils.saveToFile(path, input.getText().toString(), exportList.toString()); } }); } else { FileUtils.saveToFile(path, input.getText().toString(), exportList.toString()); } closeKeyboard(input); alertDialog.dismiss(); } else { input.setError(getString(R.string.invalidName)); } } }); } }); input.setOnEditorActionListener(new TextView.OnEditorActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) { } return false; } }); alertDialog.show(); input.requestFocus(); InputMethodManager imm = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); }
From source file:com.hughes.android.dictionary.DictionaryActivity.java
private void onCreateSetupActionBarAndSearchView() { ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayHomeAsUpEnabled(false); final LinearLayout customSearchView = new LinearLayout(getSupportActionBar().getThemedContext()); final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); customSearchView.setLayoutParams(layoutParams); listView.setOnItemClickListener(new OnItemClickListener() { @Override// w w w. ja v a2 s .com public void onItemClick(AdapterView<?> parent, View view, int row, long id) { onListItemClick(getListView(), view, row, id); } }); languageButton = new ImageButton(customSearchView.getContext()); languageButton.setScaleType(ScaleType.FIT_CENTER); languageButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { onLanguageButtonClick(); } }); languageButton.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { onLanguageButtonLongClick(v.getContext()); return true; } }); languageButton.setAdjustViewBounds(true); LinearLayout.LayoutParams lpb = new LinearLayout.LayoutParams(application.languageButtonPixels, LinearLayout.LayoutParams.MATCH_PARENT); customSearchView.addView(languageButton, lpb); searchView = new SearchView(getSupportActionBar().getThemedContext()); // Get rid of search icon, it takes up too much space. // There is still text saying "search" in the search field. searchView.setIconifiedByDefault(true); searchView.setIconified(false); searchView.setQueryHint(getString(R.string.searchText)); searchView.setSubmitButtonEnabled(false); searchView.setInputType(InputType.TYPE_CLASS_TEXT); searchView.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI | // EditorInfo.IME_FLAG_NO_FULLSCREEN | // Requires API // 11 EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS); onQueryTextListener = new OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { Log.d(LOG, "OnQueryTextListener: onQueryTextSubmit: " + searchView.getQuery()); hideKeyboard(); return true; } @Override public boolean onQueryTextChange(String newText) { Log.d(LOG, "OnQueryTextListener: onQueryTextChange: " + searchView.getQuery()); onSearchTextChange(searchView.getQuery().toString()); return true; } }; searchView.setOnQueryTextListener(onQueryTextListener); searchView.setFocusable(true); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, FrameLayout.LayoutParams.WRAP_CONTENT, 1); customSearchView.addView(searchView, lp); actionBar.setCustomView(customSearchView); actionBar.setDisplayShowCustomEnabled(true); // Avoid wasting space on large left inset Toolbar tb = (Toolbar) customSearchView.getParent(); tb.setContentInsetsRelative(0, 0); }
From source file:im.neon.activity.LoginActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { if (null == getIntent()) { Log.d(LOG_TAG, "## onCreate(): IN with no intent"); } else {//w w w . ja v a2 s .co m Log.d(LOG_TAG, "## onCreate(): IN with flags " + Integer.toHexString(getIntent().getFlags())); } super.onCreate(savedInstanceState); setContentView(R.layout.activity_vector_login); // warn that the application has started. CommonActivityUtils.onApplicationStarted(this); Intent intent = getIntent(); Bundle receivedBundle = (null != intent) ? getIntent().getExtras() : null; // resume the application if (null != receivedBundle) { if (receivedBundle.containsKey(VectorUniversalLinkReceiver.EXTRA_UNIVERSAL_LINK_URI)) { mUniversalLinkUri = receivedBundle .getParcelable(VectorUniversalLinkReceiver.EXTRA_UNIVERSAL_LINK_URI); Log.d(LOG_TAG, "## onCreate() Login activity started by universal link"); // activity has been launched from an universal link } else if (receivedBundle.containsKey(VectorRegistrationReceiver.EXTRA_EMAIL_VALIDATION_PARAMS)) { Log.d(LOG_TAG, "## onCreate() Login activity started by email verification for registration"); processEmailValidationExtras(receivedBundle); } } // already registered if (hasCredentials()) { if ((null != intent) && (intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) == 0) { Log.d(LOG_TAG, "## onCreate(): goToSplash because the credentials are already provided."); goToSplash(); } else { // detect if the application has already been started if (null == EventStreamService.getInstance()) { Log.d(LOG_TAG, "## onCreate(): goToSplash with credentials but there is no event stream service."); goToSplash(); } else { Log.d(LOG_TAG, "## onCreate(): close the login screen because it is a temporary task"); } } finish(); return; } // bind UI widgets mLoginMaskView = (RelativeLayout) findViewById(R.id.flow_ui_mask_login); // login mLoginEmailTextView = (EditText) findViewById(R.id.login_user_name); mLoginPhoneNumber = (EditText) findViewById(R.id.login_phone_number_value); mLoginPhoneNumberCountryCode = (EditText) findViewById(R.id.login_phone_number_country); mLoginPasswordTextView = (EditText) findViewById(R.id.login_password); // account creation mCreationUsernameTextView = (EditText) findViewById(R.id.creation_your_name); mCreationPassword1TextView = (EditText) findViewById(R.id.creation_password1); mCreationPassword2TextView = (EditText) findViewById(R.id.creation_password2); // account creation - three pid mThreePidInstructions = (TextView) findViewById(R.id.instructions); mEmailAddress = (EditText) findViewById(R.id.registration_email); mPhoneNumberLayout = findViewById(R.id.registration_phone_number); mPhoneNumber = (EditText) findViewById(R.id.registration_phone_number_value); mPhoneNumberCountryCode = (EditText) findViewById(R.id.registration_phone_number_country); mSubmitThreePidButton = (Button) findViewById(R.id.button_submit); mSkipThreePidButton = (Button) findViewById(R.id.button_skip); // forgot password mPasswordForgottenTxtView = (TextView) findViewById(R.id.login_forgot_password); mForgotEmailTextView = (TextView) findViewById(R.id.forget_email_address); mForgotPassword1TextView = (EditText) findViewById(R.id.forget_new_password); mForgotPassword2TextView = (EditText) findViewById(R.id.forget_confirm_new_password); mHomeServerOptionLayout = findViewById(R.id.homeserver_layout); mHomeServerText = (EditText) findViewById(R.id.login_matrix_server_url); mIdentityServerText = (EditText) findViewById(R.id.login_identity_url); mLoginButton = (Button) findViewById(R.id.button_login); mRegisterButton = (Button) findViewById(R.id.button_register); mForgotPasswordButton = (Button) findViewById(R.id.button_reset_password); mForgotValidateEmailButton = (Button) findViewById(R.id.button_forgot_email_validate); mHomeServerUrlsLayout = findViewById(R.id.login_matrix_server_options_layout); mUseCustomHomeServersCheckbox = (CheckBox) findViewById(R.id.display_server_url_expand_checkbox); mProgressTextView = (TextView) findViewById(R.id.flow_progress_message_textview); mMainLayout = findViewById(R.id.main_input_layout); mButtonsView = findViewById(R.id.login_actions_bar); if (null != savedInstanceState) { restoreSavedData(savedInstanceState); } else { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(LoginActivity.this); mHomeServerText.setText(preferences.getString(HOME_SERVER_URL_PREF, getResources().getString(R.string.default_hs_server_url))); mIdentityServerText.setText(preferences.getString(IDENTITY_SERVER_URL_PREF, getResources().getString(R.string.default_identity_server_url))); } // trap the UI events mLoginMaskView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { } }); mLoginButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { onLoginClick(); } }); // account creation handler mRegisterButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mIsUserNameAvailable = false; onRegisterClick(true); } }); // forgot password button mForgotPasswordButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { onForgotPasswordClick(); } }); mForgotValidateEmailButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onForgotOnEmailValidated(getHsConfig()); } }); // home server input validity: if the user taps on the next / done button mHomeServerText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { onHomeServerUrlUpdate(); return true; } return false; } }); // home server input validity: when focus changes mHomeServerText.setOnFocusChangeListener(new View.OnFocusChangeListener() { public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { onHomeServerUrlUpdate(); } } }); // identity server input validity: if the user taps on the next / done button mIdentityServerText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { onIdentityserverUrlUpdate(); return true; } return false; } }); // identity server input validity: when focus changes mIdentityServerText.setOnFocusChangeListener(new View.OnFocusChangeListener() { public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { onIdentityserverUrlUpdate(); } } }); // "forgot password?" handler mPasswordForgottenTxtView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mMode = MODE_FORGOT_PASSWORD; refreshDisplay(); } }); mUseCustomHomeServersCheckbox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mUseCustomHomeServersCheckbox.post(new Runnable() { @Override public void run() { // reset the HS urls. mHomeServerUrl = null; mIdentityServerUrl = null; onIdentityserverUrlUpdate(); onHomeServerUrlUpdate(); refreshDisplay(); } }); } }); mLoginPhoneNumberHandler = new PhoneNumberHandler(this, mLoginPhoneNumber, mLoginPhoneNumberCountryCode, PhoneNumberHandler.DISPLAY_COUNTRY_ISO_CODE, REQUEST_LOGIN_COUNTRY); mLoginPhoneNumberHandler.setCountryCode(PhoneNumberUtils.getCountryCode(this)); mRegistrationPhoneNumberHandler = new PhoneNumberHandler(this, mPhoneNumber, mPhoneNumberCountryCode, PhoneNumberHandler.DISPLAY_COUNTRY_ISO_CODE, REQUEST_REGISTRATION_COUNTRY); refreshDisplay(); // reset the badge counter CommonActivityUtils.updateBadgeCount(this, 0); mHomeServerText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(LoginActivity.this); SharedPreferences.Editor editor = preferences.edit(); editor.putString(HOME_SERVER_URL_PREF, mHomeServerText.getText().toString().trim()); editor.apply(); } @Override public void afterTextChanged(Editable s) { } }); mIdentityServerText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(LoginActivity.this); SharedPreferences.Editor editor = preferences.edit(); editor.putString(IDENTITY_SERVER_URL_PREF, mIdentityServerText.getText().toString().trim()); editor.apply(); } @Override public void afterTextChanged(Editable s) { } }); // set the handler used by the register to poll the server response mHandler = new Handler(getMainLooper()); }
From source file:no.ntnu.idi.socialhitchhiking.map.MapActivityAddPickupAndDropoff.java
/** * Initialize the {@link AutoCompleteTextView}'s with an {@link ArrayAdapter} * and a listener ({@link AutoCompleteTextWatcher}). The listener gets autocomplete * data from the Google Places API and updates the ArrayAdapter with these. *///from w ww . j ava 2 s .c o m private void initAutocomplete() { adapter = new ArrayAdapter<String>(this, R.layout.item_list); adapter.setNotifyOnChange(true); acPickup = (AutoCompleteTextView) findViewById(R.id.pickupText); acPickup.setAdapter(adapter); acPickup.addTextChangedListener(new AutoCompleteTextWatcher(this, adapter, acPickup)); acPickup.setThreshold(1); acPickup.selectAll(); acDropoff = (AutoCompleteTextView) findViewById(R.id.dropoffText); acDropoff.setAdapter(adapter); acDropoff.addTextChangedListener(new AutoCompleteTextWatcher(this, adapter, acDropoff)); //sets the next button on the keyboard acPickup.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_NEXT) { // Sets the pickup location setPickupLocation(); // Sets focus to dropoff acDropoff.requestFocus(); return true; } else { return false; } } }); //sets the done button on the keyboard acDropoff.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { // Sets the dropoff location setDropOffLocation(); // Sets focus to "Comment to driver" ((EditText) findViewById(R.id.mapViewPickupEtComment)).requestFocus(); return true; } else { return false; } } }); }