OpenSRP Client Core App/Module basically provides basic functionality such as networking, security, database access, common widgets, utilities, domain objects, service layer, broadcast receivers and syncing.
It provides:
If you are looking for more information regarding OpenSRP as a platform checkout the OpenSRP Site
This section will provide a brief description on how to build and install the application from the repository source code.
Deployment Target
If you want to contribute please refer to these resources:
If you are looking for detailed guides on how to install, configure, contribute and extend OpenSRP visit OpenSRP Wiki
OpenSRP Client core has been used in several modules and applications:
Security is provided in the following:
The security classes can be found in org.smartregister.ssl
Under the cryptography package we have CryptographicHelper class whose instance exposes methods
byte[] encrypt(byte[] input, String keyAlias) For encryption of a byte array input with key
byte[] decrypt(byte[] encrypted, String keyAlias) For decryption of encrypted byte array with key
Key getKey(String keyAlias) For retrieving a generated key stored in the Android keystore
void generateKey(String keyAlias) For key generation using a Key Alias parameter for use by Android keystore
AndroidLegacyCryptography
class and the AndroidMCryptography
class which both implement the above in different ways depending on the SDK version.
AndroidLegacyCryptography
has method implementation that are used when the SDK version is less than API level 23The sample app has examples of how these methods have been implemented. The code for it can be found in the MainActivity class.
This app provides data management.
It implements both plain and secure data storage. Classes implementing secure storage extend SQLiteOpenHelper
, Repository
or BaseRepository
.
The rest use the SQLite helpers provided in the Android SDK.
For this reason, there are multiple implementations for storing the same model(s).
Class | Represents |
---|---|
EventClientRepository |
Events |
AlertRepository |
Alerts |
ChildRepository |
Children |
ClientRepository |
Clients/Patients |
DetailsRepository |
Details |
EligibleCoupleRepository |
Eligible couples |
EventRepository |
Events |
FormDataRepository |
Form data |
FormsVersionRepository |
Form version |
ImageRepository |
Image locations |
MotherRepository |
Mothers |
ServiceProvidedRepository |
Provided service to the patient |
SettingsRepository |
App settings eg. connection configurations |
TimelineEventRepository |
Timeline events |
The data management classes can be found in org.smartregister.repository
This app provides the following networking capabilities:
Class | Represents |
---|---|
OpensrpSSLHelper |
SSL Connection helper |
OpenSRPImageLoader |
Asynchronous image downloader |
HttpAgent |
Synchronous networking class with username\password (Basic Auth) access support |
ConnectivityChangeReceiver |
Network status detection by a broadcast receiver |
GZipEncodingHttpClient |
GZip encoding and decoding capabilities |
Session |
Session management |
UserService |
User authentication & client-server time synchronization |
The networking classes can be found in:
org.smartregister.service
org.smartregister.util
org.smartregister.client
org.smartregister.ssl
org.smartregister.view.receiver
This app provides the following domain objects:
Class | Represents |
---|---|
Address |
Location address containing map coordinates |
BaseDataObject |
Data object with datestamps, void flag, related void details and server version |
BaseEntity |
Extends BaseDataObject to include the baseEntityId , identifiers , addresses and attributes that are common in OpenSRP models |
Client |
Represents a patient in OpenSRP eg. a child. It contains relevant patient details and extends BaseEntity |
ColumnAttribute |
Represents a column using the type, is-primary-key and is-index properties. It is used in the EventClientRepository class to define and access columns in the appropriate table |
Event |
It represents an event in OpenSRP which are mainly encounters eg. Birth Registration, Death. It extends the BaseDataObject and provides other properties |
Obs |
It represents an observation in an Event above |
Query |
It represents a data query and enables creation of queries using an OOP approach |
FormData |
It represents form fields, their inputs and any sub-forms |
FormField |
It represents a single form question/field with a name, value and source |
FormInstance |
It represents a FormData of a specific definition version |
FormSubmission |
It represents the status of a form before or after submission. It therefore contains other metadata such as client version and server verion. |
SubForm |
It represents a form inside another form |
Alert |
It represents a notification about an encounter which is due or overdue the expected time |
ANM |
It represents a health services provider |
Child |
It represents a child |
EligibleCouple |
It represents an eligible couple |
FormDefinitionVersion |
It represents a form version |
Mother |
It represents a mother |
Photo |
It represents a photo by storing the file path & resource id |
ProfileImage |
It represents the photo of an entity |
Report |
It represents a report |
MontlyReport |
It represents a monthly report |
Response |
It represents an HTTP response with status & payload |
ServiceProvided |
It represents a service that was provided to a patient |
TimelineEvent |
It represents an event within a patient's life eg. birth |
The domain object classes can be found in org.smartregister.domain
. There are several domains namely: global domain, form and database domain.
This app provides the following sync capabilities:
The sync classes can be found in org.smartregister.sync
This app provides the following utilities:
Class | Provides |
---|---|
BitmapImageCache |
Improved image caching |
Cache |
Data caching and modifications listener |
FileUtilities |
File storage utility |
FloatUtil |
Float conversion utility |
FormSubmissionBuilder |
Form submission builders |
FormUtils |
Form generation and manipulation utility |
IntegerUtil |
Integer conversion utility |
JsonFormUtils |
JSON form data extractor and injector |
OpenSRPImageLoader |
Asynchronous image downloader with thread-safe image caching |
Session |
Session manager |
StringUtil |
String manipulation utility |
TimelineEventComparator |
Timeline event comparator |
Utils |
Date conversion, android preference manipulator, view generator, metrics humanizer among other basic utility functions. |
AppExecutors |
Provides implementation of the executor interface that allows grouping request. Grouping tasks like this avoids the effects of task starvation (e.g. disk reads don't wait behind webservice requests) |
The utility classes can be found under org.smartregister.util
This app provides business logic for operations as follows:
Class | Business logic related to |
---|---|
ActionService |
Actions |
AlertService |
Alerts |
AllFormVersionSyncService |
Form versions |
ANMService |
Health service providers |
BeneficiaryService |
Beneficiaries |
ChildService |
Children |
Drishti |
Form submissions |
MotherService |
Mothers |
ServiceProvidedService |
Services provided |
The service classes can be found in org.smartregister.service
This app provides capability to support multiple languages.
Check out the sample app to see how to implement language switching.
Ensure each class in your app extends (directly or indirectly) a class in client-core. If it doesn't then extend MultiLanguageActivity instead of AppCompatActivity.
The package compression
contains an interface ICompression
whose methods are Implemented using the GZIPCompression class (which uses a GZIP implementation)
Other compression Algorithms can be used by adding a new class implementing the interface methods.
Methods in the ICompression interface are
byte[] compress(String rawString) Compress the given string input
String decompress(byte[] compressedBytes) Decompress a byte array of compressed data
void compress(String inputFilePath, String compressedOutputFilepath) Compress file in file path inputFilePath
and output to location compressedOutputFilepath
void decompress(String compressedInputFilePath, String decompressedOutputFilePath) Decompress file in file path compressedInputFilePath
and output to location decompressedOutputFilePath
You can quickly bootstrap view generation that take the format of a Register
or Profile
using the package org.smartregister.view
. Views that render a Register can extend the BaseRegisterFragment
that implements basic register functionality such as searching, listing, sorting and counting number of records on the generic base view whilst reading a cursor
object.
For views that display a generic List of items but require heavier customization, using the org.smartregister.view.fragment.BaseListFragment<T>
allows you to render any generic list while providing a context
aware background executor and error handling that only requires provisioning or Callable
function to act as a data source.
Check the Sample app's ReportFragment
that consumes a Retrofit
response and renders a list of objects.
By placing a file named app.properties
in your implementation assets folder (See sample app) , one can configure certain aspects of the app
Configuration | Type | Default | Description |
---|---|---|---|
system.toaster.centered |
Boolean | false | Position toaster(s) at the center of the view(s) |
disable.location.picker.view |
Boolean | false | Disables LocationPicker View |
location.picker.tag.shown |
Boolean | false | Hides/Shows the location tag in the location picker tree view |
encrypt.shared.preferences |
Boolean | false | Enable/disables encrypting SharedPreferences |
allow.offline.login.with.invalid.token |
Boolean | false | Allow offline login when token is no longer valid after a successful login when online and user is forcefully logged out |
enable.search.button |
Boolean | false | Enable/Disable search to be triggered only after clicking the search icon in org.smartregister.view.fragment.BaseRegisterFragment or its subclass |
feature.profile.images.disabled |
Boolean | false | Disable profile image capturing and rendering |