Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move entities package from JavaRosa #6236

Merged
merged 9 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ collect_app/.classpath
collect_app/.project
collect_app/.settings/

# Submodules
javarosa/

# Config for the official ODK Collect build
collect_app/src/odkCollectRelease/

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/dependencies/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object Dependencies {
const val rarepebble_colorpicker = "com.github.martin-stone:hsv-alpha-color-picker-android:3.1.0"
const val commons_io = "commons-io:commons-io:2.5" // Commons 2.6+ introduce java.nio usage that we can't access until our minSdkVersion >= 26 (https://developer.android.com/reference/java/io/File#toPath())
const val opencsv = "com.opencsv:opencsv:5.9"
const val javarosa_online = "org.getodk:javarosa:4.4.0"
const val javarosa_online = "org.getodk:javarosa:5.0.0-SNAPSHOT"
const val javarosa_local = "org.getodk:javarosa:local"
const val javarosa = javarosa_online
const val karumi_dexter = "com.karumi:dexter:6.2.3"
Expand Down
5 changes: 3 additions & 2 deletions collect_app/proguard-rules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
-dontwarn android.content.res.**
-dontwarn org.kxml2.io.**

-keep class org.javarosa.**
-keep class org.odk.collect.android.logic.actions.**
-keep class android.support.v7.widget.** { *; }
-keep class org.mp4parser.boxes.** { *; }
-keep class * extends androidx.fragment.app.Fragment{}

-keep class * implements org.javarosa.core.util.externalizable.Externalizable{}
-keep class org.javarosa.core.model.instance.geojson.GeojsonFeature { *; }
-keep class org.javarosa.core.model.instance.geojson.GeojsonGeometry { *; }
-keep class * extends androidx.fragment.app.Fragment{}

-dontobfuscate

Expand Down
2 changes: 1 addition & 1 deletion collect_app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ the specific language governing permissions and limitations under the License.
tools:replace="android:theme" />

<activity
android:name="org.odk.collect.entities.EntityBrowserActivity"
android:name="org.odk.collect.entities.browser.EntityBrowserActivity"
android:theme="@style/Theme.Collect"
tools:replace="android:theme" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
import org.odk.collect.entities.EntitiesDependencyComponent;
import org.odk.collect.entities.EntitiesDependencyComponentProvider;
import org.odk.collect.entities.EntitiesDependencyModule;
import org.odk.collect.entities.EntitiesRepository;
import org.odk.collect.entities.storage.EntitiesRepository;
import org.odk.collect.forms.Form;
import org.odk.collect.geo.DaggerGeoDependencyComponent;
import org.odk.collect.geo.GeoDependencyComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package org.odk.collect.android.application.initialization
import org.javarosa.core.model.CoreModelModule
import org.javarosa.core.services.PrototypeManager
import org.javarosa.core.util.JavaRosaCoreModule
import org.javarosa.entities.EntityXFormParserFactory
import org.javarosa.model.xform.XFormsModule
import org.javarosa.xform.parse.XFormParser
import org.javarosa.xform.parse.XFormParserFactory
import org.javarosa.xform.util.XFormUtils
import org.odk.collect.android.dynamicpreload.DynamicPreloadXFormParserFactory
import org.odk.collect.android.entities.EntitiesRepositoryProvider
import org.odk.collect.android.logic.actions.setgeopoint.CollectSetGeopointActionHandler
import org.odk.collect.entities.LocalEntitiesExternalInstanceParserFactory
import org.odk.collect.entities.javarosa.intance.LocalEntitiesExternalInstanceParserFactory
import org.odk.collect.entities.javarosa.parse.EntityXFormParserFactory
import org.odk.collect.metadata.PropertyManager
import org.odk.collect.settings.SettingsProvider
import org.odk.collect.settings.keys.ProjectKeys
Expand Down Expand Up @@ -40,7 +40,10 @@ class JavaRosaInitializer(
)

// Configure default parser factory
val entityXFormParserFactory = EntityXFormParserFactory(XFormParserFactory())
val entityXFormParserFactory =
EntityXFormParserFactory(
XFormParserFactory()
)
val dynamicPreloadXFormParserFactory =
DynamicPreloadXFormParserFactory(entityXFormParserFactory)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.odk.collect.android.entities

import org.odk.collect.android.projects.ProjectsDataService
import org.odk.collect.android.storage.StoragePathProvider
import org.odk.collect.entities.EntitiesRepository
import org.odk.collect.entities.storage.EntitiesRepository
import java.io.File

class EntitiesRepositoryProvider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package org.odk.collect.android.entities
import android.os.StrictMode
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import org.odk.collect.entities.EntitiesRepository
import org.odk.collect.entities.Entity
import org.odk.collect.entities.storage.EntitiesRepository
import org.odk.collect.entities.storage.Entity
import java.io.File

class JsonFileEntitiesRepository(directory: File) : EntitiesRepository {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import org.odk.collect.android.javarosawrapper.FormController
import org.odk.collect.android.javarosawrapper.JavaRosaFormController
import org.odk.collect.android.utilities.FileUtils
import org.odk.collect.android.utilities.FormUtils
import org.odk.collect.entities.EntitiesRepository
import org.odk.collect.entities.LocalEntityUseCases
import org.odk.collect.entities.storage.EntitiesRepository
import org.odk.collect.forms.Form
import org.odk.collect.forms.FormsRepository
import org.odk.collect.forms.instances.Instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.odk.collect.android.tasks.SaveFormToDisk;
import org.odk.collect.android.tasks.SaveToDiskResult;
import org.odk.collect.android.utilities.MediaUtils;
import org.odk.collect.entities.EntitiesRepository;
import org.odk.collect.entities.storage.EntitiesRepository;
import org.odk.collect.forms.instances.InstancesRepository;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.odk.collect.async.Cancellable;
import org.odk.collect.async.Scheduler;
import org.odk.collect.audiorecorder.recording.AudioRecorder;
import org.odk.collect.entities.EntitiesRepository;
import org.odk.collect.entities.storage.EntitiesRepository;
import org.odk.collect.forms.Form;
import org.odk.collect.forms.instances.Instance;
import org.odk.collect.forms.instances.InstancesRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.odk.collect.android.javarosawrapper.FormController;
import org.odk.collect.android.tasks.SaveToDiskResult;
import org.odk.collect.android.utilities.MediaUtils;
import org.odk.collect.entities.EntitiesRepository;
import org.odk.collect.entities.storage.EntitiesRepository;
import org.odk.collect.forms.instances.InstancesRepository;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package org.odk.collect.android.formmanagement

import org.javarosa.core.model.FormDef
import org.javarosa.entities.EntityFormFinalizationProcessor
import org.javarosa.form.api.FormEntryController
import org.javarosa.form.api.FormEntryModel
import org.odk.collect.android.application.Collect
import org.odk.collect.android.dynamicpreload.ExternalDataManagerImpl
import org.odk.collect.android.dynamicpreload.handler.ExternalDataHandlerPull
import org.odk.collect.android.tasks.FormLoaderTask.FormEntryControllerFactory
import org.odk.collect.entities.javarosa.finalization.EntityFormFinalizationProcessor
import java.io.File

class CollectFormEntryControllerFactory :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import org.odk.collect.android.formmanagement.download.FormDownloadException
import org.odk.collect.android.formmanagement.download.FormDownloader
import org.odk.collect.android.utilities.FileUtils
import org.odk.collect.async.OngoingWorkListener
import org.odk.collect.entities.EntitiesRepository
import org.odk.collect.entities.LocalEntityUseCases
import org.odk.collect.entities.storage.EntitiesRepository
import org.odk.collect.forms.Form
import org.odk.collect.forms.FormSource
import org.odk.collect.forms.FormSourceException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.odk.collect.android.utilities.FormNameUtils;
import org.odk.collect.androidshared.utils.Validator;
import org.odk.collect.async.OngoingWorkListener;
import org.odk.collect.entities.EntitiesRepository;
import org.odk.collect.entities.storage.EntitiesRepository;
import org.odk.collect.forms.Form;
import org.odk.collect.forms.FormSource;
import org.odk.collect.forms.FormSourceException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import org.javarosa.core.model.FormIndex
import org.javarosa.core.model.data.IAnswerData
import org.javarosa.core.model.instance.TreeReference
import org.javarosa.core.services.transport.payload.ByteArrayPayload
import org.javarosa.entities.internal.Entities
import org.javarosa.form.api.FormEntryCaption
import org.javarosa.form.api.FormEntryPrompt
import org.odk.collect.android.exception.JavaRosaException
import org.odk.collect.android.formentry.audit.AuditEventLogger
import org.odk.collect.entities.javarosa.finalization.EntitiesExtra
import java.io.File
import java.io.IOException

Expand Down Expand Up @@ -334,5 +334,5 @@ interface FormController {

fun getAnswer(treeReference: TreeReference?): IAnswerData?

fun getEntities(): Entities?
fun getEntities(): EntitiesExtra?
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.javarosa.core.model.instance.TreeElement;
import org.javarosa.core.model.instance.TreeReference;
import org.javarosa.core.services.transport.payload.ByteArrayPayload;
import org.javarosa.entities.internal.Entities;
import org.javarosa.form.api.FormEntryCaption;
import org.javarosa.form.api.FormEntryController;
import org.javarosa.form.api.FormEntryModel;
Expand All @@ -54,6 +53,7 @@
import org.odk.collect.android.formentry.audit.AuditEventLogger;
import org.odk.collect.android.utilities.Appearances;
import org.odk.collect.android.utilities.FileUtils;
import org.odk.collect.entities.javarosa.finalization.EntitiesExtra;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -1109,7 +1109,7 @@ public IAnswerData getAnswer(TreeReference treeReference) {
return getFormDef().getMainInstance().resolveReference(treeReference).getValue();
}

public Entities getEntities() {
return formEntryController.getModel().getExtras().get(Entities.class);
public EntitiesExtra getEntities() {
return formEntryController.getModel().getExtras().get(EntitiesExtra.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.jetbrains.annotations.NotNull;
import org.odk.collect.android.R;
import org.odk.collect.androidshared.ui.ToastUtils;
import org.odk.collect.entities.EntityBrowserActivity;
import org.odk.collect.entities.browser.EntityBrowserActivity;

public class ExperimentalPreferencesFragment extends BaseProjectPreferencesFragment {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
import org.odk.collect.android.utilities.FileUtils;
import org.odk.collect.android.utilities.FormsRepositoryProvider;
import org.odk.collect.android.utilities.MediaUtils;
import org.odk.collect.entities.EntitiesRepository;
import org.odk.collect.entities.storage.EntitiesRepository;
import org.odk.collect.forms.Form;
import org.odk.collect.forms.instances.Instance;
import org.odk.collect.forms.instances.InstancesRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import org.hamcrest.Matchers.contains
import org.hamcrest.Matchers.containsInAnyOrder
import org.hamcrest.Matchers.equalTo
import org.junit.Test
import org.odk.collect.entities.EntitiesRepository
import org.odk.collect.entities.Entity
import org.odk.collect.entities.storage.EntitiesRepository
import org.odk.collect.entities.storage.Entity

abstract class EntitiesRepositoryTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.odk.collect.android.entities

import org.odk.collect.entities.EntitiesRepository
import org.odk.collect.entities.InMemEntitiesRepository
import org.odk.collect.entities.storage.EntitiesRepository
import org.odk.collect.entities.storage.InMemEntitiesRepository

class InMemEntitiesRepositoryTest : EntitiesRepositoryTest() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.contains
import org.hamcrest.Matchers.equalTo
import org.junit.Test
import org.odk.collect.entities.EntitiesRepository
import org.odk.collect.entities.Entity
import org.odk.collect.entities.storage.EntitiesRepository
import org.odk.collect.entities.storage.Entity
import org.odk.collect.shared.TempFiles
import java.io.File

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import org.kxml2.kdom.Document
import org.mockito.kotlin.mock
import org.odk.collect.android.javarosawrapper.FormController
import org.odk.collect.android.utilities.FileUtils
import org.odk.collect.entities.InMemEntitiesRepository
import org.odk.collect.entities.storage.InMemEntitiesRepository
import org.odk.collect.forms.Form
import org.odk.collect.forms.instances.Instance
import org.odk.collect.formstest.FormFixtures
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import org.odk.collect.android.tasks.SaveToDiskResult;
import org.odk.collect.android.utilities.MediaUtils;
import org.odk.collect.audiorecorder.recording.AudioRecorder;
import org.odk.collect.entities.EntitiesRepository;
import org.odk.collect.entities.storage.EntitiesRepository;
import org.odk.collect.forms.Form;
import org.odk.collect.forms.instances.Instance;
import org.odk.collect.forms.instances.InstancesRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import org.mockito.stubbing.Answer
import org.odk.collect.android.formmanagement.download.FormDownloadException
import org.odk.collect.android.formmanagement.download.FormDownloader
import org.odk.collect.android.utilities.FileUtils
import org.odk.collect.entities.InMemEntitiesRepository
import org.odk.collect.entities.storage.InMemEntitiesRepository
import org.odk.collect.forms.Form
import org.odk.collect.forms.FormSource
import org.odk.collect.forms.ManifestFile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import org.junit.Test;
import org.odk.collect.android.formmanagement.FormMetadataParser;
import org.odk.collect.android.formmanagement.ServerFormDetails;
import org.odk.collect.entities.EntitiesRepository;
import org.odk.collect.entities.InMemEntitiesRepository;
import org.odk.collect.entities.storage.EntitiesRepository;
import org.odk.collect.entities.storage.InMemEntitiesRepository;
import org.odk.collect.forms.Form;
import org.odk.collect.forms.FormListItem;
import org.odk.collect.forms.FormSource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import org.javarosa.core.model.FormIndex
import org.javarosa.core.model.data.IAnswerData
import org.javarosa.core.model.instance.TreeReference
import org.javarosa.core.services.transport.payload.ByteArrayPayload
import org.javarosa.entities.internal.Entities
import org.javarosa.form.api.FormEntryCaption
import org.javarosa.form.api.FormEntryPrompt
import org.odk.collect.android.exception.JavaRosaException
Expand All @@ -14,6 +13,7 @@ import org.odk.collect.android.javarosawrapper.FormController
import org.odk.collect.android.javarosawrapper.InstanceMetadata
import org.odk.collect.android.javarosawrapper.SuccessValidationResult
import org.odk.collect.android.javarosawrapper.ValidationResult
import org.odk.collect.entities.javarosa.finalization.EntitiesExtra
import java.io.File

open class StubFormController : FormController {
Expand Down Expand Up @@ -156,5 +156,5 @@ open class StubFormController : FormController {

override fun getAnswer(treeReference: TreeReference?): IAnswerData? = null

override fun getEntities(): Entities? = null
override fun getEntities(): EntitiesExtra? = null
}
2 changes: 1 addition & 1 deletion entities/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<application>
<activity
android:name=".EntityBrowserActivity"
android:name=".browser.EntityBrowserActivity"
android:theme="@style/Theme.Material3.DayNight"/>
</application>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import dagger.Component
import dagger.Module
import dagger.Provides
import org.odk.collect.async.Scheduler
import org.odk.collect.entities.browser.EntityBrowserActivity
import org.odk.collect.entities.storage.EntitiesRepository
import javax.inject.Singleton

interface EntitiesDependencyComponentProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ package org.odk.collect.entities

import org.javarosa.core.model.instance.CsvExternalInstance
import org.javarosa.core.model.instance.TreeElement
import org.javarosa.entities.EntityAction
import org.javarosa.entities.internal.Entities
import org.odk.collect.entities.browser.EntityItemElement
import org.odk.collect.entities.javarosa.finalization.EntitiesExtra
import org.odk.collect.entities.javarosa.spec.EntityAction
import org.odk.collect.entities.storage.EntitiesRepository
import org.odk.collect.entities.storage.Entity
import java.io.File

object LocalEntityUseCases {

@JvmStatic
fun updateLocalEntitiesFromForm(
formEntities: Entities?,
formEntities: EntitiesExtra?,
entitiesRepository: EntitiesRepository
) {
formEntities?.entities?.forEach { formEntity ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.odk.collect.entities
package org.odk.collect.entities.browser

import android.content.Context
import android.os.Bundle
Expand All @@ -12,6 +12,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import org.odk.collect.entities.databinding.ListLayoutBinding
import org.odk.collect.entities.storage.Entity
import org.odk.collect.lists.RecyclerViewUtils
import org.odk.collect.lists.RecyclerViewUtils.matchParentWidth

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package org.odk.collect.entities
package org.odk.collect.entities.browser

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import org.odk.collect.async.Scheduler
import org.odk.collect.entities.storage.EntitiesRepository
import org.odk.collect.entities.storage.Entity

class EntitiesViewModel(
private val scheduler: Scheduler,
Expand Down
Loading