From 504a7b4a91d0d52dce7f79502cf7e79652dac4e8 Mon Sep 17 00:00:00 2001 From: Denzil Ferreira Date: Fri, 27 Mar 2020 15:34:28 +0200 Subject: [PATCH] - Add support for real HTTPS/HTTP URLs to join a study - Add support for pre-assigned participant IDs for study URL: append ?participant=xxx to the study URL to automatically prefill the onboarding --- aware-phone/src/main/AndroidManifest.xml | 18 +++++++--- .../com/aware/phone/ui/Aware_Join_Study.java | 36 +++++++++++-------- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 +-- 4 files changed, 37 insertions(+), 23 deletions(-) diff --git a/aware-phone/src/main/AndroidManifest.xml b/aware-phone/src/main/AndroidManifest.xml index e956459cf..aa40cc78d 100755 --- a/aware-phone/src/main/AndroidManifest.xml +++ b/aware-phone/src/main/AndroidManifest.xml @@ -75,6 +75,7 @@ android:theme="@style/Theme.Aware"> + @@ -126,10 +127,17 @@ android:theme="@style/Theme.Aware"> + - - + + + android:name="com.aware.Aware$AndroidPackageMonitor" + android:exported="true"> @@ -147,8 +156,7 @@ - + diff --git a/aware-phone/src/main/java/com/aware/phone/ui/Aware_Join_Study.java b/aware-phone/src/main/java/com/aware/phone/ui/Aware_Join_Study.java index cfb4fced6..c39b31a0d 100755 --- a/aware-phone/src/main/java/com/aware/phone/ui/Aware_Join_Study.java +++ b/aware-phone/src/main/java/com/aware/phone/ui/Aware_Join_Study.java @@ -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 @@ -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); } } @@ -376,6 +384,13 @@ 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(); } }); @@ -383,15 +398,6 @@ public void onClick(DialogInterface dialog, int which) { 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); diff --git a/build.gradle b/build.gradle index 69cd00df9..23327d857 100644 --- a/build.gradle +++ b/build.gradle @@ -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" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 195c914dc..bb268bbd3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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