Przeglądaj źródła

添加集成web组件

Arison 6 lat temu
rodzic
commit
33e66db472

+ 1 - 0
lib_common/build.gradle

@@ -70,6 +70,7 @@ dependencies {
     api deps.material_dialog
     api deps.logger
     api deps.toasty
+    api deps.agentweb
 
     //router
     api deps.arouter_api

+ 1 - 0
lib_widget/.gitignore

@@ -0,0 +1 @@
+/build

+ 43 - 0
lib_widget/build.gradle

@@ -0,0 +1,43 @@
+apply plugin: 'com.android.library'
+
+
+android {
+    compileSdkVersion build_versions.target_sdk
+    defaultConfig {
+        minSdkVersion build_versions.min_sdk
+        targetSdkVersion build_versions.target_sdk
+        versionCode 1
+        versionName "1.0"
+        javaCompileOptions {
+            annotationProcessorOptions {
+                arguments = [moduleName: project.getName()]
+            }
+        }
+    }
+
+
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_8
+        targetCompatibility JavaVersion.VERSION_1_8
+    }
+
+    buildTypes {
+        release {
+            buildConfigField "boolean", "LOG_DEBUG", "true"
+            zipAlignEnabled false
+            shrinkResources false
+            minifyEnabled false
+            debuggable true
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+        }
+    }
+
+}
+
+dependencies {
+    compile fileTree(dir: 'libs', include: ['*.jar'])
+    annotationProcessor deps.arouter_compiler
+    implementation project(':lib_common')
+   
+ 
+}

+ 25 - 0
lib_widget/proguard-rules.pro

@@ -0,0 +1,25 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in C:\Android\sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile

+ 26 - 0
lib_widget/src/androidTest/java/app/arison/com/lib_widget/ExampleInstrumentedTest.java

@@ -0,0 +1,26 @@
+package app.arison.com.lib_widget;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumentation test, which will execute on an Android device.
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+    @Test
+    public void useAppContext() throws Exception {
+        // Context of the app under test.
+        Context appContext = InstrumentationRegistry.getTargetContext();
+
+        assertEquals("app.arison.com.lib_widget.test", appContext.getPackageName());
+    }
+}

+ 13 - 0
lib_widget/src/main/AndroidManifest.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="app.arison.com.lib_widget">
+
+    <application>
+        <activity android:name="com.uas.module.widget.activity.BaseWebActivity">
+            
+        </activity>
+        <activity android:name="com.uas.module.widget.activity.UASWebActivity"
+            android:theme="@style/AppTheme.NoActionBar"></activity>
+    </application>
+
+</manifest>

+ 29 - 0
lib_widget/src/main/java/com/uas/module/widget/MyDelegate.java

@@ -0,0 +1,29 @@
+package com.uas.module.widget;
+
+import com.uas.module.common.base.IApplicationDelegate;
+
+/**
+ * Created by Arison on 2019/5/5.
+ */
+
+public class MyDelegate implements IApplicationDelegate {
+    @Override
+    public void onCreate() {
+        
+    }
+
+    @Override
+    public void onTerminate() {
+
+    }
+
+    @Override
+    public void onLowMemory() {
+
+    }
+
+    @Override
+    public void onTrimMemory(int level) {
+
+    }
+}

+ 184 - 0
lib_widget/src/main/java/com/uas/module/widget/activity/BaseWebActivity.java

@@ -0,0 +1,184 @@
+package com.uas.module.widget.activity;
+
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AlertDialog;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.View;
+import android.webkit.WebResourceRequest;
+import android.webkit.WebView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.just.agentweb.AgentWeb;
+import com.just.agentweb.DefaultWebClient;
+import com.just.agentweb.WebChromeClient;
+import com.just.agentweb.WebViewClient;
+
+import app.arison.com.lib_widget.R;
+
+public class BaseWebActivity extends AppCompatActivity {
+
+    protected AgentWeb mAgentWeb;
+    private LinearLayout mLinearLayout;
+    private Toolbar mToolbar;
+    private TextView mTitleTextView;
+    private AlertDialog mAlertDialog;
+
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        setContentView(R.layout.activity_web);
+
+
+        mLinearLayout = (LinearLayout) this.findViewById(R.id.container);
+        mToolbar = (Toolbar) this.findViewById(R.id.toolbar);
+        mToolbar.setTitleTextColor(Color.WHITE);
+        mToolbar.setTitle("");
+        mTitleTextView = (TextView) this.findViewById(R.id.toolbar_title);
+        this.setSupportActionBar(mToolbar);
+        if (getSupportActionBar() != null) {
+            // Enable the Up button
+            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+        }
+        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+
+                showDialog();
+            }
+        });
+
+
+        long p = System.currentTimeMillis();
+
+        mAgentWeb = AgentWeb.with(this)
+                .setAgentWebParent(mLinearLayout, new LinearLayout.LayoutParams(-1, -1))
+                .useDefaultIndicator()
+                .setWebChromeClient(mWebChromeClient)
+                .setWebViewClient(mWebViewClient)
+                .setMainFrameErrorView(R.layout.agentweb_error_page, -1)
+                .setSecurityType(AgentWeb.SecurityType.STRICT_CHECK)
+//                .setWebLayout(new WebLayout(this))
+                .setOpenOtherPageWays(DefaultWebClient.OpenOtherPageWays.ASK)//打开其他应用时,弹窗咨询用户是否前往其他应用
+                .interceptUnkownUrl() //拦截找不到相关页面的Scheme
+                .createAgentWeb()
+                .ready()
+                .go(getUrl());
+
+        //mAgentWeb.getUrlLoader().loadUrl(getUrl());
+
+        long n = System.currentTimeMillis();
+        Log.i("Info", "init used time:" + (n - p));
+
+
+    }
+
+    private com.just.agentweb.WebViewClient mWebViewClient = new WebViewClient() {
+        @Override
+        public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
+            return super.shouldOverrideUrlLoading(view, request);
+        }
+
+        @Override
+        public void onPageStarted(WebView view, String url, Bitmap favicon) {
+            //do you  work
+            Log.i("Info", "BaseWebActivity onPageStarted");
+        }
+    };
+    private com.just.agentweb.WebChromeClient mWebChromeClient = new WebChromeClient() {
+        @Override
+        public void onProgressChanged(WebView view, int newProgress) {
+            //do you work
+//            Log.i("Info","onProgress:"+newProgress);
+        }
+
+        @Override
+        public void onReceivedTitle(WebView view, String title) {
+            super.onReceivedTitle(view, title);
+            if (mTitleTextView != null) {
+                mTitleTextView.setText(title);
+            }
+        }
+    };
+
+    public String getUrl() {
+
+        return "https://m.jd.com/";
+    }
+
+
+    private void showDialog() {
+
+        if (mAlertDialog == null) {
+            mAlertDialog = new AlertDialog.Builder(this)
+                    .setMessage("您确定要关闭该页面吗?")
+                    .setNegativeButton("再逛逛", new DialogInterface.OnClickListener() {
+                        @Override
+                        public void onClick(DialogInterface dialog, int which) {
+                            if (mAlertDialog != null) {
+                                mAlertDialog.dismiss();
+                            }
+                        }
+                    })//
+                    .setPositiveButton("确定", new DialogInterface.OnClickListener() {
+                        @Override
+                        public void onClick(DialogInterface dialog, int which) {
+
+                            if (mAlertDialog != null) {
+                                mAlertDialog.dismiss();
+                            }
+                            BaseWebActivity.this.finish();
+                        }
+                    }).create();
+        }
+        mAlertDialog.show();
+
+    }
+
+    @Override
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+
+        if (mAgentWeb.handleKeyEvent(keyCode, event)) {
+            return true;
+        }
+        return super.onKeyDown(keyCode, event);
+    }
+
+    @Override
+    protected void onPause() {
+        mAgentWeb.getWebLifeCycle().onPause();
+        super.onPause();
+
+    }
+
+    @Override
+    protected void onResume() {
+        mAgentWeb.getWebLifeCycle().onResume();
+        super.onResume();
+    }
+
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+
+        Log.i("Info", "onResult:" + requestCode + " onResult:" + resultCode);
+        super.onActivityResult(requestCode, resultCode, data);
+    }
+
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        //mAgentWeb.destroy();
+        mAgentWeb.getWebLifeCycle().onDestroy();
+    }
+}

+ 206 - 0
lib_widget/src/main/java/com/uas/module/widget/activity/UASWebActivity.java

@@ -0,0 +1,206 @@
+package com.uas.module.widget.activity;
+
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AlertDialog;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.View;
+import android.webkit.WebResourceRequest;
+import android.webkit.WebView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.alibaba.android.arouter.facade.annotation.Autowired;
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.alibaba.android.arouter.launcher.ARouter;
+import com.blankj.utilcode.util.LogUtils;
+import com.just.agentweb.AgentWeb;
+import com.just.agentweb.DefaultWebClient;
+import com.just.agentweb.WebChromeClient;
+import com.just.agentweb.WebViewClient;
+import com.uas.module.common.utils.StringUtils;
+
+import app.arison.com.lib_widget.R;
+
+
+/**
+ * @desc:全局webview封装入口
+ * @param:url:路径 params:请求参数
+ * headers:请求头
+ * @author:Arison on 2019/5/5
+ */
+@Route(path = "/app/uas_web")
+public class UASWebActivity extends AppCompatActivity {
+
+    @Autowired(name = "url")
+    String url;
+    @Autowired(name = "title")
+    String title;
+    protected AgentWeb mAgentWeb;
+    private LinearLayout mLinearLayout;
+    private Toolbar mToolbar;
+    private TextView mTitleTextView;
+    private AlertDialog mAlertDialog;
+
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        setContentView(R.layout.activity_web);
+        ARouter.getInstance().inject(this);
+
+        mLinearLayout = (LinearLayout) this.findViewById(R.id.container);
+        mToolbar = (Toolbar) this.findViewById(R.id.toolbar);
+        mToolbar.setTitleTextColor(Color.WHITE);
+        mToolbar.setTitle("");
+        mTitleTextView = (TextView) this.findViewById(R.id.toolbar_title);
+        this.setSupportActionBar(mToolbar);
+        if (getSupportActionBar() != null) {
+            // Enable the Up button
+            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+        }
+        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+
+                showDialog();
+            }
+        });
+
+
+        long p = System.currentTimeMillis();
+
+        mAgentWeb = AgentWeb.with(this)
+                .setAgentWebParent(mLinearLayout, new LinearLayout.LayoutParams(-1, -1))
+                .useDefaultIndicator()
+                .setWebChromeClient(mWebChromeClient)
+                .setWebViewClient(mWebViewClient)
+                .setMainFrameErrorView(R.layout.agentweb_error_page, -1)
+                .setSecurityType(AgentWeb.SecurityType.STRICT_CHECK)
+                // .setWebLayout(new WebLayout(this))
+                .setOpenOtherPageWays(DefaultWebClient.OpenOtherPageWays.ASK)//打开其他应用时,弹窗咨询用户是否前往其他应用
+                .interceptUnkownUrl() //拦截找不到相关页面的Scheme
+                .createAgentWeb()
+                .ready()
+                .go(getUrl());
+
+        long n = System.currentTimeMillis();
+        Log.i("Info", "init used time:" + (n - p));
+
+        LogUtils.d("web params url:" + url + "title:" + title);
+        if (!StringUtils.isEmpty(url)) {
+            mAgentWeb.getUrlLoader().loadUrl(url);
+        }
+
+
+    }
+
+    private com.just.agentweb.WebViewClient mWebViewClient = new WebViewClient() {
+        @Override
+        public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
+            return super.shouldOverrideUrlLoading(view, request);
+        }
+
+        @Override
+        public void onPageStarted(WebView view, String url, Bitmap favicon) {
+            //do you  work
+            Log.i("Info", "BaseWebActivity onPageStarted");
+        }
+    };
+    private com.just.agentweb.WebChromeClient mWebChromeClient = new WebChromeClient() {
+        @Override
+        public void onProgressChanged(WebView view, int newProgress) {
+            //do you work
+//            Log.i("Info","onProgress:"+newProgress);
+        }
+
+        @Override
+        public void onReceivedTitle(WebView view, String title) {
+            super.onReceivedTitle(view, title);
+            if (mTitleTextView != null) {
+                mTitleTextView.setText(title);
+            }
+        }
+    };
+
+    public String getUrl() {
+
+        return "https://m.jd.com/";
+    }
+
+
+    private void showDialog() {
+
+        if (mAlertDialog == null) {
+            mAlertDialog = new AlertDialog.Builder(this)
+                    .setMessage("您确定要关闭该页面吗?")
+                    .setNegativeButton("再逛逛", new DialogInterface.OnClickListener() {
+                        @Override
+                        public void onClick(DialogInterface dialog, int which) {
+                            if (mAlertDialog != null) {
+                                mAlertDialog.dismiss();
+                            }
+                        }
+                    })//
+                    .setPositiveButton("确定", new DialogInterface.OnClickListener() {
+                        @Override
+                        public void onClick(DialogInterface dialog, int which) {
+
+                            if (mAlertDialog != null) {
+                                mAlertDialog.dismiss();
+                            }
+                            UASWebActivity.this.finish();
+                        }
+                    }).create();
+        }
+        mAlertDialog.show();
+
+    }
+
+    @Override
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+
+        if (mAgentWeb.handleKeyEvent(keyCode, event)) {
+            return true;
+        }
+        return super.onKeyDown(keyCode, event);
+    }
+
+    @Override
+    protected void onPause() {
+        mAgentWeb.getWebLifeCycle().onPause();
+        super.onPause();
+
+    }
+
+    @Override
+    protected void onResume() {
+        mAgentWeb.getWebLifeCycle().onResume();
+        super.onResume();
+    }
+
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+
+        Log.i("Info", "onResult:" + requestCode + " onResult:" + resultCode);
+        super.onActivityResult(requestCode, resultCode, data);
+    }
+
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        //mAgentWeb.destroy();
+        mAgentWeb.getWebLifeCycle().onDestroy();
+    }
+
+
+}

+ 266 - 0
lib_widget/src/main/java/com/uas/module/widget/base/BaseAgentWebActivity.java

@@ -0,0 +1,266 @@
+package com.uas.module.widget.base;
+
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.os.Bundle;
+import android.support.annotation.ColorInt;
+import android.support.annotation.LayoutRes;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.webkit.DownloadListener;
+import android.webkit.WebResourceRequest;
+import android.webkit.WebView;
+
+import com.just.agentweb.AgentWeb;
+import com.just.agentweb.AgentWebSettingsImpl;
+import com.just.agentweb.AgentWebUIControllerImplBase;
+import com.just.agentweb.DefaultWebClient;
+import com.just.agentweb.IAgentWebSettings;
+import com.just.agentweb.IWebLayout;
+import com.just.agentweb.MiddlewareWebChromeBase;
+import com.just.agentweb.MiddlewareWebClientBase;
+import com.just.agentweb.PermissionInterceptor;
+import com.just.agentweb.WebChromeClient;
+import com.just.agentweb.WebViewClient;
+
+/**
+ * Created by cenxiaozhong on 2017/7/22.
+ * <p>
+ * source code  https://github.com/Justson/AgentWeb
+ */
+
+public abstract class BaseAgentWebActivity extends AppCompatActivity {
+
+    protected AgentWeb mAgentWeb;
+    private AgentWebUIControllerImplBase mAgentWebUIController;
+    private ErrorLayoutEntity mErrorLayoutEntity;
+    private MiddlewareWebChromeBase mMiddleWareWebChrome;
+    private MiddlewareWebClientBase mMiddleWareWebClient;
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+    }
+
+    @Override
+    public void setContentView(@LayoutRes int layoutResID) {
+        super.setContentView(layoutResID);
+        buildAgentWeb();
+    }
+
+    @Override
+    public void setContentView(View view) {
+        super.setContentView(view);
+        buildAgentWeb();
+    }
+
+    protected void buildAgentWeb() {
+        ErrorLayoutEntity mErrorLayoutEntity = getErrorLayoutEntity();
+        mAgentWeb = AgentWeb.with(this)
+                .setAgentWebParent(getAgentWebParent(), new ViewGroup.LayoutParams(-1, -1))
+                .useDefaultIndicator(getIndicatorColor(), getIndicatorHeight())
+                .setWebChromeClient(getWebChromeClient())
+                .setWebViewClient(getWebViewClient())
+                .setWebView(getWebView())
+                .setPermissionInterceptor(getPermissionInterceptor())
+                .setWebLayout(getWebLayout())
+                .setAgentWebUIController(getAgentWebUIController())
+                .interceptUnkownUrl()
+                .setOpenOtherPageWays(getOpenOtherAppWay())
+                .useMiddlewareWebChrome(getMiddleWareWebChrome())
+                .useMiddlewareWebClient(getMiddleWareWebClient())
+                .setAgentWebWebSettings(getAgentWebSettings())
+                .setMainFrameErrorView(mErrorLayoutEntity.layoutRes, mErrorLayoutEntity.reloadId)
+                .setSecurityType(AgentWeb.SecurityType.STRICT_CHECK)
+                .createAgentWeb()
+                .ready()
+                .go(getUrl())
+                .clearWebCache();
+    }
+
+
+    protected @NonNull
+    ErrorLayoutEntity getErrorLayoutEntity() {
+        if (this.mErrorLayoutEntity == null) {
+            this.mErrorLayoutEntity = new ErrorLayoutEntity();
+        }
+        return mErrorLayoutEntity;
+    }
+
+    protected AgentWeb getAgentWeb() {
+        return this.mAgentWeb;
+    }
+
+
+    protected static class ErrorLayoutEntity {
+        private int layoutRes = com.just.agentweb.R.layout.agentweb_error_page;
+        private int reloadId;
+
+        public void setLayoutRes(int layoutRes) {
+            this.layoutRes = layoutRes;
+            if (layoutRes <= 0) {
+                layoutRes = -1;
+            }
+        }
+
+        public void setReloadId(int reloadId) {
+            this.reloadId = reloadId;
+            if (reloadId <= 0) {
+                reloadId = -1;
+            }
+        }
+    }
+
+    @Override
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+
+        if (mAgentWeb != null && mAgentWeb.handleKeyEvent(keyCode, event)) {
+            return true;
+        }
+        return super.onKeyDown(keyCode, event);
+    }
+
+    @Override
+    protected void onPause() {
+        if (mAgentWeb != null) {
+            mAgentWeb.getWebLifeCycle().onPause();
+        }
+        super.onPause();
+
+    }
+
+    @Override
+    protected void onResume() {
+        if (mAgentWeb != null) {
+            mAgentWeb.getWebLifeCycle().onResume();
+        }
+        super.onResume();
+    }
+
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+    }
+
+
+    @Override
+    protected void onDestroy() {
+        if (mAgentWeb != null) {
+            mAgentWeb.getWebLifeCycle().onDestroy();
+        }
+        super.onDestroy();
+    }
+
+
+    protected @Nullable
+    DownloadListener getDownloadListener() {
+        return null;
+    }
+
+
+    protected void setTitle(WebView view, String title) {
+
+    }
+
+    protected
+    @Nullable
+    String getUrl() {
+        return null;
+    }
+
+    public @Nullable
+    IAgentWebSettings getAgentWebSettings() {
+        return AgentWebSettingsImpl.getInstance();
+    }
+
+    protected abstract @NonNull
+    ViewGroup getAgentWebParent();
+
+    protected @Nullable
+    WebChromeClient getWebChromeClient() {
+        return  new WebChromeClient() {
+            @Override
+            public void onProgressChanged(WebView view, int newProgress) {
+                //do you work
+//            Log.i("Info","onProgress:"+newProgress);
+            }
+
+            @Override
+            public void onReceivedTitle(WebView view, String title) {
+                super.onReceivedTitle(view, title);
+//                if (mTitleTextView != null) {
+//                    mTitleTextView.setText(title);
+//                }
+            }
+        };
+    }
+
+    protected @ColorInt
+    int getIndicatorColor() {
+        return -1;
+    }
+
+    protected int getIndicatorHeight() {
+        return -1;
+    }
+
+    protected @Nullable
+    WebViewClient getWebViewClient() {
+        return new WebViewClient() {
+            @Override
+            public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
+                return super.shouldOverrideUrlLoading(view, request);
+            }
+
+            @Override
+            public void onPageStarted(WebView view, String url, Bitmap favicon) {
+                //do you  work
+                Log.i("Info", "BaseWebActivity onPageStarted");
+            }
+        };
+    }
+
+
+    protected @Nullable
+    WebView getWebView() {
+        return null;
+    }
+
+    protected @Nullable
+    IWebLayout getWebLayout() {
+        return null;
+    }
+
+    protected @Nullable
+    PermissionInterceptor getPermissionInterceptor() {
+        return null;
+    }
+
+    public @Nullable
+    AgentWebUIControllerImplBase getAgentWebUIController() {
+        return null;
+    }
+
+    public @Nullable
+    DefaultWebClient.OpenOtherPageWays getOpenOtherAppWay() {
+        return null;
+    }
+
+    protected @NonNull
+    MiddlewareWebChromeBase getMiddleWareWebChrome() {
+        return this.mMiddleWareWebChrome = new MiddlewareWebChromeBase() {
+        };
+    }
+
+    protected @NonNull
+    MiddlewareWebClientBase getMiddleWareWebClient() {
+        return this.mMiddleWareWebClient = new MiddlewareWebClientBase() {
+        };
+    }
+}

+ 32 - 0
lib_widget/src/main/res/layout/activity_web.xml

@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:id="@+id/container"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+
+
+    <android.support.v7.widget.Toolbar
+        android:id="@+id/toolbar"
+        android:layout_width="match_parent"
+        android:layout_height="?android:actionBarSize"
+        android:background="?attr/colorPrimary"
+        android:titleTextColor="@android:color/white"
+        app:titleTextColor="@android:color/white">
+
+
+        <TextView
+            android:id="@+id/toolbar_title"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center"
+            android:singleLine="true"
+            android:textColor="@android:color/white"
+            android:textSize="14sp"/>
+    </android.support.v7.widget.Toolbar>
+
+
+
+</LinearLayout>

+ 14 - 0
lib_widget/src/main/res/values-v21/styles.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <style name="AppTheme" parent="Base.AppTheme">
+        <item name="android:navigationBarColor">@color/gray_E6</item><!--虚拟导航栏颜色-->
+        <!--<item name="android:colorControlHighlight">@color/gray_AD</item>&lt;!&ndash;波纹颜色&ndash;&gt;-->
+    </style>
+
+    <style name="TransparentStatusBarTheme" parent="AppTheme.NoActionBar">
+        <item name="android:statusBarColor">@color/gray_D5</item>
+    </style>
+
+
+</resources>

+ 3 - 0
lib_widget/src/main/res/values/strings.xml

@@ -0,0 +1,3 @@
+<resources>
+    <string name="app_name">lib_widget</string>
+</resources>

+ 51 - 0
lib_widget/src/main/res/values/styles.xml

@@ -0,0 +1,51 @@
+<resources>
+
+    <!-- Base application theme. -->
+    <style name="Base.AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
+        <!-- Customize your theme here. -->
+        <item name="colorPrimary">@color/colorPrimary</item>
+        <item name="colorPrimaryDark">@color/colorPrimary</item>
+        <item name="colorAccent">@color/colorPrimary</item>
+
+    </style>
+
+    <style name="AppTheme" parent="Base.AppTheme" />
+
+    <!--无ActionBar的AppTheme-->
+    <style name="AppTheme.NoActionBar">
+        <item name="windowActionBar">false</item>
+        <item name="windowNoTitle">true</item>
+    </style>
+
+    <!--启动页样式及窗口背景-->
+    <!--<style name="SplashTheme" parent="TransparentStatusBarTheme">-->
+    <!--<item name="android:windowBackground">@drawable/bg_launch</item>-->
+    <!--<item name="android:windowFullscreen">false</item>-->
+    <!--</style>-->
+
+
+    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
+
+    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
+
+    <style name="Toolbar" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
+
+    <!--全屏-->
+    <style name="FullscreenTheme" parent="AppTheme.NoActionBar">
+        <item name="android:windowActionBarOverlay">true</item>
+        <item name="android:windowFullscreen">true</item>
+        <item name="android:windowBackground">@null</item>
+    </style>
+
+    <!-- 自定义loading dialog -->
+    <style name="ProgressDialogTheme" parent="Theme.AppCompat.Light.Dialog">
+        <item name="android:windowFrame">@null</item><!--边框-->
+        <item name="android:windowNoTitle">true</item><!--无标题-->
+        <item name="android:windowBackground">@android:color/transparent</item><!--背景透明-->
+        <item name="android:windowIsTranslucent">false</item><!--半透明-->
+        <item name="android:windowIsFloating">true</item><!--是否浮现在activity之上-->
+        <item name="android:windowContentOverlay">@null</item>
+        <item name="android:backgroundDimEnabled">false</item><!--模糊-->
+    </style>
+
+</resources>

+ 17 - 0
lib_widget/src/test/java/app/arison/com/lib_widget/ExampleUnitTest.java

@@ -0,0 +1,17 @@
+package app.arison.com.lib_widget;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+public class ExampleUnitTest {
+    @Test
+    public void addition_isCorrect() throws Exception {
+        assertEquals(4, 2 + 2);
+    }
+}

+ 1 - 0
module_app/build.gradle

@@ -88,6 +88,7 @@ dependencies {
     implementation fileTree(dir: 'libs', include: ['*.jar'])
     implementation deps.support.multidex
     implementation project(':lib_common')
+    implementation project(':lib_widget')
     if (!isModule.toBoolean()) {
         implementation project(':module_main')
         implementation project(':module_girls')

+ 1 - 1
module_app/src/main/res/values/strings.xml

@@ -1,5 +1,5 @@
 <resources>
-    <string name="app_name">组件化项目</string>
+    <string name="app_name">UU互联</string>
 
     <string name="global_scheme">module</string>
 

+ 4 - 1
module_main/src/main/java/com/uas/module/main/MainActivity.java

@@ -37,7 +37,10 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
         } else if (view.getId() == R.id.fragment_button) {
             startActivity(new Intent(this, BottomNavigationActivity.class));
         }  else if(view.getId()==R.id.test_button){
-            ARouter.getInstance().build("/test/index").navigation();
+            ARouter.getInstance().build("/app/uas_web")
+                    .withString("url","https://www.baidu.com")
+                    .withString("title","阿里云云栖社区")
+                    .navigation();
         }
     }
 

+ 1 - 1
module_test/src/main/AndroidManifest.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.uas.module.test">
-
+  
     <application android:theme="@style/AppTheme">
         <activity
             android:name=".main.TestMainActivity"

+ 65 - 29
module_test/src/main/java/com/uas/module/test/main/TestMainActivity.java

@@ -2,10 +2,13 @@ package com.uas.module.test.main;
 
 import android.os.Bundle;
 import android.support.v7.app.AppCompatActivity;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
 
 import com.alibaba.android.arouter.facade.annotation.Route;
 import com.alibaba.fastjson.JSON;
 import com.blankj.utilcode.util.LogUtils;
+import com.just.agentweb.AgentWeb;
 import com.uas.module.test.R;
 import com.uas.module.test.network.grpc.Authentication;
 import com.uas.module.test.network.grpc.MobileClientAuthenticationInterceptor;
@@ -46,40 +49,51 @@ public class TestMainActivity extends AppCompatActivity {
             .usePlaintext(true)
             .build();
 
+    AgentWeb  mAgentWeb;
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_test_main);
-        
-        new Thread(new Runnable() {
-            @Override
-            public void run() {
-                //注册
-                signup();
 
-                try {
-                    Thread.sleep(1000);
-                } catch (InterruptedException e) {
-                    e.printStackTrace();
-                }
-                //登录
-                login();
-                try {
-                    Thread.sleep(1000);
-                } catch (InterruptedException e) {
-                    e.printStackTrace();
-                }
-                //切换公司
-                switchCompany();
-                
-                //读取配置
-                getConfig();
-                //应用配置
-                getAppConfig();
-                //我的配置
-                getMeConfig();
-            }
-        }).start();
+
+        mAgentWeb = AgentWeb.with(this)
+                .setAgentWebParent((ViewGroup) this.findViewById(R.id.container),new LinearLayout.LayoutParams(-1, -1))
+                .useDefaultIndicator()
+                .createAgentWeb()
+                .ready()
+                .go("http://www.jd.com")
+                .clearWebCache();
+        
+//        new Thread(new Runnable() {
+//            @Override
+//            public void run() {
+//                //注册
+//                signup();
+//
+//                try {
+//                    Thread.sleep(1000);
+//                } catch (InterruptedException e) {
+//                    e.printStackTrace();
+//                }
+//                //登录
+//                login();
+//                try {
+//                    Thread.sleep(1000);
+//                } catch (InterruptedException e) {
+//                    e.printStackTrace();
+//                }
+//                //切换公司
+//                switchCompany();
+//                
+//                //读取配置
+//                getConfig();
+//                //应用配置
+//                getAppConfig();
+//                //我的配置
+//                getMeConfig();
+//            }
+//        }).start();
         
     }
 
@@ -275,4 +289,26 @@ public class TestMainActivity extends AppCompatActivity {
             e.printStackTrace();
         }
     }
+
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        mAgentWeb.getWebLifeCycle().onResume();
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+        mAgentWeb.getWebLifeCycle().onPause();
+    }
+
+
+    
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        mAgentWeb.getWebLifeCycle().onDestroy();
+    }
 }

+ 27 - 3
module_test/src/main/res/layout/activity_test_main.xml

@@ -1,9 +1,33 @@
 <?xml version="1.0" encoding="utf-8"?>
-<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/container"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    tools:context="com.uas.module.test.main.TestMainActivity">
+    android:orientation="vertical">
 
-</android.support.constraint.ConstraintLayout>
+
+    <android.support.v7.widget.Toolbar
+        android:id="@+id/toolbar"
+        android:layout_width="match_parent"
+        android:layout_height="?android:actionBarSize"
+        android:background="?attr/colorPrimary"
+        android:titleTextColor="@android:color/white"
+        app:titleTextColor="@android:color/white">
+
+
+        <TextView
+            android:id="@+id/toolbar_title"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center"
+            android:singleLine="true"
+            android:textColor="@android:color/white"
+            android:textSize="14sp"/>
+    </android.support.v7.widget.Toolbar>
+
+
+
+</LinearLayout>

+ 1 - 1
settings.gradle

@@ -1,4 +1,4 @@
-include ':lib_common', ':module_test',
+include ':lib_common', ':module_test', ':lib_widget',
         ':module_app',
         ':module_main',
         ':module_girls',

+ 3 - 0
versions.gradle

@@ -38,6 +38,7 @@ versions.themvp="1.0.6"
 //GRPC
 versions.grpc_api="1.0.0-SNAPSHOT"
 versions.fastjson="1.2.57"
+versions.agentweb="4.0.3-alpha@aar"
 
 
 
@@ -87,6 +88,7 @@ deps.swipe_recycler = "com.yanzhenjie:recyclerview-swipe:$versions.swipe_recycle
 deps.easy_recycler = "com.jude:easyrecyclerview:$versions.easy_recycler"
 deps.photo_view = "com.github.chrisbanes:PhotoView:$versions.photo_view"
 deps.material_dialog = "com.afollestad.material-dialogs:core:$versions.material_dialog"
+deps.agentweb="com.just.agentweb:agentweb:$versions.agentweb"
 
 deps.android_gradle_plugin = "com.android.tools.build:gradle:$versions.android_gradle_plugin"
 deps.rxjava2 = "io.reactivex.rxjava2:rxjava:$versions.rxjava2"
@@ -108,6 +110,7 @@ deps.logger = "com.orhanobut:logger:$versions.logger"
 deps.arouter_api = "com.alibaba:arouter-api:$versions.arouter_api"
 deps.arouter_compiler = "com.alibaba:arouter-compiler:$versions.arouter_compiler"
 
+
 deps.themvp="com.kymjs.core:themvp:$versions.themvp"
 deps.grpc="com.usoftchina.uu:android-grpc-api:$versions.grpc_api"