Details
-
Type:
Bug
-
Status: Closed
-
Priority:
None
-
Resolution: Fixed
-
Affects Version/s: Release 7.0.0
-
Fix Version/s: Release 8.0.1
-
Component/s: Android
-
Labels:
-
Environment:
Studio Ver: 5.0.0.201712081732
SDK Ver: 7.1.0.v20180301114750
OS Ver: 10.13.2
Xcode Ver: Xcode 9.2
Appc NPM: 4.2.12
Appc CLI: 7.0.2
Daemon Ver: 1.0.1
Ti CLI Ver: 5.0.14
Alloy Ver: 1.11.0
Node Ver: 8.9.1
NPM Ver: 5.5.1
Java Ver: 1.8.0_101
Devices: ⇨ google Nexus 6P — Android 8.0.0
⇨ google Nexus 5 — Android 6.0.1Studio Ver: 5.0.0.201712081732 SDK Ver: 7.1.0.v20180301114750 OS Ver: 10.13.2 Xcode Ver: Xcode 9.2 Appc NPM: 4.2.12 Appc CLI: 7.0.2 Daemon Ver: 1.0.1 Ti CLI Ver: 5.0.14 Alloy Ver: 1.11.0 Node Ver: 8.9.1 NPM Ver: 5.5.1 Java Ver: 1.8.0_101 Devices: ⇨ google Nexus 6P — Android 8.0.0 ⇨ google Nexus 5 — Android 6.0.1
-
Story Points:3
Description
Summary:
Assigning a string to Ti.UI.SearchBar property "hintText" after it has been created will cause a crash on Android as of Titanium 7.0.0.
Steps to reproduce:
- Build and run the below code on Android.
- Notice the app crashes on startup.
var window = Ti.UI.createWindow(); |
var searchBar = Ti.UI.createSearchBar({ |
barColor: "white", |
top: 0,
|
width: Ti.UI.FILL,
|
height: "50dp", |
});
|
window.add(searchBar);
|
window.add(Ti.UI.createLabel({ text: "SearchBar Test" })); |
window.addEventListener("open", function(e) { |
searchBar.hintText = "Hint Text"; |
});
|
window.open();
|
Recommended Fix:
When Titanium's "TiUIText.java" class reads property PROPERTY_HINT_TYPE via TiConvert.toInt(), the code needs to set the default value to UIModule.HINT_TYPE_STATIC in the following places in the code.
TiUIText.java#L350
TiUIText.java#L924
Work-Around 1:
Set the "hintText" property when creating the SearchBar, but never afterwards.
var searchBar = Ti.UI.createSearchBar({ |
hintText: "Hint Text", |
});
|
Work-Around 2:
Set SearchBar property "hintType" to Ti.UI.HINT_TYPE_STATIC. This is an undocumented feature of SearchBar but it supports on Android since it internally uses Ti.UI.TextField within the SearchBar.
var window = Ti.UI.createWindow(); |
var searchBar = Ti.UI.createSearchBar({ |
hintType: Ti.UI.HINT_TYPE_STATIC, // <- This works-around the issue. |
});
|
window.add(searchBar);
|
window.addEventListener("open", function() { |
searchBar.hintText = "Hint Text"; |
});
|
window.open();
|