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 Dec 18, 2019
2 parents 841cc81 + ccb8559 commit e43735c
Show file tree
Hide file tree
Showing 57 changed files with 1,876 additions and 1,170 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.3.61'

repositories {
google()
Expand All @@ -10,9 +10,9 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// NOTE: Do not place application dependencies here; they belong
// in the individual module build.gradle files
}
}
Expand Down
2 changes: 1 addition & 1 deletion gn_mobile_core
Submodule gn_mobile_core updated 188 files
8 changes: 4 additions & 4 deletions occtax/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

version = "0.1.9"
version = "0.2.5"

android {
compileSdkVersion 28
Expand Down Expand Up @@ -54,11 +54,11 @@ dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0'

implementation 'androidx.core:core-ktx:1.2.0-beta01'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0-rc01"
implementation 'androidx.core:core-ktx:1.2.0-rc01'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0-rc03"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0-rc01'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.preference:preference:1.1.0'
implementation 'com.l4digital.fastscroll:fastscroll:2.0.1'
Expand Down
4 changes: 4 additions & 0 deletions occtax/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
<activity
android:name=".ui.settings.PreferencesActivity"
android:label="@string/activity_preferences_title" />
<activity
android:name=".ui.dataset.DatasetListActivity"
android:label="@string/activity_dataset_title"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".ui.observers.InputObserverListActivity"
android:label="@string/activity_observers_title"
Expand Down
27 changes: 18 additions & 9 deletions occtax/src/main/java/fr/geonature/occtax/input/CountingMetadata.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ class CountingMetadata() : Parcelable {
internal set

val properties: SortedMap<String, PropertyValue> = TreeMap<String, PropertyValue>(Comparator { o1, o2 ->
val i1 = defaultMnemonicOrder.indexOfFirst { it == o1 }
val i2 = defaultMnemonicOrder.indexOfFirst { it == o2 }
val i1 = defaultMnemonic.indexOfFirst { it.first == o1 }
val i2 = defaultMnemonic.indexOfFirst { it.first == o2 }

when {
i1 == -1 -> 1
i2 == -1 -> -1
else -> i1 - i2
}
})
var min: Int = 0
var max: Int = 0
var min: Int = 1
var max: Int = 1

constructor(source: Parcel) : this() {
index = source.readInt()
Expand Down Expand Up @@ -75,15 +75,24 @@ class CountingMetadata() : Parcelable {
}

fun isEmpty(): Boolean {
return properties.filterNot { it.value.isEmpty() }.isEmpty() && min == 0 && max == 0
return properties.filterNot { it.value.isEmpty() }
.isEmpty()
}

companion object {

private val defaultMnemonicOrder = arrayOf("STADE_VIE",
"SEXE",
"OBJ_DENBR",
"TYP_DENBR")
val defaultMnemonic = arrayOf(Pair("STADE_VIE",
NomenclatureTypeViewType.NOMENCLATURE_TYPE),
Pair("SEXE",
NomenclatureTypeViewType.NOMENCLATURE_TYPE),
Pair("OBJ_DENBR",
NomenclatureTypeViewType.NOMENCLATURE_TYPE),
Pair("TYP_DENBR",
NomenclatureTypeViewType.NOMENCLATURE_TYPE),
Pair("MIN",
NomenclatureTypeViewType.MIN_MAX),
Pair("MAX",
NomenclatureTypeViewType.MIN_MAX))

@JvmField
val CREATOR: Parcelable.Creator<CountingMetadata> = object : Parcelable.Creator<CountingMetadata> {
Expand Down
54 changes: 46 additions & 8 deletions occtax/src/main/java/fr/geonature/occtax/input/Input.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import android.os.Parcelable
import fr.geonature.commons.input.AbstractInput
import fr.geonature.commons.input.AbstractInputTaxon
import org.locationtech.jts.geom.Geometry
import java.util.SortedMap
import java.util.TreeMap

/**
* Describes a current input.
Expand All @@ -15,18 +17,39 @@ class Input : AbstractInput {

var geometry: Geometry? = null
var selectedFeatureId: String? = null
var comment: String? = null
val properties: SortedMap<String, PropertyValue> = TreeMap<String, PropertyValue>(Comparator { o1, o2 ->
val i1 = defaultPropertiesMnemonic.indexOfFirst { it.first == o1 }
val i2 = defaultPropertiesMnemonic.indexOfFirst { it.first == o2 }

when {
i1 == -1 -> 1
i2 == -1 -> -1
else -> i1 - i2
}
})

constructor() : super("occtax")
constructor(source: Parcel) : super(source) {
this.geometry = source.readSerializable() as Geometry?
this.comment = source.readString()
(source.createTypedArrayList(PropertyValue.CREATOR)
?: emptyList<PropertyValue>())
.forEach {
this.properties[it.code] = it
}
}

override fun writeToParcel(dest: Parcel,
override fun writeToParcel(dest: Parcel?,
flags: Int) {
super.writeToParcel(dest,
flags)

dest.writeSerializable(geometry)
dest?.also {
it.writeSerializable(geometry)
it.writeString(comment)
it.writeTypedList(this.properties.values.toList())
}
}

override fun getTaxaFromParcel(source: Parcel): List<AbstractInputTaxon> {
Expand All @@ -40,23 +63,38 @@ class Input : AbstractInput {
if (!super.equals(other)) return false

if (geometry != other.geometry) return false
if (comment != other.comment) return false
if (properties != other.properties) return false

return true
}

override fun hashCode(): Int {
var result = super.hashCode()
result = 31 * result + (geometry?.hashCode() ?: 0)
result = 31 * result + (comment?.hashCode() ?: 0)
result = 31 * result + properties.hashCode()

return result
}

companion object CREATOR : Parcelable.Creator<Input> {
override fun createFromParcel(parcel: Parcel): Input {
return Input(parcel)
}
companion object {

val defaultPropertiesMnemonic = arrayOf(Pair("TECHNIQUE_OBS",
NomenclatureTypeViewType.NOMENCLATURE_TYPE),
Pair("TYP_GRP",
NomenclatureTypeViewType.NOMENCLATURE_TYPE))

@JvmField
val CREATOR: Parcelable.Creator<Input> = object : Parcelable.Creator<Input> {

override fun createFromParcel(source: Parcel): Input {
return Input(source)
}

override fun newArray(size: Int): Array<Input?> {
return arrayOfNulls(size)
override fun newArray(size: Int): Array<Input?> {
return arrayOfNulls(size)
}
}
}
}
34 changes: 21 additions & 13 deletions occtax/src/main/java/fr/geonature/occtax/input/InputTaxon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import java.util.TreeMap
*/
class InputTaxon : AbstractInputTaxon {

val properties: SortedMap<String, SelectedProperty> = TreeMap<String, SelectedProperty>(Comparator { o1, o2 ->
val i1 = defaultPropertiesMnemonicOrder.indexOfFirst { it == o1 }
val i2 = defaultPropertiesMnemonicOrder.indexOfFirst { it == o2 }
val properties: SortedMap<String, PropertyValue> = TreeMap<String, PropertyValue>(Comparator { o1, o2 ->
val i1 = defaultPropertiesMnemonic.indexOfFirst { it.first == o1 }
val i2 = defaultPropertiesMnemonic.indexOfFirst { it.first == o2 }

when {
i1 == -1 -> 1
Expand All @@ -28,8 +28,8 @@ class InputTaxon : AbstractInputTaxon {

constructor(taxon: AbstractTaxon) : super(taxon)
constructor(source: Parcel) : super(source) {
(source.createTypedArrayList(SelectedProperty.CREATOR)
?: emptyList<SelectedProperty>())
(source.createTypedArrayList(PropertyValue.CREATOR)
?: emptyList<PropertyValue>())
.forEach {
this.properties[it.code] = it
}
Expand Down Expand Up @@ -90,14 +90,22 @@ class InputTaxon : AbstractInputTaxon {

companion object {

private val defaultPropertiesMnemonicOrder = arrayOf("METH_OBS",
"ETA_BIO",
"METH_DETERMIN",
"DETERMINER",
"STATUT_BIO",
"NATURALITE",
"PREUVE_EXIST",
"COMMENT")
val defaultPropertiesMnemonic = arrayOf(Pair("METH_OBS",
NomenclatureTypeViewType.NOMENCLATURE_TYPE),
Pair("ETA_BIO",
NomenclatureTypeViewType.NOMENCLATURE_TYPE),
Pair("METH_DETERMIN",
NomenclatureTypeViewType.NOMENCLATURE_TYPE),
Pair("DETERMINER",
NomenclatureTypeViewType.TEXT_SIMPLE),
Pair("STATUT_BIO",
NomenclatureTypeViewType.NOMENCLATURE_TYPE),
Pair("NATURALITE",
NomenclatureTypeViewType.NOMENCLATURE_TYPE),
Pair("PREUVE_EXIST",
NomenclatureTypeViewType.NOMENCLATURE_TYPE),
Pair("COMMENT",
NomenclatureTypeViewType.TEXT_MULTIPLE))

@JvmField
val CREATOR: Parcelable.Creator<InputTaxon> = object : Parcelable.Creator<InputTaxon> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package fr.geonature.occtax.input

/**
* Describes nomenclature type view type.
*
* @author [S. Grimault](mailto:[email protected])
*/
enum class NomenclatureTypeViewType {
NOMENCLATURE_TYPE,
MORE,
TEXT_SIMPLE,
TEXT_MULTIPLE,
MIN_MAX
}
17 changes: 3 additions & 14 deletions occtax/src/main/java/fr/geonature/occtax/input/PropertyValue.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package fr.geonature.occtax.input

import android.os.Parcel
import android.os.Parcelable
import android.text.TextUtils
import fr.geonature.commons.data.Nomenclature
import fr.geonature.commons.input.AbstractInputTaxon
import java.io.Serializable
Expand Down Expand Up @@ -34,7 +33,7 @@ data class PropertyValue(val code: String,
}

fun isEmpty(): Boolean {
return TextUtils.isEmpty(label) && value == null
return value == null
}

companion object {
Expand All @@ -50,20 +49,10 @@ data class PropertyValue(val code: String,
}

/**
* Creates a [PropertyValue] instance from given String value.
* Creates a [PropertyValue] instance from given value.
*/
fun fromValue(code: String,
value: String?): PropertyValue {
return PropertyValue(code,
null,
value)
}

/**
* Creates a [PropertyValue] instance from given Int value.
*/
fun fromValue(code: String,
value: Int?): PropertyValue {
value: Serializable?): PropertyValue {
return PropertyValue(code,
null,
value)
Expand Down
Loading

0 comments on commit e43735c

Please sign in to comment.