Git Product home page Git Product logo

agentweb's Introduction

AgentWeb 介绍

AgentWeb 是一个基于的 Android WebView ,极度容易使用以及功能强大的库,提供了 Android WebView 一系列的问题解决方案 ,并且轻量和极度灵活,详细使用请参照上面的 Sample 。

Gradle 引入

allprojects {
  repositories {
    mavenCentral()
    maven { url 'https://jitpack.io' }
  }
}
  • Androidx

     implementation 'io.github.justson:agentweb-core:v5.1.1-androidx' 
     implementation 'io.github.justson:agentweb-filechooser:v5.1.1-androidx' // (可选)
     implementation 'com.github.Justson:Downloader:v5.0.4-androidx' // (可选)
    

相关

注意事项

  • 支付宝使用需要引入支付宝SDK ,并在项目中依赖 , 微信支付不需要做任何操作。
  • AgentWeb 内部使用了 AlertDialog 需要依赖 AppCompat 主题 。
  • setAgentWebParent 不支持 ConstraintLayout
  • mAgentWeb.getWebLifeCycle().onPause();会暂停应用内所有WebView
  • minSdkVersion 低于等于16以下自定义WebView请注意与 JS 之间通信安全。

文档帮助

有问题或者有更好的建议

赞赏

开源不易,你的支持是我更新的动力。

License

License

Copyright (C)  Justson(https://github.com/Justson/AgentWeb)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

agentweb's People

Contributors

clanaid avatar desfate avatar hujinqiang avatar justson avatar leondevlifelog avatar liyujiang-gzu avatar spenceacc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

agentweb's Issues

Android17以下不支持回调

@Override
public void callJs(String js, final ValueCallback<String> callback) {
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR1) {
        this.evaluateJs(js, callback);
    } else {
        this.loadJs(js);
    }
}

不支持 accept="image/*" capture="camera" 打开相机

大概看了下代码,发现onShowFileChooser 里的 FileChooserParams 也没有capture属性,只有个captureEnabled。这种的不能打开相机的要怎么处理,我看用UC浏览器可以打开,是不是跟浏览器内核有关?

反馈问题

  1. 如何修改通过WebView下载文件的路径?
  2. 我重复调用OnCreat下的方法想实现刷新界面不起作用,如何刷新当前WebView界面?

建议颜色那些加注解

比如:useDefaultIndicator(@ColorInt int color)
R.color.xx 也是int 但是是@ColorRes的,不加注解不好区分

js 调用java

我看到代码中,java 调用js,可以使用quickCallJs();那么 js 调用java,需要在那里做设置呢

建议sample工程和library工程做拆分,拆分为两个Repository

最近需要使用webview做一些复杂点的展示,就发现了您的开源工程。首先感谢您的分享!我想把您的library工程作为一个module嵌入到我的工程中,但是我发现我拷贝后就比较难与您的代码同步。还有一种选择是使用compile,但是这样的话一旦遇到问题不能及时修改。如果把library作为一个单独的module(一个单独的repository),再在sample repository中通过忽略library repository的git消除冲突的git校验。这样如果使用过程中发现问题可以及时修改,如果解决问题也可以把解决方案反馈给您

Select form field can't popup window, and jsconfirm crashed

1 . A basic form with select field, click no popup window, and monitor error as next:
webview show mWindowManager.addView RuntimeException

2 .Javascript confirm will crash the webview

I used AgentWeb with fragment.

AgentWeb is very nice!!

关于js交互问题

感谢您的分享,刚看到Javascript 调 Java的方法,是window.android.这种方式调用的.这种调用方法只有在android中使用AgentWeb才能调用成功吗?
因为一般公司的项目都是两个端的(ios和android),之前js直接用JavaScriptClient.方法 两个端的方法就都能调用了

反馈AgentWeb功能建议

有三个功能我觉得挺不错的,AgentWeb库当前里面有吗?
第一个功能:如果网站的标题颜色的绿色,可以自动获取到网站标题的颜色,并设置标题栏颜色和网站标题颜色为一致绿色
第二个功能:可以像QQ浏览器那样设置UA标识吗,就是可以根据设置来决定打开的页面为(Android页面还是电脑端页面)的网页
第三个功能:当点击网页中的图片时,可以实现自动跳转到图片预览界面,图片预览界面库推荐使用此库很不错https://github.com/Hitomis/transferee

闪退

运行一段时间会自动闪退,是h5写的太烂嘛?

onShowFileChooser 报错

E/dalvikvm: Could not find class 'android.webkit.WebChromeClient$FileChooserParams', referenced from method com.just.library.DefaultChromeClient.onShowFileChooser
E/dalvikvm: Could not find class 'org.greenrobot.greendao.database.DatabaseOpenHelper$EncryptedHelper', referenced from method org.greenrobot.greendao.database.DatabaseOpenHelper.checkEncryptedHelper
E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering

onDestroy()的是要做处理吗?

    public void onDestroy() {
        mAgentWeb.getWebLifeCycle().onDestroy();
        super.onDestroy();
    }

我这样调,发现退出activity的时候会崩溃

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.os.Handler.removeCallbacksAndMessages(java.lang.Object)' on a null object reference

我之前 看过很多webview的文章,提到退出时最后在onDestroy()做webview的置空操作,可以尽可能避免内存溢出
之前我是这样做的:

    protected void onDestroy() {
        super.onDestroy();
        if (mWebView != null) {
            mWebView.clearHistory();
            ((ViewGroup) mWebView.getParent()).removeView(mWebView);
            mWebView.loadUrl("about:blank");
            mWebView.stopLoading();
            mWebView.setWebChromeClient(null);
            mWebView.setWebViewClient(null);
            mWebView.destroy();
            mWebView = null;
        }
    }

现在agentWeb是否需要做类似的操作

下载安装判断版本有问题

AgentWebUtils里面getIntentCompat方法 if (Build.VERSION.SDK_INT >= 24) 这样才没问题。你之前的写法是在夜神模拟器上点击安装崩溃。
public static Intent getIntentCompat(Context context, File file) {
Intent mIntent = null;
LogUtils.i("Info", "getIntentCompat :" + context.getApplicationInfo().targetSdkVersion);
if (Build.VERSION.SDK_INT >= 24) {

        mIntent = new Intent(Intent.ACTION_VIEW);
        mIntent.setDataAndType(FileProvider.getUriForFile(context, context.getPackageName() + ".AgentWebFileProvider", file), "application/vnd.android.package-archive");
        mIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    } else {

        mIntent = AgentWebUtils.getFileIntent(file);
    }

    return mIntent;
}

文件上传时的requestCode

你好,文件上传时,选择一个文件比如图片后,会在onActivityResult里调用uploadFileResult上传图片,那这个requestCode是多少呢?是否可以暴露出来?

sample跑不上

Error:Execution failed for task ':sample:validateSigningDebug'.

Keystore file F:\Download\AgentWeb-master\sample\keystore\keystore.jks not found for signing config 'release'.

SSL Error Handler error by google play team

Hi,
I using agent web and when upload app to google, i have email alert:

Vulnerability APK Version(s)
SSL Error Handler
For more information on how to address WebView SSL Error Handler alerts, please see this Google Help Center article.

I try google and fix this in AgentWebFragment.java (My app base on your example app), but when update app again, error still orccur, please help!

private WebViewClient mWebViewClient = new WebViewClient() {

        @Override
        public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) {
            //final AlertDialog.Builder builder = new AlertDialog.Builder(OnlinePayment.this);
            String msg="";
            if(error.getPrimaryError()==SslError.SSL_DATE_INVALID
                    || error.getPrimaryError()== SslError.SSL_EXPIRED
                    || error.getPrimaryError()== SslError.SSL_IDMISMATCH
                    || error.getPrimaryError()== SslError.SSL_INVALID
                    || error.getPrimaryError()== SslError.SSL_NOTYETVALID
                    || error.getPrimaryError()==SslError.SSL_UNTRUSTED) {
                if(error.getPrimaryError()==SslError.SSL_DATE_INVALID){
                    msg="The date of the certificate is invalid";
                }else if(error.getPrimaryError()==SslError.SSL_INVALID){
                    msg="A generic error occurred";
                }
                else if(error.getPrimaryError()== SslError.SSL_EXPIRED){
                    msg="The certificate has expired";
                }else if(error.getPrimaryError()== SslError.SSL_IDMISMATCH){
                    msg="Hostname mismatch";
                }
                else if(error.getPrimaryError()== SslError.SSL_NOTYETVALID){
                    msg="The certificate is not yet valid";
                }
                else if(error.getPrimaryError()==SslError.SSL_UNTRUSTED){
                    msg="The certificate authority is not trusted";
                }
            }

            msg += ". We will cancel the request.";

            final AlertDialog.Builder builder = new AlertDialog.Builder(AgentWebFragment.this.getActivity());
            builder.setMessage(msg);
            builder.setPositiveButton("", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    handler.cancel();
                }
            });
            final AlertDialog dialog = builder.create();
            dialog.show();

        }
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {

            Log.i("Info","shouldOverrideUrlLoading");
            return false;
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {

            Log.i("Info","url:"+url);
            if(url.equals(getUrl())){
                pageNavigator(View.GONE);
            }else{
                pageNavigator(View.VISIBLE);
            }

        }

    };

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.