├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── map.png │ │ │ │ ├── back.png │ │ │ │ ├── biji.png │ │ │ │ ├── clock.png │ │ │ │ ├── dang.png │ │ │ │ ├── error.png │ │ │ │ ├── huiyi.png │ │ │ │ ├── jueyi.png │ │ │ │ ├── news.png │ │ │ │ ├── sign.png │ │ │ │ ├── time.jpg │ │ │ │ ├── user.png │ │ │ │ ├── video.png │ │ │ │ ├── wifi.png │ │ │ │ ├── dangfei.png │ │ │ │ ├── download.png │ │ │ │ ├── ganqun.png │ │ │ │ ├── goback.png │ │ │ │ ├── huabiao.png │ │ │ │ ├── lable_1.png │ │ │ │ ├── lable_2.png │ │ │ │ ├── luntan.png │ │ │ │ ├── main_hd.jpg │ │ │ │ ├── splash.png │ │ │ │ ├── tongzhi.png │ │ │ │ ├── zhanhui.png │ │ │ │ ├── back_index.png │ │ │ │ ├── callphone.png │ │ │ │ ├── crosshair.jpg │ │ │ │ ├── dang_anpai.jpg │ │ │ │ ├── dang_video.png │ │ │ │ ├── error_icon.png │ │ │ │ ├── gognheguo.jpg │ │ │ │ ├── huiyiinfo.png │ │ │ │ ├── index_icon.png │ │ │ │ ├── norify_pic.png │ │ │ │ ├── sign_icon.png │ │ │ │ ├── sinaweibo.png │ │ │ │ ├── wifi_icon.png │ │ │ │ ├── xindebiji.png │ │ │ │ ├── china_dream.png │ │ │ │ ├── dang_gonggao.png │ │ │ │ ├── dazhongluntan.png │ │ │ │ ├── follow_group.png │ │ │ │ ├── group_create.png │ │ │ │ ├── heart_group.png │ │ │ │ ├── huiyi_person.png │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── jueyi_submit.png │ │ │ │ ├── leave_message.png │ │ │ │ ├── sign_button.png │ │ │ │ ├── waimai_icon.png │ │ │ │ ├── xinde_bottom.png │ │ │ │ ├── zhognhang_map.jpg │ │ │ │ ├── jueyi_head_pic.png │ │ │ │ ├── danginfo_download.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── not_forget_heart.png │ │ │ ├── mipmap-hdpi │ │ │ │ ├── splash.png │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── splash.png │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── splash.png │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── splash.png │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher2.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── styles.xml │ │ │ │ └── config.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ ├── drawable │ │ │ │ ├── ic_chevron_left_white_24px.xml │ │ │ │ ├── ic_chevron_right_white_24px.xml │ │ │ │ ├── ic_refresh_white_24px.xml │ │ │ │ ├── ic_not_interested_white_24px.xml │ │ │ │ └── item_bg.xml │ │ │ └── layout │ │ │ │ ├── progress_bar_layout.xml │ │ │ │ ├── activity_main.xml │ │ │ │ ├── activity_second.xml │ │ │ │ ├── pop_img.xml │ │ │ │ └── webview_activity.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── xiaoyunchengzhu │ │ │ │ └── androidandh5 │ │ │ │ ├── module │ │ │ │ ├── CallBackJs.java │ │ │ │ ├── ActionService.java │ │ │ │ └── ConvertCore.java │ │ │ │ ├── SecondActivity.java │ │ │ │ ├── bean │ │ │ │ └── TestBean.java │ │ │ │ ├── MainActivity.java │ │ │ │ ├── webviewpakage │ │ │ │ ├── NetworkHandler.java │ │ │ │ ├── ProgressDialogHelper.java │ │ │ │ ├── AndroidToJs.java │ │ │ │ ├── PermissionUtil.java │ │ │ │ ├── OkhttpDownloadFile.java │ │ │ │ ├── CustomWebChromClient.java │ │ │ │ ├── CustomWebViewClient.java │ │ │ │ ├── UrlHander.java │ │ │ │ ├── WebViewActivity.java │ │ │ │ ├── SuperWebChromClient.java │ │ │ │ └── WebViewManger.java │ │ │ │ └── service │ │ │ │ ├── ToAnotherActivity.java │ │ │ │ └── Test.java │ │ ├── assets │ │ │ ├── party.js │ │ │ ├── error.html │ │ │ ├── test.html │ │ │ └── NoInternet.html │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── xiaoyunchengzhu │ │ │ └── androidandh5 │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── xiaoyunchengzhu │ │ └── androidandh5 │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .idea ├── caches │ └── build_file_checksums.ser ├── vcs.xml ├── compiler.xml ├── modules.xml ├── gradle.xml ├── jarRepositories.xml ├── codeStyles │ └── Project.xml └── misc.xml ├── .gitignore ├── settings.gradle ├── .gitattributes ├── gradle.properties ├── README.md ├── gradlew.bat ├── gradlew └── LICENCE /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/map.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/map.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-hdpi/splash.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-mdpi/splash.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/back.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/biji.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/biji.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/clock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/clock.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/dang.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/dang.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/error.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/huiyi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/huiyi.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/jueyi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/jueyi.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/news.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/news.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/sign.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/sign.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/time.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/time.jpg -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/user.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/video.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/video.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/wifi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/wifi.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/dangfei.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/dangfei.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/download.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ganqun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/ganqun.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/goback.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/goback.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/huabiao.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/huabiao.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/lable_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/lable_1.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/lable_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/lable_2.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/luntan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/luntan.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/main_hd.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/main_hd.jpg -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/splash.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/tongzhi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/tongzhi.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/zhanhui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/zhanhui.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xxhdpi/splash.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xxxhdpi/splash.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/back_index.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/back_index.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/callphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/callphone.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/crosshair.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/crosshair.jpg -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/dang_anpai.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/dang_anpai.jpg -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/dang_video.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/dang_video.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/error_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/error_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/gognheguo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/gognheguo.jpg -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/huiyiinfo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/huiyiinfo.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/index_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/index_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/norify_pic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/norify_pic.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/sign_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/sign_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/sinaweibo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/sinaweibo.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/wifi_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/wifi_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/xindebiji.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/xindebiji.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/china_dream.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/china_dream.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/dang_gonggao.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/dang_gonggao.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/dazhongluntan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/dazhongluntan.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/follow_group.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/follow_group.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/group_create.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/group_create.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/heart_group.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/heart_group.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/huiyi_person.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/huiyi_person.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/jueyi_submit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/jueyi_submit.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/leave_message.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/leave_message.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/sign_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/sign_button.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/waimai_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/waimai_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/xinde_bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/xinde_bottom.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/zhognhang_map.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/zhognhang_map.jpg -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/jueyi_head_pic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/jueyi_head_pic.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher2.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/danginfo_download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/danginfo_download.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/not_forget_heart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xhdpi/not_forget_heart.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyunchengzhu/AndroidAndH5/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | AndroidAndH5Demo 3 | 加载中... 4 | 5 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/xiaoyunchengzhu/androidandh5/module/CallBackJs.java: -------------------------------------------------------------------------------- 1 | package com.xiaoyunchengzhu.androidandh5.module; 2 | 3 | /** 4 | * Created by TL on 2016/6/1. 5 | */ 6 | public interface CallBackJs { 7 | 8 | void callback(String json); 9 | } 10 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Aug 19 14:16:03 CST 2022 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | #844ad2 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/assets/party.js: -------------------------------------------------------------------------------- 1 | 2 | var m={ 3 | action:"Tst", 4 | params:'ok' 5 | 6 | }; 7 | var Local={ 8 | call:function(json){ 9 | }, 10 | execute:function(action,json,func){ 11 | m.params=json; 12 | m.action=action; 13 | this.call=func; 14 | LocalNative.execute(JSON.stringify(m)); 15 | 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | google() 5 | mavenCentral() 6 | } 7 | } 8 | dependencyResolutionManagement { 9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 10 | repositories { 11 | google() 12 | mavenCentral() 13 | } 14 | } 15 | rootProject.name = "AndroidAndH5" 16 | include ':app' 17 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_chevron_left_white_24px.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_chevron_right_white_24px.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/test/java/com/xiaoyunchengzhu/androidandh5/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.xiaoyunchengzhu.androidandh5; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /app/src/main/assets/error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | fuck 5 | 6 | 7 | 18 | 19 | 20 | 21 | 22 | 页面错误。 23 | 24 | 25 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/xiaoyunchengzhu/androidandh5/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.xiaoyunchengzhu.androidandh5; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/java/com/xiaoyunchengzhu/androidandh5/SecondActivity.java: -------------------------------------------------------------------------------- 1 | package com.xiaoyunchengzhu.androidandh5; 2 | 3 | import android.os.Bundle; 4 | 5 | import androidx.appcompat.app.AppCompatActivity; 6 | 7 | import com.xiaoyunchengzhu.androidandh5.webviewpakage.WebViewActivity; 8 | 9 | public class SecondActivity extends AppCompatActivity { 10 | 11 | @Override 12 | protected void onCreate(Bundle savedInstanceState) { 13 | super.onCreate(savedInstanceState); 14 | setContentView(R.layout.activity_second); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/xiaoyunchengzhu/androidandh5/module/ActionService.java: -------------------------------------------------------------------------------- 1 | package com.xiaoyunchengzhu.androidandh5.module; 2 | 3 | import android.app.Activity; 4 | 5 | /** 6 | * Created by TL on 2016/6/1. 7 | */ 8 | public abstract class ActionService { 9 | 10 | protected Activity activity; 11 | public ActionService(Activity activity) 12 | { 13 | this.activity=activity; 14 | } 15 | public abstract void execute(T param,CallBackJs callBackJs); 16 | public abstract T fromJson(String params); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_refresh_white_24px.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/layout/progress_bar_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_not_interested_white_24px.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/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 D:\android-sdk-windows/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 | -------------------------------------------------------------------------------- /app/src/main/java/com/xiaoyunchengzhu/androidandh5/bean/TestBean.java: -------------------------------------------------------------------------------- 1 | package com.xiaoyunchengzhu.androidandh5.bean; 2 | 3 | /** 4 | * Created by TL on 2016/6/3. 5 | */ 6 | public class TestBean { 7 | 8 | private String name; 9 | private String sex; 10 | private int age; 11 | 12 | public String getName() { 13 | return name; 14 | } 15 | 16 | public void setName(String name) { 17 | this.name = name; 18 | } 19 | 20 | public String getSex() { 21 | return sex; 22 | } 23 | 24 | public void setSex(String sex) { 25 | this.sex = sex; 26 | } 27 | 28 | public int getAge() { 29 | return age; 30 | } 31 | 32 | public void setAge(int age) { 33 | this.age = age; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 14 | 15 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
No Internet Connection or page is not available
29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/xiaoyunchengzhu/androidandh5/module/ConvertCore.java: -------------------------------------------------------------------------------- 1 | package com.xiaoyunchengzhu.androidandh5.module; 2 | 3 | import android.app.Activity; 4 | import android.webkit.WebView; 5 | 6 | import org.json.JSONException; 7 | import org.json.JSONObject; 8 | 9 | import java.lang.reflect.Constructor; 10 | import java.lang.reflect.InvocationTargetException; 11 | 12 | /** 13 | * Created by TL on 2016/6/1. 14 | */ 15 | public class ConvertCore implements CallBackJs{ 16 | 17 | private WebView webView; 18 | public ConvertCore(WebView webView) 19 | { 20 | this.webView=webView; 21 | } 22 | public void convert(String param, Activity a) { 23 | String actoin = null; 24 | String paramContent = null; 25 | JSONObject jsonObject = null; 26 | try { 27 | jsonObject = new JSONObject(param); 28 | actoin = jsonObject.getString("action"); 29 | paramContent = jsonObject.getString("params"); 30 | } catch (JSONException e) { 31 | e.printStackTrace(); 32 | } 33 | try { 34 | Class aClass = Class.forName("com.xiaoyunchengzhu.androidandh5.service." + actoin); 35 | Constructor[] constructors = aClass.getConstructors(); 36 | ActionService actionParam = (ActionService) constructors[0].newInstance(a); 37 | actionParam.execute(actionParam.fromJson(paramContent),this); 38 | } catch (ClassNotFoundException e) { 39 | e.printStackTrace(); 40 | } catch (InstantiationException e) { 41 | e.printStackTrace(); 42 | } catch (IllegalAccessException e) { 43 | e.printStackTrace(); 44 | } catch (InvocationTargetException e) { 45 | e.printStackTrace(); 46 | } 47 | } 48 | 49 | @Override 50 | public void callback(final String json) { 51 | webView.post(new Runnable() { 52 | @Override 53 | public void run() { 54 | webView.loadUrl("javascript:Local.call('"+json+"')"); 55 | } 56 | }); 57 | 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/src/main/java/com/xiaoyunchengzhu/androidandh5/webviewpakage/PermissionUtil.java: -------------------------------------------------------------------------------- 1 | package com.xiaoyunchengzhu.androidandh5.webviewpakage; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.content.pm.PackageManager; 6 | import androidx.core.app.ActivityCompat; 7 | import androidx.core.content.ContextCompat; 8 | import android.webkit.GeolocationPermissions; 9 | 10 | /** 11 | * Created by dragank on 10/1/2016. 12 | */ 13 | public class PermissionUtil { 14 | 15 | public static final int MY_PERMISSIONS_REQUEST_CALL = 10; 16 | public static final int MY_PERMISSIONS_REQUEST_SMS = 11; 17 | public static final int MY_PERMISSIONS_REQUEST_DOWNLOAD = 12; 18 | public static final int MY_PERMISSIONS_REQUEST_GEOLOCATION= 13; 19 | 20 | //We are calling this method to check the permissionSelectFile status 21 | public static boolean isPermissionAllowed(Context mContext, String permission) { 22 | //Getting the permissionSelectFile status 23 | int result = ContextCompat.checkSelfPermission(mContext, permission); 24 | 25 | //If permissionSelectFile is granted returning true 26 | if (result == PackageManager.PERMISSION_GRANTED) 27 | return true; 28 | 29 | //If permissionSelectFile is not granted returning false 30 | return false; 31 | } 32 | 33 | //Requesting permissionSelectFile 34 | public static void requestPermission(Activity mActivity, String permision, int permisionNumer) { 35 | 36 | if (ActivityCompat.shouldShowRequestPermissionRationale(mActivity, permision)) { 37 | //If the user has denied the permissionSelectFile previously your code will come to this block 38 | //Here you can explain why you need this permissionSelectFile 39 | //Explain here why you need this permissionSelectFile 40 | } 41 | 42 | //And finally ask for the permissionSelectFile 43 | ActivityCompat.requestPermissions(mActivity, new String[]{permision}, permisionNumer); 44 | } 45 | 46 | public static void geoLocationPermission(Activity mActivity, String origin, GeolocationPermissions.Callback callback) { 47 | if (PermissionUtil.isPermissionAllowed(mActivity, android.Manifest.permission.ACCESS_FINE_LOCATION)) { 48 | callback.invoke(origin, true, false); 49 | } 50 | PermissionUtil.requestPermission(mActivity, android.Manifest.permission.ACCESS_FINE_LOCATION, 51 | PermissionUtil.MY_PERMISSIONS_REQUEST_GEOLOCATION); 52 | } 53 | 54 | public static void checkPermissions(Activity mActivity, String[] permissions) { 55 | boolean needsPermission = false; 56 | for (String permission : permissions) { 57 | int permissionCheck = ContextCompat.checkSelfPermission(mActivity, permission); 58 | if (PackageManager.PERMISSION_GRANTED != permissionCheck) { 59 | needsPermission = true; 60 | break; 61 | } 62 | } 63 | 64 | if (needsPermission) { 65 | ActivityCompat.requestPermissions(mActivity, permissions, 0); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 31 | 48 | 49 | 50 | 51 | 52 | 53 | 55 | -------------------------------------------------------------------------------- /app/src/main/res/layout/webview_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | 15 | 16 | 23 | 30 | 31 | 41 | 42 | 52 | 53 | 65 | 66 | 71 | 72 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /app/src/main/java/com/xiaoyunchengzhu/androidandh5/webviewpakage/OkhttpDownloadFile.java: -------------------------------------------------------------------------------- 1 | package com.xiaoyunchengzhu.androidandh5.webviewpakage; 2 | 3 | import android.content.Context; 4 | import android.os.Environment; 5 | import android.os.Handler; 6 | import android.os.Message; 7 | import android.util.Log; 8 | import org.json.JSONObject; 9 | import java.io.File; 10 | import java.io.IOException; 11 | import okhttp3.Callback; 12 | import okhttp3.OkHttpClient; 13 | import okhttp3.Request; 14 | import okhttp3.Response; 15 | import okio.BufferedSink; 16 | import okio.Okio; 17 | import okio.Sink; 18 | 19 | public class OkhttpDownloadFile { 20 | /** 21 | * Created by Jane on 2019/2/15. 22 | */ 23 | private final String TAG = "OkhttpDownloadFile"; 24 | private String mSDCardPath = Environment.getExternalStorageDirectory().getAbsolutePath(); 25 | private static OkhttpDownloadFile okhttpDownloadFile; 26 | private static Context mContext; 27 | private static Handler handler; 28 | 29 | /** 30 | * 设置单例模式 31 | */ 32 | public static OkhttpDownloadFile getInstance(Context context, Handler mHandle) { 33 | if (okhttpDownloadFile == null) { 34 | okhttpDownloadFile = new OkhttpDownloadFile(); 35 | } 36 | handler = mHandle; 37 | return okhttpDownloadFile; 38 | } 39 | 40 | /** 41 | * 下载文件 42 | * 43 | * @param url 文件下载路径 44 | * @param fileName 文件名 45 | **/ 46 | public void downloadFile(final String url, final String fileName) { 47 | //下载路径,如果路径无效了,可换成你的下载路径 48 | final long startTime = System.currentTimeMillis(); 49 | Log.i(TAG, "startTime=" + startTime); 50 | Request request = new Request.Builder().url(url).build(); 51 | new OkHttpClient().newCall(request).enqueue(new Callback() { 52 | @Override 53 | public void onFailure(okhttp3.Call call, IOException e) { 54 | Log.e(TAG, "fail===cause==" + e.getCause().getMessage()); 55 | e.printStackTrace(); 56 | } 57 | 58 | @Override 59 | public void onResponse(okhttp3.Call call, Response response) throws IOException { 60 | Sink sink = null; 61 | BufferedSink bufferedSink = null; 62 | try { 63 | File dest = new File(mSDCardPath, fileName); 64 | sink = Okio.sink(dest); 65 | bufferedSink = Okio.buffer(sink); 66 | bufferedSink.writeAll(response.body().source()); 67 | bufferedSink.close(); 68 | JSONObject jsonObject = new JSONObject(); 69 | // jsonObject.put("fileName", Constants.FILE_EXT_NAME); 70 | // jsonObject.put("filePath", mSDCardPath + "/" + Constants.FILE_EXT_NAME); 71 | Message message = handler.obtainMessage(); 72 | message.what = 1; 73 | message.obj = jsonObject.toString(); 74 | handler.sendMessage(message); 75 | Log.i(TAG, "totalTime=" + (System.currentTimeMillis() - startTime)); 76 | } catch (Exception e) { 77 | e.printStackTrace(); 78 | Log.i(TAG, "download failed"); 79 | } finally { 80 | if (bufferedSink != null) { 81 | bufferedSink.close(); 82 | } 83 | } 84 | } 85 | }); 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /app/src/main/java/com/xiaoyunchengzhu/androidandh5/webviewpakage/CustomWebChromClient.java: -------------------------------------------------------------------------------- 1 | package com.xiaoyunchengzhu.androidandh5.webviewpakage; 2 | 3 | import android.annotation.TargetApi; 4 | import android.app.Activity; 5 | import android.content.ActivityNotFoundException; 6 | import android.content.Intent; 7 | import android.net.Uri; 8 | import android.os.Build; 9 | import android.util.Log; 10 | import android.webkit.ValueCallback; 11 | import android.webkit.WebChromeClient; 12 | import android.webkit.WebView; 13 | import android.widget.Toast; 14 | 15 | /** 16 | * Created by TL on 2016/5/31. 17 | */ 18 | public class CustomWebChromClient extends WebChromeClient { 19 | 20 | private WebViewActivity activity = null; 21 | private int FILECHOOSER_RESULTCODE = 0; 22 | private int REQUEST_SELECT_FILE = 0; 23 | private ValueCallback mUploadMessage; 24 | 25 | public CustomWebChromClient(WebViewActivity activity, int FILECHOOSER_RESULTCODE, int REQUEST_SELECT_FILE) { 26 | 27 | this.activity = activity; 28 | this.FILECHOOSER_RESULTCODE = FILECHOOSER_RESULTCODE; 29 | this.REQUEST_SELECT_FILE = REQUEST_SELECT_FILE; 30 | } 31 | 32 | /** 33 | * 文件选择 34 | * @param uploadMsg 35 | */ 36 | public void openFileChooser(ValueCallback uploadMsg) { 37 | 38 | ((WebViewActivity) activity).mUploadMessage = uploadMsg; 39 | 40 | mUploadMessage = uploadMsg; 41 | Intent i = new Intent(Intent.ACTION_GET_CONTENT); 42 | i.addCategory(Intent.CATEGORY_OPENABLE); 43 | i.setType("*/*"); 44 | activity.startActivityForResult(Intent.createChooser(i, "文件选择"), FILECHOOSER_RESULTCODE); 45 | 46 | } 47 | 48 | // For Android 3.0+ 49 | public void openFileChooser(ValueCallback uploadMsg, String acceptType) { 50 | 51 | ((WebViewActivity) activity).mUploadMessage = uploadMsg; 52 | 53 | mUploadMessage = uploadMsg; 54 | Intent i = new Intent(Intent.ACTION_GET_CONTENT); 55 | i.addCategory(Intent.CATEGORY_OPENABLE); 56 | i.setType("*/*"); 57 | activity.startActivityForResult( 58 | Intent.createChooser(i, "文件选择"), 59 | FILECHOOSER_RESULTCODE); 60 | } 61 | 62 | //For Android 4.1 63 | public void openFileChooser(ValueCallback uploadMsg, String acceptType, String capture) { 64 | ((WebViewActivity) activity).mUploadMessage = uploadMsg; 65 | 66 | mUploadMessage = uploadMsg; 67 | Intent i = new Intent(Intent.ACTION_GET_CONTENT); 68 | i.addCategory(Intent.CATEGORY_OPENABLE); 69 | i.setType("*/*"); 70 | activity.startActivityForResult(Intent.createChooser(i, "文件选择"), FILECHOOSER_RESULTCODE); 71 | 72 | } 73 | // For >= Lollipop 5.0 74 | 75 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 76 | public boolean onShowFileChooser(WebView mWebView, ValueCallback filePathCallback, FileChooserParams fileChooserParams) { 77 | 78 | Log.i("filechooser", REQUEST_SELECT_FILE + "启动"); 79 | if (((WebViewActivity) activity).uploadMessage != null) { 80 | ((WebViewActivity) activity).uploadMessage.onReceiveValue(null); 81 | ((WebViewActivity) activity).uploadMessage = null; 82 | } 83 | ((WebViewActivity) activity).uploadMessage = filePathCallback; 84 | 85 | Log.i("filechooser", filePathCallback.toString()); 86 | ; 87 | Intent intent = fileChooserParams.createIntent(); 88 | 89 | try { 90 | activity.startActivityForResult(intent, REQUEST_SELECT_FILE); 91 | } catch (ActivityNotFoundException e) { 92 | ((WebViewActivity) activity).uploadMessage = null; 93 | Toast.makeText(activity.getApplicationContext(), "不能打开文件选择器", Toast.LENGTH_LONG).show(); 94 | return false; 95 | } 96 | // openFileChooserImplForAndroid5(filePathCallback); 97 | return true; 98 | } 99 | 100 | private void openFileChooserImplForAndroid5(ValueCallback uploadMsg) { 101 | ((WebViewActivity) activity).uploadMessage = uploadMsg; 102 | Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); 103 | contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); 104 | contentSelectionIntent.setType("*/*"); 105 | 106 | Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); 107 | chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); 108 | chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser"); 109 | 110 | activity.startActivityForResult(chooserIntent, REQUEST_SELECT_FILE); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /app/src/main/java/com/xiaoyunchengzhu/androidandh5/webviewpakage/CustomWebViewClient.java: -------------------------------------------------------------------------------- 1 | package com.xiaoyunchengzhu.androidandh5.webviewpakage; 2 | 3 | import android.annotation.TargetApi; 4 | import android.app.Activity; 5 | import android.content.ActivityNotFoundException; 6 | import android.content.Context; 7 | import android.content.Intent; 8 | import android.net.Uri; 9 | import android.net.http.SslError; 10 | import android.os.Build; 11 | import android.util.Log; 12 | import android.view.KeyEvent; 13 | import android.view.View; 14 | import android.webkit.SslErrorHandler; 15 | import android.webkit.WebResourceError; 16 | import android.webkit.WebResourceRequest; 17 | import android.webkit.WebView; 18 | import android.webkit.WebViewClient; 19 | import android.widget.Toast; 20 | 21 | /** 22 | * Created by TL on 2016/5/31. 23 | */ 24 | public class CustomWebViewClient extends WebViewClient { 25 | 26 | private Activity context; 27 | public CustomWebViewClient(Activity context) { 28 | this.context=context; 29 | } 30 | 31 | @Override 32 | public boolean shouldOverrideKeyEvent(WebView view, KeyEvent event) { 33 | if (event.getAction() == KeyEvent.KEYCODE_BACK) { 34 | 35 | } 36 | return super.shouldOverrideKeyEvent(view, event); 37 | } 38 | 39 | @Override 40 | public boolean shouldOverrideUrlLoading(WebView view, String url) { 41 | // 处理自定义scheme http开头,包含http ,https 42 | Log.i("url :",url); 43 | if (!url.startsWith("http")) { 44 | 45 | try { 46 | Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); 47 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); 48 | context.startActivity(intent); 49 | } catch (ActivityNotFoundException e) { 50 | e.printStackTrace(); 51 | if (url.startsWith("d2k")||url.startsWith("magnet")||url.startsWith("thunder")||url.startsWith("flashget")|| 52 | url.startsWith("qqdl")){ 53 | Toast.makeText(context,"请安装迅雷",0).show(); 54 | 55 | }else if (url.startsWith("baiduyun")){ 56 | Toast.makeText(context,"请安装百度云盘",0).show(); 57 | } 58 | Log.i("no","noactivity"); 59 | } 60 | return true; 61 | }else { 62 | 63 | // view.loadUrl(url); 64 | } 65 | view.getSettings().setBlockNetworkImage(true); 66 | if (!((WebViewActivity)context).show_content) { 67 | ProgressDialogHelper.showProgress(context); 68 | } 69 | return false; 70 | } 71 | 72 | @Override 73 | public void onPageFinished(WebView view, String url) { 74 | view.getSettings().setBlockNetworkImage(false); 75 | if (!view.getSettings().getLoadsImagesAutomatically()) { 76 | view.getSettings().setLoadsImagesAutomatically(true); 77 | } 78 | super.onPageFinished(view, url); 79 | ((WebViewActivity)context).hideStatusBar(); 80 | ((WebViewActivity)context).setToolbarButtonColor(); 81 | ((WebViewActivity)context).showContent(); 82 | ProgressDialogHelper.dismissProgress(); 83 | } 84 | 85 | @Override 86 | public void onPageCommitVisible(WebView view, String url) { 87 | super.onPageCommitVisible(view, url); 88 | ((WebViewActivity)context).setToolbarButtonColor(); 89 | ((WebViewActivity)context).hideStatusBar(); 90 | ProgressDialogHelper.dismissProgress(); 91 | } 92 | 93 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 94 | @Override 95 | public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) { 96 | super.onReceivedError(view, request, error); 97 | 98 | Log.i("error :",view.getUrl()+","+request.getUrl()+","+error.getDescription().toString()); 99 | if (!NetworkHandler.isNetworkAvailable(view.getContext())) { 100 | view.loadUrl("file:///android_asset/NoInternet.html"); 101 | return; 102 | } 103 | if (view.getUrl().equals(request.getUrl())) { 104 | view.loadUrl("file:///android_asset/error.html"); 105 | } 106 | ((WebViewActivity)context).hideStatusBar(); 107 | ProgressDialogHelper.dismissProgress(); 108 | } 109 | 110 | @Override 111 | public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { 112 | super.onReceivedSslError(view, handler, error); 113 | if (!NetworkHandler.isNetworkAvailable(view.getContext())) { 114 | view.loadUrl("file:///android_asset/NoInternet.html"); 115 | return; 116 | } 117 | handler.proceed(); 118 | ((WebViewActivity)context).hideStatusBar(); 119 | ProgressDialogHelper.dismissProgress(); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /app/src/main/java/com/xiaoyunchengzhu/androidandh5/webviewpakage/UrlHander.java: -------------------------------------------------------------------------------- 1 | package com.xiaoyunchengzhu.androidandh5.webviewpakage; 2 | 3 | import android.Manifest; 4 | import android.app.Activity; 5 | import android.app.DownloadManager; 6 | import android.content.Intent; 7 | import android.content.pm.PackageManager; 8 | import android.net.Uri; 9 | import android.os.Environment; 10 | import androidx.core.app.ActivityCompat; 11 | import android.webkit.URLUtil; 12 | import android.widget.Toast; 13 | 14 | 15 | /** 16 | * Created by dragank on 10/1/2016. 17 | */ 18 | public class UrlHander { 19 | 20 | 21 | 22 | 23 | private static void phoneLink(Activity mActivity, String url) { 24 | if (PermissionUtil.isPermissionAllowed(mActivity, Manifest.permission.CALL_PHONE)) { 25 | call(mActivity, url); 26 | } else { 27 | PermissionUtil.requestPermission(mActivity, Manifest.permission.CALL_PHONE, PermissionUtil.MY_PERMISSIONS_REQUEST_CALL); 28 | } 29 | } 30 | 31 | public static void call(Activity mActivity, String url) { 32 | Intent callIntent = new Intent(Intent.ACTION_CALL); 33 | callIntent.setData(Uri.parse(url)); 34 | if (ActivityCompat.checkSelfPermission(mActivity, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) { 35 | return; 36 | } 37 | mActivity.startActivity(callIntent); 38 | } 39 | 40 | private static void smsLink(Activity mActivity, String url) { 41 | if (PermissionUtil.isPermissionAllowed(mActivity, Manifest.permission.SEND_SMS)) { 42 | sms(mActivity, url); 43 | } else { 44 | PermissionUtil.requestPermission(mActivity, Manifest.permission.SEND_SMS, PermissionUtil.MY_PERMISSIONS_REQUEST_SMS); 45 | } 46 | } 47 | 48 | public static void sms(Activity mActivity, String url) { 49 | Intent smsIntent = new Intent(Intent.ACTION_VIEW); 50 | smsIntent.setType("vnd.android-dir/mms-sms"); 51 | smsIntent.setData(Uri.parse(url)); 52 | if (ActivityCompat.checkSelfPermission(mActivity, Manifest.permission.SEND_SMS) != PackageManager.PERMISSION_GRANTED) { 53 | return; 54 | } 55 | mActivity.startActivity(smsIntent); 56 | } 57 | 58 | private static void email(Activity mActivity, String url) { 59 | Intent emailIntent = new Intent(Intent.ACTION_SENDTO); 60 | emailIntent.setData(Uri.parse(url)); 61 | mActivity.startActivity(emailIntent); 62 | } 63 | 64 | public static void map(Activity mActivity, String url) { 65 | Intent mapIntent = new Intent(Intent.ACTION_VIEW); 66 | mapIntent.setData(Uri.parse(url)); 67 | mapIntent.setPackage("com.google.android.apps.maps"); 68 | if (mapIntent.resolveActivity(mActivity.getPackageManager()) != null) { 69 | mActivity.startActivity(mapIntent); 70 | } 71 | } 72 | 73 | 74 | private static void openGooglePlay(Activity mActivity, String url) { 75 | // url = url.replace("http://play.google.com/store/apps/", "market://"); 76 | Intent googlePlayIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); 77 | if (googlePlayIntent.resolveActivity(mActivity.getPackageManager()) != null) { 78 | mActivity.startActivity(googlePlayIntent); 79 | } 80 | } 81 | 82 | private static void openYoutube(Activity mActivity, String url) { 83 | Intent youtubeIntent = new Intent(Intent.ACTION_VIEW); 84 | youtubeIntent.setData(Uri.parse(url)); 85 | if (youtubeIntent.resolveActivity(mActivity.getPackageManager()) != null) { 86 | mActivity.startActivity(youtubeIntent); 87 | } 88 | } 89 | 90 | public static void download(Activity mActivity, String url, String contentDisposition, String mimetype) { 91 | if (ActivityCompat.checkSelfPermission(mActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { 92 | return; 93 | } 94 | //To notify the Client that the file is being downloaded 95 | Toast.makeText(mActivity, "下载", Toast.LENGTH_LONG).show(); 96 | final String filename = URLUtil.guessFileName(url, contentDisposition, mimetype); 97 | DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); 98 | 99 | request.setVisibleInDownloadsUi(true); 100 | request.allowScanningByMediaScanner(); 101 | request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); //Notify client once download is completed! 102 | request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, filename); 103 | DownloadManager dm = (DownloadManager) mActivity.getSystemService(Activity.DOWNLOAD_SERVICE); 104 | dm.enqueue(request); 105 | } 106 | 107 | public static void downloadLink(Activity mActivity, String url, String contentDisposition, String mimetype) { 108 | if (PermissionUtil.isPermissionAllowed(mActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE)) { 109 | download(mActivity, url, contentDisposition, mimetype); 110 | } else { 111 | PermissionUtil.requestPermission(mActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE, PermissionUtil.MY_PERMISSIONS_REQUEST_DOWNLOAD); 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /app/src/main/java/com/xiaoyunchengzhu/androidandh5/webviewpakage/WebViewActivity.java: -------------------------------------------------------------------------------- 1 | package com.xiaoyunchengzhu.androidandh5.webviewpakage; 2 | 3 | import android.app.ActionBar; 4 | import android.app.Activity; 5 | import android.content.Intent; 6 | import android.content.pm.PackageManager; 7 | import android.net.Uri; 8 | import android.os.Build; 9 | import android.os.Bundle; 10 | import android.os.Handler; 11 | 12 | import androidx.annotation.NonNull; 13 | import androidx.core.content.ContextCompat; 14 | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; 15 | 16 | import android.text.TextUtils; 17 | import android.util.Log; 18 | import android.view.KeyEvent; 19 | import android.view.View; 20 | import android.view.WindowManager; 21 | import android.webkit.DownloadListener; 22 | import android.webkit.ValueCallback; 23 | import android.webkit.WebChromeClient; 24 | import android.webkit.WebView; 25 | import android.widget.ImageView; 26 | import android.widget.Toast; 27 | 28 | import com.xiaoyunchengzhu.androidandh5.R; 29 | 30 | 31 | /** 32 | * Created by TL on 2016/5/31. 33 | */ 34 | public class WebViewActivity extends Activity implements DownloadListener, SwipeRefreshLayout.OnRefreshListener{ 35 | 36 | public ValueCallback mUploadMessage; 37 | public final static int FILECHOOSER_RESULTCODE = 1; 38 | public ValueCallback uploadMessage; 39 | public static final int REQUEST_SELECT_FILE = 100; 40 | protected WebViewManger webViewManger; 41 | private WebView webView; 42 | private SwipeRefreshLayout mSwipeToRefresh; 43 | private ImageView mImageViewSplash; 44 | private ImageView mBack; 45 | private ImageView mForward; 46 | public boolean show_content=true; 47 | public String mCameraPhotoPath; 48 | public Uri mCapturedImageURI = null; 49 | private String urlData, currentUrl, contentDisposition, mimeType; 50 | @Override 51 | protected void onCreate(Bundle savedInstanceState) { 52 | super.onCreate(savedInstanceState); 53 | setContentView(R.layout.webview_activity); 54 | webView = (WebView) this.findViewById(R.id.WebViewActivityWebView); 55 | mImageViewSplash = (ImageView) findViewById(R.id.image_splash); 56 | webViewManger = new WebViewManger(this, webView); 57 | webView.setWebViewClient(new CustomWebViewClient(this)); 58 | mSwipeToRefresh= (SwipeRefreshLayout) findViewById(R.id.swipeToRefresh); 59 | if (mSwipeToRefresh != null) { 60 | mSwipeToRefresh.setOnRefreshListener(this); 61 | } 62 | 63 | if (savedInstanceState != null) { 64 | showContent(); 65 | } else { 66 | new Handler().postDelayed(new Runnable() { 67 | @Override 68 | public void run() { 69 | showContent(); 70 | } 71 | }, 5000); 72 | } 73 | } 74 | 75 | @Override 76 | protected void onResume() { 77 | super.onResume(); 78 | hideStatusBar(); 79 | } 80 | 81 | @Override 82 | public boolean onKeyDown(int keyCode, KeyEvent event) { 83 | if (keyCode == KeyEvent.KEYCODE_BACK) { 84 | if (webViewManger.canGoBack()) { 85 | webViewManger.goBack(); 86 | return false; 87 | } else { 88 | return super.onKeyDown(keyCode, event); 89 | } 90 | } else { 91 | return super.onKeyDown(keyCode, event); 92 | } 93 | } 94 | 95 | @Override 96 | protected void onActivityResult(int requestCode, int resultCode, Intent intent) { 97 | 98 | 99 | Log.i("filechooser", requestCode + ""); 100 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 101 | if (requestCode == REQUEST_SELECT_FILE) { 102 | if (uploadMessage == null) 103 | return; 104 | uploadMessage.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent)); 105 | uploadMessage = null; 106 | } 107 | } else if (requestCode == FILECHOOSER_RESULTCODE) { 108 | if (null == mUploadMessage) 109 | return; 110 | Uri result = intent == null || resultCode != this.RESULT_OK ? null : intent.getData(); 111 | mUploadMessage.onReceiveValue(result); 112 | mUploadMessage = null; 113 | } else { 114 | Toast.makeText(this.getApplicationContext(), "Failed to Upload Image", Toast.LENGTH_LONG).show(); 115 | } 116 | Log.i("filechooser", requestCode + "结束"); 117 | } 118 | 119 | @Override 120 | public void onRefresh() { 121 | webView.reload(); 122 | mSwipeToRefresh.setRefreshing(false); 123 | } 124 | //This method will be called when the user will tap on allow or deny 125 | @Override 126 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { 127 | //Checking the request code of our request 128 | if (requestCode == PermissionUtil.MY_PERMISSIONS_REQUEST_CALL) { 129 | //If permissionSelectFile is granted 130 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { 131 | UrlHander.call(this, urlData); 132 | } 133 | } else if (requestCode == PermissionUtil.MY_PERMISSIONS_REQUEST_SMS) { 134 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { 135 | UrlHander.sms(this, urlData); 136 | } 137 | } else if (requestCode == PermissionUtil.MY_PERMISSIONS_REQUEST_DOWNLOAD) { 138 | UrlHander.download(this, urlData, contentDisposition, mimeType); 139 | } else if (requestCode == PermissionUtil.MY_PERMISSIONS_REQUEST_GEOLOCATION) { 140 | 141 | } 142 | } 143 | 144 | @Override 145 | public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimeType, long l) { 146 | this.contentDisposition = contentDisposition; 147 | this.mimeType = mimeType; 148 | UrlHander.downloadLink(this, url, contentDisposition, mimeType); 149 | } 150 | public void showContent() { 151 | if (show_content) { 152 | PermissionUtil.checkPermissions(this, new String[]{android.Manifest.permission.RECORD_AUDIO, 153 | android.Manifest.permission.CALL_PHONE, 154 | android.Manifest.permission.SEND_SMS, 155 | android.Manifest.permission.ACCESS_NETWORK_STATE, 156 | android.Manifest.permission.WRITE_EXTERNAL_STORAGE, 157 | android.Manifest.permission.BLUETOOTH, 158 | android.Manifest.permission.ACCESS_FINE_LOCATION, 159 | android.Manifest.permission.ACCESS_COARSE_LOCATION, 160 | android.Manifest.permission.INTERNET 161 | }); 162 | show_content=false; 163 | mImageViewSplash.setVisibility(View.GONE); 164 | ProgressDialogHelper.dismissProgress(); 165 | } 166 | } 167 | public void hideStatusBar() { 168 | if (!TextUtils.isEmpty(getString(R.string.hide_status_bar))) { 169 | if (Build.VERSION.SDK_INT < 16) { 170 | getWindow().setFlags( 171 | WindowManager.LayoutParams.FLAG_FULLSCREEN, 172 | WindowManager.LayoutParams.FLAG_FULLSCREEN); 173 | } else { 174 | View decorView = getWindow().getDecorView(); 175 | int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN; 176 | decorView.setSystemUiVisibility(uiOptions); 177 | ActionBar actionBar = getActionBar(); 178 | if (actionBar != null) { 179 | actionBar.hide(); 180 | } 181 | } 182 | } 183 | } 184 | public void setToolbarButtonColor() { 185 | if (false) { 186 | if (webView.canGoBack()) { 187 | mBack.setColorFilter(ContextCompat.getColor(this, R.color.colorPrimary)); 188 | } else { 189 | mBack.setColorFilter(ContextCompat.getColor(this, R.color.gray)); 190 | } 191 | if (webView.canGoForward()) { 192 | mForward.setColorFilter(ContextCompat.getColor(this, R.color.colorPrimary)); 193 | } else { 194 | mForward.setColorFilter(ContextCompat.getColor(this, R.color.gray)); 195 | } 196 | } 197 | } 198 | } 199 | -------------------------------------------------------------------------------- /app/src/main/java/com/xiaoyunchengzhu/androidandh5/webviewpakage/SuperWebChromClient.java: -------------------------------------------------------------------------------- 1 | package com.xiaoyunchengzhu.androidandh5.webviewpakage; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.annotation.TargetApi; 5 | import android.content.Intent; 6 | import android.net.Uri; 7 | import android.os.Build; 8 | import android.os.Environment; 9 | import android.os.Message; 10 | import android.os.Parcelable; 11 | import android.provider.MediaStore; 12 | import android.util.Log; 13 | import android.webkit.CookieManager; 14 | import android.webkit.GeolocationPermissions; 15 | import android.webkit.JsResult; 16 | import android.webkit.ValueCallback; 17 | import android.webkit.WebChromeClient; 18 | import android.webkit.WebView; 19 | 20 | import java.io.File; 21 | import java.io.IOException; 22 | import java.text.SimpleDateFormat; 23 | import java.util.Date; 24 | 25 | public class SuperWebChromClient extends WebChromeClient { 26 | 27 | 28 | private WebViewActivity activity = null; 29 | private int FILECHOOSER_RESULTCODE = 0; 30 | private int REQUEST_SELECT_FILE = 0; 31 | private ValueCallback mUploadMessage; 32 | public SuperWebChromClient(WebViewActivity activity, int FILECHOOSER_RESULTCODE, int REQUEST_SELECT_FILE) { 33 | 34 | this.activity = activity; 35 | this.FILECHOOSER_RESULTCODE = FILECHOOSER_RESULTCODE; 36 | this.REQUEST_SELECT_FILE = REQUEST_SELECT_FILE; 37 | } 38 | 39 | @SuppressLint({"AddJavascriptInterface", "SetJavaScriptEnabled"}) 40 | @Override 41 | public boolean onCreateWindow(WebView view, boolean isDialog, 42 | boolean isUserGesture, Message resultMsg) { 43 | 44 | 45 | CookieManager cookieManager = CookieManager.getInstance(); 46 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 47 | cookieManager.setAcceptThirdPartyCookies(view, true); 48 | } else { 49 | cookieManager.setAcceptCookie(true); 50 | } 51 | CookieManager.setAcceptFileSchemeCookies(true); 52 | 53 | WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj; 54 | transport.setWebView(view); 55 | resultMsg.sendToTarget(); 56 | return super.onCreateWindow(view, isDialog, isUserGesture, resultMsg); 57 | } 58 | 59 | @Override 60 | public void onProgressChanged(WebView view, int newProgress) { 61 | super.onProgressChanged(view, newProgress); 62 | 63 | } 64 | 65 | @Override 66 | public void onCloseWindow(WebView window) { 67 | Log.v("TEST", "onCloseWindow"); 68 | } 69 | 70 | @Override 71 | public void onGeolocationPermissionsShowPrompt(final String origin, 72 | final GeolocationPermissions.Callback callback) { 73 | // Always grant permissionSelectFile since the app itself requires location 74 | // permissionSelectFile and the user has therefore already granted it 75 | PermissionUtil.geoLocationPermission(activity, origin, callback); 76 | } 77 | 78 | // openFileChooser for Android 3.0+ 79 | protected void openFileChooser(ValueCallback uploadMsg, String acceptType) { 80 | 81 | Log.i("accepttype",acceptType); 82 | activity.mUploadMessage = uploadMsg; 83 | File imageStorageDir = new File( 84 | Environment.getExternalStoragePublicDirectory( 85 | Environment.DIRECTORY_PICTURES) 86 | , "AndroidExampleFolder"); 87 | 88 | if (!imageStorageDir.exists()) { 89 | // Create AndroidExampleFolder at sdcard 90 | imageStorageDir.mkdirs(); 91 | } 92 | 93 | // Create camera captured image file path and name 94 | File file = new File( 95 | imageStorageDir + File.separator + "IMG_" 96 | + String.valueOf(System.currentTimeMillis()) 97 | + ".jpg"); 98 | Log.d("File", "File: " + file); 99 | activity.mCapturedImageURI = Uri.fromFile(file); 100 | 101 | // Camera capture image intent 102 | final Intent captureIntent = new Intent( 103 | android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 104 | 105 | captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, activity.mCapturedImageURI); 106 | 107 | Intent i = new Intent(Intent.ACTION_GET_CONTENT); 108 | i.addCategory(Intent.CATEGORY_OPENABLE); 109 | i.setType("image/*"); 110 | 111 | // Create file chooser intent 112 | Intent chooserIntent = Intent.createChooser(i, "Image Chooser"); 113 | 114 | // Set camera intent to file chooser 115 | chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS 116 | , new Parcelable[]{captureIntent}); 117 | 118 | // On select image call onActivityResult method of activity 119 | activity.startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE); 120 | 121 | 122 | } 123 | 124 | // For Lollipop 5.0+ Devices 125 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 126 | public boolean onShowFileChooser(WebView mWebView, ValueCallback filePathCallback, 127 | WebChromeClient.FileChooserParams fileChooserParams) { 128 | 129 | for (String type:fileChooserParams.getAcceptTypes()){ 130 | Log.i("accepttype",type); 131 | 132 | } 133 | String type=fileChooserParams.getAcceptTypes()[0]; 134 | if (activity.uploadMessage != null) { 135 | activity.uploadMessage.onReceiveValue(null); 136 | activity.uploadMessage = null; 137 | } 138 | // if () 139 | 140 | activity.uploadMessage = filePathCallback; 141 | Intent takePictureIntent=null; 142 | if (type.contains("image")){ 143 | takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 144 | }else if (type.contains("video")){ 145 | takePictureIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); 146 | }else { 147 | takePictureIntent=new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 148 | } 149 | if (takePictureIntent.resolveActivity(activity.getPackageManager()) != null) { 150 | // Create the File where the photo should go 151 | File photoFile = null; 152 | try { 153 | photoFile = createImageFile(); 154 | takePictureIntent.putExtra("PhotoPath", activity.mCameraPhotoPath); 155 | } catch (IOException ex) { 156 | // Error occurred while creating the File 157 | Log.e("TEST", "Unable to create Image File", ex); 158 | } 159 | 160 | // Continue only if the File was successfully created 161 | if (photoFile != null) { 162 | activity.mCameraPhotoPath = "file:" + photoFile.getAbsolutePath(); 163 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, 164 | Uri.fromFile(photoFile)); 165 | } else { 166 | takePictureIntent = null; 167 | } 168 | } 169 | 170 | Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); 171 | contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); 172 | contentSelectionIntent.setType(fileChooserParams.getAcceptTypes()[0]); 173 | 174 | Intent[] intentArray; 175 | if (takePictureIntent != null) { 176 | intentArray = new Intent[]{takePictureIntent}; 177 | } else { 178 | intentArray = new Intent[0]; 179 | } 180 | 181 | Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); 182 | chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); 183 | chooserIntent.putExtra(Intent.EXTRA_TITLE, type+" Chooser"); 184 | chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray); 185 | 186 | activity.startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE); 187 | 188 | return true; 189 | } 190 | 191 | private File createImageFile() throws IOException { 192 | // Create an image file name 193 | String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); 194 | String imageFileName = "JPEG_" + timeStamp + "_"; 195 | File storageDir = Environment.getExternalStoragePublicDirectory( 196 | Environment.DIRECTORY_PICTURES); 197 | File imageFile = File.createTempFile( 198 | imageFileName, /* prefix */ 199 | ".jpg", /* suffix */ 200 | storageDir /* directory */ 201 | ); 202 | return imageFile; 203 | } 204 | 205 | // openFileChooser for Android < 3.0 206 | public void openFileChooser(ValueCallback uploadMsg) { 207 | openFileChooser(uploadMsg, ""); 208 | } 209 | 210 | //For Android 4.1 only 211 | protected void openFileChooser(ValueCallback uploadMsg, String acceptType, String capture) { 212 | openFileChooser(uploadMsg, acceptType); 213 | } 214 | 215 | @Override 216 | public boolean onJsAlert(WebView view, String url, String message, JsResult result) { 217 | return super.onJsAlert(view, url, message, result); 218 | } 219 | 220 | } 221 | -------------------------------------------------------------------------------- /app/src/main/java/com/xiaoyunchengzhu/androidandh5/webviewpakage/WebViewManger.java: -------------------------------------------------------------------------------- 1 | package com.xiaoyunchengzhu.androidandh5.webviewpakage; 2 | 3 | import android.annotation.TargetApi; 4 | import android.app.Activity; 5 | import android.app.AlertDialog; 6 | import android.content.ClipData; 7 | import android.content.ClipboardManager; 8 | import android.content.DialogInterface; 9 | import android.content.Intent; 10 | import android.graphics.Bitmap; 11 | import android.graphics.BitmapFactory; 12 | import android.net.Uri; 13 | import android.os.Build; 14 | import android.os.Environment; 15 | import android.os.Handler; 16 | import android.util.Log; 17 | import android.view.Gravity; 18 | import android.view.LayoutInflater; 19 | import android.view.MotionEvent; 20 | import android.view.View; 21 | import android.view.ViewGroup; 22 | import android.webkit.CookieManager; 23 | import android.webkit.WebSettings; 24 | import android.webkit.WebView; 25 | import android.widget.Button; 26 | import android.widget.PopupWindow; 27 | import android.widget.SeekBar; 28 | import android.widget.Toast; 29 | 30 | import com.xiaoyunchengzhu.androidandh5.R; 31 | 32 | import java.io.BufferedInputStream; 33 | import java.io.File; 34 | import java.io.FileOutputStream; 35 | import java.io.IOException; 36 | import java.io.InputStream; 37 | import java.net.HttpURLConnection; 38 | import java.net.URL; 39 | import java.net.URLConnection; 40 | 41 | import static android.content.Context.CLIPBOARD_SERVICE; 42 | 43 | 44 | /** 45 | * Created by TL on 2016/5/31. 46 | */ 47 | public class WebViewManger implements View.OnClickListener{ 48 | 49 | private WebView webView; 50 | private WebViewActivity activity; 51 | 52 | public WebViewManger(WebViewActivity activity, WebView webView) { 53 | this.webView = webView; 54 | this.activity = activity; 55 | inite(); 56 | } 57 | 58 | //{"app":"TongLian","systemVersion":"8.0","systemPlatform":"android"} user-agent 59 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN) 60 | private void inite() { 61 | // webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); 62 | // webView.getSettings().setJavaScriptEnabled(true); 63 | // webView.getSettings().setAllowFileAccess(true); 64 | // webView.getSettings().setAllowFileAccessFromFileURLs(true); 65 | // webView.getSettings().setSupportZoom(true); 66 | // //添加useragent 67 | // String ua = webView.getSettings().getUserAgentString(); 68 | // webView.getSettings().setUserAgentString(ua + " " + ""); 69 | 70 | 71 | WebSettings webSettings=webView.getSettings(); 72 | webSettings.setJavaScriptEnabled(true); 73 | webSettings.setJavaScriptCanOpenWindowsAutomatically(true); 74 | webSettings.setSupportMultipleWindows(true); 75 | webSettings.setGeolocationEnabled(true); 76 | webSettings.setDomStorageEnabled(true); 77 | webSettings.setDatabaseEnabled(true); 78 | webSettings.setGeolocationEnabled(true); 79 | webSettings.setGeolocationDatabasePath(activity.getFilesDir().getPath()); 80 | webSettings.setLoadWithOverviewMode(true); 81 | webSettings.setAllowFileAccess(true); 82 | webSettings.setUserAgentString(webSettings.getUserAgentString()+" Android"); 83 | if (false) { 84 | webSettings.setAppCacheEnabled(true); 85 | webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL); 86 | webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); 87 | } 88 | 89 | 90 | //阻塞加载图片 91 | // webView.getSettings().setBlockNetworkImage(true); 92 | webView.setWebChromeClient(new SuperWebChromClient(activity, WebViewActivity.FILECHOOSER_RESULTCODE, WebViewActivity.REQUEST_SELECT_FILE)); 93 | webView.addJavascriptInterface(new AndroidToJs(activity, webView), "LocalNative"); 94 | setCookie(); 95 | imageInit(); 96 | } 97 | 98 | public void load(String url) { 99 | webView.loadUrl(url); 100 | } 101 | 102 | public void goBack() { 103 | webView.goBack(); 104 | } 105 | 106 | public boolean canGoBack() { 107 | return webView.canGoBack(); 108 | } 109 | void setCookie(){ 110 | CookieManager cookieManager = CookieManager.getInstance(); 111 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 112 | cookieManager.setAcceptThirdPartyCookies(webView, true); 113 | } else { 114 | cookieManager.setAcceptCookie(true); 115 | } 116 | CookieManager.setAcceptFileSchemeCookies(true); 117 | cookieManager.setCookie("www.chehngzhu.com","name:chengzhu;password:123456"); 118 | Log.i("cookie",cookieManager.getCookie("www.chehngzhu.com")); 119 | } 120 | private String picUrl=null; 121 | private int x,y; 122 | private PopupWindow mPopWindow; 123 | private 124 | void imageInit(){ 125 | mPopWindow=new PopupWindow(activity); 126 | View contentView = LayoutInflater.from(activity).inflate(R.layout.pop_img, null); 127 | mPopWindow = new PopupWindow(contentView, 128 | ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true); 129 | mPopWindow.setContentView(contentView); 130 | Button save= (Button) contentView.findViewById(R.id.btn_save); 131 | Button cp= (Button) contentView.findViewById(R.id.btn_cp); 132 | Button cancel= (Button) contentView.findViewById(R.id.btn_cancel); 133 | save.setOnClickListener(this); 134 | cp.setOnClickListener(this); 135 | cancel.setOnClickListener(this); 136 | webView.setOnTouchListener(new View.OnTouchListener() { 137 | @Override 138 | public boolean onTouch(View v, MotionEvent event) { 139 | x= (int) event.getX(); 140 | y= (int) event.getY(); 141 | return false; 142 | } 143 | }); 144 | 145 | webView.setOnLongClickListener(new View.OnLongClickListener() { 146 | @Override 147 | public boolean onLongClick(View view) { 148 | WebView.HitTestResult hitTestResult = webView.getHitTestResult(); 149 | // 如果是图片类型或者是带有图片链接的类型 150 | if (hitTestResult.getType() == WebView.HitTestResult.IMAGE_TYPE || 151 | hitTestResult.getType() == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) { 152 | picUrl = hitTestResult.getExtra(); 153 | mPopWindow.showAtLocation(webView, Gravity.TOP|Gravity.LEFT, x, y); 154 | return true; 155 | } 156 | return false; 157 | } 158 | }); 159 | } 160 | public void savePic(String url) { 161 | String[] str = picUrl.split("/"); 162 | String fileName = str[str.length - 1]; 163 | if (fileName.length()>20) { 164 | fileName=fileName.substring(fileName.length()-10,fileName.length()); 165 | } 166 | OkhttpDownloadFile.getInstance(activity,new Handler(activity.getMainLooper())).downloadFile(url,fileName); 167 | 168 | 169 | } 170 | private void saveBitmap(Bitmap bitmap) { 171 | File appDir = new File(Environment.getExternalStorageDirectory(), "com.xiaoyunchengzhu.androidandh5"); 172 | if (!appDir.exists()) { 173 | appDir.mkdir(); 174 | } 175 | String[] str = picUrl.split("/"); 176 | String fileName = str[str.length - 1]; 177 | if (fileName.length()>20) { 178 | fileName=fileName.substring(fileName.length()-10,fileName.length()); 179 | } 180 | File file = new File(appDir, fileName); 181 | if (!file.exists()){ 182 | try { 183 | file.createNewFile(); 184 | } catch (IOException e) { 185 | e.printStackTrace(); 186 | } 187 | } 188 | try { 189 | FileOutputStream fos = new FileOutputStream(file); 190 | bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos); 191 | fos.flush(); 192 | fos.close(); 193 | activity.runOnUiThread(new Runnable() { 194 | @Override 195 | public void run() { 196 | Toast.makeText(activity, "保存成功", Toast.LENGTH_SHORT).show(); 197 | } 198 | }); 199 | } catch (IOException e) { 200 | activity.runOnUiThread(new Runnable() { 201 | @Override 202 | public void run() { 203 | Toast.makeText(activity, "保存失败", Toast.LENGTH_SHORT).show(); 204 | } 205 | }); 206 | e.printStackTrace(); 207 | } 208 | } 209 | 210 | 211 | 212 | @Override 213 | public void onClick(View v) { 214 | switch (v.getId()){ 215 | //保存本地 216 | case R.id.btn_save: 217 | 218 | savePic(picUrl); 219 | mPopWindow.dismiss(); 220 | break; 221 | //复制粘贴板 222 | case R.id.btn_cp: 223 | ClipboardManager mClipboardManager = 224 | (ClipboardManager) activity.getSystemService(CLIPBOARD_SERVICE); 225 | ClipData mClipData; 226 | mClipData = ClipData.newPlainText("test", picUrl); 227 | mClipboardManager.setPrimaryClip(mClipData); 228 | Toast.makeText(activity, "复制成功", Toast.LENGTH_SHORT).show(); 229 | mPopWindow.dismiss(); 230 | break; 231 | case R.id.btn_cancel: 232 | if (mPopWindow!=null){ 233 | mPopWindow.dismiss(); 234 | } 235 | break; 236 | } 237 | } 238 | 239 | public WebView getWebView() { 240 | return webView; 241 | } 242 | } 243 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------