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
5885d509
Commit
5885d509
authored
Mar 06, 2022
by
Anuththara18
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Consent Form Integration & Saving parent's signature
parent
f2899e35
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
193 additions
and
47 deletions
+193
-47
app/build.gradle
app/build.gradle
+1
-1
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
+2
-1
app/src/main/java/com/anuththara18/attentionassessment/age/AgeActivity.java
...com/anuththara18/attentionassessment/age/AgeActivity.java
+2
-1
app/src/main/java/com/anuththara18/attentionassessment/alternating/AACompleteScreen.java
...a18/attentionassessment/alternating/AACompleteScreen.java
+1
-1
app/src/main/java/com/anuththara18/attentionassessment/consentform/GetParentsConsentActivity.java
...tionassessment/consentform/GetParentsConsentActivity.java
+74
-38
app/src/main/java/com/anuththara18/attentionassessment/consentform/ParentsConsentDatabaseHelper.java
...nassessment/consentform/ParentsConsentDatabaseHelper.java
+47
-0
app/src/main/java/com/anuththara18/attentionassessment/consentform/ParentsConsentModel.java
.../attentionassessment/consentform/ParentsConsentModel.java
+21
-0
app/src/main/java/com/anuththara18/attentionassessment/dividedattention/DACompleteScreen.java
...ttentionassessment/dividedattention/DACompleteScreen.java
+1
-1
app/src/main/java/com/anuththara18/attentionassessment/focused/FACompleteScreen.java
...thara18/attentionassessment/focused/FACompleteScreen.java
+1
-1
app/src/main/java/com/anuththara18/attentionassessment/selective/SelectiveACompleteScreen.java
...tentionassessment/selective/SelectiveACompleteScreen.java
+42
-2
app/src/main/java/com/anuththara18/attentionassessment/sustained/SA1CompleteScreen.java
...ra18/attentionassessment/sustained/SA1CompleteScreen.java
+1
-1
No files found.
app/build.gradle
View file @
5885d509
...
...
@@ -9,7 +9,7 @@ android {
defaultConfig
{
applicationId
"com.anuththara18.attentionassessment"
minSdkVersion
24
targetSdkVersion
31
targetSdkVersion
29
versionCode
1
versionName
"1.0"
...
...
app/src/main/AndroidManifest.xml
View file @
5885d509
...
...
@@ -34,7 +34,8 @@
<activity
android:name=
".consentform.ConsentFormActivity"
android:screenOrientation=
"portrait"
android:theme=
"@style/Theme.AppCompat.NoActionBar"
></activity>
android:theme=
"@style/Theme.AppCompat.NoActionBar"
>
</activity>
<activity
android:name=
".consentform.GetParentsConsentActivity"
android:screenOrientation=
"portrait"
...
...
app/src/main/java/com/anuththara18/attentionassessment/age/AgeActivity.java
View file @
5885d509
...
...
@@ -18,6 +18,7 @@ import android.widget.RelativeLayout;
import
android.widget.TextView
;
import
com.anuththara18.attentionassessment.R
;
import
com.anuththara18.attentionassessment.consentform.ConsentFormActivity
;
import
com.anuththara18.attentionassessment.gender.GenderActivity
;
import
com.anuththara18.attentionassessment.home.NavigationDrawerActivity
;
import
com.anuththara18.attentionassessment.language.LanguageActivity
;
...
...
@@ -104,7 +105,7 @@ public class AgeActivity extends AppCompatActivity {
next
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
Intent
intent
=
new
Intent
(
AgeActivity
.
this
,
NavigationDrawer
Activity
.
class
);
Intent
intent
=
new
Intent
(
AgeActivity
.
this
,
ConsentForm
Activity
.
class
);
startActivity
(
intent
);
}
});
...
...
app/src/main/java/com/anuththara18/attentionassessment/alternating/AACompleteScreen.java
View file @
5885d509
...
...
@@ -50,7 +50,7 @@ public class AACompleteScreen extends AppCompatActivity {
// declaring width and height
// for our PDF file.
int
pageHeight
=
1
1
20
;
int
pageHeight
=
1
5
20
;
int
pagewidth
=
792
;
// creating a bitmap variable
...
...
app/src/main/java/com/anuththara18/attentionassessment/consentform/GetParentsConsentActivity.java
View file @
5885d509
package
com.anuththara18.attentionassessment.consentform
;
import
android.Manifest
;
import
android.content.ContentValues
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.database.Cursor
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.graphics.drawable.BitmapDrawable
;
import
android.os.Bundle
;
import
android.os.Environment
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.ImageView
;
...
...
@@ -19,9 +25,17 @@ import androidx.core.content.ContextCompat;
import
com.anuththara18.attentionassessment.R
;
import
com.anuththara18.attentionassessment.home.NavigationDrawerActivity
;
import
com.anuththara18.attentionassessment.language.LanguageSetter
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
static
android
.
Manifest
.
permission
.
MANAGE_EXTERNAL_STORAGE
;
import
static
android
.
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
;
import
static
android
.
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
;
public
class
GetParentsConsentActivity
extends
AppCompatActivity
{
...
...
@@ -30,8 +44,11 @@ public class GetParentsConsentActivity extends AppCompatActivity {
public
static
ImageView
fingerprintImageView
;
static
int
flag2
=
0
;
private
static
final
int
STORAGE_PERMISSION_CODE
=
101
;
// constant code for runtime permissions
private
static
final
int
PERMISSION_REQUEST_CODE
=
200
;
public
static
ParentsConsentDatabaseHelper
sqLiteHelper
;
private
static
final
int
STORAGE_PERMISSION_CODE
=
101
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -47,9 +64,21 @@ public class GetParentsConsentActivity extends AppCompatActivity {
//btnSaveFingerPrint.setText(LanguageSetter.getresources().getString(R.string.startTest));
//btnGetSignature.setText(LanguageSetter.getresources().getString(R.string.getSignature));
checkPermission
(
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
,
STORAGE_PERMISSION_CODE
);
/*******************************************************************************************/
// below code is used for
// checking our permissions.
if
(
checkPermission
())
{
//Toast.makeText(this, "Permission Granted", Toast.LENGTH_SHORT).show();
}
else
{
requestPermission
();
}
/*******************************************************************************************/
sqLiteHelper
=
new
ParentsConsentDatabaseHelper
(
this
,
"ParentsConsent.sqlite"
,
null
,
1
);
sqLiteHelper
.
queryData
(
"CREATE TABLE IF NOT EXISTS ParentsConsent(signature BLOB)"
);
/************************************************************************************/
...
...
@@ -58,8 +87,6 @@ public class GetParentsConsentActivity extends AppCompatActivity {
public
void
onClick
(
View
view
)
{
if
(
flag2
==
1
)
{
saveImage
();
//Intent intent = new Intent(getApplicationContext(), QuestionnaireMainScreen.class);
//startActivity(intent);
}
else
if
(
flag2
==
0
){
Toast
.
makeText
(
getApplicationContext
(),
"Please Provide your Signature"
,
Toast
.
LENGTH_SHORT
).
show
();
...
...
@@ -86,12 +113,10 @@ public class GetParentsConsentActivity extends AppCompatActivity {
public
void
saveImage
()
{
try
{
/************************************************
* **********************************************
* **********************************************
*/
sqLiteHelper
.
insertData
(
imageViewToByte
(
fingerprintImageView
));
Toast
.
makeText
(
getApplicationContext
(),
"Consent Saved Successfully!"
,
Toast
.
LENGTH_SHORT
).
show
();
Intent
intent
=
new
Intent
(
getApplicationContext
(),
NavigationDrawerActivity
.
class
);
startActivity
(
intent
);
}
catch
(
Exception
e
){
Toast
.
makeText
(
getApplicationContext
(),
"Consent not Saved!"
,
Toast
.
LENGTH_SHORT
).
show
();
...
...
@@ -111,43 +136,54 @@ public class GetParentsConsentActivity extends AppCompatActivity {
return
byteArray
;
}
/************************************************************************************/
/************************************************************************************
**************
/
private
boolean
checkPermission
()
{
// checking of permissions.
int
permission1
=
ContextCompat
.
checkSelfPermission
(
getApplicationContext
(),
WRITE_EXTERNAL_STORAGE
);
int
permission2
=
ContextCompat
.
checkSelfPermission
(
getApplicationContext
(),
READ_EXTERNAL_STORAGE
);
int
permission3
=
ContextCompat
.
checkSelfPermission
(
getApplicationContext
(),
MANAGE_EXTERNAL_STORAGE
);
return
permission1
==
PackageManager
.
PERMISSION_GRANTED
&&
permission2
==
PackageManager
.
PERMISSION_GRANTED
&&
permission3
==
PackageManager
.
PERMISSION_GRANTED
;
}
// Function to check and request permission.
public
void
checkPermission
(
String
permission
,
int
requestCode
)
{
if
(
ContextCompat
.
checkSelfPermission
(
com
.
anuththara18
.
attentionassessment
.
consentform
.
GetParentsConsentActivity
.
this
,
permission
)
==
PackageManager
.
PERMISSION_DENIED
)
{
/**************************************************************************************************/
// Requesting the permission
ActivityCompat
.
requestPermissions
(
com
.
anuththara18
.
attentionassessment
.
consentform
.
GetParentsConsentActivity
.
this
,
new
String
[]
{
permission
},
requestCode
);
}
else
{
//Toast.makeText(GetParentsConsentActivity.this, "Permission already granted", Toast.LENGTH_SHORT).show();
}
private
void
requestPermission
()
{
// requesting permissions if not provided.
ActivityCompat
.
requestPermissions
(
this
,
new
String
[]{
WRITE_EXTERNAL_STORAGE
,
READ_EXTERNAL_STORAGE
,
MANAGE_EXTERNAL_STORAGE
},
PERMISSION_REQUEST_CODE
);
}
// This function is called when the user accepts or decline the permission.
// Request Code is used to check which permission called this function.
// This request code is provided when the user is prompt for permission.
@Override
public
void
onRequestPermissionsResult
(
int
requestCode
,
@NonNull
String
[]
permissions
,
@NonNull
int
[]
grantResults
)
{
super
.
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
);
if
(
requestCode
==
STORAGE_PERMISSION_CODE
)
{
if
(
grantResults
.
length
>
0
&&
grantResults
[
0
]
==
PackageManager
.
PERMISSION_GRANTED
)
{
Toast
.
makeText
(
com
.
anuththara18
.
attentionassessment
.
consentform
.
GetParentsConsentActivity
.
this
,
"Storage Permission Granted"
,
Toast
.
LENGTH_SHORT
).
show
();
}
else
{
Toast
.
makeText
(
com
.
anuththara18
.
attentionassessment
.
consentform
.
GetParentsConsentActivity
.
this
,
"Storage Permission Denied"
,
Toast
.
LENGTH_SHORT
).
show
();
public
void
onRequestPermissionsResult
(
int
requestCode
,
@NonNull
String
[]
permissions
,
@NonNull
int
[]
grantResults
)
{
super
.
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
);
if
(
requestCode
==
PERMISSION_REQUEST_CODE
)
{
if
(
grantResults
.
length
>
0
)
{
/*
Intent intent = new Intent();
intent.setAction(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
Uri uri = Uri.fromParts("package", this.getPackageName(), null);
intent.setData(uri);
startActivity(intent);
*/
// after requesting permissions we are showing
// users a toast message of permission granted.
boolean
writeStorage
=
grantResults
[
0
]
==
PackageManager
.
PERMISSION_GRANTED
;
boolean
readStorage
=
grantResults
[
1
]
==
PackageManager
.
PERMISSION_GRANTED
;
if
(
writeStorage
&&
readStorage
)
{
//Toast.makeText(this, "Permission Granted..", Toast.LENGTH_SHORT).show();
}
else
{
Toast
.
makeText
(
this
,
"Permission Denined."
,
Toast
.
LENGTH_SHORT
).
show
();
finish
();
}
}
}
}
/**************************************************************************************************/
}
\ No newline at end of file
app/src/main/java/com/anuththara18/attentionassessment/consentform/ParentsConsentDatabaseHelper.java
0 → 100644
View file @
5885d509
package
com.anuththara18.attentionassessment.consentform
;
import
android.content.Context
;
import
android.database.Cursor
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.database.sqlite.SQLiteOpenHelper
;
import
android.database.sqlite.SQLiteStatement
;
public
class
ParentsConsentDatabaseHelper
extends
SQLiteOpenHelper
{
public
ParentsConsentDatabaseHelper
(
Context
context
,
String
name
,
SQLiteDatabase
.
CursorFactory
factory
,
int
version
)
{
super
(
context
,
name
,
factory
,
version
);
}
public
void
queryData
(
String
sql
){
SQLiteDatabase
database
=
getWritableDatabase
();
database
.
execSQL
(
sql
);
}
public
void
insertData
(
byte
[]
image
){
SQLiteDatabase
database
=
getWritableDatabase
();
String
sql
=
"INSERT INTO ParentsConsent VALUES (?)"
;
SQLiteStatement
statement
=
database
.
compileStatement
(
sql
);
statement
.
clearBindings
();
statement
.
bindBlob
(
1
,
image
);
statement
.
executeInsert
();
}
public
Cursor
getData
(
String
sql
){
SQLiteDatabase
database
=
getReadableDatabase
();
return
database
.
rawQuery
(
sql
,
null
);
}
@Override
public
void
onCreate
(
SQLiteDatabase
sqLiteDatabase
)
{
}
@Override
public
void
onUpgrade
(
SQLiteDatabase
sqLiteDatabase
,
int
i
,
int
i1
)
{
}
}
app/src/main/java/com/anuththara18/attentionassessment/consentform/ParentsConsentModel.java
0 → 100644
View file @
5885d509
package
com.anuththara18.attentionassessment.consentform
;
import
java.io.Serializable
;
public
class
ParentsConsentModel
implements
Serializable
{
private
byte
[]
signature
;
public
ParentsConsentModel
(
byte
[]
signature
)
{
this
.
signature
=
signature
;
}
public
byte
[]
getSignature
()
{
return
signature
;
}
public
void
setSignature
(
byte
[]
signature
)
{
this
.
signature
=
signature
;
}
}
app/src/main/java/com/anuththara18/attentionassessment/dividedattention/DACompleteScreen.java
View file @
5885d509
...
...
@@ -52,7 +52,7 @@ public class DACompleteScreen extends AppCompatActivity {
// declaring width and height
// for our PDF file.
int
pageHeight
=
1
1
20
;
int
pageHeight
=
1
5
20
;
int
pagewidth
=
792
;
// creating a bitmap variable
...
...
app/src/main/java/com/anuththara18/attentionassessment/focused/FACompleteScreen.java
View file @
5885d509
...
...
@@ -52,7 +52,7 @@ public class FACompleteScreen extends AppCompatActivity {
// declaring width and height
// for our PDF file.
int
pageHeight
=
1
1
20
;
int
pageHeight
=
1
5
20
;
int
pagewidth
=
792
;
// creating a bitmap variable
...
...
app/src/main/java/com/anuththara18/attentionassessment/selective/SelectiveACompleteScreen.java
View file @
5885d509
...
...
@@ -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,6 +31,7 @@ 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.opencsv.CSVWriter
;
...
...
@@ -54,12 +56,13 @@ public class SelectiveACompleteScreen extends AppCompatActivity {
// declaring width and height
// for our PDF file.
int
pageHeight
=
1
1
20
;
int
pageHeight
=
1
5
20
;
int
pagewidth
=
792
;
// 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
;
...
...
@@ -77,6 +80,8 @@ public class SelectiveACompleteScreen 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
()
{
...
...
@@ -90,9 +95,25 @@ public class SelectiveACompleteScreen extends AppCompatActivity {
/*******************************************************************************************/
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
.
selective
);
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.
...
...
@@ -186,6 +207,7 @@ public class SelectiveACompleteScreen extends AppCompatActivity {
Canvas
canvas
=
myPage
.
getCanvas
();
canvas
.
drawBitmap
(
scaledbmp
,
56
,
40
,
paint
);
canvas
.
drawBitmap
(
scaledbmp2
,
400
,
0
,
paint
);
title
.
setTypeface
(
Typeface
.
create
(
Typeface
.
DEFAULT
,
Typeface
.
BOLD
));
title
.
setTextSize
(
20
);
...
...
@@ -304,4 +326,22 @@ public class SelectiveACompleteScreen 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 @
5885d509
...
...
@@ -52,7 +52,7 @@ public class SA1CompleteScreen extends AppCompatActivity {
// declaring width and height
// for our PDF file.
int
pageHeight
=
1
1
20
;
int
pageHeight
=
1
5
20
;
int
pagewidth
=
792
;
// creating a bitmap variable
...
...
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