remove debugging cruft

This commit is contained in:
erinn 2021-06-11 14:51:35 -07:00
parent 37996b5d96
commit 97f1e43009
5 changed files with 8 additions and 49 deletions

View File

@ -19,8 +19,6 @@ import org.json.JSONObject
class FlwtchWorker(context: Context, parameters: WorkerParameters) :
CoroutineWorker(context, parameters) {
private val CWTCH_EVENTBUS = "test.flutter.dev/eventBus"
private val notificationManager =
context.getSystemService(Context.NOTIFICATION_SERVICE) as
NotificationManager
@ -33,9 +31,8 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) :
?: return Result.failure()
val args = inputData.getString(KEY_ARGS)
?: return Result.failure()
Log.i("FlwtchWorker.kt", "got call $method with args $args")
// Mark the Worker as important
val progress = "Trying to do a Flwtch"
val progress = "Trying to do a Flwtch"//todo:translate
setForeground(createForegroundInfo(progress))
return handleCwtch(method, args)
}
@ -62,20 +59,8 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) :
// infinite coroutine :)
while(true) {
val evt = MainActivity.AppbusEvent(Cwtch.getAppBusEvent())
//Log.i("FlwtchWorker.kt", "got appbusEvent: " + evt)
if (isStopped) {
Log.i("FlwtchWorker.kt", "COROUTINEWORKER DOT ISSTOPPED TRUE OH MY")
}
if (evt.EventType == "NewMessageFromPeer") {
val data = JSONObject(evt.Data)
// val appProcesses: List<ActivityManager.RunningAppProcessInfo> = (applicationContext.getSystemService(ACTIVITY_SERVICE) as ActivityManager).runningAppProcesses
// for (appProcess in appProcesses) {
// if (appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
// Log.i("Foreground App", appProcess.processName)
// }
// }
val channelId =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
createMessageNotificationChannel(data.getString("RemotePeer"), data.getString("RemotePeer"))
@ -90,8 +75,7 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) :
val fh = applicationContext.assets.open(key)
val clickIntent = Intent(applicationContext, MainActivity::class.java).also { intent ->
intent.setAction(Intent.ACTION_RUN)//("im.cwtch.flwtch.broadcast.SERVICE_EVENT_BUS")
//intent.setClassName("im.cwtch.flwtch", "MainActivity")
intent.setAction(Intent.ACTION_RUN)
intent.putExtra("EventType", "NotificationClicked")
intent.putExtra("ProfileOnion", data.getString("ProfileOnion"))
intent.putExtra("RemotePeer", data.getString("RemotePeer"))
@ -107,14 +91,7 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) :
.build()
notificationManager.notify(getNotificationID(data.getString("ProfileOnion"), data.getString("RemotePeer")), newNotification)
}
//todo: this elides evt.EventID which may be needed at some point?
// val data = Data.Builder()
// .putString("EventType", evt.EventType)
// .putString("Data", evt.Data)
// .putString("EventID", evt.EventID)
// .build()
//setProgress(data)//progress can only hold a single undelivered value so it's possible for observers to miss rapidfire updates
//Thread.sleep(200)//this is a kludge to make it mostly-work until a proper channel is implemented
Intent().also { intent ->
intent.setAction("im.cwtch.flwtch.broadcast.SERVICE_EVENT_BUS")
intent.putExtra("EventType", evt.EventType)
@ -149,12 +126,6 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) :
return Result.success(Data.Builder().putLong("result", Cwtch.numMessages(profile, handle)).build())
}
"GetMessage" -> {
//Log.i("MainActivivity.kt", (a.get("index")));
// var args : HashMap<String, dynamic> = a.gets();
// Log.i("FlwtchWorker.kt", args);
val profile = (a.get("profile") as? String) ?: "";
val handle = (a.get("contact") as? String) ?: "";
val indexI = a.getInt("index") ?: 0;

View File

@ -67,7 +67,6 @@ class MainActivity: FlutterActivity() {
val profile = intent.extras!!.getString("ProfileOnion")
val handle = intent.extras!!.getString("RemotePeer")
val mappo = mapOf("ProfileOnion" to profile, "RemotePeer" to handle)
Log.i("MainActivity.kt", "onNewIntent($profile, $handle)")
val j = JSONObject(mappo)
methodChan!!.invokeMethod("NotificationClicked", j.toString())
}
@ -137,7 +136,7 @@ class MainActivity: FlutterActivity() {
val data: Data = Data.Builder().putString(FlwtchWorker.KEY_METHOD, call.method).putString(FlwtchWorker.KEY_ARGS, JSONObject(argmap).toString()).build()
// 15 minutes is the shortest interval you can request
val workRequest = PeriodicWorkRequestBuilder<FlwtchWorker>(15, TimeUnit.MINUTES).setInputData(data).addTag(workerTag).addTag(uniqueTag).build()
val workResult = WorkManager.getInstance(this).enqueueUniquePeriodicWork("req_$uniqueTag", ExistingPeriodicWorkPolicy.KEEP, workRequest)
WorkManager.getInstance(this).enqueueUniquePeriodicWork("req_$uniqueTag", ExistingPeriodicWorkPolicy.KEEP, workRequest)
return
}
}
@ -145,16 +144,12 @@ class MainActivity: FlutterActivity() {
// ...otherwise fallthru to a normal ffi method call (and return the result using the result callback)
val data: Data = Data.Builder().putString(FlwtchWorker.KEY_METHOD, method).putString(FlwtchWorker.KEY_ARGS, JSONObject(argmap).toString()).build()
val workRequest = OneTimeWorkRequestBuilder<FlwtchWorker>().setInputData(data).build()
val workResult = WorkManager.getInstance(this).enqueue(workRequest)
WorkManager.getInstance(this).enqueue(workRequest)
WorkManager.getInstance(applicationContext).getWorkInfoByIdLiveData(workRequest.id).observe(
this, Observer { workInfo ->
if (workInfo.state == WorkInfo.State.SUCCEEDED) {
val res = workInfo.outputData.keyValueMap.toString()
//Log.i("MainActivity.kt", "method $method returned SUCCESS($res)")
result.success(workInfo.outputData.getString("result"))
} else {
val idk = workInfo.state.toString()
//Log.i("MainActivity.kt", "method $method returned $idk")
}
}
)
@ -184,13 +179,6 @@ class MainActivity: FlutterActivity() {
val eventBus: MethodChannel = mc
override fun onReceive(context: Context, intent: Intent) {
// StringBuilder().apply {
// append("Action: ${intent.action}\n")
// append("URI: ${intent.toUri(Intent.URI_INTENT_SCHEME)}\n")
// toString().also { log ->
// Log.d("MyBroadcastReceiver", log)
// }
// }
val evtType = intent.getStringExtra("EventType") ?: ""
val evtData = intent.getStringExtra("Data") ?: ""
//val evtID = intent.getStringExtra("EventID") ?: ""//todo?

View File

@ -27,6 +27,7 @@ subprojects {
project.evaluationDependsOn(':app')
}
//removed due to gradle namespace conflicts that are beyond erinn's mere mortal understanding
//task clean(type: Delete) {
// delete rootProject.buildDir
//}

View File

@ -436,7 +436,6 @@ class MessageState extends ChangeNotifier {
void tryLoad(BuildContext context) {
Provider.of<FlwtchState>(context, listen: false).cwtch.GetMessage(profileOnion, contactHandle, messageIndex).then((jsonMessage) {
try {
print("debug messageJson $jsonMessage");
dynamic messageWrapper = jsonDecode(jsonMessage);
if (messageWrapper['Message'] == null || messageWrapper['Message'] == '' || messageWrapper['Message'] == '{}') {
this._senderOnion = profileOnion;

View File

@ -105,7 +105,7 @@ packages:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.0"
version: "6.1.1"
flutter:
dependency: "direct main"
description: flutter
@ -413,7 +413,7 @@ packages:
name: vm_service
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.0+1"
version: "6.2.0"
webdriver:
dependency: transitive
description: