diff --git a/.gitignore b/.gitignore index 144609d..36f2735 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1 @@ -*.iml -.gradle -/gradle/wrapper/*.zip -/local.properties -.DS_Store -/build -.idea +/javascrpit/demo/node_modules/ diff --git a/android/.gitignore b/android/.gitignore new file mode 100644 index 0000000..144609d --- /dev/null +++ b/android/.gitignore @@ -0,0 +1,7 @@ +*.iml +.gradle +/gradle/wrapper/*.zip +/local.properties +.DS_Store +/build +.idea diff --git a/build.gradle b/android/build.gradle similarity index 58% rename from build.gradle rename to android/build.gradle index 4ff022f..195f199 100644 --- a/build.gradle +++ b/android/build.gradle @@ -1,12 +1,14 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { + ext.kotlin_version = '2.0.21' repositories { - jcenter() + maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' } google() } dependencies { - classpath 'com.android.tools.build:gradle:3.6.2' + classpath 'com.android.tools.build:gradle:8.8.2' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" //classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -15,7 +17,8 @@ buildscript { allprojects { repositories { - jcenter() + maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' } google() } } + diff --git a/example/.gitignore b/android/example/.gitignore similarity index 100% rename from example/.gitignore rename to android/example/.gitignore diff --git a/android/example/build.gradle b/android/example/build.gradle new file mode 100644 index 0000000..2ea079c --- /dev/null +++ b/android/example/build.gradle @@ -0,0 +1,35 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' + +android { + compileSdk 35 + defaultConfig { + minSdkVersion 23 + targetSdkVersion 35 + versionCode 1 + versionName '1.0' + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + namespace 'com.orientsec.jsbridge.example' + compileOptions { + sourceCompatibility JavaVersion.VERSION_18 + targetCompatibility JavaVersion.VERSION_18 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_18.toString() + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation project(':library') + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation "androidx.webkit:webkit:1.6.1" +} diff --git a/example/proguard-rules.pro b/android/example/proguard-rules.pro similarity index 100% rename from example/proguard-rules.pro rename to android/example/proguard-rules.pro diff --git a/example/src/main/AndroidManifest.xml b/android/example/src/main/AndroidManifest.xml similarity index 60% rename from example/src/main/AndroidManifest.xml rename to android/example/src/main/AndroidManifest.xml index 05a481e..f2f00f5 100644 --- a/example/src/main/AndroidManifest.xml +++ b/android/example/src/main/AndroidManifest.xml @@ -1,15 +1,15 @@ - + - + + android:exported="true"> diff --git a/android/example/src/main/java/com/orientsec/jsbridge/example/MainActivity.kt b/android/example/src/main/java/com/orientsec/jsbridge/example/MainActivity.kt new file mode 100644 index 0000000..1b563f7 --- /dev/null +++ b/android/example/src/main/java/com/orientsec/jsbridge/example/MainActivity.kt @@ -0,0 +1,65 @@ +package com.orientsec.jsbridge.example + +import android.annotation.SuppressLint +import android.app.Activity +import android.os.Bundle +import android.util.Log +import android.view.View +import android.webkit.WebView +import android.webkit.WebViewClient +import android.widget.Button +import android.widget.Toast +import com.orientsec.jsbridge.* + +class MainActivity : Activity(), View.OnClickListener { + private lateinit var webView: BridgeWebView + + @SuppressLint("SetJavaScriptEnabled") + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + WebView.setWebContentsDebuggingEnabled(true) + JsBridge.debug = true + webView = findViewById(R.id.webView) + val settings = webView.settings + settings.javaScriptEnabled = true + val button = findViewById