
Research
/Security News
DuckDB npm Account Compromised in Continuing Supply Chain Attack
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
@nativescript-use/change-icon
Advanced tools
Programmatically change the application icon.
npm install @nativescript-use/change-icon
To begin, we must define our icons in App_Resources/Android/src/main/res
, we recommend the page https://icon.kitchen/ to generate the icons for our application. This document will create 3 icons for the sample:
App_Resources/Android/src/main/res/mipmap
.Icon
)Icon Background
)adaptive-icon
to your mipmap-anydpi-v26
folder inside App_Resources/Android/src/main/res/
.mipmap-anydpi-v26/ic_launcher_default.xml
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@mipmap/ic_launcher_background_default"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground_default"/>
</adaptive-icon>
mipmap-anydpi-v26/ic_launcher_dark.xml
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@mipmap/ic_launcher_background_dark"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground_dark"/>
</adaptive-icon>
mipmap-anydpi-v26/ic_launcher_cafe.xml
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@mipmap/ic_launcher_background_cafe"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground_cafe"/>
</adaptive-icon>
activity-alias
to our AndroidManifest.xml
. To change the icon in android we need to specify an activity-alias
in AndroidManifest.xml
plus one for the default icon, so for this example we will have 3 activity-aliases in our manifest:
<application
android:name="com.tns.NativeScriptApplication"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher_default"
android:roundIcon="@mipmap/ic_launcher_default"
android:theme="@style/AppTheme">
<activity
android:name="com.tns.NativeScriptActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|locale|uiMode"
android:exported="true"
android:hardwareAccelerated="true"
android:label="@string/title_activity_kimera"
android:launchMode="singleTask"
android:theme="@style/AppTheme">
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />
<intent-filter>
<!-- Note that here we have removed <category android:name="android.intent.category.LAUNCHER" /> -->
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity-alias
android:name=".MainActivityDefault"
android:enabled="true"
android:exported="true"
android:icon="@mipmap/ic_launcher_default"
android:label="@string/title_activity_kimera"
android:targetActivity="com.tns.NativeScriptActivity">
<meta-data
android:name="SET_THEME_ON_LAUNCH"
android:resource="@style/AppTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
<activity-alias
android:name=".MainActivityDark"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_dark"
android:label="@string/title_activity_kimera"
android:targetActivity="com.tns.NativeScriptActivity">
<meta-data
android:name="SET_THEME_ON_LAUNCH"
android:resource="@style/AppTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
<activity-alias
android:name=".MainActivityCafe"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_cafe"
android:label="@string/title_activity_kimera"
android:targetActivity="com.tns.NativeScriptActivity">
<meta-data
android:name="SET_THEME_ON_LAUNCH"
android:resource="@style/AppTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
<activity android:name="com.tns.ErrorReportActivity" />
</application>
Note here the important things from the previous code:
<category android:name="android.intent.category.LAUNCHER" />
from the main activity activity
.activity-alias
, for Default, Dark and Cafe.activity-alias
of MainActivityDefault
has android:enabled="true"
by default.activity-aliases
have android:enabled="false"
android:name
of the activity-alias
tags must always have the format .MainActivity[The name we will use to change]
, in this case: MainActivityDefault
, MainActivityDark
, MainActivityCafe
.android:icon
and android:roundIcon
have the icon we added earlier.android:targetActivity
has the value of the main activity, default for NativeScript: com.tns.NativeScriptActivity
.To begin, we must define our icons in App_Resources/iOS
, we recommend the page https://icon.kitchen/ to generate the icons for our application. This document will create 3 icons for the sample:
App_Resources/iOS/Assets.xcassets/AppIcon.appiconset
folderApp_Resources/iOS
.Info.plist
(App_Resources/iOS/Info.plist
) the following code to indicate which is the default and which are the alternatives:<key>CFBundleIcons</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>Default</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
<key>CFBundleAlternateIcons</key>
<dict>
<key>Dark</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>Dark</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
<key>Cafe</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>Cafe</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
</dict>
</dict>
You just have to import the library and use the available methods
getCurrent()
reset()
change("NameOfIcon")
import { changeIcon } from "@nativescript-use/change-icon"
function changeIconToDark(){
changeIcon.change("Dark");
}
function changeIconToCafe(){
changeIcon.change("Cafe");
}
function changeIconToDefault(){
changeIcon.reset();
}
function getCurrentIcon(){
return changeIcon.getCurrent(); // "Default" | "Dark" | "Cafe"
}
Apache License Version 2.0
FAQs
Add a plugin description
We found that @nativescript-use/change-icon demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.