Skip to content
This repository has been archived by the owner on Jun 18, 2023. It is now read-only.

Commit

Permalink
- Add support for real HTTPS/HTTP URLs to join a study
Browse files Browse the repository at this point in the history
- Add support for pre-assigned participant IDs for study URL: append ?participant=xxx to the study URL to automatically prefill the onboarding
  • Loading branch information
denzilferreira committed Mar 27, 2020
1 parent 8097102 commit 504a7b4
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 23 deletions.
18 changes: 13 additions & 5 deletions aware-phone/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
android:theme="@style/Theme.Aware">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Expand Down Expand Up @@ -126,10 +127,17 @@
android:theme="@style/Theme.Aware">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="aware" />
<data android:scheme="aware-ssl" />
<data
android:host="*"
android:pathPattern="/index.php/webservice/index/.*"
android:scheme="http" />
<data
android:host="*"
android:pathPattern="/index.php/webservice/index/.*"
android:scheme="https" />
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
Expand All @@ -138,7 +146,8 @@
<activity android:name=".ui.Aware_Participant" />

<receiver
android:name="com.aware.Aware$AndroidPackageMonitor" android:exported="true">
android:name="com.aware.Aware$AndroidPackageMonitor"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
Expand All @@ -147,8 +156,7 @@
</intent-filter>
</receiver>

<receiver
android:name="com.aware.Aware$AwareBoot">
<receiver android:name="com.aware.Aware$AwareBoot">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
Expand Down
36 changes: 21 additions & 15 deletions aware-phone/src/main/java/com/aware/phone/ui/Aware_Join_Study.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public class Aware_Join_Study extends Aware_Activity {
public static final String EXTRA_STUDY_URL = "study_url";

private static String study_url;
private static String onboarding;

private JSONArray study_configs;

@Override
Expand Down Expand Up @@ -95,12 +97,18 @@ public void afterTextChanged(Editable s) {
//If we are getting here from an AWARE study link
String scheme = getIntent().getScheme();
if (scheme != null) {
if (Aware.DEBUG)
Log.d(Aware.TAG, "AWARE Link detected: " + getIntent().getDataString() + " SCHEME: " + scheme);
if (scheme.equalsIgnoreCase("aware")) {
study_url = getIntent().getDataString().replace("aware://", "http://");
} else if (scheme.equalsIgnoreCase("aware-ssl")) {
study_url = getIntent().getDataString().replace("aware-ssl://", "https://");

if (Aware.DEBUG) Log.d(Aware.TAG, "AWARE Link detected: " + getIntent().getDataString() + " SCHEME: " + scheme);

study_url = getIntent().getDataString();

Uri url = Uri.parse(study_url);
onboarding = url.getQueryParameter("participant");
if (onboarding != null) {
participant_label.setText(onboarding);
if (Aware.DEBUG) Log.d(Aware.TAG, "AWARE Study participant ID detected: " + onboarding);
study_url = study_url.substring(0,study_url.indexOf("participant")-1);
if (Aware.DEBUG) Log.d(Aware.TAG, "AWARE Study URL: " + study_url);
}
}

Expand Down Expand Up @@ -376,22 +384,20 @@ protected void onPostExecute(JSONObject result) {
@Override
public void onClick(DialogInterface dialog, int which) {
setResult(Activity.RESULT_CANCELED);

//Reset the webservice server status because this one is not valid
Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_WEBSERVICE, false);

Intent resetClient = new Intent(getApplicationContext(), Aware_Client.class);
resetClient.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(resetClient);
finish();
}
});
builder.setTitle("Study information");
builder.setMessage("Unable to retrieve this study information: " + study_url + "\nTry again.");
builder.show();

//Reset the webservice server status because this one is not valid
Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_WEBSERVICE, false);

Intent resetClient = new Intent(getApplicationContext(), Aware_Client.class);
resetClient.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(resetClient);

finish();

} else {
try {
Cursor dbStudy = Aware.getStudy(getApplicationContext(), study_url);
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ buildscript {
build_tools = "28.0.3"
aware_libs = "master-SNAPSHOT"
kotlin_version = '1.3.60'
build_gradle = '3.5.3'
build_gradle = '3.6.1'
anko_version = "0.10.8"
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Oct 03 15:15:49 EEST 2019
#Wed Mar 25 22:09:26 EET 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

0 comments on commit 504a7b4

Please sign in to comment.