Skip to content

Commit d195af4

Browse files
committed
Initial commit
0 parents  commit d195af4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1351
-0
lines changed

.gitignore

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Built application files
2+
*.apk
3+
*.ap_
4+
5+
# Files for the ART/Dalvik VM
6+
*.dex
7+
8+
# Java class files
9+
*.class
10+
11+
# Generated files
12+
bin/
13+
gen/
14+
out/
15+
16+
# Gradle files
17+
.gradle/
18+
build/
19+
20+
# Local configuration file (sdk path, etc)
21+
local.properties
22+
23+
# Proguard folder generated by Eclipse
24+
proguard/
25+
26+
# Log Files
27+
*.log
28+
29+
# Android Studio Navigation editor temp files
30+
.navigation/
31+
32+
# Android Studio captures folder
33+
captures/
34+
35+
# IntelliJ
36+
*.iml
37+
.idea/
38+
39+
# External native build folder generated in Android Studio 2.2 and later
40+
.externalNativeBuild
41+
42+
# Google Services (e.g. APIs or Firebase)
43+
google-services.json

LICENSE.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Norsk Rikskringkasting (NRK)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Native Bridge Android
2+
3+
The Android library is written in Kotlin.
4+
5+
## Download
6+
Add the dependency to your app level build.gradle file:
7+
```java
8+
dependencies {
9+
compile 'no.nrk.nativebridge:nativebridge:1.0.0-SNAPSHOT'
10+
}
11+
```
12+
13+
Note that the library has a dependency on Jackson.
14+
15+
## Usage
16+
Instead of using ```android.webkit.WebView```, use ```no.nrk.NativeBridgeWebView```. If you're already extending ```WebView```, you must instead extend ```NativeBridgeWebView```.
17+
18+
Create classes implementing the ```TopicData.In``` and ```TopicData.Out``` interfaces. ```TopicData.In``` corresponds to the JSON received _from_ the webview, while ```TopicData.Out``` corresponds to the data we want to pass _to_ the webview.
19+
20+
Register a handler for the datatype, and you've successfully established a bridge between your app and the webview:
21+
```java
22+
webview.connection.addHandler("someTopic", { _ : SomeTopic.In, connection ->
23+
connection.send("someTopic", SomeTopic.Out("data"))
24+
}
25+
)
26+
```

build.gradle

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
3+
buildscript {
4+
ext.kotlin_version = '1.2.0'
5+
repositories {
6+
google()
7+
jcenter()
8+
}
9+
dependencies {
10+
classpath 'com.android.tools.build:gradle:3.0.1'
11+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
12+
13+
// NOTE: Do not place your application dependencies here; they belong
14+
// in the individual module build.gradle files
15+
}
16+
}
17+
18+
allprojects {
19+
repositories {
20+
google()
21+
jcenter()
22+
}
23+
}
24+
25+
task clean(type: Delete) {
26+
delete rootProject.buildDir
27+
}

gradle.properties

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
org.gradle.jvmargs=-Xmx1536m
2+
VERSION_NAME=1.0.0-SNAPSHOT
3+
VERSION_CODE=1
4+
GROUP=no.nrk.nativebridge
5+
6+
POM_DESCRIPTION=A RPC like bridge for communication between webviews and native apps
7+
POM_URL=https://github.com/nrkno/nativebridge-android
8+
POM_SCM_URL=https://github.com/nrkno/nativebridge-android
9+
POM_SCM_CONNECTION=scm:[email protected]:nrkno/nativebridge-android.git
10+
POM_SCM_DEV_CONNECTION=scm:[email protected]:nrkno/nativebridge-android.git
11+
12+
POM_LICENCE_NAME=MIT License
13+
POM_LICENCE_URL=http://opensource.org/licenses/MIT
14+
POM_LICENCE_DIST=repo
15+
16+
POM_DEVELOPER_ID=nrk
17+
POM_DEVELOPER_NAME=Norsk Rikskringkasting (NRK)
18+

gradle/gradle-mvn-push.gradle

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
* Copyright 2013 Chris Banes
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
apply plugin: 'maven'
18+
apply plugin: 'signing'
19+
20+
def isReleaseBuild() {
21+
return !VERSION_NAME.contains("SNAPSHOT")
22+
}
23+
24+
def getRepositoryUsername() {
25+
return hasProperty('SONATYPE_NEXUS_USERNAME') ? SONATYPE_NEXUS_USERNAME : ""
26+
}
27+
28+
def getRepositoryPassword() {
29+
return hasProperty('SONATYPE_NEXUS_PASSWORD') ? SONATYPE_NEXUS_PASSWORD : ""
30+
}
31+
32+
afterEvaluate { project ->
33+
uploadArchives {
34+
repositories {
35+
mavenDeployer {
36+
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
37+
38+
pom.groupId = GROUP
39+
pom.artifactId = POM_ARTIFACT_ID
40+
pom.version = VERSION_NAME
41+
42+
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
43+
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
44+
}
45+
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
46+
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
47+
}
48+
49+
pom.project {
50+
name POM_NAME
51+
packaging POM_PACKAGING
52+
description POM_DESCRIPTION
53+
url POM_URL
54+
55+
scm {
56+
url POM_SCM_URL
57+
connection POM_SCM_CONNECTION
58+
developerConnection POM_SCM_DEV_CONNECTION
59+
}
60+
61+
licenses {
62+
license {
63+
name POM_LICENCE_NAME
64+
url POM_LICENCE_URL
65+
distribution POM_LICENCE_DIST
66+
}
67+
}
68+
69+
developers {
70+
developer {
71+
id POM_DEVELOPER_ID
72+
name POM_DEVELOPER_NAME
73+
}
74+
}
75+
}
76+
}
77+
}
78+
}
79+
80+
signing {
81+
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
82+
sign configurations.archives
83+
}
84+
85+
task androidSourcesJar(type: Jar) {
86+
classifier = 'sources'
87+
from android.sourceSets.main.java.sourceFiles
88+
}
89+
90+
artifacts {
91+
archives androidSourcesJar
92+
}
93+
}

gradle/wrapper/gradle-wrapper.jar

52.4 KB
Binary file not shown.
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Fri Nov 10 15:05:43 CET 2017
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

0 commit comments

Comments
 (0)