Skip to content

Commit

Permalink
refactor: add inline suggestions handling in broadcaster
Browse files Browse the repository at this point in the history
  • Loading branch information
goofyz committed Jan 14, 2025
1 parent f5aa0ea commit 80d0e03
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package com.osfans.trime.ime.broadcast

import android.view.View
import android.view.inputmethod.EditorInfo
import com.osfans.trime.core.RimeMessage
import com.osfans.trime.core.RimeProto
Expand All @@ -29,4 +30,6 @@ interface InputBroadcastReceiver {
fun onWindowDetached(window: BoardWindow) {}

fun onEnterKeyLabelUpdate(label: String) {}

fun onInlineSuggestion(views: List<View>) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package com.osfans.trime.ime.broadcast

import android.view.View
import android.view.inputmethod.EditorInfo
import com.osfans.trime.core.RimeMessage
import com.osfans.trime.core.RimeProto
Expand Down Expand Up @@ -68,4 +69,8 @@ class InputBroadcaster : InputBroadcastReceiver {
override fun onEnterKeyLabelUpdate(label: String) {
receivers.forEach { it.onEnterKeyLabelUpdate(label) }
}

override fun onInlineSuggestion(views: List<View>) {
receivers.forEach { it.onInlineSuggestion(views) }
}
}
4 changes: 4 additions & 0 deletions app/src/main/java/com/osfans/trime/ime/core/InputView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ class InputView(
broadcaster.onSelectionUpdate(start, end)
}

fun updateInlineSuggestion(views: List<View>) {
broadcaster.onInlineSuggestion(views)
}

override fun onDetachedFromWindow() {
ViewCompat.setOnApplyWindowInsetsListener(this, null)
// cancel the notification job and clear all broadcast receivers,
Expand Down

0 comments on commit 80d0e03

Please sign in to comment.