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;
}
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);
}
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;
}
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);
}
}
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;
}
Aggregations