forked from Blendman974/faceclaw
Clean up unused code
Mostly remnants of iOS porting, where some things were temporarily in typescript but became shared kotlin
This commit is contained in:
1 parent
2c088378bd
commit
7d8f03ffe5
18 files changed
+66
-644
No files matched your search
@@ -1,33 +0,0 @@
|
||||
import type { KotlinBridge } from './kotlin-platform';
|
||||
|
||||
// Handwritten declarations for the small native surface, checked against the
|
||||
// compiled API. NativeScript runtime metadata is generated from the AAR.
|
||||
declare namespace com.faceclaw.shared {
|
||||
// Used as com.faceclaw.shared.KotlinBridge; oxlint misses qualified references.
|
||||
// oxlint-disable-next-line no-unused-vars
|
||||
class KotlinBridge extends java.lang.Object {
|
||||
constructor();
|
||||
platform(): string;
|
||||
threadName(): string;
|
||||
isMainThread(): boolean;
|
||||
greet(name: string): string;
|
||||
roundTrip(message: string, listener: KotlinBridgeListener): string;
|
||||
}
|
||||
class KotlinBridgeListener extends java.lang.Object {
|
||||
constructor(implementation: { transform(message: string): string });
|
||||
}
|
||||
}
|
||||
|
||||
export function createKotlinBridge(): KotlinBridge {
|
||||
const bridge = new com.faceclaw.shared.KotlinBridge();
|
||||
return {
|
||||
platform: () => bridge.platform(),
|
||||
threadName: () => bridge.threadName(),
|
||||
isMainThread: () => bridge.isMainThread(),
|
||||
greet: name => bridge.greet(name),
|
||||
roundTrip(message, transform) {
|
||||
const listener = new com.faceclaw.shared.KotlinBridgeListener({ transform });
|
||||
return bridge.roundTrip(message, listener);
|
||||
},
|
||||
};
|
||||
}
|
||||
Vendored
-11
@@ -1,11 +0,0 @@
|
||||
/** Exported native API normalized across Java interfaces and Obj-C protocols. */
|
||||
export interface KotlinBridge {
|
||||
platform(): string;
|
||||
threadName(): string;
|
||||
isMainThread(): boolean;
|
||||
greet(name: string): string;
|
||||
/** Synchronous callback; must not throw across the native boundary. */
|
||||
roundTrip(message: string, transform: (message: string) => string): string;
|
||||
}
|
||||
|
||||
export function createKotlinBridge(): KotlinBridge;
|
||||
@@ -1,42 +0,0 @@
|
||||
import type { KotlinBridge } from './kotlin-platform';
|
||||
|
||||
// Handwritten declarations matching FaceclawKit's Objective-C header.
|
||||
declare class FaceclawKitKotlinBridge extends NSObject {
|
||||
static alloc(): FaceclawKitKotlinBridge;
|
||||
init(): this;
|
||||
platform(): string;
|
||||
threadName(): string;
|
||||
isMainThread(): boolean;
|
||||
greetName(name: string): string;
|
||||
roundTripMessageListener(message: string, listener: FaceclawKitKotlinBridgeListener): string;
|
||||
}
|
||||
interface FaceclawKitKotlinBridgeListener {
|
||||
transformMessage(message: string): string;
|
||||
}
|
||||
declare const FaceclawKitKotlinBridgeListener: {
|
||||
prototype: FaceclawKitKotlinBridgeListener;
|
||||
};
|
||||
|
||||
@NativeClass()
|
||||
class KotlinCallback extends NSObject implements FaceclawKitKotlinBridgeListener {
|
||||
static ObjCProtocols = [FaceclawKitKotlinBridgeListener];
|
||||
transform!: (message: string) => string;
|
||||
|
||||
transformMessage(message: string): string { return this.transform(message); }
|
||||
}
|
||||
|
||||
export function createKotlinBridge(): KotlinBridge {
|
||||
const bridge = FaceclawKitKotlinBridge.alloc().init();
|
||||
return {
|
||||
platform: () => bridge.platform(),
|
||||
threadName: () => bridge.threadName(),
|
||||
isMainThread: () => bridge.isMainThread(),
|
||||
greet: name => bridge.greetName(name),
|
||||
roundTrip(message, transform) {
|
||||
const listener = KotlinCallback.new() as KotlinCallback;
|
||||
listener.transform = transform;
|
||||
// Kotlin uses this listener synchronously and never retains it.
|
||||
return bridge.roundTripMessageListener(message, listener);
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { File, knownFolders, path, type ImageSource } from "@nativescript/core";
|
||||
import { SurfaceCompositor } from "../graphics/surface-compositor";
|
||||
import { SurfaceCompositor } from "../graphics/surface-compositor.ios";
|
||||
import { G2_LENS_WIDTH, G2_LENS_HEIGHT } from "../graphics/image";
|
||||
import { previewPixels } from "./ios-graphics";
|
||||
import { toData } from "./kotlin-data";
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
import { Utils } from "@nativescript/core";
|
||||
import { GrayImage } from "../graphics/image";
|
||||
import { spanCurrent } from "./frame-timings";
|
||||
import { toUint8Array } from "~/util/array-util";
|
||||
|
||||
declare const com: any;
|
||||
|
||||
const ICON_SIZE = 24;
|
||||
const ICON_CACHE_MS = 5_000;
|
||||
|
||||
let cachedIcons: GrayImage[] = [];
|
||||
let cachedAtMs = 0;
|
||||
|
||||
export function readSystemStatusIcons(): GrayImage[] {
|
||||
if (!global.isAndroid) return [];
|
||||
|
||||
const now = Date.now();
|
||||
if (now - cachedAtMs < ICON_CACHE_MS) {
|
||||
return cachedIcons.map(cachedIcon => cachedIcon.clone());
|
||||
}
|
||||
|
||||
const context = Utils.android.getApplicationContext();
|
||||
if (!context) return [];
|
||||
|
||||
const bytes = spanCurrent("fetch-system-status-icons", () =>
|
||||
toUint8Array(
|
||||
com.faceclaw.app.FaceclawSystemStatusIconProvider.getSystemStatusIconGrays(context, ICON_SIZE),
|
||||
),
|
||||
);
|
||||
const iconByteLength = ICON_SIZE * ICON_SIZE;
|
||||
const iconCount = Math.floor(bytes.length / iconByteLength);
|
||||
const icons: GrayImage[] = [];
|
||||
for (let index = 0; index < iconCount; index++) {
|
||||
const icon = new GrayImage(ICON_SIZE, ICON_SIZE, 0);
|
||||
icon.pixels.set(bytes.subarray(index * iconByteLength, (index + 1) * iconByteLength));
|
||||
icons.push(icon);
|
||||
}
|
||||
|
||||
cachedIcons = icons;
|
||||
cachedAtMs = now;
|
||||
return icons.map(icon => icon.clone());
|
||||
}
|
||||
Reference in new issue
Block a user