List of usage examples for android.view.inputmethod EditorInfo IME_ACTION_NEXT
int IME_ACTION_NEXT
To view the source code for android.view.inputmethod EditorInfo IME_ACTION_NEXT.
Click Source Link
From source file:com.manning.androidhacks.hack017.CreateAccountAdapter.java
private EditText createEditText(String hint, int inputType, int imeOption, boolean shouldMoveToNext, final String key) { EditText ret = new EditText(mContext); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);/* w w w . jav a 2 s .c o m*/ ret.setLayoutParams(params); ret.setHint(hint); ret.setInputType(inputType); ret.setImeOptions(imeOption); if (shouldMoveToNext) { ret.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (mDelegate != null) { if (EditorInfo.IME_ACTION_NEXT == actionId) { mDelegate.scroll(CreateAccountDelegate.FORWARD); } else { processForm(); } return true; } else { return false; } } }); } ret.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) { mFormData.put(key, s.toString()); } }); return ret; }
From source file:nl.mpcjanssen.simpletask.AddTask.java
@Override public void onCreate(Bundle savedInstanceState) { Log.v(TAG, "onCreate()"); m_app = (TodoApplication) getApplication(); m_app.setActionBarStyle(getWindow()); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); super.onCreate(savedInstanceState); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Constants.BROADCAST_UPDATE_UI); intentFilter.addAction(Constants.BROADCAST_SYNC_START); intentFilter.addAction(Constants.BROADCAST_SYNC_DONE); localBroadcastManager = m_app.getLocalBroadCastManager(); m_broadcastReceiver = new BroadcastReceiver() { @Override//from w ww . ja v a2 s. c o m public void onReceive(Context context, @NotNull Intent intent) { if (intent.getAction().equals(Constants.BROADCAST_SYNC_START)) { setProgressBarIndeterminateVisibility(true); } else if (intent.getAction().equals(Constants.BROADCAST_SYNC_DONE)) { setProgressBarIndeterminateVisibility(false); } } }; localBroadcastManager.registerReceiver(m_broadcastReceiver, intentFilter); ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); } final Intent intent = getIntent(); ActiveFilter mFilter = new ActiveFilter(); mFilter.initFromIntent(intent); final String action = intent.getAction(); // create shortcut and exit if (Intent.ACTION_CREATE_SHORTCUT.equals(action)) { Log.d(TAG, "Setting up shortcut icon"); setupShortcut(); finish(); return; } else if (Intent.ACTION_SEND.equals(action)) { Log.d(TAG, "Share"); if (intent.hasExtra(Intent.EXTRA_TEXT)) { share_text = intent.getCharSequenceExtra(Intent.EXTRA_TEXT).toString(); } else { share_text = ""; } if (!m_app.hasShareTaskShowsEdit()) { if (!share_text.equals("")) { addBackgroundTask(share_text); } finish(); return; } } else if ("com.google.android.gm.action.AUTO_SEND".equals(action)) { // Called as note to self from google search/now noteToSelf(intent); finish(); return; } else if (Constants.INTENT_BACKGROUND_TASK.equals(action)) { Log.v(TAG, "Adding background task"); if (intent.hasExtra(Constants.EXTRA_BACKGROUND_TASK)) { addBackgroundTask(intent.getStringExtra(Constants.EXTRA_BACKGROUND_TASK)); } else { Log.w(TAG, "Task was not in extras"); } finish(); return; } getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); setContentView(R.layout.add_task); // text textInputField = (EditText) findViewById(R.id.taskText); m_app.setEditTextHint(textInputField, R.string.tasktexthint); if (share_text != null) { textInputField.setText(share_text); } Task iniTask = null; setTitle(R.string.addtask); m_backup = m_app.getTaskCache(this).getTasksToUpdate(); if (m_backup != null && m_backup.size() > 0) { ArrayList<String> prefill = new ArrayList<String>(); for (Task t : m_backup) { prefill.add(t.inFileFormat()); } String sPrefill = Util.join(prefill, "\n"); textInputField.setText(sPrefill); setTitle(R.string.updatetask); } else { if (textInputField.getText().length() == 0) { iniTask = new Task(1, ""); iniTask.initWithFilter(mFilter); } if (iniTask != null && iniTask.getTags().size() == 1) { List<String> ps = iniTask.getTags(); String project = ps.get(0); if (!project.equals("-")) { textInputField.append(" +" + project); } } if (iniTask != null && iniTask.getLists().size() == 1) { List<String> cs = iniTask.getLists(); String context = cs.get(0); if (!context.equals("-")) { textInputField.append(" @" + context); } } } // Listen to enter events, use IME_ACTION_NEXT for soft keyboards // like Swype where ENTER keyCode is not generated. int inputFlags = InputType.TYPE_CLASS_TEXT; if (m_app.hasCapitalizeTasks()) { inputFlags |= InputType.TYPE_TEXT_FLAG_CAP_SENTENCES; } textInputField.setRawInputType(inputFlags); textInputField.setImeOptions(EditorInfo.IME_ACTION_NEXT); textInputField.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int actionId, @Nullable KeyEvent keyEvent) { boolean hardwareEnterUp = keyEvent != null && keyEvent.getAction() == KeyEvent.ACTION_UP && keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER; boolean hardwareEnterDown = keyEvent != null && keyEvent.getAction() == KeyEvent.ACTION_DOWN && keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER; boolean imeActionNext = (actionId == EditorInfo.IME_ACTION_NEXT); if (imeActionNext || hardwareEnterUp) { // Move cursor to end of line int position = textInputField.getSelectionStart(); String remainingText = textInputField.getText().toString().substring(position); int endOfLineDistance = remainingText.indexOf('\n'); int endOfLine; if (endOfLineDistance == -1) { endOfLine = textInputField.length(); } else { endOfLine = position + endOfLineDistance; } textInputField.setSelection(endOfLine); replaceTextAtSelection("\n", false); if (hasCloneTags()) { String precedingText = textInputField.getText().toString().substring(0, endOfLine); int lineStart = precedingText.lastIndexOf('\n'); String line; if (lineStart != -1) { line = precedingText.substring(lineStart, endOfLine); } else { line = precedingText; } Task t = new Task(0, line); LinkedHashSet<String> tags = new LinkedHashSet<String>(); for (String ctx : t.getLists()) { tags.add("@" + ctx); } for (String prj : t.getTags()) { tags.add("+" + prj); } replaceTextAtSelection(Util.join(tags, " "), true); } endOfLine++; textInputField.setSelection(endOfLine); } return (imeActionNext || hardwareEnterDown || hardwareEnterUp); } }); setCloneTags(m_app.isAddTagsCloneTags()); setWordWrap(m_app.isWordWrap()); findViewById(R.id.cb_wrap).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setWordWrap(hasWordWrap()); } }); int textIndex = 0; textInputField.setSelection(textIndex); // Set button callbacks findViewById(R.id.btnContext).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showContextMenu(); } }); findViewById(R.id.btnProject).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showTagMenu(); } }); findViewById(R.id.btnPrio).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showPrioMenu(); } }); findViewById(R.id.btnDue).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { insertDate(Task.DUE_DATE); } }); findViewById(R.id.btnThreshold).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { insertDate(Task.THRESHOLD_DATE); } }); if (m_backup != null && m_backup.size() > 0) { textInputField.setSelection(textInputField.getText().length()); } }
From source file:com.google.android.apps.flexbox.FlexItemEditFragment.java
private void setNextFocusesOnEnterDown(final TextView... textViews) { // This can be done by setting android:nextFocus* as in // https://developer.android.com/training/keyboard-input/navigation.html // But it requires API level 11 as a minimum sdk version. To support the lower level devices, // doing it programatically. for (int i = 0; i < textViews.length; i++) { final int index = i; textViews[index].setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override/* w w w.ja v a 2s. c o m*/ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_NEXT || actionId == EditorInfo.IME_ACTION_DONE || (actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) { if (index + 1 < textViews.length) { textViews[index + 1].requestFocus(); } else if (index == textViews.length - 1) { InputMethodManager inputMethodManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(v.getWindowToken(), 0); } } return true; } }); // Suppress the key focus change by KeyEvent.ACTION_UP of the enter key textViews[index].setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { return keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP; } }); } }
From source file:com.digitalarx.android.authentication.AuthenticatorActivity.java
/** * //from w ww .j a va 2 s .c om * @param savedInstanceState Saved activity state, as in {{@link #onCreate(Bundle)} */ private void initServerPreFragment(Bundle savedInstanceState) { /// step 1 - load and process relevant inputs (resources, intent, savedInstanceState) boolean isUrlInputAllowed = getResources().getBoolean(R.bool.show_server_url_input); if (savedInstanceState == null) { if (mAccount != null) { mServerInfo.mBaseUrl = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_BASE_URL); mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith("https://"); // TODO do this in a setter for mBaseUrl String ocVersion = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_VERSION); if (ocVersion != null) { mServerInfo.mVersion = new OwnCloudVersion(ocVersion); } } else { mServerInfo.mBaseUrl = getString(R.string.server_url).trim(); mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith("https://"); } } else { mServerStatusText = savedInstanceState.getInt(KEY_SERVER_STATUS_TEXT); mServerStatusIcon = savedInstanceState.getInt(KEY_SERVER_STATUS_ICON); mServerIsValid = savedInstanceState.getBoolean(KEY_SERVER_VALID); mServerIsChecked = savedInstanceState.getBoolean(KEY_SERVER_CHECKED); // TODO parcelable mServerInfo.mIsSslConn = savedInstanceState.getBoolean(KEY_IS_SSL_CONN); mServerInfo.mBaseUrl = savedInstanceState.getString(KEY_HOST_URL_TEXT); String ocVersion = savedInstanceState.getString(KEY_OC_VERSION); if (ocVersion != null) { mServerInfo.mVersion = new OwnCloudVersion(ocVersion); } mServerInfo.mAuthMethod = AuthenticationMethod .valueOf(savedInstanceState.getString(KEY_SERVER_AUTH_METHOD)); } /// step 2 - set properties of UI elements (text, visibility, enabled...) mHostUrlInput = (EditText) findViewById(R.id.hostUrlInput); mHostUrlInput.setText(mServerInfo.mBaseUrl); if (mAction != ACTION_CREATE) { /// lock things that should not change mHostUrlInput.setEnabled(false); mHostUrlInput.setFocusable(false); } if (isUrlInputAllowed) { mRefreshButton = findViewById(R.id.embeddedRefreshButton); } else { findViewById(R.id.hostUrlFrame).setVisibility(View.GONE); mRefreshButton = findViewById(R.id.centeredRefreshButton); } showRefreshButton(mServerIsChecked && !mServerIsValid && mWaitingForOpId > Integer.MAX_VALUE); mServerStatusView = (TextView) findViewById(R.id.server_status_text); showServerStatus(); /// step 3 - bind some listeners and options mHostUrlInput.setImeOptions(EditorInfo.IME_ACTION_NEXT); mHostUrlInput.setOnEditorActionListener(this); /// step 4 - create listeners that will be bound at onResume mHostUrlInputWatcher = new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (mOkButton.isEnabled() && !mServerInfo.mBaseUrl.equals(normalizeUrl(s.toString(), mServerInfo.mIsSslConn))) { 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 (mAuthStatusIcon != 0) { Log_OC.d(TAG, "onTextChanged: hiding authentication status"); mAuthStatusIcon = 0; mAuthStatusText = 0; showAuthStatus(); } } }; // TODO find out if this is really necessary, or if it can done in a different way findViewById(R.id.scroll).setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()) .equals(mAuthTokenType) && mHostUrlInput.hasFocus()) { checkOcServer(); } } return false; } }); /// step 4 - mark automatic check to be started when OperationsService is ready mPendingAutoCheck = (savedInstanceState == null && (mAction != ACTION_CREATE || !isUrlInputAllowed)); }
From source file:com.duy.pascal.ui.view.console.ConsoleView.java
@Override public InputConnection onCreateInputConnection(EditorInfo outAttrs) { outAttrs.inputType = InputType.TYPE_NULL; // outAttrs.imeOptions = EditorInfo.IME_ACTION_DONE; return new InputConnection() { /**/*from w ww . j a va 2 s.co m*/ * Used to handle composing text requests */ private int mCursor; private int mComposingTextStart; private int mComposingTextEnd; private int mSelectedTextStart = 0; private int mSelectedTextEnd = 0; private boolean mInBatchEdit; private void sendText(CharSequence text) { DLog.d(TAG, "sendText: " + text); int n = text.length(); for (int i = 0; i < n; i++) { mKeyBuffer.push(text.charAt(i)); putString(Character.toString(text.charAt(i))); } } @Override public boolean performEditorAction(int actionCode) { DLog.d(TAG, "performEditorAction: " + actionCode); if (actionCode == EditorInfo.IME_ACTION_DONE || actionCode == EditorInfo.IME_ACTION_GO || actionCode == EditorInfo.IME_ACTION_NEXT || actionCode == EditorInfo.IME_ACTION_SEND || actionCode == EditorInfo.IME_ACTION_UNSPECIFIED) { sendText("\n"); return true; } return false; } public boolean beginBatchEdit() { { DLog.w(TAG, "beginBatchEdit"); } setImeBuffer(""); mCursor = 0; mComposingTextStart = 0; mComposingTextEnd = 0; mInBatchEdit = true; return true; } public boolean clearMetaKeyStates(int arg0) { { DLog.w(TAG, "clearMetaKeyStates " + arg0); } return false; } public boolean commitCompletion(CompletionInfo arg0) { { DLog.w(TAG, "commitCompletion " + arg0); } return false; } @Override public boolean commitCorrection(CorrectionInfo correctionInfo) { return false; } public boolean endBatchEdit() { { DLog.w(TAG, "endBatchEdit"); } mInBatchEdit = false; return true; } public boolean finishComposingText() { { DLog.w(TAG, "finishComposingText"); } sendText(mImeBuffer); setImeBuffer(""); mComposingTextStart = 0; mComposingTextEnd = 0; mCursor = 0; return true; } public int getCursorCapsMode(int arg0) { { DLog.w(TAG, "getCursorCapsMode(" + arg0 + ")"); } return 0; } public ExtractedText getExtractedText(ExtractedTextRequest arg0, int arg1) { { DLog.w(TAG, "getExtractedText" + arg0 + "," + arg1); } return null; } public CharSequence getTextAfterCursor(int n, int flags) { { DLog.w(TAG, "getTextAfterCursor(" + n + "," + flags + ")"); } int len = Math.min(n, mImeBuffer.length() - mCursor); if (len <= 0 || mCursor < 0 || mCursor >= mImeBuffer.length()) { return ""; } return mImeBuffer.substring(mCursor, mCursor + len); } public CharSequence getTextBeforeCursor(int n, int flags) { { DLog.w(TAG, "getTextBeforeCursor(" + n + "," + flags + ")"); } int len = Math.min(n, mCursor); if (len <= 0 || mCursor < 0 || mCursor >= mImeBuffer.length()) { return ""; } return mImeBuffer.substring(mCursor - len, mCursor); } public boolean performContextMenuAction(int arg0) { { DLog.w(TAG, "performContextMenuAction" + arg0); } return true; } public boolean performPrivateCommand(String arg0, Bundle arg1) { { DLog.w(TAG, "performPrivateCommand" + arg0 + "," + arg1); } return true; } @Override public boolean requestCursorUpdates(int cursorUpdateMode) { return false; } @Override public Handler getHandler() { return null; } @Override public void closeConnection() { } @Override public boolean commitContent(@NonNull InputContentInfo inputContentInfo, int flags, Bundle opts) { return false; } public boolean reportFullscreenMode(boolean arg0) { { DLog.w(TAG, "reportFullscreenMode" + arg0); } return true; } public boolean commitText(CharSequence text, int newCursorPosition) { { DLog.w(TAG, "commitText(\"" + text + "\", " + newCursorPosition + ")"); } char[] characters = text.toString().toCharArray(); for (char character : characters) { mKeyBuffer.push(character); } clearComposingText(); sendText(text); setImeBuffer(""); mCursor = 0; return true; } private void clearComposingText() { setImeBuffer( mImeBuffer.substring(0, mComposingTextStart) + mImeBuffer.substring(mComposingTextEnd)); if (mCursor < mComposingTextStart) { // do nothing } else if (mCursor < mComposingTextEnd) { mCursor = mComposingTextStart; } else { mCursor -= mComposingTextEnd - mComposingTextStart; } mComposingTextEnd = mComposingTextStart = 0; } public boolean deleteSurroundingText(int leftLength, int rightLength) { { DLog.w(TAG, "deleteSurroundingText(" + leftLength + "," + rightLength + ")"); } if (leftLength > 0) { for (int i = 0; i < leftLength; i++) { sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL)); } } else if ((leftLength == 0) && (rightLength == 0)) { // Delete key held down / repeating sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL)); } // TODO: handle forward deletes. return true; } @Override public boolean deleteSurroundingTextInCodePoints(int beforeLength, int afterLength) { return false; } public boolean sendKeyEvent(KeyEvent event) { { DLog.w(TAG, "sendKeyEvent(" + event + ")"); } // Some keys are sent here rather than to commitText. // In particular, del and the digit keys are sent here. // (And I have reports that the HTC Magic also sends Return here.) // As a bit of defensive programming, handle every key. dispatchKeyEvent(event); return true; } public boolean setComposingText(CharSequence text, int newCursorPosition) { { DLog.w(TAG, "setComposingText(\"" + text + "\", " + newCursorPosition + ")"); } setImeBuffer(mImeBuffer.substring(0, mComposingTextStart) + text + mImeBuffer.substring(mComposingTextEnd)); mComposingTextEnd = mComposingTextStart + text.length(); mCursor = newCursorPosition > 0 ? mComposingTextEnd + newCursorPosition - 1 : mComposingTextStart - newCursorPosition; return true; } public boolean setSelection(int start, int end) { { DLog.w(TAG, "setSelection" + start + "," + end); } int length = mImeBuffer.length(); if (start == end && start > 0 && start < length) { mSelectedTextStart = mSelectedTextEnd = 0; mCursor = start; } else if (start < end && start > 0 && end < length) { mSelectedTextStart = start; mSelectedTextEnd = end; mCursor = start; } return true; } public boolean setComposingRegion(int start, int end) { { DLog.w(TAG, "setComposingRegion " + start + "," + end); } if (start < end && start > 0 && end < mImeBuffer.length()) { clearComposingText(); mComposingTextStart = start; mComposingTextEnd = end; } return true; } public CharSequence getSelectedText(int flags) { try { { DLog.w(TAG, "getSelectedText " + flags); } if (mImeBuffer.length() < 1) { return ""; } return mImeBuffer.substring(mSelectedTextStart, mSelectedTextEnd + 1); } catch (Exception ignored) { } return ""; } }; }
From source file:com.owncloud.android.authentication.AuthenticatorActivity.java
/** * {@inheritDoc}/* w w w .j a va 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:com.synox.android.authentication.AuthenticatorActivity.java
/** * /*from w ww. j a va2 s. c om*/ * @param savedInstanceState Saved activity state, as in {{@link #onCreate(Bundle)} */ private void initServerPreFragment(Bundle savedInstanceState) { /// step 1 - load and process relevant inputs (resources, intent, savedInstanceState) boolean isUrlInputAllowed = getResources().getBoolean(R.bool.show_server_url_input); if (savedInstanceState == null) { if (mAccount != null) { mServerInfo.mBaseUrl = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_BASE_URL); // TODO do next in a setter for mBaseUrl mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith("https://"); mServerInfo.mVersion = AccountUtils.getServerVersion(mAccount); } else { mServerInfo.mBaseUrl = getString(R.string.server_url).trim(); mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith("https://"); } } else { mServerStatusText = savedInstanceState.getInt(KEY_SERVER_STATUS_TEXT); mServerStatusIcon = savedInstanceState.getInt(KEY_SERVER_STATUS_ICON); mServerIsValid = savedInstanceState.getBoolean(KEY_SERVER_VALID); mServerIsChecked = savedInstanceState.getBoolean(KEY_SERVER_CHECKED); // TODO parcelable mServerInfo.mIsSslConn = savedInstanceState.getBoolean(KEY_IS_SSL_CONN); mServerInfo.mBaseUrl = savedInstanceState.getString(KEY_HOST_URL_TEXT); String ocVersion = savedInstanceState.getString(KEY_OC_VERSION); if (ocVersion != null) { mServerInfo.mVersion = new OwnCloudVersion(ocVersion); } mServerInfo.mAuthMethod = AuthenticationMethod .valueOf(savedInstanceState.getString(KEY_SERVER_AUTH_METHOD)); } /// step 2 - set properties of UI elements (text, visibility, enabled...) mHostUrlInput = (EditText) findViewById(R.id.hostUrlInput); // Convert IDN to Unicode mHostUrlInput.setText(DisplayUtils.convertIdn(mServerInfo.mBaseUrl, false)); if (mAction != ACTION_CREATE) { /// lock things that should not change mHostUrlInput.setEnabled(false); mHostUrlInput.setFocusable(false); } if (isUrlInputAllowed) { mRefreshButton = findViewById(R.id.embeddedRefreshButton); } else { findViewById(R.id.hostUrlFrame).setVisibility(View.GONE); mRefreshButton = findViewById(R.id.centeredRefreshButton); } showRefreshButton(mServerIsChecked && !mServerIsValid && mWaitingForOpId > Integer.MAX_VALUE); mServerStatusView = (TextView) findViewById(R.id.server_status_text); showServerStatus(); /// step 3 - bind some listeners and options mHostUrlInput.setImeOptions(EditorInfo.IME_ACTION_NEXT); mHostUrlInput.setOnEditorActionListener(this); /// step 4 - create listeners that will be bound at onResume mHostUrlInputWatcher = new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (mOkButton.isEnabled() && !mServerInfo.mBaseUrl.equals(normalizeUrl(s.toString(), mServerInfo.mIsSslConn))) { 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 (mAuthStatusIcon != 0) { Log_OC.d(TAG, "onTextChanged: hiding authentication status"); mAuthStatusIcon = 0; mAuthStatusText = 0; showAuthStatus(); } } }; // TODO find out if this is really necessary, or if it can done in a different way findViewById(R.id.scroll).setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()) .equals(mAuthTokenType) && mHostUrlInput.hasFocus()) { checkOcServer(); } } return false; } }); /// step 4 - mark automatic check to be started when OperationsService is ready mPendingAutoCheck = (savedInstanceState == null && (mAction != ACTION_CREATE || !isUrlInputAllowed)); }
From source file:edu.usf.cutr.opentripplanner.android.fragments.MainFragment.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override//w ww . j a va2s. 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:org.akop.crosswords.view.CrosswordView.java
@Override public InputConnection onCreateInputConnection(EditorInfo outAttrs) { outAttrs.actionLabel = null;//from w ww . j av a2 s . c o m outAttrs.inputType = InputType.TYPE_NULL; //InputType.TYPE_CLASS_TEXT; outAttrs.imeOptions &= ~EditorInfo.IME_FLAG_NO_FULLSCREEN; outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_EXTRACT_UI; outAttrs.imeOptions &= ~EditorInfo.IME_MASK_ACTION; outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT; outAttrs.packageName = getContext().getPackageName(); CrosswordInputConnection inputConnection = new CrosswordInputConnection(this); inputConnection.setOnInputEventListener(mInputEventListener); return inputConnection; }
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 {/* www . jav a 2 s.c o m*/ showScanToast(TOAST_NO_MANUAL, ""); } } return true; }