From d55d5943e33f622b2edb4c3a96c0787dd2c6d5f2 Mon Sep 17 00:00:00 2001 From: aarnaude <antoine.arnaudet@polytech-lille.net> Date: Tue, 9 Jan 2018 14:07:52 +0100 Subject: [PATCH] resolution Bravo --- .idea/modules.xml | 2 +- app/src/main/AndroidManifest.xml | 11 ++++++++++- app/src/main/java/tonio/noa/BravoActivity.java | 18 +++++++++++++++--- app/src/main/java/tonio/noa/MainActivity.java | 2 +- app/src/main/java/tonio/noa/MyPlayActivity.java | 42 ++++++++++++++++++++++++++++++++++++++++++ app/src/main/java/tonio/noa/TutorialActivity.java | 29 ----------------------------- app/src/main/java/tonio/noa/TutorialScene1Activity.java | 25 +++++++++++++++++++++++++ app/src/main/java/tonio/noa/TutorialScene2Activity.java | 23 +++++++++++++++++++++++ app/src/main/res/layout/bravo_display.xml | 7 ++++++- app/src/main/res/layout/tutorial1_display.xml | 31 +++++++++++++++++++++++++++++++ app/src/main/res/layout/tutorial2_display.xml | 23 +++++++++++++++++++++++ app/src/main/res/layout/tutorial_display.xml | 31 ------------------------------- build.gradle | 2 +- 13 files changed, 178 insertions(+), 68 deletions(-) create mode 100644 app/src/main/java/tonio/noa/MyPlayActivity.java delete mode 100644 app/src/main/java/tonio/noa/TutorialActivity.java create mode 100644 app/src/main/java/tonio/noa/TutorialScene1Activity.java create mode 100644 app/src/main/java/tonio/noa/TutorialScene2Activity.java create mode 100644 app/src/main/res/layout/tutorial1_display.xml create mode 100644 app/src/main/res/layout/tutorial2_display.xml delete mode 100644 app/src/main/res/layout/tutorial_display.xml diff --git a/.idea/modules.xml b/.idea/modules.xml index d92c38d..2cc43fc 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,7 @@ <project version="4"> <component name="ProjectModuleManager"> <modules> - <module fileurl="file://$PROJECT_DIR$/Noa.iml" filepath="$PROJECT_DIR$/Noa.iml" /> + <module fileurl="file://$PROJECT_DIR$/PFE.iml" filepath="$PROJECT_DIR$/PFE.iml" /> <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" /> </modules> </component> diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 981a7f6..f880dfd 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -46,7 +46,7 @@ </activity> <activity - android:name=".TutorialActivity" + android:name=".TutorialScene1Activity" android:parentActivityName=".MainActivity" android:screenOrientation="userLandscape"> <meta-data @@ -55,6 +55,15 @@ </activity> <activity + android:name=".TutorialScene2Activity" + android:parentActivityName=".TutorialScene1Activity" + android:screenOrientation="userLandscape"> + <meta-data + android:name="android.support.PARENT_ACTIVITY" + android:value=".MainActivity" /> + </activity> + + <activity android:name=".BravoActivity" android:screenOrientation="userLandscape"> </activity> diff --git a/app/src/main/java/tonio/noa/BravoActivity.java b/app/src/main/java/tonio/noa/BravoActivity.java index 538e520..4cba385 100644 --- a/app/src/main/java/tonio/noa/BravoActivity.java +++ b/app/src/main/java/tonio/noa/BravoActivity.java @@ -1,20 +1,32 @@ package tonio.noa; import android.app.Activity; +import android.content.Intent; import android.os.Bundle; +import android.view.MotionEvent; +import android.view.View; /** * Created by tonio on 23/11/17. */ -class BravoActivity extends Activity{ +public class BravoActivity extends Activity{ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + final Intent intent = getIntent(); setContentView(R.layout.bravo_display); - } - + View view = findViewById(R.id.bravo_view); + view.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View view,MotionEvent event) { + setResult(RESULT_OK,intent); + finish(); + return true; + } + }); + } } diff --git a/app/src/main/java/tonio/noa/MainActivity.java b/app/src/main/java/tonio/noa/MainActivity.java index bf82201..0b30f6f 100644 --- a/app/src/main/java/tonio/noa/MainActivity.java +++ b/app/src/main/java/tonio/noa/MainActivity.java @@ -28,7 +28,7 @@ public class MainActivity extends Activity { public void tutorialPage(View view){ - startActivity(new Intent(this, TutorialActivity.class)); + startActivity(new Intent(this, TutorialScene1Activity.class)); finish(); } } diff --git a/app/src/main/java/tonio/noa/MyPlayActivity.java b/app/src/main/java/tonio/noa/MyPlayActivity.java new file mode 100644 index 0000000..a7edabb --- /dev/null +++ b/app/src/main/java/tonio/noa/MyPlayActivity.java @@ -0,0 +1,42 @@ +package tonio.noa; + +import android.app.Activity; +import android.content.Intent; +import android.view.View; +import android.widget.Toast; + + +/** + * Created by psyk on 09/01/18. + */ + +public abstract class MyPlayActivity extends Activity { + + public static final int REQUEST_CODE = 1; + + protected abstract void next(); + + protected void bravoPage(View view){ + startActivityForResult(new Intent(this, BravoActivity.class), REQUEST_CODE); + } + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data){ + try { + super.onActivityResult(requestCode, resultCode, data); + + if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) { + this.next(); + finish(); + } + } catch (Exception ex) { + Toast.makeText(MyPlayActivity.this, ex.toString(), + Toast.LENGTH_SHORT).show(); + } + } + + public void backHome(View view) { + + startActivity(new Intent(this, MainActivity.class)); + finish(); + } +} diff --git a/app/src/main/java/tonio/noa/TutorialActivity.java b/app/src/main/java/tonio/noa/TutorialActivity.java deleted file mode 100644 index f8a8497..0000000 --- a/app/src/main/java/tonio/noa/TutorialActivity.java +++ /dev/null @@ -1,29 +0,0 @@ -package tonio.noa; - -import android.app.Activity; -import android.content.Intent; -import android.os.Bundle; -import android.view.View; - -/** - * Created by tonio on 22/11/17. - */ - -public class TutorialActivity extends Activity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - - super.onCreate(savedInstanceState); - setContentView(R.layout.tutorial_display); - } - - public void backHome(View view) { - - startActivity(new Intent(this, MainActivity.class)); - } - - public void bravoPage(View view){ - startActivity(new Intent(this, BravoActivity.class)); - } -} \ No newline at end of file diff --git a/app/src/main/java/tonio/noa/TutorialScene1Activity.java b/app/src/main/java/tonio/noa/TutorialScene1Activity.java new file mode 100644 index 0000000..882bfe0 --- /dev/null +++ b/app/src/main/java/tonio/noa/TutorialScene1Activity.java @@ -0,0 +1,25 @@ +package tonio.noa; + +import android.content.Intent; +import android.os.Bundle; +import android.view.View; + +/** + * Created by tonio on 22/11/17. + */ + +public class TutorialScene1Activity extends MyPlayActivity{ + + @Override + protected void next() { + startActivity(new Intent(this, TutorialScene2Activity.class)); + finish(); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + + super.onCreate(savedInstanceState); + setContentView(R.layout.tutorial1_display); + } +} \ No newline at end of file diff --git a/app/src/main/java/tonio/noa/TutorialScene2Activity.java b/app/src/main/java/tonio/noa/TutorialScene2Activity.java new file mode 100644 index 0000000..cf672d7 --- /dev/null +++ b/app/src/main/java/tonio/noa/TutorialScene2Activity.java @@ -0,0 +1,23 @@ +package tonio.noa; + +import android.os.Bundle; +import android.view.View; + +/** + * Created by psyk on 09/01/18. + */ + +public class TutorialScene2Activity extends MyPlayActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + + super.onCreate(savedInstanceState); + setContentView(R.layout.tutorial2_display); + } + + @Override + protected void next() { + finish(); + } +} diff --git a/app/src/main/res/layout/bravo_display.xml b/app/src/main/res/layout/bravo_display.xml index 4fcc0c7..a106dfa 100644 --- a/app/src/main/res/layout/bravo_display.xml +++ b/app/src/main/res/layout/bravo_display.xml @@ -2,6 +2,10 @@ <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" + android:focusable="true" + android:clickable="true" + android:focusableInTouchMode="true" + android:id="@+id/bravo_view" android:orientation="vertical"> <TextView @@ -9,13 +13,14 @@ android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" - android:text="Bien joué!" + android:text="Bien joué! Touche l'écran pour continuer à jouer!" android:textStyle="bold"/> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" + android:maxHeight="50dp" android:src="@drawable/bravo" /> </RelativeLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/tutorial1_display.xml b/app/src/main/res/layout/tutorial1_display.xml new file mode 100644 index 0000000..f8459e1 --- /dev/null +++ b/app/src/main/res/layout/tutorial1_display.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:layout_centerHorizontal="true" + android:text="Bienvenue dans la scène 1 du tutoriel!" /> + + <ImageButton + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerInParent="true" + android:background="?android:attr/selectableItemBackgroundBorderless" + android:src="@drawable/ballondefoot" + android:onClick="bravoPage"/> + + <Button + android:id="@+id/button_id_home" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_alignParentLeft="true" + android:onClick="backHome" + android:text="@string/home" /> + +</RelativeLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/tutorial2_display.xml b/app/src/main/res/layout/tutorial2_display.xml new file mode 100644 index 0000000..7046d3b --- /dev/null +++ b/app/src/main/res/layout/tutorial2_display.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:layout_centerHorizontal="true" + android:text="Tutoriel scène 2" /> + + <Button + android:id="@+id/button_id_home" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_alignParentLeft="true" + android:onClick="backHome" + android:text="@string/home" /> + +</RelativeLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/tutorial_display.xml b/app/src/main/res/layout/tutorial_display.xml deleted file mode 100644 index 5223e5f..0000000 --- a/app/src/main/res/layout/tutorial_display.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical"> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentTop="true" - android:layout_centerHorizontal="true" - android:text="Bienvenue dans le tutoriel!" /> - - <ImageButton - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_centerInParent="true" - android:background="?android:attr/selectableItemBackgroundBorderless" - android:src="@drawable/ballondefoot" - android:onClick="bravoPage"/> - - <Button - android:id="@+id/button_id_home" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentBottom="true" - android:layout_alignParentLeft="true" - android:onClick="backHome" - android:text="@string/home" /> - -</RelativeLayout> \ No newline at end of file diff --git a/build.gradle b/build.gradle index 020eae2..e6b32bc 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.0.0' + classpath 'com.android.tools.build:gradle:3.0.1' // NOTE: Do not place your application dependencies here; they belong -- libgit2 0.21.2