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

margaux/artwork-on-answer #256

Merged
merged 4 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have no more limitations on the maximum number of players?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the limitation to 4 players is still there, but this val was only used in a check before I figured out how to directly fetch the player names from the intent, so it's not useful anymore.

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))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I have never heard of that Library. After having a look on internet, it may be great to use it everywhere. I will check later in my refactor if it is worth it or not.

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>