Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android: allow specifying an adaptive-icon xml #781

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions android/buildIcons.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
{ runCommand, imagemagick }:
{ src }:
{ runCommand, imagemagick, lib }:
{ src ? null # Base raster image for fixed-size icons (must be a path)
, adaptiveIcon ? null
# Path to a XML file containing the adaptive icon specification (SDK
# 26 and up).
}:
let
rasterInput =
if (src == null) && (adaptiveIcon == null)
then abort "Either src or adaptiveIcon must be specified!"
else src;
in
runCommand "android-icons" {
inherit src;
buildCommand = ''
buildCommand = lib.optionalString (src != null) ''
mkdir "$out"

launcherIconSize() {
Expand All @@ -20,8 +29,11 @@ runCommand "android-icons" {
for x in l m tv h xh xxh xxxh ; do
local dir="$out/drawable-''${x}dpi"
mkdir "$dir"
convert -resize "$(launcherIconSize "$x")" -flatten "$src" "$dir/ic_launcher.png"
convert -resize "$(launcherIconSize "$x")" -flatten "${rasterInput}" "$dir/ic_launcher.png"
done
'' + lib.optionalString (adaptiveIcon != null) ''
mkidr -p "$out/mipmap-anydpi-v26/"
cp "${adaptiveIcon}" "$out/mipmap-anydpi-v26/ic_launcher.xml"
'';
nativeBuildInputs = [
imagemagick
Expand Down