Skip to content

Commit

Permalink
Merge branch 'release/1.1.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrimault committed Mar 28, 2021
2 parents 1474ebd + 382d284 commit e15e8b7
Show file tree
Hide file tree
Showing 40 changed files with 1,674 additions and 833 deletions.
10 changes: 9 additions & 1 deletion .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 5 additions & 8 deletions commons/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

version = "0.8.0"
version = "0.8.2"

android {
compileSdkVersion 29
Expand Down Expand Up @@ -46,19 +46,16 @@ dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1"

implementation 'androidx.appcompat:appcompat:1.3.0-beta01'
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.3.0-rc01"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
implementation 'androidx.appcompat:appcompat:1.3.0-rc01'
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.3.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'com.google.android.material:material:1.3.0-rc01'

api 'androidx.room:room-runtime:2.2.6'

testImplementation 'androidx.arch.core:core-testing:2.1.0'
testImplementation 'androidx.test:core:1.3.0'
testImplementation 'junit:junit:4.13.1'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:3.0.0'
testImplementation 'org.robolectric:robolectric:4.3.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'androidx.test:runner:1.3.0'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package fr.geonature.commons.util

import android.util.JsonReader
import android.util.JsonToken
import android.util.JsonToken.NAME
import android.util.JsonToken.STRING
import java.io.IOException

/**
* Utility functions about JsonReader.
*
* @author S. Grimault
*/

/**
* Returns the next token, a property name, consumes it and check if its value matches the given `JsonToken`.
*/
fun JsonReader.nextName(name: String, expected: JsonToken): JsonReader {
return if (peek() == NAME) {
val nextName = nextName()

if (nextName != name) {
throw IOException("Expected a property name '$name' but was '${peek().name}'")
}

if (peek() != expected) {
throw IOException("Expected a property name '$name' to be '${expected.name}' but was '${peek().name}'")
}

this
} else {
throw IOException("Missing '$name' property")
}
}

/**
* Returns the string value of the next token and consuming it.
* If the next token is not a string returns `null`.
*/
fun JsonReader.nextStringOrNull(): String? {
return when (peek()) {
STRING -> {
nextString()
}
else -> {
null
}
}
}
4 changes: 2 additions & 2 deletions commons/version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#Tue Feb 02 20:36:43 CET 2021
VERSION_CODE=2680
#Sun Mar 28 16:42:31 CEST 2021
VERSION_CODE=2820
6 changes: 2 additions & 4 deletions mountpoint/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

version = "0.0.6"
version = "0.0.7"

android {
compileSdkVersion 29
Expand Down Expand Up @@ -45,8 +45,6 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

testImplementation 'androidx.test:core:1.3.0'
testImplementation 'junit:junit:4.13.1'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.robolectric:robolectric:4.3.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'androidx.test:runner:1.3.0'
}
4 changes: 2 additions & 2 deletions mountpoint/version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#Mon Feb 01 21:59:56 CET 2021
VERSION_CODE=150
#Sun Mar 28 16:43:24 CEST 2021
VERSION_CODE=300
50 changes: 38 additions & 12 deletions sync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Synchronize local database through GeoNature API:

- Users (i.e. Observers)
- Taxa (with "color" by areas and taxonomy)
- Taxa (with additional data like "color" by areas and taxonomy)
- Dataset
- Nomenclature

Expand Down Expand Up @@ -38,16 +38,42 @@ Example:

### Parameters description

| Parameter | UI | Description | Default value |
| ------------------- | ------- | ------------------------------------------------------ | ------------- |
| `geonature_url` | ☑ | GeoNature URL | |
| `taxhub_url` | ☑ | TaxHub URL | |
| `uh_application_id` | ☐ | GeoNature application ID in UsersHub | |
| `observers_list_id` | ☐ | GeoNature selected observer list ID in UsersHub | |
| `taxa_list_id` | ☐ | GeoNature selected taxa list ID | |
| `code_area_type` | ☐ | GeoNature selected area type | |
| `page_size` | ☐ | Default page size while fetching paginated values | 1000 |
| `page_max_retry` | ☐ | Max attempt to fetch data according to given page size | 20 |
| Parameter | UI | Description | Default value |
| --------------------------------- | ------- | ------------------------------------------------------ | ------------- |
| `geonature_url` | ☑ | GeoNature URL | |
| `taxhub_url` | ☑ | TaxHub URL | |
| `uh_application_id` | ☐ | GeoNature application ID in UsersHub | |
| `observers_list_id` | ☐ | GeoNature selected observer list ID in UsersHub | |
| `taxa_list_id` | ☐ | GeoNature selected taxa list ID | |
| `code_area_type` | ☐ | GeoNature selected area type | |
| `page_size` | ☐ | Default page size while fetching paginated values | 1000 |
| `page_max_retry` | ☐ | Max attempt to fetch data according to given page size | 20 |
| `sync_periodicity_data_essential` | ☐ | Configure essential data synchronization periodicity | |
| `sync_periodicity_data` | ☐ | Configure all data synchronization periodicity | |

### Data synchronization periodicity

By default, data synchronization is done manually through app interface.
If one of these parameters are set (`sync_periodicity_data_essential` or `sync_periodicity_data`), data synchronization is also made automatically according to these parameters.

The expected format describing a periodic synchronization must following the pattern `DdHhMmSs` where `d`, `h`, `m`, `s` represents the time unit of the duration.
Each part (duration value and its time unit) of the duration is optional. A time unit represents time durations at a given unit of granularity:

- `d`: time unit representing 24 hours (i.e. one day)
- `h`: time unit representing 60 minutes (i.e. one hour)
- `m`: time unit representing 60 seconds (i.e. one minute)
- `s`: time unit representing one second

Examples of valid durations:

- `1d12h`: 36 hours (i.e. 1.5 days)
- `1d`: 24 hours (i.e. one day)
- `4h30m`: 4.5 hours
- `15m`: 15 minutes

A valid synchronization periodicity should not be less than 15 minutes: Such a configuration will be ignored.
If only one of these parameters is set, data synchronization involves all data.
If both of these parameters are set, `sync_periodicity_data` parameter should be greater than `sync_periodicity_data_essential` parameter.

## Content Provider

Expand All @@ -56,7 +82,7 @@ The authority of this content provider is `fr.geonature.sync.provider`.

### Exposed content URIs

Base URI: `content://fr.geonature.sync.provider`
**Base URI:** `content://fr.geonature.sync.provider`

| URI | Parameters | Description |
| -------------------------------------------------- | --------------------------------------- | --------------------------------------------------------------------------------------------------------- |
Expand Down
12 changes: 4 additions & 8 deletions sync/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-kapt"

version = "1.1.4"
version = "1.1.5"

android {
compileSdkVersion 29
Expand Down Expand Up @@ -70,13 +70,11 @@ dependencies {

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

implementation 'androidx.constraintlayout:constraintlayout:2.1.0-alpha2'
implementation 'androidx.core:core-ktx:1.5.0-beta01'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.work:work-runtime-ktx:2.5.0'
implementation 'com.google.android.material:material:1.3.0-rc01'
implementation 'com.google.android.material:material:1.4.0-alpha01'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.0'
implementation 'com.squareup.retrofit2:converter-gson:2.6.0'
Expand All @@ -85,9 +83,7 @@ dependencies {
kapt 'androidx.room:room-compiler:2.2.6'

testImplementation 'androidx.test:core:1.3.0'
testImplementation 'junit:junit:4.13.1'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:3.0.0'
testImplementation 'org.robolectric:robolectric:4.3.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0-alpha03'
androidTestImplementation 'androidx.test:runner:1.3.1-alpha03'
}
39 changes: 31 additions & 8 deletions sync/src/main/java/fr/geonature/sync/MainApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,21 @@ class MainApplication : Application() {
"external storage: " + getExternalStorage(this)
)

val notificationManager = NotificationManagerCompat.from(this)
configureCheckInputsToSynchronizeChannel(notificationManager)
configureSynchronizeDataChannel(notificationManager)

checkInputsToSynchronize()
}

private fun checkInputsToSynchronize() {
val notificationManager = NotificationManagerCompat.from(this)
configureSyncChannel(notificationManager)
val workManager: WorkManager = WorkManager.getInstance(this)

val request = PeriodicWorkRequestBuilder<CheckInputsToSynchronizeWorker>(
15,
TimeUnit.MINUTES
).addTag(CheckInputsToSynchronizeWorker.CHECK_INPUTS_TO_SYNC_WORKER_TAG)
)
.addTag(CheckInputsToSynchronizeWorker.CHECK_INPUTS_TO_SYNC_WORKER_TAG)
.build()

workManager.enqueueUniquePeriodicWork(
Expand All @@ -53,14 +56,14 @@ class MainApplication : Application() {
)
}

private fun configureSyncChannel(notificationManager: NotificationManagerCompat): NotificationChannel? {
private fun configureCheckInputsToSynchronizeChannel(notificationManager: NotificationManagerCompat): NotificationChannel? {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
val channel = NotificationChannel(
SYNC_CHANNEL_ID,
getText(R.string.sync_channel_name),
CHANNEL_CHECK_INPUTS_TO_SYNCHRONIZE,
getText(R.string.channel_name_check_inputs_to_synchronize),
NotificationManager.IMPORTANCE_LOW
).apply {
description = getString(R.string.sync_channel_description)
description = getString(R.string.channel_description_check_inputs_to_synchronize)
setShowBadge(true)
}

Expand All @@ -73,9 +76,29 @@ class MainApplication : Application() {
return null
}

private fun configureSynchronizeDataChannel(notificationManager: NotificationManagerCompat): NotificationChannel? {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
val channel = NotificationChannel(
CHANNEL_DATA_SYNCHRONIZATION,
getText(R.string.channel_name_data_synchronization),
NotificationManager.IMPORTANCE_LOW
).apply {
description = getString(R.string.channel_description_data_synchronization)
}

// register this channel with the system
notificationManager.createNotificationChannel(channel)

return channel
}

return null
}

companion object {
private val TAG = MainApplication::class.java.name

const val SYNC_CHANNEL_ID = "sync_channel"
const val CHANNEL_CHECK_INPUTS_TO_SYNCHRONIZE = "channel_check_inputs_to_synchronize"
const val CHANNEL_DATA_SYNCHRONIZATION = "channel_data_synchronization"
}
}
Loading

0 comments on commit e15e8b7

Please sign in to comment.