Example usage for android.webkit WebView setFocusable

List of usage examples for android.webkit WebView setFocusable

Introduction

In this page you can find the example usage for android.webkit WebView setFocusable.

Prototype

public void setFocusable(boolean focusable) 

Source Link

Document

Set whether this view can receive the focus.

Usage

From source file:com.owncloud.android.ui.activity.ExternalSiteWebView.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log_OC.v(TAG, "onCreate() start");

    Bundle extras = getIntent().getExtras();
    String title = extras.getString(EXTRA_TITLE);
    String url = extras.getString(EXTRA_URL);
    menuItemId = extras.getInt(EXTRA_MENU_ITEM_ID);
    showSidebar = extras.getBoolean(EXTRA_SHOW_SIDEBAR);

    // show progress
    getWindow().requestFeature(Window.FEATURE_PROGRESS);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.externalsite_webview);

    WebView webview = (WebView) findViewById(R.id.webView);
    WebSettings webSettings = webview.getSettings();

    webview.setFocusable(true);
    webview.setFocusableInTouchMode(true);
    webview.setClickable(true);/*from  ww w. j av  a  2  s.co m*/

    // setup toolbar
    setupToolbar();

    // setup drawer
    setupDrawer(menuItemId);

    if (!showSidebar) {
        setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
    }

    getSupportActionBar().setTitle(title);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // enable zoom
    webSettings.setSupportZoom(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setDisplayZoomControls(false);

    // Non-responsive webs are zoomed out when loaded
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);

    // user agent
    webSettings.setUserAgentString(MainApp.getUserAgent());

    // no private data storing
    webSettings.setSavePassword(false);
    webSettings.setSaveFormData(false);

    // disable local file access
    webSettings.setAllowFileAccess(false);

    // enable javascript
    webview.getSettings().setJavaScriptEnabled(true);

    final Activity activity = this;
    final ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar);

    webview.setWebChromeClient(new WebChromeClient() {
        public void onProgressChanged(WebView view, int progress) {
            progressBar.setProgress(progress * 1000);
        }
    });

    webview.setWebViewClient(new WebViewClient() {
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            Toast.makeText(activity, getString(R.string.webview_error) + ": " + description, Toast.LENGTH_SHORT)
                    .show();
        }
    });

    webview.loadUrl(url);
}

From source file:com.example.leebeomwoo.viewbody_final.ItemGroup.TrainerInfoFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    view = inflater.inflate(R.layout.fragment_trainer_info, container, false);
    final RecyclerView rvli = (RecyclerView) view.findViewById(R.id.license_list);
    rvli.setHasFixedSize(true);/*from   w  ww.  j  a va  2 s .  c o m*/
    LinearLayoutManager llmli = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
    rvli.setLayoutManager(llmli);
    final RecyclerView rvaw = (RecyclerView) view.findViewById(R.id.award_list);
    rvaw.setHasFixedSize(true);
    LinearLayoutManager llmaw = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
    rvaw.setLayoutManager(llmaw);
    Call<ResponseTr> call = ConAdapter.getInstance().TR_CALL(tr_id);
    call.enqueue(new Callback<ResponseTr>() {
        @Override
        public void onResponse(Call<ResponseTr> call, Response<ResponseTr> response) {
            responseTr = response.body();
            TextView asstxtB = (TextView) view.findViewById(R.id.trainer_association_txt);
            TextView nicktxtB = (TextView) view.findViewById(R.id.trainer_nicname_txt);
            TextView calltxtB = (TextView) view.findViewById(R.id.trainer_call_txt);
            TextView emailtxtB = (TextView) view.findViewById(R.id.trainer_email_txt);
            WebView faceWxb = (WebView) view.findViewById(R.id.trainer_facewebView);
            asstxtB.setText(responseTr.getAssociation());
            nicktxtB.setText(responseTr.getNickName());
            calltxtB.setText(responseTr.getCall());
            emailtxtB.setText(responseTr.getEmail());
            faceWxb.loadUrl(responseTr.getPhotoUrl());
            faceWxb.setFocusable(false);
            licenses = responseTr.getLicense();
            Trainer_license_Adapter adapterli = new Trainer_license_Adapter(getActivity(), licenses);
            rvli.setAdapter(adapterli);
            awards = responseTr.getAward();
            Trainer_award_Adapter adapteraw = new Trainer_award_Adapter(getActivity(), awards);
            rvaw.setAdapter(adapteraw);
        }

        @Override
        public void onFailure(Call<ResponseTr> call, Throwable t) {
            Toast toast = null;
            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
                toast = Toast.makeText(getContext(), "? ? ?.",
                        Toast.LENGTH_SHORT);
            }
            toast.show();
        }
    });
    return view;
}

From source file:org.openqa.selendroid.server.model.SelendroidWebDriver.java

private void configureWebView(final WebView view) {
    ServerInstrumentation.getInstance().runOnUiThread(new Runnable() {

        @Override/*from w  w w . ja v a  2  s . c  om*/
        public void run() {
            view.clearCache(true);
            view.clearFormData();
            view.clearHistory();
            view.setFocusable(true);
            view.setFocusableInTouchMode(true);
            view.setNetworkAvailable(true);
            view.setWebChromeClient(new MyWebChromeClient());

            WebSettings settings = view.getSettings();
            settings.setJavaScriptCanOpenWindowsAutomatically(true);
            settings.setSupportMultipleWindows(true);
            settings.setBuiltInZoomControls(true);
            settings.setJavaScriptEnabled(true);
            settings.setAppCacheEnabled(true);
            settings.setAppCacheMaxSize(10 * 1024 * 1024);
            settings.setAppCachePath("");
            settings.setDatabaseEnabled(true);
            settings.setDomStorageEnabled(true);
            settings.setGeolocationEnabled(true);
            settings.setSaveFormData(false);
            settings.setSavePassword(false);
            settings.setRenderPriority(WebSettings.RenderPriority.HIGH);
            // Flash settings
            settings.setPluginState(WebSettings.PluginState.ON);

            // Geo location settings
            settings.setGeolocationEnabled(true);
            settings.setGeolocationDatabasePath("/data/data/selendroid");
        }
    });
}

From source file:io.selendroid.server.model.SelendroidWebDriver.java

private void configureWebView(final WebView view) {
    ServerInstrumentation.getInstance().getCurrentActivity().runOnUiThread(new Runnable() {

        @Override/*w w w  .  ja  v  a  2s.co m*/
        public void run() {
            try {
                view.clearCache(true);
                view.clearFormData();
                view.clearHistory();
                view.setFocusable(true);
                view.setFocusableInTouchMode(true);
                view.setNetworkAvailable(true);
                // need to check the class name rather than checking instanceof
                // since when it is not an instanceof, it likely means the app under test
                // does not contain the Cordova project and this will cause a RuntimeException
                if (view.getClass().getSimpleName().equalsIgnoreCase("CordovaWebView")) {
                    CordovaWebView webview = (CordovaWebView) view;
                    CordovaInterface ci = null;
                    chromeClient = new ExtendedCordovaChromeClient(null, webview);
                } else {
                    chromeClient = new SelendroidWebChromeClient();
                }
                view.setWebChromeClient(chromeClient);

                WebSettings settings = view.getSettings();
                settings.setJavaScriptCanOpenWindowsAutomatically(true);
                settings.setSupportMultipleWindows(true);
                settings.setBuiltInZoomControls(true);
                settings.setJavaScriptEnabled(true);
                settings.setAppCacheEnabled(true);
                settings.setAppCacheMaxSize(10 * 1024 * 1024);
                settings.setAppCachePath("");
                settings.setDatabaseEnabled(true);
                settings.setDomStorageEnabled(true);
                settings.setGeolocationEnabled(true);
                settings.setSaveFormData(false);
                settings.setSavePassword(false);
                settings.setRenderPriority(WebSettings.RenderPriority.HIGH);
                // Flash settings
                settings.setPluginState(WebSettings.PluginState.ON);

                // Geo location settings
                settings.setGeolocationEnabled(true);
                settings.setGeolocationDatabasePath("/data/data/selendroid");
            } catch (Exception e) {
                SelendroidLogger.error("Error configuring web view", e);
            }
        }
    });
}