use of android.webkit.WebViewClient in project UltimateAndroid by cymcsg.
the class Html5Webview method init.
private void init(Context context) {
mContext = context;
Activity mActivity = (Activity) mContext;
mLayout = new FrameLayout(context);
mBrowserFrameLayout = (FrameLayout) LayoutInflater.from(mActivity).inflate(R.layout.custom_screen, null);
mContentView = (FrameLayout) mBrowserFrameLayout.findViewById(R.id.main_content);
mCustomViewContainer = (FrameLayout) mBrowserFrameLayout.findViewById(R.id.fullscreen_custom_content);
mLayout.addView(mBrowserFrameLayout, COVER_SCREEN_PARAMS);
// Configure the webview
WebSettings s = getSettings();
s.setBuiltInZoomControls(true);
s.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
s.setUseWideViewPort(true);
s.setLoadWithOverviewMode(true);
// s.setSavePassword(true);
s.setSaveFormData(true);
s.setJavaScriptEnabled(true);
mWebChromeClient = new MyWebChromeClient();
setWebChromeClient(mWebChromeClient);
setWebViewClient(new WebViewClient());
setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
// enable navigator.geolocation
// s.setGeolocationEnabled(true);
// s.setGeolocationDatabasePath("/data/data/org.itri.html5webview/databases/");
// enable Web Storage: localStorage, sessionStorage
s.setDomStorageEnabled(true);
mContentView.addView(this);
}
use of android.webkit.WebViewClient in project AntennaPod by AntennaPod.
the class ItemFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View layout = inflater.inflate(R.layout.feeditem_fragment, container, false);
root = (ViewGroup) layout.findViewById(R.id.content_root);
LinearLayout header = (LinearLayout) root.findViewById(R.id.header);
if (feedItems.length > 0) {
header.setOnTouchListener((v, event) -> headerGestureDetector.onTouchEvent(event));
}
txtvPodcast = (TextView) layout.findViewById(R.id.txtvPodcast);
txtvPodcast.setOnClickListener(v -> openPodcast());
txtvTitle = (TextView) layout.findViewById(R.id.txtvTitle);
if (Build.VERSION.SDK_INT >= 23) {
txtvTitle.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_FULL);
}
txtvDuration = (TextView) layout.findViewById(R.id.txtvDuration);
txtvPublished = (TextView) layout.findViewById(R.id.txtvPublished);
if (Build.VERSION.SDK_INT >= 14) {
// ellipsize is causing problems on old versions, see #448
txtvTitle.setEllipsize(TextUtils.TruncateAt.END);
}
webvDescription = (WebView) layout.findViewById(R.id.webvDescription);
if (UserPreferences.getTheme() == R.style.Theme_AntennaPod_Dark) {
if (Build.VERSION.SDK_INT >= 11 && Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
webvDescription.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
webvDescription.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.black));
}
webvDescription.getSettings().setUseWideViewPort(false);
webvDescription.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
webvDescription.getSettings().setLoadWithOverviewMode(true);
if (feedItems.length > 0) {
webvDescription.setOnLongClickListener(webViewLongClickListener);
}
webvDescription.setOnTouchListener((v, event) -> webviewGestureDetector.onTouchEvent(event));
webvDescription.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
if (IntentUtils.isCallable(getActivity(), intent)) {
startActivity(intent);
}
return true;
}
});
registerForContextMenu(webvDescription);
imgvCover = (ImageView) layout.findViewById(R.id.imgvCover);
imgvCover.setOnClickListener(v -> openPodcast());
progbarDownload = (ProgressBar) layout.findViewById(R.id.progbarDownload);
progbarLoading = (ProgressBar) layout.findViewById(R.id.progbarLoading);
butAction1 = (IconButton) layout.findViewById(R.id.butAction1);
butAction2 = (IconButton) layout.findViewById(R.id.butAction2);
butAction1.setOnClickListener(v -> {
if (item == null) {
return;
}
DefaultActionButtonCallback actionButtonCallback = new DefaultActionButtonCallback(getActivity());
actionButtonCallback.onActionButtonPressed(item, item.isTagged(FeedItem.TAG_QUEUE) ? LongList.of(item.getId()) : new LongList(0));
FeedMedia media = item.getMedia();
if (media != null && media.isDownloaded()) {
((MainActivity) getActivity()).dismissChildFragment();
}
});
butAction2.setOnClickListener(v -> {
if (item == null) {
return;
}
if (item.hasMedia()) {
FeedMedia media = item.getMedia();
if (!media.isDownloaded()) {
DBTasks.playMedia(getActivity(), media, true, true, true);
((MainActivity) getActivity()).dismissChildFragment();
} else {
DBWriter.deleteFeedMediaOfItem(getActivity(), media.getId());
}
} else if (item.getLink() != null) {
Uri uri = Uri.parse(item.getLink());
getActivity().startActivity(new Intent(Intent.ACTION_VIEW, uri));
}
});
return layout;
}
use of android.webkit.WebViewClient in project OneSignal-Android-SDK by OneSignal.
the class GreenActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_green);
String openURL = getIntent().getStringExtra("openURL");
final TextView textView = (TextView) findViewById(R.id.debug_view);
textView.setText("URL from additionalData: " + openURL);
Button onBackButton = (Button) (findViewById(R.id.back_button));
onBackButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent);
}
});
WebView webView = (WebView) (findViewById(R.id.webview));
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient());
if (openURL == null) {
webView.loadUrl("https://google.com");
} else {
webView.loadUrl(openURL);
}
}
use of android.webkit.WebViewClient in project Rashr by DsLNeXuS.
the class SettingsFragment method showChangelog.
public static void showChangelog(Context AppContext) {
AlertDialog.Builder dialog = new AlertDialog.Builder(AppContext);
dialog.setTitle(R.string.changelog);
WebView changes = new WebView(AppContext);
changes.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
changes.setWebViewClient(new WebViewClient());
changes.loadUrl(Const.CHANGELOG_URL);
changes.clearCache(true);
dialog.setView(changes);
dialog.show();
}
use of android.webkit.WebViewClient in project weex-example by KalicyZhou.
the class WXWebViewTest method testLoadUrl.
@Test
public void testLoadUrl() throws Exception {
String url = "http://www.taobao.com";
view.loadUrl(url);
WebViewClient client = shadow.getWebViewClient();
client.onPageStarted(webView, url, null);
client.onPageFinished(webView, url);
WebChromeClient chromeClient = shadow.getWebChromeClient();
chromeClient.onProgressChanged(webView, 10);
chromeClient.onProgressChanged(webView, 100);
chromeClient.onReceivedTitle(webView, "test");
}
Aggregations