Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed CardBrowser Heading Language Change #17497

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

soCallmeAdityaKumar
Copy link
Contributor

@soCallmeAdityaKumar soCallmeAdityaKumar commented Nov 25, 2024

Purpose / Description

On Changing the language, heading doesn't changes immediately

Fixes

Approach

WhatsApp.mp4

Checklist

Please, go through these checks before submitting the PR.

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

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

  • Is it feasible to add a unit test for this one? The ViewModel should be well tested.
  • Is it feasible to move this inside the ViewModel, so the UI is reacting to a change in ViewModel
  • Should this be in onConfigurationChanged or onResume?
    • Is it worthwhile to add an AnkiDroid Language Changed event?
    • ^ maybe not, given we shouldn't be handling configuration changes manually most of the time

column1Candidates = CardBrowserColumn.COLUMN1_KEYS.map { allColumns[it.ankiColumnKey]!! }
column2Candidates = CardBrowserColumn.COLUMN2_KEYS.map { allColumns[it.ankiColumnKey]!! }

setUpColumns()
Copy link
Member

Choose a reason for hiding this comment

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

Rename: two methods one after the other with the same name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -576,6 +542,41 @@ open class CardBrowser :
viewModel.flowOfCardsOrNotes.launchCollectionInLifecycleScope(::cardsOrNotesChanged)
}

private fun setupColumnSpinners() {
Copy link
Member

Choose a reason for hiding this comment

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

as below, revert + react to the ViewModel change

AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt Outdated Show resolved Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt Outdated Show resolved Hide resolved
@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label Nov 26, 2024
@david-allison david-allison added this to the 2.19.3 release milestone Nov 26, 2024
@soCallmeAdityaKumar
Copy link
Contributor Author

There is one problem like i am not able to identify , i am open for suggestion:)
When we change the language from system language to some other and again change it to system language it does not change immediately(like the actual issue)

@david-allison david-allison added Needs Review and removed Needs Author Reply Waiting for a reply from the original author labels Nov 29, 2024
@david-allison
Copy link
Member

david-allison commented Nov 29, 2024

I don't believe this is ready to review as you've identified an issue. Please un-draft when ready

@david-allison david-allison marked this pull request as draft November 30, 2024 05:34
@david-allison david-allison added Needs Author Reply Waiting for a reply from the original author and removed Needs Review labels Nov 30, 2024
@david-allison david-allison removed their request for review November 30, 2024 05:35
@mikehardy mikehardy modified the milestones: 2.20 Release, 2.21 release Dec 4, 2024
@soCallmeAdityaKumar
Copy link
Contributor Author

soCallmeAdityaKumar commented Dec 7, 2024

@david-allison i have noticed that certain text in cardBrowser are not translated properly if language is changed from other language to SystemLanguage.Other language changes are handled properly

WhatsApp.Video.2024-12-07.at.2.19.03.PM.mp4

@david-allison
Copy link
Member

That's a known issue. Focus on the column headers, as those are defined in the ViewModel

@soCallmeAdityaKumar
Copy link
Contributor Author

@david-allison i need to add tests for viewmodel for this case or is there something more I have to do?

@david-allison
Copy link
Member

That's it

@soCallmeAdityaKumar
Copy link
Contributor Author

@david-allison i have tried but i am not able add tests for this, because i am not able to find a way to change the language in test so that the new column2candidates are fetched on automatically.

@david-allison
Copy link
Member

Look into how the preferences screen does it

This comment was marked as outdated.

@github-actions github-actions bot added the Stale label Dec 27, 2024
@soCallmeAdityaKumar

This comment was marked as resolved.

@github-actions github-actions bot removed the Stale label Dec 27, 2024
@david-allison
Copy link
Member

@soCallmeAdityaKumar Still waiting for feedback though?

@soCallmeAdityaKumar
Copy link
Contributor Author

@soCallmeAdityaKumar Still waiting for feedback though?

yeah still i am working on this, figuring out

@soCallmeAdityaKumar
Copy link
Contributor Author

soCallmeAdityaKumar commented Dec 29, 2024

@david-allison opened a new pr for this ->#17687
got merge conflicts and then messed with the files, so opened a new one, hope it fixes the and close this issue , added the test in that

@mikehardy
Copy link
Member

got merge conflicts and then messed with the files, so opened a new one

Inability to drive git well as a user isn't a great reason to break the conversation / review context on a PR by hopping over to another one. It seems that spending some quality time getting better at driving git would pay dividends

@soCallmeAdityaKumar
Copy link
Contributor Author

got merge conflicts and then messed with the files, so opened a new one

Inability to drive git well as a user isn't a great reason to break the conversation / review context on a PR by hopping over to another one. It seems that spending some quality time getting better at driving git would pay dividends

sorry, @mikehardy , i was not diverting the conversation, just got messed with local files and got lost the track so opened a new fresh branch , i am still learning git

@soCallmeAdityaKumar
Copy link
Contributor Author

@david-allison i have added the test should i open this

@david-allison
Copy link
Member

Yes, but please fix the git history. It makes it difficult to review

@@ -370,6 +371,19 @@ class CardBrowserViewModelTest : JvmTest() {
}
}

@Test
@Config(qualifiers = "da")
Copy link
Member

@david-allison david-allison Jan 3, 2025

Choose a reason for hiding this comment

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

This test passes on main

Index: AnkiDroid/src/test/java/com/ichi2/anki/browser/CardBrowserViewModelTest.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/AnkiDroid/src/test/java/com/ichi2/anki/browser/CardBrowserViewModelTest.kt b/AnkiDroid/src/test/java/com/ichi2/anki/browser/CardBrowserViewModelTest.kt
--- a/AnkiDroid/src/test/java/com/ichi2/anki/browser/CardBrowserViewModelTest.kt	(revision d35746b7aeee5db0e34029099c261391fc3d65a8)
+++ b/AnkiDroid/src/test/java/com/ichi2/anki/browser/CardBrowserViewModelTest.kt	(date 1735918889736)
@@ -65,6 +65,7 @@
 import org.hamcrest.Matchers.nullValue
 import org.junit.Test
 import org.junit.runner.RunWith
+import org.robolectric.annotation.Config
 import timber.log.Timber
 import java.io.File
 import kotlin.io.path.createTempDirectory
@@ -88,6 +89,19 @@
             assertThat("filters should be empty after removing", savedSearches().size, equalTo(0))
         }
 
+    @Test
+    @Config(qualifiers = "da")
+    fun `change language to dansk and check columnHeaders`() =
+        runViewModelTest {
+            setColumn1(QUESTION)
+            val column1Header = column1Candidates[0].notesModeLabel
+            assertThat("column1 headers is not question", column1Header, not(QUESTION))
+
+            setColumn2(ANSWER)
+            val column2Header = column2Candidates[0].notesModeLabel
+            assertThat("column2 headers is not question", column2Header, not(ANSWER))
+        }
+
     @Test
     fun `saving search with same name fails`() =
         runViewModelTest {

@soCallmeAdityaKumar
Copy link
Contributor Author

Yes, but please fix the git history. It makes it difficult to review

Ok will do this .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Has Conflicts Needs Author Reply Waiting for a reply from the original author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]: Browser Column Headers Language Doesn't Change
3 participants