use of android.webkit.WebChromeClient in project wire-android by wireapp.
the class InAppWebViewFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup viewGroup, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_in_app_web_view, viewGroup, false);
webView = ViewUtils.getView(view, R.id.wv__inapp);
if (getArguments() == null || !getArguments().containsKey(ARG_URL_TO_BE_OPENED)) {
throw new RuntimeException("InAppWebViewFragment can only be opened via newInstance(url");
}
webView.setWebViewClient(new WebViewClient());
webView.setWebChromeClient(new WebChromeClient());
webView.loadUrl(getArguments().getString(ARG_URL_TO_BE_OPENED));
View closeButton = ViewUtils.getView(view, R.id.gtv__inapp__close);
if (getArguments().getBoolean(ARG_WITH_CLOSE_BUTTON)) {
closeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getContainer().dismissInAppWebView();
}
});
} else {
closeButton.setVisibility(View.GONE);
}
return view;
}
use of android.webkit.WebChromeClient in project android_frameworks_base by crdroidandroid.
the class LooperAcceleration method makeView.
private View makeView() {
LinearLayout layout = new LinearLayout(this);
layout.addView(new IsAcceleratedView(this), LayoutParams.MATCH_PARENT, 60);
if (INCLUDE_WEBVIEW) {
WebView wv = new WebView(this);
wv.setWebViewClient(new WebViewClient());
wv.setWebChromeClient(new WebChromeClient());
wv.loadUrl("http://www.webkit.org/blog-files/3d-transforms/poster-circle.html");
layout.addView(wv, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
}
return layout;
}
use of android.webkit.WebChromeClient in project baker-android by bakerframework.
the class GindActivity method loadHeader.
private void loadHeader() {
WebView webview = (WebView) findViewById(R.id.headerView);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setUseWideViewPort(true);
//webview.getSettings().setLoadWithOverviewMode(true);
webview.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
return true;
}
});
webview.setBackgroundColor(Color.TRANSPARENT);
webview.setWebChromeClient(new WebChromeClient());
webview.loadUrl(getString(R.string.headerUrl));
}
use of android.webkit.WebChromeClient in project SimplifyReader by chentao0707.
the class BrowserLayout method init.
private void init(Context context) {
mContext = context;
setOrientation(VERTICAL);
mProgressBar = (ProgressBar) LayoutInflater.from(context).inflate(R.layout.progress_horizontal, null);
mProgressBar.setMax(100);
mProgressBar.setProgress(0);
addView(mProgressBar, LayoutParams.MATCH_PARENT, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, mBarHeight, getResources().getDisplayMetrics()));
mWebView = new WebView(context);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
mWebView.getSettings().setDefaultTextEncodingName("UTF-8");
mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
mWebView.getSettings().setBuiltInZoomControls(false);
mWebView.getSettings().setSupportMultipleWindows(true);
mWebView.getSettings().setUseWideViewPort(true);
mWebView.getSettings().setLoadWithOverviewMode(true);
mWebView.getSettings().setSupportZoom(false);
mWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
mWebView.getSettings().setDomStorageEnabled(true);
mWebView.getSettings().setLoadsImagesAutomatically(true);
LayoutParams lps = new LayoutParams(LayoutParams.MATCH_PARENT, 0, 1);
addView(mWebView, lps);
mWebView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
super.onProgressChanged(view, newProgress);
if (newProgress == 100) {
mProgressBar.setVisibility(View.GONE);
} else {
mProgressBar.setVisibility(View.VISIBLE);
mProgressBar.setProgress(newProgress);
}
}
});
mWebView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
mLoadUrl = url;
}
});
mBrowserControllerView = LayoutInflater.from(context).inflate(R.layout.browser_controller, null);
mGoBackBtn = (ImageButton) mBrowserControllerView.findViewById(R.id.browser_controller_back);
mGoForwardBtn = (ImageButton) mBrowserControllerView.findViewById(R.id.browser_controller_forward);
mGoBrowserBtn = (ImageButton) mBrowserControllerView.findViewById(R.id.browser_controller_go);
mRefreshBtn = (ImageButton) mBrowserControllerView.findViewById(R.id.browser_controller_refresh);
mGoBackBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (canGoBack()) {
goBack();
}
}
});
mGoForwardBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (canGoForward()) {
goForward();
}
}
});
mRefreshBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
loadUrl(mLoadUrl);
}
});
mGoBrowserBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (!CommonUtils.isEmpty(mLoadUrl)) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(mLoadUrl));
mContext.startActivity(intent);
}
}
});
addView(mBrowserControllerView, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
}
use of android.webkit.WebChromeClient in project clutchandroid by clutchio.
the class ClutchView method clutchInit.
@SuppressLint("SetJavaScriptEnabled")
private void clutchInit() {
loading = new ProgressDialog(this.getContext());
loading.hide();
this.setWebChromeClient(new WebChromeClient() {
// TODO: Clutch Debug Toolbar
@Override
public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {
if (!"methodCalled".equals(defaultValue)) {
return false;
}
JSONObject jsonMessage = null;
String methodName = null;
String callbackId = null;
JSONObject params = null;
try {
jsonMessage = new JSONObject(message);
methodName = jsonMessage.getString("method");
callbackId = jsonMessage.getString("callbackNum");
params = jsonMessage.getJSONObject("args");
} catch (JSONException e) {
Log.e(TAG, "Could not decode JSON: " + message);
result.cancel();
return true;
}
if (methodName.equals("clutch.loading.begin")) {
String loadingMessage = params.optString("text");
if (loadingMessage == null) {
loadingMessage = "Loading...";
} else if ("null".equals(loadingMessage)) {
loadingMessage = "Loading...";
}
loading.setMessage(loadingMessage);
loading.show();
} else if (methodName.equals("clutch.loading.end")) {
loading.hide();
}
ClutchCallback callback = null;
if (!"0".equals(callbackId)) {
callback = new ClutchCallback(ClutchView.this, callbackId);
}
dispatcher.methodCalled(methodName, params, callback);
result.cancel();
return true;
}
});
ClutchSync.addClutchView(this);
WebSettings settings = this.getSettings();
settings.setJavaScriptEnabled(true);
settings.setSupportZoom(true);
settings.setAppCacheEnabled(false);
}
Aggregations