Browse Source

Gave GettingStartedActivity a makeover. Changed System.out.println() calls to Log calls. Moved services into their own package.

Víctor Hernández 3 years ago
parent
commit
90984eca1d

+ 1
- 1
app/src/main/AndroidManifest.xml View File

@@ -118,7 +118,7 @@
118 118
             android:name="com.google.firebase.messaging.default_notification_channel_id"
119 119
             android:value="default_notification_channel_id"/>
120 120
 
121
-        <service android:name=".MyFirebaseMessagingService">
121
+        <service android:name=".services.MyFirebaseMessagingService">
122 122
             <intent-filter>
123 123
                 <action android:name="com.google.firebase.MESSAGING_EVENT" />
124 124
             </intent-filter>

+ 6
- 5
app/src/main/java/uprrp/tania/SNSRegister.java View File

@@ -1,6 +1,7 @@
1 1
 package uprrp.tania;
2 2
 
3 3
 import android.os.AsyncTask;
4
+import android.util.Log;
4 5
 
5 6
 import com.amazonaws.auth.CognitoCachingCredentialsProvider;
6 7
 import com.amazonaws.services.sns.AmazonSNSClient;
@@ -46,7 +47,7 @@ public class SNSRegister extends AsyncTask <String, Void, String> {
46 47
             createNeeded = false;
47 48
         }
48 49
 
49
-        System.out.println("Retrieving platform endpoint data...");
50
+        Log.i(TAG, "Retrieving platform endpoint data...");
50 51
         // Look up the platform endpoint and make sure the data in it is current, even if
51 52
         // it was just created.
52 53
         try {
@@ -70,12 +71,12 @@ public class SNSRegister extends AsyncTask <String, Void, String> {
70 71
             createEndpoint(token);
71 72
         }
72 73
 
73
-        System.out.println("updateNeeded = " + updateNeeded);
74
+        Log.d(TAG, "updateNeeded = " + updateNeeded);
74 75
 
75 76
         if (updateNeeded) {
76 77
             // The platform endpoint is out of sync with the current data;
77 78
             // update the token and enable it.
78
-            System.out.println("Updating platform endpoint " + endpointArn);
79
+            Log.d(TAG, "Updating platform endpoint " + endpointArn);
79 80
             Map attribs = new HashMap();
80 81
             attribs.put("Token", token);
81 82
             attribs.put("Enabled", "true");
@@ -96,7 +97,7 @@ public class SNSRegister extends AsyncTask <String, Void, String> {
96 97
 
97 98
         String endpointArn = null;
98 99
         try {
99
-            System.out.println("Creating platform endpoint with token " + token);
100
+            Log.d(TAG, "Creating platform endpoint with token " + token);
100 101
             CreatePlatformEndpointRequest cpeReq =
101 102
                     new CreatePlatformEndpointRequest()
102 103
                             .withPlatformApplicationArn("arn:aws:sns:us-east-1:227586183436:app/GCM/TANIA_Android")
@@ -106,7 +107,7 @@ public class SNSRegister extends AsyncTask <String, Void, String> {
106 107
             endpointArn = cpeRes.getEndpointArn();
107 108
         } catch (InvalidParameterException ipe) {
108 109
             String message = ipe.getErrorMessage();
109
-            System.out.println("Exception message: " + message);
110
+            Log.d(TAG, "Exception message: " + message);
110 111
             Pattern p = Pattern
111 112
                     .compile(".*Endpoint (arn:aws:sns[^ ]+) already exists " +
112 113
                             "with the same token.*");

+ 3
- 3
app/src/main/java/uprrp/tania/activities/GettingStartedActivity.java View File

@@ -77,6 +77,8 @@ public class GettingStartedActivity extends AppCompatActivity {
77 77
         // Attach onClick listeners to buttons
78 78
         Button createAccountButton = findViewById(R.id.buttonCreateAccount);
79 79
         Button loginAccountButton = findViewById(R.id.buttonRecoverAccount);
80
+        createAccountButton.setTransformationMethod(null); // TODO: this is a workaround I found, any other acceptable solution is welcome
81
+        loginAccountButton.setTransformationMethod(null); // TODO: this is a workaround I found, any other acceptable solution is welcome
80 82
         createAccountButton.setOnClickListener(new View.OnClickListener() {
81 83
             @Override
82 84
             public void onClick(View v) {
@@ -112,6 +114,7 @@ public class GettingStartedActivity extends AppCompatActivity {
112 114
     }
113 115
 
114 116
 
117
+    // TODO: decide which parts in this function to move to a background task
115 118
     private void processConsentResult(TaskResult result) {
116 119
 
117 120
         boolean consented = (boolean) result.getStepResult(CONSENT_DOC).getResult();
@@ -478,6 +481,3 @@ public class GettingStartedActivity extends AppCompatActivity {
478 481
 
479 482
     }
480 483
 }
481
-
482
-
483
-

app/src/main/java/uprrp/tania/MyFirebaseMessagingService.java → app/src/main/java/uprrp/tania/services/MyFirebaseMessagingService.java View File

@@ -1,4 +1,4 @@
1
-package uprrp.tania;
1
+package uprrp.tania.services;
2 2
 
3 3
 import com.google.firebase.messaging.FirebaseMessagingService;
4 4
 import com.google.firebase.messaging.RemoteMessage;
@@ -17,6 +17,7 @@ import android.util.Log;
17 17
 import androidx.core.app.NotificationCompat;
18 18
 import androidx.core.app.NotificationManagerCompat;
19 19
 
20
+import uprrp.tania.R;
20 21
 import uprrp.tania.activities.MainActivity;
21 22
 
22 23
 public class MyFirebaseMessagingService extends FirebaseMessagingService {

+ 75
- 59
app/src/main/res/layout/activity_getting_started.xml View File

@@ -8,100 +8,116 @@
8 8
     android:background="@color/rsb_white_60">
9 9
 
10 10
     <ImageView
11
-        android:id="@+id/bubble3"
12
-        android:layout_width="69dp"
13
-        android:layout_height="25dp"
14
-        app:layout_constraintBottom_toTopOf="@+id/buttonRecoverAccount"
11
+        android:id="@+id/bubble1"
12
+        android:layout_width="@dimen/bubbleSize"
13
+        android:layout_height="@dimen/bubbleSize"
14
+        android:layout_marginStart="@dimen/horizontalMargin"
15
+        android:layout_marginTop="52dp"
16
+        android:layout_marginEnd="@dimen/horizontalMargin"
17
+        android:contentDescription="@string/bubbleDescription"
18
+        app:layout_constraintBottom_toTopOf="@+id/bubble2"
15 19
         app:layout_constraintEnd_toEndOf="parent"
16 20
         app:layout_constraintStart_toStartOf="parent"
17
-        app:layout_constraintTop_toBottomOf="@+id/applicationNameMeaning"
21
+        app:layout_constraintTop_toBottomOf="@+id/applicationNameLong"
18 22
         app:srcCompat="@drawable/circle" />
19 23
 
20 24
     <ImageView
21 25
         android:id="@+id/bubble2"
22
-        android:layout_width="69dp"
23
-        android:layout_height="25dp"
26
+        android:layout_width="@dimen/bubbleSize"
27
+        android:layout_height="@dimen/bubbleSize"
28
+        android:layout_marginStart="@dimen/horizontalMargin"
29
+        android:layout_marginTop="28dp"
30
+        android:layout_marginEnd="@dimen/horizontalMargin"
31
+        android:contentDescription="@string/bubbleDescription"
24 32
         app:layout_constraintBottom_toTopOf="@+id/bubble3"
25 33
         app:layout_constraintEnd_toEndOf="parent"
26 34
         app:layout_constraintStart_toStartOf="parent"
27
-        app:layout_constraintTop_toBottomOf="@+id/applicationNameMeaning"
28
-        app:layout_constraintVertical_bias="0.756"
35
+        app:layout_constraintTop_toBottomOf="@id/bubble1"
36
+        app:srcCompat="@drawable/circle" />
37
+
38
+    <ImageView
39
+        android:id="@+id/bubble3"
40
+        android:layout_width="@dimen/bubbleSize"
41
+        android:layout_height="@dimen/bubbleSize"
42
+        android:layout_marginStart="@dimen/horizontalMargin"
43
+        android:layout_marginTop="28dp"
44
+        android:layout_marginEnd="@dimen/horizontalMargin"
45
+        android:contentDescription="@string/bubbleDescription"
46
+        app:layout_constraintBottom_toTopOf="@id/buttonCreateAccount"
47
+        app:layout_constraintEnd_toEndOf="parent"
48
+        app:layout_constraintStart_toStartOf="parent"
49
+        app:layout_constraintTop_toBottomOf="@id/bubble2"
29 50
         app:srcCompat="@drawable/circle" />
30 51
 
31 52
     <TextView
32 53
         android:id="@+id/ApplicationName"
33
-        android:layout_width="259dp"
34
-        android:layout_height="98dp"
35
-        android:fontFamily="@font/acme"
36
-        android:text="TANIA"
54
+        android:layout_width="0dp"
55
+        android:layout_height="wrap_content"
56
+        android:layout_marginStart="@dimen/horizontalMargin"
57
+        android:layout_marginTop="128dp"
58
+        android:layout_marginEnd="@dimen/horizontalMargin"
59
+        android:fontFamily="@font/cabin"
60
+        android:text="@string/appName"
37 61
         android:textAlignment="center"
38 62
         android:textColor="@color/colorPrimary"
39 63
         android:textSize="80sp"
40
-        app:layout_constraintBottom_toBottomOf="parent"
64
+        android:textStyle="bold"
41 65
         app:layout_constraintEnd_toEndOf="parent"
42 66
         app:layout_constraintStart_toStartOf="parent"
43
-        app:layout_constraintTop_toTopOf="parent"
44
-        app:layout_constraintVertical_bias="0.23" />
67
+        app:layout_constraintTop_toTopOf="parent" />
45 68
 
46 69
     <TextView
47
-        android:id="@+id/applicationNameMeaning"
48
-        android:layout_width="336dp"
49
-        android:layout_height="50dp"
50
-        android:fontFamily="@font/acme"
51
-        android:text="Timely And Non-Intrusive Assessments"
70
+        android:id="@+id/applicationNameLong"
71
+        android:layout_width="0dp"
72
+        android:layout_height="wrap_content"
73
+        android:layout_marginStart="@dimen/horizontalMargin"
74
+        android:layout_marginEnd="@dimen/horizontalMargin"
75
+        android:fontFamily="@font/cabin"
76
+        android:text="@string/appNameLong"
52 77
         android:textAlignment="center"
53
-        android:textColor="@color/colorPrimary"
54 78
         android:textSize="18sp"
55
-        app:layout_constraintBottom_toBottomOf="parent"
56 79
         app:layout_constraintEnd_toEndOf="parent"
57
-        app:layout_constraintHorizontal_bias="0.493"
58 80
         app:layout_constraintStart_toStartOf="parent"
59
-        app:layout_constraintTop_toBottomOf="@+id/ApplicationName"
60
-        app:layout_constraintVertical_bias="0.0" />
81
+        app:layout_constraintTop_toBottomOf="@+id/ApplicationName" />
61 82
 
62 83
     <Button
63 84
         android:id="@+id/buttonCreateAccount"
64
-        android:layout_width="284dp"
65
-        android:layout_height="60dp"
66
-        android:backgroundTint="@color/colorPrimary"
67
-        android:fontFamily="sans-serif-medium"
68
-        android:text="@string/rss_join_study"
69
-        android:textAlignment="center"
70
-        android:textColor="@color/rsb_white_60"
71
-        android:textSize="18sp"
85
+        android:layout_width="0dp"
86
+        android:layout_height="wrap_content"
87
+        android:layout_marginStart="@dimen/horizontalMargin"
88
+        android:layout_marginTop="52dp"
89
+        android:layout_marginEnd="@dimen/horizontalMargin"
90
+        android:background="@drawable/button_background"
91
+        android:fontFamily="sans-serif-black"
92
+        android:paddingHorizontal="@dimen/buttonHorizontalPadding"
93
+        android:paddingVertical="@dimen/buttonVerticalPadding"
94
+        android:text="@string/createAccountButtonText"
95
+        android:textColor="@android:color/white"
96
+        android:textSize="@dimen/buttonTextSize"
72 97
         android:textStyle="bold"
73
-        app:layout_constraintBottom_toBottomOf="parent"
74 98
         app:layout_constraintEnd_toEndOf="parent"
99
+        app:layout_constraintHeight_max="@dimen/buttonMaxHeight"
75 100
         app:layout_constraintStart_toStartOf="parent"
76
-        app:layout_constraintTop_toBottomOf="@+id/bubble3"
77
-        app:layout_constraintVertical_bias="0.163" />
101
+        app:layout_constraintTop_toBottomOf="@id/bubble3" />
78 102
 
79 103
     <Button
80 104
         android:id="@+id/buttonRecoverAccount"
81
-        android:layout_width="284dp"
82
-        android:layout_height="60dp"
83
-        android:layout_marginStart="60dp"
84
-        android:layout_marginTop="120dp"
85
-        android:layout_marginEnd="60dp"
86
-        android:backgroundTint="@color/colorPrimary"
87
-        android:fontFamily="@font/acme"
88
-        android:text="Log In"
89
-        android:textColor="@color/rsb_white_60"
90
-        android:textSize="18sp"
105
+        android:layout_width="0dp"
106
+        android:layout_height="wrap_content"
107
+        android:layout_marginStart="@dimen/horizontalMargin"
108
+        android:layout_marginTop="16dp"
109
+        android:layout_marginEnd="@dimen/horizontalMargin"
110
+        android:background="@drawable/button_background"
111
+        android:fontFamily="sans-serif-black"
112
+        android:paddingHorizontal="@dimen/buttonHorizontalPadding"
113
+        android:paddingVertical="@dimen/buttonVerticalPadding"
114
+        android:text="@string/recoverAccountButtonText"
115
+        android:textColor="@android:color/white"
116
+        android:textSize="@dimen/buttonTextSize"
91 117
         android:textStyle="bold"
92
-        app:layout_constraintBottom_toBottomOf="parent"
93 118
         app:layout_constraintEnd_toEndOf="parent"
119
+        app:layout_constraintHeight_max="@dimen/buttonMaxHeight"
94 120
         app:layout_constraintStart_toStartOf="parent"
95
-        app:layout_constraintTop_toBottomOf="@+id/applicationNameMeaning"
96
-        app:layout_constraintVertical_bias="0.416" />
121
+        app:layout_constraintTop_toBottomOf="@id/buttonCreateAccount" />
97 122
 
98
-    <ImageView
99
-        android:id="@+id/bubble1"
100
-        android:layout_width="69dp"
101
-        android:layout_height="25dp"
102
-        app:layout_constraintBottom_toTopOf="@+id/bubble2"
103
-        app:layout_constraintEnd_toEndOf="parent"
104
-        app:layout_constraintStart_toStartOf="parent"
105
-        app:layout_constraintTop_toBottomOf="@+id/applicationNameMeaning"
106
-        app:srcCompat="@drawable/circle" />
107 123
 </androidx.constraintlayout.widget.ConstraintLayout>

+ 1
- 0
app/src/main/res/values/dimens.xml View File

@@ -13,4 +13,5 @@
13 13
     <dimen name="sectionDescriptionTextSize">20sp</dimen>
14 14
     <dimen name="buttonTextSize">24sp</dimen>
15 15
     <dimen name="mainActivityToolbarHeight">54dp</dimen>
16
+    <dimen name="bubbleSize">18dp</dimen>
16 17
 </resources>

+ 9
- 5
app/src/main/res/values/strings.xml View File

@@ -32,6 +32,7 @@
32 32
 <!--    <string name="loginBaseURL">https://tania.uprrp.edu/recoverAccount.php</string>-->
33 33
     <!--  General App Configurations  -->
34 34
     <string name="appName">TANIA</string>
35
+    <string name="appNameLong">Timely And Non-Intrusive Assessments</string>
35 36
     <string name="surveyToolbarText">Assessment</string>
36 37
     <string name="tokenErrorText">There was an error…\nPlease come back later!</string>
37 38
     <!--  Assessment Fragment  -->
@@ -58,20 +59,23 @@
58 59
     <string name="consentGeneral">If you decide to participate in this study, understand that your participation is completely voluntary and that you have the right to abstain from participating or even withdraw at any time of the study without incurring in any penalty. In the application you will find the instructions to withdraw from the study and stop receiving notifications if you wish. You also have the right not to answer any question if you wish. Your participation in this study will not affect in any way your academic evaluation in the courses in which you are carrying out this research. Finally, you have the right to receive a copy of this document.</string>
59 60
     <string name="consentConclusion">If you have any questions or would like more information about this study, please contact Prof. Ramírez Lugo at 787-764-0000 Ext. 88068, at 787-918-5330 or by email at juan.ramirez3@upr.edu at any moment. If you have any questions about your rights as a participant or claim or complaint related to your participation in this study, you may contact the Compliance Officer of the Río Piedras Campus of the University of Puerto Rico, at telephone 764-0000, extension 86773 or cipshi. degi@upr.edu. Your signature on this document means that you have decided to participate voluntarily, that the information presented on this Consent Sheet has been discussed and that you have received a copy of this document. This printed sheet will be stored under lock and key for a period of 5 years after completion of the investigation and will then be shredded and discarded.</string>
60 61
     <!--  Getting Started Activity  -->
62
+    <string name="createAccountButtonText">Join the Study</string>
63
+    <string name="recoverAccountButtonText">Login</string>
64
+    <string name="overviewTitleText">Welcome</string>
61 65
     <string name="overviewConsentSectionSummaryText">You have been invited to participate in this study whose objectives are (1) to develop and demonstrate the utility of a mobile application (TANIA) to collect perception data of students participating in research experiences and (2) to use TANIA to determine the sources of self-efficacy that lead to career exploration and decision-making in undergraduate students.</string>
62 66
     <string name="overviewConsentSectionContentText">This study is been carried out under the supervision of Dr. Juan S. Ramírez Lugo, Department of Biology and Dr. Carlos Corrada Bravo, Department of Computer Sciences at the University of Puerto Rico, Río Piedras Campus. You were selected to participate in this study because you are enrolled in a course that offers a research experience or you voluntarily participate in research with a professor affiliated to the Río Piedras Campus.</string>
67
+    <string name="timeCommitmentTitleText">Time Commitment</string>
63 68
     <string name="timeCommitmentConsentSectionContentText">You are also expected to respond to short questionnaires between 1-3 times per week while you are participating in the research. You will receive notifications at random times during your research experience and answer questions adapted from survey instruments that have been previously validated. It will take you between 1-3 minutes to answer these questionnaires. It is expected that 25 students will participate in this phase of the study.</string>
64 69
     <string name="timeCommitmentConsentSectionSummaryText">In the study you will be asked to answer a questionnaire, about your perception of self-efficacy in research, scientific identity and decision-making about your professional career at the beginning and end of your research experience. It will take you between 10-20 minutes to answer this questionnaire.</string>
70
+    <string name="dataGatheringTitleText">Data Gathering</string>
65 71
     <string name="dataGatheringConsentSectionSummaryText">While answering the questions, you may feel uncomfortable because the questions are about your general opinion about science and research and your career. If you feel uncomfortable with the questions, you can stop and choose not to answer the question.</string>
66 72
     <string name="dataGatheringConsentSectionContentText">In addition, when you download the application, it will occupy space in the memory of your mobile device and also consume your data plan in the transmission of information when you answer the questionnaires. It is estimated that the application will have a size of 40 Mb (As reference the WhatsApp application is 88.9 Mb). Although at the moment we cannot say exactly how much memory or data you will consume, we understand that both will be minimal. The risks of this study are minimal.</string>
73
+    <string name="privacyTitleText">Privacy</string>
67 74
     <string name="privacyConsentSectionSummaryText">Your identity will be protected throughout the study. Your identifiable information will be handled confidentially and when presenting the results of the investigation you will not be identified.</string>
68 75
     <string name="privacyConsentSectionContentText">The information you issue through the application will be through access credentials (username and password) that only you will know. These access credentials will be encrypted and any subsequent association between you and your data will be made by reference to the encrypted information, not your personal identity. The data collected through the questionnaires will be stored digitally on a secure hard drive in the researcher\'s office. These data will also be stored virtually in the cloud, with access limited only to researchers.</string>
76
+    <string name="dataUseTitleText">Use of Data</string>
69 77
     <string name="dataUseConsentSectionSummaryText">The data obtained will be used to improve academic offerings and research experiences. The results of this study may be part of a scientific publication on science education strategies and will serve as a basis to improve the teaching curriculum.</string>
70 78
     <string name="dataUseConsentSectionContentText">It may be used to develop proposals for obtaining external funds for research. The officials of the Río Piedras Campus of the University of Puerto Rico and / or federal agencies responsible for ensuring the integrity of the research may require the researcher to prove the data obtained in this study, including this informed consent. The information handled by your device can be intervened or revised by third parties. These people can be people with legitimate or illegitimate access to the device and its content such as a family member, employer, hackers, intruders, etc. In addition, the device that you use may keep track of the information you access or send over the Internet.</string>
71
-    <string name="overviewTitleText">Welcome</string>
72
-    <string name="timeCommitmentTitleText">Time Commitment</string>
73
-    <string name="dataGatheringTitleText">Data Gathering</string>
74
-    <string name="privacyTitleText">Privacy</string>
75
-    <string name="dataUseTitleText">Use of Data</string>
76 79
     <string name="generalTitleText">General</string>
80
+    <string name="bubbleDescription">Just a blue bubble for decoration</string>
77 81
 </resources>