Skip to content

About

No description, website, or topics provided.

Resources

Contributing

Stars

15 stars

Watchers

0 watching

Forks

Latest commit

 

History

3,184 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KMPToolkit

A collection of small, independent Kotlin Multiplatform libraries (Android + iOS) — haptics, audio record/playback, local scheduling, secure key-value storage, permissions, notifications, raw accelerometer readings, and a database-agnostic transactional uploader. Each module is published as its own artifact — take only what you need — and the whole suite is released together on a single version, so two KMPToolkit artifacts on one classpath can never come from different releases.

Maven Central License: MIT Kotlin Multiplatform Android iOS

Why small modules instead of one library

Every artifact solves exactly one problem and depends on as few others as possible. You add kmptoolkit-haptics without pulling in an uploader engine, a notification system, or Compose. See docs/01-architecture.md for the principles every module follows (no bundled DI framework, no hardcoded consumer identifiers, no user-facing text) and why.

Modules

Artifact What it solves Depends on Status Docs
kmptoolkit-bom Pins every artifact below to one version — import this first — Available install
kmptoolkit-logging Minimal tag/level logging interface + pluggable sinks, zero dependencies. Also publishes jvm, with a standard-error sink, for code shared with desktop — Available docs
kmptoolkit-haptics Haptic feedback, with the outcome reported rather than thrown — Available docs
kmptoolkit-haptics-testing RecordingHapticFeedback double, for testImplementation haptics Available docs
kmptoolkit-flashlight Camera-torch blink cue, with the outcome degraded to a no-op rather than thrown — Available docs
kmptoolkit-flashlight-testing RecordingFlashlight double, for testImplementation flashlight Available docs
kmptoolkit-audio-player Audio playback (MediaPlayer / AVPlayer) behind a pluggable engine — Available docs
kmptoolkit-audio-player-testing FakePlaybackEngine, for testImplementation audio-player Available docs
kmptoolkit-video-player Headless video playback (Media3 ExoPlayer / AVPlayer) behind a pluggable engine: state, position, buffering, picture size, volume, mute, repeat. Also publishes jvm; the desktop engine is a separate artifact — Available docs
kmptoolkit-video-player-testing FakeVideoPlaybackEngine, for testImplementation. Also publishes jvm video-player Available docs
kmptoolkit-video-player-compose Compose surface (VideoPlayerSurface) and a VideoPlayer with ready-made controls whose every part can be replaced or restyled. Also publishes jvm video-player Available docs
kmptoolkit-video-player-vlcj Desktop (JVM-only) video engine on VLCJ — any format VLC plays. VLCJ is GPL-3; VLC must be installed video-player Available docs
kmptoolkit-video-player-javafx Desktop (JVM-only) video engine on JavaFX Media — nothing to install, fewer formats. OpenJFX is GPL-2 + Classpath Exception video-player Available docs
kmptoolkit-audio-recorder Audio recording (MediaRecorder / AVAudioRecorder), live input level for a waveform, typed errors instead of throws, and an Interrupted state when the system ends a recording (call, silenced microphone, full disk, dead media service) files Available docs
kmptoolkit-audio-recorder-testing FakeAudioRecorder, for testImplementation audio-recorder Available docs
kmptoolkit-scheduler Exact-time one-shot local alarms — Available docs
kmptoolkit-scheduler-testing RecordingAlarmScheduler double, for testImplementation scheduler Available docs
kmptoolkit-storage Key-value storage, plain and encrypted, with a main-safe suspend API, typed Int/Long/Boolean accessors and a stable device id. Encrypted stores share one hierarchy (EncryptedKeyValueStorage, SecureStorageProtection) that says who holds the key, and fail with typed errors (AccessDenied, Unsupported, InvalidValue). Android: Keystore options (StrongBox, unlocked-device key, time-bound user authentication), androidKeySecurityLevel() and a versioned secure envelope. iOS: Keychain options (access group, iCloud synchronizable, user presence). Also publishes jvm: a properties-file store, desktop secure storage (macOS Keychain, Windows DPAPI, Linux Secret Service; JDK 22+ without a native dependency; only the macOS key store has been run on a real OS, the Windows and Linux ones are tested through fakes, see the platform notes) and an app-key encrypted store (passphrase or raw key), for code shared with desktop files (jvm) Available docs
kmptoolkit-storage-jna Optional JNA binding that lets desktop secure storage run on JDK 21 (a bridge: deprecated once the desktop baseline reaches JDK 22; no public API). jvm only storage Available docs
kmptoolkit-storage-testing InMemoryKeyValueStorage: a map-backed SecureKeyValueStorage fake with a shareable Backing (restart or second process), one-shot and sticky failure knobs, protection and ensureKey, safe from parallel threads, for testImplementation. Also publishes jvm storage Available docs
kmptoolkit-files File-system primitives for shared code: atomic durable writes, bounded reads, safe recursive delete, leftover sweeps, per-key coroutine locks, path and file-name rules including Windows, app directories with backup exclusion, owner-only files and directories (ownerOnly); typed errors instead of throws. Also publishes jvm, for code shared with desktop — Available docs
kmptoolkit-files-testing FakeFileAccess (in memory, with fault and crash injection, records owner-only creation with isOwnerOnly) and FileAccessContract, for testImplementation files Available docs
kmptoolkit-biometric Biometric gate with typed outcomes, an enrolment shortcut whose launch you can customise, and opt-in weak-tier / single-attempt checks; prompt copy is yours activity (Android) Available docs
kmptoolkit-biometric-testing ScriptedBiometricGate, for testImplementation biometric Available docs
kmptoolkit-permission One PermissionController for every grant: 15 permissions both platforms have (notifications, microphone, camera, location, photos, contacts, calendar, motion, Bluetooth, …), Android runtime permissions, special accesses, roles and device admins, and iOS tracking, speech, reminders and Focus — with a status that tells limited, restricted and unavailable apart from a refusal, batch requests, observation, a headless request flow, and on iOS a temporary full-accuracy request for a user who chose approximate location storage, activity (Android) Available docs
kmptoolkit-permission-testing FakePermissionController, for testImplementation permission Available docs
kmptoolkit-notification Local notifications, channels, actions, and the notification a foreground service starts with permission Available docs
kmptoolkit-notification-testing RecordingNotifier, for testImplementation notification Available docs
kmptoolkit-uploader Transactional uploader engine (storage-agnostic), with UploadHandler — which hands the app the server's response (status, headers, body) — and built-in background HTTP upload transports on Android (WorkManager) and iOS (background NSURLSession) logging, files Available docs
kmptoolkit-uploader-testing InMemoryUploaderStore, UploaderStoreContract, FakeUploader, RecordingUploadTransport, for testImplementation uploader Available docs
kmptoolkit-uploader-sqldelight SQLDelight-backed UploaderStore, the reference SPI implementation uploader Available docs
kmptoolkit-location Device geographic position as typed readings (a fix with its accuracy, or a typed reason it is unavailable): one-shot fix and continuous updates with per-call options, service-enabled check and re-enable prompt, validated coordinates and geo math (distance, bearing, bounds), a compass HeadingProvider, and an Android/iOS platform layer. Also publishes jvm, where the providers answer UNSUPPORTED and the geo math is real core, logging (Android, iOS), activity (Android) Available docs
kmptoolkit-location-testing FakeLocationProvider, FakeHeadingProvider and fakeFix, for testImplementation. Also publishes jvm location Available docs
kmptoolkit-proximity Proximity sensor (ProximitySensor + ProximityRule) — Available docs
kmptoolkit-proximity-testing FakeProximitySensor double, for testImplementation proximity Available docs
kmptoolkit-downloader Resumable background-download engine (transfer-agnostic) logging, files Available docs
kmptoolkit-downloader-testing FakeDownloader, FakeDownloaderStorage, for testImplementation downloader Available docs
kmptoolkit-activity Scoped access to the currently resumed Activity, with no getter to leak through and a predicate deciding which activities count; plus SystemScreenLauncher, which decides the task a system screen opened by another module lands in. The one Android-only module: there is no iOS counterpart to an Activity — Available docs
kmptoolkit-systembars Compose system-bar control with per-axis ownership, optional pixel-sampled auto icon styling, and a keep-screen-awake primitive. Also publishes jvm, so a UI tree shared with desktop still compiles activity (Android) Available docs
kmptoolkit-hardware-keys Keeps an app's hardware-key policy (volume and other keys) in force inside Compose dialog windows and sheets on Android, where the Activity's key handling cannot reach. Compose; no-op on iOS; also publishes jvm logging (Android) Available docs
kmptoolkit-systembars-testing RecordingSystemBarsController / RecordingScreenWakeLockController doubles, for testImplementation systembars Available docs
kmptoolkit-logging-overlay Compose in-app log overlay (debug builds only) logging Available docs
kmptoolkit-accelerometer Raw accelerometer readings as a cold Flow, m/s² on both platforms — Available docs
kmptoolkit-accelerometer-testing ScriptedAccelerometer double, for testImplementation accelerometer Available docs
kmptoolkit-language App language selection (AppLanguageHolder), a supported-language catalog you populate, and the platform-locale side effect — including the Android Application wiring that keeps a chosen language from reverting. Also publishes jvm, for code shared with desktop — Available docs
kmptoolkit-language-compose Compose wiring (AppLocale, mirrorOnRtl/mirrorOnLtr) for kmptoolkit-language. Also publishes jvm language Available docs
kmptoolkit-hijri Umm al-Qura date conversion: LocalDate.toHijriDate(). Also publishes jvm — Available docs

Internal support artifacts

kmptoolkit-core (Android, iOS, jvm) is published and on the BOM but is not in the table above: it is an internal support artifact holding what several modules share (@ToolkitInternalApi, the StateMachineLock the players and the recorder use, and the iOS SharedIdleTimer that the wake lock and the video surfaces share). Modules pull it in transitively — do not depend on it directly, and expect no compatibility promise from it. See docs/kmptoolkit-core/.

See docs/README.md for the full documentation index and the recommended reading order.

Installation

Add the BOM to align every module on one version, then pull in only what you use:

// build.gradle.kts of your shared module
kotlin {
    sourceSets {
        commonMain.dependencies {
            implementation(project.dependencies.platform("io.github.jamal-wia:kmptoolkit-bom:<version>"))
            implementation("io.github.jamal-wia:kmptoolkit-logging")
        }
    }
}

KMP module resolution needs platform() at every source set that declares the dependency, not just commonMain — see KT-58759 if a version fails to resolve on a specific target.

Quick start

class UserRepository(private val loggerFactory: LoggerFactory) {
    private val log = loggerFactory.logger("UserRepository")

    suspend fun loadUsers(): List<User> {
        log.i { "loading users" }
        return emptyList()
    }
}

// production
val repository = UserRepository(createLoggerFactory())

See docs/00-getting-started.md for a from-scratch walkthrough, and each module's own docs/<module>/02-getting-started.md for a runnable example.

Read next

About

No description, website, or topics provided.

Resources

Contributing

Stars

15 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages