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

Android: Ti.UI.Notifications logs errors because of alignment, margins and gravity

    Details

    • Story Points:
      3

      Description

      When showing a Ti.UI.Notification, the console always logs an error since a few Android versions (mostly noted since Android 11):

      [ERROR] Toast: getHorizontalMargin() shouldn't be called on text toasts, the result may not reflect actual values.
      [ERROR] Toast: getVerticalMargin() shouldn't be called on text toasts, the result may not reflect actual values.
      [ERROR] Toast: getXOffset() shouldn't be called on text toasts, the result may not reflect actual values.
      [ERROR] Toast: getYOffset() shouldn't be called on text toasts, the result may not reflect actual values.
      [ERROR] Toast: getGravity() shouldn't be called on text toasts, the result may not reflect actual values.
      [ERROR] Toast: setMargin() shouldn't be called on text toasts, the values won't be used
      [ERROR] Toast: setGravity() shouldn't be called on text toasts, the values won't be used
      

      The issue can be fixed by guarding the related properties to only access them if we really want to override alignment, gravity or margins.

      Test case:

      const window = Ti.UI.createWindow();
      window.addEventListener('open', () => {
          Ti.UI.createNotification({
              title: 'Hello world',
              duration: Ti.UI.NOTIFICATION_DURATION_SHORT
          }).show();
      });
      window.open();
      

        Attachments

          Activity

            People

            • Assignee:
              jquick Joshua Quick
              Reporter:
              hknoechel Hans Knöchel
              Reviewer:
              Joshua Quick
            • Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Integration