Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
Research-Project
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jayakody J.A.D.K.A - IT19114040
Research-Project
Commits
20fbad9b
Commit
20fbad9b
authored
Mar 06, 2022
by
Anuththara18
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CSV File Generating in other assessments & Adding image of parent's signature to the PDF generated
parent
5885d509
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
358 additions
and
21 deletions
+358
-21
app/src/main/java/com/anuththara18/attentionassessment/alternating/AACompleteScreen.java
...a18/attentionassessment/alternating/AACompleteScreen.java
+88
-6
app/src/main/java/com/anuththara18/attentionassessment/dividedattention/DACompleteScreen.java
...ttentionassessment/dividedattention/DACompleteScreen.java
+90
-5
app/src/main/java/com/anuththara18/attentionassessment/focused/FACompleteScreen.java
...thara18/attentionassessment/focused/FACompleteScreen.java
+90
-5
app/src/main/java/com/anuththara18/attentionassessment/sustained/SA1CompleteScreen.java
...ra18/attentionassessment/sustained/SA1CompleteScreen.java
+90
-5
No files found.
app/src/main/java/com/anuththara18/attentionassessment/alternating/AACompleteScreen.java
View file @
20fbad9b
...
...
@@ -7,6 +7,7 @@ import android.database.sqlite.SQLiteDatabase;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.graphics.Canvas
;
import
android.graphics.Matrix
;
import
android.graphics.Paint
;
import
android.graphics.Typeface
;
import
android.graphics.pdf.PdfDocument
;
...
...
@@ -26,11 +27,15 @@ import androidx.core.content.ContextCompat;
import
com.anuththara18.attentionassessment.R
;
import
com.anuththara18.attentionassessment.age.AgeActivity
;
import
com.anuththara18.attentionassessment.consentform.ParentsConsentDatabaseHelper
;
import
com.anuththara18.attentionassessment.gender.GenderActivity
;
import
com.anuththara18.attentionassessment.home.NavigationDrawerActivity
;
import
com.anuththara18.attentionassessment.selective.Selective
;
import
com.opencsv.CSVWriter
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -55,7 +60,8 @@ public class AACompleteScreen extends AppCompatActivity {
// creating a bitmap variable
// for storing our images
Bitmap
bmp
,
scaledbmp
;
Bitmap
bmp
,
bmp2
,
scaledbmp
,
scaledbmp2
;
public
static
ParentsConsentDatabaseHelper
sqLiteHelper
;
// constant code for runtime permissions
private
static
final
int
PERMISSION_REQUEST_CODE
=
200
;
...
...
@@ -73,6 +79,8 @@ public class AACompleteScreen extends AppCompatActivity {
decorView
.
setSystemUiVisibility
(
uiOptions
);
setContentView
(
R
.
layout
.
activity_complete_screen2
);
sqLiteHelper
=
new
ParentsConsentDatabaseHelper
(
this
,
"ParentsConsent.sqlite"
,
null
,
1
);
complete
=
findViewById
(
R
.
id
.
complete
);
complete
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
...
...
@@ -84,16 +92,27 @@ public class AACompleteScreen extends AppCompatActivity {
}
});
dataList
=
new
ArrayList
<>();
/*******************************************************************************************/
//opening the database
mDatabase
=
openOrCreateDatabase
(
AlternatingAttentionGame1
.
DATABASE_NAME
,
MODE_PRIVATE
,
null
);
try
{
Cursor
cursor
=
sqLiteHelper
.
getData
(
"SELECT * FROM ParentsConsent"
);
while
(
cursor
.
moveToNext
())
{
byte
[]
image
=
cursor
.
getBlob
(
0
);
bmp2
=
BitmapFactory
.
decodeByteArray
(
image
,
0
,
image
.
length
);
//fingerprintImageView.setImageBitmap(bmp);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
/*******************************************************************************************/
// initializing our variables.
bmp
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
focused
);
bmp
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
alternative
);
scaledbmp
=
Bitmap
.
createScaledBitmap
(
bmp
,
140
,
140
,
false
);
//scaledbmp2 = Bitmap.createScaledBitmap(bmp2, 200, 200, false);
scaledbmp2
=
BITMAP_RESIZER
(
bmp2
,
400
,
400
);
// below code is used for
// checking our permissions.
...
...
@@ -105,6 +124,14 @@ public class AACompleteScreen extends AppCompatActivity {
/*******************************************************************************************/
dataList
=
new
ArrayList
<>();
//opening the database
mDatabase
=
openOrCreateDatabase
(
AlternatingAttentionGame1
.
DATABASE_NAME
,
MODE_PRIVATE
,
null
);
/*******************************************************************************************/
//this part will display the data in the list
//we used rawQuery(sql, selectionargs) for fetching all the employees
...
...
@@ -132,6 +159,42 @@ public class AACompleteScreen extends AppCompatActivity {
/*******************************************************************************************/
String
csv
=
(
Environment
.
getExternalStorageDirectory
().
getAbsolutePath
()
+
"/AlternatingAttention.csv"
);
// Here csv file name is MyCsvFile.csv
// csv will create inside phone storage.
CSVWriter
writer
=
null
;
try
{
writer
=
new
CSVWriter
(
new
FileWriter
(
csv
));
String
[]
entries
=
{
"id"
,
"child_id"
,
"total_correct_responses"
,
"correct_responses"
,
"commission_errors"
,
"omission_errors"
,
"mean_reaction_time"
,
"total_duration"
};
writer
.
writeNext
(
entries
);
List
<
String
[]>
data
=
new
ArrayList
<
String
[]>();
for
(
int
i
=
0
;
i
<
dataList
.
size
();
i
++)
{
Alternating
gameData
=
dataList
.
get
(
i
);
data
.
add
(
new
String
[]{
String
.
valueOf
(
gameData
.
getId
()),
String
.
valueOf
(
gameData
.
getChildID
()),
String
.
valueOf
(
gameData
.
getTotalCorrectResponses
()),
String
.
valueOf
(
gameData
.
getNoOfCorrectResponses
()),
String
.
valueOf
(
gameData
.
getNoOfCommissionErrors
()),
String
.
valueOf
(
gameData
.
getNoOfOmmissionErrors
()),
String
.
valueOf
(
gameData
.
getMeanReactionTime
()),
String
.
valueOf
(
gameData
.
getTotalDuration
())
});
}
writer
.
writeAll
(
data
);
// data is adding to csv
writer
.
close
();
//callRead();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
/*******************************************************************************************/
// generate our PDF file.
// creating an object variable
// for our PDF document.
...
...
@@ -164,6 +227,7 @@ public class AACompleteScreen extends AppCompatActivity {
// third parameter is position from top and last
// one is our variable for paint.
canvas
.
drawBitmap
(
scaledbmp
,
56
,
40
,
paint
);
canvas
.
drawBitmap
(
scaledbmp2
,
400
,
0
,
paint
);
// below line is used for adding typeface for
// our text which we will be adding in our PDF file.
...
...
@@ -338,4 +402,22 @@ public class AACompleteScreen extends AppCompatActivity {
/**************************************************************************************************/
public
Bitmap
BITMAP_RESIZER
(
Bitmap
bitmap
,
int
newWidth
,
int
newHeight
)
{
Bitmap
scaledBitmap
=
Bitmap
.
createBitmap
(
newWidth
,
newHeight
,
Bitmap
.
Config
.
ARGB_8888
);
float
ratioX
=
newWidth
/
(
float
)
bitmap
.
getWidth
();
float
ratioY
=
newHeight
/
(
float
)
bitmap
.
getHeight
();
float
middleX
=
newWidth
/
2.0f
;
float
middleY
=
newHeight
/
2.0f
;
Matrix
scaleMatrix
=
new
Matrix
();
scaleMatrix
.
setScale
(
ratioX
,
ratioY
,
middleX
,
middleY
);
Canvas
canvas
=
new
Canvas
(
scaledBitmap
);
canvas
.
setMatrix
(
scaleMatrix
);
canvas
.
drawBitmap
(
bitmap
,
middleX
-
bitmap
.
getWidth
()
/
2
,
middleY
-
bitmap
.
getHeight
()
/
2
,
new
Paint
(
Paint
.
FILTER_BITMAP_FLAG
));
return
scaledBitmap
;
}
}
app/src/main/java/com/anuththara18/attentionassessment/dividedattention/DACompleteScreen.java
View file @
20fbad9b
...
...
@@ -8,6 +8,7 @@ import android.database.sqlite.SQLiteDatabase;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.graphics.Canvas
;
import
android.graphics.Matrix
;
import
android.graphics.Paint
;
import
android.graphics.Typeface
;
import
android.graphics.pdf.PdfDocument
;
...
...
@@ -30,11 +31,15 @@ import androidx.core.content.FileProvider;
import
com.anuththara18.attentionassessment.BuildConfig
;
import
com.anuththara18.attentionassessment.R
;
import
com.anuththara18.attentionassessment.age.AgeActivity
;
import
com.anuththara18.attentionassessment.consentform.ParentsConsentDatabaseHelper
;
import
com.anuththara18.attentionassessment.gender.GenderActivity
;
import
com.anuththara18.attentionassessment.home.NavigationDrawerActivity
;
import
com.anuththara18.attentionassessment.selective.Selective
;
import
com.opencsv.CSVWriter
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -57,7 +62,8 @@ public class DACompleteScreen extends AppCompatActivity {
// creating a bitmap variable
// for storing our images
Bitmap
bmp
,
scaledbmp
;
Bitmap
bmp
,
bmp2
,
scaledbmp
,
scaledbmp2
;
public
static
ParentsConsentDatabaseHelper
sqLiteHelper
;
// constant code for runtime permissions
private
static
final
int
PERMISSION_REQUEST_CODE
=
200
;
...
...
@@ -75,6 +81,8 @@ public class DACompleteScreen extends AppCompatActivity {
decorView
.
setSystemUiVisibility
(
uiOptions
);
setContentView
(
R
.
layout
.
activity_complete_screen2
);
sqLiteHelper
=
new
ParentsConsentDatabaseHelper
(
this
,
"ParentsConsent.sqlite"
,
null
,
1
);
complete
=
findViewById
(
R
.
id
.
complete
);
complete
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
...
...
@@ -86,16 +94,27 @@ public class DACompleteScreen extends AppCompatActivity {
}
});
dataList
=
new
ArrayList
<>();
/*******************************************************************************************/
//opening the database
mDatabase
=
openOrCreateDatabase
(
DividedAttentionGame1
.
DATABASE_NAME
,
MODE_PRIVATE
,
null
);
try
{
Cursor
cursor
=
sqLiteHelper
.
getData
(
"SELECT * FROM ParentsConsent"
);
while
(
cursor
.
moveToNext
())
{
byte
[]
image
=
cursor
.
getBlob
(
0
);
bmp2
=
BitmapFactory
.
decodeByteArray
(
image
,
0
,
image
.
length
);
//fingerprintImageView.setImageBitmap(bmp);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
/*******************************************************************************************/
// initializing our variables.
bmp
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
divided
);
scaledbmp
=
Bitmap
.
createScaledBitmap
(
bmp
,
140
,
140
,
false
);
//scaledbmp2 = Bitmap.createScaledBitmap(bmp2, 200, 200, false);
scaledbmp2
=
BITMAP_RESIZER
(
bmp2
,
400
,
400
);
// below code is used for
// checking our permissions.
...
...
@@ -107,6 +126,13 @@ public class DACompleteScreen extends AppCompatActivity {
/*******************************************************************************************/
dataList
=
new
ArrayList
<>();
//opening the database
mDatabase
=
openOrCreateDatabase
(
DividedAttentionGame1
.
DATABASE_NAME
,
MODE_PRIVATE
,
null
);
/*******************************************************************************************/
//this part will display the data in the list
//we used rawQuery(sql, selectionargs) for fetching all the employees
...
...
@@ -134,6 +160,43 @@ public class DACompleteScreen extends AppCompatActivity {
/*******************************************************************************************/
String
csv
=
(
Environment
.
getExternalStorageDirectory
().
getAbsolutePath
()
+
"/DividedAttention.csv"
);
// Here csv file name is MyCsvFile.csv
// csv will create inside phone storage.
CSVWriter
writer
=
null
;
try
{
writer
=
new
CSVWriter
(
new
FileWriter
(
csv
));
String
[]
entries
=
{
"id"
,
"child_id"
,
"total_correct_responses"
,
"correct_responses"
,
"commission_errors"
,
"omission_errors"
,
"mean_reaction_time"
,
"total_duration"
};
writer
.
writeNext
(
entries
);
List
<
String
[]>
data
=
new
ArrayList
<
String
[]>();
for
(
int
i
=
0
;
i
<
dataList
.
size
();
i
++)
{
Divided
gameData
=
dataList
.
get
(
i
);
data
.
add
(
new
String
[]{
String
.
valueOf
(
gameData
.
getId
()),
String
.
valueOf
(
gameData
.
getChildID
()),
String
.
valueOf
(
gameData
.
getTotalCorrectResponses
()),
String
.
valueOf
(
gameData
.
getNoOfCorrectResponses
()),
String
.
valueOf
(
gameData
.
getNoOfCommissionErrors
()),
String
.
valueOf
(
gameData
.
getNoOfOmmissionErrors
()),
String
.
valueOf
(
gameData
.
getMeanReactionTime
()),
String
.
valueOf
(
gameData
.
getTotalDuration
())
});
}
writer
.
writeAll
(
data
);
// data is adding to csv
writer
.
close
();
//callRead();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
/*******************************************************************************************/
// generate our PDF file.
// creating an object variable
// for our PDF document.
...
...
@@ -166,6 +229,7 @@ public class DACompleteScreen extends AppCompatActivity {
// third parameter is position from top and last
// one is our variable for paint.
canvas
.
drawBitmap
(
scaledbmp
,
56
,
40
,
paint
);
canvas
.
drawBitmap
(
scaledbmp2
,
400
,
0
,
paint
);
// below line is used for adding typeface for
// our text which we will be adding in our PDF file.
...
...
@@ -340,4 +404,25 @@ public class DACompleteScreen extends AppCompatActivity {
/**************************************************************************************************/
public
Bitmap
BITMAP_RESIZER
(
Bitmap
bitmap
,
int
newWidth
,
int
newHeight
)
{
Bitmap
scaledBitmap
=
Bitmap
.
createBitmap
(
newWidth
,
newHeight
,
Bitmap
.
Config
.
ARGB_8888
);
float
ratioX
=
newWidth
/
(
float
)
bitmap
.
getWidth
();
float
ratioY
=
newHeight
/
(
float
)
bitmap
.
getHeight
();
float
middleX
=
newWidth
/
2.0f
;
float
middleY
=
newHeight
/
2.0f
;
Matrix
scaleMatrix
=
new
Matrix
();
scaleMatrix
.
setScale
(
ratioX
,
ratioY
,
middleX
,
middleY
);
Canvas
canvas
=
new
Canvas
(
scaledBitmap
);
canvas
.
setMatrix
(
scaleMatrix
);
canvas
.
drawBitmap
(
bitmap
,
middleX
-
bitmap
.
getWidth
()
/
2
,
middleY
-
bitmap
.
getHeight
()
/
2
,
new
Paint
(
Paint
.
FILTER_BITMAP_FLAG
));
return
scaledBitmap
;
}
/**************************************************************************************************/
}
app/src/main/java/com/anuththara18/attentionassessment/focused/FACompleteScreen.java
View file @
20fbad9b
...
...
@@ -8,6 +8,7 @@ import android.database.sqlite.SQLiteDatabase;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.graphics.Canvas
;
import
android.graphics.Matrix
;
import
android.graphics.Paint
;
import
android.graphics.Typeface
;
import
android.graphics.pdf.PdfDocument
;
...
...
@@ -30,11 +31,15 @@ import androidx.core.content.FileProvider;
import
com.anuththara18.attentionassessment.BuildConfig
;
import
com.anuththara18.attentionassessment.R
;
import
com.anuththara18.attentionassessment.age.AgeActivity
;;
import
com.anuththara18.attentionassessment.consentform.ParentsConsentDatabaseHelper
;
import
com.anuththara18.attentionassessment.gender.GenderActivity
;
import
com.anuththara18.attentionassessment.home.NavigationDrawerActivity
;
import
com.anuththara18.attentionassessment.selective.Selective
;
import
com.opencsv.CSVWriter
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -57,7 +62,8 @@ public class FACompleteScreen extends AppCompatActivity {
// creating a bitmap variable
// for storing our images
Bitmap
bmp
,
scaledbmp
;
Bitmap
bmp
,
bmp2
,
scaledbmp
,
scaledbmp2
;
public
static
ParentsConsentDatabaseHelper
sqLiteHelper
;
// constant code for runtime permissions
private
static
final
int
PERMISSION_REQUEST_CODE
=
200
;
...
...
@@ -75,6 +81,8 @@ public class FACompleteScreen extends AppCompatActivity {
decorView
.
setSystemUiVisibility
(
uiOptions
);
setContentView
(
R
.
layout
.
activity_complete_screen2
);
sqLiteHelper
=
new
ParentsConsentDatabaseHelper
(
this
,
"ParentsConsent.sqlite"
,
null
,
1
);
complete
=
findViewById
(
R
.
id
.
complete
);
complete
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
...
...
@@ -86,16 +94,27 @@ public class FACompleteScreen extends AppCompatActivity {
}
});
dataList
=
new
ArrayList
<>();
/*******************************************************************************************/
//opening the database
mDatabase
=
openOrCreateDatabase
(
FocusedAttentionGame1
.
DATABASE_NAME
,
MODE_PRIVATE
,
null
);
try
{
Cursor
cursor
=
sqLiteHelper
.
getData
(
"SELECT * FROM ParentsConsent"
);
while
(
cursor
.
moveToNext
())
{
byte
[]
image
=
cursor
.
getBlob
(
0
);
bmp2
=
BitmapFactory
.
decodeByteArray
(
image
,
0
,
image
.
length
);
//fingerprintImageView.setImageBitmap(bmp);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
/*******************************************************************************************/
// initializing our variables.
bmp
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
focused
);
scaledbmp
=
Bitmap
.
createScaledBitmap
(
bmp
,
140
,
140
,
false
);
//scaledbmp2 = Bitmap.createScaledBitmap(bmp2, 200, 200, false);
scaledbmp2
=
BITMAP_RESIZER
(
bmp2
,
400
,
400
);
// below code is used for
// checking our permissions.
...
...
@@ -107,6 +126,13 @@ public class FACompleteScreen extends AppCompatActivity {
/*******************************************************************************************/
dataList
=
new
ArrayList
<>();
//opening the database
mDatabase
=
openOrCreateDatabase
(
FocusedAttentionGame1
.
DATABASE_NAME
,
MODE_PRIVATE
,
null
);
/*******************************************************************************************/
//this part will display the data in the list
//we used rawQuery(sql, selectionargs) for fetching all the employees
...
...
@@ -134,6 +160,43 @@ public class FACompleteScreen extends AppCompatActivity {
/*******************************************************************************************/
String
csv
=
(
Environment
.
getExternalStorageDirectory
().
getAbsolutePath
()
+
"/FocusedAttention.csv"
);
// Here csv file name is MyCsvFile.csv
// csv will create inside phone storage.
CSVWriter
writer
=
null
;
try
{
writer
=
new
CSVWriter
(
new
FileWriter
(
csv
));
String
[]
entries
=
{
"id"
,
"child_id"
,
"total_correct_responses"
,
"correct_responses"
,
"commission_errors"
,
"omission_errors"
,
"mean_reaction_time"
,
"total_duration"
};
writer
.
writeNext
(
entries
);
List
<
String
[]>
data
=
new
ArrayList
<
String
[]>();
for
(
int
i
=
0
;
i
<
dataList
.
size
();
i
++)
{
Focused
gameData
=
dataList
.
get
(
i
);
data
.
add
(
new
String
[]{
String
.
valueOf
(
gameData
.
getId
()),
String
.
valueOf
(
gameData
.
getChildID
()),
String
.
valueOf
(
gameData
.
getTotalCorrectResponses
()),
String
.
valueOf
(
gameData
.
getNoOfCorrectResponses
()),
String
.
valueOf
(
gameData
.
getNoOfCommissionErrors
()),
String
.
valueOf
(
gameData
.
getNoOfOmmissionErrors
()),
String
.
valueOf
(
gameData
.
getMeanReactionTime
()),
String
.
valueOf
(
gameData
.
getTotalDuration
())
});
}
writer
.
writeAll
(
data
);
// data is adding to csv
writer
.
close
();
//callRead();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
/*******************************************************************************************/
// generate our PDF file.
// creating an object variable
// for our PDF document.
...
...
@@ -166,6 +229,7 @@ public class FACompleteScreen extends AppCompatActivity {
// third parameter is position from top and last
// one is our variable for paint.
canvas
.
drawBitmap
(
scaledbmp
,
56
,
40
,
paint
);
canvas
.
drawBitmap
(
scaledbmp2
,
400
,
0
,
paint
);
// below line is used for adding typeface for
// our text which we will be adding in our PDF file.
...
...
@@ -340,4 +404,25 @@ public class FACompleteScreen extends AppCompatActivity {
/**************************************************************************************************/
public
Bitmap
BITMAP_RESIZER
(
Bitmap
bitmap
,
int
newWidth
,
int
newHeight
)
{
Bitmap
scaledBitmap
=
Bitmap
.
createBitmap
(
newWidth
,
newHeight
,
Bitmap
.
Config
.
ARGB_8888
);
float
ratioX
=
newWidth
/
(
float
)
bitmap
.
getWidth
();
float
ratioY
=
newHeight
/
(
float
)
bitmap
.
getHeight
();
float
middleX
=
newWidth
/
2.0f
;
float
middleY
=
newHeight
/
2.0f
;
Matrix
scaleMatrix
=
new
Matrix
();
scaleMatrix
.
setScale
(
ratioX
,
ratioY
,
middleX
,
middleY
);
Canvas
canvas
=
new
Canvas
(
scaledBitmap
);
canvas
.
setMatrix
(
scaleMatrix
);
canvas
.
drawBitmap
(
bitmap
,
middleX
-
bitmap
.
getWidth
()
/
2
,
middleY
-
bitmap
.
getHeight
()
/
2
,
new
Paint
(
Paint
.
FILTER_BITMAP_FLAG
));
return
scaledBitmap
;
}
/**************************************************************************************************/
}
app/src/main/java/com/anuththara18/attentionassessment/sustained/SA1CompleteScreen.java
View file @
20fbad9b
...
...
@@ -8,6 +8,7 @@ import android.database.sqlite.SQLiteDatabase;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.graphics.Canvas
;
import
android.graphics.Matrix
;
import
android.graphics.Paint
;
import
android.graphics.Typeface
;
import
android.graphics.pdf.PdfDocument
;
...
...
@@ -30,11 +31,15 @@ import androidx.core.content.FileProvider;
import
com.anuththara18.attentionassessment.BuildConfig
;
import
com.anuththara18.attentionassessment.R
;
import
com.anuththara18.attentionassessment.age.AgeActivity
;
import
com.anuththara18.attentionassessment.consentform.ParentsConsentDatabaseHelper
;
import
com.anuththara18.attentionassessment.gender.GenderActivity
;
import
com.anuththara18.attentionassessment.home.NavigationDrawerActivity
;
import
com.anuththara18.attentionassessment.selective.Selective
;
import
com.opencsv.CSVWriter
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -57,7 +62,8 @@ public class SA1CompleteScreen extends AppCompatActivity {
// creating a bitmap variable
// for storing our images
Bitmap
bmp
,
scaledbmp
;
Bitmap
bmp
,
bmp2
,
scaledbmp
,
scaledbmp2
;
public
static
ParentsConsentDatabaseHelper
sqLiteHelper
;
// constant code for runtime permissions
private
static
final
int
PERMISSION_REQUEST_CODE
=
200
;
...
...
@@ -75,6 +81,8 @@ public class SA1CompleteScreen extends AppCompatActivity {
decorView
.
setSystemUiVisibility
(
uiOptions
);
setContentView
(
R
.
layout
.
activity_complete_screen2
);
sqLiteHelper
=
new
ParentsConsentDatabaseHelper
(
this
,
"ParentsConsent.sqlite"
,
null
,
1
);
complete
=
findViewById
(
R
.
id
.
complete
);
complete
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
...
...
@@ -86,16 +94,27 @@ public class SA1CompleteScreen extends AppCompatActivity {
}
});
dataList
=
new
ArrayList
<>();
/*******************************************************************************************/
//opening the database
mDatabase
=
openOrCreateDatabase
(
SustainedAttentionGame1
.
DATABASE_NAME
,
MODE_PRIVATE
,
null
);
try
{
Cursor
cursor
=
sqLiteHelper
.
getData
(
"SELECT * FROM ParentsConsent"
);
while
(
cursor
.
moveToNext
())
{
byte
[]
image
=
cursor
.
getBlob
(
0
);
bmp2
=
BitmapFactory
.
decodeByteArray
(
image
,
0
,
image
.
length
);
//fingerprintImageView.setImageBitmap(bmp);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
/*******************************************************************************************/
// initializing our variables.
bmp
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
sustained
);
scaledbmp
=
Bitmap
.
createScaledBitmap
(
bmp
,
140
,
140
,
false
);
//scaledbmp2 = Bitmap.createScaledBitmap(bmp2, 200, 200, false);
scaledbmp2
=
BITMAP_RESIZER
(
bmp2
,
400
,
400
);
// below code is used for
// checking our permissions.
...
...
@@ -107,6 +126,14 @@ public class SA1CompleteScreen extends AppCompatActivity {
/*******************************************************************************************/
dataList
=
new
ArrayList
<>();
//opening the database
mDatabase
=
openOrCreateDatabase
(
SustainedAttentionGame1
.
DATABASE_NAME
,
MODE_PRIVATE
,
null
);
/*******************************************************************************************/
//this part will display the data in the list
//we used rawQuery(sql, selectionargs) for fetching all the employees
...
...
@@ -134,6 +161,42 @@ public class SA1CompleteScreen extends AppCompatActivity {
/*******************************************************************************************/
String
csv
=
(
Environment
.
getExternalStorageDirectory
().
getAbsolutePath
()
+
"/SustainedAttention.csv"
);
// Here csv file name is MyCsvFile.csv
// csv will create inside phone storage.
CSVWriter
writer
=
null
;
try
{
writer
=
new
CSVWriter
(
new
FileWriter
(
csv
));
String
[]
entries
=
{
"id"
,
"child_id"
,
"total_correct_responses"
,
"correct_responses"
,
"commission_errors"
,
"omission_errors"
,
"mean_reaction_time"
,
"total_duration"
};
writer
.
writeNext
(
entries
);
List
<
String
[]>
data
=
new
ArrayList
<
String
[]>();
for
(
int
i
=
0
;
i
<
dataList
.
size
();
i
++)
{
Sustained
gameData
=
dataList
.
get
(
i
);
data
.
add
(
new
String
[]{
String
.
valueOf
(
gameData
.
getId
()),
String
.
valueOf
(
gameData
.
getChildID
()),
String
.
valueOf
(
gameData
.
getTotalCorrectResponses
()),
String
.
valueOf
(
gameData
.
getNoOfCorrectResponses
()),
String
.
valueOf
(
gameData
.
getNoOfCommissionErrors
()),
String
.
valueOf
(
gameData
.
getNoOfOmmissionErrors
()),
String
.
valueOf
(
gameData
.
getMeanReactionTime
()),
String
.
valueOf
(
gameData
.
getTotalDuration
())
});
}
writer
.
writeAll
(
data
);
// data is adding to csv
writer
.
close
();
//callRead();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
/*******************************************************************************************/
// generate our PDF file.
// creating an object variable
// for our PDF document.
...
...
@@ -166,6 +229,7 @@ public class SA1CompleteScreen extends AppCompatActivity {
// third parameter is position from top and last
// one is our variable for paint.
canvas
.
drawBitmap
(
scaledbmp
,
56
,
40
,
paint
);
canvas
.
drawBitmap
(
scaledbmp2
,
400
,
0
,
paint
);
// below line is used for adding typeface for
// our text which we will be adding in our PDF file.
...
...
@@ -340,4 +404,25 @@ public class SA1CompleteScreen extends AppCompatActivity {
/**************************************************************************************************/
public
Bitmap
BITMAP_RESIZER
(
Bitmap
bitmap
,
int
newWidth
,
int
newHeight
)
{
Bitmap
scaledBitmap
=
Bitmap
.
createBitmap
(
newWidth
,
newHeight
,
Bitmap
.
Config
.
ARGB_8888
);
float
ratioX
=
newWidth
/
(
float
)
bitmap
.
getWidth
();
float
ratioY
=
newHeight
/
(
float
)
bitmap
.
getHeight
();
float
middleX
=
newWidth
/
2.0f
;
float
middleY
=
newHeight
/
2.0f
;
Matrix
scaleMatrix
=
new
Matrix
();
scaleMatrix
.
setScale
(
ratioX
,
ratioY
,
middleX
,
middleY
);
Canvas
canvas
=
new
Canvas
(
scaledBitmap
);
canvas
.
setMatrix
(
scaleMatrix
);
canvas
.
drawBitmap
(
bitmap
,
middleX
-
bitmap
.
getWidth
()
/
2
,
middleY
-
bitmap
.
getHeight
()
/
2
,
new
Paint
(
Paint
.
FILTER_BITMAP_FLAG
));
return
scaledBitmap
;
}
/**************************************************************************************************/
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment