Skip to content

Commit 44258b7

Browse files
authored
Merge pull request #1443 from PhenoApps/photo-names-export
Photo Names Export
2 parents 9686502 + 7a94994 commit 44258b7

4 files changed

Lines changed: 14 additions & 11 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ gradlew.bat
2323

2424
# Local configuration file (sdk path, etc)
2525
local.properties
26-
gradle.properties
2726

2827
# Log Files
2928
*.log

app/src/main/java/com/fieldbook/tracker/database/dao/ObservationUnitPropertyDao.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import com.fieldbook.tracker.database.withDatabase
2020
import com.fieldbook.tracker.objects.RangeObject
2121
import com.fieldbook.tracker.objects.TraitObject
2222
import com.fieldbook.tracker.preferences.GeneralKeys
23+
import com.fieldbook.tracker.traits.formats.presenters.UriPresenter
2324
import com.fieldbook.tracker.utilities.CategoryJsonUtil
2425
import com.fieldbook.tracker.utilities.export.ValueProcessorFormatAdapter
2526

@@ -141,7 +142,7 @@ class ObservationUnitPropertyDao {
141142

142143
Log.d("getExportDbData", "Final Query: $query")
143144
val table = db.rawQuery(query, null).toTable()
144-
145+
val attachedMediaUriPresenter = UriPresenter()
145146
table.forEach { row ->
146147
cursor.addRow(fieldList.map { row[it] } + traitRequiredFields.map {
147148
when (it) {
@@ -158,9 +159,9 @@ class ObservationUnitPropertyDao {
158159
"person" -> row["collector"]
159160
"location" -> row["geo_coordinates"]
160161
"rep" -> row["rep"]
161-
"photo_uri" -> row["photo_uri"]
162-
"video_uri" -> row["video_uri"]
163-
"audio_uri" -> row["audio_uri"]
162+
"photo_uri" -> (row["photo_uri"] as? String)?.takeIf { it.isNotEmpty() }?.let { attachedMediaUriPresenter.represent(context, it) } ?: ""
163+
"video_uri" -> (row["video_uri"] as? String)?.takeIf { it.isNotEmpty() }?.let { attachedMediaUriPresenter.represent(context, it) } ?: ""
164+
"audio_uri" -> (row["audio_uri"] as? String)?.takeIf { it.isNotEmpty() }?.let { attachedMediaUriPresenter.represent(context, it) } ?: ""
164165
else -> String()
165166
}
166167
})

app/src/main/java/com/fieldbook/tracker/utilities/export/ValueProcessorFormatAdapter.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@ class ValueProcessorFormatAdapter @Inject constructor(
2222
}
2323

2424
fun processValue(value: String, trait: TraitObject): String? {
25-
return when (trait.format) {
25+
return when {
2626

27-
in setOf(Formats.DATE.getDatabaseName()) -> {
27+
trait.format in setOf(Formats.DATE.getDatabaseName()) -> {
2828

2929
val dateValue = DateJsonUtil.decode(value)
3030

3131
return (Formats.DATE.getTraitFormatDefinition() as ValuePresenter).represent(context, dateValue, trait)
3232
}
3333

34-
in CategoricalTraitLayout.POSSIBLE_VALUES -> return CategoryJsonUtil.processValue(
34+
trait.format in CategoricalTraitLayout.POSSIBLE_VALUES -> return CategoryJsonUtil.processValue(
3535
buildMap {
3636
put("value", value)
3737
put("observation_variable_field_book_format", trait.format)
3838
put("categoryDisplayValue", trait.categoryDisplayValue)
3939
})
4040

41-
in Formats.getSpectralFormats().map { it.getDatabaseName() } -> {
41+
trait.format in Formats.getSpectralFormats().map { it.getDatabaseName() } -> {
4242
spectralFileProcessor.processValue(value)
4343
.onSuccess { value ->
4444
val presentable = UriPresenter().represent(context, value)
@@ -52,6 +52,10 @@ class ValueProcessorFormatAdapter @Inject constructor(
5252
}
5353
}
5454

55+
Formats.isCameraTrait(trait.format) -> {
56+
if (value.isEmpty()) "" else UriPresenter().represent(context, value, trait)
57+
}
58+
5559
else -> value
5660

5761
}.toString()

gradle.properties

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@
1313
#Fri Aug 20 09:12:17 CDT 2021
1414
org.gradle.jvmargs=-Xmx2048m -Dkotlin.daemon.jvm.options\="-Xmx2048m" -XX:+UseParallelGC
1515
android.useAndroidX=true
16-
android.enableJetifier=true
17-
16+
android.enableJetifier=true

0 commit comments

Comments
 (0)