forked from Blendman974/faceclaw
Fix an issue where animations on the phone preview stopped prematurely
This commit is contained in:
1 parent
eb7f385644
commit
4234d3e9e9
14 files changed
+160
-6
No files matched your search
@@ -191,6 +191,7 @@ export class FaceclawCommunicatorBridge {
|
||||
private latestPhoneLockState: boolean | null = null;
|
||||
private readonly evenAppConflictListeners = new Set<(message: string) => void>();
|
||||
private readonly frameMetricsListeners = new Set<(metrics: FrameMetrics) => void>();
|
||||
private readonly previewAnimationListeners = new Set<() => void>();
|
||||
private readonly firmwareInfoListeners = new Set<(info: FirmwareInfo) => void>();
|
||||
private readonly ancsAuthorizationListeners = new Set<(authorized: boolean) => void>();
|
||||
private readonly ancsRelayListeners = new Set<(frame: Uint8Array) => void>();
|
||||
@@ -209,6 +210,10 @@ export class FaceclawCommunicatorBridge {
|
||||
this.listenerProxy = SessionListener.new() as SessionListener;
|
||||
this.listenerProxy.bridge = this;
|
||||
this.communicator.setListenerListener(this.listenerProxy);
|
||||
// Kotlin calls this on the main queue.
|
||||
this.communicator.setPreviewAnimationListenerListener(() => {
|
||||
for (const listener of Array.from(this.previewAnimationListeners)) listener();
|
||||
});
|
||||
}
|
||||
|
||||
// ----- Kotlin listener entry points (main queue) -----------------------------------
|
||||
@@ -357,6 +362,15 @@ export class FaceclawCommunicatorBridge {
|
||||
return () => this.frameMetricsListeners.delete(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Each step of an animation the phone preview is replaying (a menu slide
|
||||
* reaches the glasses as one frame, so frame metrics fire only at its start).
|
||||
*/
|
||||
onPreviewAnimationFrame(listener: () => void): () => void {
|
||||
this.previewAnimationListeners.add(listener);
|
||||
return () => this.previewAnimationListeners.delete(listener);
|
||||
}
|
||||
|
||||
onFirmwareInfo(listener: (info: FirmwareInfo) => void): () => void {
|
||||
this.firmwareInfoListeners.add(listener);
|
||||
return () => this.firmwareInfoListeners.delete(listener);
|
||||
@@ -603,7 +617,11 @@ export class FaceclawCommunicatorBridge {
|
||||
|
||||
async close(): Promise<void> {
|
||||
this.setAncsListeners(false);
|
||||
await this.enqueueNativeCall(() => this.communicator.close());
|
||||
this.previewAnimationListeners.clear();
|
||||
await this.enqueueNativeCall(() => {
|
||||
this.communicator.setPreviewAnimationListenerListener(null);
|
||||
this.communicator.close();
|
||||
});
|
||||
}
|
||||
|
||||
// ----- iOS extras: compass, microphone, iPhone notifications (ANCS) ----------------------
|
||||
|
||||
Reference in new issue
Block a user