Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ public class Bridge private constructor() {
deviceModel: String,
gestureName: String,
timestamp: Long,
source: Int? = null
source: Int? = null,
extra: Map<String, Any>? = null

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like extra

) {
val body = HashMap<String, Any>()
body["type"] = "touch_event"
Expand All @@ -334,6 +335,7 @@ public class Bridge private constructor() {
if (source != null) {
body["source"] = source
}
extra?.let { body.putAll(it) }
sendTypedMessage("touch_event", body)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,11 +651,7 @@ class DeviceManager {
}

private fun statesEqual(s1: ViewState, s2: ViewState): Boolean {
val state1 =
"${s1.layoutType}${s1.text}${s1.topText}${s1.bottomText}${s1.title}${s1.data ?: ""}"
val state2 =
"${s2.layoutType}${s2.text}${s2.topText}${s2.bottomText}${s2.title}${s2.data ?: ""}"
return state1 == state2
return s1 == s2
}

private fun Map<String, Any>.getString(key: String, defaultValue: String): String {
Expand All @@ -680,7 +676,13 @@ class DeviceManager {
var bmpHeight: Int? = null,
// Optional positioned_text border (used by G2; ignored by others).
var borderWidth: Int? = null,
var borderRadius: Int? = null
var borderRadius: Int? = null,
// Optional selectable_list fields (used by G2; ignored by others).
var borderColor: Int? = null,
var paddingLength: Int? = null,
var listItems: List<String> = emptyList(),
var itemWidth: Int? = null,
var showSelectionBorder: Boolean? = null
)
// MARK: - End Unique

Expand Down Expand Up @@ -955,6 +957,22 @@ class DeviceManager {
)
}

"selectable_list" -> {
sgc?.sendSelectableList(
currentViewState.listItems,
currentViewState.bmpX ?: 0,
currentViewState.bmpY ?: 0,
currentViewState.bmpWidth ?: 576,
currentViewState.bmpHeight ?: 288,
currentViewState.borderWidth ?: 1,
currentViewState.borderColor ?: 13,
currentViewState.borderRadius ?: 6,
currentViewState.paddingLength ?: 5,
currentViewState.itemWidth ?: 0,
currentViewState.showSelectionBorder ?: true
)
}

"clear_view" -> sgc?.clearDisplay()
else -> Bridge.log("MAN: UNHANDLED LAYOUT_TYPE ${currentViewState.layoutType}")
}
Expand Down Expand Up @@ -1347,6 +1365,12 @@ class DeviceManager {
// Optional positioned_text border (G2).
val borderWidth = (layout["borderWidth"] as? Number)?.toInt()
val borderRadius = (layout["borderRadius"] as? Number)?.toInt()
val borderColor = (layout["borderColor"] as? Number)?.toInt()
val paddingLength = (layout["paddingLength"] as? Number)?.toInt()
val rawListItems = (layout["items"] as? List<*>) ?: (layout["itemName"] as? List<*>)
val listItems = rawListItems?.mapNotNull { it?.toString() } ?: emptyList()
val itemWidth = (layout["itemWidth"] as? Number)?.toInt()
val showSelectionBorder = layout["showSelectionBorder"] as? Boolean

var newViewState =
ViewState(
Expand All @@ -1362,7 +1386,12 @@ class DeviceManager {
bmpWidth,
bmpHeight,
borderWidth,
borderRadius
borderRadius,
borderColor,
paddingLength,
listItems,
itemWidth,
showSelectionBorder
)

val currentState = viewStates[stateIndex]
Expand Down
Loading
Loading