├── app ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── colors.xml │ │ │ └── themes.xml │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.webp │ │ │ └── ic_launcher_round.webp │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.webp │ │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.webp │ │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.webp │ │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.webp │ │ │ └── ic_launcher_round.webp │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ ├── layout │ │ │ ├── activity_user_info.xml │ │ │ ├── activity_main.xml │ │ │ ├── activity_first.xml │ │ │ └── activity_second.xml │ │ ├── values-night │ │ │ └── themes.xml │ │ ├── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ └── drawable │ │ │ └── ic_launcher_background.xml │ │ ├── java │ │ └── site │ │ │ └── exciter │ │ │ └── mentosweb │ │ │ ├── MessageEvent.kt │ │ │ ├── FirstActivity.kt │ │ │ ├── SecondActivity.kt │ │ │ ├── MainActivity.kt │ │ │ ├── UserInfoActivity.kt │ │ │ ├── GlobalApplication.kt │ │ │ └── command │ │ │ ├── ShowToastCommand.kt │ │ │ ├── OpenPageCommand.kt │ │ │ └── UserInfoCommand.kt │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── mentosweb ├── .gitignore ├── consumer-rules.pro ├── src │ └── main │ │ ├── res │ │ ├── drawable │ │ │ └── ic_back_arrow.png │ │ ├── values │ │ │ └── strings.xml │ │ └── layout │ │ │ ├── fragment_mentos_webview.xml │ │ │ └── activity_mentos_webview.xml │ │ ├── java │ │ └── site │ │ │ └── exciter │ │ │ └── mentosweb │ │ │ ├── entity │ │ │ └── JsParam.kt │ │ │ ├── webview │ │ │ ├── MWebViewCallback.kt │ │ │ ├── MWebChromeClient.kt │ │ │ ├── MWebViewClient.kt │ │ │ ├── MWebViewSettings.kt │ │ │ └── MentosWebView.kt │ │ │ ├── MentosWebConfig.kt │ │ │ ├── constant │ │ │ └── MentosConstant.kt │ │ │ ├── command │ │ │ ├── Command.kt │ │ │ └── CommandDispatcher.kt │ │ │ ├── mainprocess │ │ │ ├── MainProcessCommandService.kt │ │ │ └── MainProcessCommandManager.kt │ │ │ ├── MentosWeb.kt │ │ │ └── ui │ │ │ ├── MentosWebViewActivity.kt │ │ │ └── MentosWebViewFragment.kt │ │ ├── aidl │ │ └── site │ │ │ └── exciter │ │ │ └── mentosweb │ │ │ ├── ICallbackFromMainprocessToWebViewProcessInterface.aidl │ │ │ └── IWebViewProcessToMainProcessInterface.aidl │ │ ├── AndroidManifest.xml │ │ └── assets │ │ ├── js │ │ └── MentosWeb.js │ │ └── demo.html ├── proguard-rules.pro └── build.gradle ├── .idea ├── .gitignore ├── compiler.xml ├── jarRepositories.xml ├── misc.xml ├── inspectionProfiles │ └── Project_Default.xml └── dbnavigator.xml ├── images ├── demo1.gif ├── demo2.gif ├── MentosWeb.png └── MentosWebArchitecture.png ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── README.md ├── .gitignore ├── gradlew.bat ├── publish.gradle ├── gradlew └── LICENSE /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /mentosweb/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /mentosweb/consumer-rules.pro: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /images/demo1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mushui-x/MentosWeb/HEAD/images/demo1.gif -------------------------------------------------------------------------------- /images/demo2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mushui-x/MentosWeb/HEAD/images/demo2.gif -------------------------------------------------------------------------------- /images/MentosWeb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mushui-x/MentosWeb/HEAD/images/MentosWeb.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "MentosWeb" 2 | include ':app' 3 | include ':mentosweb' 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | MentosWeb 3 | -------------------------------------------------------------------------------- /images/MentosWebArchitecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mushui-x/MentosWeb/HEAD/images/MentosWebArchitecture.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mushui-x/MentosWeb/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mushui-x/MentosWeb/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mushui-x/MentosWeb/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mushui-x/MentosWeb/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mushui-x/MentosWeb/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mushui-x/MentosWeb/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /mentosweb/src/main/res/drawable/ic_back_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mushui-x/MentosWeb/HEAD/mentosweb/src/main/res/drawable/ic_back_arrow.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mushui-x/MentosWeb/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mushui-x/MentosWeb/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mushui-x/MentosWeb/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mushui-x/MentosWeb/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mushui-x/MentosWeb/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /mentosweb/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello blank fragment 4 | -------------------------------------------------------------------------------- /mentosweb/src/main/java/site/exciter/mentosweb/entity/JsParam.kt: -------------------------------------------------------------------------------- 1 | package site.exciter.mentosweb.entity 2 | 3 | import com.google.gson.JsonObject 4 | 5 | data class JsParam(val name: String, val param: JsonObject) 6 | -------------------------------------------------------------------------------- /mentosweb/src/main/aidl/site/exciter/mentosweb/ICallbackFromMainprocessToWebViewProcessInterface.aidl: -------------------------------------------------------------------------------- 1 | package site.exciter.mentosweb; 2 | 3 | interface ICallbackFromMainprocessToWebViewProcessInterface { 4 | void onResult(String callbacId, String response); 5 | } 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jan 21 11:41:26 CST 2022 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /mentosweb/src/main/java/site/exciter/mentosweb/webview/MWebViewCallback.kt: -------------------------------------------------------------------------------- 1 | package site.exciter.mentosweb.webview 2 | 3 | interface MWebViewCallback { 4 | fun onPageStarted() 5 | fun onPageFinished() 6 | fun onProgressChanged(progress: Int) 7 | fun onError() 8 | fun onUpdateTitle(title: String) 9 | } -------------------------------------------------------------------------------- /app/src/main/java/site/exciter/mentosweb/MessageEvent.kt: -------------------------------------------------------------------------------- 1 | package site.exciter.mentosweb 2 | 3 | /** 4 | * 5 | * @Description: MessageEvent 6 | * @Author: ZhangJie 7 | * @CreateDate: 2022/1/19 1:41 下午 8 | */ 9 | data class MessageEvent(val code: Int, val message: String) 10 | 11 | const val USER_INFO_CODE = 1 12 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /mentosweb/src/main/aidl/site/exciter/mentosweb/IWebViewProcessToMainProcessInterface.aidl: -------------------------------------------------------------------------------- 1 | package site.exciter.mentosweb; 2 | import site.exciter.mentosweb.ICallbackFromMainprocessToWebViewProcessInterface; 3 | 4 | interface IWebViewProcessToMainProcessInterface { 5 | void handleWebCommand(String commandName, String jsonParams, in ICallbackFromMainprocessToWebViewProcessInterface callback); 6 | } 7 | -------------------------------------------------------------------------------- /app/src/main/java/site/exciter/mentosweb/FirstActivity.kt: -------------------------------------------------------------------------------- 1 | package site.exciter.mentosweb 2 | 3 | import androidx.appcompat.app.AppCompatActivity 4 | import android.os.Bundle 5 | 6 | class FirstActivity : AppCompatActivity() { 7 | override fun onCreate(savedInstanceState: Bundle?) { 8 | super.onCreate(savedInstanceState) 9 | setContentView(R.layout.activity_first) 10 | } 11 | } -------------------------------------------------------------------------------- /app/src/main/java/site/exciter/mentosweb/SecondActivity.kt: -------------------------------------------------------------------------------- 1 | package site.exciter.mentosweb 2 | 3 | import androidx.appcompat.app.AppCompatActivity 4 | import android.os.Bundle 5 | 6 | class SecondActivity : AppCompatActivity() { 7 | override fun onCreate(savedInstanceState: Bundle?) { 8 | super.onCreate(savedInstanceState) 9 | setContentView(R.layout.activity_second) 10 | } 11 | } -------------------------------------------------------------------------------- /mentosweb/src/main/java/site/exciter/mentosweb/MentosWebConfig.kt: -------------------------------------------------------------------------------- 1 | package site.exciter.mentosweb 2 | 3 | import android.graphics.Color 4 | 5 | /** 6 | * 7 | * @Description: 配置 8 | * @Author: ZhangJie 9 | * @CreateDate: 2022/1/20 3:07 下午 10 | */ 11 | 12 | object MentosWebConfig { 13 | var REFRESH_SCHEME_COLORS = intArrayOf(Color.parseColor("#ff00CC99")) 14 | var PROGRESS_BAR_COLOR: Int = Color.parseColor("#ff00CC99") 15 | } -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /mentosweb/src/main/java/site/exciter/mentosweb/constant/MentosConstant.kt: -------------------------------------------------------------------------------- 1 | package site.exciter.mentosweb.constant 2 | 3 | const val MENTOS_WEB_URL = "web_url" 4 | const val MENTOS_WEB_TITLE = "web_title" 5 | const val MENTOS_WEB_ENABLE_ACTION_BAR = "web_enable_action_bar" 6 | const val MENTOS_WEB_ENABLE_NATIVE_REFRESH = "web_enable_native_refresh" 7 | const val MENTOS_WEB_PROGRESS_BAR_STARTCOLOR="" 8 | 9 | const val MENTOS_WEB_LOG_TAG = "MentosWebView" -------------------------------------------------------------------------------- /mentosweb/src/main/java/site/exciter/mentosweb/command/Command.kt: -------------------------------------------------------------------------------- 1 | package site.exciter.mentosweb.command 2 | 3 | import site.exciter.mentosweb.ICallbackFromMainprocessToWebViewProcessInterface 4 | 5 | /** 6 | * 7 | * @Description: Command 8 | * @Author: ZhangJie 9 | * @CreateDate: 2022/1/19 11:18 上午 10 | */ 11 | interface Command { 12 | fun name(): String 13 | fun execute( 14 | parameters: Map<*, *>, 15 | callback: ICallbackFromMainprocessToWebViewProcessInterface? 16 | ) 17 | } -------------------------------------------------------------------------------- /mentosweb/src/main/java/site/exciter/mentosweb/mainprocess/MainProcessCommandService.kt: -------------------------------------------------------------------------------- 1 | package site.exciter.mentosweb.mainprocess 2 | 3 | import android.app.Service 4 | import android.content.Intent 5 | import android.os.IBinder 6 | 7 | /** 8 | * 9 | * @Description: 主进程命令处理服务 10 | * @Author: ZhangJie 11 | * @CreateDate: 2022/1/19 11:32 上午 12 | */ 13 | class MainProcessCommandService : Service() { 14 | override fun onBind(intent: Intent?): IBinder? { 15 | return MainProcessCommandManager.asBinder() 16 | } 17 | } -------------------------------------------------------------------------------- /mentosweb/src/main/java/site/exciter/mentosweb/webview/MWebChromeClient.kt: -------------------------------------------------------------------------------- 1 | package site.exciter.mentosweb.webview 2 | 3 | import android.webkit.WebChromeClient 4 | import android.webkit.WebView 5 | 6 | class MWebChromeClient(private val callback: MWebViewCallback) : WebChromeClient() { 7 | 8 | override fun onReceivedTitle(view: WebView?, title: String?) { 9 | title?.let { callback.onUpdateTitle(title) } 10 | } 11 | 12 | override fun onProgressChanged(view: WebView?, newProgress: Int) { 13 | callback.onProgressChanged(newProgress) 14 | } 15 | } -------------------------------------------------------------------------------- /mentosweb/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/java/site/exciter/mentosweb/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package site.exciter.mentosweb 2 | 3 | import androidx.appcompat.app.AppCompatActivity 4 | import android.os.Bundle 5 | import kotlinx.android.synthetic.main.activity_main.* 6 | 7 | class MainActivity : AppCompatActivity() { 8 | override fun onCreate(savedInstanceState: Bundle?) { 9 | super.onCreate(savedInstanceState) 10 | setContentView(R.layout.activity_main) 11 | 12 | button1.setOnClickListener { 13 | MentosWeb.startWebActivity(this, "https://www.baidu.com", "WebView") 14 | } 15 | button2.setOnClickListener { 16 | MentosWeb.startWebActivity(this, "file:///android_asset/demo.html", "WebView") 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /app/src/main/java/site/exciter/mentosweb/UserInfoActivity.kt: -------------------------------------------------------------------------------- 1 | package site.exciter.mentosweb 2 | 3 | import androidx.appcompat.app.AppCompatActivity 4 | import android.os.Bundle 5 | import android.util.Log 6 | import kotlinx.android.synthetic.main.activity_user_info.* 7 | import org.greenrobot.eventbus.EventBus 8 | 9 | class UserInfoActivity : AppCompatActivity() { 10 | override fun onCreate(savedInstanceState: Bundle?) { 11 | super.onCreate(savedInstanceState) 12 | setContentView(R.layout.activity_user_info) 13 | 14 | button.setOnClickListener { 15 | //模拟获取用户信息 16 | EventBus.getDefault().post(MessageEvent(USER_INFO_CODE, "---MentosWeb---")) 17 | finish() 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /app/src/main/java/site/exciter/mentosweb/GlobalApplication.kt: -------------------------------------------------------------------------------- 1 | package site.exciter.mentosweb 2 | 3 | import android.app.Application 4 | import android.graphics.Color 5 | 6 | /** 7 | * 8 | * @Description: GlobalApplication 9 | * @Author: ZhangJie 10 | * @CreateDate: 2022/1/19 12:43 下午 11 | */ 12 | class GlobalApplication : Application() { 13 | 14 | companion object { 15 | var mApplication: Application? = null 16 | } 17 | 18 | override fun onCreate() { 19 | super.onCreate() 20 | mApplication = this 21 | MentosWeb.init(this) 22 | .setProgressBarColor(Color.parseColor("#ff00CC99")) 23 | .setRefreshSchemeColors(Color.parseColor("#ff00CC99"), Color.parseColor("#FFFF6155")) 24 | } 25 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /mentosweb/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_user_info.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 |