Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

[Feature Request] Add support for conditionally changing the android app icon name #44

Open
AdamDiament opened this issue Oct 17, 2022 · 1 comment

Comments

@AdamDiament
Copy link

This would be a cool addition and could slot in nicely as an optional parameter to the app bundle id task

There are workarounds out there involving maintaining two separate manifest files and switching them in based on build config, but maintaining multiple build configurations plus an additional file is not ideal.

@AdamDiament
Copy link
Author

In the meantime, I am just running a custom powershell script in azure, based heavily on the one that changes the app name in the library

Param(
  [string]$sourcePath,
  [string]$iconName
)

# requies parameters
if(!$sourcePath)
{
    write-host " [!] Missing required input: sourcePath"
    exit 1
} 

write-host "Source path is: $sourcePath"

if(!(Test-Path $sourcePath))
{
    Write-Host " [!] File doesn't exist at specified Android Manifest path: $sourcePath"
    exit 1
}

if(!$iconName)
{
    Write-Host " [!] No iconName specified!"
    exit 1
}

# ---------------------
# --- Configs:
Write-Host " (i) Provided Android Manifest path: $sourcePath"

Write-Host " (i) New Icon Name: $iconName"    

 # Load the manifest file
 [xml] $xam = Get-Content -Path $sourcePath
 
 # Get the version from Android Manifest
 $NAME = Select-Xml -xml $xam  -Xpath "/manifest/application/@android:icon" -namespace @{android="http://schemas.android.com/apk/res/android"}

 $old_name = $NAME.Node.Value;

 Write-Host " (i) Original Icon Name: $old_name"  

# ---------------------
# --- Main:

Write-Host "Original Manifest:"
Get-Content $sourcePath | Write-Host

$NAME.Node.Value = "@mipmap/$iconName"

$xam.Save($sourcePath)

Write-Host "Final Manifest:"
Get-Content $sourcePath | Write-Host

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant