android service and notifications #167

Merged
sarah merged 12 commits from androidservice into trunk 2021-06-11 22:25:55 +00:00
3 changed files with 18 additions and 14 deletions
Showing only changes of commit 6972028ecf - Show all commits

View File

@ -111,4 +111,9 @@ dependencies {
// optional - Multiprocess support
implementation "androidx.work:work-multiprocess:2.5.0"
// end of workmanager deps
// ipc
implementation "io.reactivex:rxkotlin:1.x.y"
}

View File

@ -7,25 +7,17 @@ import android.content.Context
import android.graphics.Color
import android.os.Build
import android.util.Log
import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat
import androidx.work.CoroutineWorker
import androidx.work.Data
import androidx.work.ForegroundInfo
import androidx.work.WorkerParameters
import androidx.work.WorkManager
import androidx.work.*
import cwtch.Cwtch
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import org.json.JSONObject
import cwtch.Cwtch
class FlwtchWorker(context: Context, parameters: WorkerParameters) :
Review

lol maybe now is a good time to rename test.flutter.dev/eventBut here and in gomobile.dart

lol maybe now is a good time to rename test.flutter.dev/eventBut here and in gomobile.dart
CoroutineWorker(context, parameters) {
@ -67,7 +59,11 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) :
Log.i("FlwtchWorker.kt", "COROUTINEWORKER DOT ISSTOPPED TRUE OH MY")
}
//todo: this elides evt.EventID which may be needed at some point?
val data = Data.Builder().putString("EventType", evt.EventType).putString("Data", evt.Data).build()
val data = Data.Builder()
.putString("EventType", evt.EventType)
.putString("Data", evt.Data)
.putString("EventID", evt.EventID)
Review

delete?

delete?
.build()
setProgress(data)
Thread.sleep(200)
}

View File

@ -77,7 +77,7 @@ class MainActivity: FlutterActivity() {
WorkManager.getInstance(applicationContext)
// requestId is the WorkRequest id
.getWorkInfosByTagLiveData("cwtchEventBus")
.observeForever(Observer<List<WorkInfo>> { listOfWorkInfo ->
.observe(this, Observer<List<WorkInfo>> { listOfWorkInfo ->
if (listOfWorkInfo.isNullOrEmpty()) {
return@Observer
}
@ -87,9 +87,12 @@ class MainActivity: FlutterActivity() {
val progress = workInfo.progress
val eventType = progress.getString("EventType") ?: ""
val eventData = progress.getString("Data")
Log.i("MainActivity.kt", "got event $progress $eventType $eventData")
val output = progress.keyValueMap.toString()
try {
eventbus_chan.invokeMethod(eventType, eventData)
if (eventType != "") {
Log.i("MainActivity.kt", "got event $output $eventType $eventData")
eventbus_chan.invokeMethod(eventType, eventData)
}
} catch (e: Exception) {
Log.i("MainActivity.kt", "event bus exception")
}