Introducing a new way to review your PRs.

Read the announcement

shmykelsa / aaad

The original application for downloading and installing apps made specifically for Android Auto outside of Google Play Store. Active since 2021.

View on GitHub

6 documents · Updated Nov 16, 2026

docs / app-utilities-versioning-and-shared-helpers

App Utilities, Versioning, and Shared Helpers

Overview

This utility slice is made of two small Java helpers under app/src/main/java/com/legs/appsforaa/utils/: UtilsLibrary.java for Android UI helper behavior and Version.java for dotted numeric version metadata.

app/…/UtilsLibrary.java is package-private to com.legs.appsforaa.utils, so its public effect is through other classes in that package rather than through app-wide imports. dpToPixels(Context, int) reads context.getResources().getDisplayMetrics().density and rounds dp * density + 0.5f to an int. app/…/BottomDialog.java uses it when applying a custom shadow height in initBottomDialog(...) and when BottomDialog.Builder.setCustomView(View, int, int, int, int) stores custom-view padding; callers pass density-independent units, and the builder stores pixels.

UtilsLibrary.createButtonBackgroundDrawable(Context, int) builds the positive button background used by BottomDialog.java. It converts a fixed 2dp corner radius, resolves the external BottomDialogs theme attribute com.github.javiersantos.bottomdialogs.R.attr.colorControlHighlight for the ripple color, falls back to #88CCCCCC when the attribute is unavailable, and returns a RippleDrawable containing a rectangular GradientDrawable filled with the requested color. The helper depends on Android framework drawing classes (ColorStateList, GradientDrawable, RippleDrawable) and on the BottomDialogs library resources, which are supplied by the Gradle dependency com.github.iGio90:BottomDialogs:master-SNAPSHOT in app/build.gradle.

app/…/Version.java is a strict dotted-numeric version value object. The constructor rejects null with IllegalArgumentException("Version can not be null") and rejects any string that does not match [0-9]+(\.[0-9]+)*, so suffixes such as -beta, empty components, and build metadata are not accepted. compareTo(Version) splits both versions on ., parses each component as an int, pads missing components with zero, and returns normal semantic ordering for numeric components: for example 1.2 equals 1.2.0, 1.10 is greater than 1.2, and any non-null Version compares greater than null. equals(Object) only accepts other Version instances and delegates equality to compareTo, so versions with trailing zero components compare equal even when their original strings differ.

At this commit, repository call-site searches under app/src/main find no active construction or import of Version.java; release metadata elsewhere uses Gradle fields such as versionCode and versionName in app/build.gradle. Treat Version.java as an available helper for future update/release comparison flows rather than a currently wired runtime path.

Coupling

  • If app/…/UtilsLibrary.java changes density conversion or rounding, verify app/…/BottomDialog.java shadow height and custom-view padding behavior; those builder APIs accept values that are immediately converted and stored as pixels.
  • If the BottomDialogs dependency or theme resources change in app/build.gradle, verify UtilsLibrary.createButtonBackgroundDrawable(...) and BottomDialog.java: both reference com.github.javiersantos.bottomdialogs.R resources directly, including colorControlHighlight, colorPrimary, layout, style, and view IDs.
  • If Version.java is introduced into update-checking or release-gating code, normalize inputs before constructing it; it accepts only dotted integer components and will throw on common release strings such as 2.1-beta or v2.1.
  • If Version.equals(...) is used in hashed collections, add a matching hashCode() implementation in Version.java; equality treats 1.2 and 1.2.0 as the same value, but the class currently does not override hashCode().

Risks

  • app/…/UtilsLibrary.java always creates a RippleDrawable, which requires API 21. The app's current minSdk is 24 in app/build.gradle, so this is safe now; lowering minSdk below 21 without adding a pre-Lollipop branch would break BottomDialog positive button background creation at runtime.
  • app/…/Version.java parses each version component with Integer.parseInt; unusually large numeric components will throw NumberFormatException, and strings with release labels will throw IllegalArgumentException. Any future remote update metadata path that feeds unchecked server values into this class can fail before showing an update result.