Skip to content

premex-ab/android-compose-preview-ext

Repository files navigation

Android Compose Preview Extensions

Build and Test Publish to GitHub Packages MIT License

Super‑charge your Jetpack Compose previews with production‑grade device specs for rugged enterprise handhelds and popular Android OEM devices – Zebra, Honeywell, Datalogic, Samsung, and more – plus Google reference devices through their stable IDs.

Stop eyeballing layouts on a single Pixel. Catch density, width/height & aspect issues instantly – before they ship.

Total devices: 24282 across 2668 manufacturers. See the full list: Supported Devices.

Why this exists

The built‑in Compose preview device list is limited and focused on consumer phones. Enterprise & vertical‑market apps often run on purpose‑built scanners, sleds and rugged handhelds with very different screen metrics. This library ships curated, de‑duplicated specs so you can preview realistically with a single import.

Key Features

  • One Kotlin object per manufacturer (e.g. Zebra, Honeywell, Samsung)
  • Simple constant strings drop straight into @Preview(device = Zebra.MC33) style usage
  • Google devices use official id: previews; others use explicit spec:width=...,height=...,dpi=... strings
  • Automatic markdown catalog generation: browse all supported devices in docs/devices
  • Deterministic naming with conflict resolution (resolution / DPI / short hash fallbacks)
  • Regenerate & extend via a Kotlin generator module (no shell scripts)

Quick Start

Add the dependency from Maven Central:

// Module build.gradle.kts
dependencies {
    implementation("se.premex.compose.preview:android-compose-preview-ext:1.0.0")
}

The library is hosted on Maven Central, so no additional repository configuration is needed if you already have mavenCentral() in your repositories block.

Usage

Import the manufacturer object you need and reference a constant:

import androidx.compose.ui.tooling.preview.Preview
import se.premex.compose.preview.device.catalog.android.Zebra

@Preview(name = "Zebra MC33", device = Zebra.MC33)
@Composable
fun ZebraPreview() { /* ... */ }

Multiple devices in one file:

@Preview(name = "Rugged (MC33)", device = Zebra.MC33)
@Preview(name = "Rugged (EC50)", device = Zebra.EC50)
@Preview(name = "Scanner (CK65)", device = Honeywell.CK65)
@Composable
fun MultiDevicePreview() { /* ... */ }

Google reference devices (Pixels etc.) use their id: values automatically in constants, so you still write:

@Preview(name = "Pixel 8", device = Google.PIXEL_8)

Supported Devices

A regenerated catalog lives here: docs/devices/README.md. (If the link is empty, run the generator locally.)

Regenerating / Contributing New Devices

The device-generator module fetches & normalizes specs, then outputs:

  • Kotlin sources under android-compose-preview-ext/src/main/kotlin/se/premex/compose/preview/device/catalog/android/
  • Markdown docs under docs/devices/
  • Updated stats block in this README (between markers)

Run:

./gradlew :device-generator:run

Commit the changed Kotlin & Markdown files.

Adding / fixing a device

  1. Locate the fetch logic inside device-generator (e.g. DeviceFetcher) and extend its source lists.
  2. Run the generator.
  3. Verify new constants & docs.
  4. Open a PR describing the source/reference for the spec (link to vendor PDF / site preferred).

Versioning & Stability

Constant names are derived from vendor model codes. If a conflict occurs (same code, different resolution) a suffix (resolution, DPI or short hash) is appended. This keeps existing names stable for the common case.

License

MIT – see LICENSE.

Credits

Maintained by Premex AB. Vendor names & trademarks belong to their respective owners.

Device catalog data is sourced from android-device-catalog-parser by Hossain Khan.


Enjoy faster feedback loops? Star the repo so others can discover it ⭐

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages