Skip to content

Commit

Permalink
Merge branch 'release/0.2.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrimault committed Feb 2, 2020
2 parents 86656b2 + c644ec0 commit ae34d11
Show file tree
Hide file tree
Showing 82 changed files with 138 additions and 120 deletions.
1 change: 1 addition & 0 deletions .idea/codeStyles/Project.xml

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

2 changes: 1 addition & 1 deletion artwork/occtax_launcher.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion gn_mobile_core
Submodule gn_mobile_core updated 85 files
+1 −0 .idea/codeStyles/Project.xml
+2 −2 commons/build.gradle
+8 −6 sync/build.gradle
+ 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
+63 −10 sync/src/main/java/fr/geonature/sync/api/GeoNatureAPIClient.kt
+7 −14 sync/src/main/java/fr/geonature/sync/api/GeoNatureService.kt
+21 −0 sync/src/main/java/fr/geonature/sync/api/TaxHubService.kt
+20 −13 sync/src/main/java/fr/geonature/sync/auth/AuthLoginViewModel.kt
+23 −6 sync/src/main/java/fr/geonature/sync/data/dao/AppSyncDao.kt
+1 −1 sync/src/main/java/fr/geonature/sync/data/dao/NomenclatureDao.kt
+6 −30 sync/src/main/java/fr/geonature/sync/sync/DataSyncManager.kt
+14 −25 sync/src/main/java/fr/geonature/sync/sync/DataSyncWorker.kt
+4 −18 sync/src/main/java/fr/geonature/sync/sync/InputsSyncWorker.kt
+3 −1 sync/src/main/java/fr/geonature/sync/ui/home/HomeActivity.kt
+85 −47 sync/src/main/java/fr/geonature/sync/ui/login/LoginActivity.kt
+22 −2 sync/src/main/java/fr/geonature/sync/util/SettingsUtils.kt
+1 −1 sync/src/main/res/layout/activity_login.xml
+ sync/src/main/res/mipmap-hdpi/ic_launcher.png
+ sync/src/main/res/mipmap-hdpi/ic_launcher_round.png
+ sync/src/main/res/mipmap-mdpi/ic_launcher.png
+ sync/src/main/res/mipmap-mdpi/ic_launcher_round.png
+ sync/src/main/res/mipmap-xhdpi/ic_launcher.png
+ sync/src/main/res/mipmap-xhdpi/ic_launcher_round.png
+ sync/src/main/res/mipmap-xxhdpi/ic_launcher.png
+ sync/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
+ sync/src/main/res/mipmap-xxxhdpi/ic_launcher.png
+ sync/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
+5 −2 sync/src/main/res/values-fr/prefs.xml
+5 −3 sync/src/main/res/values-fr/strings.xml
+5 −5 sync/src/main/res/values/colors.xml
+7 −3 sync/src/main/res/values/prefs.xml
+4 −2 sync/src/main/res/values/strings.xml
+12 −4 sync/src/main/res/xml/preferences.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
+3 −3 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
+3 −3 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
+2 −2 sync/version.properties
8 changes: 5 additions & 3 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.2.7"
version = "0.2.8"

android {
compileSdkVersion 28
Expand Down Expand Up @@ -38,6 +38,8 @@ android {

flavorDimensions "version"
productFlavors {
pnx {
}
pne {
}
pnv {
Expand All @@ -62,8 +64,8 @@ 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-rc01'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0-rc03"
implementation 'androidx.core:core-ktx:1.3.0-alpha01'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
Expand Down
Binary file modified occtax/src/debug/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified occtax/src/debug/res/mipmap-hdpi/ic_launcher_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified occtax/src/debug/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified occtax/src/debug/res/mipmap-mdpi/ic_launcher_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified occtax/src/debug/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified occtax/src/debug/res/mipmap-xhdpi/ic_launcher_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified occtax/src/debug/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified occtax/src/debug/res/mipmap-xxhdpi/ic_launcher_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified occtax/src/debug/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified occtax/src/debug/res/mipmap-xxxhdpi/ic_launcher_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import fr.geonature.occtax.input.Input
import fr.geonature.occtax.settings.AppSettings
import fr.geonature.occtax.ui.input.InputPagerFragmentActivity
import fr.geonature.occtax.ui.settings.PreferencesActivity
import fr.geonature.occtax.util.IntentUtils
import fr.geonature.occtax.util.IntentUtils.syncActivity

/**
* Home screen Activity.
Expand Down Expand Up @@ -36,7 +36,9 @@ class HomeActivity : AppCompatActivity(),
}

override fun onStartSync() {
startActivity(IntentUtils.syncActivity(this))
syncActivity(this)?.also {
startActivity(it)
}
}

override fun onStartInput(
Expand Down
131 changes: 80 additions & 51 deletions occtax/src/main/java/fr/geonature/occtax/ui/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.view.animation.AnimationUtils
import android.widget.TextView
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.os.bundleOf
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
Expand All @@ -21,6 +23,8 @@ import androidx.loader.content.CursorLoader
import androidx.loader.content.Loader
import androidx.recyclerview.widget.DividerItemDecoration
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.AppSync
import fr.geonature.commons.data.helper.Provider.buildUri
Expand All @@ -35,7 +39,7 @@ import fr.geonature.occtax.input.InputViewModel
import fr.geonature.occtax.settings.AppSettings
import fr.geonature.occtax.settings.AppSettingsViewModel
import fr.geonature.occtax.ui.shared.view.ListItemActionView
import kotlinx.android.synthetic.main.fragment_home.*
import fr.geonature.occtax.util.IntentUtils.syncActivity

/**
* Home screen [Fragment].
Expand All @@ -50,6 +54,12 @@ class HomeFragment : Fragment() {
private var appSettingsViewModel: AppSettingsViewModel? = null
private var inputViewModel: InputViewModel? = null

private var homeContent: CoordinatorLayout? = null
private var appSyncView: AppSyncView? = null
private var inputRecyclerView: RecyclerView? = null
private var inputEmptyTextView: TextView? = null
private var fab: FloatingActionButton? = null

private val loaderCallbacks = object : LoaderManager.LoaderCallbacks<Cursor> {
override fun onCreateLoader(
id: Int,
Expand Down Expand Up @@ -89,7 +99,7 @@ class HomeFragment : Fragment() {
when (loader.id) {
LOADER_APP_SYNC -> {
if (data.moveToFirst()) {
appSyncView.setAppSync(AppSync.fromCursor(data))
appSyncView?.setAppSync(AppSync.fromCursor(data))
}
}
}
Expand Down Expand Up @@ -125,11 +135,19 @@ class HomeFragment : Fragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
return inflater.inflate(
val view = inflater.inflate(
R.layout.fragment_home,
container,
false
)

homeContent = view.findViewById(R.id.homeContent)
appSyncView = view.findViewById(R.id.appSyncView)
inputRecyclerView = view.findViewById(R.id.inputRecyclerView)
inputEmptyTextView = view.findViewById(R.id.inputEmptyTextView)
fab = view.findViewById(R.id.fab)

return view
}

override fun onViewCreated(
Expand All @@ -143,13 +161,13 @@ class HomeFragment : Fragment() {

setHasOptionsMenu(true)

appSyncView.setListener(object : ListItemActionView.OnListItemActionViewListener {
appSyncView?.setListener(object : ListItemActionView.OnListItemActionViewListener {
override fun onAction() {
listener?.onStartSync()
}
})

fab.setOnClickListener {
fab?.setOnClickListener {
val appSettings = appSettings ?: return@setOnClickListener
listener?.onStartInput(appSettings)
}
Expand All @@ -176,56 +194,52 @@ class HomeFragment : Fragment() {
) {
inputViewModel?.deleteInput(item)

Snackbar.make(
homeContent,
R.string.home_snackbar_input_deleted,
Snackbar.LENGTH_SHORT
)
.setAction(
R.string.home_snackbar_input_undo
) {
makeSnackbar(getString(R.string.home_snackbar_input_deleted))
?.setAction(R.string.home_snackbar_input_undo) {
inputViewModel?.restoreDeletedInput()
}
.show()
?.show()
}

override fun showEmptyTextView(show: Boolean) {
if (inputEmptyTextView.visibility == View.VISIBLE == show) {
if (inputEmptyTextView?.visibility == View.VISIBLE == show) {
return
}

if (show) {
inputEmptyTextView.startAnimation(
inputEmptyTextView?.startAnimation(
AnimationUtils.loadAnimation(
context,
android.R.anim.fade_in
)
)
inputEmptyTextView.visibility = View.VISIBLE
inputEmptyTextView?.visibility = View.VISIBLE
} else {
inputEmptyTextView.startAnimation(
inputEmptyTextView?.startAnimation(
AnimationUtils.loadAnimation(
context,
android.R.anim.fade_out
)
)
inputEmptyTextView.visibility = View.GONE
inputEmptyTextView?.visibility = View.GONE
}
}
})

with(inputRecyclerView) {
inputRecyclerView?.apply {
layoutManager = LinearLayoutManager(context)
adapter = this@HomeFragment.adapter
}

val dividerItemDecoration = DividerItemDecoration(
inputRecyclerView.context,
(inputRecyclerView.layoutManager as LinearLayoutManager).orientation
inputRecyclerView?.context,
(inputRecyclerView?.layoutManager as LinearLayoutManager).orientation
)
inputRecyclerView.addItemDecoration(dividerItemDecoration)
inputRecyclerView?.addItemDecoration(dividerItemDecoration)

checkSelfPermissions()
if (checkAppSync()) {
checkSelfPermissions()
}
}

override fun onResume() {
Expand Down Expand Up @@ -297,20 +311,10 @@ class HomeFragment : Fragment() {
val requestPermissionsResult = checkPermissions(grantResults)

if (requestPermissionsResult) {
Snackbar.make(
homeContent,
R.string.snackbar_permission_external_storage_available,
Snackbar.LENGTH_LONG
)
.show()
makeSnackbar(getString(R.string.snackbar_permission_external_storage_available))?.show()
loadAppSettings()
} else {
Snackbar.make(
homeContent,
R.string.snackbar_permissions_not_granted,
Snackbar.LENGTH_LONG
)
.show()
makeSnackbar(getString(R.string.snackbar_permissions_not_granted))?.show()
}
}
else -> super.onRequestPermissionsResult(
Expand All @@ -332,40 +336,55 @@ class HomeFragment : Fragment() {
}

override fun onRequestPermissions(vararg permissions: String) {
requestPermissions(
this@HomeFragment,
homeContent,
R.string.snackbar_permission_external_storage_rationale,
REQUEST_STORAGE_PERMISSIONS,
*permissions
)
homeContent?.also {
requestPermissions(
this@HomeFragment,
it,
R.string.snackbar_permission_external_storage_rationale,
REQUEST_STORAGE_PERMISSIONS,
*permissions
)
}
}
},
Manifest.permission.WRITE_EXTERNAL_STORAGE
)
}

private fun checkAppSync(): Boolean {
val context = context ?: return true

if (syncActivity(context) == null) {
fab?.hide()
appSyncView?.enableActionButton(false)
makeSnackbar(getString(R.string.snackbar_app_sync_not_found))?.show()

return false
}

appSyncView?.enableActionButton()

return true
}

private fun loadAppSettings() {
appSettingsViewModel?.getAppSettings<AppSettings>()
?.observe(this,
Observer {
if (it?.mapSettings == null) {
fab.hide()
fab?.hide()
adapter.clear()
activity?.invalidateOptionsMenu()

Snackbar.make(
homeContent,
makeSnackbar(
getString(
if (it == null) R.string.snackbar_settings_not_found else R.string.snackbar_settings_map_invalid,
appSettingsViewModel?.getAppSettingsFilename()
),
Snackbar.LENGTH_LONG
)
.show()
)
)?.show()
} else {
appSettings = it
fab.show()
fab?.show()
activity?.invalidateOptionsMenu()

loadInputs()
Expand All @@ -381,6 +400,16 @@ class HomeFragment : Fragment() {
})
}

private fun makeSnackbar(text: CharSequence): Snackbar? {
val view = homeContent ?: return null

return Snackbar.make(
view,
text,
Snackbar.LENGTH_LONG
)
}

/**
* Callback used by [HomeFragment].
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import android.util.Log
import androidx.lifecycle.ViewModelProvider
import androidx.viewpager.widget.ViewPager
import fr.geonature.maps.settings.MapSettings
import fr.geonature.maps.util.SettingsUtils.showCompass
import fr.geonature.maps.util.SettingsUtils.showScale
import fr.geonature.maps.util.SettingsUtils.showZoom
import fr.geonature.occtax.R
import fr.geonature.occtax.input.Input
import fr.geonature.occtax.input.InputViewModel
Expand All @@ -17,8 +20,6 @@ import fr.geonature.occtax.ui.input.map.InputMapFragment
import fr.geonature.occtax.ui.input.observers.ObserversAndDateInputFragment
import fr.geonature.occtax.ui.input.summary.InputTaxaSummaryFragment
import fr.geonature.occtax.ui.input.taxa.TaxaFragment
import fr.geonature.occtax.util.SettingsUtils.getMapShowCompass
import fr.geonature.occtax.util.SettingsUtils.getMapShowScale
import fr.geonature.viewpager.ui.AbstractNavigationHistoryPagerFragmentActivity
import fr.geonature.viewpager.ui.AbstractPagerFragmentActivity
import fr.geonature.viewpager.ui.IValidateFragment
Expand Down Expand Up @@ -119,8 +120,9 @@ class InputPagerFragmentActivity : AbstractNavigationHistoryPagerFragmentActivit
private fun getMapSettings(): MapSettings {
return MapSettings.Builder.newInstance()
.from(appSettings.mapSettings!!)
.showScale(getMapShowScale(this))
.showCompass(getMapShowCompass(this))
.showCompass(showCompass(this))
.showScale(showScale(this))
.showZoom(showZoom(this))
.build()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ open class ListItemActionView : ConstraintLayout {
emptyTextView.setText(if (emptyTextResourceId == 0) R.string.no_data else emptyTextResourceId)
}

fun enableActionButton(enabled: Boolean = true) {
actionButton.isEnabled = enabled
}

fun setActionText(@StringRes actionResourceId: Int) {
if (actionResourceId == 0) {
return
Expand Down Expand Up @@ -199,6 +203,12 @@ open class ListItemActionView : ConstraintLayout {
R.string.no_data
)
)
enableActionButton(
ta.getBoolean(
R.styleable.ListItemActionView_action_enabled,
true
)
)
setActionText(
ta.getResourceId(
R.styleable.ListItemActionView_action,
Expand Down
Loading

0 comments on commit ae34d11

Please sign in to comment.