Skip to content

Commit

Permalink
Merge branch 'release/0.2.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrimault committed Jan 22, 2020
2 parents d01bb58 + 60e8ffa commit 86656b2
Show file tree
Hide file tree
Showing 75 changed files with 329 additions and 87 deletions.
5 changes: 0 additions & 5 deletions .idea/codeStyles/Project.xml

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

11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Occtax-mobile

![Occtax-mobile launcher](https://raw.githubusercontent.com/PnX-SI/gn_mobile_occtax/develop/occtax/src/main/res/mipmap-xxxhdpi/ic_launcher.png)
![PNV](https://raw.githubusercontent.com/PnX-SI/gn_mobile_occtax/develop/occtax/src/pnv/res/mipmap-xxxhdpi/ic_launcher.png)
![PNE](https://raw.githubusercontent.com/PnX-SI/gn_mobile_occtax/develop/occtax/src/pne/res/mipmap-xxxhdpi/ic_launcher.png)

GeoNature Android mobile application for Occtax module.

Expand All @@ -22,3 +23,11 @@ Any changes should be made from each underlying git repository:
* Kotlin error, Redeclaration from class within imported module:

clean project from menu *Build -> Clean Project*, then rebuild project.

## Full Build

A full build can be executed with the following command:

```
./gradlew clean assembleDebug
```
2 changes: 1 addition & 1 deletion gn_mobile_core
Submodule gn_mobile_core updated 77 files
+16 −0 .idea/codeStyles/Project.xml
+1 −1 commons/build.gradle
+26 −3 commons/src/main/java/fr/geonature/commons/data/Dataset.kt
+15 −6 commons/src/test/java/fr/geonature/commons/data/DatasetTest.kt
+13 −4 sync/README.md
+9 −1 sync/build.gradle
+6 −4 sync/src/debug/res/drawable/ic_launcher_background.xml
+ sync/src/debug/res/mipmap-hdpi/ic_launcher.png
+ sync/src/debug/res/mipmap-hdpi/ic_launcher_round.png
+ sync/src/debug/res/mipmap-mdpi/ic_launcher.png
+ sync/src/debug/res/mipmap-mdpi/ic_launcher_round.png
+ sync/src/debug/res/mipmap-xhdpi/ic_launcher.png
+ sync/src/debug/res/mipmap-xhdpi/ic_launcher_round.png
+ sync/src/debug/res/mipmap-xxhdpi/ic_launcher.png
+ sync/src/debug/res/mipmap-xxhdpi/ic_launcher_round.png
+ sync/src/debug/res/mipmap-xxxhdpi/ic_launcher.png
+ sync/src/debug/res/mipmap-xxxhdpi/ic_launcher_round.png
+12 −2 sync/src/main/java/fr/geonature/sync/data/LocalDatabase.kt
+30 −8 sync/src/main/java/fr/geonature/sync/data/MainContentProvider.kt
+16 −0 sync/src/main/java/fr/geonature/sync/data/dao/DatasetDao.kt
+26 −5 sync/src/main/java/fr/geonature/sync/data/dao/NomenclatureDao.kt
+53 −13 sync/src/main/java/fr/geonature/sync/sync/io/DatasetJsonReader.kt
+3 −2 sync/src/main/res/drawable/ic_launcher_background.xml
+2 −1 sync/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
+2 −1 sync/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
+1 −0 sync/src/main/res/values/colors.xml
+ sync/src/pne/res/mipmap-hdpi/ic_launcher.png
+ sync/src/pne/res/mipmap-hdpi/ic_launcher_round.png
+ sync/src/pne/res/mipmap-mdpi/ic_launcher.png
+ sync/src/pne/res/mipmap-mdpi/ic_launcher_round.png
+ sync/src/pne/res/mipmap-xhdpi/ic_launcher.png
+ sync/src/pne/res/mipmap-xhdpi/ic_launcher_round.png
+ sync/src/pne/res/mipmap-xxhdpi/ic_launcher.png
+ sync/src/pne/res/mipmap-xxhdpi/ic_launcher_round.png
+ sync/src/pne/res/mipmap-xxxhdpi/ic_launcher.png
+ sync/src/pne/res/mipmap-xxxhdpi/ic_launcher_round.png
+8 −0 sync/src/pne/res/values/colors.xml
+ sync/src/pneDebug/res/mipmap-hdpi/ic_launcher.png
+ sync/src/pneDebug/res/mipmap-hdpi/ic_launcher_round.png
+ sync/src/pneDebug/res/mipmap-mdpi/ic_launcher.png
+ sync/src/pneDebug/res/mipmap-mdpi/ic_launcher_round.png
+ sync/src/pneDebug/res/mipmap-xhdpi/ic_launcher.png
+ sync/src/pneDebug/res/mipmap-xhdpi/ic_launcher_round.png
+ sync/src/pneDebug/res/mipmap-xxhdpi/ic_launcher.png
+ sync/src/pneDebug/res/mipmap-xxhdpi/ic_launcher_round.png
+ sync/src/pneDebug/res/mipmap-xxxhdpi/ic_launcher.png
+ sync/src/pneDebug/res/mipmap-xxxhdpi/ic_launcher_round.png
+ sync/src/pnv/res/mipmap-hdpi/ic_launcher.png
+ sync/src/pnv/res/mipmap-hdpi/ic_launcher_round.png
+ sync/src/pnv/res/mipmap-mdpi/ic_launcher.png
+ sync/src/pnv/res/mipmap-mdpi/ic_launcher_round.png
+ sync/src/pnv/res/mipmap-xhdpi/ic_launcher.png
+ sync/src/pnv/res/mipmap-xhdpi/ic_launcher_round.png
+ sync/src/pnv/res/mipmap-xxhdpi/ic_launcher.png
+ sync/src/pnv/res/mipmap-xxhdpi/ic_launcher_round.png
+ sync/src/pnv/res/mipmap-xxxhdpi/ic_launcher.png
+ sync/src/pnv/res/mipmap-xxxhdpi/ic_launcher_round.png
+8 −0 sync/src/pnv/res/values/colors.xml
+ sync/src/pnvDebug/res/mipmap-hdpi/ic_launcher.png
+ sync/src/pnvDebug/res/mipmap-hdpi/ic_launcher_round.png
+ sync/src/pnvDebug/res/mipmap-mdpi/ic_launcher.png
+ sync/src/pnvDebug/res/mipmap-mdpi/ic_launcher_round.png
+ sync/src/pnvDebug/res/mipmap-xhdpi/ic_launcher.png
+ sync/src/pnvDebug/res/mipmap-xhdpi/ic_launcher_round.png
+ sync/src/pnvDebug/res/mipmap-xxhdpi/ic_launcher.png
+ sync/src/pnvDebug/res/mipmap-xxhdpi/ic_launcher_round.png
+ sync/src/pnvDebug/res/mipmap-xxxhdpi/ic_launcher.png
+ sync/src/pnvDebug/res/mipmap-xxxhdpi/ic_launcher_round.png
+10 −0 sync/src/test/java/fr/geonature/sync/sync/io/DatasetJsonReaderTest.kt
+51 −2 sync/src/test/resources/fixtures/metadataset_geonature.json
+2 −2 sync/version.properties
+1 −1 viewpager/build.gradle
+1 −0 viewpager/src/main/java/fr/geonature/viewpager/ui/AbstractNavigationHistoryPagerFragmentActivity.kt
+3 −1 viewpager/src/main/java/fr/geonature/viewpager/ui/AbstractPagerFragmentActivity.kt
+7 −0 viewpager/src/main/java/fr/geonature/viewpager/ui/IValidateFragment.kt
+10 −0 viewpager/src/main/java/fr/geonature/viewpager/ui/SimpleFragmentPagerAdapter.kt
+9 −2 viewpager/src/main/res/layout/activity_pager.xml
10 changes: 9 additions & 1 deletion 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.2.6"
version = "0.2.7"

android {
compileSdkVersion 28
Expand Down Expand Up @@ -36,6 +36,14 @@ android {
}
}

flavorDimensions "version"
productFlavors {
pne {
}
pnv {
}
}

testOptions {
unitTests {
includeAndroidResources = true
Expand Down
10 changes: 6 additions & 4 deletions occtax/src/debug/res/drawable/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="161.19403"
Expand All @@ -7,14 +8,15 @@
android:translateX="26.597015"
android:translateY="26.597015">
<path
android:fillColor="#008577"
android:fillColor="@color/primary"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillAlpha="0.20"
android:fillColor="#000000"
android:pathData="M55,26V1h53v25z" />
android:pathData="M55,26V25h53v1z" />
<path
android:fillColor="#545473"
android:fillAlpha="0.4"
android:fillColor="@color/accent"
android:pathData="M54,25V0h54v25z" />
<path
android:fillColor="#ffffff"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.view.ActionMode
import androidx.core.os.bundleOf
import androidx.fragment.app.Fragment
import androidx.loader.app.LoaderManager
import androidx.loader.content.CursorLoader
Expand Down Expand Up @@ -43,6 +44,7 @@ class DatasetListFragment : Fragment() {
requireContext(),
buildUri(
Dataset.TABLE_NAME,
args?.getString(Dataset.COLUMN_MODULE) ?: "",
"active"
),
null,
Expand Down Expand Up @@ -142,7 +144,12 @@ class DatasetListFragment : Fragment() {
LoaderManager.getInstance(this)
.initLoader(
LOADER_DATASET,
null,
bundleOf(
Pair(
Dataset.COLUMN_MODULE,
context?.packageName
)
),
loaderCallbacks
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class InputRecyclerViewAdapter(listener: OnListItemRecyclerViewAdapterListener<I
inner class ViewHolder(itemView: View) :
AbstractListItemRecyclerViewAdapter<Input>.AbstractViewHolder(itemView) {
private val text1: TextView = itemView.findViewById(android.R.id.text1)
private val text2: TextView = itemView.findViewById(android.R.id.text2)

override fun onBind(item: Input) {
text1.text = itemView.context.getString(
Expand All @@ -58,6 +59,14 @@ class InputRecyclerViewAdapter(listener: OnListItemRecyclerViewAdapterListener<I
item.date
)
)

if (item.getInputTaxa().isNotEmpty()) {
text2.text = itemView.resources.getQuantityString(
R.plurals.home_input_taxa_count,
item.getInputTaxa().size,
item.getInputTaxa().size
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ class CountingFragment : Fragment(),
return R.string.pager_fragment_counting_title
}

override fun getSubtitle(): CharSequence? {
return input?.getCurrentSelectedInputTaxon()?.taxon?.name
}

override fun pagingEnabled(): Boolean {
return true
}
Expand All @@ -205,6 +209,21 @@ class CountingFragment : Fragment(),
(input?.getCurrentSelectedInputTaxon() as InputTaxon?)?.getCounting()
?: emptyList()
)

if ((input?.getCurrentSelectedInputTaxon() as InputTaxon?)?.getCounting()?.isEmpty() == true) {
val context = context ?: return
startActivityForResult(
EditCountingMetadataActivity.newIntent(
context,
input?.getCurrentSelectedInputTaxon()?.taxon?.taxonomy
?: Taxonomy(
Taxonomy.ANY,
Taxonomy.ANY
)
),
0
)
}
}

override fun setInput(input: AbstractInput) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CountingRecyclerViewAdapter(listener: OnListItemRecyclerViewAdapterListene
position: Int,
item: CountingMetadata
): Int {
return R.layout.list_item_2
return R.layout.list_item_3
}

override fun areItemsTheSame(
Expand All @@ -49,43 +49,50 @@ class CountingRecyclerViewAdapter(listener: OnListItemRecyclerViewAdapterListene

inner class ViewHolder(itemView: View) :
AbstractListItemRecyclerViewAdapter<CountingMetadata>.AbstractViewHolder(itemView) {
private val title: TextView = itemView.findViewById(android.R.id.title)
private val text1: TextView = itemView.findViewById(android.R.id.text1)
private val text2: TextView = itemView.findViewById(android.R.id.text2)

override fun onBind(item: CountingMetadata) {
text1.text = itemView.context.getString(
title.text = itemView.context.getString(
R.string.counting_main_label,
item.index
)
text1.text = buildCountingDescription(item)
text2.text = buildDescription(item)
}

private fun buildDescription(countingMetadata: CountingMetadata): String {
return (countingMetadata.properties.values.asSequence()
.filterNot { it.isEmpty() }
.map {
itemView.context.getString(
R.string.counting_description_separator,
getNomenclatureTypeLabel(it.code),
it.label
)
} + arrayOf(
private fun buildCountingDescription(countingMetadata: CountingMetadata): String {
return arrayOf(
Pair(
R.string.counting_min_label,
countingMetadata.min
itemView.context.getString(R.string.counting_min_label),
countingMetadata.min.toString()
),
Pair(
R.string.counting_max_label,
countingMetadata.max
itemView.context.getString(R.string.counting_max_label),
countingMetadata.max.toString()
)
).asSequence()
.map {
itemView.context.getString(
R.string.counting_description_separator,
itemView.context.getString(it.first),
it.second.toString()
it.first,
it.second
)
}
.joinToString(", ")
}

private fun buildDescription(countingMetadata: CountingMetadata): String {
return countingMetadata.properties.values.asSequence()
.filterNot { it.isEmpty() }
.map {
itemView.context.getString(
R.string.counting_description_separator,
getNomenclatureTypeLabel(it.code),
it.label
)
})
}
.joinToString(", ")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.os.Bundle
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import fr.geonature.commons.data.Taxonomy
import fr.geonature.occtax.R
import fr.geonature.occtax.input.CountingMetadata

/**
Expand All @@ -28,6 +29,8 @@ class EditCountingMetadataActivity : AppCompatActivity(),

countingMetadata = intent.getParcelableExtra(EXTRA_COUNTING_METADATA) ?: CountingMetadata()

setTitle(if (countingMetadata.isEmpty()) R.string.activity_counting_add_title else R.string.activity_counting_edit_title)

if (savedInstanceState == null) {
supportFragmentManager.beginTransaction()
.replace(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.os.bundleOf
import androidx.fragment.app.Fragment
import androidx.loader.app.LoaderManager
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
Expand Down Expand Up @@ -56,7 +59,7 @@ class EditCountingMetadataFragment : Fragment(),
requireContext(),
buildUri(
NomenclatureType.TABLE_NAME,
"occtax",
args?.getString(Dataset.COLUMN_MODULE) ?: "",
"default"
),
null,
Expand Down Expand Up @@ -231,7 +234,12 @@ class EditCountingMetadataFragment : Fragment(),
LoaderManager.getInstance(this)
.initLoader(
LOADER_DEFAULT_NOMENCLATURE_VALUES,
null,
bundleOf(
Pair(
DefaultNomenclature.COLUMN_MODULE,
context?.packageName
)
),
loaderCallbacks
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class InformationFragment : Fragment(),

private var input: Input? = null
private var adapter: NomenclatureTypesRecyclerViewAdapter? = null
private lateinit var savedState: Bundle

private val loaderCallbacks = object : LoaderManager.LoaderCallbacks<Cursor> {
override fun onCreateLoader(
Expand Down Expand Up @@ -117,6 +118,12 @@ class InformationFragment : Fragment(),
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

savedState = savedInstanceState ?: Bundle()
}

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
Expand All @@ -131,6 +138,7 @@ class InformationFragment : Fragment(),
adapter = NomenclatureTypesRecyclerViewAdapter(object :
NomenclatureTypesRecyclerViewAdapter.OnNomenclatureTypesRecyclerViewAdapterListener {
override fun showMore() {
savedState.putBoolean(KEY_SHOW_ALL_NOMENCLATURE_TYPES, true)
setPropertyValues()
}

Expand Down Expand Up @@ -165,6 +173,12 @@ class InformationFragment : Fragment(),
)
}
})
adapter?.showAllNomenclatureTypes(
savedState.getBoolean(
KEY_SHOW_ALL_NOMENCLATURE_TYPES,
false
)
)

with(recyclerView as RecyclerView) {
layoutManager = LinearLayoutManager(context)
Expand All @@ -174,10 +188,18 @@ class InformationFragment : Fragment(),
return recyclerView
}

override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(savedState.apply { putAll(outState) })
}

override fun getResourceTitle(): Int {
return R.string.pager_fragment_information_title
}

override fun getSubtitle(): CharSequence? {
return input?.getCurrentSelectedInputTaxon()?.taxon?.name
}

override fun pagingEnabled(): Boolean {
return true
}
Expand Down Expand Up @@ -257,6 +279,8 @@ class InformationFragment : Fragment(),
private const val CHOOSE_NOMENCLATURE_DIALOG_FRAGMENT =
"choose_nomenclature_dialog_fragment"

private const val KEY_SHOW_ALL_NOMENCLATURE_TYPES = "show_all_nomenclature_types"

/**
* Use this factory method to create a new instance of [InformationFragment].
*
Expand Down
Loading

0 comments on commit 86656b2

Please sign in to comment.