build(android): launcher icon and splash from the web app icon
The APK carried Capacitor's default icon and splash. scripts/android-icons.ps1 draws them from public/icon-512.png: the adaptive icon foreground (source at 86% of the 108 dp canvas, so the ring stays inside the 66 dp safe zone) on the icon's own background #0F1115, the legacy square and round icons, and the splash images with the icon centred. The Android 12+ splash background uses the same colour. Installed on a OnePlus 15; how each launcher masks the icon was not checked beyond that phone.
No files matched your search
|
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 9.3 KiB |
|
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 9.5 KiB |
|
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 9.3 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 7.6 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 7.6 KiB |
|
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 5.5 KiB |
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#FFFFFF</color>
|
||||
<color name="ic_launcher_background">#0F1115</color>
|
||||
</resources>
|
||||
@@ -18,5 +18,6 @@
|
||||
|
||||
<style name="AppTheme.NoActionBarLaunch" parent="Theme.SplashScreen">
|
||||
<item name="android:background">@drawable/splash</item>
|
||||
<item name="windowSplashScreenBackground">@color/ic_launcher_background</item>
|
||||
</style>
|
||||
</resources>
|
||||
@@ -0,0 +1,62 @@
|
||||
# Regenerates the Android launcher icons and splash images from the web app icon
|
||||
# (public/icon-512.png), so the app and the PWA carry the same logo.
|
||||
# Run from the repo root: powershell -File scripts/android-icons.ps1
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
|
||||
$root = Split-Path -Parent $PSScriptRoot
|
||||
$res = Join-Path $root 'android\app\src\main\res'
|
||||
$src = [System.Drawing.Bitmap]::FromFile((Join-Path $root 'public\icon-512.png'))
|
||||
$bg = $src.GetPixel(5, 5) # the icon's own background colour
|
||||
|
||||
function New-Canvas([int]$w, [int]$h) {
|
||||
$b = New-Object System.Drawing.Bitmap($w, $h, [System.Drawing.Imaging.PixelFormat]::Format32bppArgb)
|
||||
$g = [System.Drawing.Graphics]::FromImage($b)
|
||||
$g.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic
|
||||
$g.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::AntiAlias
|
||||
$g.PixelOffsetMode = [System.Drawing.Drawing2D.PixelOffsetMode]::HighQuality
|
||||
return @($b, $g)
|
||||
}
|
||||
|
||||
function Save([System.Drawing.Bitmap]$b, [string]$rel) {
|
||||
$b.Save((Join-Path $res $rel), [System.Drawing.Imaging.ImageFormat]::Png)
|
||||
$b.Dispose()
|
||||
}
|
||||
|
||||
# Adaptive icon foreground: 108 dp canvas, of which a 66 dp circle survives any launcher
|
||||
# mask. The ring spans 68% of the source, so the source is drawn at 86% of the canvas
|
||||
# (ring = 58% < 61%); the transparent margin shows the background colour below it.
|
||||
$dens = @{ 'mdpi' = 1; 'hdpi' = 1.5; 'xhdpi' = 2; 'xxhdpi' = 3; 'xxxhdpi' = 4 }
|
||||
foreach ($d in $dens.Keys) {
|
||||
$f = $dens[$d]
|
||||
$fg = [int](108 * $f); $b, $g = New-Canvas $fg $fg
|
||||
$s = [int]($fg * 0.86); $o = [int](($fg - $s) / 2)
|
||||
$g.DrawImage($src, $o, $o, $s, $s); $g.Dispose()
|
||||
Save $b "mipmap-$d\ic_launcher_foreground.png"
|
||||
|
||||
$lg = [int](48 * $f)
|
||||
$b, $g = New-Canvas $lg $lg
|
||||
$g.DrawImage($src, 0, 0, $lg, $lg); $g.Dispose()
|
||||
Save $b "mipmap-$d\ic_launcher.png"
|
||||
|
||||
$b, $g = New-Canvas $lg $lg
|
||||
$brush = New-Object System.Drawing.TextureBrush($src)
|
||||
$brush.ScaleTransform($lg / $src.Width, $lg / $src.Height)
|
||||
$g.FillEllipse($brush, 0, 0, $lg, $lg); $brush.Dispose(); $g.Dispose()
|
||||
Save $b "mipmap-$d\ic_launcher_round.png"
|
||||
}
|
||||
|
||||
# Splash: the icon centred on its background colour, 40% of the short side.
|
||||
Get-ChildItem $res -Recurse -Filter splash.png | ForEach-Object {
|
||||
$old = [System.Drawing.Image]::FromFile($_.FullName); $w = $old.Width; $h = $old.Height; $old.Dispose()
|
||||
$b, $g = New-Canvas $w $h
|
||||
$g.Clear($bg)
|
||||
$s = [int]([Math]::Min($w, $h) * 0.4)
|
||||
$g.DrawImage($src, [int](($w - $s) / 2), [int](($h - $s) / 2), $s, $s); $g.Dispose()
|
||||
$b.Save($_.FullName, [System.Drawing.Imaging.ImageFormat]::Png); $b.Dispose()
|
||||
}
|
||||
|
||||
$hex = '#{0:X2}{1:X2}{2:X2}' -f $bg.R, $bg.G, $bg.B
|
||||
$xml = "<?xml version=`"1.0`" encoding=`"utf-8`"?>`n<resources>`n <color name=`"ic_launcher_background`">$hex</color>`n</resources>"
|
||||
[System.IO.File]::WriteAllText((Join-Path $res 'values\ic_launcher_background.xml'), $xml)
|
||||
$src.Dispose()
|
||||
"icons and splash written, background $hex"
|
||||