Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

252 changes: 252 additions & 0 deletions .idea/other.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 10 additions & 17 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# This option should only be used with decoupled projects. For more details, visit
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.disableAutomaticComponentCreation=true
android.nonTransitiveRClass=true
android.useAndroidX=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.disableAutomaticComponentCreation=true
org.gradle.jvmargs=-Xmx1536M -Dkotlin.daemon.jvm.options\="-Xmx1024M" -Dfile.encoding\=UTF-8
3 changes: 3 additions & 0 deletions metamask-android-sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ dependencies {
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.6.1"

testImplementation 'junit:junit:4.13.2'
testImplementation 'org.robolectric:robolectric:4.10.3'
testImplementation 'org.mockito:mockito-core:4.0.0'
testImplementation 'org.mockito.kotlin:mockito-kotlin:4.0.0'
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.0'

androidTestImplementation 'androidx.test.ext:junit:1.2.1'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.metamask.androidsdk

import android.os.Bundle
import io.metamask.nativesdk.IMessegeServiceCallback

open class ClientMessageServiceCallback(
var onMessage: ((Bundle) -> Unit)? = null
) : IMessegeServiceCallback.Stub() {
override fun onMessageReceived(bundle: Bundle) {
onMessage?.invoke(bundle)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package io.metamask.androidsdk

import android.content.ComponentName
import android.content.ServiceConnection
import android.os.Bundle
import android.os.IBinder
import io.metamask.nativesdk.IMessegeService
import io.metamask.nativesdk.IMessegeServiceCallback

open class ClientServiceConnection(
var onConnected: (() -> Unit)? = null,
var onDisconnected: ((ComponentName?) -> Unit)? = null,
var onBindingDied: ((ComponentName?) -> Unit)? = null,
var onNullBinding: ((ComponentName?) -> Unit)? = null
) : ServiceConnection {
private var messageService: IMessegeService? = null

override fun onServiceConnected(name: ComponentName?, service: IBinder?) {
messageService = IMessegeService.Stub.asInterface(service)
onConnected?.invoke()
}

override fun onServiceDisconnected(name: ComponentName?) {
onDisconnected?.invoke(name)
}

override fun onBindingDied(name: ComponentName?) {
onBindingDied?.invoke(name)
}

override fun onNullBinding(name: ComponentName?) {
onNullBinding?.invoke(name)
}

open fun registerCallback(callback: IMessegeServiceCallback) {
messageService?.registerCallback(callback)
}

open fun sendMessage(bundle: Bundle) {
messageService?.sendMessage(bundle)
}
}
Loading