├── .gitignore ├── .idea ├── caches │ └── build_file_checksums.ser ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── dictionaries │ └── cenxiaozhong.xml ├── gradle.xml ├── inspectionProfiles │ ├── Project_Default.xml │ └── profiles_settings.xml ├── markdown-navigator.xml ├── markdown-navigator │ └── profiles_settings.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── LICENSE ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── .gitignore ├── build.gradle ├── proguard-rules.pro ├── providedLibs │ ├── alipaySdk-20170922.jar │ └── tbs_sdk_thirdapp_v3.5.0.1004_43500_sharewithdownload_withoutGame_obfs_20170801_113025.jar └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── just │ │ └── agentwebX5 │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── just │ │ │ └── agentwebX5 │ │ │ ├── ActionActivity.java │ │ │ ├── AgentWebJsInterfaceX5Compat.java │ │ │ ├── AgentWebX5.java │ │ │ ├── AgentWebX5Compat.java │ │ │ ├── AgentWebX5Config.java │ │ │ ├── AgentWebX5FileProvider.java │ │ │ ├── AgentWebX5Permissions.java │ │ │ ├── AgentWebX5Utils.java │ │ │ ├── BaseAgentWebActivity.java │ │ │ ├── BaseIndicatorView.java │ │ │ ├── BaseJsEntraceAccess.java │ │ │ ├── BaseProgressSpec.java │ │ │ ├── ChromeClientCallbackManager.java │ │ │ ├── CloseUtils.java │ │ │ ├── DefaultChromeClient.java │ │ │ ├── DefaultDownLoaderImpl.java │ │ │ ├── DefaultMsgConfig.java │ │ │ ├── DefaultWebClient.java │ │ │ ├── DefaultWebCreator.java │ │ │ ├── DefaultWebLifeCycleImpl.java │ │ │ ├── DownLoadResultListener.java │ │ │ ├── DownLoadTask.java │ │ │ ├── EventHandlerImpl.java │ │ │ ├── EventInterceptor.java │ │ │ ├── FileParcel.java │ │ │ ├── FileUpLoadChooserImpl.java │ │ │ ├── FileUploadPop.java │ │ │ ├── HookManager.java │ │ │ ├── IEventHandler.java │ │ │ ├── IFileUploadChooser.java │ │ │ ├── ILoader.java │ │ │ ├── IVideo.java │ │ │ ├── IWebClientHelper.java │ │ │ ├── IWebLayout.java │ │ │ ├── IndicatorController.java │ │ │ ├── IndicatorHandler.java │ │ │ ├── JsBaseInterfaceHolder.java │ │ │ ├── JsEntraceAccess.java │ │ │ ├── JsEntraceAccessImpl.java │ │ │ ├── JsInterfaceHolder.java │ │ │ ├── JsInterfaceHolderImpl.java │ │ │ ├── JsInterfaceObjectException.java │ │ │ ├── LayoutParamsOffer.java │ │ │ ├── LoaderImpl.java │ │ │ ├── LogUtils.java │ │ │ ├── MiddleWareWebChromeBase.java │ │ │ ├── MiddleWareWebClientBase.java │ │ │ ├── Notify.java │ │ │ ├── PermissionInterceptor.java │ │ │ ├── ProgressLifeCyclic.java │ │ │ ├── ProgressManager.java │ │ │ ├── ProgressSpec.java │ │ │ ├── Provider.java │ │ │ ├── QuickCallJs.java │ │ │ ├── RealDownLoader.java │ │ │ ├── UrlCommonException.java │ │ │ ├── VideoImpl.java │ │ │ ├── WebChromeClientWrapper.java │ │ │ ├── WebCreator.java │ │ │ ├── WebDefaultSettingsManager.java │ │ │ ├── WebLifeCycle.java │ │ │ ├── WebListenerManager.java │ │ │ ├── WebProgress.java │ │ │ ├── WebSecurityCheckLogic.java │ │ │ ├── WebSecurityController.java │ │ │ ├── WebSecurityControllerImpl.java │ │ │ ├── WebSecurityLogicImpl.java │ │ │ ├── WebSettings.java │ │ │ ├── WebViewClientCallbackManager.java │ │ │ └── WrapperWebViewClient.java │ └── res │ │ ├── mipmap-xxhdpi │ │ └── download.png │ │ ├── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── style.xml │ │ └── xml │ │ └── web_download_paths.xml │ └── test │ └── java │ └── com │ └── just │ └── agentwebX5 │ └── ExampleUnitTest.java ├── sample ├── .gitignore ├── CMakeLists.txt ├── build.gradle ├── libs │ ├── alipaySdk-20170922.jar │ └── tbs_sdk_thirdapp_v3.1.0.1034_43100_sharewithdownload_obfs_20170301_182143.jar ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── just │ │ └── agentwebx5 │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ ├── js_interaction │ │ │ ├── button.css │ │ │ └── hello.html │ │ ├── sms │ │ │ └── sms.html │ │ └── upload_file │ │ │ ├── event.js │ │ │ ├── id.png │ │ │ ├── jsuploadfile.html │ │ │ ├── upload.css │ │ │ └── uploadfile.html │ ├── cpp │ │ └── native-lib.cpp │ ├── java │ │ └── com │ │ │ └── just │ │ │ └── agentwebx5_sample │ │ │ ├── AgentWebX5Fragment.java │ │ │ ├── AndroidInterface.java │ │ │ ├── App.java │ │ │ ├── BaseWebActivity.java │ │ │ ├── CommonActivity.java │ │ │ ├── CommonIndicator.java │ │ │ ├── CustomIndicatorFragment.java │ │ │ ├── CustomSettings.java │ │ │ ├── CustomSettingsFragment.java │ │ │ ├── FragmentKeyDown.java │ │ │ ├── JsAgentWebFragment.java │ │ │ ├── MainActivity.java │ │ │ ├── WebActivity.java │ │ │ └── WebLayout.java │ ├── jniLibs │ │ └── armeabi │ │ │ └── liblbs.so │ └── res │ │ ├── drawable-v21 │ │ ├── ripple_for_btn.xml │ │ └── selector_drawable_for_btn.xml │ │ ├── drawable │ │ ├── btn_shape.xml │ │ ├── btn_shape_s.xml │ │ ├── indicator_shape.xml │ │ ├── iv_back_selector.xml │ │ └── selector_drawable_for_btn.xml │ │ ├── layout │ │ ├── activity_common.xml │ │ ├── activity_main.xml │ │ ├── activity_web.xml │ │ ├── fragment_agentweb.xml │ │ ├── fragment_js.xml │ │ ├── fragment_twk_web.xml │ │ ├── listview_main.xml │ │ ├── markdown_view.xml │ │ └── toorbar_main.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── app_logo.png │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── app_logo.png │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── app_logo.png │ │ ├── back.png │ │ ├── cha.png │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── just │ └── agentwebx5 │ └── ExampleUnitTest.java ├── settings.gradle └── twlibrary ├── .gitignore ├── build.gradle ├── libs └── tbs_sdk_thirdapp_v3.1.0.1034_43100_sharewithdownload_obfs_20170301_182143.jar ├── proguard-rules.pro └── src └── main ├── AndroidManifest.xml ├── java └── com │ └── lcodecore │ └── tkrefreshlayout │ ├── Footer │ ├── BallPulseView.java │ └── LoadingView.java │ ├── IBottomView.java │ ├── IHeaderView.java │ ├── OnAnimEndListener.java │ ├── OnGestureListener.java │ ├── PullListener.java │ ├── RefreshListenerAdapter.java │ ├── TwinklingRefreshLayout.java │ ├── header │ ├── GoogleDotView.java │ ├── SinaRefreshView.java │ ├── bezierlayout │ │ ├── BezierLayout.java │ │ ├── RippleView.java │ │ ├── RoundDotView.java │ │ ├── RoundProgressView.java │ │ └── WaveView.java │ └── progresslayout │ │ ├── CircleImageView.java │ │ ├── MaterialProgressDrawable.java │ │ └── ProgressLayout.java │ ├── processor │ ├── AnimProcessor.java │ ├── Decorator.java │ ├── IAnimOverScroll.java │ ├── IAnimRefresh.java │ ├── IDecorator.java │ ├── OverScrollDecorator.java │ └── RefreshProcessor.java │ └── utils │ ├── DensityUtil.java │ ├── LogUtil.java │ └── ScrollingUtil.java └── res ├── drawable-xhdpi └── ic_arrow.png ├── drawable └── anim_loading_view.xml ├── layout ├── view_bezier.xml └── view_sinaheader.xml ├── mipmap-hdpi ├── refresh_head_arrow.png ├── refresh_loading01.png ├── refresh_loading02.png ├── refresh_loading03.png ├── refresh_loading04.png ├── refresh_loading05.png ├── refresh_loading06.png ├── refresh_loading07.png ├── refresh_loading08.png ├── refresh_loading09.png ├── refresh_loading10.png ├── refresh_loading11.png └── refresh_loading12.png └── values ├── attrs.xml ├── colors.xml ├── ids.xml └── strings.xml /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | /node_modules 11 | package-lock.json 12 | package.json -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/dictionaries/cenxiaozhong.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/markdown-navigator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /.idea/markdown-navigator/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 1.8 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## AgentWebX5 介绍(该库不再维护) 4 | 5 | 基于腾讯X5内核版的 [AgentWeb](https://github.com/Justson/AgentWeb) ,简单易用 , 带有进度条 、 支持文件上传 、 下载 、 简化 Javascript 通信 、 链式调用 、性能更优 。更多使用请参照上面的 sample 。 6 | 7 | ## AgentWebX5 功能 8 | 1. 支持进度条以及自定义进度条 9 | 2. 支持文件下载 10 | 3. 支持文件下载断点续传 11 | 4. 支持下载通知形式提示进度 12 | 5. 简化 Javascript 通信 13 | 6. 支持 Android 4.4 Kitkat 以及其他版本文件上传 14 | 7. 支持注入 Cookies 15 | 8. 支持全屏播放视频 16 | 9. 支持调起微信支付 17 | 10. 支持调起支付宝 18 | 11. 默认支持定位 19 | 12. 支持传入IWebLayout(下拉回弹效果) 20 | 21 | ## 引入 22 | 23 | * Gradle 24 | 25 | ``` 26 | compile 'com.just.agentwebX5:agentwebX5:2.0.0' 27 | ``` 28 | * Maven 29 | 30 | ``` 31 | 32 | com.just.agentwebX5 33 | agentwebX5 34 | 2.0.0 35 | pom 36 | 37 | ``` 38 | 39 | ## Android WebView 40 | 如果你更喜欢Android WebView ,请切换到这个仓库 41 | [AgentWeb](https://github.com/Justson/AgentWeb) 42 | 43 | ## 使用 44 | 45 | 1. 下载腾讯X5内核最新 [SDK](https://x5.tencent.com/tbs/) 导入项目中并依赖。 46 | 2. 引入 `AgentWebX5` 47 | 3. 需要全局初始化X5内核 `QbSdk.initX5Environment(getApplicationContext(), cb);` 48 | 49 | ## 注意事项 50 | 1. AgentWebX5 内部并没有直接依赖X5库 ,需要用户到[腾讯X5官网](https://x5.tencent.com/tbs/)下载 , 并在项目中依赖该库 。 51 | 2. 由于使用的是 X5 内核,不是 Google 官方控件, 所以很多第三方开源组件不支持 。 52 | 3. 支付宝需要引入[支付宝SDK](https://open.alipay.com/platform/home.htm)项目中依赖上支付宝SDK即可 ,微信支付不需要做任何操作。 53 | 4. 注意权限 。 54 | 5. 注意腾讯X5库官方升级并替换成最新的库。 55 | 6. [onJsAlert 阻塞 ](https://github.com/Justson/AgentWebX5/issues/21) 56 | 57 | ## 问答 58 | 59 | ### AgentWeb 和 AgentWebX5 有什么区别吗? 60 | AgentWebX5 和 AgentWeb 区别在于 AgentWeb 依赖于系统 WebView ,而 AgentWebX5 依赖是腾讯X5内核 , AgentWebX5 是把 AgentWeb 内部 Android系统提供的WebView 替换成了X5库WebView 。 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.3.3' 9 | 10 | classpath 'com.novoda:bintray-release:0.3.4' 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | jcenter() 19 | } 20 | } 21 | 22 | task clean(type: Delete) { 23 | delete rootProject.buildDir 24 | } 25 | tasks.withType(Javadoc) { 26 | options.addStringOption('Xdoclint:none', '-quiet') 27 | options.addStringOption('encoding', 'UTF-8') 28 | } 29 | 30 | tasks.getByPath(":library:mavenAndroidJavadocs").enabled = false 31 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | SUPPORT_LIB_VERSION=25.2.0 14 | android.useDeprecatedNdk=true 15 | 16 | # When configured, Gradle will run in incubating parallel mode. 17 | # This option should only be used with decoupled projects. More details, visit 18 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 19 | # org.gradle.parallel=true 20 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 30 23:12:10 CST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip 7 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'maven' 3 | apply plugin: 'com.novoda.bintray-release' 4 | 5 | android { 6 | compileSdkVersion 25 7 | buildToolsVersion "25.0.2" 8 | 9 | defaultConfig { 10 | minSdkVersion 11 11 | targetSdkVersion 25 12 | versionCode 1 13 | versionName "1.0" 14 | 15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 16 | 17 | } 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | lintOptions{ 25 | abortOnError false 26 | } 27 | //defaultPublishConfig "debug" 28 | 29 | } 30 | 31 | task javadoc(type: Javadoc) { 32 | options.encoding = "utf-8" 33 | } 34 | dependencies { 35 | compile fileTree(include: ['*.jar'], dir: 'libs') 36 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 37 | exclude group: 'com.android.support', module: 'support-annotations' 38 | }) 39 | testCompile 'junit:junit:4.12' 40 | compile "com.android.support:design:${SUPPORT_LIB_VERSION}" 41 | compile "com.android.support:support-v4:${SUPPORT_LIB_VERSION}" 42 | provided fileTree(include: ['*.jar'], dir: 'providedLibs') 43 | } 44 | publish { 45 | userOrg = 'just' 46 | groupId = 'com.just.agentwebX5' 47 | artifactId = 'agentwebX5' 48 | version = '2.0.0' 49 | description = 'very easy to build you web page' 50 | website = "https://github.com/Justson/AgentWebX5" 51 | 52 | } 53 | -------------------------------------------------------------------------------- /library/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/cenxiaozhong/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /library/providedLibs/alipaySdk-20170922.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/library/providedLibs/alipaySdk-20170922.jar -------------------------------------------------------------------------------- /library/providedLibs/tbs_sdk_thirdapp_v3.5.0.1004_43500_sharewithdownload_withoutGame_obfs_20170801_113025.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/library/providedLibs/tbs_sdk_thirdapp_v3.5.0.1004_43500_sharewithdownload_withoutGame_obfs_20170801_113025.jar -------------------------------------------------------------------------------- /library/src/androidTest/java/com/just/agentwebX5/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.just.agentwebX5.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 10 | 11 | 16 | 19 | 20 | 21 | 22 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/AgentWebJsInterfaceX5Compat.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.app.Activity; 4 | import android.webkit.JavascriptInterface; 5 | 6 | import java.lang.ref.WeakReference; 7 | 8 | /** 9 | * Created by cenxiaozhong on 2017/5/24. 10 | */ 11 | 12 | public class AgentWebJsInterfaceX5Compat implements AgentWebX5Compat, FileUploadPop { 13 | 14 | private AgentWebX5 mAgentWebX5; 15 | private WeakReference mReference = null; 16 | private WeakReference mActivityWeakReference = null; 17 | 18 | AgentWebJsInterfaceX5Compat(AgentWebX5 agentWebX5, Activity activity) { 19 | this.mReference = new WeakReference(agentWebX5); 20 | mActivityWeakReference = new WeakReference(activity); 21 | } 22 | 23 | private IFileUploadChooser mIFileUploadChooser; 24 | 25 | @JavascriptInterface 26 | public void uploadFile() { 27 | 28 | 29 | LogUtils.i("AgentWebJsInterfaceX5Compat", "upload file"); 30 | if (mActivityWeakReference.get() != null && mReference.get() != null) { 31 | mIFileUploadChooser = new FileUpLoadChooserImpl.Builder() 32 | .setActivity(mActivityWeakReference.get()) 33 | .setJsChannelCallback(new FileUpLoadChooserImpl.JsChannelCallback() { 34 | @Override 35 | public void call(String value) { 36 | if (mReference.get() != null) 37 | mReference.get().getJsEntraceAccess().quickCallJs("uploadFileResult", value); 38 | } 39 | }).setFileUploadMsgConfig(mReference.get().getDefaultMsgConfig().getChromeClientMsgCfg().getFileUploadMsgConfig()) 40 | .setPermissionInterceptor(mReference.get().getPermissionInterceptor()) 41 | .setWebView(mReference.get().getWebCreator().get()) 42 | .build(); 43 | mIFileUploadChooser.openFileChooser(); 44 | return; 45 | } 46 | // mIFileUploadChooser.openFileChooser(); 47 | 48 | } 49 | 50 | @Override 51 | public IFileUploadChooser pop() { 52 | IFileUploadChooser mIFileUploadChooser = this.mIFileUploadChooser; 53 | this.mIFileUploadChooser = null; 54 | return mIFileUploadChooser; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/AgentWebX5Compat.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | /** 4 | * Created by cenxiaozhong on 2017/5/24. 5 | */ 6 | 7 | public interface AgentWebX5Compat { 8 | } 9 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/AgentWebX5FileProvider.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.support.v4.content.FileProvider; 4 | 5 | /** 6 | * Created by cenxiaozhong on 2017/5/25. 7 | */ 8 | 9 | public class AgentWebX5FileProvider extends FileProvider { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/AgentWebX5Permissions.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.Manifest; 4 | 5 | /** 6 | * Created by cenxiaozhong on 2017/8/18. 7 | */ 8 | 9 | public class AgentWebX5Permissions { 10 | 11 | 12 | public static final String[] CAMERA; 13 | public static final String[] LOCATION; 14 | public static final String[] STORAGE; 15 | 16 | static { 17 | 18 | 19 | CAMERA = new String[]{ 20 | Manifest.permission.CAMERA}; 21 | 22 | 23 | LOCATION = new String[]{ 24 | Manifest.permission.ACCESS_FINE_LOCATION, 25 | Manifest.permission.ACCESS_COARSE_LOCATION}; 26 | 27 | 28 | STORAGE = new String[]{ 29 | Manifest.permission.READ_EXTERNAL_STORAGE, 30 | Manifest.permission.WRITE_EXTERNAL_STORAGE}; 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/BaseAgentWebActivity.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v7.app.AppCompatActivity; 6 | 7 | /** 8 | * Created by cenxiaozhong on 2017/7/18. 9 | */ 10 | public class BaseAgentWebActivity extends AppCompatActivity { 11 | 12 | @Override 13 | protected void onCreate(@Nullable Bundle savedInstanceState) { 14 | super.onCreate(savedInstanceState); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/BaseIndicatorView.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.Nullable; 5 | import android.util.AttributeSet; 6 | import android.widget.FrameLayout; 7 | 8 | /** 9 | * Created by cenxiaozhong on 2017/5/12. 10 | * source CODE https://github.com/Justson/AgentWebX5 11 | */ 12 | 13 | public abstract class BaseIndicatorView extends FrameLayout implements BaseProgressSpec ,LayoutParamsOffer{ 14 | public BaseIndicatorView(Context context) { 15 | super(context); 16 | } 17 | 18 | public BaseIndicatorView(Context context, @Nullable AttributeSet attrs) { 19 | super(context, attrs); 20 | } 21 | 22 | public BaseIndicatorView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { 23 | super(context, attrs, defStyleAttr); 24 | } 25 | 26 | @Override 27 | public void reset() { 28 | 29 | } 30 | 31 | @Override 32 | public void setProgress(int newProgress) { 33 | 34 | } 35 | 36 | @Override 37 | public void show() { 38 | 39 | } 40 | 41 | @Override 42 | public void hide() { 43 | 44 | } 45 | 46 | 47 | 48 | @Override 49 | public LayoutParams offerLayoutParams() { 50 | return null; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/BaseJsEntraceAccess.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.os.Build; 4 | import android.util.Log; 5 | import android.webkit.ValueCallback; 6 | 7 | import com.tencent.smtt.sdk.WebView; 8 | 9 | 10 | /** 11 | * Created by cenxiaozhong on 2017/5/26. 12 | * source code https://github.com/Justson/AgentWebX5 13 | */ 14 | 15 | public abstract class BaseJsEntraceAccess implements JsEntraceAccess { 16 | 17 | private WebView mWebView; 18 | BaseJsEntraceAccess(WebView webView){ 19 | this.mWebView=webView; 20 | } 21 | 22 | @Override 23 | public void callJs(String js, final ValueCallback callback) { 24 | 25 | Log.i("Info","js:"+js); 26 | 27 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { 28 | this.evaluateJs(js, callback); 29 | } else { 30 | this.loadJs(js); 31 | } 32 | 33 | 34 | } 35 | @Override 36 | public void callJs(String js) { 37 | this.callJs(js, null); 38 | } 39 | 40 | 41 | private void loadJs(String js) { 42 | 43 | mWebView.loadUrl(js); 44 | 45 | } 46 | private void evaluateJs(String js, final ValueCallbackcallback){ 47 | 48 | mWebView.evaluateJavascript(js, new com.tencent.smtt.sdk.ValueCallback() { 49 | @Override 50 | public void onReceiveValue(String value) { 51 | if (callback != null) 52 | callback.onReceiveValue(value); 53 | } 54 | }); 55 | } 56 | 57 | 58 | @Override 59 | public void quickCallJs(String method, ValueCallback callback,String... params) { 60 | 61 | StringBuilder sb=new StringBuilder(); 62 | sb.append("javascript:"+method); 63 | if(params==null||params.length==0){ 64 | sb.append("()"); 65 | }else{ 66 | sb.append("(").append(concat(params)).append(")"); 67 | } 68 | 69 | 70 | callJs(sb.toString(),callback); 71 | 72 | } 73 | 74 | private String concat(String...params){ 75 | 76 | StringBuilder mStringBuilder=new StringBuilder(); 77 | 78 | for(int i=0;i= 11) 25 | this.mWebView.onResume(); 26 | 27 | this.mWebView.resumeTimers(); 28 | 29 | } 30 | 31 | 32 | } 33 | 34 | @Override 35 | public void onPause() { 36 | 37 | if (this.mWebView != null) { 38 | this.mWebView.pauseTimers(); 39 | if (Build.VERSION.SDK_INT >= 11) 40 | this.mWebView.onPause(); 41 | } 42 | } 43 | 44 | @Override 45 | public void onDestroy() { 46 | if(this.mWebView!=null){ 47 | this.mWebView.resumeTimers(); 48 | } 49 | AgentWebX5Utils.clearWebView(this.mWebView); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/DownLoadResultListener.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | /** 4 | * Created by cenxiaozhong on 2017/6/21. 5 | * 6 | * source CODE https://github.com/Justson/AgentWebX5 7 | */ 8 | 9 | public interface DownLoadResultListener { 10 | 11 | 12 | void success(String path); 13 | 14 | void error(String path, String resUrl, String cause, Throwable e); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/DownLoadTask.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.content.Context; 4 | 5 | import java.io.File; 6 | import java.io.Serializable; 7 | import java.lang.ref.WeakReference; 8 | 9 | /** 10 | * Created by cenxiaozhong on 2017/5/13. 11 | * source CODE https://github.com/Justson/AgentWebX5 12 | */ 13 | 14 | public class DownLoadTask implements Serializable { 15 | 16 | 17 | private int id; 18 | private String url; 19 | //是否强制下载不管网络类型 20 | private boolean isForce; 21 | 22 | //如否需要需要下载进度条 23 | private boolean enableIndicator=true; 24 | 25 | private Context mContext; 26 | private File mFile; 27 | 28 | private long length; 29 | 30 | private int drawableRes; 31 | 32 | private WeakReferencemReference=null; 33 | private DefaultMsgConfig.DownLoadMsgConfig mDownLoadMsgConfig; 34 | 35 | 36 | public DownLoadTask(int id, String url, DownLoadResultListener downLoadResultListeners, boolean isForce, boolean enableIndicator, Context context, File file, long length, DefaultMsgConfig.DownLoadMsgConfig downLoadMsgConfig, int drawableRes) { 37 | this.id = id; 38 | this.url = url; 39 | this.isForce = isForce; 40 | this.enableIndicator = enableIndicator; 41 | mContext = context; 42 | mFile = file; 43 | this.length = length; 44 | this.drawableRes = drawableRes; 45 | mReference=new WeakReference(downLoadResultListeners); 46 | this.mDownLoadMsgConfig=downLoadMsgConfig; 47 | } 48 | 49 | public int getId() { 50 | return id; 51 | } 52 | 53 | public void setId(int id) { 54 | this.id = id; 55 | } 56 | 57 | public String getUrl() { 58 | return url; 59 | } 60 | 61 | public void setUrl(String url) { 62 | this.url = url; 63 | } 64 | 65 | public boolean isForce() { 66 | return isForce; 67 | } 68 | 69 | public void setForce(boolean force) { 70 | isForce = force; 71 | } 72 | 73 | public boolean isEnableIndicator() { 74 | return enableIndicator; 75 | } 76 | 77 | public void setEnableIndicator(boolean enableIndicator) { 78 | this.enableIndicator = enableIndicator; 79 | } 80 | 81 | public WeakReference getReference() { 82 | return mReference; 83 | } 84 | 85 | public void setReference(WeakReference reference) { 86 | mReference = reference; 87 | } 88 | 89 | public DefaultMsgConfig.DownLoadMsgConfig getDownLoadMsgConfig() { 90 | return mDownLoadMsgConfig; 91 | } 92 | 93 | public void setDownLoadMsgConfig(DefaultMsgConfig.DownLoadMsgConfig downLoadMsgConfig) { 94 | mDownLoadMsgConfig = downLoadMsgConfig; 95 | } 96 | 97 | public Context getContext() { 98 | return mContext; 99 | } 100 | 101 | public void setContext(Context context) { 102 | mContext = context.getApplicationContext(); 103 | } 104 | 105 | public File getFile() { 106 | return mFile; 107 | } 108 | 109 | public void setFile(File file) { 110 | mFile = file; 111 | } 112 | 113 | public long getLength() { 114 | return length; 115 | } 116 | 117 | public void setLength(long length) { 118 | this.length = length; 119 | } 120 | 121 | public int getDrawableRes() { 122 | return drawableRes; 123 | } 124 | 125 | public DownLoadResultListener getDownLoadResultListener() { 126 | return mReference.get(); 127 | } 128 | 129 | 130 | 131 | public void setDrawableRes(int drawableRes) { 132 | this.drawableRes = drawableRes; 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/EventHandlerImpl.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.view.KeyEvent; 4 | 5 | import com.tencent.smtt.sdk.WebView; 6 | 7 | 8 | /** 9 | * @项目名: agentwebX5 10 | * @包名: 11 | * @创建者: cxz -- just 12 | * @创建时间: &{DATE} 13 | * @公司: 14 | * @邮箱: cenxiaozhong.qqcom@qq.com 15 | * @描述 16 | * 17 | * source CODE https://github.com/Justson/AgentWebX5 18 | */ 19 | 20 | public class EventHandlerImpl implements IEventHandler { 21 | private WebView mWebView; 22 | private EventInterceptor mEventInterceptor; 23 | 24 | public static final EventHandlerImpl getInstantce(WebView view,EventInterceptor eventInterceptor) { 25 | return new EventHandlerImpl(view, eventInterceptor); 26 | } 27 | 28 | public EventHandlerImpl(WebView webView,EventInterceptor eventInterceptor) { 29 | LogUtils.i("Info","EventInterceptor:"+eventInterceptor); 30 | this.mWebView = webView; 31 | this.mEventInterceptor = eventInterceptor; 32 | } 33 | 34 | @Override 35 | public boolean onKeyDown(int keyCode, KeyEvent event) { 36 | 37 | 38 | if (keyCode == KeyEvent.KEYCODE_BACK) { 39 | 40 | return back(); 41 | } 42 | return false; 43 | } 44 | 45 | @Override 46 | public boolean back() { 47 | if(this.mEventInterceptor!=null&&this.mEventInterceptor.event()){ 48 | return true; 49 | } 50 | if(mWebView!=null&&mWebView.canGoBack()){ 51 | mWebView.goBack(); 52 | return true; 53 | } 54 | return false; 55 | } 56 | 57 | public void inJectPriorityEvent(){ 58 | 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/EventInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | /** 4 | * Created by cenxiaozhong on 2017/6/10. 5 | * source CODE https://github.com/Justson/AgentWebX5 6 | */ 7 | 8 | public interface EventInterceptor { 9 | 10 | boolean event(); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/FileParcel.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | /** 7 | * Created by cenxiaozhong on 2017/5/24. 8 | * source CODE https://github.com/Justson/AgentWebX5 9 | */ 10 | 11 | public class FileParcel implements Parcelable { 12 | 13 | int id; 14 | private String contentPath; 15 | private String fileBase64; 16 | 17 | protected FileParcel(Parcel in) { 18 | id = in.readInt(); 19 | contentPath = in.readString(); 20 | fileBase64 = in.readString(); 21 | } 22 | 23 | public FileParcel(int id, String contentPath, String fileBase64) { 24 | this.id = id; 25 | this.contentPath = contentPath; 26 | this.fileBase64 = fileBase64; 27 | 28 | LogUtils.i("Info","file:"+fileBase64); 29 | } 30 | 31 | public static final Creator CREATOR = new Creator() { 32 | @Override 33 | public FileParcel createFromParcel(Parcel in) { 34 | return new FileParcel(in); 35 | } 36 | 37 | @Override 38 | public FileParcel[] newArray(int size) { 39 | return new FileParcel[size]; 40 | } 41 | }; 42 | 43 | public int getId() { 44 | return id; 45 | } 46 | 47 | public void setId(int id) { 48 | this.id = id; 49 | } 50 | 51 | public String getContentPath() { 52 | return contentPath; 53 | } 54 | 55 | public void setContentPath(String contentPath) { 56 | this.contentPath = contentPath; 57 | } 58 | 59 | public String getFileBase64() { 60 | return fileBase64; 61 | } 62 | 63 | public void setFileBase64(String fileBase64) { 64 | this.fileBase64 = fileBase64; 65 | } 66 | 67 | @Override 68 | public int describeContents() { 69 | return 0; 70 | } 71 | 72 | @Override 73 | public void writeToParcel(Parcel dest, int flags) { 74 | dest.writeInt(id); 75 | dest.writeString(contentPath); 76 | dest.writeString(fileBase64); 77 | } 78 | 79 | @Override 80 | public String toString() { 81 | return "FileParcel{" + 82 | "id=" + id + 83 | ", contentPath='" + contentPath + '\'' + 84 | ", fileBase64='" + fileBase64 + '\'' + 85 | '}'; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/FileUploadPop.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | /** 4 | * Created by cenxiaozhong on 2017/5/22. 5 | * source CODE https://github.com/Justson/AgentWebX5 6 | */ 7 | 8 | public interface FileUploadPop { 9 | 10 | T pop(); 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/HookManager.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | 4 | public class HookManager { 5 | 6 | 7 | public static AgentWebX5 hookAgentWeb(AgentWebX5 agentWebX5, AgentWebX5.AgentBuilder agentBuilder) { 8 | return agentWebX5; 9 | } 10 | 11 | public static AgentWebX5 hookAgentWeb(AgentWebX5 agentWebX5, AgentWebX5.AgentBuilderFragment agentBuilder) { 12 | return agentWebX5; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/IEventHandler.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.view.KeyEvent; 4 | 5 | /** 6 | * @项目名: agentwebX5 7 | * @包名:com.just.library 8 | * @创建者: cxz -- just 9 | * @创建时间: &{DATE} 10 | * @公司: 宝诺科技 11 | * @邮箱: cenxiaozhong.qqcom@qq.com 12 | * @描述 13 | * 14 | * source CODE https://github.com/Justson/AgentWebX5 15 | */ 16 | 17 | public interface IEventHandler { 18 | 19 | boolean onKeyDown(int keyCode, KeyEvent event); 20 | 21 | 22 | boolean back(); 23 | } 24 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/IFileUploadChooser.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.content.Intent; 4 | 5 | /** 6 | * Created by cenxiaozhong on 2017/5/22. 7 | * source CODE https://github.com/Justson/AgentWebX5 8 | */ 9 | 10 | public interface IFileUploadChooser { 11 | 12 | 13 | 14 | void openFileChooser(); 15 | 16 | void fetchFilePathFromIntent(int requestCode, int resultCode, Intent data); 17 | } 18 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/ILoader.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | /** 4 | * Created by cenxiaozhong on 2017/6/3. 5 | * source CODE https://github.com/Justson/AgentWebX5 6 | */ 7 | 8 | public interface ILoader { 9 | 10 | 11 | void loadUrl(String url); 12 | 13 | void reload(); 14 | 15 | void loadData(String data, String mimeType, String encoding); 16 | 17 | void stopLoading(); 18 | 19 | void loadDataWithBaseURL(String baseUrl, String data, 20 | String mimeType, String encoding, String historyUrl); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/IVideo.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | 4 | import android.view.View; 5 | 6 | import com.tencent.smtt.export.external.interfaces.IX5WebChromeClient; 7 | 8 | /** 9 | * Created by cenxiaozhong on 2017/6/10. 10 | * source CODE https://github.com/Justson/AgentWebX5 11 | */ 12 | 13 | public interface IVideo { 14 | 15 | 16 | void onShowCustomView(View view,IX5WebChromeClient.CustomViewCallback callback); 17 | 18 | 19 | void onHideCustomView(); 20 | 21 | 22 | boolean isVideoState(); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/IWebClientHelper.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | /** 4 | * Created by cenxiaozhong on 2017/6/10. 5 | * 这个接口主要是服务 WebViewClient , 处理一些常用固定的业务的 6 | * source CODE https://github.com/Justson/AgentWebX5 7 | */ 8 | 9 | public interface IWebClientHelper { 10 | } 11 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/IWebLayout.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.support.annotation.NonNull; 4 | import android.support.annotation.Nullable; 5 | import android.view.ViewGroup; 6 | 7 | import com.tencent.smtt.sdk.WebView; 8 | 9 | /** 10 | * Created by cenxiaozhong on 2017/7/1. 11 | * source CODE https://github.com/Justson/AgentWebX5 12 | */ 13 | 14 | public interface IWebLayout { 15 | 16 | /** 17 | * 18 | * @return WebView 的父控件 19 | */ 20 | @NonNull V getLayout(); 21 | 22 | /** 23 | * 24 | * @return 返回 WebView 或 WebView 的子View ,返回null AgentWebX5 内部会自动创建适当 WebView 25 | */ 26 | @Nullable T getWeb(); 27 | } 28 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/IndicatorController.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | 4 | import com.tencent.smtt.sdk.WebView; 5 | 6 | /** 7 | * @项目名: agentwebX5 8 | * @包名:com.just.library 9 | * @创建者: cxz -- just 10 | * @创建时间: &{DATE} 11 | * @公司: 12 | * @邮箱: cenxiaozhong.qqcom@qq.com 13 | * @描述source CODE https://github.com/Justson/AgentWebX5 14 | */ 15 | 16 | public interface IndicatorController { 17 | 18 | void progress(WebView v, int newProgress); 19 | 20 | BaseProgressSpec offerIndicator(); 21 | } 22 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/IndicatorHandler.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | 4 | import com.tencent.smtt.sdk.WebView; 5 | 6 | /** 7 | * @项目名: agentwebX5 8 | * @包名:com.just.library 9 | * @创建者: cxz -- just 10 | * @创建时间: &{DATE} 11 | * @公司: 12 | * @邮箱: cenxiaozhong.qqcom@qq.com 13 | * @描述source CODE https://github.com/Justson/AgentWebX5 14 | */ 15 | 16 | public class IndicatorHandler implements IndicatorController, ProgressLifeCyclic { 17 | BaseProgressSpec baseProgressSpec; 18 | 19 | @Override 20 | public void progress(WebView v, int newProgress) { 21 | 22 | // Log.i("Info", "newProgress:" + newProgress + " v:" + v); 23 | if (newProgress == 0) { 24 | reset(); 25 | } else if (newProgress > 0 && newProgress <= 10) { 26 | showProgressBar(); 27 | } else if (newProgress > 10 && newProgress < 95) { 28 | setProgressBar(newProgress); 29 | } else { 30 | setProgressBar(newProgress); 31 | finish(); 32 | } 33 | 34 | } 35 | 36 | @Override 37 | public BaseProgressSpec offerIndicator() { 38 | return this.baseProgressSpec; 39 | } 40 | 41 | public void reset() { 42 | 43 | if (baseProgressSpec != null) { 44 | baseProgressSpec.reset(); 45 | } 46 | } 47 | 48 | public void finish() { 49 | if (baseProgressSpec != null) { 50 | baseProgressSpec.hide(); 51 | } 52 | } 53 | 54 | public void setProgressBar(int n) { 55 | if (baseProgressSpec != null) { 56 | baseProgressSpec.setProgress(n); 57 | } 58 | } 59 | 60 | public void showProgressBar() { 61 | 62 | if (baseProgressSpec != null) { 63 | baseProgressSpec.show(); 64 | } 65 | } 66 | 67 | public static IndicatorHandler getInstance() { 68 | return new IndicatorHandler(); 69 | } 70 | 71 | 72 | public IndicatorHandler inJectProgressView(BaseProgressSpec baseProgressSpec) { 73 | this.baseProgressSpec = baseProgressSpec; 74 | return this; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/JsBaseInterfaceHolder.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.os.Build; 4 | import android.webkit.JavascriptInterface; 5 | 6 | import java.lang.annotation.Annotation; 7 | import java.lang.reflect.Method; 8 | 9 | /** 10 | * Created by cenxiaozhong on 2017/5/13. 11 | * source CODE https://github.com/Justson/AgentWebX5 12 | */ 13 | 14 | public abstract class JsBaseInterfaceHolder implements JsInterfaceHolder{ 15 | 16 | private AgentWebX5.SecurityType mSecurityType; 17 | protected JsBaseInterfaceHolder(AgentWebX5.SecurityType securityType){ 18 | this.mSecurityType =securityType; 19 | } 20 | @Override 21 | public boolean checkObject(Object v) { 22 | 23 | if(Build.VERSION.SDK_INTBuild.VERSION_CODES.JELLY_BEAN_MR1; 53 | } 54 | 55 | 56 | } 57 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/JsEntraceAccess.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.webkit.ValueCallback; 4 | 5 | /** 6 | * Created by cenxiaozhong on 2017/5/14. 7 | * source CODE https://github.com/Justson/AgentWebX5 8 | */ 9 | 10 | public interface JsEntraceAccess extends QuickCallJs{ 11 | 12 | 13 | void callJs(String js, ValueCallback callback); 14 | 15 | void callJs(String js); 16 | 17 | 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/JsEntraceAccessImpl.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.os.Handler; 4 | import android.os.Looper; 5 | import android.webkit.ValueCallback; 6 | 7 | import com.tencent.smtt.sdk.WebView; 8 | 9 | 10 | /** 11 | * @项目名: 12 | * @包名: 13 | * @创建者: cxz -- just 14 | * @创建时间: &{DATE} 15 | * @公司: 16 | * @邮箱: cenxiaozhong.qqcom@qq.com 17 | * @描述 18 | * source CODE https://github.com/Justson/AgentWebX5 19 | */ 20 | 21 | public class JsEntraceAccessImpl extends BaseJsEntraceAccess { 22 | 23 | private WebView mWebView; 24 | private Handler mHandler = new Handler(Looper.getMainLooper()); 25 | 26 | 27 | public static JsEntraceAccessImpl getInstance(WebView webView) { 28 | return new JsEntraceAccessImpl(webView); 29 | } 30 | 31 | private JsEntraceAccessImpl(WebView webView) { 32 | super(webView); 33 | this.mWebView = webView; 34 | } 35 | 36 | 37 | 38 | private void callSafeCallJs(final String s, final ValueCallback valueCallback) { 39 | mHandler.post(new Runnable() { 40 | @Override 41 | public void run() { 42 | callJs(s, valueCallback); 43 | } 44 | }); 45 | } 46 | 47 | @Override 48 | public void callJs(String params, final ValueCallback callback) { 49 | if (Thread.currentThread() != Looper.getMainLooper().getThread()) { 50 | callSafeCallJs(params, callback); 51 | return; 52 | } 53 | 54 | super.callJs(params,callback); 55 | 56 | } 57 | 58 | 59 | 60 | 61 | 62 | 63 | /* private void safeCallJs(final String method, final ValueCallbackvalueCallback, final String... params){ 64 | mHandler.post(new Runnable() { 65 | @Override 66 | public void run() { 67 | quickCallJs(method,valueCallback,params); 68 | } 69 | }); 70 | } 71 | @Override 72 | public void quickCallJs(String method, ValueCallback callback, String... params) { 73 | if(Thread.currentThread()!=Looper.getMainLooper().getThread()){ 74 | safeCallJs(method,callback,params); 75 | return; 76 | } 77 | super.quickCallJs(method, callback, params); 78 | } 79 | */ 80 | 81 | } 82 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/JsInterfaceHolder.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.support.v4.util.ArrayMap; 4 | 5 | /** 6 | * Created by cenxiaozhong on 2017/5/13. 7 | * source CODE https://github.com/Justson/AgentWebX5 8 | */ 9 | 10 | public interface JsInterfaceHolder { 11 | 12 | JsInterfaceHolder addJavaObjects(ArrayMap maps); 13 | 14 | JsInterfaceHolder addJavaObject(String k, Object v); 15 | 16 | boolean checkObject(Object v) ; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/JsInterfaceHolderImpl.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.support.v4.util.ArrayMap; 4 | import android.util.Log; 5 | 6 | import com.tencent.smtt.sdk.WebView; 7 | 8 | import java.util.Map; 9 | import java.util.Set; 10 | 11 | /** 12 | * Created by cenxiaozhong on 2017/5/13. 13 | * source CODE https://github.com/Justson/AgentWebX5 14 | */ 15 | 16 | public class JsInterfaceHolderImpl extends JsBaseInterfaceHolder { 17 | 18 | static JsInterfaceHolderImpl getJsInterfaceHolder(WebView webView, AgentWebX5.SecurityType securityType) { 19 | 20 | return new JsInterfaceHolderImpl(webView,securityType); 21 | } 22 | 23 | private WebView mWebView; 24 | private AgentWebX5.SecurityType mSecurityType; 25 | JsInterfaceHolderImpl(WebView webView, AgentWebX5.SecurityType securityType) { 26 | super(securityType); 27 | this.mWebView = webView; 28 | this.mSecurityType=securityType; 29 | } 30 | 31 | @Override 32 | public JsInterfaceHolder addJavaObjects(ArrayMap maps) { 33 | 34 | 35 | 36 | if(!checkSecurity()){ 37 | return this; 38 | } 39 | Set> sets = maps.entrySet(); 40 | for (Map.Entry mEntry : sets) { 41 | 42 | 43 | Object v = mEntry.getValue(); 44 | boolean t = checkObject(v); 45 | if (!t) 46 | throw new JsInterfaceObjectException("this object has not offer method javascript to call ,please check addJavascriptInterface annotation was be added"); 47 | 48 | else 49 | addJavaObjectDirect(mEntry.getKey(), v); 50 | } 51 | 52 | return this; 53 | } 54 | 55 | @Override 56 | public JsInterfaceHolder addJavaObject(String k, Object v) { 57 | 58 | if(!checkSecurity()){ 59 | return this; 60 | } 61 | boolean t = checkObject(v); 62 | if (!t) 63 | throw new JsInterfaceObjectException("this object has not offer method javascript to call , please check addJavascriptInterface annotation was be added"); 64 | 65 | else 66 | addJavaObjectDirect(k, v); 67 | return this; 68 | } 69 | 70 | private JsInterfaceHolder addJavaObjectDirect(String k, Object v) { 71 | Log.i("Info", "k" + k + " v:" + v); 72 | this.mWebView.addJavascriptInterface(v, k); 73 | return this; 74 | } 75 | 76 | 77 | } 78 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/JsInterfaceObjectException.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | /** 4 | * Created by cenxiaozhong on 2017/5/13. 5 | * source CODE https://github.com/Justson/AgentWebX5 6 | */ 7 | 8 | public class JsInterfaceObjectException extends RuntimeException { 9 | JsInterfaceObjectException(String msg){ 10 | super(msg); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/LayoutParamsOffer.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.widget.FrameLayout; 4 | 5 | /** 6 | * Created by cenxiaozhong on 2017/5/12. 7 | * source CODE https://github.com/Justson/AgentWebX5 8 | */ 9 | 10 | public interface LayoutParamsOffer { 11 | 12 | T offerLayoutParams(); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/LoaderImpl.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.os.Handler; 4 | import android.os.Looper; 5 | 6 | import com.tencent.smtt.sdk.WebView; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * Created by cenxiaozhong on 2017/6/3. 12 | * source CODE https://github.com/Justson/AgentWebX5 13 | */ 14 | 15 | public class LoaderImpl implements ILoader { 16 | 17 | 18 | private Handler mHandler = null; 19 | private WebView mWebView; 20 | 21 | private Map headers = null; 22 | 23 | LoaderImpl(WebView webView, Map map) { 24 | this.mWebView = webView; 25 | if (this.mWebView == null) 26 | new NullPointerException("webview is null"); 27 | 28 | this.headers = map; 29 | mHandler = new Handler(Looper.getMainLooper()); 30 | } 31 | 32 | private void safeLoadUrl(final String url) { 33 | 34 | mHandler.post(new Runnable() { 35 | @Override 36 | public void run() { 37 | loadUrl(url); 38 | } 39 | }); 40 | } 41 | 42 | private void safeReload() { 43 | 44 | mHandler.post(new Runnable() { 45 | @Override 46 | public void run() { 47 | reload(); 48 | } 49 | }); 50 | } 51 | 52 | @Override 53 | public void loadUrl(String url) { 54 | 55 | 56 | if (!AgentWebX5Utils.isUIThread()) { 57 | safeLoadUrl(url); 58 | return; 59 | } 60 | //|| ((!url.startsWith("http")&&(!url.startsWith("javascript:")))) 61 | /*if (TextUtils.isEmpty(url)) 62 | throw new UrlCommonException("url is null or '' or not startsWith http ,javascript , file , please check url format");*/ 63 | 64 | if (!AgentWebX5Utils.isEmptyMap(this.headers)) 65 | this.mWebView.loadUrl(url, headers); 66 | else 67 | this.mWebView.loadUrl(url); 68 | } 69 | 70 | @Override 71 | public void reload() { 72 | if (!AgentWebX5Utils.isUIThread()) { 73 | mHandler.post(new Runnable() { 74 | @Override 75 | public void run() { 76 | reload(); 77 | } 78 | }); 79 | return; 80 | } 81 | this.mWebView.reload(); 82 | 83 | 84 | } 85 | 86 | @Override 87 | public void loadData(final String data, final String mimeType, final String encoding) { 88 | 89 | if (!AgentWebX5Utils.isUIThread()) { 90 | mHandler.post(new Runnable() { 91 | @Override 92 | public void run() { 93 | loadData(data, mimeType, encoding); 94 | } 95 | }); 96 | return; 97 | } 98 | this.mWebView.loadData(data, mimeType, encoding); 99 | 100 | } 101 | 102 | @Override 103 | public void stopLoading() { 104 | 105 | if (!AgentWebX5Utils.isUIThread()) { 106 | mHandler.post(new Runnable() { 107 | @Override 108 | public void run() { 109 | stopLoading(); 110 | } 111 | }); 112 | return; 113 | } 114 | this.mWebView.stopLoading(); 115 | 116 | } 117 | 118 | @Override 119 | public void loadDataWithBaseURL(final String baseUrl, final String data, final String mimeType, final String encoding, final String historyUrl) { 120 | 121 | if (!AgentWebX5Utils.isUIThread()) { 122 | mHandler.post(new Runnable() { 123 | @Override 124 | public void run() { 125 | loadDataWithBaseURL(baseUrl, data, mimeType, encoding, historyUrl); 126 | } 127 | }); 128 | return; 129 | } 130 | this.mWebView.loadDataWithBaseURL(baseUrl, data, mimeType, encoding, historyUrl); 131 | 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/LogUtils.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.util.Log; 4 | 5 | /** 6 | * Created by cenxiaozhong on 2017/5/28. 7 | */ 8 | 9 | public class LogUtils { 10 | 11 | private static final String PREFIX = " agentwebX5 ---> "; // 12 | 13 | public static boolean isDebug() { 14 | return AgentWebX5Config.DEBUG; 15 | } 16 | 17 | public static void i(String tag, String message) { 18 | 19 | if (isDebug()) 20 | Log.i(PREFIX.concat(tag), message); 21 | } 22 | 23 | public static void v(String tag, String message) { 24 | 25 | if (isDebug()) 26 | Log.v(PREFIX.concat(tag), message); 27 | 28 | } 29 | 30 | public static void safeCheckCrash(String tag, String msg, Throwable tr) { 31 | if (isDebug()) { 32 | throw new RuntimeException(PREFIX.concat(tag) + " " + msg, tr); 33 | } else { 34 | Log.e(PREFIX.concat(tag), msg, tr); 35 | } 36 | } 37 | 38 | public static void e(String tag, String msg, Throwable tr) { 39 | Log.e(tag, msg, tr); 40 | } 41 | 42 | public static void e(String tag, String message) { 43 | 44 | if (BuildConfig.DEBUG) 45 | Log.e(PREFIX.concat(tag), message); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/MiddleWareWebChromeBase.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | 4 | import com.tencent.smtt.sdk.WebChromeClient; 5 | 6 | /** 7 | * Created by cenxiaozhong on 2017/12/16. 8 | * https://github.com/Justson/AgentWebX5 9 | */ 10 | 11 | public class MiddleWareWebChromeBase extends WebChromeClientWrapper { 12 | 13 | private MiddleWareWebChromeBase mMiddleWareWebChromeBase; 14 | 15 | public MiddleWareWebChromeBase(WebChromeClient webChromeClient) { 16 | super(webChromeClient); 17 | } 18 | 19 | public MiddleWareWebChromeBase(){ 20 | super(null); 21 | } 22 | @Override 23 | final void setWebChromeClient(WebChromeClient webChromeClient) { 24 | super.setWebChromeClient(webChromeClient); 25 | } 26 | 27 | public MiddleWareWebChromeBase enq(MiddleWareWebChromeBase middleWareWebChromeBase) { 28 | setWebChromeClient(middleWareWebChromeBase); 29 | this.mMiddleWareWebChromeBase = middleWareWebChromeBase; 30 | return this.mMiddleWareWebChromeBase; 31 | } 32 | 33 | 34 | public MiddleWareWebChromeBase next() { 35 | return this.mMiddleWareWebChromeBase; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/MiddleWareWebClientBase.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | 4 | import com.tencent.smtt.sdk.WebViewClient; 5 | 6 | /** 7 | * Created by cenxiaozhong on 2017/12/15. 8 | * https://github.com/Justson/AgentWebX5 9 | */ 10 | 11 | public class MiddleWareWebClientBase extends WrapperWebViewClient { 12 | private MiddleWareWebClientBase mMiddleWrareWebClientBase; 13 | private String TAG = this.getClass().getSimpleName(); 14 | 15 | MiddleWareWebClientBase(MiddleWareWebClientBase client) { 16 | super(client); 17 | this.mMiddleWrareWebClientBase = client; 18 | } 19 | 20 | MiddleWareWebClientBase(WebViewClient client) { 21 | super(client); 22 | } 23 | public MiddleWareWebClientBase(){ 24 | super(null); 25 | } 26 | 27 | MiddleWareWebClientBase next() { 28 | LogUtils.i(TAG, "next"); 29 | return this.mMiddleWrareWebClientBase; 30 | } 31 | 32 | 33 | @Override 34 | final void setWebViewClient(WebViewClient webViewClient) { 35 | super.setWebViewClient(webViewClient); 36 | 37 | } 38 | MiddleWareWebClientBase enq(MiddleWareWebClientBase middleWrareWebClientBase){ 39 | setWebViewClient(middleWrareWebClientBase); 40 | this.mMiddleWrareWebClientBase = middleWrareWebClientBase; 41 | return middleWrareWebClientBase; 42 | } 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/Notify.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.app.Activity; 4 | import android.app.Notification; 5 | import android.app.NotificationManager; 6 | import android.app.PendingIntent; 7 | import android.content.Context; 8 | import android.os.SystemClock; 9 | import android.support.v4.app.NotificationCompat; 10 | 11 | /** 12 | * Created by cenxiaozhong on 2017/5/13. 13 | */ 14 | 15 | public class Notify { 16 | 17 | private static final int FLAG = Notification.FLAG_INSISTENT; 18 | int requestCode = (int) SystemClock.uptimeMillis(); 19 | private int NOTIFICATION_ID; 20 | private NotificationManager nm; 21 | private Notification notification; 22 | private NotificationCompat.Builder cBuilder; 23 | private Notification.Builder nBuilder; 24 | private Context mContext; 25 | 26 | public Notify(Context context, int ID) { 27 | this.NOTIFICATION_ID = ID; 28 | mContext = context; 29 | // 获取系统服务来初始化对象 30 | nm = (NotificationManager) mContext 31 | .getSystemService(Activity.NOTIFICATION_SERVICE); 32 | cBuilder = new NotificationCompat.Builder(mContext); 33 | } 34 | 35 | 36 | public void notify_progress(PendingIntent pendingIntent, int smallIcon, 37 | String ticker, String title, String content, boolean sound, boolean vibrate, boolean lights, PendingIntent pendingIntentCancel) { 38 | 39 | setCompatBuilder(pendingIntent, smallIcon, ticker, title, content, sound, vibrate, lights, pendingIntentCancel); 40 | 41 | } 42 | 43 | /** 44 | * 设置在顶部通知栏中的各种信息 45 | * 46 | * @param pendingIntent 47 | * @param smallIcon 48 | * @param ticker 49 | * @param pendingIntentCancel 50 | */ 51 | private void setCompatBuilder(PendingIntent pendingIntent, int smallIcon, String ticker, 52 | String title, String content, boolean sound, boolean vibrate, boolean lights, PendingIntent pendingIntentCancel) { 53 | // // 如果当前Activity启动在前台,则不开启新的Activity。 54 | // intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); 55 | // // 当设置下面PendingIntent.FLAG_UPDATE_CURRENT这个参数的时候,常常使得点击通知栏没效果,你需要给notification设置一个独一无二的requestCode 56 | // // 将Intent封装进PendingIntent中,点击通知的消息后,就会启动对应的程序 57 | // PendingIntent pIntent = PendingIntent.getActivity(mContext, 58 | // requestCode, intent, FLAG); 59 | 60 | cBuilder.setContentIntent(pendingIntent);// 该通知要启动的Intent 61 | cBuilder.setSmallIcon(smallIcon);// 设置顶部状态栏的小图标 62 | cBuilder.setTicker(ticker);// 在顶部状态栏中的提示信息 63 | 64 | cBuilder.setContentTitle(title);// 设置通知中心的标题 65 | cBuilder.setContentText(content);// 设置通知中心中的内容 66 | cBuilder.setWhen(System.currentTimeMillis()); 67 | 68 | /* 69 | * 将AutoCancel设为true后,当你点击通知栏的notification后,它会自动被取消消失, 70 | * 不设置的话点击消息后也不清除,但可以滑动删除 71 | */ 72 | cBuilder.setAutoCancel(true); 73 | // 将Ongoing设为true 那么notification将不能滑动删除 74 | // notifyBuilder.setOngoing(true); 75 | /* 76 | * 从Android4.1开始,可以通过以下方法,设置notification的优先级, 77 | * 优先级越高的,通知排的越靠前,优先级低的,不会在手机最顶部的状态栏显示图标 78 | */ 79 | cBuilder.setPriority(NotificationCompat.PRIORITY_MAX); 80 | /* 81 | * Notification.DEFAULT_ALL:铃声、闪光、震动均系统默认。 82 | * Notification.DEFAULT_SOUND:系统默认铃声。 83 | * Notification.DEFAULT_VIBRATE:系统默认震动。 84 | * Notification.DEFAULT_LIGHTS:系统默认闪光。 85 | * notifyBuilder.setDefaults(Notification.DEFAULT_ALL); 86 | */ 87 | int defaults = 0; 88 | 89 | cBuilder.setDeleteIntent(pendingIntentCancel); 90 | 91 | 92 | if (sound) { 93 | defaults |= Notification.DEFAULT_SOUND; 94 | } 95 | if (vibrate) { 96 | defaults |= Notification.DEFAULT_VIBRATE; 97 | } 98 | if (lights) { 99 | defaults |= Notification.DEFAULT_LIGHTS; 100 | } 101 | 102 | 103 | cBuilder.setDefaults(defaults); 104 | } 105 | 106 | public void setProgress(int maxprogress, int currentprogress, boolean exc) { 107 | cBuilder.setProgress(maxprogress, currentprogress, exc); 108 | sent(); 109 | } 110 | 111 | public void setContentText(String text) { 112 | 113 | cBuilder.setContentText(text); 114 | } 115 | 116 | public boolean hasDeleteContent() { 117 | return cBuilder.build().deleteIntent != null; 118 | } 119 | 120 | public void setDelecte(PendingIntent intent) { 121 | cBuilder.mNotification.deleteIntent = intent; 122 | } 123 | 124 | public void setProgressFinish(String content, PendingIntent pendingIntent) { 125 | cBuilder.setContentText(content); 126 | cBuilder.setProgress(100, 100, false); 127 | cBuilder.setContentIntent(pendingIntent); 128 | sent(); 129 | } 130 | 131 | /** 132 | * 发送通知 133 | */ 134 | void sent() { 135 | 136 | 137 | try { 138 | notification = cBuilder.build(); 139 | //LogUtils.i("Info","send:"+NOTIFICATION_ID+" nocation:"+notification+" "); 140 | // 发送该通知 141 | nm.notify(NOTIFICATION_ID, notification); 142 | } catch (Throwable throwable) { 143 | throwable.printStackTrace(); 144 | } 145 | 146 | 147 | } 148 | 149 | 150 | /** 151 | * 根据id清除通知 152 | */ 153 | public void clear() { 154 | // 取消通知 155 | nm.cancelAll(); 156 | 157 | 158 | } 159 | 160 | public void cancel(int id) { 161 | nm.cancel(id); 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/PermissionInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | /** 4 | * Created by cenxiaozhong on 2017/8/17. 5 | */ 6 | 7 | public interface PermissionInterceptor { 8 | 9 | boolean intercept(String url, String[] permissions, String action); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/ProgressLifeCyclic.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | /** 4 | * @项目名: agentwebX5 5 | * @包名:com.just.library 6 | * @创建者: cxz -- just 7 | * @创建时间: &{DATE} 8 | * @公司: 9 | * @邮箱: cenxiaozhong.qqcom@qq.com 10 | * @描述source code https://github.com/Justson/AgentWebX5 11 | */ 12 | 13 | public interface ProgressLifeCyclic { 14 | 15 | void showProgressBar(); 16 | 17 | void setProgressBar(int newProgress); 18 | 19 | void finish(); 20 | } 21 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/ProgressManager.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | /** 4 | * @项目名: agentwebX5 5 | * @包名:com.just.library 6 | * @创建者: cxz -- just 7 | * @创建时间: &{DATE} 8 | * @公司: 9 | * @邮箱: cenxiaozhong.qqcom@qq.com 10 | * @描述source code https://github.com/Justson/AgentWebX5 11 | */ 12 | 13 | public interface ProgressManager { 14 | 15 | 16 | T offer(); 17 | } 18 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/ProgressSpec.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | /** 4 | * @项目名: agentwebX5 5 | * @包名:com.just.library 6 | * @创建者: cxz -- just 7 | * @创建时间: &{DATE} 8 | * @公司: 9 | * @邮箱: cenxiaozhong.qqcom@qq.com 10 | * @描述source code https://github.com/Justson/AgentWebX5 11 | */ 12 | 13 | public interface ProgressSpec { 14 | 15 | 16 | void reset(); 17 | 18 | void setProgress(int newProgress); 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/Provider.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | /** 4 | * Created by cenxiaozhong on 2017/7/5. 5 | */ 6 | 7 | public interface Provider { 8 | 9 | 10 | T provide(); 11 | } 12 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/QuickCallJs.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.os.Build; 4 | import android.support.annotation.RequiresApi; 5 | import android.webkit.ValueCallback; 6 | 7 | /** 8 | * Created by cenxiaozhong on 2017/5/29. 9 | * source code https://github.com/Justson/AgentWebX5 10 | */ 11 | 12 | public interface QuickCallJs { 13 | @RequiresApi(Build.VERSION_CODES.KITKAT) 14 | void quickCallJs(String method, ValueCallback callback, String... params); 15 | void quickCallJs(String method, String... params); 16 | void quickCallJs(String method); 17 | } 18 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/UrlCommonException.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | /** 4 | * @项目名: agentwebX5 5 | * @包名:com.just.library 6 | * @创建者: cxz -- just 7 | * @创建时间: &{DATE} 8 | * @公司: 9 | * @邮箱: cenxiaozhong.qqcom@qq.com 10 | * @描述:source CODE https://github.com/Justson/AgentWebX5 11 | */ 12 | 13 | public class UrlCommonException extends RuntimeException { 14 | public UrlCommonException() { 15 | 16 | } 17 | 18 | public UrlCommonException(String msg) { 19 | super(msg); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/VideoImpl.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.app.Activity; 4 | import android.content.pm.ActivityInfo; 5 | import android.graphics.Color; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.FrameLayout; 9 | 10 | import com.tencent.smtt.export.external.interfaces.IX5WebChromeClient; 11 | import com.tencent.smtt.sdk.WebView; 12 | 13 | 14 | /** 15 | * Created by cenxiaozhong on 2017/6/10. 16 | * source code https://github.com/Justson/AgentWebX5 17 | */ 18 | 19 | public class VideoImpl implements IVideo, EventInterceptor { 20 | 21 | 22 | private Activity mActivity; 23 | private WebView mWebView; 24 | 25 | public VideoImpl(Activity mActivity, WebView webView) { 26 | this.mActivity = mActivity; 27 | this.mWebView = webView; 28 | 29 | } 30 | 31 | private View moiveView = null; 32 | private ViewGroup moiveParentView = null; 33 | private IX5WebChromeClient.CustomViewCallback mCallback; 34 | @Override 35 | public void onShowCustomView(View view, IX5WebChromeClient.CustomViewCallback callback) { 36 | 37 | LogUtils.i("Info", "onShowCustomView:" + view); 38 | 39 | Activity mActivity; 40 | if ((mActivity = this.mActivity) == null) 41 | return; 42 | mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); 43 | 44 | if (moiveView != null){ 45 | callback.onCustomViewHidden(); 46 | return; 47 | } 48 | 49 | if (mWebView != null) 50 | mWebView.setVisibility(View.GONE); 51 | 52 | if (moiveParentView == null) { 53 | FrameLayout mDecorView = (FrameLayout) mActivity.getWindow().getDecorView(); 54 | moiveParentView = new FrameLayout(mActivity); 55 | moiveParentView.setBackgroundColor(Color.BLACK); 56 | mDecorView.addView(moiveParentView); 57 | } 58 | this.mCallback=callback; 59 | moiveParentView.addView(this.moiveView = view); 60 | 61 | 62 | moiveParentView.setVisibility(View.VISIBLE); 63 | 64 | 65 | 66 | 67 | 68 | 69 | } 70 | 71 | @Override 72 | public void onHideCustomView() { 73 | 74 | LogUtils.i("Info", "onHideCustomView:" + moiveView); 75 | if (moiveView == null) 76 | return; 77 | if (mActivity!=null&&mActivity.getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) 78 | mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 79 | 80 | moiveView.setVisibility(View.GONE); 81 | if (moiveParentView != null && moiveView != null) { 82 | moiveParentView.removeView(moiveView); 83 | 84 | } 85 | if (moiveParentView != null) 86 | moiveParentView.setVisibility(View.GONE); 87 | 88 | if(this.mCallback!=null) 89 | mCallback.onCustomViewHidden(); 90 | this.moiveView = null; 91 | if (mWebView != null) 92 | mWebView.setVisibility(View.VISIBLE); 93 | 94 | 95 | 96 | } 97 | 98 | @Override 99 | public boolean isVideoState() { 100 | return moiveView != null; 101 | } 102 | 103 | @Override 104 | public boolean event() { 105 | 106 | LogUtils.i("Info", "event:" + isVideoState()); 107 | if (isVideoState()) { 108 | onHideCustomView(); 109 | return true; 110 | } else { 111 | return false; 112 | } 113 | 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/WebCreator.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.view.ViewGroup; 4 | 5 | /** 6 | * @项目名: agentwebX5 7 | * @包名:com.just.library 8 | * @创建者: cxz -- just 9 | * @创建时间: &{DATE} 10 | * @公司: 11 | * @邮箱: cenxiaozhong.qqcom@qq.com 12 | * @描述:source CODE https://github.com/Justson/AgentWebX5 13 | */ 14 | 15 | public interface WebCreator extends ProgressManager { 16 | WebCreator create(); 17 | 18 | com.tencent.smtt.sdk.WebView get(); 19 | 20 | ViewGroup getGroup(); 21 | } 22 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/WebLifeCycle.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | /** 4 | * Created by cenxiaozhong on 2017/5/30. 5 | * source code https://github.com/Justson/AgentWebX5 6 | */ 7 | 8 | public interface WebLifeCycle { 9 | 10 | 11 | void onResume(); 12 | void onPause(); 13 | void onDestroy(); 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/WebListenerManager.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | 4 | import com.tencent.smtt.sdk.DownloadListener; 5 | import com.tencent.smtt.sdk.WebChromeClient; 6 | import com.tencent.smtt.sdk.WebView; 7 | import com.tencent.smtt.sdk.WebViewClient; 8 | 9 | /** 10 | * Created by cenxiaozhong on 2017/5/13. 11 | * source CODE https://github.com/Justson/AgentWebX5 12 | */ 13 | 14 | public interface WebListenerManager { 15 | 16 | 17 | WebListenerManager setWebChromeClient(WebView webview, WebChromeClient webChromeClient); 18 | WebListenerManager setWebViewClient(WebView webView, WebViewClient webViewClient); 19 | WebListenerManager setDownLoader(WebView webView, DownloadListener downloadListener); 20 | 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/WebSecurityCheckLogic.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.support.v4.util.ArrayMap; 4 | 5 | import com.tencent.smtt.sdk.WebView; 6 | 7 | 8 | /** 9 | * @项目名: 10 | * @包名: 11 | * @创建者: cxz -- just 12 | * @创建时间: &{DATE} 13 | * @公司: 14 | * @邮箱: cenxiaozhong.qqcom@qq.com 15 | * @描述 16 | * source code https://github.com/Justson/AgentWebX5 17 | * 18 | */ 19 | 20 | public interface WebSecurityCheckLogic { 21 | void dealHoneyComb(WebView view); 22 | 23 | void dealJsInterface(ArrayMap objects, AgentWebX5.SecurityType securityType); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/WebSecurityController.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | /** 4 | * @项目名: AgentWebX5 5 | * @包名: 6 | * @创建者: cxz -- just 7 | * @创建时间: &{DATE} 8 | * @公司: 9 | * @邮箱: cenxiaozhong.qqcom@qq.com 10 | * @描述source code https://github.com/Justson/AgentWebX5 11 | */ 12 | 13 | public interface WebSecurityController { 14 | 15 | void check(T t); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/WebSecurityControllerImpl.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.os.Build; 4 | import android.support.v4.util.ArrayMap; 5 | 6 | import com.tencent.smtt.sdk.WebView; 7 | 8 | 9 | /** 10 | */ 11 | 12 | public class WebSecurityControllerImpl implements WebSecurityController { 13 | 14 | private WebView mWebView; 15 | private ArrayMap mMap; 16 | private AgentWebX5.SecurityType mSecurityType; 17 | 18 | public WebSecurityControllerImpl(WebView view, ArrayMap map, AgentWebX5.SecurityType securityType) { 19 | this.mWebView = view; 20 | this.mMap = map; 21 | this.mSecurityType=securityType; 22 | } 23 | 24 | @Override 25 | public void check(WebSecurityCheckLogic webSecurityCheckLogic) { 26 | 27 | if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) { 28 | webSecurityCheckLogic.dealHoneyComb(mWebView); 29 | } 30 | 31 | if (mMap != null &&mSecurityType== AgentWebX5.SecurityType.strict&& !mMap.isEmpty()) { 32 | webSecurityCheckLogic.dealJsInterface(mMap,mSecurityType); 33 | } 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/WebSecurityLogicImpl.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.annotation.TargetApi; 4 | import android.os.Build; 5 | import android.support.v4.util.ArrayMap; 6 | 7 | import com.tencent.smtt.sdk.WebView; 8 | 9 | 10 | /** 11 | * @项目名: 12 | * @包名: 13 | * @创建者: cxz -- just 14 | * @创建时间: &{DATE} 15 | * @公司: 16 | * @邮箱: cenxiaozhong.qqcom@qq.com 17 | * @描述source code https://github.com/Justson/AgentWebX5 18 | */ 19 | 20 | public class WebSecurityLogicImpl implements WebSecurityCheckLogic { 21 | public static WebSecurityLogicImpl getInstance() { 22 | return new WebSecurityLogicImpl(); 23 | } 24 | 25 | public WebSecurityLogicImpl(){} 26 | 27 | @TargetApi(Build.VERSION_CODES.HONEYCOMB) 28 | @Override 29 | public void dealHoneyComb(WebView view) { 30 | if (Build.VERSION_CODES.HONEYCOMB > Build.VERSION.SDK_INT || Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR1) 31 | return; 32 | view.removeJavascriptInterface("searchBoxJavaBridge_"); 33 | view.removeJavascriptInterface("accessibility"); 34 | view.removeJavascriptInterface("accessibilityTraversal"); 35 | } 36 | 37 | @Override 38 | public void dealJsInterface(ArrayMap objects,AgentWebX5.SecurityType securityType) { 39 | 40 | if (securityType== AgentWebX5.SecurityType.strict&& AgentWebX5Config.WEBVIEW_TYPE!= AgentWebX5Config.WEBVIEW_AGENTWEB_SAFE_TYPE&&Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { 41 | objects.clear(); 42 | objects = null; 43 | System.gc(); 44 | } 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/WebSettings.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | 4 | import com.tencent.smtt.sdk.WebView; 5 | 6 | 7 | public interface WebSettings { 8 | 9 | WebSettings toSetting(WebView webView); 10 | 11 | 12 | T getWebSettings(); 13 | 14 | 15 | 16 | 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /library/src/main/java/com/just/agentwebX5/WebViewClientCallbackManager.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import android.graphics.Bitmap; 4 | 5 | import com.tencent.smtt.sdk.WebView; 6 | 7 | 8 | /** 9 | * Created by cenxiaozhong on 2017/5/28. 10 | * source code https://github.com/Justson/AgentWebX5 11 | */ 12 | 13 | public class WebViewClientCallbackManager { 14 | 15 | 16 | private PageLifeCycleCallback mPageLifeCycleCallback; 17 | 18 | public PageLifeCycleCallback getPageLifeCycleCallback() { 19 | return mPageLifeCycleCallback; 20 | } 21 | 22 | public void setPageLifeCycleCallback(PageLifeCycleCallback pageLifeCycleCallback) { 23 | mPageLifeCycleCallback = pageLifeCycleCallback; 24 | } 25 | 26 | public interface PageLifeCycleCallback { 27 | 28 | void onPageStarted(WebView view, String url, Bitmap favicon); 29 | void onPageFinished(WebView view, String url); 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /library/src/main/res/mipmap-xxhdpi/download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/library/src/main/res/mipmap-xxhdpi/download.png -------------------------------------------------------------------------------- /library/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #000000 4 | #ffffff 5 | #2e2e32 6 | -------------------------------------------------------------------------------- /library/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | AgentWebX5 3 | 4 | -------------------------------------------------------------------------------- /library/src/main/res/values/style.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /library/src/main/res/xml/web_download_paths.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /library/src/test/java/com/just/agentwebX5/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebX5; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /sample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # For more information about using CMake with Android Studio, read the 2 | # documentation: https://d.android.com/studio/projects/add-native-code.html 3 | 4 | # Sets the minimum version of CMake required to build the native library. 5 | 6 | cmake_minimum_required(VERSION 3.4.1) 7 | 8 | # Creates and names a library, sets it as either STATIC 9 | # or SHARED, and provides the relative paths to its source code. 10 | # You can define multiple libraries, and CMake builds them for you. 11 | # Gradle automatically packages shared libraries with your APK. 12 | 13 | add_library( # Sets the name of the library. 14 | native-lib 15 | 16 | # Sets the library as a shared library. 17 | SHARED 18 | 19 | # Provides a relative path to your source file(s). 20 | src/main/cpp/native-lib.cpp ) 21 | 22 | # Searches for a specified prebuilt library and stores the path as a 23 | # variable. Because CMake includes system libraries in the search path by 24 | # default, you only need to specify the name of the public NDK library 25 | # you want to add. CMake verifies that the library exists before 26 | # completing its build. 27 | 28 | find_library( # Sets the name of the path variable. 29 | log-lib 30 | 31 | # Specifies the name of the NDK library that 32 | # you want CMake to locate. 33 | log ) 34 | 35 | # Specifies libraries CMake should link to your target library. You 36 | # can link multiple libraries, such as libraries you define in this 37 | # build script, prebuilt third-party libraries, or system libraries. 38 | 39 | target_link_libraries( # Specifies the target library. 40 | native-lib 41 | 42 | # Links the target library to the log library 43 | # included in the NDK. 44 | ${log-lib} ) -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | defaultConfig { 7 | applicationId "com.just.agentwebx5_sample" 8 | minSdkVersion 14 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | externalNativeBuild { 14 | cmake { 15 | cppFlags "" 16 | } 17 | } 18 | ndk { 19 | abiFilters "armeabi", "armeabi-v7a", "x86", "mips" 20 | } 21 | } 22 | buildTypes { 23 | release { 24 | minifyEnabled false 25 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 26 | } 27 | } 28 | 29 | 30 | lintOptions{ 31 | abortOnError false 32 | } 33 | 34 | lintOptions{ 35 | abortOnError false; 36 | } 37 | 38 | 39 | } 40 | 41 | dependencies { 42 | compile fileTree(include: ['*.jar'], dir: 'libs') 43 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 44 | exclude group: 'com.android.support', module: 'support-annotations' 45 | }) 46 | compile 'com.android.support:appcompat-v7:25.2.0' 47 | compile 'com.android.support.constraint:constraint-layout:1.0.2' 48 | debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1' 49 | releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1' 50 | testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1' 51 | testCompile 'junit:junit:4.12' 52 | compile project(':library') 53 | compile project(':twlibrary') 54 | // compile 'com.lcodecorex:tkrefreshlayout:1.0.7' 55 | } 56 | -------------------------------------------------------------------------------- /sample/libs/alipaySdk-20170922.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/sample/libs/alipaySdk-20170922.jar -------------------------------------------------------------------------------- /sample/libs/tbs_sdk_thirdapp_v3.1.0.1034_43100_sharewithdownload_obfs_20170301_182143.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/sample/libs/tbs_sdk_thirdapp_v3.1.0.1034_43100_sharewithdownload_obfs_20170301_182143.jar -------------------------------------------------------------------------------- /sample/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/cenxiaozhong/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /sample/src/androidTest/java/com/just/agentwebx5/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebx5; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.just.agentwebx5", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 43 | 44 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /sample/src/main/assets/js_interaction/button.css: -------------------------------------------------------------------------------- 1 | 2 | .button { 3 | color: #666; 4 | background-color: #EEE; 5 | border-color: #EEE; 6 | font-weight: 300; 7 | font-size: 16px; 8 | font-family: "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; 9 | text-decoration: none; 10 | text-align: center; 11 | line-height: 40px; 12 | height: 40px; 13 | padding: 0 40px; 14 | margin: 0; 15 | display: inline-block; 16 | appearance: none; 17 | cursor: pointer; 18 | border: none; 19 | -webkit-box-sizing: border-box; 20 | -moz-box-sizing: border-box; 21 | box-sizing: border-box; 22 | -webkit-transition-property: all; 23 | transition-property: all; 24 | -webkit-transition-duration: .3s; 25 | transition-duration: .3s; 26 | /* 27 | * Disabled State 28 | * 29 | * The disabled state uses the class .disabled, is-disabled, 30 | * and the form attribute disabled="disabled". 31 | * The use of !important is only added because this is a state 32 | * that must be applied to all buttons when in a disabled state. 33 | */ } 34 | 35 | .button-glow { 36 | -webkit-animation-duration: 3s; 37 | animation-duration: 3s; 38 | -webkit-animation-iteration-count: infinite; 39 | animation-iteration-count: infinite; 40 | -webkit-animation-name: glowing; 41 | animation-name: glowing; } 42 | 43 | .button-rounded { 44 | border-radius: 4px; } 45 | 46 | /* 47 | * Base Colors 48 | * 49 | * Create colors for buttons 50 | * (.button-primary, .button-secondary, etc.) 51 | */ 52 | .button-primary, 53 | .button-primary-flat { 54 | background-color: #1B9AF7; 55 | border-color: #1B9AF7; 56 | color: #FFF; } 57 | 58 | /* 59 | * Border Buttons 60 | * 61 | * These buttons have no fill they only have a 62 | * border to define their hit target. 63 | */ 64 | .button-border, .button-border-thin, .button-border-thick { 65 | background: none; 66 | border-width: 2px; 67 | border-style: solid; 68 | line-height: 36px; } 69 | 70 | -------------------------------------------------------------------------------- /sample/src/main/assets/js_interaction/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /sample/src/main/assets/sms/sms.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 电话短信邮件 7 | 8 | 29 | 30 | 31 | 32 | 电话短信邮件跳转 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 50 | 电话 短信 邮件 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /sample/src/main/assets/upload_file/event.js: -------------------------------------------------------------------------------- 1 | // ---------- 事件绑定与删除绑定 ---------- // 2 | function bindEvent(element, eventName, func) { 3 | var events = element['the'+eventName]; //用于保存某个事件序列 4 | if(!events) { //如果不存在一个序列,则创建它,并加入HTML标记当中的onEvent = function(){}形式的绑定 5 | events = element['the'+eventName] = []; 6 | if (element['on'+eventName]) { events.push(element['on'+eventName]); } 7 | } 8 | 9 | //检测是否为重复绑定 10 | for(var i=0; i= events.length) { events.push(func); } 16 | 17 | // 重新定义这个事件的执行方式 18 | element['on'+eventName] = function(event) { 19 | event = event || (function() { //修复IE的事件对象 20 | var e = window.event; 21 | e.preventDefault = function() { e.returnValue = false; } 22 | e.stopPropagation = function() { e.cancelBubble = true; } 23 | //根据需要继续修复 24 | return e; 25 | })(); 26 | //顺序执行这些函数 27 | for(var i=0; i 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 上传身份证 13 | 14 | 15 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 请上传身份证 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 上传身份证 134 | 135 | 136 | 137 | 138 | 139 | 选择文件 140 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | -------------------------------------------------------------------------------- /sample/src/main/assets/upload_file/upload.css: -------------------------------------------------------------------------------- 1 | .file { 2 | position: relative; 3 | display: inline-block; 4 | background: #D0EEFF; 5 | border: 1px solid #99D3F5; 6 | border-radius: 4px; 7 | padding: 4px 12px; 8 | overflow: hidden; 9 | color: #1E88C7; 10 | text-decoration: none; 11 | text-indent: 0; 12 | line-height: 20px; 13 | } 14 | .file input { 15 | position: absolute; 16 | font-size: 100px; 17 | right: 0; 18 | top: 0; 19 | opacity: 0; 20 | } 21 | .file:hover { 22 | background: #AADFFD; 23 | border-color: #78C3F3; 24 | color: #004974; 25 | text-decoration: none; 26 | } 27 | -------------------------------------------------------------------------------- /sample/src/main/assets/upload_file/uploadfile.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 上传身份证 13 | 14 | 15 | 16 | 17 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 请上传身份证 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 上传身份证 117 | 118 | 选择文件 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /sample/src/main/cpp/native-lib.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern "C" 5 | JNIEXPORT jstring JNICALL 6 | Java_com_just_agentwebx5_MainActivity_stringFromJNI( 7 | JNIEnv *env, 8 | jobject /* this */) { 9 | std::string hello = "Hello from C++"; 10 | return env->NewStringUTF(hello.c_str()); 11 | } 12 | -------------------------------------------------------------------------------- /sample/src/main/java/com/just/agentwebx5_sample/AndroidInterface.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebx5_sample; 2 | 3 | import android.content.Context; 4 | import android.os.Handler; 5 | import android.os.Looper; 6 | import android.util.Log; 7 | import android.webkit.JavascriptInterface; 8 | import android.widget.Toast; 9 | 10 | import com.just.agentwebX5.AgentWebX5; 11 | 12 | 13 | /** 14 | * Created by cenxiaozhong on 2017/5/14. 15 | */ 16 | 17 | public class AndroidInterface { 18 | 19 | 20 | private AgentWebX5 agent; 21 | private Context context; 22 | 23 | public AndroidInterface(AgentWebX5 agent, Context context) { 24 | this.agent = agent; 25 | this.context = context; 26 | } 27 | 28 | private Handler deliver = new Handler(Looper.getMainLooper()); 29 | 30 | @JavascriptInterface 31 | public void callAndroid(final String msg) { 32 | 33 | 34 | deliver.post(new Runnable() { 35 | @Override 36 | public void run() { 37 | 38 | Log.i("Info", "main Thread:" + Thread.currentThread()); 39 | Toast.makeText(context.getApplicationContext(), "" + msg, Toast.LENGTH_LONG).show(); 40 | } 41 | }); 42 | 43 | 44 | Log.i("Info", "Thread:" + Thread.currentThread()); 45 | 46 | //对外接口 47 | 48 | 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /sample/src/main/java/com/just/agentwebx5_sample/App.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebx5_sample; 2 | 3 | import android.app.Application; 4 | import android.util.Log; 5 | 6 | import com.squareup.leakcanary.LeakCanary; 7 | import com.tencent.smtt.sdk.QbSdk; 8 | 9 | /** 10 | * Created by cenxiaozhong on 2017/5/23. 11 | */ 12 | 13 | public class App extends Application { 14 | 15 | @Override 16 | public void onCreate() { 17 | super.onCreate(); 18 | 19 | if (LeakCanary.isInAnalyzerProcess(this)) { 20 | // This process is dedicated to LeakCanary for heap analysis. 21 | // You should not init your app in this process. 22 | return; 23 | } 24 | LeakCanary.install(this); 25 | // Normal app init code... 26 | 27 | 28 | 29 | QbSdk.PreInitCallback cb = new QbSdk.PreInitCallback() { 30 | 31 | @Override 32 | public void onViewInitFinished(boolean arg0) { 33 | // TODO Auto-generated method stub 34 | //x5內核初始化完成的回调,为true表示x5内核加载成功,否则表示x5内核加载失败,会自动切换到系统内核。 35 | Log.d("app", " onViewInitFinished is " + arg0); 36 | 37 | 38 | } 39 | 40 | @Override 41 | public void onCoreInitFinished() { 42 | // TODO Auto-generated method stub 43 | } 44 | }; 45 | //x5内核初始化接口 46 | QbSdk.initX5Environment(getApplicationContext(), cb); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /sample/src/main/java/com/just/agentwebx5_sample/CommonIndicator.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebx5_sample; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.Nullable; 5 | import android.util.AttributeSet; 6 | import android.view.View; 7 | import android.widget.FrameLayout; 8 | 9 | import com.just.agentwebX5.BaseIndicatorView; 10 | 11 | 12 | /** 13 | * Created by cenxiaozhong on 2017/5/26. 14 | */ 15 | 16 | public class CommonIndicator extends BaseIndicatorView { 17 | public CommonIndicator(Context context) { 18 | super(context); 19 | } 20 | 21 | public CommonIndicator(Context context, @Nullable AttributeSet attrs) { 22 | super(context, attrs); 23 | } 24 | 25 | public CommonIndicator(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { 26 | super(context, attrs, defStyleAttr); 27 | } 28 | 29 | 30 | @Override 31 | public void show() { 32 | this.setVisibility(View.VISIBLE); 33 | } 34 | 35 | @Override 36 | public void hide() { 37 | this.setVisibility(View.GONE); 38 | } 39 | 40 | 41 | @Override 42 | public FrameLayout.LayoutParams offerLayoutParams() { 43 | return new FrameLayout.LayoutParams(-1,-1); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /sample/src/main/java/com/just/agentwebx5_sample/CustomIndicatorFragment.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebx5_sample; 2 | 3 | import android.os.Build; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.support.annotation.RequiresApi; 7 | import android.view.Gravity; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.widget.FrameLayout; 11 | import android.widget.LinearLayout; 12 | import android.widget.ProgressBar; 13 | 14 | import com.just.agentwebX5.AgentWebX5; 15 | import com.just.agentwebX5.WebDefaultSettingsManager; 16 | 17 | /** 18 | * Created by cenxiaozhong on 2017/5/26. 19 | */ 20 | 21 | public class CustomIndicatorFragment extends AgentWebX5Fragment { 22 | public static CustomIndicatorFragment getInstance(Bundle bundle){ 23 | CustomIndicatorFragment mCustomIndicatorFragment=new CustomIndicatorFragment(); 24 | if(bundle!=null) 25 | mCustomIndicatorFragment.setArguments(bundle); 26 | return mCustomIndicatorFragment; 27 | } 28 | 29 | @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) 30 | @Override 31 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 32 | 33 | CommonIndicator mCommonIndicator=new CommonIndicator(this.getActivity()); 34 | FrameLayout.LayoutParams lp=new FrameLayout.LayoutParams(-2,-2); 35 | lp.gravity= Gravity.CENTER; 36 | ProgressBar mProgressBar=new ProgressBar(this.getActivity()); 37 | mProgressBar.setBackground(this.getResources().getDrawable(R.drawable.indicator_shape)); 38 | mCommonIndicator.addView(mProgressBar,lp); 39 | 40 | this.mAgentWebX5 = AgentWebX5.with( this)// 41 | .setAgentWebParent((ViewGroup) view, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))// 42 | .setCustomIndicator(mCommonIndicator) 43 | .setWebSettings(WebDefaultSettingsManager.getInstance())// 44 | .setWebViewClient(mWebViewClient) 45 | .setReceivedTitleCallback(mCallback) 46 | .setSecurityType(AgentWebX5.SecurityType.strict) 47 | .createAgentWeb()// 48 | .ready()// 49 | .go(getUrl()); 50 | 51 | 52 | initView(view); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /sample/src/main/java/com/just/agentwebx5_sample/CustomSettings.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebx5_sample; 2 | 3 | 4 | import com.just.agentwebX5.WebDefaultSettingsManager; 5 | import com.just.agentwebX5.WebSettings; 6 | import com.tencent.smtt.sdk.WebView; 7 | 8 | /** 9 | * Created by cenxiaozhong on 2017/5/26. 10 | */ 11 | 12 | public class CustomSettings extends WebDefaultSettingsManager { 13 | protected CustomSettings() { 14 | super(); 15 | } 16 | 17 | 18 | @Override 19 | public WebSettings toSetting(WebView webView) { 20 | super.toSetting(webView); 21 | getWebSettings().setBlockNetworkImage(false);//是否阻塞加载网络图片 协议http or https 22 | getWebSettings().setAllowFileAccess(false); //允许加载本地文件html file协议, 这可能会造成不安全 , 建议重写关闭 23 | getWebSettings().setAllowFileAccessFromFileURLs(false); //通过 file url 加载的 Javascript 读取其他的本地文件 .建议关闭 24 | getWebSettings().setAllowUniversalAccessFromFileURLs(false);//允许通过 file url 加载的 Javascript 可以访问其他的源,包括其他的文件和 http,https 等其他的源 25 | return this; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /sample/src/main/java/com/just/agentwebx5_sample/CustomSettingsFragment.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebx5_sample; 2 | 3 | import android.os.Bundle; 4 | 5 | /** 6 | * Created by cenxiaozhong on 2017/5/26. 7 | */ 8 | 9 | public class CustomSettingsFragment extends AgentWebX5Fragment { 10 | 11 | public static AgentWebX5Fragment getInstance(Bundle bundle) { 12 | 13 | CustomSettingsFragment mCustomSettingsFragment = new CustomSettingsFragment(); 14 | if (bundle != null) 15 | mCustomSettingsFragment.setArguments(bundle); 16 | 17 | return mCustomSettingsFragment; 18 | 19 | } 20 | 21 | 22 | @Override 23 | public com.just.agentwebX5.WebSettings getSettings() { 24 | 25 | return new CustomSettings(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /sample/src/main/java/com/just/agentwebx5_sample/FragmentKeyDown.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebx5_sample; 2 | 3 | import android.view.KeyEvent; 4 | 5 | /** 6 | * Created by cenxiaozhong on 2017/5/23. 7 | */ 8 | 9 | public interface FragmentKeyDown { 10 | 11 | boolean onFragmentKeyDown(int keyCode, KeyEvent event); 12 | } 13 | -------------------------------------------------------------------------------- /sample/src/main/java/com/just/agentwebx5_sample/JsAgentWebFragment.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebx5_sample; 2 | 3 | import android.os.Build; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.support.annotation.RequiresApi; 7 | import android.util.Log; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.webkit.ValueCallback; 12 | import android.widget.LinearLayout; 13 | 14 | import org.json.JSONObject; 15 | 16 | /** 17 | * Created by cenxiaozhong on 2017/5/26. 18 | */ 19 | 20 | public class JsAgentWebFragment extends AgentWebX5Fragment { 21 | 22 | public static final JsAgentWebFragment getInstance(Bundle bundle) { 23 | 24 | JsAgentWebFragment mJsAgentWebFragment = new JsAgentWebFragment(); 25 | if (bundle != null) 26 | mJsAgentWebFragment.setArguments(bundle); 27 | 28 | return mJsAgentWebFragment; 29 | 30 | } 31 | 32 | @Nullable 33 | @Override 34 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 35 | return super.onCreateView(inflater, container, savedInstanceState); 36 | } 37 | 38 | @Override 39 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 40 | 41 | LinearLayout mLinearLayout= (LinearLayout) view; 42 | LayoutInflater.from(getContext()).inflate(R.layout.fragment_js,mLinearLayout,true); 43 | super.onViewCreated(view, savedInstanceState); 44 | 45 | 46 | Log.i("Info","add android:"+ mAgentWebX5); 47 | if(mAgentWebX5 !=null){ 48 | mAgentWebX5.getJsInterfaceHolder().addJavaObject("android",new AndroidInterface(mAgentWebX5,this.getActivity())); 49 | 50 | } 51 | // String p="\"hello\""+","+"\" js\""; 52 | // mAgentWebX5.getWebCreator().get().loadUrl("javascript:callByAndroid("+"\"hello\""+","+"\" js\""+")"); 53 | 54 | view.findViewById(R.id.one).setOnClickListener(mOnClickListener); 55 | view.findViewById(R.id.two).setOnClickListener(mOnClickListener); 56 | view.findViewById(R.id.three).setOnClickListener(mOnClickListener); 57 | view.findViewById(R.id.four).setOnClickListener(mOnClickListener); 58 | 59 | 60 | } 61 | 62 | private View.OnClickListener mOnClickListener=new View.OnClickListener() { 63 | @RequiresApi(api = Build.VERSION_CODES.KITKAT) 64 | @Override 65 | public void onClick(View v) { 66 | 67 | 68 | switch (v.getId()){ 69 | 70 | case R.id.one: 71 | mAgentWebX5.getJsEntraceAccess().quickCallJs("callByAndroid"); 72 | break; 73 | 74 | case R.id.two: 75 | mAgentWebX5.getJsEntraceAccess().quickCallJs("callByAndroidParam","Hello ! Agentweb"); 76 | break; 77 | 78 | case R.id.three: 79 | mAgentWebX5.getJsEntraceAccess().quickCallJs("callByAndroidMoreParams", new ValueCallback() { 80 | @Override 81 | public void onReceiveValue(String value) { 82 | Log.i("Info","value:"+value); 83 | } 84 | },getJson(),"say:", " Hello! Agentweb"); 85 | break; 86 | case R.id.four: 87 | mAgentWebX5.getJsEntraceAccess().quickCallJs("callByAndroidInteraction","你好Js"); 88 | break; 89 | } 90 | 91 | } 92 | }; 93 | 94 | private String getJson(){ 95 | 96 | String result=""; 97 | try { 98 | 99 | JSONObject mJSONObject=new JSONObject(); 100 | mJSONObject.put("id",1); 101 | mJSONObject.put("name","Agentweb"); 102 | mJSONObject.put("age",18); 103 | result= mJSONObject.toString(); 104 | }catch (Exception e){ 105 | 106 | } 107 | 108 | return result; 109 | } 110 | 111 | 112 | } 113 | -------------------------------------------------------------------------------- /sample/src/main/java/com/just/agentwebx5_sample/WebActivity.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebx5_sample; 2 | 3 | /** 4 | * Created by cenxiaozhong on 2017/5/22. 5 | */ 6 | 7 | public class WebActivity extends BaseWebActivity { 8 | 9 | @Override 10 | public String getUrl() { 11 | 12 | return super.getUrl(); 13 | } 14 | 15 | @Override 16 | protected void onStart() { 17 | 18 | 19 | 20 | 21 | super.onStart(); 22 | } 23 | 24 | @Override 25 | protected void onResume() { 26 | super.onResume(); 27 | 28 | //测试Cookies 29 | /*try { 30 | 31 | String targetUrl=""; 32 | Log.i("Info","cookies:"+ AgentWebX5Config.getCookiesByUrl(targetUrl="http://www.jd.com")); 33 | AgentWebX5Config.removeAllCookies(new ValueCallback() { 34 | @Override 35 | public void onReceiveValue(Boolean value) { 36 | Log.i("Info","onResume():"+value); 37 | } 38 | }); 39 | 40 | String tagInfo=AgentWebX5Config.getCookiesByUrl(targetUrl); 41 | Log.i("Info","tag:"+tagInfo); 42 | AgentWebX5Config.syncCookies("http://www.jd.com","ID=IDHl3NVU0N3ltZm9OWHhubHVQZW1BRThLdGhLaFc5TnVtQWd1S2g1REcwNVhTS3RXQVFBQEBFDA984906B62C444931EA0"); 43 | String tag=AgentWebX5Config.getCookiesByUrl(targetUrl); 44 | Log.i("Info","tag:"+tag); 45 | AgentWebX5Config.removeSessionCookies(); 46 | Log.i("Info","removeSessionCookies:"+AgentWebX5Config.getCookiesByUrl(targetUrl)); 47 | }catch (Exception e){ 48 | e.printStackTrace(); 49 | }*/ 50 | 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /sample/src/main/java/com/just/agentwebx5_sample/WebLayout.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebx5_sample; 2 | 3 | import android.app.Activity; 4 | import android.support.annotation.NonNull; 5 | import android.support.annotation.Nullable; 6 | import android.view.LayoutInflater; 7 | import android.view.ViewGroup; 8 | 9 | import com.just.agentwebX5.IWebLayout; 10 | import com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout; 11 | import com.tencent.smtt.sdk.WebView; 12 | 13 | /** 14 | * Created by cenxiaozhong on 2017/7/1. 15 | */ 16 | 17 | public class WebLayout implements IWebLayout { 18 | 19 | private Activity mActivity; 20 | private final TwinklingRefreshLayout mTwinklingRefreshLayout; 21 | private WebView mWebView = null; 22 | 23 | public WebLayout(Activity activity) { 24 | this.mActivity = activity; 25 | mTwinklingRefreshLayout = (TwinklingRefreshLayout) LayoutInflater.from(activity).inflate(R.layout.fragment_twk_web, null); 26 | mTwinklingRefreshLayout.setPureScrollModeOn(); 27 | mWebView = (WebView) mTwinklingRefreshLayout.findViewById(R.id.webView); 28 | } 29 | 30 | @NonNull 31 | @Override 32 | public ViewGroup getLayout() { 33 | return mTwinklingRefreshLayout; 34 | } 35 | 36 | @Nullable 37 | @Override 38 | public WebView getWeb() { 39 | return mWebView; 40 | } 41 | 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /sample/src/main/jniLibs/armeabi/liblbs.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/sample/src/main/jniLibs/armeabi/liblbs.so -------------------------------------------------------------------------------- /sample/src/main/res/drawable-v21/ripple_for_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable-v21/selector_drawable_for_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/btn_shape.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/btn_shape_s.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/indicator_shape.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/iv_back_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/selector_drawable_for_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_common.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 17 | 18 | 19 | 27 | 28 | 29 | 30 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_web.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 21 | 22 | 23 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/fragment_agentweb.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/fragment_js.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 20 | 21 | 32 | 44 | 45 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/fragment_twk_web.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 17 | 18 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/listview_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/markdown_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/toorbar_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 17 | 18 | 28 | 37 | 46 | 47 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/sample/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/sample/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/app_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/sample/src/main/res/mipmap-xhdpi/app_logo.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/sample/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/app_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/sample/src/main/res/mipmap-xxhdpi/app_logo.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/app_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/sample/src/main/res/mipmap-xxxhdpi/app_logo.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/sample/src/main/res/mipmap-xxxhdpi/back.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/cha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/sample/src/main/res/mipmap-xxxhdpi/cha.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #393a3f 4 | #303135 5 | #1aad19 6 | 7 | #1B9AF7 8 | #58b2f2 9 | 10 | #7b393a3f 11 | 12 | -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | AgentWebX5 3 | 4 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 14 | 18 | 19 | 25 | 26 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /sample/src/test/java/com/just/agentwebx5/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.just.agentwebx5; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':sample', ':library', ':twlibrary' 2 | -------------------------------------------------------------------------------- /twlibrary/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /twlibrary/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | 4 | android { 5 | compileSdkVersion 25 6 | buildToolsVersion '25.0.1' 7 | 8 | defaultConfig { 9 | minSdkVersion 14 10 | targetSdkVersion 25 11 | versionCode 7 12 | versionName "1.07" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | 21 | lintOptions { 22 | abortOnError false 23 | } 24 | } 25 | 26 | dependencies { 27 | provided fileTree(include: ['*.jar'], dir: 'libs') 28 | compile 'com.android.support:recyclerview-v7:25.2.0' 29 | compile 'com.android.support:support-v4:25.2.0' 30 | 31 | } 32 | -------------------------------------------------------------------------------- /twlibrary/libs/tbs_sdk_thirdapp_v3.1.0.1034_43100_sharewithdownload_obfs_20170301_182143.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/twlibrary/libs/tbs_sdk_thirdapp_v3.1.0.1034_43100_sharewithdownload_obfs_20170301_182143.jar -------------------------------------------------------------------------------- /twlibrary/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/lcodecore/Documents/android_sdk_macosx/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /twlibrary/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /twlibrary/src/main/java/com/lcodecore/tkrefreshlayout/Footer/LoadingView.java: -------------------------------------------------------------------------------- 1 | package com.lcodecore.tkrefreshlayout.Footer; 2 | 3 | import android.content.Context; 4 | import android.graphics.drawable.AnimationDrawable; 5 | import android.util.AttributeSet; 6 | import android.view.Gravity; 7 | import android.view.View; 8 | import android.widget.FrameLayout; 9 | import android.widget.ImageView; 10 | 11 | import com.lcodecore.tkrefreshlayout.IBottomView; 12 | import com.lcodecore.tkrefreshlayout.R; 13 | import com.lcodecore.tkrefreshlayout.utils.DensityUtil; 14 | 15 | /** 16 | * Created by lcodecore on 2016/10/3. 17 | */ 18 | 19 | public class LoadingView extends ImageView implements IBottomView { 20 | public LoadingView(Context context) { 21 | this(context, null); 22 | } 23 | 24 | public LoadingView(Context context, AttributeSet attrs) { 25 | this(context, attrs, 0); 26 | } 27 | 28 | public LoadingView(Context context, AttributeSet attrs, int defStyleAttr) { 29 | super(context, attrs, defStyleAttr); 30 | 31 | int size = DensityUtil.dp2px(context,34); 32 | FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(size,size); 33 | params.gravity = Gravity.CENTER; 34 | setLayoutParams(params); 35 | setImageResource(R.drawable.anim_loading_view); 36 | } 37 | 38 | @Override 39 | public View getView() { 40 | return this; 41 | } 42 | 43 | @Override 44 | public void onPullingUp(float fraction, float maxHeadHeight, float headHeight) { 45 | 46 | } 47 | 48 | @Override 49 | public void startAnim(float maxHeadHeight, float headHeight) { 50 | ((AnimationDrawable)getDrawable()).start(); 51 | } 52 | 53 | @Override 54 | public void onPullReleasing(float fraction, float maxHeadHeight, float headHeight) { 55 | 56 | } 57 | 58 | @Override 59 | public void onFinish() { 60 | 61 | } 62 | 63 | @Override 64 | public void reset() { 65 | 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /twlibrary/src/main/java/com/lcodecore/tkrefreshlayout/IBottomView.java: -------------------------------------------------------------------------------- 1 | package com.lcodecore.tkrefreshlayout; 2 | 3 | import android.view.View; 4 | 5 | /** 6 | * Created by lcodecore on 2016/10/1. 7 | */ 8 | 9 | public interface IBottomView { 10 | View getView(); 11 | 12 | /** 13 | * 上拉准备加载更多的动作 14 | * 15 | * @param fraction 上拉高度与Bottom总高度之比 16 | * @param maxBottomHeight 底部部可拉伸最大高度 17 | * @param bottomHeight 底部高度 18 | */ 19 | void onPullingUp(float fraction, float maxBottomHeight, float bottomHeight); 20 | 21 | void startAnim(float maxBottomHeight, float bottomHeight); 22 | 23 | /** 24 | * 上拉释放过程 25 | */ 26 | void onPullReleasing(float fraction, float maxBottomHeight, float bottomHeight); 27 | 28 | void onFinish(); 29 | 30 | void reset(); 31 | } 32 | -------------------------------------------------------------------------------- /twlibrary/src/main/java/com/lcodecore/tkrefreshlayout/IHeaderView.java: -------------------------------------------------------------------------------- 1 | package com.lcodecore.tkrefreshlayout; 2 | 3 | import android.view.View; 4 | 5 | /** 6 | * Created by lcodecore on 2016/10/1. 7 | */ 8 | 9 | public interface IHeaderView { 10 | View getView(); 11 | 12 | /** 13 | * 下拉准备刷新动作 14 | * 15 | * @param fraction 当前下拉高度与总高度的比 16 | * @param maxHeadHeight 17 | * @param headHeight 18 | */ 19 | void onPullingDown(float fraction, float maxHeadHeight, float headHeight); 20 | 21 | /** 22 | * 下拉释放过程 23 | * 24 | * @param fraction 25 | * @param maxHeadHeight 26 | * @param headHeight 27 | */ 28 | void onPullReleasing(float fraction, float maxHeadHeight, float headHeight); 29 | 30 | void startAnim(float maxHeadHeight, float headHeight); 31 | 32 | void onFinish(OnAnimEndListener animEndListener); 33 | 34 | /** 35 | * 用于在必要情况下复位View,清除动画 36 | */ 37 | void reset(); 38 | } 39 | -------------------------------------------------------------------------------- /twlibrary/src/main/java/com/lcodecore/tkrefreshlayout/OnAnimEndListener.java: -------------------------------------------------------------------------------- 1 | package com.lcodecore.tkrefreshlayout; 2 | 3 | /** 4 | * Created by lcodecore on 2016/11/26. 5 | */ 6 | 7 | public interface OnAnimEndListener { 8 | 9 | public void onAnimEnd(); 10 | } 11 | -------------------------------------------------------------------------------- /twlibrary/src/main/java/com/lcodecore/tkrefreshlayout/OnGestureListener.java: -------------------------------------------------------------------------------- 1 | package com.lcodecore.tkrefreshlayout; 2 | 3 | import android.view.MotionEvent; 4 | 5 | public interface OnGestureListener { 6 | void onDown(MotionEvent ev); 7 | 8 | void onScroll(MotionEvent downEvent, MotionEvent currentEvent, float distanceX, float distanceY); 9 | 10 | void onUp(MotionEvent ev, boolean isFling); 11 | 12 | void onFling(MotionEvent downEvent, MotionEvent upEvent, float velocityX, float velocityY); 13 | } -------------------------------------------------------------------------------- /twlibrary/src/main/java/com/lcodecore/tkrefreshlayout/PullListener.java: -------------------------------------------------------------------------------- 1 | package com.lcodecore.tkrefreshlayout; 2 | 3 | public interface PullListener { 4 | /** 5 | * 下拉中 6 | * 7 | * @param refreshLayout 8 | * @param fraction 9 | */ 10 | void onPullingDown(TwinklingRefreshLayout refreshLayout, float fraction); 11 | 12 | /** 13 | * 上拉 14 | */ 15 | void onPullingUp(TwinklingRefreshLayout refreshLayout, float fraction); 16 | 17 | /** 18 | * 下拉松开 19 | * 20 | * @param refreshLayout 21 | * @param fraction 22 | */ 23 | void onPullDownReleasing(TwinklingRefreshLayout refreshLayout, float fraction); 24 | 25 | /** 26 | * 上拉松开 27 | */ 28 | void onPullUpReleasing(TwinklingRefreshLayout refreshLayout, float fraction); 29 | 30 | /** 31 | * 刷新中。。。 32 | */ 33 | void onRefresh(TwinklingRefreshLayout refreshLayout); 34 | 35 | /** 36 | * 加载更多中 37 | */ 38 | void onLoadMore(TwinklingRefreshLayout refreshLayout); 39 | 40 | /** 41 | * 手动调用finishRefresh或者finishLoadmore之后的回调 42 | */ 43 | void onFinishRefresh(); 44 | 45 | void onFinishLoadMore(); 46 | 47 | /** 48 | * 正在刷新时向上滑动屏幕,刷新被取消 49 | */ 50 | void onRefreshCanceled(); 51 | 52 | /** 53 | * 正在加载更多时向下滑动屏幕,加载更多被取消 54 | */ 55 | void onLoadmoreCanceled(); 56 | } -------------------------------------------------------------------------------- /twlibrary/src/main/java/com/lcodecore/tkrefreshlayout/RefreshListenerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.lcodecore.tkrefreshlayout; 2 | 3 | public abstract class RefreshListenerAdapter implements PullListener { 4 | @Override 5 | public void onPullingDown(TwinklingRefreshLayout refreshLayout, float fraction) { 6 | } 7 | 8 | @Override 9 | public void onPullingUp(TwinklingRefreshLayout refreshLayout, float fraction) { 10 | } 11 | 12 | @Override 13 | public void onPullDownReleasing(TwinklingRefreshLayout refreshLayout, float fraction) { 14 | } 15 | 16 | @Override 17 | public void onPullUpReleasing(TwinklingRefreshLayout refreshLayout, float fraction) { 18 | } 19 | 20 | @Override 21 | public void onRefresh(TwinklingRefreshLayout refreshLayout) { 22 | } 23 | 24 | @Override 25 | public void onLoadMore(TwinklingRefreshLayout refreshLayout) { 26 | } 27 | 28 | @Override 29 | public void onFinishRefresh() { 30 | 31 | } 32 | 33 | @Override 34 | public void onFinishLoadMore() { 35 | 36 | } 37 | 38 | @Override 39 | public void onRefreshCanceled() { 40 | 41 | } 42 | 43 | @Override 44 | public void onLoadmoreCanceled() { 45 | 46 | } 47 | } -------------------------------------------------------------------------------- /twlibrary/src/main/java/com/lcodecore/tkrefreshlayout/header/SinaRefreshView.java: -------------------------------------------------------------------------------- 1 | package com.lcodecore.tkrefreshlayout.header; 2 | 3 | import android.content.Context; 4 | import android.graphics.drawable.AnimationDrawable; 5 | import android.support.annotation.ColorInt; 6 | import android.support.annotation.DrawableRes; 7 | import android.util.AttributeSet; 8 | import android.view.View; 9 | import android.widget.FrameLayout; 10 | import android.widget.ImageView; 11 | import android.widget.TextView; 12 | 13 | import com.lcodecore.tkrefreshlayout.IHeaderView; 14 | import com.lcodecore.tkrefreshlayout.OnAnimEndListener; 15 | import com.lcodecore.tkrefreshlayout.R; 16 | 17 | /** 18 | * Created by lcodecore on 2016/10/2. 19 | */ 20 | 21 | public class SinaRefreshView extends FrameLayout implements IHeaderView { 22 | 23 | private ImageView refreshArrow; 24 | private ImageView loadingView; 25 | private TextView refreshTextView; 26 | 27 | public SinaRefreshView(Context context) { 28 | this(context, null); 29 | } 30 | 31 | public SinaRefreshView(Context context, AttributeSet attrs) { 32 | this(context, attrs, 0); 33 | } 34 | 35 | public SinaRefreshView(Context context, AttributeSet attrs, int defStyleAttr) { 36 | super(context, attrs, defStyleAttr); 37 | init(); 38 | } 39 | 40 | private void init() { 41 | View rootView = View.inflate(getContext(), R.layout.view_sinaheader, null); 42 | refreshArrow = (ImageView) rootView.findViewById(R.id.iv_arrow); 43 | refreshTextView = (TextView) rootView.findViewById(R.id.tv); 44 | loadingView = (ImageView) rootView.findViewById(R.id.iv_loading); 45 | addView(rootView); 46 | } 47 | 48 | public void setArrowResource(@DrawableRes int resId) { 49 | refreshArrow.setImageResource(resId); 50 | } 51 | 52 | public void setTextColor(@ColorInt int color) { 53 | refreshTextView.setTextColor(color); 54 | } 55 | 56 | public void setPullDownStr(String pullDownStr1) { 57 | pullDownStr = pullDownStr1; 58 | } 59 | 60 | public void setReleaseRefreshStr(String releaseRefreshStr1) { 61 | releaseRefreshStr = releaseRefreshStr1; 62 | } 63 | 64 | public void setRefreshingStr(String refreshingStr1) { 65 | refreshingStr = refreshingStr1; 66 | } 67 | 68 | private String pullDownStr = "下拉刷新"; 69 | private String releaseRefreshStr = "释放刷新"; 70 | private String refreshingStr = "正在刷新"; 71 | 72 | @Override 73 | public View getView() { 74 | return this; 75 | } 76 | 77 | @Override 78 | public void onPullingDown(float fraction, float maxHeadHeight, float headHeight) { 79 | if (fraction < 1f) refreshTextView.setText(pullDownStr); 80 | if (fraction > 1f) refreshTextView.setText(releaseRefreshStr); 81 | refreshArrow.setRotation(fraction * headHeight / maxHeadHeight * 180); 82 | } 83 | 84 | @Override 85 | public void onPullReleasing(float fraction, float maxHeadHeight, float headHeight) { 86 | if (fraction < 1f) { 87 | refreshTextView.setText(pullDownStr); 88 | refreshArrow.setRotation(fraction * headHeight / maxHeadHeight * 180); 89 | if (refreshArrow.getVisibility() == GONE) { 90 | refreshArrow.setVisibility(VISIBLE); 91 | loadingView.setVisibility(GONE); 92 | } 93 | } 94 | } 95 | 96 | @Override 97 | public void startAnim(float maxHeadHeight, float headHeight) { 98 | refreshTextView.setText(refreshingStr); 99 | refreshArrow.setVisibility(GONE); 100 | loadingView.setVisibility(VISIBLE); 101 | ((AnimationDrawable) loadingView.getDrawable()).start(); 102 | } 103 | 104 | @Override 105 | public void onFinish(OnAnimEndListener listener) { 106 | listener.onAnimEnd(); 107 | } 108 | 109 | @Override 110 | public void reset() { 111 | refreshArrow.setVisibility(VISIBLE); 112 | loadingView.setVisibility(GONE); 113 | refreshTextView.setText(pullDownStr); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /twlibrary/src/main/java/com/lcodecore/tkrefreshlayout/header/bezierlayout/RippleView.java: -------------------------------------------------------------------------------- 1 | package com.lcodecore.tkrefreshlayout.header.bezierlayout; 2 | 3 | 4 | import android.animation.Animator; 5 | import android.animation.AnimatorListenerAdapter; 6 | import android.animation.ValueAnimator; 7 | import android.content.Context; 8 | import android.graphics.Canvas; 9 | import android.graphics.Paint; 10 | import android.support.annotation.ColorInt; 11 | import android.util.AttributeSet; 12 | import android.view.View; 13 | 14 | /** 15 | * cjj 16 | */ 17 | public class RippleView extends View { 18 | private Paint mPaint; 19 | private int r; 20 | private OnRippleEndListener listener; 21 | 22 | public int getR() { 23 | return r; 24 | } 25 | 26 | public void setR(int r) { 27 | this.r = r; 28 | } 29 | 30 | public RippleView(Context context) { 31 | this(context, null, 0); 32 | } 33 | 34 | public RippleView(Context context, AttributeSet attrs) { 35 | this(context, attrs, 0); 36 | } 37 | 38 | public RippleView(Context context, AttributeSet attrs, int defStyleAttr) { 39 | super(context, attrs, defStyleAttr); 40 | init(); 41 | } 42 | 43 | ValueAnimator va; 44 | 45 | private void init() { 46 | mPaint = new Paint(); 47 | mPaint.setAntiAlias(true); 48 | mPaint.setColor(0xffffffff); 49 | mPaint.setStyle(Paint.Style.FILL); 50 | } 51 | 52 | public void setRippleColor(@ColorInt int color) { 53 | if (mPaint != null) mPaint.setColor(color); 54 | } 55 | 56 | public void startReveal() { 57 | setVisibility(VISIBLE); 58 | if (va == null) { 59 | int bigRadius = (int) (Math.sqrt(Math.pow(getHeight(), 2) + Math.pow(getWidth(), 2))); 60 | va = ValueAnimator.ofInt(0, bigRadius / 2); 61 | va.setDuration(bigRadius); 62 | va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 63 | @Override 64 | public void onAnimationUpdate(ValueAnimator animation) { 65 | r = (int) animation.getAnimatedValue() * 2; 66 | invalidate(); 67 | } 68 | }); 69 | va.addListener(new AnimatorListenerAdapter() { 70 | @Override 71 | public void onAnimationEnd(Animator animation) { 72 | if (listener != null) { 73 | listener.onRippleEnd(); 74 | } 75 | } 76 | }); 77 | } 78 | va.start(); 79 | } 80 | 81 | public void stopAnim() { 82 | if (va != null && va.isRunning()) va.cancel(); 83 | } 84 | 85 | @Override 86 | protected void onDraw(Canvas canvas) { 87 | super.onDraw(canvas); 88 | canvas.drawCircle(getWidth() / 2, getHeight() / 2, r, mPaint); 89 | } 90 | 91 | @Override 92 | protected void onDetachedFromWindow() { 93 | super.onDetachedFromWindow(); 94 | if (va != null) va.cancel(); 95 | } 96 | 97 | public void setRippleEndListener(OnRippleEndListener listener) { 98 | this.listener = listener; 99 | } 100 | 101 | public interface OnRippleEndListener { 102 | void onRippleEnd(); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /twlibrary/src/main/java/com/lcodecore/tkrefreshlayout/header/bezierlayout/RoundDotView.java: -------------------------------------------------------------------------------- 1 | package com.lcodecore.tkrefreshlayout.header.bezierlayout; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.graphics.Color; 6 | import android.graphics.Paint; 7 | import android.util.AttributeSet; 8 | import android.view.View; 9 | 10 | /** 11 | * Created by cjj on 2015/8/27. 12 | */ 13 | public class RoundDotView extends View { 14 | private Paint mPath; 15 | private float r=15; 16 | private int num = 7; 17 | 18 | public void setCir_x(int cir_x) { 19 | this.cir_x = cir_x; 20 | } 21 | 22 | private int cir_x; 23 | 24 | public RoundDotView(Context context) { 25 | this(context, null, 0); 26 | } 27 | 28 | public RoundDotView(Context context, AttributeSet attrs) { 29 | this(context, attrs, 0); 30 | } 31 | 32 | public RoundDotView(Context context, AttributeSet attrs, int defStyleAttr) { 33 | super(context, attrs, defStyleAttr); 34 | init(); 35 | } 36 | 37 | private void init() { 38 | mPath = new Paint(); 39 | mPath.setAntiAlias(true); 40 | mPath.setColor(Color.rgb(114,114,114)); 41 | } 42 | 43 | @Override 44 | protected void onDraw(Canvas canvas) { 45 | super.onDraw(canvas); 46 | int w = getMeasuredWidth()/num-10; 47 | for (int i = 0;i < num; i++) 48 | { 49 | switch (i) 50 | { 51 | case 0: 52 | mPath.setAlpha(35); 53 | canvas.drawCircle(getMeasuredWidth() / 2-cir_x*3 -3*w/3*2,getMeasuredHeight()/2,r,mPath); 54 | break; 55 | case 1: 56 | mPath.setAlpha(105); 57 | canvas.drawCircle(getMeasuredWidth() / 2-cir_x*2 -2*w/3*2,getMeasuredHeight()/2,r,mPath); 58 | break; 59 | case 2: 60 | mPath.setAlpha(145); 61 | canvas.drawCircle(getMeasuredWidth() / 2 -cir_x*1-w/3*2,getMeasuredHeight()/2,r,mPath); 62 | break; 63 | case 3: 64 | mPath.setAlpha(255); 65 | canvas.drawCircle(getMeasuredWidth() / 2 ,getMeasuredHeight()/2,r,mPath); 66 | break; 67 | case 4: 68 | mPath.setAlpha(145); 69 | canvas.drawCircle(getMeasuredWidth() / 2 +cir_x*1+w/3*2,getMeasuredHeight()/2,r,mPath); 70 | break; 71 | case 5: 72 | mPath.setAlpha(105); 73 | canvas.drawCircle(getMeasuredWidth() / 2 +cir_x*2+2*w/3*2,getMeasuredHeight()/2,r,mPath); 74 | break; 75 | case 6: 76 | mPath.setAlpha(35); 77 | canvas.drawCircle(getMeasuredWidth() / 2 +cir_x*3+3*w/3*2,getMeasuredHeight()/2,r,mPath); 78 | break; 79 | } 80 | 81 | } 82 | } 83 | 84 | 85 | } 86 | -------------------------------------------------------------------------------- /twlibrary/src/main/java/com/lcodecore/tkrefreshlayout/header/bezierlayout/RoundProgressView.java: -------------------------------------------------------------------------------- 1 | package com.lcodecore.tkrefreshlayout.header.bezierlayout; 2 | 3 | import android.animation.ValueAnimator; 4 | import android.content.Context; 5 | import android.graphics.Canvas; 6 | import android.graphics.Color; 7 | import android.graphics.Paint; 8 | import android.graphics.RectF; 9 | import android.util.AttributeSet; 10 | import android.view.View; 11 | import android.view.animation.AccelerateDecelerateInterpolator; 12 | 13 | /** 14 | * Created by Administrator on 2015/8/27. 15 | */ 16 | public class RoundProgressView extends View { 17 | private Paint mPath; 18 | private Paint mPantR; 19 | private float r = 40; 20 | private int num = 7; 21 | private int stratAngle = 270; 22 | private int endAngle = 0; 23 | private int outCir_value = 15; 24 | 25 | public void setCir_x(int cir_x) { 26 | this.cir_x = cir_x; 27 | } 28 | 29 | private int cir_x; 30 | 31 | public RoundProgressView(Context context) { 32 | this(context, null, 0); 33 | } 34 | 35 | public RoundProgressView(Context context, AttributeSet attrs) { 36 | this(context, attrs, 0); 37 | } 38 | 39 | public RoundProgressView(Context context, AttributeSet attrs, int defStyleAttr) { 40 | super(context, attrs, defStyleAttr); 41 | init(); 42 | 43 | } 44 | 45 | ValueAnimator va; 46 | 47 | private void init() { 48 | mPath = new Paint(); 49 | mPantR = new Paint(); 50 | mPantR.setColor(Color.WHITE); 51 | mPantR.setAntiAlias(true); 52 | mPath.setAntiAlias(true); 53 | mPath.setColor(Color.rgb(114, 114, 114)); 54 | 55 | va = ValueAnimator.ofInt(0, 360); 56 | va.setDuration(720); 57 | va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 58 | @Override 59 | public void onAnimationUpdate(ValueAnimator animation) { 60 | endAngle = (int) animation.getAnimatedValue(); 61 | postInvalidate(); 62 | } 63 | }); 64 | va.setRepeatCount(ValueAnimator.INFINITE); 65 | va.setInterpolator(new AccelerateDecelerateInterpolator()); 66 | } 67 | 68 | private RectF oval, oval2; 69 | 70 | @Override 71 | protected void onDraw(Canvas canvas) { 72 | super.onDraw(canvas); 73 | int w = getMeasuredWidth() / num - 10; 74 | mPath.setStyle(Paint.Style.FILL); 75 | canvas.drawCircle(getMeasuredWidth() / 2, getMeasuredHeight() / 2, r, mPath); 76 | canvas.save(); 77 | mPath.setStyle(Paint.Style.STROKE);//设置为空心 78 | mPath.setStrokeWidth(6); 79 | canvas.drawCircle(getMeasuredWidth() / 2, getMeasuredHeight() / 2, r + 15, mPath); 80 | canvas.restore(); 81 | 82 | mPantR.setStyle(Paint.Style.FILL); 83 | if (oval == null) oval = new RectF(); 84 | oval.set(getMeasuredWidth() / 2 - r, getMeasuredHeight() / 2 - r, getMeasuredWidth() / 2 + r, getMeasuredHeight() / 2 + r);// 设置个新的长方形,扫描测量 85 | canvas.drawArc(oval, stratAngle, endAngle, true, mPantR); 86 | canvas.save(); 87 | mPantR.setStrokeWidth(6); 88 | mPantR.setStyle(Paint.Style.STROKE); 89 | if (oval2 == null) oval2 = new RectF(); 90 | oval2.set(getMeasuredWidth() / 2 - r - outCir_value, getMeasuredHeight() / 2 - r - outCir_value, getMeasuredWidth() / 2 + r + outCir_value, getMeasuredHeight() / 2 + r + outCir_value);// 设置个新的长方形,扫描测量 91 | canvas.drawArc(oval2, stratAngle, endAngle, false, mPantR); 92 | canvas.restore(); 93 | } 94 | 95 | @Override 96 | protected void onDetachedFromWindow() { 97 | super.onDetachedFromWindow(); 98 | if (va != null) va.cancel(); 99 | } 100 | 101 | public void startAnim() { 102 | if (va != null) va.start(); 103 | } 104 | 105 | public void stopAnim() { 106 | if (va != null && va.isRunning()) va.cancel(); 107 | } 108 | 109 | } 110 | -------------------------------------------------------------------------------- /twlibrary/src/main/java/com/lcodecore/tkrefreshlayout/header/bezierlayout/WaveView.java: -------------------------------------------------------------------------------- 1 | package com.lcodecore.tkrefreshlayout.header.bezierlayout; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | import android.graphics.Path; 8 | import android.graphics.PixelFormat; 9 | import android.graphics.drawable.Drawable; 10 | import android.support.annotation.ColorInt; 11 | import android.util.AttributeSet; 12 | import android.view.View; 13 | 14 | /** 15 | * Created by cjj on 2015/8/5. 16 | * 绘制贝塞尔来绘制波浪形 17 | */ 18 | public class WaveView extends View { 19 | private int waveHeight; 20 | private int headHeight; 21 | Path path; 22 | Paint paint; 23 | 24 | public WaveView(Context context) { 25 | this(context, null, 0); 26 | } 27 | 28 | public WaveView(Context context, AttributeSet attrs) { 29 | this(context, attrs, 0); 30 | } 31 | 32 | public WaveView(Context context, AttributeSet attrs, int defStyleAttr) { 33 | super(context, attrs, defStyleAttr); 34 | init(); 35 | } 36 | 37 | private void init() { 38 | path = new Path(); 39 | paint = new Paint(); 40 | paint.setColor(0xff1F2426); 41 | paint.setAntiAlias(true); 42 | } 43 | 44 | public int getHeadHeight() { 45 | return headHeight; 46 | } 47 | 48 | public void setHeadHeight(int headHeight) { 49 | this.headHeight = headHeight; 50 | } 51 | 52 | public int getWaveHeight() { 53 | return waveHeight; 54 | } 55 | 56 | public void setWaveHeight(int waveHeight) { 57 | this.waveHeight = waveHeight; 58 | } 59 | 60 | public void setWaveColor(@ColorInt int color) { 61 | if (paint != null) paint.setColor(color); 62 | } 63 | 64 | @Override 65 | protected void onDraw(Canvas canvas) { 66 | super.onDraw(canvas); 67 | //重置画笔 68 | path.reset(); 69 | path.lineTo(0, headHeight); 70 | //绘制贝塞尔曲线 71 | path.quadTo(getMeasuredWidth() / 2, headHeight + waveHeight, getMeasuredWidth(), headHeight); 72 | path.lineTo(getMeasuredWidth(), 0); 73 | canvas.drawPath(path, paint); 74 | } 75 | 76 | 77 | static Bitmap drawableToBitmap(Drawable drawable) // drawable 转换成bitmap 78 | { 79 | int width = drawable.getIntrinsicWidth();// 取drawable的长宽 80 | int height = drawable.getIntrinsicHeight(); 81 | Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;// 取drawable的颜色格式 82 | Bitmap bitmap = Bitmap.createBitmap(width, height, config);// 建立对应bitmap 83 | Canvas canvas = new Canvas(bitmap);// 建立对应bitmap的画布 84 | drawable.setBounds(0, 0, width, height); 85 | drawable.draw(canvas);// 把drawable内容画到画布中 86 | return bitmap; 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /twlibrary/src/main/java/com/lcodecore/tkrefreshlayout/header/progresslayout/CircleImageView.java: -------------------------------------------------------------------------------- 1 | package com.lcodecore.tkrefreshlayout.header.progresslayout; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.graphics.Color; 6 | import android.graphics.Paint; 7 | import android.graphics.RadialGradient; 8 | import android.graphics.Shader; 9 | import android.graphics.drawable.ShapeDrawable; 10 | import android.graphics.drawable.shapes.OvalShape; 11 | import android.support.v4.view.ViewCompat; 12 | import android.view.animation.Animation; 13 | import android.widget.ImageView; 14 | 15 | /** 16 | * Private class created to work around issues with AnimationListeners being 17 | * called before the animation is actually complete and support shadows on older 18 | * platforms. 19 | * 20 | */ 21 | public class CircleImageView extends ImageView { 22 | 23 | private static final int KEY_SHADOW_COLOR = 0x1E000000; 24 | private static final int FILL_SHADOW_COLOR = 0x3D000000; 25 | // PX 26 | private static final float X_OFFSET = 0f; 27 | private static final float Y_OFFSET = 1.75f; 28 | private static final float SHADOW_RADIUS = 3.5f; 29 | private static final int SHADOW_ELEVATION = 4; 30 | 31 | private Animation.AnimationListener mListener; 32 | private int mShadowRadius; 33 | 34 | public CircleImageView(Context context, int color, final float radius) { 35 | super(context); 36 | final float density = getContext().getResources().getDisplayMetrics().density; 37 | final int diameter = (int) (radius * density * 2); 38 | final int shadowYOffset = (int) (density * Y_OFFSET); 39 | final int shadowXOffset = (int) (density * X_OFFSET); 40 | 41 | mShadowRadius = (int) (density * SHADOW_RADIUS); 42 | 43 | ShapeDrawable circle; 44 | if (elevationSupported()) { 45 | circle = new ShapeDrawable(new OvalShape()); 46 | ViewCompat.setElevation(this, SHADOW_ELEVATION * density); 47 | } else { 48 | OvalShape oval = new OvalShadow(mShadowRadius, diameter); 49 | circle = new ShapeDrawable(oval); 50 | ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, circle.getPaint()); 51 | circle.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, 52 | KEY_SHADOW_COLOR); 53 | final int padding = mShadowRadius; 54 | // set padding so the inner image sits correctly within the shadow. 55 | setPadding(padding, padding, padding, padding); 56 | } 57 | circle.getPaint().setColor(color); 58 | setBackgroundDrawable(circle); 59 | } 60 | 61 | private boolean elevationSupported() { 62 | return android.os.Build.VERSION.SDK_INT >= 21; 63 | } 64 | 65 | @Override 66 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 67 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 68 | if (!elevationSupported()) { 69 | setMeasuredDimension(getMeasuredWidth() + mShadowRadius*2, getMeasuredHeight() 70 | + mShadowRadius*2); 71 | } 72 | } 73 | 74 | public void setAnimationListener(Animation.AnimationListener listener) { 75 | mListener = listener; 76 | } 77 | 78 | @Override 79 | public void onAnimationStart() { 80 | super.onAnimationStart(); 81 | if (mListener != null) { 82 | mListener.onAnimationStart(getAnimation()); 83 | } 84 | } 85 | 86 | @Override 87 | public void onAnimationEnd() { 88 | super.onAnimationEnd(); 89 | if (mListener != null) { 90 | mListener.onAnimationEnd(getAnimation()); 91 | } 92 | } 93 | 94 | /** 95 | * Update the background color of the circle image view. 96 | * 97 | * @param colorRes Id of a color resource. 98 | */ 99 | public void setBackgroundColorRes(int colorRes) { 100 | setBackgroundColor(getContext().getResources().getColor(colorRes)); 101 | } 102 | 103 | @Override 104 | public void setBackgroundColor(int color) { 105 | if (getBackground() instanceof ShapeDrawable) { 106 | ((ShapeDrawable) getBackground()).getPaint().setColor(color); 107 | } 108 | } 109 | 110 | private class OvalShadow extends OvalShape { 111 | private RadialGradient mRadialGradient; 112 | private Paint mShadowPaint; 113 | private int mCircleDiameter; 114 | 115 | public OvalShadow(int shadowRadius, int circleDiameter) { 116 | super(); 117 | mShadowPaint = new Paint(); 118 | mShadowRadius = shadowRadius; 119 | mCircleDiameter = circleDiameter; 120 | mRadialGradient = new RadialGradient(mCircleDiameter / 2, mCircleDiameter / 2, 121 | mShadowRadius, new int[] { 122 | FILL_SHADOW_COLOR, Color.TRANSPARENT 123 | }, null, Shader.TileMode.CLAMP); 124 | mShadowPaint.setShader(mRadialGradient); 125 | } 126 | 127 | @Override 128 | public void draw(Canvas canvas, Paint paint) { 129 | final int viewWidth = CircleImageView.this.getWidth(); 130 | final int viewHeight = CircleImageView.this.getHeight(); 131 | canvas.drawCircle(viewWidth / 2, viewHeight / 2, (mCircleDiameter / 2 + mShadowRadius), 132 | mShadowPaint); 133 | canvas.drawCircle(viewWidth / 2, viewHeight / 2, (mCircleDiameter / 2), paint); 134 | } 135 | } 136 | } -------------------------------------------------------------------------------- /twlibrary/src/main/java/com/lcodecore/tkrefreshlayout/processor/Decorator.java: -------------------------------------------------------------------------------- 1 | package com.lcodecore.tkrefreshlayout.processor; 2 | 3 | import com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout; 4 | 5 | /** 6 | * Created by lcodecore on 2017/3/3. 7 | */ 8 | 9 | public abstract class Decorator implements IDecorator { 10 | protected IDecorator decorator; 11 | protected TwinklingRefreshLayout.CoContext cp; 12 | 13 | public Decorator(TwinklingRefreshLayout.CoContext processor, IDecorator decorator1) { 14 | cp = processor; 15 | decorator = decorator1; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /twlibrary/src/main/java/com/lcodecore/tkrefreshlayout/processor/IAnimOverScroll.java: -------------------------------------------------------------------------------- 1 | package com.lcodecore.tkrefreshlayout.processor; 2 | 3 | /** 4 | * Created by lcodecore on 2017/3/3. 5 | */ 6 | 7 | public interface IAnimOverScroll { 8 | void animOverScrollTop(float vy, int computeTimes); 9 | void animOverScrollBottom(float vy, int computeTimes); 10 | } 11 | -------------------------------------------------------------------------------- /twlibrary/src/main/java/com/lcodecore/tkrefreshlayout/processor/IAnimRefresh.java: -------------------------------------------------------------------------------- 1 | package com.lcodecore.tkrefreshlayout.processor; 2 | 3 | /** 4 | * Created by lcodecore on 2017/3/3. 5 | */ 6 | 7 | public interface IAnimRefresh { 8 | void scrollHeadByMove(float moveY); 9 | void scrollBottomByMove(float moveY); 10 | void animHeadToRefresh(); 11 | void animHeadBack(boolean isFinishRefresh); 12 | void animHeadHideByVy(int vy); 13 | void animBottomToLoad(); 14 | void animBottomBack(boolean isFinishRefresh); 15 | void animBottomHideByVy(int vy); 16 | } 17 | -------------------------------------------------------------------------------- /twlibrary/src/main/java/com/lcodecore/tkrefreshlayout/processor/IDecorator.java: -------------------------------------------------------------------------------- 1 | package com.lcodecore.tkrefreshlayout.processor; 2 | 3 | import android.view.MotionEvent; 4 | 5 | /** 6 | * Created by lcodecore on 2017/3/1. 7 | */ 8 | 9 | public interface IDecorator { 10 | boolean dispatchTouchEvent(MotionEvent ev); 11 | 12 | boolean interceptTouchEvent(MotionEvent ev); 13 | 14 | boolean dealTouchEvent(MotionEvent ev); 15 | 16 | void onFingerDown(MotionEvent ev); 17 | 18 | void onFingerUp(MotionEvent ev, boolean isFling); 19 | 20 | void onFingerScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY, float velocityX, float velocityY); 21 | 22 | void onFingerFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY); 23 | } 24 | -------------------------------------------------------------------------------- /twlibrary/src/main/java/com/lcodecore/tkrefreshlayout/processor/OverScrollDecorator.java: -------------------------------------------------------------------------------- 1 | package com.lcodecore.tkrefreshlayout.processor; 2 | 3 | import android.os.Handler; 4 | import android.os.Message; 5 | import android.view.MotionEvent; 6 | import android.view.View; 7 | 8 | import com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout; 9 | import com.lcodecore.tkrefreshlayout.utils.ScrollingUtil; 10 | 11 | /** 12 | * Created by lcodecore on 2017/3/1. 13 | */ 14 | //TODO FullOverScrollDecorator、VerticalDecorator 15 | public class OverScrollDecorator extends Decorator { 16 | 17 | //主要为了监测Fling的动作,实现越界回弹 18 | private float mVelocityY; 19 | 20 | //满足越界的手势的最低速度(默认3000) 21 | private static final int OVER_SCROLL_MIN_VX = 3000; 22 | 23 | //针对View的延时策略 24 | private static final int MSG_START_COMPUTE_SCROLL = 0; //开始计算 25 | private static final int MSG_CONTINUE_COMPUTE_SCROLL = 1;//继续计算 26 | private static final int MSG_STOP_COMPUTE_SCROLL = 2; //停止计算 27 | 28 | private int cur_delay_times = 0; //当前计算次数 29 | private static final int ALL_DELAY_TIMES = 60; //10ms计算一次,总共计算20次 30 | 31 | public OverScrollDecorator(TwinklingRefreshLayout.CoContext processor, IDecorator decorator1) { 32 | super(processor, decorator1); 33 | } 34 | 35 | 36 | @Override 37 | public boolean dispatchTouchEvent(MotionEvent ev) { 38 | return decorator != null && decorator.dispatchTouchEvent(ev); 39 | } 40 | 41 | @Override 42 | public boolean interceptTouchEvent(MotionEvent ev) { 43 | return decorator != null && decorator.interceptTouchEvent(ev); 44 | } 45 | 46 | @Override 47 | public boolean dealTouchEvent(MotionEvent e) { 48 | return decorator != null && decorator.dealTouchEvent(e); 49 | } 50 | 51 | private boolean preventTopOverScroll = false; 52 | private boolean preventBottomOverScroll = false; 53 | private boolean checkOverScroll = false; 54 | 55 | @Override 56 | public void onFingerDown(MotionEvent ev) { 57 | if (decorator != null) decorator.onFingerDown(ev); 58 | preventTopOverScroll = ScrollingUtil.isViewToTop(cp.getTargetView(), cp.getTouchSlop()); 59 | preventBottomOverScroll = ScrollingUtil.isViewToBottom(cp.getTargetView(), cp.getTouchSlop()); 60 | } 61 | 62 | @Override 63 | public void onFingerUp(MotionEvent ev, boolean isFling) { 64 | 65 | if (decorator != null) { 66 | decorator.onFingerUp(ev, checkOverScroll && isFling); 67 | } 68 | checkOverScroll = false; 69 | } 70 | 71 | @Override 72 | public void onFingerScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY, float velocityX, float velocityY) { 73 | if (decorator != null) 74 | decorator.onFingerScroll(e1, e2, distanceX, distanceY, velocityX, velocityY); 75 | } 76 | 77 | @Override 78 | public void onFingerFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { 79 | if (decorator != null) decorator.onFingerFling(e1, e2, velocityX, velocityY); 80 | //fling时才触发OverScroll,获取速度并采用演示策略估算View是否滚动到边界 81 | if (!cp.enableOverScroll()) return; 82 | 83 | int dy = (int) (e2.getY() - e1.getY()); 84 | if (dy < -cp.getTouchSlop() && preventBottomOverScroll) return;//控件滚动在底部且向上fling 85 | if (dy > cp.getTouchSlop() && preventTopOverScroll) return;//控件滚动在顶部且向下fling 86 | 87 | mVelocityY = velocityY; 88 | if (Math.abs(mVelocityY) >= OVER_SCROLL_MIN_VX) { 89 | mHandler.sendEmptyMessage(MSG_START_COMPUTE_SCROLL); 90 | checkOverScroll = true; 91 | } else { 92 | mVelocityY = 0; 93 | cur_delay_times = ALL_DELAY_TIMES; 94 | } 95 | } 96 | 97 | private Handler mHandler = new Handler() { 98 | 99 | @Override 100 | public void handleMessage(Message msg) { 101 | int mTouchSlop = cp.getTouchSlop(); 102 | switch (msg.what) { 103 | case MSG_START_COMPUTE_SCROLL: 104 | cur_delay_times = -1; //这里没有break,写作-1方便计数 105 | case MSG_CONTINUE_COMPUTE_SCROLL: 106 | cur_delay_times++; 107 | 108 | View mChildView = cp.getTargetView(); 109 | 110 | if (cp.allowOverScroll()) { 111 | if (mVelocityY >= OVER_SCROLL_MIN_VX) { 112 | if (ScrollingUtil.isViewToTop(mChildView, mTouchSlop)) { 113 | cp.getAnimProcessor().animOverScrollTop(mVelocityY, cur_delay_times); 114 | mVelocityY = 0; 115 | cur_delay_times = ALL_DELAY_TIMES; 116 | } 117 | } else if (mVelocityY <= -OVER_SCROLL_MIN_VX) { 118 | if (ScrollingUtil.isViewToBottom(mChildView, mTouchSlop)) { 119 | cp.getAnimProcessor().animOverScrollBottom(mVelocityY, cur_delay_times); 120 | mVelocityY = 0; 121 | cur_delay_times = ALL_DELAY_TIMES; 122 | } 123 | } 124 | } 125 | 126 | //计算未超时,继续发送消息并循环计算 127 | if (cur_delay_times < ALL_DELAY_TIMES) 128 | mHandler.sendEmptyMessageDelayed(MSG_CONTINUE_COMPUTE_SCROLL, 10); 129 | break; 130 | case MSG_STOP_COMPUTE_SCROLL: 131 | cur_delay_times = ALL_DELAY_TIMES; 132 | break; 133 | } 134 | } 135 | }; 136 | } 137 | -------------------------------------------------------------------------------- /twlibrary/src/main/java/com/lcodecore/tkrefreshlayout/utils/DensityUtil.java: -------------------------------------------------------------------------------- 1 | package com.lcodecore.tkrefreshlayout.utils; 2 | 3 | import android.content.Context; 4 | 5 | public class DensityUtil { 6 | 7 | /** 8 | * 根据手机的分辨率从 dp 的单位 转成为 px(像素) 9 | */ 10 | public static int dp2px(Context context, float dpValue) { 11 | final float scale = context.getResources().getDisplayMetrics().density; 12 | return (int) (dpValue * scale + 0.5f); 13 | } 14 | 15 | /** 16 | * 根据手机的分辨率从 px(像素) 的单位 转成为 dp 17 | */ 18 | public static int px2dp(Context context, float pxValue) { 19 | final float scale = context.getResources().getDisplayMetrics().density; 20 | return (int) (pxValue / scale + 0.5f); 21 | } 22 | } -------------------------------------------------------------------------------- /twlibrary/src/main/java/com/lcodecore/tkrefreshlayout/utils/LogUtil.java: -------------------------------------------------------------------------------- 1 | package com.lcodecore.tkrefreshlayout.utils; 2 | 3 | import android.util.Log; 4 | 5 | /** 6 | * Created by lcodecore on 2017/4/1. 7 | */ 8 | 9 | public class LogUtil { 10 | private static final boolean DEBUG = false; 11 | 12 | public static void i(String msg) { 13 | if (!DEBUG) return; 14 | Log.i("TwinklingRefreshLayout", msg); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /twlibrary/src/main/res/drawable-xhdpi/ic_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/twlibrary/src/main/res/drawable-xhdpi/ic_arrow.png -------------------------------------------------------------------------------- /twlibrary/src/main/res/drawable/anim_loading_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 11 | 14 | 17 | 20 | 23 | 26 | 29 | 32 | 35 | 38 | 41 | 42 | -------------------------------------------------------------------------------- /twlibrary/src/main/res/layout/view_bezier.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 13 | 19 | 20 | 21 | 27 | 28 | 32 | 33 | -------------------------------------------------------------------------------- /twlibrary/src/main/res/layout/view_sinaheader.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | 12 | 18 | 19 | 26 | -------------------------------------------------------------------------------- /twlibrary/src/main/res/mipmap-hdpi/refresh_head_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/twlibrary/src/main/res/mipmap-hdpi/refresh_head_arrow.png -------------------------------------------------------------------------------- /twlibrary/src/main/res/mipmap-hdpi/refresh_loading01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/twlibrary/src/main/res/mipmap-hdpi/refresh_loading01.png -------------------------------------------------------------------------------- /twlibrary/src/main/res/mipmap-hdpi/refresh_loading02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/twlibrary/src/main/res/mipmap-hdpi/refresh_loading02.png -------------------------------------------------------------------------------- /twlibrary/src/main/res/mipmap-hdpi/refresh_loading03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/twlibrary/src/main/res/mipmap-hdpi/refresh_loading03.png -------------------------------------------------------------------------------- /twlibrary/src/main/res/mipmap-hdpi/refresh_loading04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/twlibrary/src/main/res/mipmap-hdpi/refresh_loading04.png -------------------------------------------------------------------------------- /twlibrary/src/main/res/mipmap-hdpi/refresh_loading05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/twlibrary/src/main/res/mipmap-hdpi/refresh_loading05.png -------------------------------------------------------------------------------- /twlibrary/src/main/res/mipmap-hdpi/refresh_loading06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/twlibrary/src/main/res/mipmap-hdpi/refresh_loading06.png -------------------------------------------------------------------------------- /twlibrary/src/main/res/mipmap-hdpi/refresh_loading07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/twlibrary/src/main/res/mipmap-hdpi/refresh_loading07.png -------------------------------------------------------------------------------- /twlibrary/src/main/res/mipmap-hdpi/refresh_loading08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/twlibrary/src/main/res/mipmap-hdpi/refresh_loading08.png -------------------------------------------------------------------------------- /twlibrary/src/main/res/mipmap-hdpi/refresh_loading09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/twlibrary/src/main/res/mipmap-hdpi/refresh_loading09.png -------------------------------------------------------------------------------- /twlibrary/src/main/res/mipmap-hdpi/refresh_loading10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/twlibrary/src/main/res/mipmap-hdpi/refresh_loading10.png -------------------------------------------------------------------------------- /twlibrary/src/main/res/mipmap-hdpi/refresh_loading11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/twlibrary/src/main/res/mipmap-hdpi/refresh_loading11.png -------------------------------------------------------------------------------- /twlibrary/src/main/res/mipmap-hdpi/refresh_loading12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justson/AgentWebX5/428e703a84fbf85c30cbeb12e5a3934cc648e8bf/twlibrary/src/main/res/mipmap-hdpi/refresh_loading12.png -------------------------------------------------------------------------------- /twlibrary/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /twlibrary/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #e75946 4 | #f4d227 5 | #4674e7 6 | #0ba62c 7 | -------------------------------------------------------------------------------- /twlibrary/src/main/res/values/ids.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /twlibrary/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Library 3 | 4 | --------------------------------------------------------------------------------
电话 短信 邮件
上传身份证