diff --git a/app/src/main/java/com/jorgecruces/metrometro/activities/MainActivity.java b/app/src/main/java/com/jorgecruces/metrometro/activities/MainActivity.java
index 9aa6b6e..8f4ae35 100644
--- a/app/src/main/java/com/jorgecruces/metrometro/activities/MainActivity.java
+++ b/app/src/main/java/com/jorgecruces/metrometro/activities/MainActivity.java
@@ -27,6 +27,12 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
setContentView(R.layout.activity_main);
}
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ }
+
public void goToLinesMenuActivity(View view) {
Intent intent = new Intent(this, MenuMetroActivity.class);
startActivity(intent);
@@ -100,9 +106,6 @@ public void showConfirmationResetDialog(View view) {
dialog.dismiss();
});
-
-
-
// Reset Shared Preferences
dialog.show();
}
diff --git a/app/src/main/java/com/jorgecruces/metrometro/activities/PlayGameActivity.java b/app/src/main/java/com/jorgecruces/metrometro/activities/PlayGameActivity.java
index 928f5a3..4efc47d 100644
--- a/app/src/main/java/com/jorgecruces/metrometro/activities/PlayGameActivity.java
+++ b/app/src/main/java/com/jorgecruces/metrometro/activities/PlayGameActivity.java
@@ -9,10 +9,12 @@
import android.content.res.Resources;
import android.media.MediaPlayer;
import android.os.Bundle;
+import android.util.Log;
import android.util.TypedValue;
import android.view.View;
import android.widget.Button;
import android.widget.HorizontalScrollView;
+import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
@@ -133,6 +135,7 @@ private void setLineName() {
throw new Error("Hubo un problema al iniciar el level");
}
this.lineName = extra.getString("LINEA");
+ Log.d("LINE NAME", this.lineName);
}
/**
@@ -301,6 +304,12 @@ public void onWinLevel() {
this.showWinningDialog();
}
+ private void resetLevel() {
+ Intent intent = new Intent(this.getApplicationContext(), PlayGameActivity.class);
+ intent.putExtra("LINEA", this.lineName);
+ this.startActivity(intent);
+ }
+
private void updateProgressInfo() {
SharedPreferences sharedPref = this.getSharedPreferences(
@@ -323,6 +332,8 @@ private void updateProgressInfo() {
private void showWinningDialog() {
// Show dialog
Dialog winningDialog = new Dialog(this);
+ winningDialog.setCancelable(false);
+ winningDialog.setCanceledOnTouchOutside(false);
winningDialog.setContentView(R.layout.winning_dialog);
// Button
@@ -335,9 +346,25 @@ private void showWinningDialog() {
winningDialog.show();
}
+
private void onIncorrectAlternative() {
- Toast.makeText(this, "INCORRECTO", Toast.LENGTH_SHORT).show();
- //TODO - add ads
+ this.onLostLevel();
+ }
+
+ private void onLostLevel() {
+ // TODO - Ads
+ Dialog lostDialog = new Dialog(this);
+ lostDialog.setCancelable(false);
+ lostDialog.setCanceledOnTouchOutside(false);
+ lostDialog.setContentView(R.layout.lost_dialog);
+
+ ImageView resetLevelImageView = (ImageView) lostDialog.findViewById(R.id.imageViewResetLevel);
+
+ resetLevelImageView.setOnClickListener(listener-> {
+ this.resetLevel();
+ });
+
+ lostDialog.show();
}
public void goBackToMenu(View view) {
diff --git a/app/src/main/java/com/jorgecruces/metrometro/logic/PickerStationsAlternative.java b/app/src/main/java/com/jorgecruces/metrometro/logic/PickerStationsAlternative.java
index dd91190..cc1b94f 100644
--- a/app/src/main/java/com/jorgecruces/metrometro/logic/PickerStationsAlternative.java
+++ b/app/src/main/java/com/jorgecruces/metrometro/logic/PickerStationsAlternative.java
@@ -1,16 +1,9 @@
package com.jorgecruces.metrometro.logic;
-import android.os.Build;
-import android.util.Log;
-
-import androidx.annotation.RequiresApi;
-
-import com.jorgecruces.metrometro.logger.LoggerSout;
import com.jorgecruces.metrometro.model.Station;
import java.util.ArrayList;
import java.util.Random;
-import java.util.concurrent.atomic.AtomicReferenceArray;
public class PickerStationsAlternative {
diff --git a/app/src/main/java/com/jorgecruces/metrometro/sound/MediaPlayerReproducer.java b/app/src/main/java/com/jorgecruces/metrometro/sound/MediaPlayerReproducer.java
index 4445a20..d4df513 100644
--- a/app/src/main/java/com/jorgecruces/metrometro/sound/MediaPlayerReproducer.java
+++ b/app/src/main/java/com/jorgecruces/metrometro/sound/MediaPlayerReproducer.java
@@ -1,58 +1,49 @@
package com.jorgecruces.metrometro.sound;
import android.content.Context;
-import android.media.AudioAttributes;
-import android.media.AudioManager;
import android.media.MediaPlayer;
-import android.media.SoundPool;
-import android.os.Build;
-import android.provider.MediaStore;
-import android.util.Log;
import com.jorgecruces.metrometro.R;
-import java.io.IOException;
/**
- * Singleton that reproduce the sound across the App
+ * Singleton class that works as a general Audio Manager
*/
public class MediaPlayerReproducer {
private static final MediaPlayerReproducer mp = new MediaPlayerReproducer();
+ private MediaPlayer mediaPlayer;
+
private boolean isAudioReproducing = true;
private boolean isMusicOn = true;
+ /**
+ Singleton Pattern
+ */
private MediaPlayerReproducer()
{
+ }
+ public static MediaPlayerReproducer getInstance()
+ {
+ return mp;
}
- /**
- * Change between reproduce Sound
- */
+
+ // Audio and Music Setting
public void changeAudioReproducing() {
isAudioReproducing = !isAudioReproducing;
}
-
- /**
- * Change between reproduce Music
- */
public void changeMusicReproducing() {
isMusicOn = !isMusicOn;
}
-
public boolean getAudioBoolean() {
return this.isAudioReproducing;
}
-
public boolean getMusicBoolean() {
return this.isMusicOn;
}
- public static MediaPlayerReproducer getInstance()
- {
- return mp;
- }
/**
* Reproduce click Sound
@@ -72,9 +63,17 @@ public void reproduceWinSound(Context context)
reproduceSound(context, R.raw.win_sound);
}
- public void reproduceMusic(Context context) {
+ public void reproduceMusicMainMenu(Context context) {
if (!isMusicOn) {return;}
+// this.mediaPlayer = MediaPlayer.create(context, R.raw.);
+// this.mediaPlayer.setLooping(true);
+// this.mediaPlayer.start();
+ }
+ public void stopMusicMainMenu() {
+ if (this.mediaPlayer != null) {
+ this.mediaPlayer.stop();
+ }
}
/**
diff --git a/app/src/main/res/drawable/gameplay_button_ad.png b/app/src/main/res/drawable/gameplay_button_ad.png
new file mode 100644
index 0000000..86c5701
Binary files /dev/null and b/app/src/main/res/drawable/gameplay_button_ad.png differ
diff --git a/app/src/main/res/layout/configuration_dialog.xml b/app/src/main/res/layout/configuration_dialog.xml
index 94df93e..6c07eeb 100644
--- a/app/src/main/res/layout/configuration_dialog.xml
+++ b/app/src/main/res/layout/configuration_dialog.xml
@@ -9,7 +9,7 @@
android:padding="5dp">
+ app:layout_constraintTop_toBottomOf="@+id/lostTextView" />
\ No newline at end of file
diff --git a/app/src/main/res/layout/lost_dialog.xml b/app/src/main/res/layout/lost_dialog.xml
new file mode 100644
index 0000000..56680cd
--- /dev/null
+++ b/app/src/main/res/layout/lost_dialog.xml
@@ -0,0 +1,79 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/winning_dialog.xml b/app/src/main/res/layout/winning_dialog.xml
index f0353f8..e8e125f 100644
--- a/app/src/main/res/layout/winning_dialog.xml
+++ b/app/src/main/res/layout/winning_dialog.xml
@@ -8,7 +8,7 @@
android:background="@color/white">
\ No newline at end of file