-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
base: main
Are you sure you want to change the base?
Fixed CardBrowser Heading Language Change #17497
Conversation
There was a problem hiding this 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
oronResume
?- 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
- Is it worthwhile to add an
column1Candidates = CardBrowserColumn.COLUMN1_KEYS.map { allColumns[it.ankiColumnKey]!! } | ||
column2Candidates = CardBrowserColumn.COLUMN2_KEYS.map { allColumns[it.ankiColumnKey]!! } | ||
|
||
setUpColumns() |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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
There is one problem like i am not able to identify , i am open for suggestion:) |
I don't believe this is ready to review as you've identified an issue. Please un-draft when ready |
@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 |
That's a known issue. Focus on the column headers, as those are defined in the ViewModel |
@david-allison i need to add tests for viewmodel for this case or is there something more I have to do? |
That's it |
AnkiDroid/src/main/java/com/ichi2/anki/browser/CardBrowserViewModel.kt
Outdated
Show resolved
Hide resolved
@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. |
Look into how the preferences screen does it |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
@soCallmeAdityaKumar Still waiting for feedback though? |
yeah still i am working on this, figuring out |
@david-allison opened a new pr for this ->#17687 |
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 |
b1d49ff
to
1f06203
Compare
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 |
# Conflicts: # AnkiDroid/src/main/java/com/ichi2/anki/browser/CardBrowserViewModel.kt
@david-allison i have added the test should i open this |
Yes, but please fix the git history. It makes it difficult to review |
@@ -370,6 +371,19 @@ class CardBrowserViewModelTest : JvmTest() { | |||
} | |||
} | |||
|
|||
@Test | |||
@Config(qualifiers = "da") |
There was a problem hiding this comment.
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 {
Ok will do this . |
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.