application in the specified orientation. This can be useful for games and
other multimedia applications.
+## Resources and application icon
+
+Resources specific to the Android platform should be placed in an `android/` folder at the root of the project.
+The folder should adopt the structure of a normal Android project, e.g., a custom XML resource file can be placed
+at `android/res/values/color.xml` to be compiled with the Android application.
+
+The application icon should also be placed in the `android/` folder.
+Place the classic bitmap version at `android/res/mipmap-hdpi/ic_launcher.png` (and others),
+and the adaptive version at `android/res/mipmap-anydpi-v26/ic_launcher.xml`.
+The Nit compiler detects these files and uses them as the application icon.
+
+Additional `android/` folders may be placed next to more specific Nit modules to change the Android resources
+for application variants. The more specific resources will have priority over the project level `android/` files.
+
# Compilation modes
There are two compilation modes for the Android platform, debug and release.
# Generate AndroidManifest.xml
# Is there an icon?
- var resolutions = ["ldpi", "mdpi", "hdpi", "xhdpi", "xxhdpi", "xxxhdpi"]
- var icon_available = false
+ var resolutions = ["ldpi", "mdpi", "hdpi", "xhdpi", "xxhdpi", "xxxhdpi", "anydpi", "anydpi-v26"]
+ var icon_name = null
+ var has_round = false
+
for res in resolutions do
- var path = project_root / "android/res/drawable-{res}/icon.png"
- if path.file_exists then
- icon_available = true
+ # New style mipmap
+ if "{project_root}/android/res/mipmap-{res}/ic_launcher_round.png".file_exists then
+ has_round = true
+ end
+ if "{project_root}/android/res/mipmap-{res}/ic_launcher.png".file_exists then
+ icon_name = "@mipmap/ic_launcher"
+ break
+ end
+ if "{project_root}/android/res/mipmap-{res}/ic_launcher.xml".file_exists then
+ icon_name = "@mipmap/ic_launcher"
break
end
end
+ if icon_name == null then
+ # Old style drawable-hdpi/icon.png
+ for res in resolutions do
+ var path = project_root / "android/res/drawable-{res}/icon.png"
+ if path.file_exists then
+ icon_name = "@drawable/icon"
+ break
+ end
+ end
+ end
var icon_declaration
- if icon_available then
- icon_declaration = "android:icon=\"@drawable/icon\""
+ if icon_name != null then
+ icon_declaration = "android:icon=\"{icon_name}\""
+ if app_target_api >= 25 and has_round then
+ icon_declaration += "\n\t\tandroid:roundIcon=\"@mipmap/ic_launcher_round\""
+ end
else icon_declaration = ""
# TODO android:roundIcon