Skip to content

Implement multi-language support with language selection screen - #8

Open
gyanu2507 wants to merge 6 commits into
allknowledge34:mainfrom
gyanu2507:feature/multi-language-support
Open

Implement multi-language support with language selection screen#8
gyanu2507 wants to merge 6 commits into
allknowledge34:mainfrom
gyanu2507:feature/multi-language-support

Conversation

@gyanu2507

@gyanu2507 gyanu2507 commented Dec 21, 2025

Copy link
Copy Markdown

Description

This PR implements multi-language support for the UpdateApp with a fully functional language selection screen, as requested in issue #7.

Changes Made

New Features

  • ✅ Added support for 10 languages: English, Chinese, Hindi, Spanish, Arabic, French, Bengali, Portuguese, Russian, and Urdu
  • ✅ Implemented language selection screen with RecyclerView displaying all available languages
  • ✅ Immediate language switching when a language is selected
  • ✅ Language preference persistence using SharedPreferences
  • ✅ Language preference persists after app restart

New Files Created

  • LocaleHelper.java - Utility class for managing locale changes and persistence
  • UpdateAppApplication.java - Custom Application class to initialize locale on app start
  • LanguageModel.java - Model class for language data
  • LanguageAdapter.java - RecyclerView adapter for language list
  • item_language.xml - Layout for language list items
  • strings.xml files for all 10 languages in their respective values-<lang>/ directories

Files Modified

  • LanguageActivity.java - Implemented full language selection functionality
  • MainActivity.java - Added locale support via attachBaseContext
  • ProfileFragment.java - Removed "Coming Soon" toast message
  • AndroidManifest.xml - Added custom Application class
  • strings.xml (base) - Added language name strings

Technical Implementation

  • Uses Android's standard localization system (strings.xml)
  • Supports both Android N+ (API 24+) and older versions
  • No UI redesign required - uses existing layout
  • Follows Android best practices for multi-language support

Summary by CodeRabbit

  • New Features

    • Added multi-language support with persistent language selection
    • Language selection screen now appears on first app launch
    • Supported languages: English, Arabic, Bengali, Spanish, French, Hindi, Portuguese, Russian, Urdu, and Chinese
    • Selected language preference is saved and automatically applied across the app
  • Bug Fixes

    • Fixed RecyclerView identifier naming inconsistency

✏️ Tip: You can customize this high-level summary in your review settings.

- Add support for 10 languages: English, Chinese, Hindi, Spanish, Arabic, French, Bengali, Portuguese, Russian, Urdu
- Create LocaleHelper utility class for managing locale changes
- Add UpdateAppApplication class to initialize locale on app start
- Implement LanguageActivity with RecyclerView for language selection
- Create LanguageAdapter and LanguageModel for language list
- Add strings.xml files for all supported languages
- Update MainActivity and LanguageActivity to support locale changes
- Language preference persists after app restart
- Immediate language switching when language is selected

Fixes allknowledge34#7
@coderabbitai

coderabbitai Bot commented Dec 21, 2025

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 38cca76d-0c53-4696-a0cc-7599b14aade3

📝 Walkthrough

Walkthrough

Introduces app-wide locale management infrastructure by creating a LocaleHelper utility class that persists language preferences to SharedPreferences, adding an Application subclass to apply locale at startup, and modifying the launch flow to present a language selection screen on first run.

Changes

Cohort / File(s) Summary
Locale Management Infrastructure
app/src/main/java/com/example/updateapp/Helpers/LocaleHelper.java, app/src/main/java/com/example/updateapp/UpdateAppApplication.java
New LocaleHelper utility with setLocale, attachBaseContext, and getSavedLanguage methods storing preferences under "app_prefs"; new UpdateAppApplication extends Application and wires LocaleHelper.attachBaseContext for app-wide locale configuration.
Activity Locale Integration
app/src/main/java/com/example/updateapp/MainActivity.java, app/src/main/java/com/example/updateapp/views/activites/LoginActivity.java, app/src/main/java/com/example/updateapp/views/activites/NewUpdateActivity.java, app/src/main/java/com/example/updateapp/views/activites/OTPActivity.java, app/src/main/java/com/example/updateapp/views/activites/OnboardingActivity.java, app/src/main/java/com/example/updateapp/views/activites/SignUpActivity.java
Import LocaleHelper from Helpers package; LoginActivity adds attachBaseContext override wrapping context via LocaleHelper.onAttach.
Launch Flow and Language Selection
app/src/main/java/com/example/updateapp/views/activites/SplashScreenActivity.java, app/src/main/java/com/example/updateapp/views/activites/LanguageActivity.java
SplashScreenActivity adds language-first logic checking LANGUAGE_SELECTED state and conditionally routing to LanguageActivity for first-time users; adds attachBaseContext override. LanguageActivity declares recyclerView, adapter, languageList, and currentLanguageCode fields.
Layout and String Resources
app/src/main/res/layout/activity_language.xml, app/src/main/res/layout/item_language.xml, app/src/main/res/values-{ar,bn,es,fr,hi,pt,ru,ur,zh}/strings.xml
RecyclerView ID corrected from rev_langauge to rev_language in activity_language.xml; trailing newlines added to layout and locale string resource files.
Model Formatting
app/src/main/java/com/example/updateapp/models/LanguageModel.java, app/src/main/java/com/example/updateapp/adapters/LanguageAdapter.java
Trailing newline formatting updates; no functional changes.

Sequence Diagram

sequenceDiagram
    participant User
    participant App as App Launch
    participant UAA as UpdateAppApplication
    participant LH as LocaleHelper
    participant SP as SharedPreferences
    participant SSA as SplashScreenActivity
    participant LA as LanguageActivity
    participant OBA as OnboardingActivity

    User->>App: Start App
    App->>UAA: attachBaseContext()
    UAA->>LH: attachBaseContext(context)
    LH->>SP: getSavedLanguage()
    SP-->>LH: saved_language or "en"
    LH->>LH: apply Locale to Configuration
    LH-->>UAA: localized context
    UAA-->>App: context configured

    App->>SSA: Launch SplashScreenActivity
    SSA->>SP: read LANGUAGE_SELECTED
    alt Language Not Selected (First Launch)
        SSA->>LA: navigate to LanguageActivity
        LA->>User: show language selection
        User->>LA: select language
        LA->>LH: setLocale(context, languageCode)
        LH->>SP: save selected_language
        LA->>OBA: navigate to OnboardingActivity
    else Language Already Selected
        SSA->>OBA: navigate to OnboardingActivity
    end
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly Related PRs

Poem

🐰 A language for each and each for all,
Our helper hops through context's call,
SharedPreferences guard the tongue of choice,
First launch asks—now users have a voice! 🌍✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Implement multi-language support with language selection screen' directly and clearly summarizes the main objective of the PR, which is adding multi-language support and a language selection screen.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@gyanu2507

Copy link
Copy Markdown
Author

@allknowledge34, please review the PR

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 10

🧹 Nitpick comments (11)
app/src/main/res/values-zh/strings.xml (1)

3-3: Optional: Consider translating placeholder text.

The "Hello blank fragment" placeholder remains in English. While the base file has a TODO to remove or change this, if it's user-facing, it should be translated to "你好,空白片段" or similar.

app/src/main/res/layout/item_language.xml (2)

13-13: Remove the hard-coded default text.

The hard-coded text "English" should be removed or replaced with an empty string. The text is set dynamically by the adapter, so this placeholder is unnecessary and could cause confusion during development.

🔎 Proposed fix
-        android:text="English"
+        android:text=""

15-15: Consider using theme-aware color.

Using @color/black directly may not adapt well to dark mode themes. Consider using a theme attribute like ?android:attr/textColorPrimary or defining a color in your theme that adapts to light/dark modes.

🔎 Proposed fix
-        android:textColor="@color/black" />
+        android:textColor="?android:attr/textColorPrimary" />
app/src/main/res/values-fr/strings.xml (1)

3-3: Untranslated string: hello_blank_fragment.

This string remains in English across all locales. If this is intentional (e.g., a debug/placeholder string), consider adding a comment. Otherwise, provide translations for consistency.

app/src/main/java/com/example/updateapp/views/activites/LanguageActivity.java (1)

68-90: Consider extracting language configuration to constants.

The language codes and their mapping to string resource IDs are hard-coded in the method. Consider extracting these to a constants class or configuration file to improve maintainability, especially if you plan to add more languages in the future.

Example refactor

Create a constants class:

public class LanguageConstants {
    public static final String[] LANGUAGE_CODES = {
        "en", "zh", "hi", "es", "ar", "fr", "bn", "pt", "ru", "ur"
    };
    
    public static final int[] LANGUAGE_NAME_RES_IDS = {
        R.string.language_english,
        R.string.language_chinese,
        R.string.language_hindi,
        R.string.language_spanish,
        R.string.language_arabic,
        R.string.language_french,
        R.string.language_bengali,
        R.string.language_portuguese,
        R.string.language_russian,
        R.string.language_urdu
    };
}
app/src/main/java/com/example/updateapp/Helpers/LocaleHelper.java (1)

15-47: Code duplication: locale configuration logic repeated.

The locale configuration setup is duplicated between setLocale() (lines 19-24) and attachBaseContext() (lines 38-41). Consider extracting this into a private helper method to reduce duplication and improve maintainability.

Example refactor
private static Configuration createLocaleConfiguration(Context context, Locale locale) {
    Configuration configuration = context.getResources().getConfiguration();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        configuration.setLocale(locale);
    } else {
        configuration.locale = locale;
    }
    return configuration;
}

Then use it in both methods to eliminate duplication.

app/src/main/java/com/example/updateapp/adapters/LanguageAdapter.java (3)

26-29: Consider adding null checks for defensive coding.

The constructor accepts languageList and listener without validation. While the listener has a null check at Line 45, the list does not. If null is passed for languageList, it will cause an NPE when getItemCount() is called.

🔎 Suggested defensive null checks
 public LanguageAdapter(List<LanguageModel> languageList, OnLanguageClickListener listener) {
+    if (languageList == null) {
+        throw new IllegalArgumentException("languageList cannot be null");
+    }
     this.languageList = languageList;
     this.listener = listener;
 }

44-48: Consider moving click listener to ViewHolder constructor.

Setting the click listener in onBindViewHolder means a new lambda is created every time an item is bound (including during scrolling). Moving the listener setup to the ViewHolder constructor is a better practice.

🔎 Suggested refactor

Modify the ViewHolder constructor:

 public ViewHolder(@NonNull View itemView) {
     super(itemView);
     languageName = itemView.findViewById(R.id.txt_language_name);
     selectedIcon = itemView.findViewById(R.id.img_selected);
+    
+    itemView.setOnClickListener(v -> {
+        int position = getAdapterPosition();
+        if (position != RecyclerView.NO_POSITION && listener != null) {
+            listener.onLanguageClick(languageList.get(position));
+        }
+    });
 }

Then remove the click listener from onBindViewHolder:

 @Override
 public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
     LanguageModel language = languageList.get(position);
     holder.languageName.setText(language.getLanguageName());
     holder.selectedIcon.setVisibility(language.isSelected() ? View.VISIBLE : View.GONE);
-
-    holder.itemView.setOnClickListener(v -> {
-        if (listener != null) {
-            listener.onLanguageClick(language);
-        }
-    });
 }

56-61: Optimize selection updates with targeted notifications.

Using notifyDataSetChanged() refreshes the entire RecyclerView, which is inefficient. Since only two items change state during selection (the previously selected item and the newly selected item), use notifyItemChanged() for better performance.

🔎 Optimized implementation
 public void updateSelection(String selectedLanguageCode) {
+    int previouslySelectedPosition = -1;
+    int newSelectedPosition = -1;
+    
-    for (LanguageModel language : languageList) {
-        language.setSelected(language.getLanguageCode().equals(selectedLanguageCode));
+    for (int i = 0; i < languageList.size(); i++) {
+        LanguageModel language = languageList.get(i);
+        boolean wasSelected = language.isSelected();
+        boolean shouldBeSelected = language.getLanguageCode().equals(selectedLanguageCode);
+        
+        if (wasSelected && !shouldBeSelected) {
+            previouslySelectedPosition = i;
+            language.setSelected(false);
+        } else if (!wasSelected && shouldBeSelected) {
+            newSelectedPosition = i;
+            language.setSelected(true);
+        }
     }
-    notifyDataSetChanged();
+    
+    if (previouslySelectedPosition != -1) {
+        notifyItemChanged(previouslySelectedPosition);
+    }
+    if (newSelectedPosition != -1) {
+        notifyItemChanged(newSelectedPosition);
+    }
 }
app/src/main/java/com/example/updateapp/models/LanguageModel.java (2)

8-12: Consider adding parameter validation.

The constructor accepts languageCode and languageName without validation. While the current implementation works, adding basic null checks would make the class more robust and catch issues earlier.

🔎 Suggested validation
 public LanguageModel(String languageCode, String languageName, boolean isSelected) {
+    if (languageCode == null || languageCode.trim().isEmpty()) {
+        throw new IllegalArgumentException("languageCode cannot be null or empty");
+    }
+    if (languageName == null || languageName.trim().isEmpty()) {
+        throw new IllegalArgumentException("languageName cannot be null or empty");
+    }
     this.languageCode = languageCode;
     this.languageName = languageName;
     this.isSelected = isSelected;
 }

3-36: Consider implementing equals() and hashCode().

For a data model class, implementing equals() and hashCode() based on languageCode would enable proper object comparison and use in collections. This becomes useful if you need to compare language objects or use them as Map keys.

🔎 Suggested implementation
+import java.util.Objects;
+
 public class LanguageModel {
     private String languageCode;
     private String languageName;
     private boolean isSelected;
     
     // ... existing constructor, getters and setters ...
+    
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        LanguageModel that = (LanguageModel) o;
+        return Objects.equals(languageCode, that.languageCode);
+    }
+    
+    @Override
+    public int hashCode() {
+        return Objects.hash(languageCode);
+    }
 }
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 158ee93 and 60c243b.

📒 Files selected for processing (19)
  • app/src/main/AndroidManifest.xml (1 hunks)
  • app/src/main/java/com/example/updateapp/Helpers/LocaleHelper.java (1 hunks)
  • app/src/main/java/com/example/updateapp/MainActivity.java (2 hunks)
  • app/src/main/java/com/example/updateapp/UpdateAppApplication.java (1 hunks)
  • app/src/main/java/com/example/updateapp/adapters/LanguageAdapter.java (1 hunks)
  • app/src/main/java/com/example/updateapp/models/LanguageModel.java (1 hunks)
  • app/src/main/java/com/example/updateapp/views/activites/LanguageActivity.java (2 hunks)
  • app/src/main/java/com/example/updateapp/views/fragments/ProfileFragment.java (0 hunks)
  • app/src/main/res/layout/item_language.xml (1 hunks)
  • app/src/main/res/values-ar/strings.xml (1 hunks)
  • app/src/main/res/values-bn/strings.xml (1 hunks)
  • app/src/main/res/values-es/strings.xml (1 hunks)
  • app/src/main/res/values-fr/strings.xml (1 hunks)
  • app/src/main/res/values-hi/strings.xml (1 hunks)
  • app/src/main/res/values-pt/strings.xml (1 hunks)
  • app/src/main/res/values-ru/strings.xml (1 hunks)
  • app/src/main/res/values-ur/strings.xml (1 hunks)
  • app/src/main/res/values-zh/strings.xml (1 hunks)
  • app/src/main/res/values/strings.xml (1 hunks)
💤 Files with no reviewable changes (1)
  • app/src/main/java/com/example/updateapp/views/fragments/ProfileFragment.java
🧰 Additional context used
🧬 Code graph analysis (4)
app/src/main/java/com/example/updateapp/UpdateAppApplication.java (1)
app/src/main/java/com/example/updateapp/Helpers/LocaleHelper.java (1)
  • LocaleHelper (11-53)
app/src/main/java/com/example/updateapp/adapters/LanguageAdapter.java (1)
app/src/main/java/com/example/updateapp/models/LanguageModel.java (1)
  • LanguageModel (3-37)
app/src/main/java/com/example/updateapp/views/activites/LanguageActivity.java (3)
app/src/main/java/com/example/updateapp/Helpers/LocaleHelper.java (1)
  • LocaleHelper (11-53)
app/src/main/java/com/example/updateapp/adapters/LanguageAdapter.java (1)
  • LanguageAdapter (17-73)
app/src/main/java/com/example/updateapp/models/LanguageModel.java (1)
  • LanguageModel (3-37)
app/src/main/java/com/example/updateapp/MainActivity.java (1)
app/src/main/java/com/example/updateapp/Helpers/LocaleHelper.java (1)
  • LocaleHelper (11-53)
🔇 Additional comments (11)
app/src/main/res/values/strings.xml (1)

6-16: LGTM! Native script approach is correct for language selection.

The language names are properly displayed in their native scripts (e.g., 中文, हिन्दी, العربية), which is the recommended UX pattern for language selection screens. This ensures users can identify their language regardless of the current app locale.

app/src/main/AndroidManifest.xml (1)

10-10: LGTM! Custom Application class properly wired for locale initialization.

The custom Application class is correctly configured to enable app-wide locale handling via UpdateAppApplication.attachBaseContext(). This is the standard approach for implementing persistent language selection in Android.

app/src/main/java/com/example/updateapp/MainActivity.java (1)

59-62: LGTM! Locale handling properly implemented.

The attachBaseContext override correctly delegates to LocaleHelper.attachBaseContext() to ensure the saved language preference is applied. This follows Android best practices for per-activity locale configuration.

app/src/main/java/com/example/updateapp/UpdateAppApplication.java (1)

8-12: LGTM! Correct locale initialization pattern.

The Application class correctly wraps the base context using LocaleHelper before passing it to the superclass. This ensures the saved locale is applied application-wide at startup.

app/src/main/java/com/example/updateapp/views/activites/LanguageActivity.java (2)

92-108: Language selection logic implemented correctly.

The language selection flow properly:

  • Checks if the language actually changed before applying
  • Uses LocaleHelper to persist and apply the locale
  • Updates the adapter selection state
  • Calls recreate() to immediately reflect the language change in the UI

The use of recreate() is appropriate here despite resetting activity state, as language changes should provide immediate visual feedback.


110-113: Correct attachBaseContext implementation.

The activity correctly overrides attachBaseContext to apply the saved locale, ensuring consistency with the Application-level locale handling.

app/src/main/java/com/example/updateapp/Helpers/LocaleHelper.java (2)

33-47: attachBaseContext correctly handles API version differences.

The method properly creates a new configuration context for API 24+ while falling back to the deprecated updateConfiguration for older versions. This is the correct pattern for handling locales in attachBaseContext.


49-52: LGTM! Clean SharedPreferences accessor.

The method provides a simple, clean way to retrieve the saved language with a sensible default.

app/src/main/res/values-ar/strings.xml (1)

1-16: RTL layout support for Arabic and Urdu is properly implemented.

Verification confirms all RTL requirements are met:

  • android:supportsRtl="true" is set in the element in AndroidManifest.xml
  • Layout files use start/end attributes; no deprecated left/right attributes remain (e.g., item_language.xml correctly uses layout_alignParentEnd)
  • Urdu translations (values-ur/strings.xml) are present and complete

No further action required.

app/src/main/java/com/example/updateapp/adapters/LanguageAdapter.java (2)

31-36: LGTM!

Standard and correct implementation of onCreateViewHolder.


63-72: LGTM!

Standard and correct ViewHolder implementation.

Comment thread app/src/main/java/com/example/updateapp/adapters/LanguageAdapter.java Outdated
Comment thread app/src/main/java/com/example/updateapp/Helpers/LocaleHelper.java Outdated
Comment thread app/src/main/res/layout/item_language.xml
Comment thread app/src/main/res/values-bn/strings.xml Outdated
Comment thread app/src/main/res/values-es/strings.xml Outdated
Comment thread app/src/main/res/values-fr/strings.xml Outdated
Comment thread app/src/main/res/values-ru/strings.xml Outdated
Comment thread app/src/main/res/values-ur/strings.xml Outdated
Comment thread app/src/main/res/values-zh/strings.xml Outdated
@allknowledge34
allknowledge34 requested review from allknowledge34 and removed request for allknowledge34 December 21, 2025 14:41
@allknowledge34

Copy link
Copy Markdown
Owner

@gyanu2507 , please review the PR

Thanks for your effort and for submitting this PR.

I have reviewed the code and tested the implementation, but unfortunately this PR does not meet the original requirements yet.

Issues found:

  1. App-wide language change is not working.

    • The language change is applied only to LanguageActivity.
    • Other screens (login, signup, profile, buttons, messages, etc.) do not update their language.
    • The requirement was to change the language across the entire app.
  2. English language switching is broken.

    • Switching from Hindi (or other languages) back to English does not work correctly.
    • In some cases, a different language is applied instead of English.
    • This indicates incorrect locale reset handling.
  3. Incorrect use of strings.xml files.

    • The language-specific strings.xml files only contain translations for the language selection screen.
    • Core app texts are still hardcoded or not localized.
    • For proper multi-language support, all app text must be moved to strings.xml and translated consistently across all languages with the same keys.
  4. UI/UX issues in the language selection screen.

    • The RecyclerView layout looks very basic and unpolished.
    • Selection state and visual feedback are not clear.
    • Overall UI does not feel production-ready and needs improvement.

Requirement clarification:

  • All visible text in the app must support localization.
  • Each language must have the same string keys across all strings.xml files.
  • Language switching must apply to the entire app immediately.
  • Switching back to English must work correctly.
  • The language selection UI should be clean, clear, and user-friendly.

Because this is a paid issue, I need the above points to be fixed before I can verify, merge, and proceed with payment.

Please update the implementation accordingly and let me know once it is ready for re-review.

- Add first-launch language selection in SplashScreenActivity
- Integrate LocaleHelper in all activities for consistent language support
- Update LanguageActivity to handle first-launch navigation
- Add language selection tracking using SaveState
- Support for 10 languages: English, Chinese, Hindi, Spanish, Arabic, French, Bengali, Portuguese, Russian, Urdu

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (5)
app/src/main/java/com/example/updateapp/views/activites/SignUpActivity.java (1)

50-52: Hardcoded strings prevent localization from working app-wide.

Per reviewer feedback, the locale change only affects screens with localized strings. These hardcoded UI texts (progress dialog messages, error messages, toast messages) will not change when the user switches languages. All visible text must be moved to strings.xml with consistent keys across all locale files.

Examples in this file:

  • Lines 51-52: "Creating Your Account", "Your Account Is Creating"
  • Lines 77-80: Validation error messages
  • Lines 102-104: "This email is already registered..."
🔎 Example fix for progress dialog strings

Add to res/values/strings.xml:

<string name="creating_account_title">Creating Your Account</string>
<string name="creating_account_message">Your Account Is Creating</string>

Then update the code:

 progressDialog = new ProgressDialog(this);
-progressDialog.setTitle("Creating Your Account");
-progressDialog.setMessage("Your Account Is Creating");
+progressDialog.setTitle(getString(R.string.creating_account_title));
+progressDialog.setMessage(getString(R.string.creating_account_message));

Also applies to: 77-80, 102-104

app/src/main/java/com/example/updateapp/views/activites/LoginActivity.java (1)

68-70: Hardcoded strings will not respond to language changes.

This activity contains numerous hardcoded strings that won't be localized when the user changes language. Per the PR requirements, all visible text must be externalized to strings.xml:

  • Lines 69-70: "Logging In", "Please wait..."
  • Lines 80, 82, 114, 116: Validation error messages
  • Lines 212-213: "Firebase Authentication Failed"

Extract these to string resources with the same keys defined in all locale files.

Also applies to: 80-82, 114-116, 211-213

app/src/main/java/com/example/updateapp/views/activites/OTPActivity.java (1)

59-61: Hardcoded strings prevent app-wide localization.

This activity has multiple hardcoded strings that won't be translated when the user changes language:

  • Lines 60-61: "Verifying OTP", "Please wait..."
  • Line 74: "Please enter valid OTP"
  • Lines 157, 163: OTP error messages
  • Lines 188-194: Account linking error messages

These must be extracted to strings.xml and translated in all locale files.

Also applies to: 74-74, 156-158, 188-194

app/src/main/java/com/example/updateapp/views/activites/ForgetActivity.java (2)

38-38: Hardcoded string needs localization.

The string "Please Wait" should be moved to strings.xml and referenced via getString(R.string.please_wait). Per reviewer feedback, all visible text must support localization for the language switch to work app-wide.

🔎 Proposed fix
-        progressDialog.setTitle("Please Wait");
+        progressDialog.setTitle(getString(R.string.please_wait));

Add to all strings.xml files:

<string name="please_wait">Please Wait</string>

46-48: Additional hardcoded strings require localization.

Lines 48, 61, and 69 contain hardcoded user-facing strings ("Enter Valid Email", "Please Check Your Email", and the Firebase exception message display). These should all use string resources for full multi-language support.

🔎 Proposed fix for line 48
-                    binding.edtForgetEmail.setError("Enter Valid Email");
+                    binding.edtForgetEmail.setError(getString(R.string.enter_valid_email));
🔎 Proposed fix for line 61
-                                Toast.makeText(ForgetActivity.this, "Please Check Your Email", Toast.LENGTH_SHORT).show();
+                                Toast.makeText(ForgetActivity.this, getString(R.string.check_your_email), Toast.LENGTH_SHORT).show();
♻️ Duplicate comments (6)
app/src/main/res/values-fr/strings.xml (1)

4-4: OAuth client ID still hardcoded in version control.

The hardcoded default_web_client_id from a previous review comment has not been addressed. This value should be moved to gradle.properties (excluded from VCS) or injected via BuildConfig, not committed across all locale files.

app/src/main/res/values-es/strings.xml (1)

6-15: Language names should use native scripts.

This issue was already flagged in a previous review. Language names should be displayed in their native scripts (e.g., "中文" for Chinese, "हिन्दी" for Hindi) so users can identify their language regardless of current locale.

app/src/main/res/layout/item_language.xml (1)

17-24: Missing contentDescription for accessibility.

The ImageView lacks a contentDescription attribute, which is required for accessibility. Screen readers need this to describe the checkmark icon to users.

This was already flagged in a previous review.

app/src/main/java/com/example/updateapp/views/activites/LanguageActivity.java (1)

46-46: Typo in resource ID: rev_langauge.

This should be rev_language. The typo exists in the layout XML file and should be fixed for consistency.

This was already flagged in a previous review.

app/src/main/java/com/example/updateapp/adapters/LanguageAdapter.java (1)

56-61: Critical: Unresolved NPE risk in updateSelection.

The past review correctly identified that Line 58 will throw a NullPointerException if selectedLanguageCode is null and language.getLanguageCode() is non-null. This issue remains unaddressed and must be fixed before merge.

🔎 Recommended null-safe fix
 public void updateSelection(String selectedLanguageCode) {
     for (LanguageModel language : languageList) {
-        language.setSelected(language.getLanguageCode().equals(selectedLanguageCode));
+        language.setSelected(selectedLanguageCode != null && 
+                           selectedLanguageCode.equals(language.getLanguageCode()));
     }
     notifyDataSetChanged();
 }

Alternatively, use Objects.equals() for a more concise solution:

+import java.util.Objects;
+
 // ...
 
 public void updateSelection(String selectedLanguageCode) {
     for (LanguageModel language : languageList) {
-        language.setSelected(language.getLanguageCode().equals(selectedLanguageCode));
+        language.setSelected(Objects.equals(language.getLanguageCode(), selectedLanguageCode));
     }
     notifyDataSetChanged();
 }
app/src/main/res/values-ur/strings.xml (1)

6-15: Critical: Language names must use native scripts, not Urdu translations.

This issue was flagged in the previous review but remains unaddressed. When all language names are written in Urdu script, users who don't read Urdu cannot identify or select their preferred language. Each language must appear in its own native script.

🔎 Required fix: Use native scripts for language names
-    <string name="language_english">انگریزی</string>
-    <string name="language_chinese">چینی</string>
-    <string name="language_hindi">ہندی</string>
-    <string name="language_spanish">ہسپانوی</string>
-    <string name="language_arabic">عربی</string>
-    <string name="language_french">فرانسیسی</string>
-    <string name="language_bengali">بنگالی</string>
-    <string name="language_portuguese">پرتگالی</string>
-    <string name="language_russian">روسی</string>
-    <string name="language_urdu">اردو</string>
+    <string name="language_english">English</string>
+    <string name="language_chinese">中文</string>
+    <string name="language_hindi">हिन्दी</string>
+    <string name="language_spanish">Español</string>
+    <string name="language_arabic">العربية</string>
+    <string name="language_french">Français</string>
+    <string name="language_bengali">বাংলা</string>
+    <string name="language_portuguese">Português</string>
+    <string name="language_russian">Русский</string>
+    <string name="language_urdu">اردو</string>

Note: This same correction must be applied to all other locale-specific strings.xml files (values-ar, values-bn, values-es, values-fr, values-hi, values-pt, values-ru, values-zh).

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 60c243b and 87743a4.

📒 Files selected for processing (22)
  • app/src/main/java/com/example/updateapp/Helpers/LocaleHelper.java
  • app/src/main/java/com/example/updateapp/UpdateAppApplication.java
  • app/src/main/java/com/example/updateapp/adapters/LanguageAdapter.java
  • app/src/main/java/com/example/updateapp/models/LanguageModel.java
  • app/src/main/java/com/example/updateapp/views/activites/ForgetActivity.java
  • app/src/main/java/com/example/updateapp/views/activites/LanguageActivity.java
  • app/src/main/java/com/example/updateapp/views/activites/LoginActivity.java
  • app/src/main/java/com/example/updateapp/views/activites/NewUpdateActivity.java
  • app/src/main/java/com/example/updateapp/views/activites/OTPActivity.java
  • app/src/main/java/com/example/updateapp/views/activites/OnboardingActivity.java
  • app/src/main/java/com/example/updateapp/views/activites/SignUpActivity.java
  • app/src/main/java/com/example/updateapp/views/activites/SplashScreenActivity.java
  • app/src/main/res/layout/item_language.xml
  • app/src/main/res/values-ar/strings.xml
  • app/src/main/res/values-bn/strings.xml
  • app/src/main/res/values-es/strings.xml
  • app/src/main/res/values-fr/strings.xml
  • app/src/main/res/values-hi/strings.xml
  • app/src/main/res/values-pt/strings.xml
  • app/src/main/res/values-ru/strings.xml
  • app/src/main/res/values-ur/strings.xml
  • app/src/main/res/values-zh/strings.xml
🚧 Files skipped from review as they are similar to previous changes (8)
  • app/src/main/java/com/example/updateapp/Helpers/LocaleHelper.java
  • app/src/main/res/values-zh/strings.xml
  • app/src/main/res/values-ru/strings.xml
  • app/src/main/res/values-bn/strings.xml
  • app/src/main/java/com/example/updateapp/UpdateAppApplication.java
  • app/src/main/java/com/example/updateapp/models/LanguageModel.java
  • app/src/main/res/values-hi/strings.xml
  • app/src/main/res/values-pt/strings.xml
🧰 Additional context used
🧬 Code graph analysis (8)
app/src/main/java/com/example/updateapp/views/activites/ForgetActivity.java (1)
app/src/main/java/com/example/updateapp/Helpers/LocaleHelper.java (1)
  • LocaleHelper (11-53)
app/src/main/java/com/example/updateapp/views/activites/LoginActivity.java (1)
app/src/main/java/com/example/updateapp/Helpers/LocaleHelper.java (1)
  • LocaleHelper (11-53)
app/src/main/java/com/example/updateapp/views/activites/OnboardingActivity.java (1)
app/src/main/java/com/example/updateapp/Helpers/LocaleHelper.java (1)
  • LocaleHelper (11-53)
app/src/main/java/com/example/updateapp/views/activites/OTPActivity.java (1)
app/src/main/java/com/example/updateapp/Helpers/LocaleHelper.java (1)
  • LocaleHelper (11-53)
app/src/main/java/com/example/updateapp/views/activites/LanguageActivity.java (4)
app/src/main/java/com/example/updateapp/Helpers/LocaleHelper.java (1)
  • LocaleHelper (11-53)
app/src/main/java/com/example/updateapp/Helpers/SaveState.java (1)
  • SaveState (6-27)
app/src/main/java/com/example/updateapp/adapters/LanguageAdapter.java (1)
  • LanguageAdapter (17-73)
app/src/main/java/com/example/updateapp/models/LanguageModel.java (1)
  • LanguageModel (3-37)
app/src/main/java/com/example/updateapp/views/activites/SignUpActivity.java (1)
app/src/main/java/com/example/updateapp/Helpers/LocaleHelper.java (1)
  • LocaleHelper (11-53)
app/src/main/java/com/example/updateapp/adapters/LanguageAdapter.java (1)
app/src/main/java/com/example/updateapp/models/LanguageModel.java (1)
  • LanguageModel (3-37)
app/src/main/java/com/example/updateapp/views/activites/NewUpdateActivity.java (1)
app/src/main/java/com/example/updateapp/Helpers/LocaleHelper.java (1)
  • LocaleHelper (11-53)
🔇 Additional comments (11)
app/src/main/java/com/example/updateapp/views/activites/SignUpActivity.java (1)

167-170: Locale integration is correct.

The attachBaseContext override follows the same pattern used across other activities and properly delegates to LocaleHelper.attachBaseContext() for consistent locale handling.

app/src/main/java/com/example/updateapp/views/activites/LoginActivity.java (1)

230-233: Locale integration is correctly implemented.

The attachBaseContext override properly wraps the base context with locale-aware configuration via LocaleHelper.

app/src/main/java/com/example/updateapp/views/activites/NewUpdateActivity.java (1)

39-42: LGTM!

The attachBaseContext override is correctly implemented, consistent with the locale handling pattern across other activities.

app/src/main/java/com/example/updateapp/views/activites/OTPActivity.java (1)

230-233: Locale integration is correctly implemented.

The attachBaseContext override properly applies the saved locale configuration.

app/src/main/java/com/example/updateapp/views/activites/OnboardingActivity.java (1)

119-122: Locale context wrapping looks correct.

The attachBaseContext override properly delegates to LocaleHelper.attachBaseContext(), ensuring this activity respects the user's saved language preference. This is consistent with the pattern applied across other activities in the PR.

app/src/main/java/com/example/updateapp/views/activites/ForgetActivity.java (1)

87-90: Locale context wrapping is correctly implemented.

The attachBaseContext override follows the established pattern.

app/src/main/res/layout/item_language.xml (1)

1-26: Layout structure is acceptable.

The layout provides a functional language item view with a name and selection indicator. The hardcoded android:text="English" on Line 13 is a design-time placeholder and is correctly overwritten by the adapter at runtime.

app/src/main/java/com/example/updateapp/views/activites/SplashScreenActivity.java (2)

32-50: First-launch language selection flow is well-implemented.

The logic correctly checks if a language has been selected before and routes accordingly:

  • First launch → LanguageActivity with isFirstLaunch flag
  • Subsequent launches → OnboardingActivity

The SaveState usage for tracking language selection state is consistent with patterns elsewhere in the codebase.


59-62: Locale context wrapping is correctly applied.

The attachBaseContext override ensures the splash screen respects the saved language preference from the start.

app/src/main/java/com/example/updateapp/views/activites/LanguageActivity.java (2)

80-102: Language list construction is correct.

The method properly:

  • Uses string resources for language names (enabling localized display)
  • Marks the current language as selected
  • Covers all 10 required languages

126-129: Locale context wrapping is correctly implemented.

Comment thread app/src/main/java/com/example/updateapp/views/activites/LanguageActivity.java Outdated
Comment thread app/src/main/res/values-ar/strings.xml Outdated
Comment thread app/src/main/res/values-ar/strings.xml Outdated
Comment thread app/src/main/res/values-es/strings.xml Outdated
Comment thread app/src/main/res/values-fr/strings.xml Outdated
Comment thread app/src/main/res/values-ur/strings.xml
Gyanu and others added 2 commits December 23, 2025 22:10
…improve back button handling

- Fix typo: rev_langauge -> rev_language in layout and Java file
- Remove deprecated updateConfiguration() call from LocaleHelper.setLocale()
- Remove unused Resources import
- Replace deprecated onBackPressed() with OnBackPressedCallback
- Prevent back navigation on first launch (user must select language)
- All language translations verified complete

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
app/src/main/java/com/example/updateapp/views/activites/LanguageActivity.java (1)

29-39: ⚠️ Potential issue | 🔴 Critical

Duplicate field declarations will cause compilation error.

Fields recyclerView and languageList are declared twice (lines 29, 31 and lines 36, 38). Additionally, there are two adapter fields with different names (languageAdapter on line 30 and adapter on line 37), and currentLanguageCode is declared but never used in the final implementation.

🐛 Proposed fix: Remove duplicate declarations
 public class LanguageActivity extends AppCompatActivity implements LanguageAdapter.OnLanguageSelectedListener {
 
     private RecyclerView recyclerView;
     private LanguageAdapter languageAdapter;
     private List<LanguageModel> languageList;
     private ImageView imgDone, imgBack;
     private TextView txtTitle;
     private int selectedPosition = 0;
 
-    private RecyclerView recyclerView;
-    private LanguageAdapter adapter;
-    private List<LanguageModel> languageList;
-    private String currentLanguageCode;
-
     `@Override`
     protected void onCreate(Bundle savedInstanceState) {
app/src/main/java/com/example/updateapp/views/activites/OnboardingActivity.java (1)

16-20: ⚠️ Potential issue | 🔴 Critical

Duplicate LocaleHelper imports from different packages will cause compilation error.

Same issue as other files—two LocaleHelper classes imported from Helpers and utils packages. Remove the unused import.

🐛 Proposed fix
-import com.example.updateapp.Helpers.LocaleHelper;
 import com.example.updateapp.Helpers.SaveState;
 import com.example.updateapp.R;
 import com.example.updateapp.adapters.OnboardingAdapter;
 import com.example.updateapp.utils.LocaleHelper;
app/src/main/java/com/example/updateapp/views/activites/SplashScreenActivity.java (1)

60-68: ⚠️ Potential issue | 🔴 Critical

Duplicate attachBaseContext method declarations will cause compilation error.

Two attachBaseContext methods are defined (lines 60-63 and lines 65-68). This won't compile. Additionally, they use different LocaleHelper methods:

  • First uses LocaleHelper.attachBaseContext(newBase) (from Helpers package)
  • Second uses LocaleHelper.onAttach(newBase) (from utils package)

Keep only one method. For consistency with other activities, use LocaleHelper.onAttach() from the utils package.

🐛 Proposed fix: Keep only one attachBaseContext method
-    `@Override`
-    protected void attachBaseContext(Context newBase) {
-        super.attachBaseContext(LocaleHelper.attachBaseContext(newBase));
-    }
-
     `@Override`
     protected void attachBaseContext(Context newBase) {
         super.attachBaseContext(LocaleHelper.onAttach(newBase));
     }
 }
🤖 Fix all issues with AI agents
In
`@app/src/main/java/com/example/updateapp/views/activites/NewUpdateActivity.java`:
- Around line 14-17: There are two conflicting imports of LocaleHelper causing a
compile error; remove the import for com.example.updateapp.Helpers.LocaleHelper
and keep com.example.updateapp.utils.LocaleHelper, then ensure any references in
NewUpdateActivity (e.g., in attachBaseContext(...) or onAttach(...) usages) use
the utils.LocaleHelper implementation so all calls resolve to that single class.

In `@app/src/main/java/com/example/updateapp/views/activites/SignUpActivity.java`:
- Around line 14-17: Remove the duplicate/incorrect import of LocaleHelper in
SignUpActivity: keep the correct import com.example.updateapp.utils.LocaleHelper
and delete the unused com.example.updateapp.Helpers.LocaleHelper import so the
class (SignUpActivity) compiles without conflicting imports.

In
`@app/src/main/java/com/example/updateapp/views/activites/SplashScreenActivity.java`:
- Around line 14-17: The file has two conflicting imports for LocaleHelper
(com.example.updateapp.Helpers.LocaleHelper and
com.example.updateapp.utils.LocaleHelper) which causes a compile error; in
SplashScreenActivity remove the incorrect/unused LocaleHelper import and keep
the one that matches the actual class used by this activity (ensure references
in SplashScreenActivity resolve to the retained LocaleHelper), or refactor usage
to the retained package if the wrong one was imported.
🧹 Nitpick comments (1)
app/src/main/java/com/example/updateapp/views/activites/LanguageActivity.java (1)

10-10: Unused import.

OnBackPressedCallback is imported but not used anywhere in this file.

♻️ Remove unused import
-import androidx.activity.OnBackPressedCallback;

Comment thread app/src/main/java/com/example/updateapp/views/activites/NewUpdateActivity.java Outdated
Comment thread app/src/main/java/com/example/updateapp/views/activites/SignUpActivity.java Outdated
Comment thread app/src/main/java/com/example/updateapp/views/activites/SplashScreenActivity.java Outdated
Keep a single LocaleHelper, persist English as en with no country, and
apply it through AppCompatDelegate plus a full-task restart so every
screen follows the choice. Move remaining hardcoded copy into strings.xml
for all locales and give the language list a selected state.
@gyanu2507

Copy link
Copy Markdown
Author

@allknowledge34 this is ready for another look.

Language now applies app-wide (AppCompatDelegate plus a full-task restart). English is stored as en with no country, so switching back actually hits values/ instead of a missing en-US folder. The duplicate LocaleHelper is gone, so the project should compile. Splash, onboarding, chatbot, and the remaining layout copy are in strings.xml for all 10 locales, and the language list has a selected card + check.

Persist English without a country tag so switching back from Hindi works, and move remaining hardcoded UI copy into translated string resources.
@gyanu2507

Copy link
Copy Markdown
Author

Addressed the review:

  • Selected language now applies app-wide. UpdateApplication and LocaleHelper persist the choice and call AppCompatDelegate.setApplicationLocales, so screens after LanguageActivity pick it up.
  • English is stored as en with an empty country (not en-US). Switching Hindi -> English should work.
  • Remaining hardcoded copy (splash, onboarding, chatbot hint, ads, login, OTP, chatbot fragment) is in strings.xml and the locale folders.
  • Language rows keep the selected/unselected drawables and add a content description on the checkmark.

Please rebuild and try: open the app, pick Hindi, leave LanguageActivity, then switch back to English.

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.

2 participants