All Projects → youlookwhat → Bywebview

youlookwhat / Bywebview

Licence: apache-2.0
🌐 WebView 全方面使用,JS交互、进度条、上传图片、错误页面、视频全屏播放、唤起原生App、获取网页源代码、被作为第三方浏览器打开、DeepLink、[腾讯x5使用示例]

Programming Languages

java
68154 projects - #9 most used programming language

Labels

Projects that are alternatives of or similar to Bywebview

Miox
Modern infrastructure of complex SPA
Stars: ✭ 374 (-61.91%)
Mutual labels:  webview
Android Reports And Resources
A big list of Android Hackerone disclosed reports and other resources.
Stars: ✭ 590 (-39.92%)
Mutual labels:  webview
Axwebviewcontroller
AXWebViewController is a webViewController to browse web content inside applications. It’s a lightweight controller on iOS platform based on WKWebView (UIWebView would be the base Kit under iOS 8.0). It added navigation tool bar to refresh, go back, go forward and so on. It support the navigation style on WeChat. It is a simple-using and convenient web view controller using inside applications.
Stars: ✭ 770 (-21.59%)
Mutual labels:  webview
Imgresize
移动端H5图片压缩
Stars: ✭ 391 (-60.18%)
Mutual labels:  webview
Aachartkit
📈📊🚀🚀🚀An elegant modern declarative data visualization chart framework for iOS, iPadOS and macOS. Extremely powerful, supports line, spline, area, areaspline, column, bar, pie, scatter, angular gauges, arearange, areasplinerange, columnrange, bubble, box plot, error bars, funnel, waterfall and polar chart types. 极其精美而又强大的跨平台数据可视化图表框架,支持柱状图、条形图、折…
Stars: ✭ 4,358 (+343.79%)
Mutual labels:  webview
React Native Wkwebview
WKWebview Component for React Native
Stars: ✭ 622 (-36.66%)
Mutual labels:  webview
Android Smartwebview
A webview integrated w/ native features to help create most advanced hybrid applications.
Stars: ✭ 357 (-63.65%)
Mutual labels:  webview
Tiny.scatter
Scatter compatible eos injection library
Stars: ✭ 31 (-96.84%)
Mutual labels:  webview
Cloudreader
🗡️ 云阅:一款基于网易云音乐UI,使用玩Android Api,Retrofit2 + RxJava2 + Room + MVVM-databinding架构开发的Android客户端
Stars: ✭ 4,611 (+369.55%)
Mutual labels:  webview
Multi
Create a custom, lightweight macOS app from a group of websites
Stars: ✭ 755 (-23.12%)
Mutual labels:  webview
Cordova Plugin Ionic Webview
Web View plugin for Cordova, specialized for Ionic apps.
Stars: ✭ 419 (-57.33%)
Mutual labels:  webview
Smartyoutubetv
Watch YouTube videos on your TV and set-top-box with comfort
Stars: ✭ 4,384 (+346.44%)
Mutual labels:  webview
Jxbwkwebview
An component WebView for iOS base on WKWebView
Stars: ✭ 646 (-34.22%)
Mutual labels:  webview
React Native Autoheight Webview
An auto height webview for React Native
Stars: ✭ 385 (-60.79%)
Mutual labels:  webview
Slimsocial For Twitter
Light version of Twitter. Light not only in weight but also in the use.
Stars: ✭ 24 (-97.56%)
Mutual labels:  webview
Youtube player flutter
Flutter plugin for playing or streaming YouTube videos inline using the official iFrame Player API. Supports both Android and iOS platforms.
Stars: ✭ 366 (-62.73%)
Mutual labels:  webview
Jsbridge
A simpler, extendable bidirectional communication Frame between Android WebView and Javascript
Stars: ✭ 612 (-37.68%)
Mutual labels:  webview
Popup Bridge Android
PopupBridge allows WebViews to open popup windows in a browser and send data back to the WebView
Stars: ✭ 31 (-96.84%)
Mutual labels:  webview
React Electron Webview
React component for the <webview> element in Electron.
Stars: ✭ 29 (-97.05%)
Mutual labels:  webview
Webview deno
🌐 Deno bindings for webview, a tiny library for creating web-based desktop GUIs
Stars: ✭ 729 (-25.76%)
Mutual labels:  webview

ByWebView

JitPack fir.im

Features

  • 基本配置使用(宽度自适应、返回网页上一层、显示网页标题等)
  • 唤起三方应用(拨打电话、发送短信、发送邮件等)
  • 上传图片(版本兼容)
  • 错误页面处理
  • 全屏播放网络视频
  • 与Js交互实例
  • 优雅的进度条显示控件

Demo示例:

  • DeepLink的基本使用
  • 被作为第三方浏览器打开
  • 腾讯x5使用示例

引用

  1. Add the JitPack repository to your build file
allprojects {
   	repositories {
   		...
   		maven { url 'https://jitpack.io' }
   	}
   }
  1. Add the dependency:
dependencies {
       implementation 'com.github.youlookwhat:ByWebView:1.0.0'
}

Use

byWebView = ByWebView
        .with(this)
        .setWebParent(container, new LinearLayout.LayoutParams(-1, -1))
        .useWebProgress(ContextCompat.getColor(this, R.color.coloRed))
        .loadUrl(mUrl);

与Js交互

  • 调用Js方法:
// 无参数调用
byWebView.getLoadJsHolder().quickCallJs("javacalljs");
// 传递参数调用
byWebView.getLoadJsHolder().quickCallJs("javacalljswithargs", "android传入到网页里的数据,有参");
  • Js调用Java方法:
ByWebView.with(this)
	.addJavascriptInterface("injectedObject", new MyJavascriptInterface(this))
	.loadUrl(mUrl);
window.injectedObject.startFunction()

生命周期处理

@Override
protected void onPause() {
    super.onPause();
    byWebView.onPause();
}

@Override
protected void onResume() {
    super.onResume();
    byWebView.onResume();
}

@Override
protected void onDestroy() {
    byWebView.onDestroy();
    super.onDestroy();
}

返回操作

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (byWebView.handleKeyEvent(keyCode, event)) {
        return true;
    } else {
        return super.onKeyDown(keyCode, event);
    }
}

上传图片之后的回调

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    byWebView.handleFileChooser(requestCode, resultCode, intent);
}

监听 标题、进度条、WebViewClient

byWebView = ByWebView
        .with(this)
        .setWebParent(container, new LinearLayout.LayoutParams(-1, -1))
        .useWebProgress(ContextCompat.getColor(this, R.color.coloRed))
        .setOnTitleProgressCallback(onTitleProgressCallback)
        .setOnByWebClientCallback(onByWebClientCallback)
        .addJavascriptInterface("injectedObject", new MyJavascriptInterface(this))
        .loadUrl(mUrl);
private OnTitleProgressCallback onTitleProgressCallback = new OnTitleProgressCallback() {
    
    @Override
    public void onReceivedTitle(String title) {
        Log.e("---title", title);
    }

    @Override
    public void onProgressChanged(int newProgress) {
        
    }
};

private OnByWebClientCallback onByWebClientCallback = new OnByWebClientCallback() {

    @Override
    public void onPageFinished(WebView view, String url) {
        // 网页加载完成后的回调
    }

    @Override
    public boolean isOpenThirdApp(String url) {
        // 处理三方链接
        Log.e("---url", url);
        return ByWebTools.handleThirdApp(ByWebViewActivity.this, url);
    }
};

自定义错误页面

ByWebView.with(this)
	.setErrorLayout(R.layout.by_load_url_error,"无法打开网页")
	.loadUrl(mUrl);

完整设置

byWebView = ByWebView
        .with(this)
        .useWebProgress(true) // 是否使用进度条,默认true,如使用可不用配置
        .setWebParent(container, new LinearLayout.LayoutParams(-1, -1)) // 设置WebView父容器
        .useWebProgress("#ffb6cf", "#ff0000", 3)// 进度条渐变色(开始颜色,结束颜色,高度)
        .setOnTitleProgressCallback(onTitleProgressCallback)// title 和 progress 监听
        .setOnByWebClientCallback(onByWebClientCallback)    // WebViewClient监听
        .setErrorLayout(R.layout.by_load_url_error, "无法打开网页") // 设置错误页面及标题
        .addJavascriptInterface("injectedObject", new MyJavascriptInterface(this)) // 设置Js监听
        .loadUrl(mUrl);

Document

Screenshots

Download

Tip

  • 混淆时应加上(通过JS向网页传值,如不加有时候会传值失败):

    -keepattributes *Annotation*
    -keepattributes *JavascriptInterface*
    -keepclassmembers class * {
       @android.webkit.JavascriptInterface <methods>;
    }
    
    

Thanks

Other

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].