feat(android): a padlock icon instead of Delphi's default
Cyan on slate, the accent the desktop app already uses. Adaptive vectors for Android 8+ - background covering the full 108 units since the launcher applies its own mask, foreground kept inside the central 66 that no mask can crop - plus a monochrome layer for Android 13 themed icons, where the keyhole has to be a hole in the path rather than a shape in another colour. PNGs for older launchers come from make-icons.ps1, same drawing, and carry their own rounded square since nothing masks them. They are copied over Delphi's in repack-apk.ps1, for the same reason as libsk4d.so: the Android_LauncherIcon and Android_AdaptiveIcon properties ought to be enough, and nothing deploys them here. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
# Genere les icones PNG du lanceur, pour Android < 8 qui ignore les icones
|
||||
# adaptatives. Meme dessin que les vecteurs de android-res\drawable :
|
||||
# cadenas cyan sur ardoise.
|
||||
#
|
||||
# A relancer seulement si le dessin change ; les PNG sont suivis par git.
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
|
||||
$root = Join-Path $PSScriptRoot 'android-res'
|
||||
$bg = [System.Drawing.Color]::FromArgb(255, 15, 23, 42) # #0F172A
|
||||
$fg = [System.Drawing.Color]::FromArgb(255, 34, 211, 238) # #22D3EE
|
||||
|
||||
# densite -> cote en pixels, tel qu'Android les attend
|
||||
$sizes = @{ 'drawable-ldpi' = 36; 'drawable-mdpi' = 48; 'drawable-hdpi' = 72
|
||||
'drawable-xhdpi' = 96; 'drawable-xxhdpi' = 144; 'drawable-xxxhdpi' = 192 }
|
||||
|
||||
foreach ($dir in $sizes.Keys) {
|
||||
$n = $sizes[$dir]
|
||||
$out = Join-Path $root $dir
|
||||
New-Item -ItemType Directory -Force $out | Out-Null
|
||||
|
||||
$bmp = New-Object System.Drawing.Bitmap $n, $n
|
||||
$g = [System.Drawing.Graphics]::FromImage($bmp)
|
||||
$g.SmoothingMode = 'AntiAlias'
|
||||
|
||||
# Fond : carre arrondi. Les vieux lanceurs ne masquent pas, donc l'icone
|
||||
# doit porter sa propre forme.
|
||||
$r = [int]($n * 0.22)
|
||||
$path = New-Object System.Drawing.Drawing2D.GraphicsPath
|
||||
$path.AddArc(0, 0, 2*$r, 2*$r, 180, 90)
|
||||
$path.AddArc($n-2*$r-1, 0, 2*$r, 2*$r, 270, 90)
|
||||
$path.AddArc($n-2*$r-1, $n-2*$r-1, 2*$r, 2*$r, 0, 90)
|
||||
$path.AddArc(0, $n-2*$r-1, 2*$r, 2*$r, 90, 90)
|
||||
$path.CloseFigure()
|
||||
$g.FillPath((New-Object System.Drawing.SolidBrush $bg), $path)
|
||||
|
||||
# Echelle : le dessin vectoriel vit dans un carre de 108.
|
||||
$u = $n / 108.0
|
||||
$brush = New-Object System.Drawing.SolidBrush $fg
|
||||
$pen = New-Object System.Drawing.Pen $fg, ([float](5.5 * $u))
|
||||
$pen.StartCap = 'Round'; $pen.EndCap = 'Round'
|
||||
|
||||
# Anse : demi-cercle ouvert vers le bas, puis deux montants.
|
||||
$g.DrawArc($pen, [float](44*$u), [float](37*$u), [float](20*$u), [float](20*$u), 180, 180)
|
||||
$g.DrawLine($pen, [float](44*$u), [float](47*$u), [float](44*$u), [float](56*$u))
|
||||
$g.DrawLine($pen, [float](64*$u), [float](47*$u), [float](64*$u), [float](56*$u))
|
||||
|
||||
# Corps
|
||||
$body = New-Object System.Drawing.Drawing2D.GraphicsPath
|
||||
$bx = 34*$u; $by = 54*$u; $bw = 40*$u; $bh = 26*$u; $br = 4*$u
|
||||
$body.AddArc([float]$bx, [float]$by, [float](2*$br), [float](2*$br), 180, 90)
|
||||
$body.AddArc([float]($bx+$bw-2*$br), [float]$by, [float](2*$br), [float](2*$br), 270, 90)
|
||||
$body.AddArc([float]($bx+$bw-2*$br), [float]($by+$bh-2*$br), [float](2*$br), [float](2*$br), 0, 90)
|
||||
$body.AddArc([float]$bx, [float]($by+$bh-2*$br), [float](2*$br), [float](2*$br), 90, 90)
|
||||
$body.CloseFigure()
|
||||
$g.FillPath($brush, $body)
|
||||
|
||||
# Serrure, evidee dans la couleur du fond
|
||||
$bgBrush = New-Object System.Drawing.SolidBrush $bg
|
||||
$g.FillEllipse($bgBrush, [float](50*$u), [float](58*$u), [float](8*$u), [float](8*$u))
|
||||
$g.FillRectangle($bgBrush, [float](52.4*$u), [float](64*$u), [float](3.2*$u), [float](9*$u))
|
||||
|
||||
$g.Dispose()
|
||||
$bmp.Save((Join-Path $out 'ic_launcher.png'), [System.Drawing.Imaging.ImageFormat]::Png)
|
||||
$bmp.Dispose()
|
||||
"{0,-20} {1}x{1}" -f $dir, $n
|
||||
}
|
||||
Reference in New Issue
Block a user