Displaying Category image and Description (#4531)

* API call done

* API call

* Image implementation done

* Gradle

* Java docs and code convention

* Description added

* Refactoring Category

* Refactoring Category

* Refactoring Category

* Description and thumbnail issue fixed

* Description and thumbnail issue fixed

* Minor issue fixed

* Minor issue fixed

* Server changed

* Logo changed

* Change in structure

* Fixed failed tests

* Fixed Test failed

* Optimized imports

* Dialog can't be dismissed

* Dialog can't be dismissed

* Resolved Conflicts

* UI fixed

* Added description and thumbnail in local DB

* Added description and thumbnail in local DB

* Test fixed

* Added

* Updated with latest master

* Test Updated with latest master

* Issue fixed

* Revert gradle changes

* Revert gradle changes

* Update gradle-wrapper.properties

* Require Api removed
This commit is contained in:
Ayan Sarkar 2022-01-20 11:49:57 +05:30 committed by GitHub
parent 0914eeea53
commit 92957f4204
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 373 additions and 151 deletions

View file

@ -1,5 +1,6 @@
package fr.free.nrw.commons.utils
import fr.free.nrw.commons.category.CategoryItem
import fr.free.nrw.commons.utils.StringSortingUtils.sortBySimilarity
import org.junit.Assert.assertEquals
import org.junit.Test
@ -9,8 +10,18 @@ class StringSortingUtilsTest {
@Test
fun testSortingNumbersBySimilarity() {
val actualList = listOf("1234567", "4567", "12345", "123", "1234")
val expectedList = listOf("1234", "12345", "123", "1234567", "4567")
val actualList = listOf(
CategoryItem("1234567", "", "", false),
CategoryItem("4567", "", "", false),
CategoryItem("12345", "", "", false),
CategoryItem("123", "", "", false),
CategoryItem("1234", "", "", false))
val expectedList = listOf(
CategoryItem("1234", "", "", false),
CategoryItem("12345", "", "", false),
CategoryItem("123", "", "", false),
CategoryItem("1234567", "", "", false),
CategoryItem("4567", "", "", false))
sort(actualList, sortBySimilarity("1234"))
@ -20,22 +31,22 @@ class StringSortingUtilsTest {
@Test
fun testSortingTextBySimilarity() {
val actualList = listOf(
"The quick brown fox",
"quick brown fox",
"The",
"The quick ",
"The fox",
"brown fox",
"fox"
CategoryItem("The quick brown fox", "", "", false),
CategoryItem("quick brown fox", "", "", false),
CategoryItem("The", "", "", false),
CategoryItem("The quick ", "", "", false),
CategoryItem("The fox", "", "", false),
CategoryItem("brown fox", "", "", false),
CategoryItem("fox", "", "", false)
)
val expectedList = listOf(
"The",
"The fox",
"The quick ",
"The quick brown fox",
"quick brown fox",
"brown fox",
"fox"
CategoryItem("The", "", "", false),
CategoryItem("The fox", "", "", false),
CategoryItem("The quick ", "", "", false),
CategoryItem("The quick brown fox", "", "", false),
CategoryItem("quick brown fox", "", "", false),
CategoryItem("brown fox", "", "", false),
CategoryItem("fox", "", "", false)
)
sort(actualList, sortBySimilarity("The"))
@ -46,18 +57,18 @@ class StringSortingUtilsTest {
@Test
fun testSortingSymbolsBySimilarity() {
val actualList = listOf(
"$$$$$",
"****",
"**$*",
"*$*$",
".*$"
CategoryItem("$$$$$", "", "", false),
CategoryItem("****", "", "", false),
CategoryItem("**$*", "", "", false),
CategoryItem("*$*$", "", "", false),
CategoryItem(".*$", "", "", false)
)
val expectedList = listOf(
"**$*",
"*$*$",
".*$",
"****",
"$$$$$"
CategoryItem("**$*", "", "", false),
CategoryItem("*$*$", "", "", false),
CategoryItem(".*$", "", "", false),
CategoryItem("****", "", "", false),
CategoryItem("$$$$$", "", "", false)
)
sort(actualList, sortBySimilarity("**$"))
@ -69,25 +80,25 @@ class StringSortingUtilsTest {
fun testSortingMixedStringsBySimilarity() {
// Sample from Category:2018 Android phones
val actualList = listOf(
"ASUS ZenFone 5 (2018)",
"Google Pixel 3",
"HTC U12",
"Huawei P20",
"LG G7 ThinQ",
"Samsung Galaxy A8 (2018)",
"Samsung Galaxy S9",
CategoryItem("ASUS ZenFone 5 (2018)", "", "", false),
CategoryItem("Google Pixel 3", "", "", false),
CategoryItem("HTC U12", "", "", false),
CategoryItem("Huawei P20", "", "", false),
CategoryItem("LG G7 ThinQ", "", "", false),
CategoryItem("Samsung Galaxy A8 (2018)", "", "", false),
CategoryItem("Samsung Galaxy S9", "", "", false),
// One with more complicated symbols
"MadeUpPhone 2018.$£#你好"
CategoryItem("MadeUpPhone 2018.$£#你好", "", "", false)
)
val expectedList = listOf(
"Samsung Galaxy S9",
"ASUS ZenFone 5 (2018)",
"Samsung Galaxy A8 (2018)",
"Google Pixel 3",
"HTC U12",
"Huawei P20",
"LG G7 ThinQ",
"MadeUpPhone 2018.$£#你好"
CategoryItem("Samsung Galaxy S9", "", "", false),
CategoryItem("ASUS ZenFone 5 (2018)", "", "", false),
CategoryItem("Samsung Galaxy A8 (2018)", "", "", false),
CategoryItem("Google Pixel 3", "", "", false),
CategoryItem("HTC U12", "", "", false),
CategoryItem("Huawei P20", "", "", false),
CategoryItem("LG G7 ThinQ", "", "", false),
CategoryItem("MadeUpPhone 2018.$£#你好", "", "", false)
)
sort(actualList, sortBySimilarity("S9"))
@ -98,26 +109,26 @@ class StringSortingUtilsTest {
@Test
fun testSortingWithEmptyStrings() {
val actualList = listOf(
"brown fox",
"",
"quick brown fox",
"the",
"",
"the fox",
"fox",
"",
""
CategoryItem("brown fox", "", "", false),
CategoryItem("", "", "", false),
CategoryItem("quick brown fox", "", "", false),
CategoryItem("the", "", "", false),
CategoryItem("", "", "", false),
CategoryItem("the fox", "", "", false),
CategoryItem("fox", "", "", false),
CategoryItem("", "", "", false),
CategoryItem("", "", "", false)
)
val expectedList = listOf(
"the fox",
"brown fox",
"the",
"fox",
"quick brown fox",
"",
"",
"",
""
CategoryItem("the fox", "", "", false),
CategoryItem("brown fox", "", "", false),
CategoryItem("the", "", "", false),
CategoryItem("fox", "", "", false),
CategoryItem("quick brown fox", "", "", false),
CategoryItem("", "", "", false),
CategoryItem("", "", "", false),
CategoryItem("", "", "", false),
CategoryItem("", "", "", false)
)
sort(actualList, sortBySimilarity("the fox"))