Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Commit

Permalink
Merge pull request #256 from MaximeZmt/margaux/artwork-on-answer
Browse files Browse the repository at this point in the history
margaux/artwork-on-answer
  • Loading branch information
zwierski authored May 6, 2022
2 parents 017ead4 + 1954ce9 commit 49b9a08
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class BuzzerScreenActivityTest {
}

@Test
fun answerIsPresentButGoneOnStartup() {
fun answerIsPresentButInvisibleOnStartup() {
val intent = Intent(ApplicationProvider.getApplicationContext(), BuzzerScreenActivity::class.java)

// Put mock extras inside
Expand Down
18 changes: 8 additions & 10 deletions app/src/main/java/ch/sdp/vibester/activity/BuzzerScreenActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,19 @@ import android.view.Gravity
import android.view.View
import android.view.Window
import android.widget.*
import androidx.appcompat.app.AppCompatActivity
import ch.sdp.vibester.BuzzerScoreUpdater
import ch.sdp.vibester.R
import ch.sdp.vibester.helper.GameManager
import ch.sdp.vibester.helper.BuzzerGameManager
import ch.sdp.vibester.model.Song
import com.bumptech.glide.Glide
import kotlin.collections.ArrayList
import kotlin.collections.HashMap



class BuzzerScreenActivity : GameActivity() {

private val MAX_N_PLAYERS = 4
private val NO_BUZZER_PRESSED = -1
private val artworkDim = 200
private val noBuzzerPressed = -1
private val buzzersToRows:HashMap<Int, Int> = initHashmap()
private val rowsIdArray = ArrayList(buzzersToRows.values)
private val buzIds = ArrayList(buzzersToRows.keys)
Expand All @@ -37,7 +35,7 @@ class BuzzerScreenActivity : GameActivity() {
buzzersToRows.put(R.id.buzzer_3, R.id.row_3)
return buzzersToRows
}
var pressedBuzzer = NO_BUZZER_PRESSED
var pressedBuzzer = noBuzzerPressed

private fun setPressed(id: Int) {
pressedBuzzer = id
Expand Down Expand Up @@ -114,10 +112,10 @@ class BuzzerScreenActivity : GameActivity() {
private fun startRound(ctx: Context, gameManager: BuzzerGameManager) {
gameIsOn = true
findViewById<LinearLayout>(R.id.answer).visibility=View.INVISIBLE

// fetch song and initialise answerText. We'll see later for the image
val title = gameManager.getCurrentSong().getTrackName()
findViewById<TextView>(R.id.answerText).text=title
val artist = gameManager.getCurrentSong().getArtistName()
findViewById<TextView>(R.id.songTitle).text= "$title - $artist"
Glide.with(ctx).load(gameManager.getCurrentSong().getArtworkUrl()).override(artworkDim, artworkDim).into(findViewById(R.id.songArtwork))
gameManager.playSong()
checkRunnable()
barTimer(findViewById(R.id.progressBarBuzzer), ctx, gameManager)
Expand Down Expand Up @@ -260,7 +258,7 @@ class BuzzerScreenActivity : GameActivity() {
if (gameManager.playingMediaPlayer()) {
gameManager.stopMediaPlayer()
}
setPressed(NO_BUZZER_PRESSED) // reset the buzzer
setPressed(noBuzzerPressed) // reset the buzzer
gameManager.setNextSong()
startRound(ctx, gameManager)
}
Expand Down
17 changes: 13 additions & 4 deletions app/src/main/res/layout/activity_buzzer_screen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@
<LinearLayout
android:id="@+id/answer"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginEnd="30dp"
android:background="#AAAAAA"
android:background="@color/light_grey"
android:gravity="center"
android:orientation="vertical"
android:visibility="invisible"
Expand All @@ -83,11 +83,20 @@
app:layout_constraintTop_toTopOf="@+id/buzzersLayout">

<TextView
android:id="@+id/answerText"
android:layout_width="275dp"
android:id="@+id/songTitle"
android:layout_width="wrap_content"
android:textColor="@color/black"
android:textSize="16sp"
android:textStyle="bold"
android:layout_height="wrap_content"
android:gravity="center" />

<ImageView
android:id="@+id/songArtwork"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/logo" />

<Button
android:id="@+id/buttonCorrect"
android:layout_width="125dp"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
<color name="maximum_yellow_red">#FFFFCB77</color>
<color name="floral_white">#FFFEF9EF</color>
<color name="darker_floral_white">#FFFAE4B7</color>
<color name="light_grey">#DDDDDD</color>
<color name="light_coral">#FFFE6D73</color>
</resources>

0 comments on commit 49b9a08

Please sign in to comment.