public abstract class DataProvider
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ERROR_CONSENT_REQUIRED |
static java.lang.String |
ERROR_NOT_AUTHENTICATED |
Constructor and Description |
---|
DataProvider()
Default Constructor
|
Modifier and Type | Method and Description |
---|---|
abstract rx.Observable<DataResponse> |
forgotPassword(android.content.Context context,
java.lang.String email)
Called during sign-in if the user has forgotten their password.
|
static DataProvider |
getInstance()
Returns the singleton instance of this class.
|
abstract User |
getUser(android.content.Context context)
Returns the user object that contains any sort of information.
|
abstract java.lang.String |
getUserEmail(android.content.Context context)
Returns the email that the user used to sign in / up
|
abstract java.lang.String |
getUserSharingScope(android.content.Context context)
Gets the current sharing scope of the user.
|
static void |
init(DataProvider instance)
Initializes the DataProvider singleton.
|
abstract rx.Observable<DataResponse> |
initialize(android.content.Context context)
Called in
SplashActivity to initialize the state of the app. |
abstract boolean |
isConsented(android.content.Context context)
Returns true if user is currently consented to the study
|
abstract boolean |
isSignedIn(android.content.Context context)
Returns true if user is currently signed in
|
abstract boolean |
isSignedUp(android.content.Context context)
Returns true if user is currently signed up
|
abstract org.researchstack.backbone.task.Task |
loadTask(android.content.Context context,
SchedulesAndTasksModel.TaskScheduleModel task)
Loads a Task object, this should be used in conjunction with the
ResourceManager if
inflating a Task from assets folder |
abstract SchedulesAndTasksModel |
loadTasksAndSchedules(android.content.Context context)
Loads the SchedulesAndTasksModel object, this should be used in conjunction with the
ResourceManager if inflating the TaskAndSchedules object from assets folder |
abstract void |
processInitialTaskResult(android.content.Context context,
org.researchstack.backbone.result.TaskResult taskResult)
This initial task may include profile items such as height and weight that may need to be
processed differently than a normal task result.
|
abstract rx.Observable<DataResponse> |
resendEmailVerification(android.content.Context context,
java.lang.String email)
Called in
EmailVerificationActivity to alert the backend to resend a vertification
email |
abstract void |
saveConsent(android.content.Context context,
org.researchstack.backbone.result.TaskResult consentResult)
This method is responsible in saving user consent information (e.g.
|
abstract void |
setUserSharingScope(android.content.Context context,
java.lang.String scope)
Sets the current sharing scope of the user.
|
abstract rx.Observable<DataResponse> |
signIn(android.content.Context context,
java.lang.String username,
java.lang.String password)
Called in
SignUpStepLayout to sign the user in to the backend service |
abstract rx.Observable<DataResponse> |
signOut(android.content.Context context)
Currently not used within the framework
|
abstract rx.Observable<DataResponse> |
signUp(android.content.Context context,
java.lang.String email,
java.lang.String username,
java.lang.String password)
Called in
SignUpStepLayout to sign the user up to the backend service |
abstract void |
uploadConsent(android.content.Context context,
org.researchstack.backbone.result.TaskResult consentResult)
This method is responsible in uploading the user consent information (e.g.
|
abstract void |
uploadTaskResult(android.content.Context context,
org.researchstack.backbone.result.TaskResult taskResult)
Method used to upload a TaskResult to the backend
|
abstract rx.Observable<DataResponse> |
withdrawConsent(android.content.Context context,
java.lang.String reason)
Called in
SettingsFragment to alert the backend that the user wants to withdraw from
the study |
public static final java.lang.String ERROR_NOT_AUTHENTICATED
public static final java.lang.String ERROR_CONSENT_REQUIRED
public static DataProvider getInstance()
public static void init(DataProvider instance)
Application.onCreate()
method.instance
- an implementation of DataProviderpublic abstract rx.Observable<DataResponse> initialize(android.content.Context context)
SplashActivity
to initialize the state of the app. The state includes if
the user is not signed in/up, not consented, etc..context
- android contextDataResponse.isSuccess()
returning true if signUp was successfulpublic abstract rx.Observable<DataResponse> signUp(android.content.Context context, java.lang.String email, java.lang.String username, java.lang.String password)
SignUpStepLayout
to sign the user up to the backend servicecontext
- android contextDataResponse.isSuccess()
returning true if signUp was successfulpublic abstract rx.Observable<DataResponse> signIn(android.content.Context context, java.lang.String username, java.lang.String password)
SignUpStepLayout
to sign the user in to the backend servicecontext
- android contextDataResponse.isSuccess()
returning true if signIn was successfulpublic abstract rx.Observable<DataResponse> signOut(android.content.Context context)
context
- android contextDataResponse.isSuccess()
returning true if signOut was successfulpublic abstract rx.Observable<DataResponse> resendEmailVerification(android.content.Context context, java.lang.String email)
EmailVerificationActivity
to alert the backend to resend a vertification
emailcontext
- android contextDataResponse.isSuccess()
returning true if signIn was successfulpublic abstract boolean isSignedUp(android.content.Context context)
context
- android contextpublic abstract boolean isSignedIn(android.content.Context context)
context
- android contextpublic abstract boolean isConsented(android.content.Context context)
context
- android contextpublic abstract rx.Observable<DataResponse> withdrawConsent(android.content.Context context, java.lang.String reason)
SettingsFragment
to alert the backend that the user wants to withdraw from
the studycontext
- android contextDataResponse.isSuccess()
returning true if withdrawl was successfulpublic abstract void uploadConsent(android.content.Context context, org.researchstack.backbone.result.TaskResult consentResult)
context
- android contextpublic abstract void saveConsent(android.content.Context context, org.researchstack.backbone.result.TaskResult consentResult)
Please use FileAccess
class to encrypt user information when saving.
context
- android contextpublic abstract User getUser(android.content.Context context)
context
- android contextpublic abstract java.lang.String getUserSharingScope(android.content.Context context)
This scope can be:
context
- android contextpublic abstract void setUserSharingScope(android.content.Context context, java.lang.String scope)
context
- android contextscope
- the new sharing scope of the userpublic abstract java.lang.String getUserEmail(android.content.Context context)
context
- android contextpublic abstract void uploadTaskResult(android.content.Context context, org.researchstack.backbone.result.TaskResult taskResult)
context
- android contexttaskResult
- TaskResult object to uploadpublic abstract SchedulesAndTasksModel loadTasksAndSchedules(android.content.Context context)
ResourceManager
if inflating the TaskAndSchedules object from assets foldercontext
- android contextpublic abstract org.researchstack.backbone.task.Task loadTask(android.content.Context context, SchedulesAndTasksModel.TaskScheduleModel task)
ResourceManager
if
inflating a Task from assets foldercontext
- android contexttask
- the TaskScheduleModel modelpublic abstract void processInitialTaskResult(android.content.Context context, org.researchstack.backbone.result.TaskResult taskResult)
MainActivity
context
- android contexttaskResult
- initial TaskResult object to processpublic abstract rx.Observable<DataResponse> forgotPassword(android.content.Context context, java.lang.String email)
context
- android contextemail
- email of the userDataResponse.isSuccess()
returning true if forgitpassword request was successful