Commit 1835a808 authored by Anuththara18's avatar Anuththara18

Game Map UI Modification, Adding Shared Preferences, Firebase Bux Fix

parent e525e5f3
package com.anuththara18.attentionassessment.consentform; package com.anuththara18.attentionassessment.consentform;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
...@@ -40,6 +41,9 @@ public class GetSignatureActivity extends AppCompatActivity { ...@@ -40,6 +41,9 @@ public class GetSignatureActivity extends AppCompatActivity {
private signature mSignature; private signature mSignature;
public static Bitmap bitmap; public static Bitmap bitmap;
public static SharedPreferences sharedPreferences;
public static SharedPreferences.Editor myEdit;
// Creating Separate Directory for saving Generated Images // Creating Separate Directory for saving Generated Images
String DIRECTORY = Environment.getExternalStorageDirectory().getPath() + "/Signature/"; String DIRECTORY = Environment.getExternalStorageDirectory().getPath() + "/Signature/";
String pic_name = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date()); String pic_name = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date());
...@@ -68,6 +72,12 @@ public class GetSignatureActivity extends AppCompatActivity { ...@@ -68,6 +72,12 @@ public class GetSignatureActivity extends AppCompatActivity {
btnClear.setText(LanguageSetter.getresources().getString(R.string.clear)); btnClear.setText(LanguageSetter.getresources().getString(R.string.clear));
btnSave.setText(LanguageSetter.getresources().getString(R.string.save)); btnSave.setText(LanguageSetter.getresources().getString(R.string.save));
// Storing data into SharedPreferences
sharedPreferences = getSharedPreferences("MySharedPref",MODE_PRIVATE);
// Creating an Editor object to edit(write to the file)
myEdit = sharedPreferences.edit();
view = canvasLL; view = canvasLL;
btnClear.setOnClickListener(new View.OnClickListener() { btnClear.setOnClickListener(new View.OnClickListener() {
......
...@@ -35,6 +35,7 @@ import com.anuththara18.attentionassessment.gender.GenderActivity; ...@@ -35,6 +35,7 @@ import com.anuththara18.attentionassessment.gender.GenderActivity;
import com.anuththara18.attentionassessment.home.NavigationDrawerActivity; import com.anuththara18.attentionassessment.home.NavigationDrawerActivity;
import com.anuththara18.attentionassessment.language.LanguageSetter; import com.anuththara18.attentionassessment.language.LanguageSetter;
import com.anuththara18.attentionassessment.map.Map1Activity; import com.anuththara18.attentionassessment.map.Map1Activity;
import com.anuththara18.attentionassessment.map.Map2Activity;
import com.anuththara18.attentionassessment.sustained.SustainedAttentionGame1; import com.anuththara18.attentionassessment.sustained.SustainedAttentionGame1;
import org.json.JSONException; import org.json.JSONException;
...@@ -49,6 +50,7 @@ import java.util.List; ...@@ -49,6 +50,7 @@ import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.Set; import java.util.Set;
import static com.anuththara18.attentionassessment.consentform.GetSignatureActivity.myEdit;
import static com.anuththara18.attentionassessment.map.Map1Activity.comp1; import static com.anuththara18.attentionassessment.map.Map1Activity.comp1;
import static com.anuththara18.attentionassessment.map.Map1Activity.comp2; import static com.anuththara18.attentionassessment.map.Map1Activity.comp2;
...@@ -408,14 +410,22 @@ public class FocusedAttentionGame1 extends AppCompatActivity { ...@@ -408,14 +410,22 @@ public class FocusedAttentionGame1 extends AppCompatActivity {
saveDataToOnlineDB(); saveDataToOnlineDB();
createTable(); createTable();
saveDataToLocalDB(); saveDataToLocalDB();
if (Map1Activity.level == 3){ if (Map1Activity.level == 3){
Map1Activity.comp3 = 1; Map1Activity.comp3 = 1;
myEdit.putInt("fal3", Map1Activity.comp3);
myEdit.commit();
} }
else if (Map1Activity.level == 4){ else if (Map1Activity.level == 4){
Map1Activity.comp4 = 1; Map1Activity.comp4 = 1;
myEdit.putInt("fal4", Map1Activity.comp4);
myEdit.commit();
} }
else if (Map1Activity.level == 5){ else if (Map1Activity.level == 5){
Map1Activity.comp5 = 1; Map1Activity.comp5 = 1;
myEdit.putInt("fal5", Map1Activity.comp5);
myEdit.commit();
} }
Intent intent = new Intent(getApplicationContext(), FACompleteScreen.class); Intent intent = new Intent(getApplicationContext(), FACompleteScreen.class);
finish(); finish();
......
...@@ -37,6 +37,7 @@ import java.util.Iterator; ...@@ -37,6 +37,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import static com.anuththara18.attentionassessment.consentform.GetSignatureActivity.myEdit;
import static com.anuththara18.attentionassessment.map.Map1Activity.comp1; import static com.anuththara18.attentionassessment.map.Map1Activity.comp1;
import static com.anuththara18.attentionassessment.map.Map1Activity.comp2; import static com.anuththara18.attentionassessment.map.Map1Activity.comp2;
...@@ -148,7 +149,7 @@ public class FocusedAttentionGame2 extends AppCompatActivity { ...@@ -148,7 +149,7 @@ public class FocusedAttentionGame2 extends AppCompatActivity {
} }
// appearance - 1s * 20 times // appearance - 1s * 20 times
else { else {
if ( Map1Activity.level == 1 ) { if ( Map1Activity.level == 1 || Map1Activity.level == 2 ) {
if ( i == 2 || i == 14 || i == 26 || i == 38 ) { if ( i == 2 || i == 14 || i == 26 || i == 38 ) {
bear1.setVisibility(View.VISIBLE); bear1.setVisibility(View.VISIBLE);
...@@ -225,9 +226,13 @@ public class FocusedAttentionGame2 extends AppCompatActivity { ...@@ -225,9 +226,13 @@ public class FocusedAttentionGame2 extends AppCompatActivity {
saveDataToLocalDB(); saveDataToLocalDB();
if (Map1Activity.level == 1){ if (Map1Activity.level == 1){
comp1 = 1; comp1 = 1;
myEdit.putInt("fal1", Map1Activity.comp1);
myEdit.commit();
} }
else if (Map1Activity.level == 2){ else if (Map1Activity.level == 2){
comp2 = 1; comp2 = 1;
myEdit.putInt("fal2", Map1Activity.comp2);
myEdit.commit();
} }
Intent intent = new Intent(getApplicationContext(), FACompleteScreen.class); Intent intent = new Intent(getApplicationContext(), FACompleteScreen.class);
finish(); finish();
......
package com.anuththara18.attentionassessment.language; package com.anuththara18.attentionassessment.language;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent; import android.content.Intent;
...@@ -23,6 +24,10 @@ import android.widget.Toast; ...@@ -23,6 +24,10 @@ import android.widget.Toast;
import com.anuththara18.attentionassessment.R; import com.anuththara18.attentionassessment.R;
import com.anuththara18.attentionassessment.details.ParentDetailsActivity; import com.anuththara18.attentionassessment.details.ParentDetailsActivity;
import com.anuththara18.attentionassessment.gender.GenderActivity; import com.anuththara18.attentionassessment.gender.GenderActivity;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
...@@ -31,6 +36,7 @@ public class LanguageActivity extends AppCompatActivity { ...@@ -31,6 +36,7 @@ public class LanguageActivity extends AppCompatActivity {
ImageView english_btn, sinhala_btn; ImageView english_btn, sinhala_btn;
TextView english_txt; TextView english_txt;
public static String text = ""; public static String text = "";
public static String uid = "";
public static final String sharedKey = "Language"; public static final String sharedKey = "Language";
TextView selectLanguage; TextView selectLanguage;
ImageButton next, sinhala_txt_btn; ImageButton next, sinhala_txt_btn;
...@@ -62,6 +68,18 @@ public class LanguageActivity extends AppCompatActivity { ...@@ -62,6 +68,18 @@ public class LanguageActivity extends AppCompatActivity {
sharedPref = getSharedPreferences(sharedKey, MODE_PRIVATE); sharedPref = getSharedPreferences(sharedKey, MODE_PRIVATE);
FirebaseAuth auth = FirebaseAuth.getInstance();
if ( auth.getCurrentUser() == null ) {
auth.signInAnonymously().addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Log.i("**********************************************test user", String.valueOf(task.isSuccessful()));
Log.i("**********************************************test user2", String.valueOf(auth.getCurrentUser().getUid()));
uid = auth.getCurrentUser().getUid();
}
});
}
int bt_notes_blink = 0; int bt_notes_blink = 0;
if (text.equals("English")){ if (text.equals("English")){
......
...@@ -3,8 +3,14 @@ package com.anuththara18.attentionassessment.map; ...@@ -3,8 +3,14 @@ package com.anuththara18.attentionassessment.map;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.media.MediaPlayer;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View; import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageButton; import android.widget.ImageButton;
import com.anuththara18.attentionassessment.R; import com.anuththara18.attentionassessment.R;
...@@ -20,10 +26,12 @@ public class Map1Activity extends AppCompatActivity { ...@@ -20,10 +26,12 @@ public class Map1Activity extends AppCompatActivity {
ImageButton imageButton1, imageButton2, imageButton3, imageButton4, imageButton5; ImageButton imageButton1, imageButton2, imageButton3, imageButton4, imageButton5;
ImageButton star1, star2, star3, star4, star5; ImageButton star1, star2, star3, star4, star5;
public static int comp1, comp2, comp3, comp4, comp5 = 0; public static int comp1 = 0, comp2 = 0, comp3 = 0, comp4 = 0, comp5 = 0;
public static int level = 1; public static int level = 1;
MediaPlayer mp;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -46,26 +54,134 @@ public class Map1Activity extends AppCompatActivity { ...@@ -46,26 +54,134 @@ public class Map1Activity extends AppCompatActivity {
star4.setVisibility(View.INVISIBLE); star4.setVisibility(View.INVISIBLE);
star5.setVisibility(View.INVISIBLE); star5.setVisibility(View.INVISIBLE);
// Retrieving the value using its keys the file name
// must be same in both saving and retrieving the data
SharedPreferences sh = getSharedPreferences("MySharedPref", MODE_PRIVATE);
// The value will be default as empty string because for
// the very first time when the app is opened, there is nothing to show
comp1 = sh.getInt("fal1", 0);
comp2 = sh.getInt("fal2", 0);
comp3 = sh.getInt("fal3", 0);
comp4 = sh.getInt("fal4", 0);
comp5 = sh.getInt("fal5", 0);
Log.d("@@@@@@@@@@@@@@@@@@@@@@@@", String.valueOf(comp1));
Log.d("@@@@@@@@@@@@@@@@@@@@@@@@", String.valueOf(comp2));
Log.d("@@@@@@@@@@@@@@@@@@@@@@@@", String.valueOf(comp3));
Log.d("@@@@@@@@@@@@@@@@@@@@@@@@", String.valueOf(comp4));
Log.d("@@@@@@@@@@@@@@@@@@@@@@@@", String.valueOf(comp5));
if (comp1 == 1) { if (comp1 == 1) {
star1.setVisibility(View.VISIBLE); star1.setVisibility(View.VISIBLE);
star1.bringToFront();
} }
if (comp2 == 1){ if (comp2 == 1){
star2.setVisibility(View.VISIBLE); star2.setVisibility(View.VISIBLE);
star2.bringToFront();
} }
if (comp3 == 1){ if (comp3 == 1){
star3.setVisibility(View.VISIBLE); star3.setVisibility(View.VISIBLE);
star3.bringToFront();
} }
if (comp4 == 1){ if (comp4 == 1){
star4.setVisibility(View.VISIBLE); star4.setVisibility(View.VISIBLE);
star4.bringToFront();
} }
if (comp5 == 1){ if (comp5 == 1){
star5.setVisibility(View.VISIBLE); star5.setVisibility(View.VISIBLE);
star5.bringToFront();
}
if (comp1 == 0) {
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
Animation animZoomOut = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.zoom_out);
imageButton1.startAnimation(animZoomOut);
handler.postDelayed(this, 750);
}
});
}
}, 0);
}
else if (comp2 == 0){
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
Animation animZoomOut = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.zoom_out);
imageButton2.startAnimation(animZoomOut);
handler.postDelayed(this, 750);
}
});
}
}, 0);
}
else if (comp3 == 0){
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
Animation animZoomOut = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.zoom_out);
imageButton3.startAnimation(animZoomOut);
handler.postDelayed(this, 750);
}
});
}
}, 0);
}
else if (comp4 == 0){
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
Animation animZoomOut = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.zoom_out);
imageButton4.startAnimation(animZoomOut);
handler.postDelayed(this, 750);
}
});
} }
}, 0);
}
else if (comp5 == 0){
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
Animation animZoomOut = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.zoom_out);
imageButton5.startAnimation(animZoomOut);
handler.postDelayed(this, 750);
}
});
}
}, 0);
}
imageButton1.setOnClickListener(new View.OnClickListener() { imageButton1.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
level = 1; level = 1;
mp = MediaPlayer.create(getApplicationContext(), R.raw.button_click);
mp.start();
Animation animZoomOut = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.zoom_out);
imageButton5.startAnimation(animZoomOut);
Intent intent = new Intent(getApplicationContext(), IntroductoryVideoLandscapeActivity.class); Intent intent = new Intent(getApplicationContext(), IntroductoryVideoLandscapeActivity.class);
finish(); finish();
startActivity(intent); startActivity(intent);
...@@ -76,6 +192,8 @@ public class Map1Activity extends AppCompatActivity { ...@@ -76,6 +192,8 @@ public class Map1Activity extends AppCompatActivity {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
level = 2; level = 2;
mp = MediaPlayer.create(getApplicationContext(), R.raw.button_click);
mp.start();
Intent intent = new Intent(getApplicationContext(), IntroductoryVideoLandscapeActivity.class); Intent intent = new Intent(getApplicationContext(), IntroductoryVideoLandscapeActivity.class);
finish(); finish();
startActivity(intent); startActivity(intent);
...@@ -86,6 +204,8 @@ public class Map1Activity extends AppCompatActivity { ...@@ -86,6 +204,8 @@ public class Map1Activity extends AppCompatActivity {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
level = 3; level = 3;
mp = MediaPlayer.create(getApplicationContext(), R.raw.button_click);
mp.start();
Intent intent = new Intent(getApplicationContext(), IntroductoryVideoPortraitActivity.class); Intent intent = new Intent(getApplicationContext(), IntroductoryVideoPortraitActivity.class);
finish(); finish();
startActivity(intent); startActivity(intent);
...@@ -96,6 +216,8 @@ public class Map1Activity extends AppCompatActivity { ...@@ -96,6 +216,8 @@ public class Map1Activity extends AppCompatActivity {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
level = 4; level = 4;
mp = MediaPlayer.create(getApplicationContext(), R.raw.button_click);
mp.start();
Intent intent = new Intent(getApplicationContext(), IntroductoryVideoPortraitActivity.class); Intent intent = new Intent(getApplicationContext(), IntroductoryVideoPortraitActivity.class);
finish(); finish();
startActivity(intent); startActivity(intent);
...@@ -106,6 +228,8 @@ public class Map1Activity extends AppCompatActivity { ...@@ -106,6 +228,8 @@ public class Map1Activity extends AppCompatActivity {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
level = 5; level = 5;
mp = MediaPlayer.create(getApplicationContext(), R.raw.button_click);
mp.start();
Intent intent = new Intent(getApplicationContext(), IntroductoryVideoLandscapeActivity.class); Intent intent = new Intent(getApplicationContext(), IntroductoryVideoLandscapeActivity.class);
finish(); finish();
startActivity(intent); startActivity(intent);
......
...@@ -3,10 +3,16 @@ package com.anuththara18.attentionassessment.map; ...@@ -3,10 +3,16 @@ package com.anuththara18.attentionassessment.map;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.media.MediaPlayer;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View; import android.view.View;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageButton; import android.widget.ImageButton;
import com.anuththara18.attentionassessment.R; import com.anuththara18.attentionassessment.R;
...@@ -19,10 +25,13 @@ public class Map2Activity extends AppCompatActivity { ...@@ -19,10 +25,13 @@ public class Map2Activity extends AppCompatActivity {
ImageButton imageButton1, imageButton2, imageButton3, imageButton4, imageButton5; ImageButton imageButton1, imageButton2, imageButton3, imageButton4, imageButton5;
ImageButton star1, star2, star3, star4, star5; ImageButton star1, star2, star3, star4, star5;
public static int comp1, comp2, comp3, comp4, comp5 = 0; public static int comp1 = 0, comp2 = 0, comp3 = 0, comp4 = 0, comp5 = 0;
public static int level = 1; public static int level = 1;
MediaPlayer mp;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -53,26 +62,134 @@ public class Map2Activity extends AppCompatActivity { ...@@ -53,26 +62,134 @@ public class Map2Activity extends AppCompatActivity {
star4.setVisibility(View.INVISIBLE); star4.setVisibility(View.INVISIBLE);
star5.setVisibility(View.INVISIBLE); star5.setVisibility(View.INVISIBLE);
// Retrieving the value using its keys the file name
// must be same in both saving and retrieving the data
SharedPreferences sh = getSharedPreferences("MySharedPref", MODE_PRIVATE);
// The value will be default as empty string because for
// the very first time when the app is opened, there is nothing to show
comp1 = sh.getInt("sel1", 0);
comp2 = sh.getInt("sel2", 0);
comp3 = sh.getInt("sel3", 0);
comp4 = sh.getInt("sel4", 0);
comp5 = sh.getInt("sel5", 0);
Log.d("@@@@@@@@@@@@@@@@@@@@@@@@", String.valueOf(comp1));
Log.d("@@@@@@@@@@@@@@@@@@@@@@@@", String.valueOf(comp2));
Log.d("@@@@@@@@@@@@@@@@@@@@@@@@", String.valueOf(comp3));
Log.d("@@@@@@@@@@@@@@@@@@@@@@@@", String.valueOf(comp4));
Log.d("@@@@@@@@@@@@@@@@@@@@@@@@", String.valueOf(comp5));
if (comp1 == 1) { if (comp1 == 1) {
star1.setVisibility(View.VISIBLE); star1.setVisibility(View.VISIBLE);
star1.bringToFront();
} }
if (comp2 == 1){ if (comp2 == 1){
star2.setVisibility(View.VISIBLE); star2.setVisibility(View.VISIBLE);
star2.bringToFront();
} }
if (comp3 == 1){ if (comp3 == 1){
star3.setVisibility(View.VISIBLE); star3.setVisibility(View.VISIBLE);
star3.bringToFront();
} }
if (comp4 == 1){ if (comp4 == 1){
star4.setVisibility(View.VISIBLE); star4.setVisibility(View.VISIBLE);
star4.bringToFront();
} }
if (comp5 == 1){ if (comp5 == 1){
star5.setVisibility(View.VISIBLE); star5.setVisibility(View.VISIBLE);
star5.bringToFront();
}
if (comp1 == 0) {
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
Animation animZoomOut = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.zoom_out);
imageButton1.startAnimation(animZoomOut);
handler.postDelayed(this, 750);
}
});
}
}, 0);
}
else if (comp2 == 0){
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
Animation animZoomOut = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.zoom_out);
imageButton2.startAnimation(animZoomOut);
handler.postDelayed(this, 750);
}
});
}
}, 0);
}
else if (comp3 == 0){
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
Animation animZoomOut = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.zoom_out);
imageButton3.startAnimation(animZoomOut);
handler.postDelayed(this, 750);
}
});
}
}, 0);
}
else if (comp4 == 0){
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
Animation animZoomOut = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.zoom_out);
imageButton4.startAnimation(animZoomOut);
handler.postDelayed(this, 750);
}
});
}
}, 0);
}
else if (comp5 == 0){
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
Animation animZoomOut = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.zoom_out);
imageButton5.startAnimation(animZoomOut);
handler.postDelayed(this, 750);
}
});
}
}, 0);
} }
imageButton1.setOnClickListener(new View.OnClickListener() { imageButton1.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
level = 1; level = 1;
mp = MediaPlayer.create(getApplicationContext(), R.raw.button_click);
mp.start();
Animation animZoomOut = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.zoom_out);
imageButton5.startAnimation(animZoomOut);
Intent intent = new Intent(getApplicationContext(), IntroductoryVideoPortraitActivity.class); Intent intent = new Intent(getApplicationContext(), IntroductoryVideoPortraitActivity.class);
finish(); finish();
startActivity(intent); startActivity(intent);
...@@ -83,6 +200,8 @@ public class Map2Activity extends AppCompatActivity { ...@@ -83,6 +200,8 @@ public class Map2Activity extends AppCompatActivity {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
level = 2; level = 2;
mp = MediaPlayer.create(getApplicationContext(), R.raw.button_click);
mp.start();
Intent intent = new Intent(getApplicationContext(), IntroductoryVideoPortraitActivity.class); Intent intent = new Intent(getApplicationContext(), IntroductoryVideoPortraitActivity.class);
finish(); finish();
startActivity(intent); startActivity(intent);
...@@ -93,6 +212,8 @@ public class Map2Activity extends AppCompatActivity { ...@@ -93,6 +212,8 @@ public class Map2Activity extends AppCompatActivity {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
level = 3; level = 3;
mp = MediaPlayer.create(getApplicationContext(), R.raw.button_click);
mp.start();
Intent intent = new Intent(getApplicationContext(), IntroductoryVideoPortraitActivity.class); Intent intent = new Intent(getApplicationContext(), IntroductoryVideoPortraitActivity.class);
finish(); finish();
startActivity(intent); startActivity(intent);
...@@ -103,6 +224,8 @@ public class Map2Activity extends AppCompatActivity { ...@@ -103,6 +224,8 @@ public class Map2Activity extends AppCompatActivity {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
level = 4; level = 4;
mp = MediaPlayer.create(getApplicationContext(), R.raw.button_click);
mp.start();
Intent intent = new Intent(getApplicationContext(), IntroductoryVideoPortraitActivity.class); Intent intent = new Intent(getApplicationContext(), IntroductoryVideoPortraitActivity.class);
finish(); finish();
startActivity(intent); startActivity(intent);
...@@ -113,6 +236,8 @@ public class Map2Activity extends AppCompatActivity { ...@@ -113,6 +236,8 @@ public class Map2Activity extends AppCompatActivity {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
level = 5; level = 5;
mp = MediaPlayer.create(getApplicationContext(), R.raw.button_click);
mp.start();
Intent intent = new Intent(getApplicationContext(), IntroductoryVideoPortraitActivity.class); Intent intent = new Intent(getApplicationContext(), IntroductoryVideoPortraitActivity.class);
finish(); finish();
startActivity(intent); startActivity(intent);
......
...@@ -318,7 +318,6 @@ public class SelectiveACompleteScreen extends AppCompatActivity { ...@@ -318,7 +318,6 @@ public class SelectiveACompleteScreen extends AppCompatActivity {
super.onRequestPermissionsResult(requestCode, permissions, grantResults); super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == PERMISSION_REQUEST_CODE) { if (requestCode == PERMISSION_REQUEST_CODE) {
if (grantResults.length > 0) { if (grantResults.length > 0) {
// after requesting permissions we are showing // after requesting permissions we are showing
// users a toast message of permission granted. // users a toast message of permission granted.
boolean writeStorage = grantResults[0] == PackageManager.PERMISSION_GRANTED; boolean writeStorage = grantResults[0] == PackageManager.PERMISSION_GRANTED;
...@@ -361,7 +360,8 @@ public class SelectiveACompleteScreen extends AppCompatActivity { ...@@ -361,7 +360,8 @@ public class SelectiveACompleteScreen extends AppCompatActivity {
auth.signInAnonymously().addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { auth.signInAnonymously().addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override @Override
public void onComplete(@NonNull Task<AuthResult> task) { public void onComplete(@NonNull Task<AuthResult> task) {
Log.i("test user", String.valueOf(task.isSuccessful())); Log.i("**********************************************test user", String.valueOf(task.isSuccessful()));
Log.i("**********************************************test user", String.valueOf(auth.getCurrentUser().getUid()));
} }
}); });
} }
...@@ -376,7 +376,6 @@ public class SelectiveACompleteScreen extends AppCompatActivity { ...@@ -376,7 +376,6 @@ public class SelectiveACompleteScreen extends AppCompatActivity {
@Override @Override
public void onProgress(@NonNull UploadTask.TaskSnapshot snapshot) { public void onProgress(@NonNull UploadTask.TaskSnapshot snapshot) {
//Toast.makeText(getApplicationContext(), "Upload Filed", Toast.LENGTH_SHORT).show(); //Toast.makeText(getApplicationContext(), "Upload Filed", Toast.LENGTH_SHORT).show();
} }
}).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() { }).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override @Override
......
...@@ -5,6 +5,7 @@ import androidx.appcompat.app.AppCompatActivity; ...@@ -5,6 +5,7 @@ import androidx.appcompat.app.AppCompatActivity;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.media.MediaPlayer; import android.media.MediaPlayer;
...@@ -46,6 +47,7 @@ import java.util.Date; ...@@ -46,6 +47,7 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Random; import java.util.Random;
import static com.anuththara18.attentionassessment.consentform.GetSignatureActivity.myEdit;
import static com.anuththara18.attentionassessment.map.Map1Activity.comp1; import static com.anuththara18.attentionassessment.map.Map1Activity.comp1;
import static com.anuththara18.attentionassessment.map.Map1Activity.comp2; import static com.anuththara18.attentionassessment.map.Map1Activity.comp2;
...@@ -431,21 +433,36 @@ public class SelectiveAttentionGame1 extends AppCompatActivity { ...@@ -431,21 +433,36 @@ public class SelectiveAttentionGame1 extends AppCompatActivity {
gridView.setAdapter(adapter); gridView.setAdapter(adapter);
gridView.setEnabled(false); gridView.setEnabled(false);
if (Map2Activity.level == 1){ if (Map2Activity.level == 1){
Map2Activity.comp1 = 1; Map2Activity.comp1 = 1;
// Storing the key and its value as the data fetched from edittext
myEdit.putInt("sel1", Integer.parseInt(String.valueOf(Map2Activity.comp1)));
// Once the changes have been made,
// we need to commit to apply those changes made,
// otherwise, it will throw an error
myEdit.commit();
} }
else if (Map2Activity.level == 2){ else if (Map2Activity.level == 2){
Map2Activity.comp2 = 1; Map2Activity.comp2 = 1;
Log.d("***************", "level 2 done"); myEdit.putInt("sel2", Map2Activity.comp2);
myEdit.commit();
} }
else if (Map2Activity.level == 3){ else if (Map2Activity.level == 3){
Map2Activity.comp3 = 1; Map2Activity.comp3 = 1;
myEdit.putInt("sel3", Map2Activity.comp3);
myEdit.commit();
} }
else if (Map2Activity.level == 4){ else if (Map2Activity.level == 4){
Map2Activity.comp4 = 1; Map2Activity.comp4 = 1;
myEdit.putInt("sel4", Map2Activity.comp4);
myEdit.commit();
} }
else if (Map2Activity.level == 5){ else if (Map2Activity.level == 5){
Map2Activity.comp5 = 1; Map2Activity.comp5 = 1;
myEdit.putInt("sel5", Map2Activity.comp5);
myEdit.commit();
} }
saveDataToOnlineDB(); saveDataToOnlineDB();
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
android:text="@string/consentForm" android:text="@string/consentForm"
android:textAlignment="center" android:textAlignment="center"
android:textColor="@color/black" android:textColor="@color/black"
android:textSize="20dp" android:textSize="18dp"
android:textStyle="bold" android:textStyle="bold"
android:gravity="center_horizontal" /> android:gravity="center_horizontal" />
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
android:layout_width="90dp" android:layout_width="90dp"
android:layout_height="81.95dp" android:layout_height="81.95dp"
android:background="@drawable/num1" android:background="@drawable/num1"
android:elevation="20dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.464" app:layout_constraintHorizontal_bias="0.464"
......
...@@ -19,19 +19,6 @@ ...@@ -19,19 +19,6 @@
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.038" /> app:layout_constraintVertical_bias="0.038" />
<ImageButton
android:id="@+id/star1"
android:layout_width="110dp"
android:layout_height="101.95dp"
android:background="@drawable/stars"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="-20dp"
app:layout_constraintHorizontal_bias="0.472"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.000" />
<ImageButton <ImageButton
android:id="@+id/imageButton2" android:id="@+id/imageButton2"
...@@ -138,4 +125,18 @@ ...@@ -138,4 +125,18 @@
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.800" /> app:layout_constraintVertical_bias="0.800" />
<ImageButton
android:id="@+id/star1"
android:layout_width="110dp"
android:layout_height="101.95dp"
android:background="@drawable/stars"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="-20dp"
app:layout_constraintHorizontal_bias="0.472"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.000" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
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