Skip to content

Conversation

@Jason-Whitmore
Copy link
Contributor

@Jason-Whitmore Jason-Whitmore commented Oct 27, 2025

Description (required)

Fixes #6461

What changes did you make and why?

There are two primary sets of changes made.

First, ViewPager2 replaces ViewPager for the Welcome activity. This allows the swiping direction to match the language orientation.

Second, a new view pager indicator replaces the old view pager indicator in the welcome activity. This is because the old indicator was incompatible with ViewPager2 and did not support the RTL orientation. The new indicator is under the Apache 2.0 license.

The "More Information" button's XML has also been modified to match the language orientation (see screenshots).

Tests performed (required)

Tested ProdDebug on Android Studio emulator with API level 36.

To test:

  1. Set the app language to an RTL language (like Hebrew)
  2. Go to the welcome activity (use the hamburger menu, then press the option with the question mark)
  3. Both the swiping direction and the page indicator matches the language orientation.

Test can then be repeated with an LTR language (like English).

Screenshots (for UI changes only)

Both screenshots show last page in the welcome activity. Note the page indicator.
6461_hebrew
6461_english

Summary by CodeRabbit

  • New Features

    • Enhanced support for right-to-left languages with dynamic layout adjustments in the welcome experience
  • UI Improvements

    • Updated welcome screen components with improved page indicators and modern visual presentation

Before this change, the page indicator library that was used
was incompatible with ViewPager2.

This change adds a page indicator library under the Apache 2.0
license that works with ViewPager2. Now the project can take
advantage of ViewPager2 features, such as support for RTL
languages/orientations.
…L orientations

Before this commit, the Welcome activity Kotlin code only supported LTR
orientations.

This commit uses ViewPager2 and a new page indicator to support both
LTR and RTL orientations. The orientation is derived from the user's
app language setting.
Before this commit, the xml files did not support RTL orientation.

This commit adds support for RTL orientation by using ViewPager2
and a new pager indicator. Other small changes also made to support
RTL orientation.
@coderabbitai
Copy link

coderabbitai bot commented Oct 27, 2025

Walkthrough

The welcome screen is migrated from ViewPager to ViewPager2 with RTL-aware indicator support. The adapter transitions from PagerAdapter to RecyclerView.Adapter, orientation detection logic is added to respect UI language preferences for bidirectional layouts, and XML layouts are updated for proper alignment direction.

Changes

Cohort / File(s) Summary
Dependency Configuration
gradle/libs.versions.toml, app/build.gradle.kts
Added ViewPager2 indicator library (version 1.2.3) from zhpanvip/viewpagerindicator as a new UI dependency.
Welcome Activity Setup
app/src/main/java/fr/free/nrw/commons/WelcomeActivity.kt
Integrated ViewPager2 indicator with dynamic RTL orientation detection. Reads UI language preference to determine layout direction via TextUtilsCompat and sets indicator orientation to INDICATOR_RTL or INDICATOR_HORIZONTAL accordingly.
Adapter Migration
app/src/main/java/fr/free/nrw/commons/WelcomePagerAdapter.kt
Refactored from PagerAdapter to RecyclerView.Adapter. Replaced lifecycle methods (getCount → getItemCount, instantiateItem/destroyItem → onCreateViewHolder/onBindViewHolder), introduced getItemViewType for layout selection, and added an inner ViewHolder class.
Welcome Activity Layout
app/src/main/res/layout/activity_welcome.xml
Replaced ViewPager with ViewPager2 and CirclePageIndicator with IndicatorView. Added custom namespace and IndicatorView attributes (vpi_slider_checked_color, vpi_slider_radius), updated finish button gravity from right to end, and added layout_marginBottom.
Final Screen Layout
app/src/main/res/layout/welcome_final.xml
Changed TextView alignment from android:layout_alignParentRight to android:layout_alignParentEnd for bidirectional layout support.

Sequence Diagram(s)

sequenceDiagram
    participant WelcomeActivity as WelcomeActivity
    participant Prefs as Prefs<br/>(defaultKvStore)
    participant Locale as Locale
    participant TextUtils as TextUtilsCompat
    participant IndicatorView as IndicatorView

    WelcomeActivity->>Prefs: Read APP_UI_LANGUAGE preference
    Prefs-->>WelcomeActivity: Return language code
    WelcomeActivity->>Locale: Create Locale from language
    WelcomeActivity->>TextUtils: getLayoutDirectionFromLocale(locale)
    TextUtils-->>WelcomeActivity: Return layout direction
    alt Layout Direction is RTL
        WelcomeActivity->>IndicatorView: Set orientation = INDICATOR_RTL
    else Layout Direction is LTR
        WelcomeActivity->>IndicatorView: Set orientation = INDICATOR_HORIZONTAL
    end
    WelcomeActivity->>IndicatorView: setupWithViewPager(binding.welcomePager)
    IndicatorView-->>WelcomeActivity: Indicator ready with RTL/LTR support
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

Areas requiring extra attention:

  • Adapter refactoring logic (WelcomePagerAdapter.kt): Verify that RecyclerView.Adapter implementation correctly handles all page-specific behavior, especially in onBindViewHolder for the final page (underlined text, click listeners, finishTutorial action).
  • RTL orientation detection (WelcomeActivity.kt): Confirm that language preference reading from defaultKvStore is properly null-checked, and that orientation detection logic works correctly for all supported languages.
  • ViewPager2 compatibility: Ensure that the new IndicatorView library is fully compatible with ViewPager2 and properly syncs indicator position updates with page changes.
  • Layout direction transitions: Test that gravity/alignment changes (right → end, alignParentRight → alignParentEnd) render correctly in both LTR and RTL modes across supported Android versions.

Poem

🐰 Circles now dance from right to left,
Hebrew speakers, no longer bereft!
ViewPager2 brings RTL delight,
Swiping and spinning, a bidirectional sight.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "Fixes Issue 6461: Welcome screen works only from left to right #6461" directly references the core issue being addressed and clearly indicates that the PR is fixing the RTL language support problem in the welcome screen. The title is specific and relates to the primary objective: enabling the welcome screen to work properly with both LTR and RTL languages by migrating to ViewPager2 and updating the page indicator. A developer reviewing the commit history would immediately understand that this PR addresses RTL support in the welcome activity.
Linked Issues Check ✅ Passed The pull request successfully implements all coding requirements from linked issue #6461. The changes include: migrating from ViewPager to ViewPager2 to enable native RTL support (activity_welcome.xml), replacing the old page indicator with a new RTL-compatible indicator library (gradle/libs.versions.toml and build.gradle.kts), implementing dynamic orientation handling in WelcomeActivity.kt to set INDICATOR_RTL for RTL languages and INDICATOR_HORIZONTAL for LTR, adapting the WelcomePagerAdapter from PagerAdapter to RecyclerView.Adapter to work with ViewPager2, and updating layout attributes from right-aligned to end-aligned in welcome_final.xml for bidirectional layout support. All objectives from the linked issue have been addressed through code changes.
Out of Scope Changes Check ✅ Passed All code changes in this pull request are directly scoped to addressing the RTL support requirement from issue #6461. The ViewPager to ViewPager2 migration, adapter refactoring from PagerAdapter to RecyclerView.Adapter, introduction of the new RTL-supporting indicator library, dynamic orientation handling based on UI language preference, and layout direction attribute updates (right to end) are all necessary and integral to solving the reported RTL language issue. No extraneous changes, refactoring unrelated to this objective, or scope creep has been introduced.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1d216ac and 410520b.

📒 Files selected for processing (6)
  • app/build.gradle.kts (1 hunks)
  • app/src/main/java/fr/free/nrw/commons/WelcomeActivity.kt (2 hunks)
  • app/src/main/java/fr/free/nrw/commons/WelcomePagerAdapter.kt (1 hunks)
  • app/src/main/res/layout/activity_welcome.xml (2 hunks)
  • app/src/main/res/layout/welcome_final.xml (1 hunks)
  • gradle/libs.versions.toml (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
app/src/main/java/fr/free/nrw/commons/WelcomePagerAdapter.kt (1)
app/src/main/java/fr/free/nrw/commons/utils/UrlUtils.kt (1)
  • handleWebUrl (16-33)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Run tests and generate APK
🔇 Additional comments (11)
app/src/main/res/layout/welcome_final.xml (1)

70-70: LGTM! Proper RTL-aware alignment.

Changing from layout_alignParentRight to layout_alignParentEnd correctly supports bidirectional layouts, ensuring the "More Information" button aligns appropriately in both LTR and RTL languages.

app/build.gradle.kts (1)

234-234: LGTM! ViewPager2 indicator dependency added.

The dependency correctly references the library alias declared in gradle/libs.versions.toml and is appropriately placed in the UI dependencies section.

app/src/main/res/layout/activity_welcome.xml (3)

5-5: LGTM! ViewPager2 migration is correctly implemented.

The migration from ViewPager to ViewPager2 with the custom namespace declaration enables the new indicator library attributes and provides native RTL support.

Also applies to: 8-12


18-18: LGTM! RTL-aware alignment for skip button.

Changing to layout_gravity="end" ensures the skip button aligns correctly for both LTR and RTL layouts.


26-34: LGTM! IndicatorView configuration is appropriate.

The IndicatorView replaces the old CirclePageIndicator with proper RTL-aware attributes. The positioning (bottom|center_horizontal) and styling (white color, 3dp radius) maintain visual consistency with the welcome flow design.

app/src/main/java/fr/free/nrw/commons/WelcomeActivity.kt (2)

53-53: LGTM! Indicator setup with ViewPager2.

The setupWithViewPager method correctly binds the IndicatorView to the ViewPager2 instance.


55-66: LGTM! RTL orientation detection is correctly implemented.

The logic properly detects RTL languages by:

  1. Reading the language preference from shared preferences
  2. Creating a Locale and checking its layout direction
  3. Defaulting to horizontal (LTR) orientation when language is not set
  4. Setting the indicator orientation accordingly
app/src/main/java/fr/free/nrw/commons/WelcomePagerAdapter.kt (3)

12-12: LGTM! Clean migration to RecyclerView.Adapter.

The adapter correctly extends RecyclerView.Adapter<ViewHolder> and implements the required methods. Using getItemViewType to return the position as the layout selector is a valid approach for this use case.

Also applies to: 17-17, 19-21


23-27: LGTM! ViewHolder implementation follows standard pattern.

The onCreateViewHolder method properly inflates layouts based on the view type, and the ViewHolder class follows the minimal but correct pattern for this adapter.

Also applies to: 51-51


29-49: LGTM! Final page binding logic is correct.

The onBindViewHolder method properly handles the special behavior for the final page:

  • Underlines the "More Information" text
  • Wires up the web URL click handler
  • Connects the "YES!" button to the tutorial completion flow

The context cast to WelcomeActivity on line 47 is safe given that this adapter is only used within WelcomeActivity, as confirmed by the activity's onCreate method.

gradle/libs.versions.toml (1)

72-72: Version 1.2.3 is confirmed as the latest stable release.

The version and library reference are correctly configured. Version 1.2.3 is the latest numeric release (published Jun 6, 2025), making it an appropriate choice for a production dependency.


Comment @coderabbitai help to get the list of available commands and usage tips.

@Jason-Whitmore
Copy link
Contributor Author

Jason-Whitmore commented Oct 27, 2025

Also, I tried to make the new page indicator look like the old one. There are a few XML options listed at the library repo to change the appearance. I can make more changes, if needed.

@nicolas-raoul
Copy link
Member

@amire80 Are you able to test this, by any chance? If you need help with checking out this branch or with building, I can help. :-)

@github-actions
Copy link

✅ Generated APK variants!

@amire80 amire80 self-assigned this Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Welcome screen works only from left to right

3 participants