Saving custom image assets to new Cordova file structure

This forum contains topics that were moved from Get Satisfaction
Chris6743166
Posts: 1
Joined: Tue Mar 18, 2014 11:50 am

Saving custom image assets to new Cordova file structure

Post by Chris6743166 »

Hi,

My apps use 9-patch splashscreens and custom notification icons for Android.

These were previously stored in the source under CORDOVA/platforms/android/res/ with subsequent respective drawable folders for each respective density. However that source file structure is different in the latest version of Cordova.

Are you able to advise how to implement those custom assets in the source with the latest version of Cordova?

Thanks,

Chris

Chris6743166
Posts: 1
Joined: Tue Mar 18, 2014 11:50 am

Saving custom image assets to new Cordova file structure

Post by Chris6743166 »

OK. I've resolved half this problem. The 9-patch splashscreens now work by renaming all the files and moving them to the root of the splash folder. Then added this to config.xml:

code
<splash density="hdpi" src="resources/android/splash/drawable-hdpi-splash&#46;9&#46;png" />
<splash density="ldpi" src="resources/android/splash/drawable-ldpi-splash&#46;9&#46;png" />
<splash density="mdpi" src="resources/android/splash/drawable-mdpi-splash&#46;9&#46;png" />
<splash density="xhdpi" src="resources/android/splash/drawable-xhdpi-splash&#46;9&#46;png" />
<splash density="xxhdpi" src="resources/android/splash/drawable-xxhdpi-splash&#46;9&#46;png" />
<splash density="xxxhdpi" src="resources/android/splash/drawable-xxxhdpi-splash&#46;9&#46;png" />
/code

Still working on how to override the notification icon. I'll try a similar solution and update here shortly.

Chris6743166
Posts: 1
Joined: Tue Mar 18, 2014 11:50 am

Saving custom image assets to new Cordova file structure

Post by Chris6743166 »

Solved. For notification icons which are different from the main launcher icon, create a folder called 'notification-icon' in your resources/android folder and upload your zipped icons there. One icon for each supported density and each icon in it's respectively named drawable folder (e.g. drawable-mdpi).

Then add this to your config.xml between the android tags:

code<resource-file src="resources/android/notification-icon/drawable-mdpi/notification_icon&#46;png" target="app/src/main/notification-icon/drawable-mdpi/notification_icon&#46;png" />
<resource-file src="resources/android/notification-icon/drawable-hdpi/notification_icon&#46;png" target="app/src/main/notification-icon/drawable-hdpi/notification_icon&#46;png" />
<resource-file src="resources/android/notification-icon/drawable-xhdpi/notification_icon&#46;png" target="app/src/main/notification-icon/drawable-xhdpi/notification_icon&#46;png" />
<resource-file src="resources/android/notification-icon/drawable-xxhdpi/notification_icon&#46;png" target="app/src/main/notification-icon/drawable-xxhdpi/notification_icon&#46;png" />
<resource-file src="resources/android/notification-icon/drawable-xxxhdpi/notification_icon&#46;png" target="app/src/main/notification-icon/drawable-xxxhdpi/notification_icon&#46;png" /> /code

Finally, edit your home.js file in WEB_RESOURCES/app, adding a comma immediately after the senderID and then on a new line add this:

codeicon: 'notification_icon'/code

This is outlined on the pushplugin page here.

Post Reply