Skip to content

[Bug] App crashes if forcing RTL layout direction with WormIndicatorType #207

Open
@zszekeres65

Description

@zszekeres65

🐛 Bug Report

Describe the Bug
Using the WormIndicatorType can cause a crash (IllegalArgumentException: Padding must be non-negative) if the user forces RTL layout direction.

Steps to Reproduce
Steps to reproduce the behavior:

  1. Go to System Settings > Developer Options
  2. Enable 'Force RTL layout direction'
  3. Open a sample app that implements WormIndicatorType
  4. Sample app crashes with IllegalArgumentException

Expected Behavior
App should not crash.

Actual Behavior
App crashes.

Screenshots or Videos
N/A

Environment

  • Library version: [5.1.0]
  • Android version: [14]
  • Device: [Samsung S22]
  • ViewPager for Jetpack Compose or XML: Jetpack Compose
  • ViewPager type: ViewPager2

Additional Context
The width measurements stays LTR direction, which results a bigger value of firstDotPositionX than the lastDotPositionX. The value of distanceBetween2DotsDp will be negative and multiplying with this value cause negative paddings.
Locally, I could fix the issue by getting the current LayoutDirection and setting the firstDotPositionX and lastDotPositionX based on that's value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions