Example usage for android.webkit WebView getSettings

List of usage examples for android.webkit WebView getSettings

Introduction

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

Prototype

public WebSettings getSettings() 

Source Link

Document

Gets the WebSettings object used to control the settings for this WebView.

Usage

From source file:com.ezac.gliderlogs.FlightGliderActivity.java

@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.view_list);//w  w  w  .  ja va2  s .  c  om

    // hide soft keyboard
    setMode();

    WebView browser = (WebView) findViewById(R.id.webview_1);
    browser.setWebViewClient(new WebViewClient());
    browser.getSettings().setSupportZoom(true);
    browser.getSettings().setBuiltInZoomControls(true);
    browser.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    browser.setScrollbarFadingEnabled(true);
    browser.getSettings().setLoadsImagesAutomatically(true);
    browser.getSettings().setDomStorageEnabled(true);
    browser.getSettings().setAppCacheEnabled(true);
    browser.getSettings().setAppCacheMaxSize(1024 * 1024 * 32);
    String appCachePath = getApplicationContext().getCacheDir().getAbsolutePath();
    browser.getSettings().setAppCachePath(appCachePath);
    browser.getSettings().setAllowFileAccess(true);
    browser.getSettings().setJavaScriptEnabled(true);
    browser.loadUrl("http://live.glidertracking.com/index.php");
}

From source file:com.ezac.gliderlogs.FlightOGNActivity.java

@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.view_list);//from w  w  w.j av a 2  s.co  m

    // hide soft keyboard
    setMode();

    WebView browser = (WebView) findViewById(R.id.webview_1);
    browser.setWebViewClient(new WebViewClient());
    browser.getSettings().setSupportZoom(true);
    browser.getSettings().setBuiltInZoomControls(true);
    browser.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    browser.setScrollbarFadingEnabled(true);
    browser.getSettings().setLoadsImagesAutomatically(true);
    browser.getSettings().setDomStorageEnabled(true);
    browser.getSettings().setAppCacheEnabled(true);
    browser.getSettings().setAppCacheMaxSize(1024 * 1024 * 32);
    String appCachePath = getApplicationContext().getCacheDir().getAbsolutePath();
    browser.getSettings().setAppCachePath(appCachePath);
    browser.getSettings().setAllowFileAccess(true);
    browser.getSettings().setJavaScriptEnabled(true);
    browser.loadUrl("http://live.glidernet.org/#c=51.27405,3.93909&z=11");
}

From source file:com.scm.reader.resultPage.ui.ItemViewFragment.java

protected void initializeWebView(WebView webView) {

    // webview settings
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setUserAgentString(getSDKUserAgentString());

    webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    webView.getSettings().setDomStorageEnabled(true);
    webView.getSettings().setAllowFileAccess(true);

    mWebView.addJavascriptInterface(new ItemViewJavascriptInterface(getActivity(), mWebViewClient), "Android");
}

From source file:com.sonnychen.aviationhk.views.MetarFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.v("METAR-UI", "Starting");
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_metar, container, false);
    //        ((TextView) view.findViewById(R.id.metar)).setText(BaseApplication.Data.METAR_Code);
    WebView metar = ((WebView) view.findViewById(R.id.metar_html));
    metar.setInitialScale(1);//  w  ww .  j ava 2s.  co  m
    metar.getSettings().setJavaScriptEnabled(false);
    metar.getSettings().setLoadWithOverviewMode(true);
    metar.getSettings().setUseWideViewPort(true);
    metar.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    metar.setScrollbarFadingEnabled(false);
    metar.loadDataWithBaseURL("", BaseApplication.Data.METAR_HTML + "<p><p>" + BaseApplication.Data.TAF_HTML
            + "<p><pre>" + BaseApplication.Data.SIGMET_Code + "</pre>", "text/html", "UTF-8", "");
    //        ((TextView) view.findViewById(R.id.taf)).setText(BaseApplication.Data.TAF_Code);
    //        ((TextView) view.findViewById(R.id.sigmet)).setText(BaseApplication.Data.SIGMET_Code);
    return view;
}

From source file:de.vanita5.twittnuker.fragment.support.BaseSupportWebViewFragment.java

@Override
public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    final WebView view = getWebView();
    view.setWebViewClient(new DefaultWebViewClient(getActivity()));
    final WebSettings settings = view.getSettings();
    settings.setBuiltInZoomControls(true);
    settings.setJavaScriptEnabled(true);
    WebSettingsAccessor.setAllowUniversalAccessFromFileURLs(settings, true);
}

From source file:com.elekso.potfix.fragment.LicenseFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.fragment_license, container, false);
    WebView heroespage = (WebView) rootView.findViewById(R.id.webView_license);
    WebSettings webSettings = heroespage.getSettings();
    webSettings.setJavaScriptEnabled(true);
    heroespage.loadUrl("file:///android_asset/license.html");

    // return inflater.inflate(R.layout.fragment_license, container, false);
    return rootView;
}

From source file:net.meiolania.apps.habrahabr.fragments.qa.QaShowFragment.java

@Override
public void onLoadFinished(Loader<QaFullData> loader, QaFullData data) {
    if (getSherlockActivity() != null) {
        WebView content = (WebView) getSherlockActivity().findViewById(R.id.qa_content);
        content.getSettings().setPluginsEnabled(true);
        content.getSettings().setBuiltInZoomControls(true);
        content.getSettings().setSupportZoom(true);
        content.loadDataWithBaseURL("", data.getContent(), "text/html", "UTF-8", null);
    }//from  www . j  ava2s.com

    this.data = data;

    hideProgressDialog();
}

From source file:net.meiolania.apps.habrahabr.fragments.posts.PostShowFragment.java

@Override
public void onLoadFinished(Loader<PostsFullData> loader, PostsFullData data) {
    if (getSherlockActivity() != null) {
        WebView content = (WebView) getSherlockActivity().findViewById(R.id.post_content);
        content.getSettings().setPluginsEnabled(true);
        content.getSettings().setSupportZoom(true);
        content.getSettings().setBuiltInZoomControls(true);
        content.loadDataWithBaseURL("", data.getContent(), "text/html", "UTF-8", null);
    }/*from www .  j a  v a2 s  .  c  om*/

    this.data = data;

    hideProgressDialog();
}

From source file:com.ezac.gliderlogs.FlightEzacActivity.java

@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.ezac_list);//from   w w w  .  j a v  a 2 s. c om

    // hide soft keyboard
    setMode();

    Button close = (Button) findViewById(R.id.button_close);

    WebView browser = (WebView) findViewById(R.id.webview_1);
    browser.setWebViewClient(new WebViewClient());
    browser.getSettings().setSupportZoom(true);
    browser.getSettings().setBuiltInZoomControls(true);
    browser.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    browser.setScrollbarFadingEnabled(true);
    browser.getSettings().setLoadsImagesAutomatically(true);
    browser.getSettings().setDomStorageEnabled(true);
    browser.getSettings().setAppCacheEnabled(true);
    browser.getSettings().setAppCacheMaxSize(1024 * 1024 * 32);
    String appCachePath = getApplicationContext().getCacheDir().getAbsolutePath();
    browser.getSettings().setAppCachePath(appCachePath);
    browser.getSettings().setAllowFileAccess(true);
    browser.getSettings().setJavaScriptEnabled(true);
    browser.loadUrl("http://www.ezac.nl/drupal/");

    close.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            setResult(RESULT_OK);
            finish();
        }
    });
}

From source file:com.xiaoxin.apktools.view.CustomWebViewDialog.java

@NonNull
@Override/*  w w w. j  a  v  a 2 s.c om*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final View customView;
    try {
        customView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_webview, null);
    } catch (InflateException e) {
        throw new IllegalStateException("This device does not support Web Views.");
    }

    String dialogTitle = getArguments().getString("dialogTitle");
    AlertDialog dialog = new AlertDialog.Builder(getActivity()).setTitle(dialogTitle).setView(customView)
            .setPositiveButton(android.R.string.ok, null).show();

    final WebView webView = (WebView) customView.findViewById(R.id.webview);
    webView.getSettings().setDefaultTextEncodingName("utf-8");
    try {
        String htmlFileName = getArguments().getString("htmlFileName");
        StringBuilder buf = new StringBuilder();
        InputStream json = getActivity().getAssets().open(htmlFileName);
        BufferedReader in = new BufferedReader(new InputStreamReader(json, "UTF-8"));
        String str;
        while ((str = in.readLine()) != null)
            buf.append(str);
        in.close();

        final int accentColor = getArguments().getInt("accentColor");
        String formatLodString = buf.toString()
                .replace("{style-placeholder}", "body { background-color: #ffffff; color: #000; }")
                .replace("{link-color}", colorToHex(shiftColor(accentColor, true)))
                .replace("{link-color-active}", colorToHex(accentColor));
        webView.loadDataWithBaseURL(null, formatLodString, "text/html", "UTF-8", null);
    } catch (Throwable e) {
        webView.loadData("<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", "UTF-8");
    }
    return dialog;
}