appdimens-dynamic

Product Requirements Document (PRD) — AppDimens Dynamic

[!NOTE] Product Alignment: io.github.bodenberg:appdimens-dynamic:3.1.5 Primary Module: library Associated Documents: PDR (Design) | Mathematics | API Conventions

1. Executive Summary

AppDimens Dynamic is a mathematical scaling engine designed for Android (com.appdimens.dynamic). Its purpose is to map generic UI dimensions (developed against a 300dp or equivalent reference) to physical hardware parameters—scaling elegantly across phones, tablets, and unpredictable foldables.

It encapsulates 14 discrete mathematical scaling strategies (curves), alongside an autonomous Resize/Constraint subsystem that calculates the maximum bounded element size at runtime via binary search.

2. Market Context & Problem Space

Static dp measurements fall apart as device variety increases. A 300dp horizontal card fits perfectly on a classic phone but becomes aggressively small on high-density tablets or wide-screen foldables.

Core Objectives

  1. Mathematical Consistency: Provide reproducible scaling curves (Linear, Logarithmic, Factorial/Power).
  2. Unified Surface APIs: Symmetrical integration rules for both Jetpack Compose (compose.*) and legacy XML/Views (code.*).
  3. High-Frequency Performance: Accommodate zero-allocation hot paths using lock-free architecture for smooth 60FPS and 120FPS rendering algorithms.
  4. Hardware Awareness: Adapt directly to Configuration, Display aspect ratios, Multi-Window flags, and Context DPI.

3. Functional Architecture overview

mindmap
  root((AppDimens Dynamic))
    Mathematical Engine
      Linear & Scaled Defaults
      Logarithmic Deterioration
      Exponential / Power Curves
      Diagonal Vector Paths
    Resize Subsystem
      Binary Constraint Search
      Max Area Fits Predicate
      Zero-GC Floating Arrays
    Consumer Platforms
      Jetpack Compose Wrappers
      Android Virtual Views (XML)
      Pure Kotlin Math Core
    Thread Safe Cache Layer
      ScreenFactors Bypass
      Multi-Window Detection
      Atomic Array Sharding

4. Feature Requirements (FR)

FR-0: Systemic Foundation & Architecture

FR-1: Dimension Mathematics & Curves

[!TIP] The Scaled default curve remains optimal for generic UI development, specifically supporting aspect-ratio injection (sdpa, sdpi) for anti-distortion tuning.

Strategy Class Mathematical Goal Expected Consumer Use Case
Scaled (Default) Linear geometry translation from basic 300dp scale. Baseline paddings, Standard containers.
Logarithmic Fast early growth curve with heavy downstream damping. Text geometries on massive tablets.
Fluid Breakpoint-based linear interpolation ([320..768]). Responsive Web-like UI adjustments.
Percent / Space Absolute device fractional limits (( % \times sw )). Fixed grid splits, Nav bars.
Interpolated User-defined N-point vector curves. Brand-specific interactive scaling.

FR-2: Engine & Subsystem Resize Algorithms


5. Non-Functional Requirements (NFR)

6. Metrics of Success

  1. Integration on both Compose/XML environments without memory/GC stuttering.
  2. Binary scale operations taking < 15ns median time.
  3. Successful scaling to multi-window split structures automatically.