diff --git a/app/src/main/java/com/anuththara18/attentionassessment/age/AgeActivity.java b/app/src/main/java/com/anuththara18/attentionassessment/age/AgeActivity.java index 25aecd5e45794d19afbafc026c5beba690866882..728bdc3b1943e67f95640559e45ead72b92f6a3d 100644 --- a/app/src/main/java/com/anuththara18/attentionassessment/age/AgeActivity.java +++ b/app/src/main/java/com/anuththara18/attentionassessment/age/AgeActivity.java @@ -1,8 +1,10 @@ package com.anuththara18.attentionassessment.age; +import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import androidx.constraintlayout.widget.ConstraintLayout; +import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.database.sqlite.SQLiteDatabase; @@ -359,6 +361,38 @@ public class AgeActivity extends AppCompatActivity { /*************************************************************************************************/ + @Override + public void onBackPressed() { + super.onBackPressed(); + alert(); + } + + /*************************************************************************************************/ + + private void alert() { + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); + alertDialogBuilder.setMessage("Do you really want to quit the game?"); + alertDialogBuilder.setPositiveButton("yes", + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface arg0, int arg1) { + finish(); + } + }); + + alertDialogBuilder.setNegativeButton("No",new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + //finish(); + } + }); + + AlertDialog alertDialog = alertDialogBuilder.create(); + alertDialog.show(); + } + + /*************************************************************************************************/ + public void getDimensions() { if ( count == 1 ) { leftFromXDelta = 0; diff --git a/app/src/main/java/com/anuththara18/attentionassessment/consentform/ConsentFormActivity.java b/app/src/main/java/com/anuththara18/attentionassessment/consentform/ConsentFormActivity.java index 58ee8a976dacd504e9eb77cc216b5a063e4c252e..df8b73e49cc30bf5f291137a2fb01a2672bd5088 100644 --- a/app/src/main/java/com/anuththara18/attentionassessment/consentform/ConsentFormActivity.java +++ b/app/src/main/java/com/anuththara18/attentionassessment/consentform/ConsentFormActivity.java @@ -1,5 +1,6 @@ package com.anuththara18.attentionassessment.consentform; +import android.content.DialogInterface; import android.content.Intent; import android.os.Build; import android.os.Bundle; @@ -12,6 +13,7 @@ import android.widget.Button; import android.widget.ImageButton; import android.widget.TextView; +import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -112,4 +114,36 @@ public class ConsentFormActivity extends AppCompatActivity { consentFormList.add(new ConsentForm("Whom do I call if I have questions or problems?", "If you have any questions regarding your rights as a participant in this research and/or concerns about the study, or if you feel under any pressure to enroll or to continue to participate in this study, you may contact the Dr Pradeepa Samarasinghe, Principle Investigator at Sri Lanka Institute of Information Technology at 0723537952 or pradeepa.s@sliit.lk .")); } + /*************************************************************************************************/ + + @Override + public void onBackPressed() { + super.onBackPressed(); + alert(); + } + + /*************************************************************************************************/ + + private void alert() { + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); + alertDialogBuilder.setMessage("Do you really want to quit the game?"); + alertDialogBuilder.setPositiveButton("yes", + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface arg0, int arg1) { + finish(); + } + }); + + alertDialogBuilder.setNegativeButton("No",new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + //finish(); + } + }); + + AlertDialog alertDialog = alertDialogBuilder.create(); + alertDialog.show(); + } + } \ No newline at end of file diff --git a/app/src/main/java/com/anuththara18/attentionassessment/consentform/GetParentsConsentActivity.java b/app/src/main/java/com/anuththara18/attentionassessment/consentform/GetParentsConsentActivity.java index 17e8e73607959848c02a590975edd45dd732e3c9..47a7123ecb9388e647e592a1973474d5ec05d535 100644 --- a/app/src/main/java/com/anuththara18/attentionassessment/consentform/GetParentsConsentActivity.java +++ b/app/src/main/java/com/anuththara18/attentionassessment/consentform/GetParentsConsentActivity.java @@ -162,6 +162,7 @@ public class GetParentsConsentActivity extends AppCompatActivity { ed.apply(); //Toast.makeText(getApplicationContext(), String.valueOf(imageSet), Toast.LENGTH_LONG).show(); //Toast.makeText(getApplicationContext(), "Consent Saved Successfully!", Toast.LENGTH_SHORT).show(); + finish(); Intent intent = new Intent(getApplicationContext(), NavigationDrawerActivity.class); startActivity(intent); } diff --git a/app/src/main/java/com/anuththara18/attentionassessment/consentform/GetSignatureActivity.java b/app/src/main/java/com/anuththara18/attentionassessment/consentform/GetSignatureActivity.java index 79c57eadce1b304a440314d7e188a985db8bc067..a24877ef9c4dafc9547bd8234a74998987e864a7 100644 --- a/app/src/main/java/com/anuththara18/attentionassessment/consentform/GetSignatureActivity.java +++ b/app/src/main/java/com/anuththara18/attentionassessment/consentform/GetSignatureActivity.java @@ -1,6 +1,7 @@ package com.anuththara18.attentionassessment.consentform; import android.content.Context; +import android.content.DialogInterface; import android.content.SharedPreferences; import android.graphics.Bitmap; import android.graphics.Canvas; @@ -21,6 +22,7 @@ import android.widget.Button; import android.widget.LinearLayout; import android.widget.Toast; +import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import com.anuththara18.attentionassessment.R; @@ -238,4 +240,36 @@ public class GetSignatureActivity extends AppCompatActivity { dirtyRect.bottom = Math.max(lastTouchY, eventY); } } + + /*************************************************************************************************/ + + @Override + public void onBackPressed() { + super.onBackPressed(); + alert(); + } + + /*************************************************************************************************/ + + private void alert() { + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); + alertDialogBuilder.setMessage("Do you really want to quit the game?"); + alertDialogBuilder.setPositiveButton("yes", + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface arg0, int arg1) { + finish(); + } + }); + + alertDialogBuilder.setNegativeButton("No",new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + //finish(); + } + }); + + AlertDialog alertDialog = alertDialogBuilder.create(); + alertDialog.show(); + } } \ No newline at end of file diff --git a/app/src/main/java/com/anuththara18/attentionassessment/consentform/SinhalaConsentFormActivity.java b/app/src/main/java/com/anuththara18/attentionassessment/consentform/SinhalaConsentFormActivity.java index e7044ef44c2c7e26deb9839373781e47ed791be6..f6cb58bd76e5328437b5c66fe338f27a5277fe0b 100644 --- a/app/src/main/java/com/anuththara18/attentionassessment/consentform/SinhalaConsentFormActivity.java +++ b/app/src/main/java/com/anuththara18/attentionassessment/consentform/SinhalaConsentFormActivity.java @@ -1,5 +1,6 @@ package com.anuththara18.attentionassessment.consentform; +import android.content.DialogInterface; import android.content.Intent; import android.os.Build; import android.os.Bundle; @@ -11,6 +12,7 @@ import android.view.animation.AnimationUtils; import android.widget.ImageButton; import android.widget.TextView; +import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -101,4 +103,35 @@ public class SinhalaConsentFormActivity extends AppCompatActivity { consentFormList.add(new ConsentForm("ඔබට යම් ප්\u200Dරà·à·Šà¶±à¶ºà¶šà·Š හ෠ගà·à¶§à·…ුවක් ඇà¶à·Šà¶±à¶¸à·Š දුරකථනයෙන් සම්බන්ධ කරගචහà·à¶šà·’ අය ", "මෙම පර්යේෂණය සඳහ෠සහභà·à¶œà·“ වීමේදී ඔබේ අයිà¶à·’à·€à·à·ƒà·’කම් පිළිබඳව හ෠පර්යේෂණය හ෠සම්බන්ධ කිසියම් කà·à¶»à¶«à¶ºà¶šà·Š දà·à¶±à¶œà·à¶±à·“මට අවà·à·Š\u200Dය නම් සහ මෙම පර්යේෂණය සමග සම්බන්ධ වීමට à·„à· à¶à·€à¶¯à·”රටà¶à·Š කරගෙන යà·à¶¸à¶§ ඔබට යම් අපහසුà¶à·à·€à¶ºà¶šà·Š ඇà¶à·Šà¶±à¶¸à·Š 0723537952 දුරකථන අංකයෙන් à·„à· pradeepa.s@sliit.lk විද්\u200Dයුà¶à·Š à¶à·à¶´à·à¶½à·Š ලිපිනයෙන්, à·à·Š\u200Dරී ලංක෠à¶à·œà¶»à¶à·”රු à¶à·à¶šà·Šà·‚ණ ආයà¶à¶±à¶ºà·š ප්\u200Dරධà·à¶± පර්යේෂික෠(principal investigator) ආචà·à¶»à·Šà¶º ප්\u200Dරදීප෠සමරසිංහ මහà¶à·Šà¶¸à·’ය සම්බන්ධ කරගà·à¶±à·“මට à·„à·à¶šà·’යà·à·€ ඇà¶. ")); } + /*************************************************************************************************/ + + @Override + public void onBackPressed() { + super.onBackPressed(); + alert(); + } + + /*************************************************************************************************/ + + private void alert() { + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); + alertDialogBuilder.setMessage("Do you really want to quit the game?"); + alertDialogBuilder.setPositiveButton("yes", + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface arg0, int arg1) { + finish(); + } + }); + + alertDialogBuilder.setNegativeButton("No",new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + //finish(); + } + }); + + AlertDialog alertDialog = alertDialogBuilder.create(); + alertDialog.show(); + } } \ No newline at end of file diff --git a/app/src/main/java/com/anuththara18/attentionassessment/details/ParentDetailsActivity.java b/app/src/main/java/com/anuththara18/attentionassessment/details/ParentDetailsActivity.java index 9f0c1aaced0cb3aee0593f53e14612d90f0b2214..ee4dc7eb506a9dff10499500a560d4d4559bb585 100644 --- a/app/src/main/java/com/anuththara18/attentionassessment/details/ParentDetailsActivity.java +++ b/app/src/main/java/com/anuththara18/attentionassessment/details/ParentDetailsActivity.java @@ -1,7 +1,9 @@ package com.anuththara18.attentionassessment.details; +import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; +import android.content.DialogInterface; import android.content.Intent; import android.os.Build; import android.os.Bundle; @@ -150,4 +152,36 @@ public class ParentDetailsActivity extends AppCompatActivity { return TextUtils.isEmpty(phone) || (m.find() && m.group().equals(phone)); } + /*************************************************************************************************/ + + @Override + public void onBackPressed() { + super.onBackPressed(); + alert(); + } + + /*************************************************************************************************/ + + private void alert() { + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); + alertDialogBuilder.setMessage("Do you really want to quit the game?"); + alertDialogBuilder.setPositiveButton("yes", + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface arg0, int arg1) { + finish(); + } + }); + + alertDialogBuilder.setNegativeButton("No",new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + //finish(); + } + }); + + AlertDialog alertDialog = alertDialogBuilder.create(); + alertDialog.show(); + } + } \ No newline at end of file diff --git a/app/src/main/java/com/anuththara18/attentionassessment/gender/GenderActivity.java b/app/src/main/java/com/anuththara18/attentionassessment/gender/GenderActivity.java index 545e4d641e42681853279434987e37d37c7b40ab..ac7e625b84345901b40cd5a1a83f4bd7e6a86387 100644 --- a/app/src/main/java/com/anuththara18/attentionassessment/gender/GenderActivity.java +++ b/app/src/main/java/com/anuththara18/attentionassessment/gender/GenderActivity.java @@ -1,7 +1,9 @@ package com.anuththara18.attentionassessment.gender; +import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; +import android.content.DialogInterface; import android.content.Intent; import android.media.MediaPlayer; import android.os.Build; @@ -22,6 +24,7 @@ import android.widget.Toast; import com.anuththara18.attentionassessment.R; import com.anuththara18.attentionassessment.age.AgeActivity; import com.anuththara18.attentionassessment.details.ParentDetailsActivity; +import com.anuththara18.attentionassessment.home.NavigationDrawerActivity; import com.anuththara18.attentionassessment.language.LanguageActivity; import com.anuththara18.attentionassessment.language.LanguageSetter; @@ -202,4 +205,37 @@ public class GenderActivity extends AppCompatActivity { }); } + + /*************************************************************************************************/ + + @Override + public void onBackPressed() { + super.onBackPressed(); + alert(); + } + + /*************************************************************************************************/ + + private void alert() { + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); + alertDialogBuilder.setMessage("Do you really want to quit the game?"); + alertDialogBuilder.setPositiveButton("yes", + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface arg0, int arg1) { + finish(); + } + }); + + alertDialogBuilder.setNegativeButton("No",new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + //finish(); + } + }); + + AlertDialog alertDialog = alertDialogBuilder.create(); + alertDialog.show(); + } + } \ No newline at end of file diff --git a/app/src/main/java/com/anuththara18/attentionassessment/home/MainFragment.java b/app/src/main/java/com/anuththara18/attentionassessment/home/MainFragment.java index 4ea10ed1109fa8716f305b043a7083c07165881f..31356acee3ffe42ad190891e94d65e994f9225ec 100644 --- a/app/src/main/java/com/anuththara18/attentionassessment/home/MainFragment.java +++ b/app/src/main/java/com/anuththara18/attentionassessment/home/MainFragment.java @@ -1,14 +1,18 @@ package com.anuththara18.attentionassessment.home; import android.annotation.SuppressLint; +import android.content.DialogInterface; import android.content.Intent; import android.media.MediaPlayer; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Toast; +import androidx.activity.OnBackPressedCallback; import androidx.annotation.Nullable; +import androidx.appcompat.app.AlertDialog; import androidx.cardview.widget.CardView; import androidx.drawerlayout.widget.DrawerLayout; import androidx.fragment.app.Fragment; @@ -109,6 +113,54 @@ public class MainFragment extends Fragment { } + /*************************************************************************************************/ + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // This callback will only be called when MyFragment is at least Started. + OnBackPressedCallback callback = new OnBackPressedCallback(true /* enabled by default */) { + @Override + public void handleOnBackPressed() { + //Toast.makeText(getContext(), "predescnjdfcfd", Toast.LENGTH_SHORT).show(); + alert(); + } + }; + requireActivity().getOnBackPressedDispatcher().addCallback(this, callback); + + // The callback can be enabled or disabled here or in handleOnBackPressed() + } + + /*************************************************************************************************/ + + private void alert() { + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getContext()); + alertDialogBuilder.setMessage("Do you really want to quit the game?"); + alertDialogBuilder.setPositiveButton("yes", + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface arg0, int arg1) { + getActivity().finish(); + } + }); + + alertDialogBuilder.setNegativeButton("No",new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + //finish(); + } + }); + + AlertDialog alertDialog = alertDialogBuilder.create(); + alertDialog.show(); + } + + + /*************************************************************************************************/ + + + } /* public class FirstFragment extends Fragment { diff --git a/app/src/main/java/com/anuththara18/attentionassessment/language/LanguageActivity.java b/app/src/main/java/com/anuththara18/attentionassessment/language/LanguageActivity.java index 552d470c64dd433be95a6da540a1af7a14579148..ce783a02c8a9c46b8e18748a29759dc6da79018d 100644 --- a/app/src/main/java/com/anuththara18/attentionassessment/language/LanguageActivity.java +++ b/app/src/main/java/com/anuththara18/attentionassessment/language/LanguageActivity.java @@ -1,8 +1,10 @@ package com.anuththara18.attentionassessment.language; import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; +import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Resources; @@ -24,6 +26,7 @@ import android.widget.Toast; import com.anuththara18.attentionassessment.R; import com.anuththara18.attentionassessment.details.ParentDetailsActivity; import com.anuththara18.attentionassessment.gender.GenderActivity; +import com.anuththara18.attentionassessment.home.NavigationDrawerActivity; import com.google.android.gms.tasks.OnCompleteListener; import com.google.android.gms.tasks.Task; import com.google.firebase.auth.AuthResult; @@ -244,6 +247,40 @@ public class LanguageActivity extends AppCompatActivity { }); } + /*************************************************************************************************/ + + @Override + public void onBackPressed() { + super.onBackPressed(); + alert(); + } + + private void alert() { + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); + alertDialogBuilder.setMessage("Do you really want to quit the game?"); + alertDialogBuilder.setPositiveButton("yes", + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface arg0, int arg1) { + finish(); + } + }); + + alertDialogBuilder.setNegativeButton("No",new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + //finish(); + } + }); + + AlertDialog alertDialog = alertDialogBuilder.create(); + alertDialog.show(); + } + + + /*************************************************************************************************/ + + public void englishSelected() { english_btn.getLayoutParams().height = 700; english_btn.getLayoutParams().width= 700; diff --git a/app/src/main/java/com/anuththara18/attentionassessment/videos/IntroductoryVideoLandscapeActivity.java b/app/src/main/java/com/anuththara18/attentionassessment/videos/IntroductoryVideoLandscapeActivity.java index bff2d504bc9751cd2fad92993c3a08d2b44eec99..c54ddf413db8cb9d5294fa37321a9b629ad16e8f 100644 --- a/app/src/main/java/com/anuththara18/attentionassessment/videos/IntroductoryVideoLandscapeActivity.java +++ b/app/src/main/java/com/anuththara18/attentionassessment/videos/IntroductoryVideoLandscapeActivity.java @@ -70,16 +70,20 @@ public class IntroductoryVideoLandscapeActivity extends AppCompatActivity { public void onClick(View view) { if (MainFragment.game.equals("focused")) { if (Map1Activity.level == 1){ + finish(); startActivity(new Intent(getApplicationContext(), FocusedAttentionGame2.class)); } else if (Map1Activity.level == 2){ + finish(); startActivity(new Intent(getApplicationContext(), FocusedAttentionGame2.class)); } else if (Map1Activity.level == 5){ + finish(); startActivity(new Intent(getApplicationContext(), FocusedAttentionGame1.class)); } } else if (MainFragment.game.equals("alternating")) { + finish(); startActivity(new Intent(getApplicationContext(), AlternatingAttentionGame1.class)); } } diff --git a/app/src/main/java/com/anuththara18/attentionassessment/videos/IntroductoryVideoPortraitActivity.java b/app/src/main/java/com/anuththara18/attentionassessment/videos/IntroductoryVideoPortraitActivity.java index dc395b001dcd198a322f0f4ea21038a049175df1..037bf55755727beb0ea8781f3cfe0618e2a4b321 100644 --- a/app/src/main/java/com/anuththara18/attentionassessment/videos/IntroductoryVideoPortraitActivity.java +++ b/app/src/main/java/com/anuththara18/attentionassessment/videos/IntroductoryVideoPortraitActivity.java @@ -63,19 +63,24 @@ public class IntroductoryVideoPortraitActivity extends AppCompatActivity { public void onClick(View view) { if (MainFragment.game.equals("focused")) { if (Map1Activity.level == 3){ + finish(); startActivity(new Intent(getApplicationContext(), AnimalChoosingActivity.class)); } else if (Map1Activity.level == 4){ + finish(); startActivity(new Intent(getApplicationContext(), AnimalChoosingActivity.class)); } } else if (MainFragment.game.equals("divided")) { + finish(); startActivity(new Intent(getApplicationContext(), DividedAttentionGame1.class)); } else if (MainFragment.game.equals("selective")) { + finish(); startActivity(new Intent(getApplicationContext(), SelectiveAttentionGame1.class)); } else if (MainFragment.game.equals("sustained")) { + finish(); startActivity(new Intent(getApplicationContext(), BirdChoosingActivity.class)); } }