Search in sources :

Example 11 with WebView

use of android.webkit.WebView in project materialistic by hidroh.

the class ReadabilityFragmentTest method testFontMenu.

@Test
public void testFontMenu() {
    verify(readabilityClient).parse(eq("1"), eq("http://example.com/article.html"), callback.capture());
    callback.getValue().onResponse("<div>content</div>");
    PreferenceManager.getDefaultSharedPreferences(activity).edit().putString(activity.getString(R.string.pref_readability_font), "DroidSans.ttf").apply();
    WebView webView = (WebView) activity.findViewById(R.id.web_view);
    shadowOf(webView).getWebViewClient().onPageFinished(webView, "about:blank");
    assertThat(shadowOf(webView).getLastLoadDataWithBaseURL().data).contains("DroidSans.ttf");
    assertEquals("DroidSans.ttf", Preferences.Theme.getReadabilityTypeface(activity));
    controller.pause().stop().destroy();
}
Also used : WebView(android.webkit.WebView) ShadowWebView(io.github.hidroh.materialistic.test.shadow.ShadowWebView) Test(org.junit.Test)

Example 12 with WebView

use of android.webkit.WebView in project materialistic by hidroh.

the class ReadabilityFragmentTest method testFontSizeMenu.

@Test
public void testFontSizeMenu() {
    verify(readabilityClient).parse(eq("1"), eq("http://example.com/article.html"), callback.capture());
    callback.getValue().onResponse("<div>content</div>");
    fragment.onOptionsItemSelected(new RoboMenuItem(R.id.menu_font_options));
    assertThat(fragment.getFragmentManager()).hasFragmentWithTag(PopupSettingsFragment.class.getName());
    PreferenceManager.getDefaultSharedPreferences(activity).edit().putString(activity.getString(R.string.pref_readability_text_size), "3").apply();
    WebView webView = (WebView) activity.findViewById(R.id.web_view);
    shadowOf(webView).getWebViewClient().onPageFinished(webView, "about:blank");
    assertThat(shadowOf(webView).getLastLoadDataWithBaseURL().data).contains("20");
    assertEquals(R.style.AppTextSize_XLarge, Preferences.Theme.resolvePreferredReadabilityTextSize(activity));
    controller.pause().stop().destroy();
}
Also used : WebView(android.webkit.WebView) ShadowWebView(io.github.hidroh.materialistic.test.shadow.ShadowWebView) RoboMenuItem(org.robolectric.fakes.RoboMenuItem) Test(org.junit.Test)

Example 13 with WebView

use of android.webkit.WebView in project SeriesGuide by UweTrottmann.

the class BaseOAuthActivity method setupViews.

private void setupViews() {
    webview = (WebView) findViewById(R.id.webView);
    buttonContainer = findViewById(R.id.containerOauthButtons);
    progressBar = findViewById(R.id.progressBarOauth);
    textViewMessage = (TextView) buttonContainer.findViewById(R.id.textViewOauthMessage);
    // setup buttons (can be used if browser launch fails or user comes back without code)
    Button buttonBrowser = (Button) findViewById(R.id.buttonOauthBrowser);
    buttonBrowser.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            launchBrowser();
        }
    });
    Button buttonWebView = (Button) findViewById(R.id.buttonOauthWebView);
    buttonWebView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            activateWebView();
        }
    });
    activateFallbackButtons();
    setMessage(null);
}
Also used : Button(android.widget.Button) TextView(android.widget.TextView) View(android.view.View) WebView(android.webkit.WebView)

Example 14 with WebView

use of android.webkit.WebView in project material-dialogs by afollestad.

the class MDRootLayout method setUpDividersVisibility.

private void setUpDividersVisibility(final View view, final boolean setForTop, final boolean setForBottom) {
    if (view == null) {
        return;
    }
    if (view instanceof ScrollView) {
        final ScrollView sv = (ScrollView) view;
        if (canScrollViewScroll(sv)) {
            addScrollListener(sv, setForTop, setForBottom);
        } else {
            if (setForTop) {
                drawTopDivider = false;
            }
            if (setForBottom) {
                drawBottomDivider = false;
            }
        }
    } else if (view instanceof AdapterView) {
        final AdapterView sv = (AdapterView) view;
        if (canAdapterViewScroll(sv)) {
            addScrollListener(sv, setForTop, setForBottom);
        } else {
            if (setForTop) {
                drawTopDivider = false;
            }
            if (setForBottom) {
                drawBottomDivider = false;
            }
        }
    } else if (view instanceof WebView) {
        view.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

            @Override
            public boolean onPreDraw() {
                if (view.getMeasuredHeight() != 0) {
                    if (!canWebViewScroll((WebView) view)) {
                        if (setForTop) {
                            drawTopDivider = false;
                        }
                        if (setForBottom) {
                            drawBottomDivider = false;
                        }
                    } else {
                        addScrollListener((ViewGroup) view, setForTop, setForBottom);
                    }
                    view.getViewTreeObserver().removeOnPreDrawListener(this);
                }
                return true;
            }
        });
    } else if (view instanceof RecyclerView) {
        boolean canScroll = canRecyclerViewScroll((RecyclerView) view);
        if (setForTop) {
            drawTopDivider = canScroll;
        }
        if (setForBottom) {
            drawBottomDivider = canScroll;
        }
        if (canScroll) {
            addScrollListener((ViewGroup) view, setForTop, setForBottom);
        }
    } else if (view instanceof ViewGroup) {
        View topView = getTopView((ViewGroup) view);
        setUpDividersVisibility(topView, setForTop, setForBottom);
        View bottomView = getBottomView((ViewGroup) view);
        if (bottomView != topView) {
            setUpDividersVisibility(bottomView, false, true);
        }
    }
}
Also used : ScrollView(android.widget.ScrollView) ViewGroup(android.view.ViewGroup) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) WebView(android.webkit.WebView) ViewTreeObserver(android.view.ViewTreeObserver) RecyclerView(android.support.v7.widget.RecyclerView) ScrollView(android.widget.ScrollView) View(android.view.View) AdapterView(android.widget.AdapterView) WebView(android.webkit.WebView)

Example 15 with WebView

use of android.webkit.WebView in project Inscription by MartinvanZ.

the class CustomChangelogActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_custom_changelog);
    final ChangeLogDialog changeLog = new ChangeLogDialog(this);
    final WebView webView = (WebView) findViewById(R.id.webView1);
    webView.loadDataWithBaseURL(null, changeLog.getHTML(), "text/html", "utf-8", null);
}
Also used : WebView(android.webkit.WebView) ChangeLogDialog(com.inscription.ChangeLogDialog)

Aggregations

WebView (android.webkit.WebView)594 WebViewClient (android.webkit.WebViewClient)214 View (android.view.View)176 WebSettings (android.webkit.WebSettings)103 Intent (android.content.Intent)87 SuppressLint (android.annotation.SuppressLint)79 WebChromeClient (android.webkit.WebChromeClient)77 TextView (android.widget.TextView)61 Bitmap (android.graphics.Bitmap)55 LinearLayout (android.widget.LinearLayout)39 DialogInterface (android.content.DialogInterface)36 ImageView (android.widget.ImageView)35 WebResourceRequest (android.webkit.WebResourceRequest)32 Uri (android.net.Uri)31 Test (org.junit.Test)27 Bundle (android.os.Bundle)26 AlertDialog (android.app.AlertDialog)24 Activity (android.app.Activity)22 Handler (android.os.Handler)20 IOException (java.io.IOException)20