diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index ffb732d9..c8bbe249 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -5,21 +5,20 @@
diff --git a/build.gradle b/build.gradle
index ab964c2e..0a258245 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,7 +1,10 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
- ext.kotlin_version = '1.5.21'
+ ext.kotlin_version = '1.6.10'
+ ext.androidx_hilt_version = '1.0.0'
+ ext.hilt_version = '2.40.5'
+ ext.retrofit_version = '2.9.0'
repositories {
google()
@@ -12,11 +15,10 @@ buildscript {
}
dependencies {
- classpath 'com.android.tools.build:gradle:4.2.2'
+ classpath 'com.android.tools.build:gradle:7.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+ classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
classpath "org.jlleitschuh.gradle:ktlint-gradle:9.4.1"
- // NOTE: Do not place application dependencies here; they belong
- // in the individual module build.gradle files
}
}
diff --git a/gn_mobile_core b/gn_mobile_core
index b02bfbbc..c9a65b95 160000
--- a/gn_mobile_core
+++ b/gn_mobile_core
@@ -1 +1 @@
-Subproject commit b02bfbbc05b22ccd33f8d1c91d565c68d268ea55
+Subproject commit c9a65b95040bed91fc71e8188fc26083e893b780
diff --git a/gn_mobile_maps b/gn_mobile_maps
index d7479e6d..1146f768 160000
--- a/gn_mobile_maps
+++ b/gn_mobile_maps
@@ -1 +1 @@
-Subproject commit d7479e6dfc030f2b38df31a66976190c2715f42b
+Subproject commit 1146f7686212f2b8a420d73d01c75e2a9c7a7561
diff --git a/gn_mobile_occtax.iml b/gn_mobile_occtax.iml
index 043f8194..10e828d0 100644
--- a/gn_mobile_occtax.iml
+++ b/gn_mobile_occtax.iml
@@ -3,16 +3,18 @@
-
-
+
+
+
+
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 95155b9c..69d91e98 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
diff --git a/occtax/build.gradle b/occtax/build.gradle
index 7dd63f5b..87c28461 100644
--- a/occtax/build.gradle
+++ b/occtax/build.gradle
@@ -1,30 +1,38 @@
-apply plugin: 'com.android.application'
-apply plugin: 'kotlin-android'
+plugins {
+ id 'com.android.application'
+ id 'dagger.hilt.android.plugin'
+ id 'kotlin-android'
+ id 'kotlin-kapt'
+}
-version = "1.3.0"
+version = "1.3.1"
android {
- compileSdkVersion 29
+ compileSdkVersion 31
compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
+ sourceCompatibility JavaVersion.VERSION_11
+ targetCompatibility JavaVersion.VERSION_11
+ }
+
+ kotlinOptions {
+ jvmTarget = JavaVersion.VERSION_11.toString()
}
defaultConfig {
applicationId "fr.geonature.occtax"
minSdkVersion 21
- targetSdkVersion 29
- versionCode updateVersionCode(module.name)
+ targetSdkVersion 31
+ versionCode updateVersionCode(project.name)
versionName version
buildConfigField "String", "BUILD_DATE", "\"" + new Date().getTime() + "\""
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
- archivesBaseName = module.name + "-" + versionName
+ archivesBaseName = project.name + "-" + versionName
}
signingConfigs {
release {
- readKeystoreProperties(module.name)
+ readKeystoreProperties(project.name)
}
}
@@ -66,18 +74,22 @@ dependencies {
implementation project(':viewpager')
implementation project(':maps')
- implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
- implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1'
- implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1'
+ // Hilt dependencies
+ implementation "androidx.hilt:hilt-work:$androidx_hilt_version"
+ implementation "com.google.dagger:hilt-android:$hilt_version"
+ kapt "androidx.hilt:hilt-compiler:$androidx_hilt_version"
+ kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
implementation 'androidx.cardview:cardview:1.0.0'
- implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
- implementation 'androidx.preference:preference-ktx:1.1.1'
- implementation 'androidx.recyclerview:recyclerview:1.2.0'
- implementation 'com.google.android.material:material:1.3.0'
+ implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
+ implementation 'androidx.preference:preference-ktx:1.2.0'
+ implementation 'androidx.recyclerview:recyclerview:1.2.1'
+ implementation 'com.google.android.material:material:1.5.0'
implementation "io.github.l4digital:fastscroll:2.0.1"
+ // Testing dependencies
testImplementation 'androidx.test:core:1.4.0'
+ testImplementation "com.google.dagger:hilt-android-testing:$hilt_version"
testImplementation 'junit:junit:4.13.2'
- testImplementation 'org.robolectric:robolectric:4.5.1'
+ testImplementation 'org.robolectric:robolectric:4.7.3'
}
diff --git a/occtax/src/main/AndroidManifest.xml b/occtax/src/main/AndroidManifest.xml
index 5c27d169..2b2dfd40 100644
--- a/occtax/src/main/AndroidManifest.xml
+++ b/occtax/src/main/AndroidManifest.xml
@@ -20,6 +20,7 @@
diff --git a/occtax/src/main/java/fr/geonature/occtax/MainApplication.kt b/occtax/src/main/java/fr/geonature/occtax/MainApplication.kt
index 658b2d50..fcb75f32 100644
--- a/occtax/src/main/java/fr/geonature/occtax/MainApplication.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/MainApplication.kt
@@ -2,6 +2,7 @@ package fr.geonature.occtax
import android.app.Application
import android.util.Log
+import dagger.hilt.android.HiltAndroidApp
import fr.geonature.mountpoint.util.MountPointUtils
import fr.geonature.occtax.di.ServiceLocator
@@ -10,6 +11,7 @@ import fr.geonature.occtax.di.ServiceLocator
*
* @author S. Grimault
*/
+@HiltAndroidApp
class MainApplication : Application() {
override fun onCreate() {
diff --git a/occtax/src/main/java/fr/geonature/occtax/input/InputTaxon.kt b/occtax/src/main/java/fr/geonature/occtax/input/InputTaxon.kt
index 64b9ee8a..88ed345e 100644
--- a/occtax/src/main/java/fr/geonature/occtax/input/InputTaxon.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/input/InputTaxon.kt
@@ -2,7 +2,7 @@ package fr.geonature.occtax.input
import android.os.Parcel
import android.os.Parcelable
-import fr.geonature.commons.data.AbstractTaxon
+import fr.geonature.commons.data.entity.AbstractTaxon
import fr.geonature.commons.input.AbstractInputTaxon
import java.util.SortedMap
import java.util.TreeMap
@@ -10,12 +10,12 @@ import java.util.TreeMap
/**
* Describes an input taxon.
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
class InputTaxon : AbstractInputTaxon {
val properties: SortedMap =
- TreeMap { o1, o2 ->
+ TreeMap { o1, o2 ->
val i1 = defaultPropertiesMnemonic.indexOfFirst { it.first == o1 }
val i2 = defaultPropertiesMnemonic.indexOfFirst { it.first == o2 }
@@ -25,7 +25,7 @@ class InputTaxon : AbstractInputTaxon {
else -> i1 - i2
}
}
- private val counting: SortedMap = TreeMap()
+ private val counting: SortedMap = TreeMap()
constructor(taxon: AbstractTaxon) : super(taxon)
constructor(source: Parcel) : super(source) {
diff --git a/occtax/src/main/java/fr/geonature/occtax/input/PropertyValue.kt b/occtax/src/main/java/fr/geonature/occtax/input/PropertyValue.kt
index 6ab3174b..ea782abc 100644
--- a/occtax/src/main/java/fr/geonature/occtax/input/PropertyValue.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/input/PropertyValue.kt
@@ -2,14 +2,14 @@ package fr.geonature.occtax.input
import android.os.Parcel
import android.os.Parcelable
-import fr.geonature.commons.data.Nomenclature
+import fr.geonature.commons.data.entity.Nomenclature
import fr.geonature.commons.input.AbstractInputTaxon
import java.io.Serializable
/**
* Property value for [AbstractInputTaxon]
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
data class PropertyValue(
val code: String,
diff --git a/occtax/src/main/java/fr/geonature/occtax/input/io/OnInputJsonReaderListenerImpl.kt b/occtax/src/main/java/fr/geonature/occtax/input/io/OnInputJsonReaderListenerImpl.kt
index 5fb385fc..d7b33aed 100644
--- a/occtax/src/main/java/fr/geonature/occtax/input/io/OnInputJsonReaderListenerImpl.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/input/io/OnInputJsonReaderListenerImpl.kt
@@ -3,8 +3,8 @@ package fr.geonature.occtax.input.io
import android.text.TextUtils
import android.util.JsonReader
import android.util.JsonToken
-import fr.geonature.commons.data.Taxon
-import fr.geonature.commons.data.Taxonomy
+import fr.geonature.commons.data.entity.Taxon
+import fr.geonature.commons.data.entity.Taxonomy
import fr.geonature.commons.input.io.InputJsonReader
import fr.geonature.commons.util.toDate
import fr.geonature.maps.jts.geojson.io.GeoJsonReader
@@ -19,7 +19,7 @@ import java.util.Locale
/**
* Default implementation of [InputJsonReader.OnInputJsonReaderListener].
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
class OnInputJsonReaderListenerImpl : InputJsonReader.OnInputJsonReaderListener {
diff --git a/occtax/src/main/java/fr/geonature/occtax/settings/AppSettingsModule.kt b/occtax/src/main/java/fr/geonature/occtax/settings/AppSettingsModule.kt
new file mode 100644
index 00000000..249af13c
--- /dev/null
+++ b/occtax/src/main/java/fr/geonature/occtax/settings/AppSettingsModule.kt
@@ -0,0 +1,33 @@
+package fr.geonature.occtax.settings
+
+import android.content.Context
+import dagger.Module
+import dagger.Provides
+import dagger.hilt.InstallIn
+import dagger.hilt.android.qualifiers.ApplicationContext
+import dagger.hilt.components.SingletonComponent
+import fr.geonature.commons.settings.AppSettingsManagerImpl
+import fr.geonature.commons.settings.IAppSettingsManager
+import fr.geonature.occtax.settings.io.OnAppSettingsJsonReaderListenerImpl
+import javax.inject.Singleton
+
+/**
+ * Application settings module.
+ *
+ * @author S. Grimault
+ */
+@Module
+@InstallIn(SingletonComponent::class)
+object AppSettingsModule {
+
+ @Singleton
+ @Provides
+ fun provideAppSettingsManager(
+ @ApplicationContext appContext: Context
+ ): IAppSettingsManager {
+ return AppSettingsManagerImpl(
+ appContext,
+ OnAppSettingsJsonReaderListenerImpl()
+ )
+ }
+}
\ No newline at end of file
diff --git a/occtax/src/main/java/fr/geonature/occtax/settings/AppSettingsViewModel.kt b/occtax/src/main/java/fr/geonature/occtax/settings/AppSettingsViewModel.kt
index 09981451..c51059dc 100644
--- a/occtax/src/main/java/fr/geonature/occtax/settings/AppSettingsViewModel.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/settings/AppSettingsViewModel.kt
@@ -1,15 +1,17 @@
package fr.geonature.occtax.settings
-import android.app.Application
+import dagger.hilt.android.lifecycle.HiltViewModel
+import fr.geonature.commons.settings.IAppSettingsManager
+import javax.inject.Inject
import fr.geonature.commons.settings.AppSettingsViewModel as BaseAppSettingsViewModel
-import fr.geonature.occtax.settings.io.OnAppSettingsJsonReaderListenerImpl
/**
* [AppSettings] view model.
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
-class AppSettingsViewModel(application: Application) : BaseAppSettingsViewModel(
- application,
- OnAppSettingsJsonReaderListenerImpl()
-)
+@HiltViewModel
+class AppSettingsViewModel @Inject constructor(appSettingsManager: IAppSettingsManager) :
+ BaseAppSettingsViewModel(
+ appSettingsManager
+ )
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/dataset/DatasetListActivity.kt b/occtax/src/main/java/fr/geonature/occtax/ui/dataset/DatasetListActivity.kt
index 4855bea7..e9f37f27 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/dataset/DatasetListActivity.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/dataset/DatasetListActivity.kt
@@ -5,7 +5,7 @@ import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
-import fr.geonature.commons.data.Dataset
+import fr.geonature.commons.data.entity.Dataset
import fr.geonature.occtax.R
/**
@@ -13,7 +13,7 @@ import fr.geonature.occtax.R
*
* @see DatasetListFragment
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
class DatasetListActivity : AppCompatActivity(),
DatasetListFragment.OnDatasetListFragmentListener {
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/dataset/DatasetListFragment.kt b/occtax/src/main/java/fr/geonature/occtax/ui/dataset/DatasetListFragment.kt
index 867b0304..c967dfbe 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/dataset/DatasetListFragment.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/dataset/DatasetListFragment.kt
@@ -18,7 +18,7 @@ import androidx.loader.content.Loader
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
-import fr.geonature.commons.data.Dataset
+import fr.geonature.commons.data.entity.Dataset
import fr.geonature.commons.data.helper.Provider.buildUri
import fr.geonature.occtax.R
import fr.geonature.occtax.R.layout.fast_scroll_recycler_view
@@ -26,7 +26,7 @@ import fr.geonature.occtax.R.layout.fast_scroll_recycler_view
/**
* [Fragment] to let the user to choose a [Dataset] from the list.
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
class DatasetListFragment : Fragment() {
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/dataset/DatasetRecyclerViewAdapter.kt b/occtax/src/main/java/fr/geonature/occtax/ui/dataset/DatasetRecyclerViewAdapter.kt
index 3afc35c9..7829a2ff 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/dataset/DatasetRecyclerViewAdapter.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/dataset/DatasetRecyclerViewAdapter.kt
@@ -9,7 +9,7 @@ import android.widget.CheckBox
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.l4digital.fastscroll.FastScroller
-import fr.geonature.commons.data.Dataset
+import fr.geonature.commons.data.entity.Dataset
import fr.geonature.occtax.R
/**
@@ -17,7 +17,7 @@ import fr.geonature.occtax.R
*
* @see DatasetListFragment
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
class DatasetRecyclerViewAdapter(private val listener: OnDatasetRecyclerViewAdapterListener) :
RecyclerView.Adapter(),
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/home/AppSyncView.kt b/occtax/src/main/java/fr/geonature/occtax/ui/home/AppSyncView.kt
index 30178801..7399aa46 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/home/AppSyncView.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/home/AppSyncView.kt
@@ -5,7 +5,7 @@ import android.text.format.DateFormat
import android.util.AttributeSet
import android.util.Pair
import android.view.View
-import fr.geonature.commons.data.AppSync
+import fr.geonature.commons.data.entity.AppSync
import fr.geonature.occtax.R
import fr.geonature.occtax.ui.shared.view.ListItemActionView
import java.text.NumberFormat
@@ -13,7 +13,7 @@ import java.text.NumberFormat
/**
* Custom [View] about [AppSync].
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
class AppSyncView : ListItemActionView {
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/home/HomeActivity.kt b/occtax/src/main/java/fr/geonature/occtax/ui/home/HomeActivity.kt
index 38edd92f..a0a0bfa8 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/home/HomeActivity.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/home/HomeActivity.kt
@@ -10,6 +10,7 @@ import android.view.MenuItem
import android.view.View
import android.view.animation.AnimationUtils
import android.widget.TextView
+import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.content.ContextCompat
@@ -24,7 +25,8 @@ import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.google.android.material.snackbar.BaseTransientBottomBar
import com.google.android.material.snackbar.Snackbar
-import fr.geonature.commons.data.AppSync
+import dagger.hilt.android.AndroidEntryPoint
+import fr.geonature.commons.data.entity.AppSync
import fr.geonature.commons.data.helper.Provider
import fr.geonature.commons.ui.adapter.AbstractListItemRecyclerViewAdapter
import fr.geonature.commons.util.observeOnce
@@ -42,11 +44,12 @@ import fr.geonature.occtax.util.IntentUtils.syncActivity
/**
* Home screen Activity.
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
+@AndroidEntryPoint
class HomeActivity : AppCompatActivity() {
- private lateinit var appSettingsViewModel: AppSettingsViewModel
+ private val appSettingsViewModel: AppSettingsViewModel by viewModels()
private lateinit var inputViewModel: InputViewModel
private var homeContent: CoordinatorLayout? = null
@@ -120,7 +123,6 @@ class HomeActivity : AppCompatActivity() {
inputEmptyTextView = findViewById(R.id.inputEmptyTextView)
fab = findViewById(R.id.fab)
- appSettingsViewModel = configureAppSettingsViewModel()
inputViewModel = configureInputViewModel()
appSyncView?.setListener(object : ListItemActionView.OnListItemActionViewListener {
@@ -271,21 +273,12 @@ class HomeActivity : AppCompatActivity() {
)
}
- private fun configureAppSettingsViewModel(): AppSettingsViewModel {
- return ViewModelProvider(
- this,
- fr.geonature.commons.settings.AppSettingsViewModel.Factory {
- AppSettingsViewModel(application)
- }
- ).get(AppSettingsViewModel::class.java)
- }
-
private fun configureInputViewModel(): InputViewModel {
return ViewModelProvider(
this,
- fr.geonature.commons.input.InputViewModel.Factory { InputViewModel((application as MainApplication).sl.inputManager) }).get(
- InputViewModel::class.java
- )
+ fr.geonature.commons.input.InputViewModel.Factory {
+ InputViewModel((application as MainApplication).sl.inputManager)
+ })[InputViewModel::class.java]
}
private fun loadAppSettings() {
@@ -314,11 +307,10 @@ class HomeActivity : AppCompatActivity() {
private fun loadInputs() {
inputViewModel.readInputs().observe(
- this,
- {
- adapter.setItems(it)
- }
- )
+ this
+ ) {
+ adapter.setItems(it)
+ }
}
private fun checkAppSync(): Boolean {
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/input/InputPagerFragmentActivity.kt b/occtax/src/main/java/fr/geonature/occtax/ui/input/InputPagerFragmentActivity.kt
index a2f6b989..6b55a8b8 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/input/InputPagerFragmentActivity.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/input/InputPagerFragmentActivity.kt
@@ -1,13 +1,19 @@
package fr.geonature.occtax.ui.input
+import android.Manifest
import android.content.Context
import android.content.Intent
+import android.os.Build
import android.os.Bundle
import android.util.Log
import androidx.lifecycle.ViewModelProvider
+import androidx.lifecycle.lifecycleScope
import androidx.viewpager.widget.ViewPager
import fr.geonature.commons.input.AbstractInput
import fr.geonature.maps.settings.MapSettings
+import fr.geonature.maps.ui.MapFragment
+import fr.geonature.maps.util.CheckPermissionLifecycleObserver
+import fr.geonature.maps.util.ManageExternalStoragePermissionLifecycleObserver
import fr.geonature.maps.util.MapSettingsPreferencesUtils.showCompass
import fr.geonature.maps.util.MapSettingsPreferencesUtils.showScale
import fr.geonature.maps.util.MapSettingsPreferencesUtils.showZoom
@@ -25,24 +31,48 @@ import fr.geonature.occtax.ui.input.taxa.TaxaFragment
import fr.geonature.viewpager.ui.AbstractNavigationHistoryPagerFragmentActivity
import fr.geonature.viewpager.ui.AbstractPagerFragmentActivity
import fr.geonature.viewpager.ui.IValidateFragment
+import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
+import kotlinx.coroutines.suspendCancellableCoroutine
+import kotlin.coroutines.resume
/**
* [ViewPager] implementation as [AbstractPagerFragmentActivity] with navigation history support.
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
-class InputPagerFragmentActivity : AbstractNavigationHistoryPagerFragmentActivity() {
+class InputPagerFragmentActivity : AbstractNavigationHistoryPagerFragmentActivity(),
+ MapFragment.OnMapFragmentPermissionsListener {
private lateinit var inputViewModel: InputViewModel
private lateinit var appSettings: AppSettings
private lateinit var input: Input
+ private var manageExternalStoragePermissionLifecycleObserver: ManageExternalStoragePermissionLifecycleObserver? =
+ null
+ private var readExternalStoragePermissionLifecycleObserver: CheckPermissionLifecycleObserver? =
+ null
+ private var locationPermissionLifecycleObserver: CheckPermissionLifecycleObserver? = null
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+ manageExternalStoragePermissionLifecycleObserver =
+ ManageExternalStoragePermissionLifecycleObserver(this)
+ } else {
+ readExternalStoragePermissionLifecycleObserver = CheckPermissionLifecycleObserver(
+ this,
+ Manifest.permission.READ_EXTERNAL_STORAGE
+ )
+ }
+
+ locationPermissionLifecycleObserver = CheckPermissionLifecycleObserver(
+ this,
+ Manifest.permission.ACCESS_FINE_LOCATION
+ )
+
inputViewModel = configureInputViewModel()
appSettings = intent.getParcelableExtra(EXTRA_APP_SETTINGS)!!
@@ -58,7 +88,7 @@ class InputPagerFragmentActivity : AbstractNavigationHistoryPagerFragmentActivit
"loading input: ${input.id}"
)
- GlobalScope.launch(Dispatchers.Main) {
+ CoroutineScope(Dispatchers.Main).launch {
pagerManager.load(input.id)
}
}
@@ -122,6 +152,29 @@ class InputPagerFragmentActivity : AbstractNavigationHistoryPagerFragmentActivit
}
}
+ override suspend fun onStoragePermissionsGranted() =
+ suspendCancellableCoroutine { continuation ->
+ lifecycleScope.launch {
+ continuation.resume(
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+ manageExternalStoragePermissionLifecycleObserver?.invoke()
+ } else {
+ readExternalStoragePermissionLifecycleObserver?.invoke(this@InputPagerFragmentActivity)
+ } ?: false
+ )
+ }
+ }
+
+ override suspend fun onLocationPermissionGranted() =
+ suspendCancellableCoroutine { continuation ->
+ lifecycleScope.launch {
+ continuation.resume(
+ locationPermissionLifecycleObserver?.invoke(this@InputPagerFragmentActivity)
+ ?: false
+ )
+ }
+ }
+
private fun configureInputViewModel(): InputViewModel {
return ViewModelProvider(
this,
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/input/counting/CountingFragment.kt b/occtax/src/main/java/fr/geonature/occtax/ui/input/counting/CountingFragment.kt
index 8aa104af..72b8a75f 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/input/counting/CountingFragment.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/input/counting/CountingFragment.kt
@@ -20,7 +20,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.google.android.material.snackbar.Snackbar
-import fr.geonature.commons.data.Taxonomy
+import fr.geonature.commons.data.entity.Taxonomy
import fr.geonature.commons.input.AbstractInput
import fr.geonature.commons.ui.adapter.AbstractListItemRecyclerViewAdapter
import fr.geonature.occtax.R
@@ -35,7 +35,7 @@ import fr.geonature.viewpager.ui.IValidateFragment
/**
* [Fragment] to let the user to add additional counting information for the given [Input].
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
class CountingFragment : Fragment(),
IValidateFragment,
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/input/counting/EditCountingMetadataActivity.kt b/occtax/src/main/java/fr/geonature/occtax/ui/input/counting/EditCountingMetadataActivity.kt
index 6efbd061..df4beea7 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/input/counting/EditCountingMetadataActivity.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/input/counting/EditCountingMetadataActivity.kt
@@ -8,7 +8,7 @@ import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
-import fr.geonature.commons.data.Taxonomy
+import fr.geonature.commons.data.entity.Taxonomy
import fr.geonature.occtax.R
import fr.geonature.occtax.input.CountingMetadata
import fr.geonature.occtax.settings.PropertySettings
@@ -18,7 +18,7 @@ import fr.geonature.occtax.settings.PropertySettings
*
* @see EditCountingMetadataFragment
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
class EditCountingMetadataActivity : AppCompatActivity(),
EditCountingMetadataFragment.OnEditCountingMetadataFragmentListener {
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/input/counting/EditCountingMetadataFragment.kt b/occtax/src/main/java/fr/geonature/occtax/ui/input/counting/EditCountingMetadataFragment.kt
index 68b20ed7..7e001e80 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/input/counting/EditCountingMetadataFragment.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/input/counting/EditCountingMetadataFragment.kt
@@ -14,12 +14,12 @@ import androidx.loader.content.CursorLoader
import androidx.loader.content.Loader
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
-import fr.geonature.commons.data.Dataset
-import fr.geonature.commons.data.DefaultNomenclature
-import fr.geonature.commons.data.DefaultNomenclatureWithType
-import fr.geonature.commons.data.Nomenclature
-import fr.geonature.commons.data.NomenclatureType
-import fr.geonature.commons.data.Taxonomy
+import fr.geonature.commons.data.entity.Dataset
+import fr.geonature.commons.data.entity.DefaultNomenclature
+import fr.geonature.commons.data.entity.DefaultNomenclatureWithType
+import fr.geonature.commons.data.entity.Nomenclature
+import fr.geonature.commons.data.entity.NomenclatureType
+import fr.geonature.commons.data.entity.Taxonomy
import fr.geonature.commons.data.helper.Provider.buildUri
import fr.geonature.commons.util.KeyboardUtils.hideSoftKeyboard
import fr.geonature.occtax.R
@@ -32,7 +32,7 @@ import fr.geonature.occtax.ui.input.dialog.ChooseNomenclatureDialogFragment
/**
* [Fragment] to let the user to edit additional counting information for the given [Input].
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
class EditCountingMetadataFragment : Fragment(),
ChooseNomenclatureDialogFragment.OnChooseNomenclatureDialogFragmentListener {
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/input/counting/NomenclatureTypesRecyclerViewAdapter.kt b/occtax/src/main/java/fr/geonature/occtax/ui/input/counting/NomenclatureTypesRecyclerViewAdapter.kt
index f6a6ad11..b3d72e58 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/input/counting/NomenclatureTypesRecyclerViewAdapter.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/input/counting/NomenclatureTypesRecyclerViewAdapter.kt
@@ -13,7 +13,7 @@ import android.widget.TextView
import androidx.annotation.LayoutRes
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
-import fr.geonature.commons.data.NomenclatureType
+import fr.geonature.commons.data.entity.NomenclatureType
import fr.geonature.commons.util.KeyboardUtils.hideSoftKeyboard
import fr.geonature.occtax.R
import fr.geonature.occtax.input.CountingMetadata
@@ -25,7 +25,7 @@ import java.util.Locale
/**
* Default RecyclerView Adapter used by [EditCountingMetadataFragment].
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
class NomenclatureTypesRecyclerViewAdapter(private val listener: OnNomenclatureTypesRecyclerViewAdapterListener) :
RecyclerView.Adapter() {
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/input/dialog/ChooseNomenclatureDialogFragment.kt b/occtax/src/main/java/fr/geonature/occtax/ui/input/dialog/ChooseNomenclatureDialogFragment.kt
index 95a621d8..40642310 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/input/dialog/ChooseNomenclatureDialogFragment.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/input/dialog/ChooseNomenclatureDialogFragment.kt
@@ -13,9 +13,9 @@ import androidx.loader.content.Loader
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
-import fr.geonature.commons.data.Nomenclature
-import fr.geonature.commons.data.NomenclatureType
-import fr.geonature.commons.data.Taxonomy
+import fr.geonature.commons.data.entity.Nomenclature
+import fr.geonature.commons.data.entity.NomenclatureType
+import fr.geonature.commons.data.entity.Taxonomy
import fr.geonature.commons.data.helper.Provider.buildUri
import fr.geonature.occtax.R
import java.util.Locale
@@ -23,7 +23,7 @@ import java.util.Locale
/**
* [DialogFragment] to let the user to choose a nomenclature value for a given [NomenclatureType].
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
class ChooseNomenclatureDialogFragment : DialogFragment() {
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/input/dialog/NomenclatureRecyclerViewAdapter.kt b/occtax/src/main/java/fr/geonature/occtax/ui/input/dialog/NomenclatureRecyclerViewAdapter.kt
index cb20220c..b88965d0 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/input/dialog/NomenclatureRecyclerViewAdapter.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/input/dialog/NomenclatureRecyclerViewAdapter.kt
@@ -6,25 +6,22 @@ import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
-import fr.geonature.commons.data.Nomenclature
-import fr.geonature.commons.data.NomenclatureWithTaxonomy
+import fr.geonature.commons.data.entity.Nomenclature
+import fr.geonature.commons.data.entity.NomenclatureWithTaxonomy
import fr.geonature.occtax.R
/**
* Default RecyclerView Adapter used by [ChooseNomenclatureDialogFragment].
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
-class NomenclatureRecyclerViewAdapter(private val listener: OnNomenclatureRecyclerViewAdapterListener) : RecyclerView.Adapter() {
+class NomenclatureRecyclerViewAdapter(private val listener: OnNomenclatureRecyclerViewAdapterListener) :
+ RecyclerView.Adapter() {
private var cursor: Cursor? = null
- private val onClickListener: View.OnClickListener
-
- init {
- onClickListener = View.OnClickListener { v ->
- val nomenclature = v.tag as Nomenclature
- listener.onSelectedNomenclature(nomenclature)
- }
+ private val onClickListener: View.OnClickListener = View.OnClickListener { v ->
+ val nomenclature = v.tag as Nomenclature
+ listener.onSelectedNomenclature(nomenclature)
}
override fun onCreateViewHolder(
@@ -50,9 +47,13 @@ class NomenclatureRecyclerViewAdapter(private val listener: OnNomenclatureRecycl
notifyDataSetChanged()
}
- inner class ViewHolder(parent: ViewGroup) : RecyclerView.ViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.list_item_2,
- parent,
- false)) {
+ inner class ViewHolder(parent: ViewGroup) : RecyclerView.ViewHolder(
+ LayoutInflater.from(parent.context).inflate(
+ R.layout.list_item_2,
+ parent,
+ false
+ )
+ ) {
private val text1: TextView = itemView.findViewById(android.R.id.text1)
fun bind(position: Int) {
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/input/informations/InformationFragment.kt b/occtax/src/main/java/fr/geonature/occtax/ui/input/informations/InformationFragment.kt
index b2c0cbf4..e02b1d79 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/input/informations/InformationFragment.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/input/informations/InformationFragment.kt
@@ -12,10 +12,10 @@ import androidx.loader.content.CursorLoader
import androidx.loader.content.Loader
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
-import fr.geonature.commons.data.DefaultNomenclatureWithType
-import fr.geonature.commons.data.Nomenclature
-import fr.geonature.commons.data.NomenclatureType
-import fr.geonature.commons.data.Taxonomy
+import fr.geonature.commons.data.entity.DefaultNomenclatureWithType
+import fr.geonature.commons.data.entity.Nomenclature
+import fr.geonature.commons.data.entity.NomenclatureType
+import fr.geonature.commons.data.entity.Taxonomy
import fr.geonature.commons.data.helper.Provider.buildUri
import fr.geonature.commons.input.AbstractInput
import fr.geonature.occtax.R
@@ -30,7 +30,7 @@ import fr.geonature.viewpager.ui.IValidateFragment
/**
* [Fragment] to let the user to add additional information for the given [Input].
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
class InformationFragment : Fragment(),
IValidateFragment,
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/input/informations/NomenclatureTypesRecyclerViewAdapter.kt b/occtax/src/main/java/fr/geonature/occtax/ui/input/informations/NomenclatureTypesRecyclerViewAdapter.kt
index cce8c0a9..58376c66 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/input/informations/NomenclatureTypesRecyclerViewAdapter.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/input/informations/NomenclatureTypesRecyclerViewAdapter.kt
@@ -14,7 +14,7 @@ import android.widget.TextView
import androidx.annotation.LayoutRes
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
-import fr.geonature.commons.data.NomenclatureType
+import fr.geonature.commons.data.entity.NomenclatureType
import fr.geonature.commons.util.KeyboardUtils.hideSoftKeyboard
import fr.geonature.occtax.R
import fr.geonature.occtax.input.InputTaxon
@@ -26,7 +26,7 @@ import java.util.Locale
/**
* Default RecyclerView Adapter used by [InformationFragment].
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
class NomenclatureTypesRecyclerViewAdapter(private val listener: OnNomenclatureTypesRecyclerViewAdapterListener) :
RecyclerView.Adapter() {
@@ -43,13 +43,9 @@ class NomenclatureTypesRecyclerViewAdapter(private val listener: OnNomenclatureT
private val properties = mutableListOf()
private var showAllNomenclatureTypes = false
- private val onClickListener: View.OnClickListener
-
- init {
- onClickListener = View.OnClickListener { v ->
- val selectedProperty = v.tag as PropertyValue
- listener.onAction(selectedProperty.code)
- }
+ private val onClickListener: View.OnClickListener = View.OnClickListener { v ->
+ val selectedProperty = v.tag as PropertyValue
+ listener.onAction(selectedProperty.code)
}
override fun onCreateViewHolder(
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/input/map/InputMapFragment.kt b/occtax/src/main/java/fr/geonature/occtax/ui/input/map/InputMapFragment.kt
index 134b63b7..d5ec9fc2 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/input/map/InputMapFragment.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/input/map/InputMapFragment.kt
@@ -17,8 +17,8 @@ import fr.geonature.occtax.input.Input
import fr.geonature.occtax.ui.input.IInputFragment
import fr.geonature.viewpager.ui.AbstractPagerFragmentActivity
import fr.geonature.viewpager.ui.IValidateFragment
+import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers.Main
-import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import org.locationtech.jts.geom.Point
import org.osmdroid.util.GeoPoint
@@ -27,7 +27,7 @@ import org.osmdroid.views.MapView
/**
* Simple [Fragment] embedding a [MapView] instance to edit a single POI on the map.
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
class InputMapFragment : MapFragment(),
IValidateFragment,
@@ -95,7 +95,7 @@ class InputMapFragment : MapFragment(),
(activity as AbstractPagerFragmentActivity?)?.validateCurrentPage()
- GlobalScope.launch(Main) {
+ CoroutineScope(Main).launch {
getOverlays { overlay -> overlay is FeatureCollectionOverlay }
.asSequence()
.map { it as FeatureCollectionOverlay }
@@ -104,7 +104,7 @@ class InputMapFragment : MapFragment(),
}
private fun selectPOI(poi: GeoPoint) {
- GlobalScope.launch(Main) {
+ CoroutineScope(Main).launch {
val context = context ?: return@launch
input?.geometry = toPoint(poi)
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/input/observers/ObserversAndDateInputFragment.kt b/occtax/src/main/java/fr/geonature/occtax/ui/input/observers/ObserversAndDateInputFragment.kt
index 064b2df3..0f4b54c6 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/input/observers/ObserversAndDateInputFragment.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/input/observers/ObserversAndDateInputFragment.kt
@@ -19,11 +19,11 @@ import androidx.fragment.app.Fragment
import androidx.loader.app.LoaderManager
import androidx.loader.content.CursorLoader
import androidx.loader.content.Loader
-import fr.geonature.commons.data.Dataset
-import fr.geonature.commons.data.DefaultNomenclature
-import fr.geonature.commons.data.DefaultNomenclatureWithType
-import fr.geonature.commons.data.InputObserver
-import fr.geonature.commons.data.NomenclatureType
+import fr.geonature.commons.data.entity.Dataset
+import fr.geonature.commons.data.entity.DefaultNomenclature
+import fr.geonature.commons.data.entity.DefaultNomenclatureWithType
+import fr.geonature.commons.data.entity.InputObserver
+import fr.geonature.commons.data.entity.NomenclatureType
import fr.geonature.commons.data.helper.Provider.buildUri
import fr.geonature.commons.input.AbstractInput
import fr.geonature.occtax.R
@@ -47,7 +47,7 @@ import java.util.Locale
/**
* Selected observer and current date as first {@code Fragment} used by [InputPagerFragmentActivity].
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
class ObserversAndDateInputFragment : Fragment(),
IValidateFragment,
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/input/summary/InputTaxaSummaryRecyclerViewAdapter.kt b/occtax/src/main/java/fr/geonature/occtax/ui/input/summary/InputTaxaSummaryRecyclerViewAdapter.kt
index a07d84fe..b89db9f5 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/input/summary/InputTaxaSummaryRecyclerViewAdapter.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/input/summary/InputTaxaSummaryRecyclerViewAdapter.kt
@@ -7,7 +7,7 @@ import android.widget.TextView
import androidx.core.text.HtmlCompat
import com.google.android.material.chip.Chip
import com.google.android.material.chip.ChipGroup
-import fr.geonature.commons.data.Taxonomy
+import fr.geonature.commons.data.entity.Taxonomy
import fr.geonature.commons.input.AbstractInputTaxon
import fr.geonature.commons.ui.adapter.AbstractListItemRecyclerViewAdapter
import fr.geonature.occtax.R
@@ -18,7 +18,7 @@ import java.util.Locale
/**
* Default RecyclerView Adapter used by [InputTaxaSummaryFragment].
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
class InputTaxaSummaryRecyclerViewAdapter(listener: OnListItemRecyclerViewAdapterListener) :
AbstractListItemRecyclerViewAdapter(listener) {
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/input/taxa/FilterRecyclerViewAdapter.kt b/occtax/src/main/java/fr/geonature/occtax/ui/input/taxa/FilterRecyclerViewAdapter.kt
index d5b63ada..c159e8b5 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/input/taxa/FilterRecyclerViewAdapter.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/input/taxa/FilterRecyclerViewAdapter.kt
@@ -7,7 +7,7 @@ import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.ConcatAdapter
import androidx.recyclerview.widget.RecyclerView
-import fr.geonature.commons.data.Taxonomy
+import fr.geonature.commons.data.entity.Taxonomy
import fr.geonature.commons.ui.adapter.IStickyRecyclerViewAdapter
import fr.geonature.commons.ui.adapter.StickyHeaderItemDecorator
import fr.geonature.occtax.R
@@ -16,7 +16,7 @@ import fr.geonature.occtax.R
* Default RecyclerView Adapter used by [TaxaFilterFragment], combining
* [FilterAreaObservationRecyclerViewAdapter] and [FilterTaxonomyRecyclerViewAdapter].
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*
* @see FilterAreaObservationRecyclerViewAdapter
* @see FilterTaxonomyRecyclerViewAdapter
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/input/taxa/FilterTaxonomy.kt b/occtax/src/main/java/fr/geonature/occtax/ui/input/taxa/FilterTaxonomy.kt
index cdcac7bc..f0942054 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/input/taxa/FilterTaxonomy.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/input/taxa/FilterTaxonomy.kt
@@ -1,11 +1,11 @@
package fr.geonature.occtax.ui.input.taxa
-import fr.geonature.commons.data.Taxonomy
+import fr.geonature.commons.data.entity.Taxonomy
/**
* [Taxonomy] filter.
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
class FilterTaxonomy(value: Taxonomy) : Filter(
FilterType.TAXONOMY,
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/input/taxa/FilterTaxonomyRecyclerViewAdapter.kt b/occtax/src/main/java/fr/geonature/occtax/ui/input/taxa/FilterTaxonomyRecyclerViewAdapter.kt
index 35cec7fa..048fc4a7 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/input/taxa/FilterTaxonomyRecyclerViewAdapter.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/input/taxa/FilterTaxonomyRecyclerViewAdapter.kt
@@ -3,14 +3,14 @@ package fr.geonature.occtax.ui.input.taxa
import android.view.View
import android.widget.CheckBox
import android.widget.TextView
-import fr.geonature.commons.data.Taxonomy
+import fr.geonature.commons.data.entity.Taxonomy
import fr.geonature.commons.ui.adapter.AbstractListItemRecyclerViewAdapter
import fr.geonature.occtax.R
/**
* Default RecyclerView Adapter for [FilterTaxonomy].
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
class FilterTaxonomyRecyclerViewAdapter(val listener: FilterRecyclerViewAdapterListener) :
AbstractListItemRecyclerViewAdapter() {
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/input/taxa/TaxaFilterFragment.kt b/occtax/src/main/java/fr/geonature/occtax/ui/input/taxa/TaxaFilterFragment.kt
index 74b4adc7..e5573154 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/input/taxa/TaxaFilterFragment.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/input/taxa/TaxaFilterFragment.kt
@@ -15,7 +15,7 @@ import androidx.loader.content.Loader
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
-import fr.geonature.commons.data.Taxonomy
+import fr.geonature.commons.data.entity.Taxonomy
import fr.geonature.commons.data.helper.Provider
import fr.geonature.occtax.R
import fr.geonature.occtax.settings.AppSettings
@@ -23,7 +23,7 @@ import fr.geonature.occtax.settings.AppSettings
/**
* [Fragment] to let the user to apply filters on taxa list.
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
class TaxaFilterFragment : Fragment() {
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/input/taxa/TaxaFragment.kt b/occtax/src/main/java/fr/geonature/occtax/ui/input/taxa/TaxaFragment.kt
index 2d75e6b7..da2790cc 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/input/taxa/TaxaFragment.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/input/taxa/TaxaFragment.kt
@@ -27,10 +27,10 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.chip.Chip
import com.google.android.material.chip.ChipGroup
-import fr.geonature.commons.data.AbstractTaxon
-import fr.geonature.commons.data.Taxon
-import fr.geonature.commons.data.TaxonWithArea
-import fr.geonature.commons.data.Taxonomy
+import fr.geonature.commons.data.entity.AbstractTaxon
+import fr.geonature.commons.data.entity.Taxon
+import fr.geonature.commons.data.entity.TaxonWithArea
+import fr.geonature.commons.data.entity.Taxonomy
import fr.geonature.commons.data.helper.Provider.buildUri
import fr.geonature.commons.input.AbstractInput
import fr.geonature.commons.util.ThemeUtils
@@ -46,7 +46,7 @@ import java.util.Locale
/**
* [Fragment] to let the user to choose a [Taxon] from the list.
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
class TaxaFragment : Fragment(),
IValidateFragment,
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/input/taxa/TaxaRecyclerViewAdapter.kt b/occtax/src/main/java/fr/geonature/occtax/ui/input/taxa/TaxaRecyclerViewAdapter.kt
index df2f6a43..b8445e07 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/input/taxa/TaxaRecyclerViewAdapter.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/input/taxa/TaxaRecyclerViewAdapter.kt
@@ -11,9 +11,9 @@ import android.widget.TextView
import androidx.core.text.HtmlCompat
import androidx.recyclerview.widget.RecyclerView
import com.l4digital.fastscroll.FastScroller
-import fr.geonature.commons.data.AbstractTaxon
-import fr.geonature.commons.data.Taxon
-import fr.geonature.commons.data.TaxonWithArea
+import fr.geonature.commons.data.entity.AbstractTaxon
+import fr.geonature.commons.data.entity.Taxon
+import fr.geonature.commons.data.entity.TaxonWithArea
import fr.geonature.occtax.R
import java.text.NumberFormat
@@ -22,7 +22,7 @@ import java.text.NumberFormat
*
* @see TaxaFragment
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
class TaxaRecyclerViewAdapter(private val listener: OnTaxaRecyclerViewAdapterListener) :
RecyclerView.Adapter(),
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/observers/InputObserverListActivity.kt b/occtax/src/main/java/fr/geonature/occtax/ui/observers/InputObserverListActivity.kt
index f91c0d6a..6ca8d243 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/observers/InputObserverListActivity.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/observers/InputObserverListActivity.kt
@@ -6,7 +6,7 @@ import android.content.Intent
import android.os.Bundle
import android.widget.ListView
import androidx.appcompat.app.AppCompatActivity
-import fr.geonature.commons.data.InputObserver
+import fr.geonature.commons.data.entity.InputObserver
import fr.geonature.occtax.R
/**
@@ -14,7 +14,7 @@ import fr.geonature.occtax.R
*
* @see InputObserverListFragment
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
class InputObserverListActivity : AppCompatActivity(),
InputObserverListFragment.OnInputObserverListFragmentListener {
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/observers/InputObserverListFragment.kt b/occtax/src/main/java/fr/geonature/occtax/ui/observers/InputObserverListFragment.kt
index b8e8db1c..d93b9ca3 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/observers/InputObserverListFragment.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/observers/InputObserverListFragment.kt
@@ -21,7 +21,7 @@ import androidx.loader.content.Loader
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
-import fr.geonature.commons.data.InputObserver
+import fr.geonature.commons.data.entity.InputObserver
import fr.geonature.commons.data.helper.Provider.buildUri
import fr.geonature.occtax.R
import fr.geonature.occtax.R.layout.fast_scroll_recycler_view
@@ -29,7 +29,7 @@ import fr.geonature.occtax.R.layout.fast_scroll_recycler_view
/**
* [Fragment] to let the user to choose an [InputObserver] from the list.
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
class InputObserverListFragment : Fragment() {
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/observers/InputObserverRecyclerViewAdapter.kt b/occtax/src/main/java/fr/geonature/occtax/ui/observers/InputObserverRecyclerViewAdapter.kt
index 8dc66503..d29e36ac 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/observers/InputObserverRecyclerViewAdapter.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/observers/InputObserverRecyclerViewAdapter.kt
@@ -9,7 +9,7 @@ import android.widget.ListView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.l4digital.fastscroll.FastScroller
-import fr.geonature.commons.data.InputObserver
+import fr.geonature.commons.data.entity.InputObserver
import java.util.Locale
/**
@@ -17,7 +17,7 @@ import java.util.Locale
*
* @see InputObserverListFragment
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
class InputObserverRecyclerViewAdapter(private val listener: OnInputObserverRecyclerViewAdapterListener) :
RecyclerView.Adapter(),
diff --git a/occtax/src/main/java/fr/geonature/occtax/ui/settings/PreferencesFragment.kt b/occtax/src/main/java/fr/geonature/occtax/ui/settings/PreferencesFragment.kt
index c1645f3b..1b76dc3f 100644
--- a/occtax/src/main/java/fr/geonature/occtax/ui/settings/PreferencesFragment.kt
+++ b/occtax/src/main/java/fr/geonature/occtax/ui/settings/PreferencesFragment.kt
@@ -4,7 +4,9 @@ import android.app.Activity
import android.content.Context
import android.content.Intent
import android.database.Cursor
+import android.net.Uri
import android.os.Bundle
+import android.provider.Settings
import android.widget.ListView
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
@@ -14,8 +16,8 @@ import androidx.loader.content.Loader
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.PreferenceManager
-import fr.geonature.commons.data.Dataset
-import fr.geonature.commons.data.InputObserver
+import fr.geonature.commons.data.entity.Dataset
+import fr.geonature.commons.data.entity.InputObserver
import fr.geonature.commons.data.helper.Provider.buildUri
import fr.geonature.maps.settings.MapSettings
import fr.geonature.maps.util.MapSettingsPreferencesUtils
@@ -30,7 +32,7 @@ import java.util.Locale
/**
* Global settings.
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
class PreferencesFragment : PreferenceFragmentCompat() {
@@ -130,6 +132,7 @@ class PreferencesFragment : PreferenceFragmentCompat() {
setDefaultPreferences(arguments?.getParcelable(ARG_APP_SETTINGS))
loadDefaultDataset()
loadDefaultObserver()
+ configurePermissions()
(preferenceScreen.findPreference(getString(R.string.preference_category_about_app_version_key)) as Preference?)?.also {
it.summary = listener?.getAppVersion()
@@ -143,6 +146,7 @@ class PreferencesFragment : PreferenceFragmentCompat() {
addPreferencesFromResource(R.xml.preferences_dataset)
addPreferencesFromResource(R.xml.preferences_observers)
addPreferencesFromResource(R.xml.map_preferences)
+ addPreferencesFromResource(R.xml.preferences_permissions)
addPreferencesFromResource(R.xml.preferences_about)
}
@@ -246,7 +250,7 @@ class PreferencesFragment : PreferenceFragmentCompat() {
true
}
- val editor = PreferenceManager.getDefaultSharedPreferences(context)
+ val editor = PreferenceManager.getDefaultSharedPreferences(defaultDatasetPreference.context)
.edit()
if (defaultDataset == null) {
@@ -284,7 +288,7 @@ class PreferencesFragment : PreferenceFragmentCompat() {
true
}
- val editor = PreferenceManager.getDefaultSharedPreferences(context)
+ val editor = PreferenceManager.getDefaultSharedPreferences(defaultObserverPreference.context)
.edit()
if (defaultObserver == null) {
@@ -304,6 +308,27 @@ class PreferencesFragment : PreferenceFragmentCompat() {
editor.apply()
}
+ private fun configurePermissions() {
+ preferenceScreen
+ .findPreference(getString(R.string.preference_category_permissions_configure_key))
+ ?.apply {
+ onPreferenceClickListener = Preference.OnPreferenceClickListener {
+ startActivity(
+ Intent(
+ Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
+ Uri.fromParts(
+ "package",
+ it.context.packageName,
+ null
+ )
+ )
+ )
+
+ true
+ }
+ }
+ }
+
/**
* Callback used by [PreferencesFragment].
*/
diff --git a/occtax/src/main/res/values-fr/prefs.xml b/occtax/src/main/res/values-fr/prefs.xml
index ddd0df8b..dc5f59bf 100644
--- a/occtax/src/main/res/values-fr/prefs.xml
+++ b/occtax/src/main/res/values-fr/prefs.xml
@@ -7,6 +7,8 @@
Observateurs
Observateur par défaut
Non défini
+ Permissions
+ Gérer les permissions
A propos
Version de l\'application
diff --git a/occtax/src/main/res/values/prefs.xml b/occtax/src/main/res/values/prefs.xml
index 9353156f..1af99f32 100644
--- a/occtax/src/main/res/values/prefs.xml
+++ b/occtax/src/main/res/values/prefs.xml
@@ -9,6 +9,9 @@
observer_default
Default observer
Not defined
+ Permissions
+ Manage permissions
+ permissions
About
app_version
App version
diff --git a/occtax/src/main/res/xml/preferences_permissions.xml b/occtax/src/main/res/xml/preferences_permissions.xml
new file mode 100644
index 00000000..4fcdc452
--- /dev/null
+++ b/occtax/src/main/res/xml/preferences_permissions.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/occtax/src/test/java/fr/geonature/occtax/input/CountingMetadataTest.kt b/occtax/src/test/java/fr/geonature/occtax/input/CountingMetadataTest.kt
index 8a3ca3b2..7cf88c21 100644
--- a/occtax/src/test/java/fr/geonature/occtax/input/CountingMetadataTest.kt
+++ b/occtax/src/test/java/fr/geonature/occtax/input/CountingMetadataTest.kt
@@ -1,7 +1,7 @@
package fr.geonature.occtax.input
import android.os.Parcel
-import fr.geonature.commons.data.Nomenclature
+import fr.geonature.commons.data.entity.Nomenclature
import fr.geonature.occtax.input.PropertyValue.Companion.fromNomenclature
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
@@ -13,7 +13,7 @@ import org.robolectric.RobolectricTestRunner
/**
* Unit tests about [CountingMetadata].
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
@RunWith(RobolectricTestRunner::class)
class CountingMetadataTest {
diff --git a/occtax/src/test/java/fr/geonature/occtax/input/InputTaxonTest.kt b/occtax/src/test/java/fr/geonature/occtax/input/InputTaxonTest.kt
index 0afc2736..575e7884 100644
--- a/occtax/src/test/java/fr/geonature/occtax/input/InputTaxonTest.kt
+++ b/occtax/src/test/java/fr/geonature/occtax/input/InputTaxonTest.kt
@@ -1,9 +1,9 @@
package fr.geonature.occtax.input
import android.os.Parcel
-import fr.geonature.commons.data.Nomenclature
-import fr.geonature.commons.data.Taxon
-import fr.geonature.commons.data.Taxonomy
+import fr.geonature.commons.data.entity.Nomenclature
+import fr.geonature.commons.data.entity.Taxon
+import fr.geonature.commons.data.entity.Taxonomy
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
@@ -16,7 +16,7 @@ import org.robolectric.RobolectricTestRunner
/**
* Unit tests about [InputTaxon].
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
@RunWith(RobolectricTestRunner::class)
class InputTaxonTest {
diff --git a/occtax/src/test/java/fr/geonature/occtax/input/InputTest.kt b/occtax/src/test/java/fr/geonature/occtax/input/InputTest.kt
index 8303a9f4..15cbe70c 100644
--- a/occtax/src/test/java/fr/geonature/occtax/input/InputTest.kt
+++ b/occtax/src/test/java/fr/geonature/occtax/input/InputTest.kt
@@ -1,19 +1,19 @@
package fr.geonature.occtax.input
import android.os.Parcel
-import fr.geonature.commons.data.Taxon
-import fr.geonature.commons.data.Taxonomy
+import fr.geonature.commons.data.entity.Taxon
+import fr.geonature.commons.data.entity.Taxonomy
import fr.geonature.commons.util.toDate
-import java.util.Date
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
+import java.util.Date
/**
* Unit tests about [Input].
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
@RunWith(RobolectricTestRunner::class)
class InputTest {
diff --git a/occtax/src/test/java/fr/geonature/occtax/input/PropertyValueTest.kt b/occtax/src/test/java/fr/geonature/occtax/input/PropertyValueTest.kt
index 2ed89d4f..313f7afb 100644
--- a/occtax/src/test/java/fr/geonature/occtax/input/PropertyValueTest.kt
+++ b/occtax/src/test/java/fr/geonature/occtax/input/PropertyValueTest.kt
@@ -1,7 +1,7 @@
package fr.geonature.occtax.input
import android.os.Parcel
-import fr.geonature.commons.data.Nomenclature
+import fr.geonature.commons.data.entity.Nomenclature
import fr.geonature.occtax.input.PropertyValue.Companion.fromNomenclature
import fr.geonature.occtax.input.PropertyValue.Companion.fromValue
import org.junit.Assert.assertEquals
@@ -14,7 +14,7 @@ import org.robolectric.RobolectricTestRunner
/**
* Unit tests about [PropertyValue].
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
@RunWith(RobolectricTestRunner::class)
class PropertyValueTest {
diff --git a/occtax/src/test/java/fr/geonature/occtax/input/io/InputJsonReaderTest.kt b/occtax/src/test/java/fr/geonature/occtax/input/io/InputJsonReaderTest.kt
index 7c4cd8c3..d283a198 100644
--- a/occtax/src/test/java/fr/geonature/occtax/input/io/InputJsonReaderTest.kt
+++ b/occtax/src/test/java/fr/geonature/occtax/input/io/InputJsonReaderTest.kt
@@ -1,7 +1,7 @@
package fr.geonature.occtax.input.io
-import fr.geonature.commons.data.Taxon
-import fr.geonature.commons.data.Taxonomy
+import fr.geonature.commons.data.entity.Taxon
+import fr.geonature.commons.data.entity.Taxonomy
import fr.geonature.commons.input.AbstractInputTaxon
import fr.geonature.commons.input.io.InputJsonReader
import fr.geonature.commons.util.toDate
@@ -22,7 +22,7 @@ import org.robolectric.RobolectricTestRunner
/**
* Unit tests about [InputJsonReader].
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
@RunWith(RobolectricTestRunner::class)
class InputJsonReaderTest {
diff --git a/occtax/src/test/java/fr/geonature/occtax/input/io/InputJsonWriterTest.kt b/occtax/src/test/java/fr/geonature/occtax/input/io/InputJsonWriterTest.kt
index b7076175..997b0eb6 100644
--- a/occtax/src/test/java/fr/geonature/occtax/input/io/InputJsonWriterTest.kt
+++ b/occtax/src/test/java/fr/geonature/occtax/input/io/InputJsonWriterTest.kt
@@ -1,7 +1,7 @@
package fr.geonature.occtax.input.io
-import fr.geonature.commons.data.Taxon
-import fr.geonature.commons.data.Taxonomy
+import fr.geonature.commons.data.entity.Taxon
+import fr.geonature.commons.data.entity.Taxonomy
import fr.geonature.commons.input.io.InputJsonWriter
import fr.geonature.commons.util.toDate
import fr.geonature.occtax.FixtureHelper.getFixture
@@ -20,7 +20,7 @@ import java.util.Date
/**
* Unit tests about [InputJsonWriter].
*
- * @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
+ * @author S. Grimault
*/
@RunWith(RobolectricTestRunner::class)
class InputJsonWriterTest {
diff --git a/occtax/version.properties b/occtax/version.properties
index 2afc35c6..1d73cfda 100644
--- a/occtax/version.properties
+++ b/occtax/version.properties
@@ -1,2 +1,2 @@
-#Thu Jul 29 10:40:46 CEST 2021
-VERSION_CODE=2290
+#Tue Feb 08 21:58:37 CET 2022
+VERSION_CODE=2350