diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8d50716..5f7ca0d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -46,6 +46,37 @@ + + + + + + + + + + + + + + diff --git a/app/src/main/java/tonio/noa/Hygiene1Activity.java b/app/src/main/java/tonio/noa/Hygiene1Activity.java new file mode 100644 index 0000000..f10ee62 --- /dev/null +++ b/app/src/main/java/tonio/noa/Hygiene1Activity.java @@ -0,0 +1,100 @@ +package tonio.noa; + +import android.content.ClipData; +import android.content.Intent; +import android.os.Build; +import android.os.Bundle; +import android.view.DragEvent; +import android.view.MotionEvent; +import android.view.View; + +/** + * Created by psyk on 31/01/18. + */ + +public class Hygiene1Activity extends MyPlayActivity implements View.OnTouchListener, View.OnDragListener { + + @Override + protected void onCreate(Bundle savedInstanceState) { + + super.onCreate(savedInstanceState); + setContentView(R.layout.hygiene1_display); + + Intent i = new Intent(this, ConsigneActivity.class); + i.putExtra("keyConsigne", "Salut!\nTu peux mettre la brosse à dent bleu\nsur son ombre ?"); + int requestCode = 0; + startActivityForResult(i, requestCode); + + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + setContentView(R.layout.hygiene1_display); + findViewById(R.id.blue_toothbrush).setOnTouchListener(this); + findViewById(R.id.blue_toothbrush).setOnDragListener(this); + findViewById(R.id.shadow_toothbrush).setOnDragListener(this); + // do your stuff here after SecondActivity finished. + } + + + @Override + public boolean onTouch(View view, MotionEvent event) { + if (event.getAction() == MotionEvent.ACTION_DOWN) { + + View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view); + ClipData data = ClipData.newPlainText("id", view.getResources().getResourceEntryName(view.getId())); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + view.startDragAndDrop(data, shadowBuilder, view, 0); + } else { + view.startDrag(data, shadowBuilder, view, 0); + } + return true; + } else + return false; + } + + @Override + public boolean onDrag(View v, DragEvent event) { + switch (event.getAction()) { + // signal for the start of a drag and drop operation + case DragEvent.ACTION_DRAG_STARTED: + // do nothing + break; + + // the drag point has entered the bounding box of the View + case DragEvent.ACTION_DRAG_ENTERED: + // do nothing + break; + + // the user has moved the drag shadow outside the bounding box of the View + case DragEvent.ACTION_DRAG_EXITED: + // do nothing + break; + + // the drag and drop operation has concluded + case DragEvent.ACTION_DRAG_ENDED: + break; + + //drag shadow has been released,the drag point is within the bounding box of the View + case DragEvent.ACTION_DROP: + //handle the dragged view being dropped over a target view + View view = (View) event.getLocalState(); + if (v == findViewById(R.id.shadow_toothbrush)) { + //stop displaying the view where it was before it was dragged + view.setVisibility(View.INVISIBLE); + bravoPage(v); + } + break; + } + + return true; + } + + + @Override + protected void next() { + startActivity(new Intent(this, Hygiene2Activity.class)); + } +} diff --git a/app/src/main/java/tonio/noa/Hygiene2Activity.java b/app/src/main/java/tonio/noa/Hygiene2Activity.java new file mode 100644 index 0000000..dd25468 --- /dev/null +++ b/app/src/main/java/tonio/noa/Hygiene2Activity.java @@ -0,0 +1,100 @@ +package tonio.noa; + +import android.content.ClipData; +import android.content.Intent; +import android.os.Build; +import android.os.Bundle; +import android.view.DragEvent; +import android.view.MotionEvent; +import android.view.View; + +/** + * Created by psyk on 31/01/18. + */ + +public class Hygiene2Activity extends MyPlayActivity implements View.OnTouchListener, View.OnDragListener { + + @Override + protected void onCreate(Bundle savedInstanceState) { + + super.onCreate(savedInstanceState); + setContentView(R.layout.hygiene2_display); + + Intent i = new Intent(this, ConsigneActivity.class); + i.putExtra("keyConsigne", "Maintenant met le dessin de la brosse à dent\nsur la photo de la brosse à dent."); + int requestCode = 0; + startActivityForResult(i, requestCode); + + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + setContentView(R.layout.hygiene2_display); + findViewById(R.id.blue_toothbrush).setOnTouchListener(this); + findViewById(R.id.blue_toothbrush).setOnDragListener(this); + findViewById(R.id.blue_toothbrush_pic).setOnDragListener(this); + // do your stuff here after SecondActivity finished. + } + + + @Override + public boolean onTouch(View view, MotionEvent event) { + if (event.getAction() == MotionEvent.ACTION_DOWN) { + + View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view); + ClipData data = ClipData.newPlainText("id", view.getResources().getResourceEntryName(view.getId())); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + view.startDragAndDrop(data, shadowBuilder, view, 0); + } else { + view.startDrag(data, shadowBuilder, view, 0); + } + return true; + } else + return false; + } + + @Override + public boolean onDrag(View v, DragEvent event) { + switch (event.getAction()) { + // signal for the start of a drag and drop operation + case DragEvent.ACTION_DRAG_STARTED: + // do nothing + break; + + // the drag point has entered the bounding box of the View + case DragEvent.ACTION_DRAG_ENTERED: + // do nothing + break; + + // the user has moved the drag shadow outside the bounding box of the View + case DragEvent.ACTION_DRAG_EXITED: + // do nothing + break; + + // the drag and drop operation has concluded + case DragEvent.ACTION_DRAG_ENDED: + break; + + //drag shadow has been released,the drag point is within the bounding box of the View + case DragEvent.ACTION_DROP: + //handle the dragged view being dropped over a target view + View view = (View) event.getLocalState(); + if (v == findViewById(R.id.blue_toothbrush_pic)) { + //stop displaying the view where it was before it was dragged + view.setVisibility(View.INVISIBLE); + bravoPage(v); + } + break; + } + + return true; + } + + + @Override + protected void next() { + startActivity(new Intent(this, Hygiene3Activity.class)); + } +} diff --git a/app/src/main/java/tonio/noa/Hygiene3Activity.java b/app/src/main/java/tonio/noa/Hygiene3Activity.java new file mode 100644 index 0000000..3597dbd --- /dev/null +++ b/app/src/main/java/tonio/noa/Hygiene3Activity.java @@ -0,0 +1,100 @@ +package tonio.noa; + +import android.content.ClipData; +import android.content.Intent; +import android.os.Build; +import android.os.Bundle; +import android.view.DragEvent; +import android.view.MotionEvent; +import android.view.View; + +/** + * Created by psyk on 31/01/18. + */ + +public class Hygiene3Activity extends MyPlayActivity implements View.OnTouchListener, View.OnDragListener { + + @Override + protected void onCreate(Bundle savedInstanceState) { + + super.onCreate(savedInstanceState); + setContentView(R.layout.hygiene3_display); + + Intent i = new Intent(this, ConsigneActivity.class); + i.putExtra("keyConsigne", "Tu peux mettre la brosse à dent bleu\nsur la rouge?"); + int requestCode = 0; + startActivityForResult(i, requestCode); + + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + setContentView(R.layout.hygiene3_display); + findViewById(R.id.blue_toothbrush).setOnTouchListener(this); + findViewById(R.id.blue_toothbrush).setOnDragListener(this); + findViewById(R.id.red_toothbrush).setOnDragListener(this); + // do your stuff here after SecondActivity finished. + } + + + @Override + public boolean onTouch(View view, MotionEvent event) { + if (event.getAction() == MotionEvent.ACTION_DOWN) { + + View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view); + ClipData data = ClipData.newPlainText("id", view.getResources().getResourceEntryName(view.getId())); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + view.startDragAndDrop(data, shadowBuilder, view, 0); + } else { + view.startDrag(data, shadowBuilder, view, 0); + } + return true; + } else + return false; + } + + @Override + public boolean onDrag(View v, DragEvent event) { + switch (event.getAction()) { + // signal for the start of a drag and drop operation + case DragEvent.ACTION_DRAG_STARTED: + // do nothing + break; + + // the drag point has entered the bounding box of the View + case DragEvent.ACTION_DRAG_ENTERED: + // do nothing + break; + + // the user has moved the drag shadow outside the bounding box of the View + case DragEvent.ACTION_DRAG_EXITED: + // do nothing + break; + + // the drag and drop operation has concluded + case DragEvent.ACTION_DRAG_ENDED: + break; + + //drag shadow has been released,the drag point is within the bounding box of the View + case DragEvent.ACTION_DROP: + //handle the dragged view being dropped over a target view + View view = (View) event.getLocalState(); + if (v == findViewById(R.id.red_toothbrush)) { + //stop displaying the view where it was before it was dragged + view.setVisibility(View.INVISIBLE); + bravoPage(v); + } + break; + } + + return true; + } + + + @Override + protected void next() { + startActivity(new Intent(this, Hygiene4Activity.class)); + } +} diff --git a/app/src/main/java/tonio/noa/Hygiene4Activity.java b/app/src/main/java/tonio/noa/Hygiene4Activity.java new file mode 100644 index 0000000..72b4cf8 --- /dev/null +++ b/app/src/main/java/tonio/noa/Hygiene4Activity.java @@ -0,0 +1,127 @@ +package tonio.noa; + +import android.content.ClipData; +import android.content.Intent; +import android.os.Build; +import android.os.Bundle; +import android.view.DragEvent; +import android.view.MotionEvent; +import android.view.View; + +/** + * Created by psyk on 24/01/18. + */ + +public class Hygiene4Activity extends MyPlayActivity implements View.OnTouchListener, View.OnDragListener { + + private int win_counter = 0; + private boolean done = false; + + @Override + protected void onCreate(Bundle savedInstanceState) { + + super.onCreate(savedInstanceState); + Intent i = new Intent(this, ConsigneActivity.class); + i.putExtra("keyConsigne", "Tu peux m'aider ?\nPrépare mes affaires de toilette."); + int requestCode = 0; + startActivityForResult(i, requestCode); + + } + + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + + setContentView(R.layout.hygiene4_display); + + findViewById(R.id.snail).setOnTouchListener(this); + findViewById(R.id.towel).setOnTouchListener(this); + findViewById(R.id.elephant).setOnTouchListener(this); + findViewById(R.id.bmw).setOnTouchListener(this); + findViewById(R.id.toothpaste).setOnTouchListener(this); + findViewById(R.id.blue_toothbrush_pic).setOnTouchListener(this); + findViewById(R.id.trumpet).setOnTouchListener(this); + findViewById(R.id.soap).setOnTouchListener(this); + findViewById(R.id.shampoo).setOnTouchListener(this); + + findViewById(R.id.anchor_toilet_bag).setOnDragListener(this); + findViewById(R.id.snail).setOnDragListener(this); + findViewById(R.id.towel).setOnDragListener(this); + findViewById(R.id.elephant).setOnDragListener(this); + findViewById(R.id.bmw).setOnDragListener(this); + findViewById(R.id.toothpaste).setOnDragListener(this); + findViewById(R.id.blue_toothbrush_pic).setOnDragListener(this); + findViewById(R.id.trumpet).setOnDragListener(this); + findViewById(R.id.soap).setOnDragListener(this); + findViewById(R.id.shampoo).setOnDragListener(this); + } + + @Override + public boolean onTouch(View view, MotionEvent event) { + if (event.getAction() == MotionEvent.ACTION_DOWN) { + + View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view); + ClipData data = ClipData.newPlainText("id", view.getResources().getResourceEntryName(view.getId())); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + view.startDragAndDrop(data, shadowBuilder, view, 0); + } else { + view.startDrag(data, shadowBuilder, view, 0); + } + return true; + } else + return false; + } + + @Override + public boolean onDrag(View v, DragEvent event) { + switch (event.getAction()) { + // signal for the start of a drag and drop operation + case DragEvent.ACTION_DRAG_STARTED: + // do nothing + break; + + // the drag point has entered the bounding box of the View + case DragEvent.ACTION_DRAG_ENTERED: + // do nothing + break; + + // the user has moved the drag shadow outside the bounding box of the View + case DragEvent.ACTION_DRAG_EXITED: + // do nothing + break; + + // the drag and drop operation has concluded + case DragEvent.ACTION_DRAG_ENDED: + if (win_counter == 5 && !done) { + done = true; + bravoPage(v); + } + break; + + //drag shadow has been released,the drag point is within the bounding box of the View + case DragEvent.ACTION_DROP: + //handle the dragged view being dropped over a target view + View view = (View) event.getLocalState(); + if (v == findViewById(R.id.anchor_toilet_bag)) { + if (view == findViewById(R.id.towel) + || view == findViewById(R.id.toothpaste) + || view == findViewById(R.id.blue_toothbrush_pic) + || view == findViewById(R.id.shampoo) + || view == findViewById(R.id.soap)) { + //stop displaying the view where it was before it was dragged + view.setVisibility(View.INVISIBLE); + win_counter++; + } + else + } + break; + } + return true; + } + + + @Override + protected void next() { + + } +} diff --git a/app/src/main/java/tonio/noa/ThemeActivity.java b/app/src/main/java/tonio/noa/ThemeActivity.java index 4fb7cef..93955b1 100644 --- a/app/src/main/java/tonio/noa/ThemeActivity.java +++ b/app/src/main/java/tonio/noa/ThemeActivity.java @@ -24,7 +24,10 @@ public class ThemeActivity extends Activity { startActivity(new Intent(this, HealthActivity.class)); } + public void hygienePage(View view){ + startActivity(new Intent(this, Hygiene1Activity.class)); + } public void backHome(View view){ startActivity(new Intent( this, MainActivity.class)); diff --git a/app/src/main/java/tonio/noa/TutorialScene1Activity.java b/app/src/main/java/tonio/noa/TutorialScene1Activity.java index 9e12724..ca5b47a 100644 --- a/app/src/main/java/tonio/noa/TutorialScene1Activity.java +++ b/app/src/main/java/tonio/noa/TutorialScene1Activity.java @@ -13,7 +13,7 @@ public class TutorialScene1Activity extends MyPlayActivity{ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent i = new Intent(this, ConsigneActivity.class); - i.putExtra("keyConsigne","Salut mon pote!\nJe suis Noa.\nTu peux m'aider ?\nRetrouve mon ballon de football."); + i.putExtra("keyConsigne","Salut!\nJe suis Noa.\nTu peux retrouver mon ballon de football?\nTouche l'écran pour m'aider."); int requestCode = 0; startActivityForResult(i,requestCode); } diff --git a/app/src/main/java/tonio/noa/TutorialScene4Activity.java b/app/src/main/java/tonio/noa/TutorialScene4Activity.java index a407ba5..14b3840 100644 --- a/app/src/main/java/tonio/noa/TutorialScene4Activity.java +++ b/app/src/main/java/tonio/noa/TutorialScene4Activity.java @@ -22,7 +22,7 @@ public class TutorialScene4Activity extends MyPlayActivity implements View.OnTou super.onCreate(savedInstanceState); Intent i = new Intent(this, ConsigneActivity.class); - i.putExtra("keyConsigne", "Tu peux mettre les petits carrés de couleurs sur les gros de la même couleur ?\nMerci mon pote!"); + i.putExtra("keyConsigne", "Tu peux mettre les petits carrés de couleurs sur les gros de la même couleur ?\nMerci !"); int requestCode = 0; startActivityForResult(i, requestCode); diff --git a/app/src/main/res/drawable/blue_toothbrush.png b/app/src/main/res/drawable/blue_toothbrush.png new file mode 100644 index 0000000..7eb5cea Binary files /dev/null and b/app/src/main/res/drawable/blue_toothbrush.png differ diff --git a/app/src/main/res/drawable/blue_toothbrush_pic.png b/app/src/main/res/drawable/blue_toothbrush_pic.png new file mode 100644 index 0000000..1e1d786 Binary files /dev/null and b/app/src/main/res/drawable/blue_toothbrush_pic.png differ diff --git a/app/src/main/res/drawable/bmw.png b/app/src/main/res/drawable/bmw.png new file mode 100644 index 0000000..5a8942a Binary files /dev/null and b/app/src/main/res/drawable/bmw.png differ diff --git a/app/src/main/res/drawable/elephant.png b/app/src/main/res/drawable/elephant.png new file mode 100644 index 0000000..fb0dcf1 Binary files /dev/null and b/app/src/main/res/drawable/elephant.png differ diff --git a/app/src/main/res/drawable/red_toothbrush.png b/app/src/main/res/drawable/red_toothbrush.png new file mode 100644 index 0000000..62d62f3 Binary files /dev/null and b/app/src/main/res/drawable/red_toothbrush.png differ diff --git a/app/src/main/res/drawable/shampoo.png b/app/src/main/res/drawable/shampoo.png new file mode 100644 index 0000000..3a384c6 Binary files /dev/null and b/app/src/main/res/drawable/shampoo.png differ diff --git a/app/src/main/res/drawable/snail.png b/app/src/main/res/drawable/snail.png new file mode 100644 index 0000000..a8f014d Binary files /dev/null and b/app/src/main/res/drawable/snail.png differ diff --git a/app/src/main/res/drawable/soap.png b/app/src/main/res/drawable/soap.png new file mode 100644 index 0000000..f7cbc03 Binary files /dev/null and b/app/src/main/res/drawable/soap.png differ diff --git a/app/src/main/res/drawable/toilet_bag.png b/app/src/main/res/drawable/toilet_bag.png new file mode 100644 index 0000000..7a0f8b0 Binary files /dev/null and b/app/src/main/res/drawable/toilet_bag.png differ diff --git a/app/src/main/res/drawable/toothpaste.png b/app/src/main/res/drawable/toothpaste.png new file mode 100644 index 0000000..bc8c8ab Binary files /dev/null and b/app/src/main/res/drawable/toothpaste.png differ diff --git a/app/src/main/res/drawable/towel.png b/app/src/main/res/drawable/towel.png new file mode 100644 index 0000000..6991f32 Binary files /dev/null and b/app/src/main/res/drawable/towel.png differ diff --git a/app/src/main/res/drawable/trumpet.png b/app/src/main/res/drawable/trumpet.png new file mode 100644 index 0000000..9648ad9 Binary files /dev/null and b/app/src/main/res/drawable/trumpet.png differ diff --git a/app/src/main/res/layout/hygiene1_display.xml b/app/src/main/res/layout/hygiene1_display.xml new file mode 100644 index 0000000..7032898 --- /dev/null +++ b/app/src/main/res/layout/hygiene1_display.xml @@ -0,0 +1,51 @@ + + + + + + + + + +