feat(notification): add plugin (#326)

This commit is contained in:
Lucas Fernandes Nogueira
2023-05-02 09:09:50 -07:00
committed by GitHub
parent 864b9d790f
commit e9bbe94181
34 changed files with 1536 additions and 8 deletions
@@ -0,0 +1,24 @@
package app.tauri.notification
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("app.tauri.notification", appContext.packageName)
}
}
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
@@ -0,0 +1,31 @@
package app.tauri.notification
import android.app.Activity
import app.tauri.annotation.Command
import app.tauri.annotation.TauriPlugin
import app.tauri.plugin.JSObject
import app.tauri.plugin.Plugin
import app.tauri.plugin.Invoke
@TauriPlugin
class NotificationPlugin(private val activity: Activity): Plugin(activity) {
@Command
fun requestPermission(invoke: Invoke) {
val ret = JSObject()
ret.put("permissionState", "granted")
invoke.resolve(ret)
}
@Command
fun permissionState(invoke: Invoke) {
val ret = JSObject()
ret.put("permissionState", "granted")
invoke.resolve(ret)
}
@Command
fun notify(invoke: Invoke) {
// TODO
invoke.resolve()
}
}
@@ -0,0 +1,17 @@
package app.tauri.notification
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}