Skip to content

Commit ea2293a

Browse files
committed
refactor(ADFA-4419): distinguish peer-presence overlay from #1448 decorations
Rename EditorDecorationManager -> PeerPresenceOverlayManager and extract a focused PeerPresenceProvider interface out of the broad EditorProvider, so the pair-programming peer-cursor overlay (floating named badges) reads as a distinct concern from the generic EditorDecorationProvider (additive color spans) added in #1448 (ADFA-4436). Host-internal only: no plugin-api contract changed and the merged rainbow- brackets plugin is unaffected. Verified with :app:compileV8DebugKotlin.
1 parent 7788b79 commit ea2293a

3 files changed

Lines changed: 21 additions & 11 deletions

File tree

app/src/main/java/com/itsaky/androidide/activities/editor/EditorDecorationManager.kt renamed to app/src/main/java/com/itsaky/androidide/activities/editor/PeerPresenceOverlayManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import java.io.File
1818
*
1919
* All methods must be called on the main thread (the editor view is touched directly).
2020
*/
21-
class EditorDecorationManager(
21+
class PeerPresenceOverlayManager(
2222
private val editorForFile: (File) -> CodeEditor?,
2323
) {
2424

‎app/src/main/java/com/itsaky/androidide/app/EditorProviderImpl.kt‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package com.itsaky.androidide.app
33
import android.os.Handler
44
import android.os.Looper
55
import androidx.lifecycle.lifecycleScope
6-
import com.itsaky.androidide.activities.editor.EditorDecorationManager
6+
import com.itsaky.androidide.activities.editor.PeerPresenceOverlayManager
77
import com.itsaky.androidide.activities.editor.EditorHandlerActivity
88
import com.itsaky.androidide.models.Position
99
import com.itsaky.androidide.models.Range
@@ -37,7 +37,7 @@ class EditorProviderImpl(
3737
private val activityRef = WeakReference(activity)
3838
private val mainHandler = Handler(Looper.getMainLooper())
3939
private val fileCallbacks = java.util.concurrent.CopyOnWriteArrayList<(File?) -> Unit>()
40-
private val decorationManager = EditorDecorationManager { file ->
40+
private val peerPresenceOverlay = PeerPresenceOverlayManager { file ->
4141
activity()?.getEditorForFile(file)?.editor
4242
}
4343

@@ -61,7 +61,7 @@ class EditorProviderImpl(
6161
fun dispose() {
6262
EditorEvents.removeFileChangeListener(internalListener)
6363
fileCallbacks.clear()
64-
onMain { decorationManager.clearAll(); true }
64+
onMain { peerPresenceOverlay.clearAll(); true }
6565
activityRef.clear()
6666
}
6767

@@ -270,15 +270,15 @@ class EditorProviderImpl(
270270
peerName: String,
271271
peerColor: Int,
272272
): Boolean = onMain {
273-
decorationManager.addMarker(file, line, column, peerId, peerName, peerColor)
273+
peerPresenceOverlay.addMarker(file, line, column, peerId, peerName, peerColor)
274274
}
275275

276276
override fun hidePeerCursor(file: File, peerId: String): Boolean = onMain {
277-
decorationManager.removeMarker(file, peerId)
277+
peerPresenceOverlay.removeMarker(file, peerId)
278278
}
279279

280280
override fun clearPeerCursors(file: File) {
281-
onMain { decorationManager.clear(file); true }
281+
onMain { peerPresenceOverlay.clear(file); true }
282282
}
283283

284284
/**

‎plugin-manager/src/main/kotlin/com/itsaky/androidide/plugins/manager/services/IdeEditorServiceImpl.kt‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,20 @@ class IdeEditorServiceImpl(
2626
fun getAllowedPaths(): List<String>
2727
}
2828

29-
interface EditorProvider {
29+
/**
30+
* Remote-collaborator presence: draw, move and clear named peer cursors in open editors.
31+
* Split out of [EditorProvider] so peer presence is a focused, separately-named contract
32+
* rather than three more methods on the broad editor-access surface (interface segregation).
33+
* The host bridge implements both through one object. Visual overlay only — never mutates
34+
* file content. Each method defaults to a no-op so an implementer can opt in.
35+
*/
36+
interface PeerPresenceProvider {
37+
fun showPeerCursor(file: File, line: Int, column: Int, peerId: String, peerName: String, peerColor: Int): Boolean = false
38+
fun hidePeerCursor(file: File, peerId: String): Boolean = false
39+
fun clearPeerCursors(file: File) {}
40+
}
41+
42+
interface EditorProvider : PeerPresenceProvider {
3043
fun getCurrentFile(): File?
3144
fun getOpenFiles(): List<File>
3245
fun isFileOpen(file: File): Boolean
@@ -54,9 +67,6 @@ class IdeEditorServiceImpl(
5467
fun insertLineBefore(file: File, line: Int, text: String): Boolean = false
5568
fun deleteLine(file: File, line: Int): Boolean = false
5669
fun replaceRange(file: File, range: SelectionRange, newText: String): Boolean = false
57-
fun showPeerCursor(file: File, line: Int, column: Int, peerId: String, peerName: String, peerColor: Int): Boolean = false
58-
fun hidePeerCursor(file: File, peerId: String): Boolean = false
59-
fun clearPeerCursors(file: File) {}
6070
fun addFileChangeCallback(callback: (File?) -> Unit) {}
6171
fun removeFileChangeCallback(callback: (File?) -> Unit) {}
6272
}

0 commit comments

Comments
 (0)