Basic desktop plugin

Summary:
Scaffolded desktop UI for UI debugger
I changed getroot from an rpc call to an event sent on connect. The root should never change as its the application object.

Reviewed By: lblasa

Differential Revision: D38866008

fbshipit-source-id: ca0f1908bedb643238f11ed796922e3359619167
This commit is contained in:
Luke De Feo
2022-08-22 03:02:53 -07:00
committed by Facebook GitHub Bot
parent 6adf1d666f
commit f1e80b18b1
8 changed files with 87 additions and 29 deletions

View File

@@ -9,24 +9,29 @@ package com.facebook.flipper.plugins.uidebugger
import android.app.Application
import com.facebook.flipper.core.FlipperConnection
import com.facebook.flipper.core.FlipperObject
import com.facebook.flipper.core.FlipperPlugin
import com.facebook.flipper.plugins.uidebugger.commands.CommandRegister
import com.facebook.flipper.plugins.uidebugger.commands.GetRoot
import com.facebook.flipper.plugins.uidebugger.core.ApplicationRef
import com.facebook.flipper.plugins.uidebugger.core.Context
class UIDebuggerFlipperPlugin(application: Application) : FlipperPlugin {
class UIDebuggerFlipperPlugin(val application: Application) : FlipperPlugin {
private val context: Context = Context(ApplicationRef(application))
private var connection: FlipperConnection? = null
override fun getId(): String {
return "UIDebugger"
return "ui-debugger"
}
@Throws(Exception::class)
override fun onConnect(connection: FlipperConnection) {
this.connection = connection
registerCommands(connection)
// temp solution, get from descriptor
connection.send(
"init",
FlipperObject.Builder()
.put("rootId", System.identityHashCode(application).toString())
.build())
}
@Throws(Exception::class)
@@ -37,8 +42,4 @@ class UIDebuggerFlipperPlugin(application: Application) : FlipperPlugin {
override fun runInBackground(): Boolean {
return true
}
fun registerCommands(connection: FlipperConnection) {
CommandRegister.register(connection, GetRoot(context))
}
}

View File

@@ -1,20 +0,0 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.flipper.plugins.uidebugger.commands
import com.facebook.flipper.core.FlipperObject
import com.facebook.flipper.core.FlipperResponder
import com.facebook.flipper.plugins.uidebugger.core.Context
class GetRoot(context: Context) : Command(context) {
override fun identifier(): String {
return "getRoot"
}
override fun execute(params: FlipperObject, response: FlipperResponder) {}
}