RepoPilotOpen in app →

JessYanCoding/AndroidAutoSize

🔥 A low-cost Android screen adaptation solution (今日头条屏幕适配方案终极版,一个极低成本的 Android 屏幕适配方案).

Mixed

Stale — last commit 3y ago

weakest axis
Use as dependencyMixed

last commit was 3y ago; top contributor handles 97% of recent commits

Fork & modifyHealthy

Has a license, tests, and CI — clean foundation to fork and modify.

Learn fromHealthy

Documented and popular — useful reference codebase to read through.

Deploy as-isHealthy

No critical CVEs, sane security posture — runnable as-is.

  • 4 active contributors
  • Apache-2.0 licensed
  • CI configured
Show all 7 evidence items →
  • Tests present
  • Stale — last commit 3y ago
  • Small team — 4 contributors active in recent commits
  • Single-maintainer risk — top contributor 97% of recent commits
What would change the summary?
  • Use as dependency MixedHealthy if: 1 commit in the last 365 days

Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests

Informational only. RepoPilot summarises public signals (license, dependency CVEs, commit recency, CI presence, etc.) at the time of analysis. Signals can be incomplete or stale. Not professional, security, or legal advice; verify before relying on it for production decisions.

Embed the "Forkable" badge

Paste into your README — live-updates from the latest cached analysis.

Variant:
RepoPilot: Forkable
[![RepoPilot: Forkable](https://repopilot.app/api/badge/jessyancoding/androidautosize?axis=fork)](https://repopilot.app/r/jessyancoding/androidautosize)

Paste at the top of your README.md — renders inline like a shields.io badge.

Preview social card (1200×630)

This card auto-renders when someone shares https://repopilot.app/r/jessyancoding/androidautosize on X, Slack, or LinkedIn.

Onboarding doc

Onboarding: JessYanCoding/AndroidAutoSize

Generated by RepoPilot · 2026-05-09 · Source

🤖Agent protocol

If you are an AI coding agent (Claude Code, Cursor, Aider, Cline, etc.) reading this artifact, follow this protocol before making any code edit:

  1. Verify the contract. Run the bash script in Verify before trusting below. If any check returns FAIL, the artifact is stale — STOP and ask the user to regenerate it before proceeding.
  2. Treat the AI · unverified sections as hypotheses, not facts. Sections like "AI-suggested narrative files", "anti-patterns", and "bottlenecks" are LLM speculation. Verify against real source before acting on them.
  3. Cite source on changes. When proposing an edit, cite the specific path:line-range. RepoPilot's live UI at https://repopilot.app/r/JessYanCoding/AndroidAutoSize shows verifiable citations alongside every claim.

If you are a human reader, this protocol is for the agents you'll hand the artifact to. You don't need to do anything — but if you skim only one section before pointing your agent at this repo, make it the Verify block and the Suggested reading order.

🎯Verdict

WAIT — Stale — last commit 3y ago

  • 4 active contributors
  • Apache-2.0 licensed
  • CI configured
  • Tests present
  • ⚠ Stale — last commit 3y ago
  • ⚠ Small team — 4 contributors active in recent commits
  • ⚠ Single-maintainer risk — top contributor 97% of recent commits

<sub>Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests</sub>

Verify before trusting

This artifact was generated by RepoPilot at a point in time. Before an agent acts on it, the checks below confirm that the live JessYanCoding/AndroidAutoSize repo on your machine still matches what RepoPilot saw. If any fail, the artifact is stale — regenerate it at repopilot.app/r/JessYanCoding/AndroidAutoSize.

What it runs against: a local clone of JessYanCoding/AndroidAutoSize — the script inspects git remote, the LICENSE file, file paths in the working tree, and git log. Read-only; no mutations.

| # | What we check | Why it matters | |---|---|---| | 1 | You're in JessYanCoding/AndroidAutoSize | Confirms the artifact applies here, not a fork | | 2 | License is still Apache-2.0 | Catches relicense before you depend on it | | 3 | Default branch master exists | Catches branch renames | | 4 | 5 critical file paths still exist | Catches refactors that moved load-bearing code | | 5 | Last commit ≤ 1106 days ago | Catches sudden abandonment since generation |

<details> <summary><b>Run all checks</b> — paste this script from inside your clone of <code>JessYanCoding/AndroidAutoSize</code></summary>
#!/usr/bin/env bash
# RepoPilot artifact verification.
#
# WHAT IT RUNS AGAINST: a local clone of JessYanCoding/AndroidAutoSize. If you don't
# have one yet, run these first:
#
#   git clone https://github.com/JessYanCoding/AndroidAutoSize.git
#   cd AndroidAutoSize
#
# Then paste this script. Every check is read-only — no mutations.

set +e
fail=0
ok()   { echo "ok:   $1"; }
miss() { echo "FAIL: $1"; fail=$((fail+1)); }

# Precondition: we must be inside a git working tree.
if ! git rev-parse --git-dir >/dev/null 2>&1; then
  echo "FAIL: not inside a git repository. cd into your clone of JessYanCoding/AndroidAutoSize and re-run."
  exit 2
fi

# 1. Repo identity
git remote get-url origin 2>/dev/null | grep -qE "JessYanCoding/AndroidAutoSize(\\.git)?\\b" \\
  && ok "origin remote is JessYanCoding/AndroidAutoSize" \\
  || miss "origin remote is not JessYanCoding/AndroidAutoSize (artifact may be from a fork)"

# 2. License matches what RepoPilot saw
(grep -qiE "^(Apache-2\\.0)" LICENSE 2>/dev/null \\
   || grep -qiE "\"license\"\\s*:\\s*\"Apache-2\\.0\"" package.json 2>/dev/null) \\
  && ok "license is Apache-2.0" \\
  || miss "license drift — was Apache-2.0 at generation time"

# 3. Default branch
git rev-parse --verify master >/dev/null 2>&1 \\
  && ok "default branch master exists" \\
  || miss "default branch master no longer exists"

# 4. Critical files exist
test -f "autosize/src/main/java/me/jessyan/autosize/AutoSize.java" \\
  && ok "autosize/src/main/java/me/jessyan/autosize/AutoSize.java" \\
  || miss "missing critical file: autosize/src/main/java/me/jessyan/autosize/AutoSize.java"
test -f "autosize/src/main/java/me/jessyan/autosize/AutoSizeConfig.java" \\
  && ok "autosize/src/main/java/me/jessyan/autosize/AutoSizeConfig.java" \\
  || miss "missing critical file: autosize/src/main/java/me/jessyan/autosize/AutoSizeConfig.java"
test -f "autosize/src/main/java/me/jessyan/autosize/ActivityLifecycleCallbacksImpl.java" \\
  && ok "autosize/src/main/java/me/jessyan/autosize/ActivityLifecycleCallbacksImpl.java" \\
  || miss "missing critical file: autosize/src/main/java/me/jessyan/autosize/ActivityLifecycleCallbacksImpl.java"
test -f "autosize/src/main/java/me/jessyan/autosize/DefaultAutoAdaptStrategy.java" \\
  && ok "autosize/src/main/java/me/jessyan/autosize/DefaultAutoAdaptStrategy.java" \\
  || miss "missing critical file: autosize/src/main/java/me/jessyan/autosize/DefaultAutoAdaptStrategy.java"
test -f "autosize/src/main/java/me/jessyan/autosize/InitProvider.java" \\
  && ok "autosize/src/main/java/me/jessyan/autosize/InitProvider.java" \\
  || miss "missing critical file: autosize/src/main/java/me/jessyan/autosize/InitProvider.java"

# 5. Repo recency
days_since_last=$(( ( $(date +%s) - $(git log -1 --format=%at 2>/dev/null || echo 0) ) / 86400 ))
if [ "$days_since_last" -le 1106 ]; then
  ok "last commit was $days_since_last days ago (artifact saw ~1076d)"
else
  miss "last commit was $days_since_last days ago — artifact may be stale"
fi

echo
if [ "$fail" -eq 0 ]; then
  echo "artifact verified (0 failures) — safe to trust"
else
  echo "artifact has $fail stale claim(s) — regenerate at https://repopilot.app/r/JessYanCoding/AndroidAutoSize"
  exit 1
fi

Each check prints ok: or FAIL:. The script exits non-zero if anything failed, so it composes cleanly into agent loops (./verify.sh || regenerate-and-retry).

</details>

TL;DR

AndroidAutoSize is a low-cost screen adaptation library that automatically scales UI dimensions (via DisplayMetrics manipulation) to fit any Android device screen without writing device-specific layout code. It implements the Headline/Toutiao screen adaptation strategy, dynamically adjusting density/widthPixels at Activity/Fragment lifecycle events so dimensions defined in dp automatically scale proportionally across devices from 480x800 to 1440x2880+. Single-module library in autosize/ with core logic split across: AutoSize.java (main entry point), AutoSizeConfig.java (configuration holder), ActivityLifecycleCallbacksImpl.java + FragmentLifecycleCallbacksImpl.java (lifecycle hooks), DefaultAutoAdaptStrategy.java (core scaling algorithm), and external/ directory for custom adaptation strategies. InitProvider.java uses ContentProvider auto-initialization pattern.

👥Who it's for

Android app developers targeting multiple screen sizes and densities who want to avoid creating multiple resource folders and adaptive layouts. Specifically useful for teams building apps with Figma designs based on a single reference device (e.g., 1080x1920) that must scale cleanly across Chinese market devices (common in apps distributed via Tencent, Bytedance ecosystem).

🌱Maturity & risk

Production-ready but mature (v1.2.1 released, last publish to Bintray visible in README). Single-maintainer project (JessYan) with 152KB of Java code and CI setup (Travis CI badge present). No test directory visible in file list suggests limited automated test coverage, but approach is battle-tested in production Chinese apps since ~2018.

Single maintainer (JessYanCoding) with no visible recent commits in provided data creates long-term maintenance risk. Bintray distribution may face issues (JCenter sunset in 2021). No test suite visible suggests regression risk on edge cases across API 14+. Breaking changes possible when Android modifies DisplayMetrics handling (e.g., Android 10+ notch/cutout handling).

Active areas of work

Repository appears to be in maintenance mode — no active development visible. The CHANGELOG.md and last visible version (v1.2.1) suggest this peaked around 2018–2019. The library is stable but not actively adding features; issues likely accumulate in the tracker without rapid response.

🚀Get running

Clone: git clone https://github.com/JessYanCoding/AndroidAutoSize.git. Gradle-based project: ./gradlew build (Unix) or gradlew.bat build (Windows). Use Android Studio or import as a Gradle module. Dependency via Bintray: implementation 'me.jessyan:autosize:1.2.1' in app/build.gradle.

Daily commands: Not a runnable app — this is a library. To test locally: add implementation project(':autosize') to a sample app's build.gradle, then call AutoSize.initCompatMultiProcess(this) in Application.onCreate(). See example screenshots in art/ for expected output on various device resolutions. No gradle tasks for 'run' — build with ./gradlew build to generate autosize/build/outputs/aar/autosize-release.aar.

🗺️Map of the codebase

  • autosize/src/main/java/me/jessyan/autosize/AutoSize.java — Main entry point and public API for the screen adaptation library; defines initialization and core configuration methods.
  • autosize/src/main/java/me/jessyan/autosize/AutoSizeConfig.java — Central configuration holder that stores all adaptation parameters; every custom adaptation decision depends on this.
  • autosize/src/main/java/me/jessyan/autosize/ActivityLifecycleCallbacksImpl.java — Lifecycle hook that intercepts Activity creation to apply density/dimension scaling at runtime.
  • autosize/src/main/java/me/jessyan/autosize/DefaultAutoAdaptStrategy.java — Default implementation of the adaptation strategy; handles the core algorithm for calculating scaled display metrics.
  • autosize/src/main/java/me/jessyan/autosize/InitProvider.java — ContentProvider that auto-initializes the library during app startup without explicit code in Application.
  • autosize/src/main/java/me/jessyan/autosize/unit/UnitsManager.java — Manages multiple unit types (dp, sp, mm, pt, in) and conversion logic; core to multi-unit support.
  • autosize/src/main/java/me/jessyan/autosize/external/ExternalAdaptManager.java — Manages per-Activity custom adaptation settings; enables granular control without global config changes.

🛠️How to make changes

Add Custom Per-Activity Adaptation Settings

  1. Annotate your Activity with @CustomAdapt to enable custom settings for just that screen (autosize/src/main/java/me/jessyan/autosize/internal/CustomAdapt.java)
  2. Create an ExternalAdaptInfo object with your custom parameters (design width, height, design units) (autosize/src/main/java/me/jessyan/autosize/external/ExternalAdaptInfo.java)
  3. Call ExternalAdaptManager.getInstance().addExternalAdaptInfo() in onCreate before setContentView to register it (autosize/src/main/java/me/jessyan/autosize/external/ExternalAdaptManager.java)
  4. See CustomAdaptActivity.java in the demo for a complete working example (demo-androidx/src/main/java/me/jessyan/autosize/demo/androidx/CustomAdaptActivity.java)

Implement a Custom Adaptation Strategy

  1. Create a class implementing the AutoAdaptStrategy interface to define your scaling algorithm (autosize/src/main/java/me/jessyan/autosize/AutoAdaptStrategy.java)
  2. Implement the applyAdapt() method to modify DisplayMetrics based on screen size and design specs (autosize/src/main/java/me/jessyan/autosize/DefaultAutoAdaptStrategy.java)
  3. Register your strategy via AutoSize.setAutoAdaptStrategy() during app initialization (autosize/src/main/java/me/jessyan/autosize/AutoSize.java)

Initialize AutoSize with Custom Global Configuration

  1. In your Application.onCreate(), call AutoSize.getInstance() to get the singleton (autosize/src/main/java/me/jessyan/autosize/AutoSize.java)
  2. Set design reference dimensions via setDesignWidthInDp() and setDesignHeightInDp() (autosize/src/main/java/me/jessyan/autosize/AutoSizeConfig.java)
  3. Optionally configure unit types via UnitsManager.getInstance().setSupportSubunits() (autosize/src/main/java/me/jessyan/autosize/unit/UnitsManager.java)
  4. See BaseApplication.java in the demo for initialization patterns (demo-androidx/src/main/java/me/jessyan/autosize/demo/androidx/BaseApplication.java)

Disable Adaptation for Specific Screens

  1. Annotate your Activity or Fragment with @CancelAdapt (autosize/src/main/java/me/jessyan/autosize/internal/CancelAdapt.java)
  2. That Activity/Fragment will use system-default display metrics, bypassing AutoSize scaling entirely (autosize/src/main/java/me/jessyan/autosize/ActivityLifecycleCallbacksImpl.java)

🔧Why these technologies

  • Activity/Fragment Lifecycle — undefined

🪤Traps & gotchas

InitProvider uses ContentProvider auto-initialization (AndroidManifest.xml entry required in library manifest). If app proguard-obfuscates class names, custom AutoAdaptStrategy subclasses must be kept via -keep rules in proguard-rules.pro. DisplayMetrics scaling happens globally (application-wide), so disabling for specific Activities requires setScaledDensityWhenExternalAdaptOff() config. Multi-process apps must use initCompatMultiProcess() not init() or scaling breaks in secondary processes. Android 10+ with display cutouts/notches may conflict with density scaling on EdgeToEdge layouts—no built-in handling visible.

🏗️Architecture

💡Concepts to learn

  • DisplayMetrics Manipulation — AndroidAutoSize's entire strategy depends on modifying Display.getMetrics() at runtime; understanding density, widthPixels, and xdpi/ydpi is essential to debug scaling issues
  • Lifecycle Callbacks (Activity/Fragment) — The library hooks into registerActivityLifecycleCallbacks and FragmentManager callbacks to inject scaling at precise moments—knowing when these fire (onCreate, onResume, etc.) is critical to understanding why scaling happens when it does
  • Strategy Pattern — AutoAdaptStrategy interface allows swapping scaling algorithms without modifying core code—essential for supporting multiple adaptation modes (width-based, height-based, custom)
  • ContentProvider Auto-Initialization — InitProvider leverages ContentProvider.onCreate() to auto-initialize without explicit Application.onCreate() calls—understanding this pattern explains how zero-config setup works
  • Density-Independent Pixels (dp) — dp values in layouts are converted to actual pixels using density; AndroidAutoSize scales density to make fixed dp values render larger/smaller—grasp this to understand why the library works
  • Aspect Ratio Preservation — When scaling from a design reference (e.g., 1080x1920 at 420dpi), the library must maintain aspect ratio while adapting to different screen dimensions—core to preventing UI distortion
  • NexusData/AndroidScreenAdaptation — Alternative screen adaptation via resource qualifiers and multiple dimens.xml files instead of runtime DisplayMetrics injection
  • CarGuo/GSYVideoPlayer — Large production Android video player that integrates AndroidAutoSize for multi-device UI scaling in media playback UI
  • JessYanCoding/MVPArms — Companion MVP architecture framework by same author (JessYan) that often pairs with AndroidAutoSize in production apps
  • hongyangAndroid/AndroidAutoLayout — Predecessor screen adaptation library using similar lifecycle-hook approach (superseded by AndroidAutoSize but provides historical context)
  • zhouyou0/QrCodeLib — Example app in Chinese ecosystem that uses AndroidAutoSize for consistent QR code scanner UI across device sizes

🪄PR ideas

To work on one of these in Claude Code or Cursor, paste: Implement the "<title>" PR idea from CLAUDE.md, working through the checklist as the task list.

Add comprehensive unit tests for AutoSizeUtils and ScreenUtils utility classes

The repo lacks unit tests for core utility functions in autosize/src/main/java/me/jessyan/autosize/utils/. AutoSizeUtils.java and ScreenUtils.java contain critical dimension calculation logic that should be tested across various device configurations. Adding unit tests will catch regressions and validate the adaptation algorithm works correctly on different screen densities and sizes.

  • [ ] Create autosize/src/test/java/me/jessyan/autosize/utils/ directory
  • [ ] Write AutoSizeUtilsTest.java covering dimension conversion methods (dp, px, sp conversions)
  • [ ] Write ScreenUtilsTest.java covering screen metric retrieval and validation
  • [ ] Add test fixtures for multiple device configurations (480x800, 1080x1920, 1440x2560, etc.)
  • [ ] Run tests in CI pipeline via .travis.yml

Add unit tests for AutoSizeConfig and configuration validation logic

AutoSizeConfig.java is the central configuration class but has no visible test coverage. This class manages critical settings like design width/height, unit selection, and adaptation strategy. Unit tests should verify configuration initialization, validation, and prevent invalid states (negative dimensions, null strategies).

  • [ ] Create autosize/src/test/java/me/jessyan/autosize/AutoSizeConfigTest.java
  • [ ] Test configuration builder pattern and validation of design dimensions
  • [ ] Test strategy switching (DefaultAutoAdaptStrategy vs custom implementations)
  • [ ] Test edge cases: zero/negative dimensions, null values, concurrent access
  • [ ] Test persistence of configuration across lifecycle events

Add integration tests for activity/fragment lifecycle callbacks and adaptation behavior

ActivityLifecycleCallbacksImpl.java and FragmentLifecycleCallbacksImpl.java handle critical lifecycle integration but lack test coverage. Integration tests should verify that adaptation is correctly applied when activities/fragments are created and that metrics are properly updated. This ensures the core adaptation mechanism works end-to-end.

  • [ ] Create demo-androidx/src/androidTest/ test classes for lifecycle callbacks
  • [ ] Write ActivityLifecycleCallbacksImplTest verifying onActivityCreated triggers adaptation
  • [ ] Write FragmentLifecycleCallbacksImplTest for fragment-level adaptation
  • [ ] Test that DisplayMetrics are correctly modified after lifecycle events
  • [ ] Verify adaptation is properly reset when activities are destroyed
  • [ ] Add instrumented tests to .travis.yml CI configuration

🌿Good first issues

  • Add unit tests for DefaultAutoAdaptStrategy.java across various screen dimensions (480x800, 1080x1920, 1440x2880) to ensure getDisplayMetricsInfo() returns correct scaled values—currently no test/ directory exists
  • Document the exact calculation formula used to scale widthPixels/density in README-zh.md and README.md (e.g., 'widthPixels_new = designWidthPx × screenDpi / 160') with worked examples, as users often misunderstand how the adaptation actually works
  • Add support for notch/cutout-aware scaling on Android 10+ (check WindowInsets in DisplayMetricsInfo.java) so apps using EdgeToEdge don't experience distorted layouts when DisplayMetrics density is modified

Top contributors

Click to expand

📝Recent commits

Click to expand
  • e402ecd — Update README-zh.md (JessYanCoding)
  • 29adbb0 — Update README.md (JessYanCoding)
  • ee03f08 — Merge pull request #303 from liqvip/master (JessYanCoding)
  • c55a72b — 【2020.7.11】【1.使用阿里云仓库】 (liqvip)
  • 730dbc6 — Update BaseApplication.java (JessYanCoding)
  • e7d814a — Delete strings.xml (JessYanCoding)
  • 220305e — Release v1.2.1 (JessYanCoding)
  • 86ba646 — 优化: 对适配信息缓存的 Key 值进行优化 (JessYanCoding)
  • 75653c8 — 优化: 使用位运算对适配信息的缓存进行优化 (JessYanCoding)
  • b76b39f — Release to v1.2.0 (JessYanCoding)

🔒Security observations

The AndroidAutoSize library demonstrates reasonable security posture for a UI adaptation utility. No critical vulnerabilities were identified. The main concerns are build configuration practices (disabled minification, lint errors not enforced) and dependency management clarity. The codebase itself appears to be a legitimate screen adaptation solution without obvious injection risks, hardcoded credentials, or exposed sensitive data. The library uses a content provider (InitProvider.java) for auto-initialization, which is a standard Android pattern. No authentication, encryption, or network operations are evident from the file structure, reducing the attack surface. Recommendations focus on build hardening rather than code-level issues.

  • Medium · Use of compileOnly for AppCompat Dependencies — autosize/build.gradle. The build.gradle file uses 'compileOnly' for both appcompat_v7 and androidx_appcompat dependencies. While this is intentional for a library to avoid forcing specific versions on consumers, it could lead to runtime issues if the consuming app doesn't include compatible versions. This is a design choice but represents a potential support burden. Fix: Document the required AppCompat version clearly in README. Consider using 'api' for one compatible version or provide multiple build variants. Ensure clear dependency documentation for library consumers.
  • Low · Lint Warnings Not Treated as Errors — autosize/build.gradle. The lintOptions configuration sets 'abortOnError false', which means lint warnings won't fail the build. This could allow code quality and security issues to slip through the CI/CD pipeline without being caught. Fix: Change 'abortOnError' to true to enforce strict lint checks. Alternatively, explicitly configure which issues should fail the build using lintOptions { disable 'IssueId' }.
  • Low · ProGuard Minification Disabled in Release — autosize/build.gradle. The release build type has 'minifyEnabled false', meaning code is not obfuscated in release builds. This could make reverse engineering easier and exposes class/method names. Fix: Enable minification in release builds: 'minifyEnabled true'. Ensure proguard-rules.pro properly configures keep rules for public APIs while obfuscating internal implementation.
  • Low · No Explicit Dependency Version Pinning — autosize/build.gradle. Dependencies are referenced via rootProject properties without explicit version constraints visible in the provided build.gradle excerpt. This could lead to inconsistent builds if root project versions change unexpectedly. Fix: Use version constraints (e.g., 'appcompat:28.0.0') instead of just references to rootProject properties. Document the minimum required versions clearly.

LLM-derived; treat as a starting point, not a security audit.


Generated by RepoPilot. Verdict based on maintenance signals — see the live page for receipts. Re-run on a new commit to refresh.

Mixed signals · JessYanCoding/AndroidAutoSize — RepoPilot