This new sample app demonstrates many of the new APIs introduced in Titanium 5.0. Since this release is a big one, we’ve also created separate sample apps for:
- WatchOS 2 Connectivity: WatchSession Sample App
- iOS App Search: App Search Sample App
- iOS Handoff: Handoff Sample App
For a list of all the 5.0.0 changes see the release notes and linked JIRA filters.
iOS: Icons & Launch Images
- You no longer need to have any
assets/iphone. Just provide a 1024×1024 24-bit DefaultIcon.png in your project root and Titanium will generate the missing required sizes for you.
- The build will fail if your icons do not meet Apple requirements and you don’t provide a valid
- You can no longer use launch images within the app itself like this.
- Localized Splash Screens still work, but App Thinning for these images will not because Launch Images do not support localized Asset Catalogs.
The Attributed Strings sample demonstrates the use of the new Alloy
<attributedstring> proxy property. You can use this as a child element of
<TextField>. As you can see, the last one also supports
For iOS only, we’ve also added support for the attribute type
ATTRIBUTE_LINE_BREAK. Use this with one of the
Ti.UI.ATTRIBUTE_LINE_BREAK_BY_* constants found in the sample’s TSS to determine how lines break.
tiapp.xml you can now theme almost everything. We’ve added support for
platform folders. If you have a white-label app you can now easily brand strings, libraries and Android icons, splash screens and themes.
Alloy Event Management
Alloy controllers have 3 new APIs to manage event listeners for Titanium view proxies. All events you add via XML now use
$.addListener(proxy, type, callback) which is also available to you in the controller. Use
$.getListener([proxy], [type]) to get all callbacks or only for a specific proxy and/or event type. Finally
$.removeListener([proxy], [type], [callback]) can be used to remove all or specific event listeners. Just like
$.destroy() you can call this when the controller’s UI is “closed” to avoid memory leaks, e.g. by calling it in a Window
In the Alloy sample you will find that we add the same callback as listener to the different events on the first button. In the controller you can see that the second button needs only one line of code to remove all listeners from that first button. While you’re in the controller, also observe that when the controller is created we add a third tracked listener to the first button before logging all tracked listeners. When the window closes we remove all event listeners to any proxy or event in one call. See the console logs for details.
The Alloy sample also demonstrates the following new features:
- You can now use
Alloy.CFG.*properties in XML.
- As well as
The iOS sample demonstrates a few new API’s:
- After MobileWeb and Windows Phone, iOS now also supports Ti.UI.ActivityIndicator.indicatorColor to set the color of the indicator.
- For iPad-only, use showUndoRedoActions on TextFields and TextAreas to determine if iOS 9 should show the undo/redo and copy/paste actions in the toolbar above the soft keyboard. Be aware of TIMOB-19614 when toggling this property.
This release introduces new predefined Titanium themes for Android to hide the action bar and optionally the status bar:
Theme.AppCompat.NoTitleBar: Hides the action and title bar
Theme.AppCompat.NoTitleBar.Fullscreen: Hides the above plus the status bar.
There are four ways to use the existing and new built-in themes:
- Set the
android:themeattribute of the Android manifest
applicationelement in tiapp.xml to
@style/plus the theme name to apply it to use it as default for all windows.
- Set the
parentattribute of your custom theme
@style/plus the theme name.
- Use it for an individual Window via the creation-only
- Instead, set
truein tiapp.xml to select
Play around with the comments in tiapp.xml to see the different themes in action. You can also change the
parent attribute of our custom_theme.xml. Be aware that you need to remove or comment out the
<application> element to test
<fullscreen>. The Android sample demonstrates the use of a window’s
NOTE: If you use a TabGroup in your app then you can not use a theme without action bar. Also be aware of TIMOB-19613.
The android sample demonstrates this new property. Use the slider to change the elevation value. As the TSS shows you need to make sure your view has some space around it or else the parent will clip the elevation shadow. The view also needs a
backgroundColor since a transparent view wouldn’t cast much shadow.
Other Android APIs
This release supports adding a large icon to be shown in the content area of a notification. As the android sample demonstrates simply set the Ti.Android.Notification.largeIcon property to a system or app drawable, like the big fast forward icon I use:
Also new is Ti.UI.Picker.selectionOpens which determines whether calling the method
setSelectedRow() also opens the picker. Tap the button under the picker to see it in action.
Not demonstrated in the sample, but definitely worth mentioning are some new features in the different CLIs:
Also new on the CLI front are two command for the Appcelerator CLI. The
info commands combines the results from
appc ti info with information about Appcelerator CLI Installer and Core Package. The other allows you to switch to another org without needing to logout and in again. Pass
--org-id <id> if you know the ID. We’re working on making this easier in Studio as well.
appc info Display development environment information appc switch org [options] switch logged in org
If you clean a project in Studio or via CLI using
[appc] ti clean it used to only clean the
build folder, but now it also cleans the
Resources folder if it’s an Alloy project. Whenever you run into an issue, always first clean to rule out any errors introduced by the incremental builds we do to speed up your development workflow.
Thanks to a PR by Kosuke Isobe, Alloy now has some of the new commands Kosuke introduced in alloy-smelter:
[appc] alloy copy <source> <destination> copy the controller, view, and style files from <source> to <destination> [appc] alloy move <source> <destination> move the controller, view, and style files from <source> to <destination> [appc] alloy remove <source> remove the controller, view, and style files at <source>
Alloy now supports
<CommandBar> for Windows. We’ve also added support for Windows to a lot of API’s of
Ti.UI.View. Since you’ll know most of these APIs from iOS and Android I haven’t included them in the sample.
Check out this new sample app on GitHub.
In addition to this post, we are also holding a Tech Talk on October 13th to demo these APIs live and answer your questions. Register here.