Skip to content

Commit 5a176c3

Browse files
committed
webview plugin implemented
1 parent 2b11ef9 commit 5a176c3

File tree

22 files changed

+547
-3
lines changed

22 files changed

+547
-3
lines changed

.idea/gradle.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ dependencies {
4545

4646

4747
implementation project(':pluginbasicutils')
48+
implementation project(':pluginwebview')
4849

4950

5051
testImplementation 'junit:junit:4.13.2'

app/src/main/java/com/arupakaman/unitypluginsapp/MainActivity.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import android.os.Bundle
55
import android.widget.Button
66
import android.widget.TextView
77
import com.arupakaman.pluginbasicutils.unity.UnityUtils
8+
import com.arupakaman.pluginwebview.WebViewActivity
89

910
class MainActivity : AppCompatActivity() {
1011
override fun onCreate(savedInstanceState: Bundle?) {
@@ -29,5 +30,7 @@ class MainActivity : AppCompatActivity() {
2930
tvHello.text = result
3031
}
3132

33+
WebViewActivity.startWebViewActivity(this, "My GitHub Profile", "https://github.com/Noddy20", isToolbarEnabled = false)
34+
3235
}
3336
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ buildscript {
1414
}
1515
dependencies {
1616
classpath 'com.android.tools.build:gradle:4.2.0'
17-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin"
17+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
1818

1919
// NOTE: Do not place your application dependencies here; they belong
2020
// in the individual module build.gradle files

pluginbasicutils/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ dependencies {
3434
compileOnly fileTree(dir: "libs", include: ["*.jar"])
3535

3636
implementation 'androidx.core:core-ktx:1.7.0'
37-
implementation 'androidx.appcompat:appcompat:1.4.1'
38-
implementation 'com.google.android.material:material:1.5.0'
37+
//implementation 'androidx.appcompat:appcompat:1.4.1'
38+
//implementation 'com.google.android.material:material:1.5.0'
3939

4040

4141
testImplementation 'junit:junit:4.13.2'

pluginwebview/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

pluginwebview/build.gradle

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
plugins {
2+
id 'com.android.library'
3+
id 'org.jetbrains.kotlin.android'
4+
}
5+
6+
android {
7+
compileSdk compileTargetSDK
8+
9+
defaultConfig {
10+
minSdkVersion 17
11+
targetSdk compileTargetSDK
12+
13+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
14+
consumerProguardFiles "consumer-rules.pro"
15+
}
16+
17+
buildTypes {
18+
release {
19+
minifyEnabled false
20+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21+
}
22+
}
23+
compileOptions {
24+
sourceCompatibility JavaVersion.VERSION_1_8
25+
targetCompatibility JavaVersion.VERSION_1_8
26+
}
27+
kotlinOptions {
28+
jvmTarget = '1.8'
29+
}
30+
}
31+
32+
dependencies {
33+
//implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
34+
35+
//Use compileOnly otherwise will throw error
36+
compileOnly fileTree(dir: "libs", include: ["*.jar"])
37+
38+
implementation 'androidx.core:core-ktx:1.7.0'
39+
implementation 'androidx.appcompat:appcompat:1.4.1'
40+
implementation 'com.google.android.material:material:1.5.0'
41+
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
42+
43+
44+
testImplementation 'junit:junit:4.13.2'
45+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
46+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
47+
}

pluginwebview/consumer-rules.pro

Whitespace-only changes.

pluginwebview/libs/classes.jar

90.3 KB
Binary file not shown.

pluginwebview/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.arupakaman.pluginwebview
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("com.arupakaman.pluginwebview.test", appContext.packageName)
23+
}
24+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.arupakaman.pluginwebview">
4+
5+
<uses-permission android:name="android.permission.INTERNET" />
6+
7+
<application>
8+
9+
<!-- Override this activity in your Unity project Manifest for customization -->
10+
<activity
11+
android:name=".WebViewActivity"
12+
android:exported="true"
13+
android:launchMode="singleTask"
14+
android:theme="@style/Theme.WebViewTheme"
15+
>
16+
<!-- Customize the host and pathPrefix in your Unity project Manifest file (override the <activity>) for deep link handling, like below example -->
17+
<!--<intent-filter>
18+
<action android:name="android.intent.action.VIEW" />
19+
<category android:name="android.intent.category.DEFAULT" />
20+
<category android:name="android.intent.category.BROWSABLE" />
21+
22+
<data android:scheme="https"/>
23+
<data android:scheme="http"/>
24+
<data android:host="github.com"/>
25+
<data android:pathPrefix="/Noddy20"/>
26+
27+
</intent-filter>-->
28+
</activity>
29+
</application>
30+
31+
</manifest>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.arupakaman.pluginwebview
2+
3+
import android.util.Log
4+
import com.unity3d.player.UnityPlayer
5+
import org.json.JSONObject
6+
7+
internal object UnityBridge {
8+
9+
private val TAG by lazy { "BaseUnityBridge" }
10+
11+
@JvmStatic
12+
fun sendMessage(unityObjectName: String, unityMethodName: String, msg: String) {
13+
kotlin.runCatching {
14+
UnityPlayer.UnitySendMessage(unityObjectName, unityMethodName, msg)
15+
}.onFailure {
16+
Log.e(TAG, "sendMessage Exc $it")
17+
}
18+
}
19+
20+
@JvmStatic
21+
fun sendObject(unityObjectName: String, unityMethodName: String, msg: JSONObject) {
22+
kotlin.runCatching {
23+
UnityPlayer.UnitySendMessage(unityObjectName, unityMethodName, msg.toString())
24+
}.onFailure {
25+
Log.e(TAG, "sendMessage Exc $it")
26+
}
27+
}
28+
29+
}

0 commit comments

Comments
 (0)