Skip to content

Repository files navigation

icon-512

Advance Wallpaper Manager

Android Kotlin Jetpack Compose C++20

Advance Wallpaper Manager is an Android application for creating depth-effect live wallpapers. It renders a clock layer behind extracted subject foreground masks using on-device machine learning models and a native C++ rendering pipeline.

Screenshots

Main Gallery Depth Editor Clock Customization
ssg ssc1 ssc2

Features

Rendering Engine

  • Layered composition rendering base image, clock text, and foreground subject mask in a single pass.
  • Synchronized gesture transformations: scale, pan, and rotation applied to wallpaper and subject mask simultaneously.
  • Occlusion clamp (clockDepth) limiting foreground opacity over clock text.

Subject Segmentation

  • Google ML Kit Subject Segmentation API integration.
  • TensorFlow Lite models (selfie_segmenter.tflite and deeplabv3_mobilenetv2.tflite) for offline processing.
  • Native C++ edge refinement pipeline:
    • Confidence threshold ($\tau$)
    • Boundary expansion and shrinking via morphological dilation ($+\text{px}$) and erosion ($-\text{px}$)
    • Box blur feathering
    • Color decontamination to prevent edge halos
    • Automatic fallback to ML Kit if local model fails

Clock Customization

  • Horizontal and vertical stacked text layouts.
  • System font detection and custom font imports (.ttf, .otf, .zip).
  • Font embedding inside saved configuration archives.
  • Adjustable size, thickness, height stretch, letter spacing, line spacing, and auto color extraction.

Bundle Storage (.dwp)

  • Self-contained ZIP archives (.dwp) containing:
    • config.json
    • base.png
    • mask.png
    • preview.png
    • font.ttf
  • Import and export support via Android Storage Access Framework.

Rotation Scheduler

  • Scheduled background wallpaper rotation using WorkManager.
  • Intervals: Daily, Hourly, or On-Awake (pre-loads assets when screen turns off).

Tech Stack

  • Kotlin 2.0, C++20 (Android NDK)
  • Jetpack Compose, Material 3, Navigation Compose
  • Kotlin Coroutines and Flow
  • Android NDK ANativeWindow and AndroidBitmap
  • Google ML Kit Subject Segmentation
  • TensorFlow Lite 2.16
  • Android WorkManager

Native Rendering Pipeline

The C++ pipeline in native-lib.cpp renders directly to ANativeWindow_Buffer using RGBA_8888 pixel arrays.

[ ANativeWindow Buffer ]
   ├── 1. Draw Base Wallpaper  (Scale, Rotation, Panning)
   ├── 2. Draw Clock Bitmap    (Centered, Scaled, Rotation)
   └── 3. Draw Subject Mask    (Scale, Rotation, Occlusion Clamp)

Formulations

  1. Inverse 2D Affine Sampling: $$x = \text{origCx} + (dx0 \cdot \cos\theta + dy0 \cdot \sin\theta) \cdot \text{invScale}$$ $$y = \text{origCy} + (-dx0 \cdot \sin\theta + dy0 \cdot \cos\theta) \cdot \text{invScale}$$

  2. Clock Occlusion Clamp: $$\alpha_{\text{clock_area}}(x, y) = \min(\alpha(x, y), \lfloor \text{clockDepth} \times 255 \rfloor)$$

  3. Morphological Expansion:

    • Dilation ($+\text{px}$): $\alpha_{\text{new}}(x, y) = \max_{k \in [-r, r]} \alpha(x + k, y)$
    • Erosion ($-\text{px}$): $\alpha_{\text{new}}(x, y) = \min_{k \in [-r, r]} \alpha(x + k, y)$

Building

Requirements

  • Android Studio 2024.2+
  • Android SDK 37 (Min SDK 29)
  • CMake 3.22.1+
  • JDK 17

Steps

  1. Clone the repository:
    git clone https://github.com/your-username/AdvanceWallpaperManager.git
  2. Build debug APK:
    ./gradlew app:assembleDebug

Usage

  1. Load an image in the Source tab.
  2. Select segmentation mode under Model tab and adjust threshold or expansion parameters.
  3. Customize font, size, or position under Clock tab.
  4. Scale, rotate, or position wallpaper under Wallpaper tab.
  5. Tap Apply & Auto-Save in the Apply tab.

License

Copyright (C) 2026 Advance Wallpaper Manager

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.

Releases

Contributors

Languages