use of android.webkit.WebViewClient in project android_packages_apps_GmsCore by microg.
the class LoginActivity method onCreate.
@SuppressLint("AddJavascriptInterface")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
accountType = AuthConstants.DEFAULT_ACCOUNT_TYPE;
accountManager = AccountManager.get(LoginActivity.this);
inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
webView = createWebView(this);
webView.addJavascriptInterface(new JsBridge(), "mm");
authContent = (ViewGroup) findViewById(R.id.auth_content);
((ViewGroup) findViewById(R.id.auth_root)).addView(webView);
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
Log.d(TAG, "pageFinished: " + url);
if ("identifier".equals(Uri.parse(url).getFragment()))
runOnUiThread(new Runnable() {
@Override
public void run() {
webView.setVisibility(VISIBLE);
}
});
if ("close".equals(Uri.parse(url).getFragment()))
closeWeb(false);
if (url.startsWith(PROGRAMMATIC_AUTH_URL))
closeWeb(true);
}
});
if (getIntent().hasExtra(EXTRA_TOKEN)) {
if (getIntent().hasExtra(EXTRA_EMAIL)) {
AccountManager accountManager = AccountManager.get(LoginActivity.this);
Account account = new Account(getIntent().getStringExtra(EXTRA_EMAIL), accountType);
accountManager.addAccountExplicitly(account, getIntent().getStringExtra(EXTRA_TOKEN), null);
retrieveGmsToken(account);
} else {
retrieveRtToken(getIntent().getStringExtra(EXTRA_TOKEN));
}
} else {
setMessage(R.string.auth_before_connect);
setBackButtonText(android.R.string.cancel);
setNextButtonText(R.string.auth_sign_in);
}
}
use of android.webkit.WebViewClient in project MaxLock by Maxr1998.
the class MaxLockPreferenceFragment method showChangelog.
private void showChangelog() {
AlertDialog.Builder changelog = new AlertDialog.Builder(getActivity());
WebView wv = new WebView(getContext());
wv.setWebViewClient(new WebViewClient());
wv.getSettings().setUserAgentString("MaxLock App v" + BuildConfig.VERSION_NAME);
wv.loadUrl("http://maxlock.maxr1998.de/files/changelog-base.php");
changelog.setView(wv);
changelog.setPositiveButton(android.R.string.ok, null);
changelog.create().show();
}
use of android.webkit.WebViewClient in project BlogSource by TeachCourse.
the class H5WebViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_h5_web_view);
// Save the web view
webView = (VideoEnabledWebView) findViewById(R.id.webView);
// Initialize the VideoEnabledWebChromeClient and set event handlers
// Your own view, read class comments
View nonVideoLayout = findViewById(R.id.nonVideoLayout);
// Your own view, read class comments
ViewGroup videoLayout = (ViewGroup) findViewById(R.id.videoLayout);
// Your own view, read class comments
View loadingView = getLayoutInflater().inflate(R.layout.activity_h5_web_view, null);
webChromeClient = new // See all available constructors...
VideoEnabledWebChromeClient(// See all available constructors...
nonVideoLayout, // See all available constructors...
videoLayout, // See all available constructors...
loadingView, // See all available constructors...
webView) {
// Subscribe to standard events, such as onProgressChanged()...
@Override
public void onProgressChanged(WebView view, int progress) {
// Your code...
}
};
webChromeClient.setOnToggledFullscreen(new VideoEnabledWebChromeClient.ToggledFullscreenCallback() {
@Override
public void toggledFullscreen(boolean fullscreen) {
// Your code to handle the full-screen change, for example showing and hiding the title bar. Example:
if (fullscreen) {
WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
attrs.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
getWindow().setAttributes(attrs);
if (android.os.Build.VERSION.SDK_INT >= 14) {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
}
} else {
WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
attrs.flags &= ~WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
getWindow().setAttributes(attrs);
if (android.os.Build.VERSION.SDK_INT >= 14) {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
}
}
}
});
webView.setWebChromeClient(webChromeClient);
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("http:") || url.startsWith("https:")) {
return false;
}
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
view.getContext().startActivity(intent);
return true;
}
});
// Navigate everywhere you want, this classes have only been tested on YouTube's mobile site
webView.loadUrl(url);
initButton(getWindow().getDecorView());
}
use of android.webkit.WebViewClient in project RoMote by wseemann.
the class StoreFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mWebView.loadUrl("https://channelstore.roku.com/browse");
mWebView.setWebViewClient(new WebViewClient());
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
}
use of android.webkit.WebViewClient in project connect-sdk-client-android by Ingenico-ePayments.
the class PaymentWebViewActivity method setupWebView.
/**
* Setup the webview
* This is done this way to prevent data loss and pagereloads on rotation of the device
* @param context, used for loading PaymentProduct from Preferences
*/
private void setupWebView(Context context) {
webviewContainer = (LinearLayout) findViewById(R.id.webviewContainer);
if (paymentWebView == null) {
paymentWebView = new WebView(this);
paymentWebView.setWebViewClient(new WebViewClient());
paymentWebView.getSettings().setJavaScriptEnabled(true);
Intent paymentInputIntent = getIntent();
String url = paymentInputIntent.getStringExtra(Constants.INTENT_URL_WEBVIEW);
paymentWebView.loadUrl(url);
}
webviewContainer.addView(paymentWebView);
}
Aggregations