Commit df0dd89f authored by Anuththara18's avatar Anuththara18

Sustained Attention Modifications

parent b240f4a0
......@@ -74,7 +74,9 @@
<activity
android:name=".sustained.BirdChoosingActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.NoActionBar" />
android:theme="@style/Theme.AppCompat.NoActionBar" >
</activity>
<activity
android:name=".focused.AnimalChoosingActivity"
android:screenOrientation="portrait"
......@@ -122,7 +124,8 @@
<activity
android:name=".sustained.SustainedAttentionGame1"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.NoActionBar" />
android:theme="@style/Theme.AppCompat.NoActionBar" >
</activity>
<activity
android:name=".focused.FocusedAttentionGame2"
android:screenOrientation="landscape"
......
......@@ -51,9 +51,9 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
/*Integer[] isi = { 10000, 45000, 25000, 50000, 20000, 35000, 60000, 15000, 30000, 55000, 40000,
10000, 45000, 25000, 50000, 20000, 35000, 60000, 15000, 30000, 55000, 40000,
10000, 15000, 10000, 15000 };*/
Integer[] isi = { 1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000,
1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000,
1000, 1500, 1000, 1500 };
Integer[] isi = { 1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000, 1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000, 1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000, 1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000, 1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000, 1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000, 1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000, 1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000, 1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000, 1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000, 1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000, 1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000,
1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000, 1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000, 1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000, 1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000, 1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000, 1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000, 1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000, 1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000, 1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000, 1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000, 1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000, 1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000,
1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000, };
Integer[] image = { R.drawable.red_bird_gif,
R.drawable.blue_bird_gif,
......@@ -79,6 +79,8 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
long totalReactionTime = 0;
int meanReactionTime = 0;
long seconds;
MediaPlayer mp, mp2;
@Override
......@@ -118,14 +120,21 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
@Override
public void run() {
if ( i <= 51 ) { // tot duration - 14.5 mins = 870000
//385000 , 770000, (50000)
// ms -> s /1000
// s -> m /60
if ( i <= 269 ) { // tot duration - 14.534 mins = 872000
//if (duration <= 870000) {
//385000 , 770000, (50000) = 1 205 000
// 38500, 77000
if ( i % 2 != 0 || totalCorrectResponses > 25 ) {
// 75000
if ( i % 2 != 0 ) {
randomImage = random.nextInt(6);
bird.setVisibility(View.INVISIBLE);
gifImageView.setVisibility(View.VISIBLE);
red_btn.setEnabled(true);
bird.setEnabled(true);
gifImageView.setImageResource(image[randomImage]);
clickedImage = image[randomImage];
updateInterval = isi[j];
......@@ -136,10 +145,11 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
j++;
}
// appearance - 0.5s * 25 times
else if ( totalCorrectResponses <= 25 ) {
else {
Log.d("radomTimer", String.valueOf(i + " 3000" ));
Log.d("******************************", "start 1");
bird.setVisibility(View.VISIBLE);
if (BirdChoosingActivity.birdSelected == 1) {
bird.setImageResource(R.drawable.blue_bird);
clickedImage = R.drawable.blue_bird;
......@@ -159,7 +169,7 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
}
bird.setVisibility(View.VISIBLE);
red_btn.setEnabled(true);
bird.setEnabled(true);
gifImageView.setVisibility(View.INVISIBLE);
startTime = System.currentTimeMillis();
gifImageView.postDelayed(this, 3000);
......@@ -171,17 +181,22 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
}
else {
long gameEnd = System.currentTimeMillis();
long seconds = (gameEnd - gameStart) / 1000;
meanReactionTime = (int) Math.ceil(totalReactionTime / noOfCorrectResponses); // ms
seconds = (gameEnd - gameStart);
if ( noOfCorrectResponses == 0 ) {
meanReactionTime = 0;
}
else {
meanReactionTime = (int) Math.ceil(totalReactionTime / noOfCorrectResponses); // ms
}
Log.d("****************************************************", "****************************************************");
Log.d("Game Time", String.valueOf(seconds));
Log.d("Game Time", String.valueOf(duration));
Log.d("total", String.valueOf(totalCorrectResponses));
Log.d("correctResponses", String.valueOf(noOfCorrectResponses));
noOfOmmissionErrors = totalCorrectResponses - noOfCorrectResponses;
Log.d("omissionErrors", String.valueOf(totalCorrectResponses - noOfCorrectResponses));
Log.d("commissionErrors", String.valueOf(noOfCommissionErrors));
Log.d("meanReactionTime", String.valueOf(meanReactionTime));
Log.d("duration", String.valueOf(duration));
Log.d("duration", String.valueOf(seconds));
saveDataToOnlineDB();
createTable();
saveDataToLocalDB();
......@@ -208,6 +223,36 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
}
red_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
long gameEnd = System.currentTimeMillis();
seconds = (gameEnd - gameStart);
if ( noOfCorrectResponses == 0 ) {
meanReactionTime = 0;
}
else {
meanReactionTime = (int) Math.ceil(totalReactionTime / noOfCorrectResponses); // ms
}
Log.d("****************************************************", "****************************************************");
Log.d("Game Time", String.valueOf(seconds));
Log.d("total", String.valueOf(totalCorrectResponses));
Log.d("correctResponses", String.valueOf(noOfCorrectResponses));
noOfOmmissionErrors = totalCorrectResponses - noOfCorrectResponses;
Log.d("omissionErrors", String.valueOf(totalCorrectResponses - noOfCorrectResponses));
Log.d("commissionErrors", String.valueOf(noOfCommissionErrors));
Log.d("meanReactionTime", String.valueOf(meanReactionTime));
Log.d("duration", String.valueOf(seconds));
saveDataToOnlineDB();
createTable();
saveDataToLocalDB();
Intent intent = new Intent(getApplicationContext(), SA1CompleteScreen.class);
finish();
mp.pause();
startActivity(intent);
}
});
bird.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
clickedTime = System.currentTimeMillis();
......@@ -218,7 +263,7 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
totalReactionTime = (long) (totalReactionTime + reactionTime);
Log.d("correct " , startTime + " " + clickedTime + " " + reactionTime);
noOfCorrectResponses++;
red_btn.setEnabled(false);
bird.setEnabled(false);
}
else {
noOfCommissionErrors++;
......@@ -297,7 +342,7 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
int no_of_ommission_errors = noOfOmmissionErrors;
int no_of_commission_errors = noOfCommissionErrors;
int mean_reaction_time = (int) meanReactionTime;
int total_duration = duration;
int total_duration = (int) seconds;
HashMap<String, Integer> params = new HashMap<>();
params.put("childID", child_ID);
......@@ -399,7 +444,7 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
int no_of_ommission_errors = noOfOmmissionErrors;
int no_of_commission_errors = noOfCommissionErrors;
int mean_reaction_time = (int) meanReactionTime;
int total_duration = duration;
int total_duration = (int) seconds;
String insertSQL = "INSERT INTO sustainedAttention \n" +
"(childID, totalCorrectResponses, noOfCorrectResponses, noOfCommissionErrors, noOfOmmissionErrors, meanReactionTime, totalDuration)\n" +
......
package com.anuththara18.attentionassessment.videos;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import android.app.DownloadManager;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.webkit.DownloadListener;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;
......@@ -24,14 +32,14 @@ public class IntroductoryVideoPortraitActivity extends AppCompatActivity {
//String videoUrl;
String videoUrl = "https://1drv.ms/v/s!AvtsEIqJweWzmFqPURb36VGZZJpp";
//String videoUrl = "https://drive.google.com/file/d/1Qt8C8Ucf0icgnLYdBSfhThm1nQbatGDa/view?usp=sharing";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_introductory_video);
// finding videoview by its id
VideoView videoView = findViewById(R.id.videoView);
/*
if (MainFragment.game.equals("focused")) {
videoUrl = "https://media.geeksforgeeks.org/wp-content/uploads/20201217192146/Screenrecorder-2020-12-17-19-17-36-828.mp4?_=1";
}
......@@ -45,31 +53,50 @@ public class IntroductoryVideoPortraitActivity extends AppCompatActivity {
videoUrl = "";
}
// Uri object to refer the
// resource from the videoUrl
Uri uri = Uri.parse(videoUrl);
*/
// sets the resource from the
// videoUrl to the videoView
videoView.setVideoURI(uri);
// creating object of
// media controller class
MediaController mediaController = new MediaController(this);
// initialising the web view
WebView wv = (WebView) findViewById(R.id.videoView);
// sets the anchor view
// anchor view for the videoView
mediaController.setAnchorView(videoView);
// add your link here
wv.loadUrl("https://drive.google.com/file/d/1Qt8C8Ucf0icgnLYdBSfhThm1nQbatGDa/view?usp=sharing");
//wv.loadUrl("https://1drv.ms/v/s!AvtsEIqJweWzmFqPURb36VGZZJpp");
wv.setWebViewClient(new Client());
WebSettings ws = wv.getSettings();
// sets the media player to the videoView
mediaController.setMediaPlayer(videoView);
// Enabling javascript
ws.setJavaScriptEnabled(true);
wv.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
wv.clearCache(true);
wv.clearHistory();
// sets the media controller to the videoView
videoView.setMediaController(mediaController);
// download manager is a service that can be used to handle downloads
wv.setDownloadListener(new DownloadListener() {
@Override
public void onDownloadStart(String url, String s1, String s2, String s3, long l) {
DownloadManager.Request req = new DownloadManager.Request(Uri.parse(url));
req.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
dm.enqueue(req);
Toast.makeText(IntroductoryVideoPortraitActivity.this, "Downloading....", Toast.LENGTH_SHORT).show();
}
});
// starts the video
/*
VideoView videoView = findViewById(R.id.videoView);
Uri uri = Uri.parse(videoUrl);
videoView.setVideoURI(uri);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
mediaController.setMediaPlayer(videoView);
videoView.setMediaController(mediaController);
videoView.start();
*/
/*
videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
......@@ -93,8 +120,57 @@ public class IntroductoryVideoPortraitActivity extends AppCompatActivity {
}
}
});
*/
}
private class Client extends WebViewClient {
// on page started load start loading the url
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
// load the url of our drive
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
}
public void onReceivedError(WebView webView, int errorCode, String description, String failingUrl) {
// if stop loading
try {
webView.stopLoading();
} catch (Exception e) {
}
if (webView.canGoBack()) {
webView.goBack();
}
// if loaded blank then show error
// to check internet connection using
// alert dialog
webView.loadUrl("about:blank");
AlertDialog alertDialog = new AlertDialog.Builder(IntroductoryVideoPortraitActivity.this).create();
alertDialog.setTitle("Error");
alertDialog.setMessage("Check your internet connection and Try again.");
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "Try Again", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
finish();
startActivity(getIntent());
}
});
alertDialog.show();
super.onReceivedError(webView, errorCode, description, failingUrl);
}
}
}
\ No newline at end of file
......@@ -7,11 +7,11 @@
android:orientation="vertical"
tools:context=".videos.IntroductoryVideoPortraitActivity">
<VideoView android:id="@+id/videoView"
<WebView android:id="@+id/videoView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true">
</VideoView>
</WebView>
</LinearLayout>
\ No newline at end of file
......@@ -21,7 +21,7 @@
<string name="optional">* විකල්ප</string>
<string name="req">* අවශ්යයි</string>
<string name="send">දත්ත යවන්න</string>
<string name="diagnosis">ඔබේ දරුවා අවධානය යොමු කිරීමේ දුර්වලතාවයකින් පෙළෙනවාද?</string>
<string name="diagnosis">ඔබේ දරුවා අවධානය යොමු කිරිමේදී යම් දුර්වලතාවයක් පෙන්නුම් කරන්නේද?</string>
<string name="select">තෝරන්න</string>
<string name="birdselect">ඔබ වඩාත්ම කැමති චරිතය තෝරන්න</string>
......
......@@ -20,7 +20,7 @@
<string name="optional">* Optional</string>
<string name="req">* Required</string>
<string name="send">Send Data</string>
<string name="diagnosis">Is your child suffering from any attention impairements?</string>
<string name="diagnosis">Does your child show any symptoms of attention impairements?</string>
<string name="select">Select the</string>
<string name="birdselect">Pick your favourite character</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment