Search in sources :

Example 81 with WebView

use of android.webkit.WebView in project Anki-Android by Ramblurr.

the class Reviewer method createWebView.

private WebView createWebView() {
    WebView webView = new MyWebView(this);
    webView.setWillNotCacheDrawing(true);
    webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    if (mZoomEnabled) {
        webView.getSettings().setBuiltInZoomControls(true);
    }
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebChromeClient(new AnkiDroidWebChromeClient());
    webView.addJavascriptInterface(new JavaScriptInterface(this), "ankidroid");
    if (AnkiDroidApp.SDK_VERSION > 7) {
        webView.setFocusableInTouchMode(false);
    }
    AnkiDroidApp.getCompat().setScrollbarFadingEnabled(webView, mPrefFadeScrollbars);
    Log.i(AnkiDroidApp.TAG, "Focusable = " + webView.isFocusable() + ", Focusable in touch mode = " + webView.isFocusableInTouchMode());
    return webView;
}
Also used : WebView(android.webkit.WebView)

Example 82 with WebView

use of android.webkit.WebView in project Anki-Android by Ramblurr.

the class SearchImageActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        boolean b = savedInstanceState.getBoolean(BUNDLE_KEY_SHUT_OFF, false);
        if (b) {
            finishCancel();
            return;
        }
    }
    setContentView(R.layout.activity_search_image);
    try {
        mSource = getIntent().getExtras().getString(EXTRA_SOURCE).toString();
    } catch (Exception e) {
        mSource = "";
    }
    // If translation fails this is a default - source will be returned.
    mWebView = (WebView) findViewById(R.id.ImageSearchWebView);
    mWebView.setWebViewClient(new WebViewClient() {

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            processPageLoadFinished();
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
            processPageLoadStarted();
        }
    });
    mPickButton = (Button) findViewById(R.id.ImageSearchPick);
    mPickButton.setEnabled(false);
    mPickButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            pickImage();
        }
    });
    mNextButton = (Button) findViewById(R.id.ImageSearchNext);
    mNextButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            nextClicked();
        }
    });
    mPrevButton = (Button) findViewById(R.id.ImageSearchPrev);
    mPrevButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            prevClicked();
        }
    });
    mPrevButton.setEnabled(false);
}
Also used : Bitmap(android.graphics.Bitmap) OnClickListener(android.view.View.OnClickListener) WebView(android.webkit.WebView) View(android.view.View) WebView(android.webkit.WebView) WebViewClient(android.webkit.WebViewClient)

Example 83 with WebView

use of android.webkit.WebView in project robotium by RobotiumTech.

the class Solo method getWebUrl.

/**
	 * Returns the current web page URL.
	 *
	 * @return the current web page URL
	 */
public String getWebUrl() {
    if (config.commandLogging) {
        Log.d(config.commandLoggingTag, "getWebUrl()");
    }
    final WebView webView = waiter.waitForAndGetView(0, WebView.class);
    if (webView == null)
        Assert.fail("WebView is not found!");
    instrumentation.runOnMainSync(new Runnable() {

        public void run() {
            webUrl = webView.getUrl();
        }
    });
    return webUrl;
}
Also used : WebView(android.webkit.WebView)

Example 84 with WebView

use of android.webkit.WebView in project robotium by RobotiumTech.

the class Scroller method scroll.

/**
	 * Scrolls up and down.
	 *
	 * @param direction the direction in which to scroll
	 * @param allTheWay <code>true</code> if the view should be scrolled to the beginning or end,
	 *                  <code>false</code> to scroll one page up or down.
	 * @return {@code true} if more scrolling can be done
	 */
@SuppressWarnings("unchecked")
public boolean scroll(int direction, boolean allTheWay) {
    ArrayList<View> viewList = RobotiumUtils.removeInvisibleViews(viewFetcher.getAllViews(true));
    ArrayList<View> filteredViews = RobotiumUtils.filterViewsToSet(new Class[] { ListView.class, ScrollView.class, GridView.class, WebView.class }, viewList);
    List<View> scrollableSupportPackageViews = viewFetcher.getScrollableSupportPackageViews(true);
    for (View viewToScroll : scrollableSupportPackageViews) {
        filteredViews.add(viewToScroll);
    }
    View view = viewFetcher.getFreshestView(filteredViews);
    if (view == null) {
        return false;
    }
    if (view instanceof AbsListView) {
        return scrollList((AbsListView) view, direction, allTheWay);
    }
    if (view instanceof WebView) {
        return scrollWebView((WebView) view, direction, allTheWay);
    }
    if (allTheWay) {
        scrollViewAllTheWay(view, direction);
        return false;
    } else {
        return scrollView(view, direction);
    }
}
Also used : AbsListView(android.widget.AbsListView) WebView(android.webkit.WebView) GridView(android.widget.GridView) AbsListView(android.widget.AbsListView) ScrollView(android.widget.ScrollView) View(android.view.View) ListView(android.widget.ListView) WebView(android.webkit.WebView)

Example 85 with WebView

use of android.webkit.WebView in project robotium by RobotiumTech.

the class WebUtils method executeJavaScriptFunction.

/**
	 * Executes the given JavaScript function
	 * 
	 * @param function the function as a String
	 * @return true if JavaScript function was executed
	 */
private boolean executeJavaScriptFunction(final String function) {
    List<WebView> webViews = viewFetcher.getCurrentViews(WebView.class, true);
    final WebView webView = viewFetcher.getFreshestView((ArrayList<WebView>) webViews);
    if (webView == null) {
        return false;
    }
    final String javaScript = setWebFrame(prepareForStartOfJavascriptExecution(webViews));
    inst.runOnMainSync(new Runnable() {

        public void run() {
            if (webView != null) {
                webView.loadUrl("javascript:" + javaScript + function);
            }
        }
    });
    return true;
}
Also used : WebView(android.webkit.WebView)

Aggregations

WebView (android.webkit.WebView)328 WebViewClient (android.webkit.WebViewClient)108 View (android.view.View)82 WebSettings (android.webkit.WebSettings)48 Intent (android.content.Intent)42 SuppressLint (android.annotation.SuppressLint)37 WebChromeClient (android.webkit.WebChromeClient)37 TextView (android.widget.TextView)28 DialogInterface (android.content.DialogInterface)23 LinearLayout (android.widget.LinearLayout)23 ImageView (android.widget.ImageView)22 Bitmap (android.graphics.Bitmap)19 AlertDialog (android.app.AlertDialog)17 Test (org.junit.Test)15 Uri (android.net.Uri)12 Bundle (android.os.Bundle)12 Handler (android.os.Handler)11 WebResourceRequest (android.webkit.WebResourceRequest)11 Drawable (android.graphics.drawable.Drawable)10 Button (android.widget.Button)10