Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-25832

Android: Setting Ti.UI.SearchBar "hintText" property after creation causes a crash as of 7.0.0

    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
    • Environment:
    • 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:

      1. Build and run the below code on Android.
      2. 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();
      

        Attachments

          Activity

            People

            • Assignee:
              jquick Joshua Quick
              Reporter:
              lchoudhary Lokesh Choudhary
              Reviewer:
              Gary Mathews
              Tester:
              Keerthi Mahalingam (Inactive)
            • Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-6226
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Integration