Skip to content

Commit

Permalink
Merge branch 'release/0.2.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrimault committed Mar 1, 2020
2 parents 538d6f7 + 1bb509b commit ce81b13
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 28 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.6.0'
classpath 'com.android.tools.build:gradle:3.6.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jlleitschuh.gradle:ktlint-gradle:9.1.1"
// NOTE: Do not place your application dependencies here; they belong
Expand Down
2 changes: 1 addition & 1 deletion commons/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

version = "0.6.1"
version = "0.6.2"

android {
compileSdkVersion 28
Expand Down
18 changes: 14 additions & 4 deletions commons/src/main/java/fr/geonature/commons/data/AbstractTaxon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,24 @@ abstract class AbstractTaxon : Parcelable {
*
* @return this
*/
fun byName(queryString: String?): Filter {
fun byNameOrDescription(queryString: String?): Filter {
if (queryString.isNullOrBlank()) {
return this
}

this.wheres.add(
Pair(
"(${getColumnAlias(
COLUMN_NAME, tableAlias
COLUMN_NAME,
tableAlias
)} LIKE ? OR ${getColumnAlias(
COLUMN_DESCRIPTION,
tableAlias
)} LIKE ?)",
arrayOf("%$queryString%")
arrayOf(
"%$queryString%",
"%$queryString%"
)
)
)

Expand All @@ -196,7 +203,10 @@ abstract class AbstractTaxon : Parcelable {
pair.first
}

return Pair(whereClauses, bindArgs.toTypedArray())
return Pair(
whereClauses,
bindArgs.toTypedArray()
)
}
}
}
52 changes: 36 additions & 16 deletions commons/src/test/java/fr/geonature/commons/data/TaxonTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -290,38 +290,53 @@ class TaxonTest {

@Test
fun testFilter() {
val taxonFilterByNameAndTaxonomy = (Taxon.Filter().byName("as") as Taxon.Filter).byTaxonomy(
Taxonomy(
"Animalia",
"Ascidies"
val taxonFilterByNameAndTaxonomy =
(Taxon.Filter().byNameOrDescription("as") as Taxon.Filter).byTaxonomy(
Taxonomy(
"Animalia",
"Ascidies"
)
)
).build()
.build()

assertEquals(
"(${Taxon.TABLE_NAME}_${AbstractTaxon.COLUMN_NAME} LIKE ?) AND ((${Taxon.TABLE_NAME}_${Taxonomy.COLUMN_KINGDOM} = ?) AND (${Taxon.TABLE_NAME}_${Taxonomy.COLUMN_GROUP} = ?))",
"(${Taxon.TABLE_NAME}_${AbstractTaxon.COLUMN_NAME} LIKE ? OR ${Taxon.TABLE_NAME}_${AbstractTaxon.COLUMN_DESCRIPTION} LIKE ?) AND ((${Taxon.TABLE_NAME}_${Taxonomy.COLUMN_KINGDOM} = ?) AND (${Taxon.TABLE_NAME}_${Taxonomy.COLUMN_GROUP} = ?))",
taxonFilterByNameAndTaxonomy.first
)
assertArrayEquals(
arrayOf("%as%", "Animalia", "Ascidies"),
arrayOf(
"%as%",
"%as%",
"Animalia",
"Ascidies"
),
taxonFilterByNameAndTaxonomy.second
)

val taxonFilterByNameAndKingdom = (Taxon.Filter().byName("as") as Taxon.Filter).byTaxonomy(
Taxonomy(
"Animalia"
val taxonFilterByNameAndKingdom =
(Taxon.Filter().byNameOrDescription("as") as Taxon.Filter).byTaxonomy(
Taxonomy(
"Animalia"
)
)
).build()
.build()

assertEquals(
"(${Taxon.TABLE_NAME}_${AbstractTaxon.COLUMN_NAME} LIKE ?) AND (${Taxon.TABLE_NAME}_${Taxonomy.COLUMN_KINGDOM} = ?)",
"(${Taxon.TABLE_NAME}_${AbstractTaxon.COLUMN_NAME} LIKE ? OR ${Taxon.TABLE_NAME}_${AbstractTaxon.COLUMN_DESCRIPTION} LIKE ?) AND (${Taxon.TABLE_NAME}_${Taxonomy.COLUMN_KINGDOM} = ?)",
taxonFilterByNameAndKingdom.first
)
assertArrayEquals(
arrayOf("%as%", "Animalia"),
arrayOf(
"%as%",
"%as%",
"Animalia"
),
taxonFilterByNameAndKingdom.second
)

val taxonFilterByKingdom = Taxon.Filter().byKingdom("Animalia").build()
val taxonFilterByKingdom = Taxon.Filter()
.byKingdom("Animalia")
.build()

assertEquals(
"(${Taxon.TABLE_NAME}_${Taxonomy.COLUMN_KINGDOM} = ?)",
Expand All @@ -332,9 +347,14 @@ class TaxonTest {
taxonFilterByKingdom.second
)

val taxonFilterByAnyTaxonomy = Taxon.Filter().byTaxonomy(Taxonomy("")).build()
val taxonFilterByAnyTaxonomy = Taxon.Filter()
.byTaxonomy(Taxonomy(""))
.build()

assertEquals("", taxonFilterByAnyTaxonomy.first)
assertEquals(
"",
taxonFilterByAnyTaxonomy.first
)
assertTrue(taxonFilterByAnyTaxonomy.second.isEmpty())
}
}
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
android.enableJetifier=true
android.useAndroidX=true
android.useAndroidX=true
kotlin.code.style=official
android.enableUnitTestBinaryResources=true
2 changes: 1 addition & 1 deletion sync/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: "kotlin-kapt"

version = "0.2.4"
version = "0.2.5"

android {
compileSdkVersion 28
Expand Down
3 changes: 3 additions & 0 deletions sync/src/main/java/fr/geonature/sync/api/model/Taxref.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ data class Taxref(
@SerializedName("lb_nom")
val name: String,

@SerializedName("search_name")
val description: String,

@SerializedName("regne")
val kingdom: String,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class DataSyncWorker(
it.kingdom,
it.group
),
null
it.description
)
}
.toTypedArray()
Expand Down
4 changes: 2 additions & 2 deletions sync/version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#Tue Feb 25 21:34:41 CET 2020
VERSION_CODE=2080
#Sun Mar 01 17:59:25 CET 2020
VERSION_CODE=2100
2 changes: 1 addition & 1 deletion viewpager/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

version = "0.1.1"
version = "0.1.2"

android {
compileSdkVersion 28
Expand Down
2 changes: 2 additions & 0 deletions viewpager/src/main/res/layout/activity_pager.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
android:layout_height="wrap_content"
android:backgroundTint="?attr/colorBackgroundFloating"
android:text="@string/button_pager_previous"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/nextButton"
app:layout_constraintHorizontal_bias="0.5"
Expand All @@ -21,6 +22,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:backgroundTint="?attr/colorBackgroundFloating"
android:enabled="false"
android:text="@string/button_pager_next"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand Down

0 comments on commit ce81b13

Please sign in to comment.