List of usage examples for android.view View FOCUS_DOWN
int FOCUS_DOWN
To view the source code for android.view View FOCUS_DOWN.
Click Source Link
From source file:de.elanev.studip.android.app.backend.net.oauth.WebAuthFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); }/*from w w w. ja va 2 s.c o m*/ setHasOptionsMenu(true); String url = getArguments().getString(AUTH_URL); mWebView.setWebViewClient(new LoginWebViewClient()); // Workaround for embedded WebView Bug in Android 2.3, // https://code.google.com/p/android/issues/detail?id=7189 if (!ApiUtils.isOverApi11()) { mWebView.requestFocus(View.FOCUS_DOWN); mWebView.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_UP: if (!v.hasFocus()) { v.requestFocus(); } break; } return false; } }); } mWebView.loadUrl(url); }
From source file:com.he5ed.lib.cloudprovider.auth.OAuth2Fragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.cp_fragment_oauth, container, false); mRootView = (FrameLayout) rootView;//from w w w . j a v a2s .c om // insert web view if (mWebView == null) { mWebView = new OAuthWebView(getActivity()); mWebView.setOnAuthEndListener(this); mWebView.authenticate(mCloudApi); mWebView.setFocusable(true); mWebView.setFocusableInTouchMode(true); mWebView.requestFocus(View.FOCUS_DOWN); } mRootView.addView(mWebView, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); return rootView; }
From source file:space.linuxdeveloper.osum.DisplayStatsActivity.java
/** * Perform fullScroll UP or DOWN//from w w w. j a v a 2s. c om */ public void onScrollViewChildClick(View v) { if (!mScrollView.fullScroll(View.FOCUS_DOWN)) mScrollView.fullScroll(View.FOCUS_UP); }
From source file:com.github.piasy.rxqrcode.example.QrScanFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { switch (requestCode) { case PICK_IMAGE_RESULT: if (data != null && data.getData() != null) { Uri imageFileUri = data.getData(); String realPath = UriUtil.getPath(getContext(), imageFileUri); if (!TextUtils.isEmpty(realPath)) { RxQrCode.scanFromPicture(realPath).subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()).subscribe(result -> { if (mTvResult != null) { mTvResult.setText(mTvResult.getText() + "\nresult " + result.getText()); mScrollView.fullScroll(View.FOCUS_DOWN); }/*w w w . j a v a 2 s. c o m*/ }, e -> { Toast.makeText(getContext(), "code not found", Toast.LENGTH_SHORT).show(); }); } else { Toast.makeText(getContext(), "file not found", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getContext(), "no data", Toast.LENGTH_SHORT).show(); } break; default: break; } } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.example.android.google.wearable.app.MainActivity.java
/** * Handles the button to start a DelayedConfirmationView timer. */// w w w . j a v a 2s . com public void onStartTimer(View view) { DelayedConfirmationView delayedConfirmationView = (DelayedConfirmationView) findViewById(R.id.timer); delayedConfirmationView.setTotalTimeMs(NUM_SECONDS * 1000); delayedConfirmationView.setListener(this); delayedConfirmationView.start(); scroll(View.FOCUS_DOWN); }
From source file:org.liberty.android.fantastischmemo.downloader.google.GoogleOAuth2AccessCodeRetrievalFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreate(savedInstanceState); final View v = inflater.inflate(R.layout.oauth_login_layout, container, false); final WebView webview = (WebView) v.findViewById(R.id.login_page); final View loadingText = v.findViewById(R.id.auth_page_load_text); final View progressDialog = v.findViewById(R.id.auth_page_load_progress); final LinearLayout ll = (LinearLayout) v.findViewById(R.id.ll); // We have to set up the dialog's webview size manually or the webview will be zero size. // This should be a bug of Android. Rect displayRectangle = new Rect(); Window window = mActivity.getWindow(); window.getDecorView().getWindowVisibleDisplayFrame(displayRectangle); ll.setMinimumWidth((int) (displayRectangle.width() * 0.9f)); ll.setMinimumHeight((int) (displayRectangle.height() * 0.8f)); webview.getSettings().setJavaScriptEnabled(true); try {/*from www . j a v a 2 s . c om*/ String uri = String.format( "https://accounts.google.com/o/oauth2/auth?client_id=%s&response_type=%s&redirect_uri=%s&scope=%s", URLEncoder.encode(AMEnv.GOOGLE_CLIENT_ID, "UTF-8"), URLEncoder.encode("code", "UTF-8"), URLEncoder.encode(AMEnv.GOOGLE_REDIRECT_URI, "UTF-8"), URLEncoder.encode(AMEnv.GDRIVE_SCOPE, "UTF-8")); webview.loadUrl(uri); } catch (Exception e) { throw new RuntimeException(e); } // This is workaround to show input on some android version. webview.requestFocus(View.FOCUS_DOWN); webview.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_UP: if (!v.hasFocus()) { v.requestFocus(); } break; } return false; } }); webview.setWebViewClient(new WebViewClient() { private boolean authenticated = false; @Override public void onPageFinished(WebView view, String url) { loadingText.setVisibility(View.GONE); progressDialog.setVisibility(View.GONE); webview.setVisibility(View.VISIBLE); if (authenticated == true) { return; } String code = getAuthCodeFromUrl(url); String error = getErrorFromUrl(url); if (error != null) { authCodeReceiveListener.onAuthCodeError(error); authenticated = true; dismiss(); } if (code != null) { authenticated = true; authCodeReceiveListener.onAuthCodeReceived(code); dismiss(); } } }); return v; }
From source file:au.com.wallaceit.reddinator.TabWebFragment.java
@SuppressLint("SetJavaScriptEnabled") public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mContext = this.getActivity(); if (container == null) { return null; }/*ww w .ja v a2 s . c o m*/ if (mFirstTime) { // get shared preferences SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(this.getActivity().getApplicationContext()); // work out the url this instance should load boolean commentswv = false; if (this.getArguments() != null) { commentswv = this.getArguments().getBoolean("loadcom", false); } int fontsize; String url; if (commentswv) { url = "http://reddit.com" + getActivity().getIntent().getStringExtra(WidgetProvider.ITEM_PERMALINK) + ".compact"; fontsize = Integer.parseInt(prefs.getString("commentfontpref", "22")); } else { url = getActivity().getIntent().getStringExtra(WidgetProvider.ITEM_URL); fontsize = Integer.parseInt(prefs.getString("contentfontpref", "18")); } // setup progressbar mActivity = this.getActivity(); mActivity.getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON); ll = (LinearLayout) inflater.inflate(R.layout.tab1, container, false); mWebView = (WebView) ll.findViewById(R.id.webView1); // fixes for webview not taking keyboard input on some devices mWebView.requestFocus(View.FOCUS_DOWN); mWebView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_UP: if (!v.hasFocus()) { v.requestFocus(); } break; } return false; } }); mWebView.getSettings().setJavaScriptEnabled(true); // enable ecmascript mWebView.getSettings().setSupportZoom(true); mWebView.getSettings().setUseWideViewPort(true); mWebView.getSettings().setBuiltInZoomControls(true); mWebView.getSettings().setDisplayZoomControls(true); mWebView.getSettings().setDefaultFontSize(fontsize); mChromeClient = newchromeclient; mWebView.setWebChromeClient(mChromeClient); mWebView.setWebViewClient(new WebViewClient()); mWebView.loadUrl(url); mFirstTime = false; //System.out.println("Created fragment"); } else { ((ViewGroup) ll.getParent()).removeView(ll); } return ll; }
From source file:org.openoverlayrouter.noroot.logActivity.java
public void refresh() { StringBuffer contents = new StringBuffer(); final StringBuffer fixedContents = contents; try {/*from www .j a va2s . co m*/ RandomAccessFile logFile = new RandomAccessFile(log_file, "r"); if (logFile.length() > maxReadBytes) { logFile.seek(logFile.length() - maxReadBytes); } String currentLine = logFile.readLine(); while (currentLine != null) { if (currentLine != null) { contents.append(currentLine); contents.append('\n'); } currentLine = logFile.readLine(); } try { if (logFile != null) { logFile.close(); } } catch (IOException e) { e.printStackTrace(); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { } mHandler.post(new Runnable() { public void run() { // Put the file contents into the TextView TextView log = (TextView) llLayout.findViewById(R.id.logView); log.setText(fixedContents); // Auto scroll to the bottom final ScrollView scroll = (ScrollView) llLayout.findViewById(R.id.scrollView1); scroll.post(new Runnable() { public void run() { scroll.fullScroll(View.FOCUS_DOWN); } }); if (myDialog != null) { myDialog.dismiss(); myDialog = null; } } }); }
From source file:com.doomonafireball.hackerswiperfree.android.activity.MainActivity.java
private void setTyperText() { text.append(mTyper.getTextPortion()); scrollView.post(new Runnable() { @Override/* w w w . ja v a 2 s .c o m*/ public void run() { scrollView.fullScroll(View.FOCUS_DOWN); } }); }
From source file:com.mimo.service.api.MimoOauth2Client.java
/** * Instantiate a webview and allows the user to login to the Api form within * the application/*from w w w.ja va 2 s . co m*/ * * @param p_view * : Calling view * * @param p_activity * : Calling Activity reference **/ @SuppressLint("SetJavaScriptEnabled") public void login(View p_view, Activity p_activity) { final Activity m_activity; m_activity = p_activity; String m_url = this.m_api.getAuthUrl(); WebView m_webview = new WebView(p_view.getContext()); m_webview.getSettings().setJavaScriptEnabled(true); m_webview.setVisibility(View.VISIBLE); m_activity.setContentView(m_webview); m_webview.requestFocus(View.FOCUS_DOWN); /** * Open the softkeyboard of the device to input the text in form which * loads in webview. */ m_webview.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View p_v, MotionEvent p_event) { switch (p_event.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_UP: if (!p_v.hasFocus()) { p_v.requestFocus(); } break; } return false; } }); /** * Show the progressbar in the title of the activity untill the page * loads the give url. */ m_webview.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView p_view, int p_newProgress) { ((Activity) m_context).setProgress(p_newProgress * 100); ((Activity) m_context).setTitle(MimoAPIConstants.DIALOG_TEXT_LOADING); if (p_newProgress == 100) ((Activity) m_context).setTitle(m_context.getString(R.string.app_name)); } }); m_webview.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView p_view, String p_url, Bitmap p_favicon) { } @Override public void onReceivedHttpAuthRequest(WebView p_view, HttpAuthHandler p_handler, String p_url, String p_realm) { p_handler.proceed(MimoAPIConstants.USERNAME, MimoAPIConstants.PASSWORD); } public void onPageFinished(WebView p_view, String p_url) { if (MimoAPIConstants.DEBUG) { Log.d(TAG, "Page Url = " + p_url); } if (p_url.contains("?code=")) { if (p_url.indexOf("code=") != -1) { String[] m_urlSplit = p_url.split("="); String m_tempString1 = m_urlSplit[1]; if (MimoAPIConstants.DEBUG) { Log.d(TAG, "TempString1 = " + m_tempString1); } String[] m_urlSplit1 = m_tempString1.split("&"); String m_code = m_urlSplit1[0]; if (MimoAPIConstants.DEBUG) { Log.d(TAG, "code = " + m_code); } MimoOauth2Client.this.m_code = m_code; Thread m_thread = new Thread() { public void run() { String m_token = requesttoken(MimoOauth2Client.this.m_code); Log.d(TAG, "Token = " + m_token); Intent m_navigateIntent = new Intent(m_activity, MimoTransactions.class); m_navigateIntent.putExtra(MimoAPIConstants.KEY_TOKEN, m_token); m_activity.startActivity(m_navigateIntent); } }; m_thread.start(); } else { if (MimoAPIConstants.DEBUG) { Log.d(TAG, "going in else"); } } } else if (p_url.contains(MimoAPIConstants.URL_KEY_TOKEN)) { if (p_url.indexOf(MimoAPIConstants.URL_KEY_TOKEN) != -1) { String[] m_urlSplit = p_url.split("="); final String m_token = m_urlSplit[1]; Thread m_thread = new Thread() { public void run() { Intent m_navigateIntent = new Intent(m_activity, MimoTransactions.class); m_navigateIntent.putExtra(MimoAPIConstants.KEY_TOKEN, m_token); m_activity.startActivity(m_navigateIntent); } }; m_thread.start(); } } }; }); m_webview.loadUrl(m_url); }