Skip to content

Commit

Permalink
Merge pull request #557 from HackIllinois/aditya/home-page
Browse files Browse the repository at this point in the history
Home Page + Scanner Page + Splash Screen Page 2025
  • Loading branch information
AdityaK2905 authored Feb 16, 2025
2 parents c699ce1 + 01fdc6a commit 780d1af
Show file tree
Hide file tree
Showing 53 changed files with 20,682 additions and 143 deletions.
1 change: 1 addition & 0 deletions app/src/main/assets/swirling_oracle.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions app/src/main/java/org/hackillinois/android/API.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.hackillinois.android.model.scanner.DietaryRestrictions
import org.hackillinois.android.model.scanner.EventId
import org.hackillinois.android.model.scanner.MentorId
import org.hackillinois.android.model.scanner.Points
import org.hackillinois.android.model.scanner.QRCode
import org.hackillinois.android.model.scanner.UserEventPair
import org.hackillinois.android.model.shop.ItemInstance
import org.hackillinois.android.model.user.FavoritesResponse
Expand Down Expand Up @@ -68,6 +69,9 @@ interface API {
@POST("shop/item/buy/")
suspend fun buyShopItem(@Body body: ItemInstance): ShopItem

@POST("shop/cart/redeem/")
suspend fun redeemCart(@Body body: QRCode): Cart

// STAFF

@POST("staff/attendance/")
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/org/hackillinois/android/database/entity/Cart.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.hackillinois.android.database.entity

import androidx.room.Entity
import androidx.room.PrimaryKey

@Entity(tableName = "cart")
data class Cart(
@PrimaryKey val userId: String,
val items: Map<String, Int> // Maps itemId to quantity
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.hackillinois.android.model.scanner

data class QRCode(val QRCode: String)
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package org.hackillinois.android.model.scanner

data class UserEventPair(val attendeeJWT: String, val eventId: String)
data class UserEventPair(val eventId: String, val attendeeQRCode: String)
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import android.os.Build
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.ImageView
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
Expand All @@ -36,6 +37,7 @@ class SplashScreenActivity : AppCompatActivity() {
private var needsToUpdate = false
private var hasInternet = true
private var hasClickedOrAnimFinish = false
private lateinit var splashBackground: ImageView

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CountdownManager(val listener: CountDownListener) {
// 02-23-2024 15:30:00
private val eventStartTime: Calendar = Calendar.getInstance().apply {
timeZone = TimeZone.getTimeZone("America/Chicago")
timeInMillis = 1708723800000
timeInMillis = 1740722400000 // 1708723800000
}

// 02-23-2024 19:00:00
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,50 @@ import java.util.*
class EventProgressManager(val listener: CountDownListener) {

// CORRECT TIMES ARE NOT SET YET
// 02-23-2024 15:30:00
// 02-28-2025 : 14:30
private val checkInTime: Calendar = Calendar.getInstance().apply {
timeZone = TimeZone.getTimeZone("America/Chicago")
timeInMillis = 1708723800000
timeInMillis = 1740774600000
}

// 02-23-2024 16:00:00
// 02-28-2025 : 15:00
private val scavengerHuntTime: Calendar = Calendar.getInstance().apply {
timeZone = TimeZone.getTimeZone("America/Chicago")
timeInMillis = 1708725600000
timeInMillis = 1740776400000
}

// 02-23-2024 18:00:00
// 02-28-2025 : 17:00
private val openingCeremonyTime: Calendar = Calendar.getInstance().apply {
timeZone = TimeZone.getTimeZone("America/Chicago")
timeInMillis = 1708732800000
timeInMillis = 1740783600000
}

// 02-23-2024 19:00:00
// 02-28-2025 : 18:00
private val hackingTime: Calendar = Calendar.getInstance().apply {
timeZone = TimeZone.getTimeZone("America/Chicago")
timeInMillis = 1708736400000
timeInMillis = 1740787200000
}

// 02-25-2024 11:00:00
// 03-02-2025 11:30
private val projectShowcaseTime: Calendar = Calendar.getInstance().apply {
timeZone = TimeZone.getTimeZone("America/Chicago")
timeInMillis = 1708880400000
timeInMillis = 1740936600000
}

// 02-25-2024 15:00:00
// 03-02-2025 15:00
private val closingCeremonyTime: Calendar = Calendar.getInstance().apply {
timeZone = TimeZone.getTimeZone("America/Chicago")
timeInMillis = 1708894800000
timeInMillis = 1740949200000
}

// 02-25-2024 16:00:00
// 03-02-2025 16:00
private val afterHackathonTime: Calendar = Calendar.getInstance().apply {
timeZone = TimeZone.getTimeZone("America/Chicago")
timeInMillis = 1708898400000
timeInMillis = 1740952800000
}

private var times = listOf(checkInTime, scavengerHuntTime, openingCeremonyTime, hackingTime, projectShowcaseTime, closingCeremonyTime, afterHackathonTime)
private var backgrounds = listOf(R.drawable.home_bg_start, R.drawable.home_check_in_bg, R.drawable.home_scavenger_hunt_bg, R.drawable.home_opening_bg, R.drawable.home_hacking_bg, R.drawable.home_project_showcase_bg, R.drawable.home_closing_bg, R.drawable.home_final_bg)
private var backgrounds = listOf(R.drawable.home_background1_svg, R.drawable.home_background2_svg, R.drawable.home_background3_svg, R.drawable.home_background3_svg, R.drawable.home_background4_svg, R.drawable.home_background5_svg, R.drawable.home_background6_svg, R.drawable.home_background6_svg)
private var timer: CountDownTimer? = null
private var state = 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ class HomeFragment : Fragment(), CountdownManager.CountDownListener, EventProgre

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

viewModel = ViewModelProvider(this).get(HomeViewModel::class.java)
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_home, container, false)
val view = inflater.inflate(R.layout.fragment_home_2025, container, false)

daysValue = view.findViewById(R.id.daysValue)
hoursValue = view.findViewById(R.id.hoursValue)
Expand All @@ -44,7 +43,7 @@ class HomeFragment : Fragment(), CountdownManager.CountDownListener, EventProgre
homeBackgroundImageView = view.findViewById(R.id.homeBackgroundImageView)
homeBackgroundTagsImageView = view.findViewById(R.id.homeBackgroundTagsImageView)
infoButton = view.findViewById(R.id.homeInfoImageView)

//
// set info button's functionality to toggle tag descriptions on home page when pressed on/off
infoButton.setOnClickListener {
if (homeBackgroundTagsImageView.visibility == View.INVISIBLE) {
Expand All @@ -63,21 +62,21 @@ class HomeFragment : Fragment(), CountdownManager.CountDownListener, EventProgre
super.onStart()
isActive = true
countDownManager.start()
eventProgressManager.start()
// eventProgressManager.start()
}

override fun onPause() {
super.onPause()
isActive = false
countDownManager.onPause()
eventProgressManager.onPause()
// eventProgressManager.onPause()
}

override fun onResume() {
super.onResume()
isActive = true
countDownManager.onResume()
eventProgressManager.onResume()
// eventProgressManager.onResume()
}

override fun onStop() {
Expand All @@ -103,7 +102,7 @@ class HomeFragment : Fragment(), CountdownManager.CountDownListener, EventProgre

override fun updateBackground(newBackgroundResource: Int) {
if (isActive) {
homeBackgroundImageView.setImageResource(newBackgroundResource)
// homeBackgroundImageView.setImageResource(newBackgroundResource)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import android.graphics.Bitmap
import android.graphics.Color
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand Down Expand Up @@ -159,6 +160,7 @@ class ProfileFragment : Fragment() {
if (qrCodeImage.width > 0 && qrCodeImage.height > 0) {
// Retrieves qr code user info that will be encoded
val text = qr.qrInfo
Log.d("Attendee QR Code: ", "" + text)
// Creates bitmap of text
val bitmap = generateQR(text)
// actually setting the qr code to be the generated qr code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,6 @@ class AttendeeScannerFragment : Fragment() {
val scannerFragment = ScannerFragment.newInstance("mentor-check-in")
(context as MainActivity).switchFragment(scannerFragment, true)
}

// when point shop button is clicked
val pointShopButton = view.findViewById<Button>(R.id.pointShopBtn)
pointShopButton.setOnClickListener {
if (appBar != null && scannerBtn != null) {
appBar.visibility = View.INVISIBLE
scannerBtn.visibility = View.INVISIBLE
}
val scannerFragment = ScannerFragment.newInstance("point-shop")
(context as MainActivity).switchFragment(scannerFragment, true)
}

return view
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand All @@ -32,6 +33,7 @@ import org.hackillinois.android.database.entity.Event
import org.hackillinois.android.database.entity.Roles
import org.hackillinois.android.model.scanner.EventId
import org.hackillinois.android.model.scanner.MentorId
import org.hackillinois.android.model.scanner.QRCode
import org.hackillinois.android.model.scanner.ScanStatus
import org.hackillinois.android.model.scanner.UserEventPair
import org.hackillinois.android.model.shop.ItemInstance
Expand Down Expand Up @@ -128,9 +130,11 @@ class ScannerFragment : Fragment(), SimpleScanDialogFragment.OnSimpleOKButtonSel
viewModel.submitMeetingAttendance(EventId(eventId))
}
"attendee-check-in" -> {
Log.d("Attendee Code: ", "" + it.text)
val userToken = extractUserToken(it.text)
Log.d("User Token: ", userToken)
val eventId = getChipEventId()
viewModel.checkInAttendee(UserEventPair(userToken, eventId))
viewModel.checkInAttendee(UserEventPair(eventId, userToken))
}
else -> {
displayToast(R.string.something_went_wrong_message)
Expand All @@ -146,11 +150,14 @@ class ScannerFragment : Fragment(), SimpleScanDialogFragment.OnSimpleOKButtonSel
}
"mentor-check-in" -> {
val mentorId: String = it.text
Log.d("Mentor Text: ", "" + mentorId)
viewModel.checkInMentor(MentorId(mentorId))
}
"point-shop" -> {
val itemInstance = extractItemInfo(it.text)
viewModel.purchaseItem(itemInstance)
Log.d("Shop Raw Text: ", "" + it.text)
val QRCode: String = it.text
Log.d("Point Text: ", QRCode)
viewModel.redeemAttendeeCart(QRCode(QRCode))
}
else -> {
displayToast(R.string.something_went_wrong_message)
Expand Down Expand Up @@ -257,8 +264,11 @@ class ScannerFragment : Fragment(), SimpleScanDialogFragment.OnSimpleOKButtonSel
}

private fun extractUserToken(qrString: String): String {
val splitOnEquals = qrString.split("=")
return splitOnEquals.last()
// val splitOnEquals = qrString.split("=")
// return splitOnEquals.last()
val uri = Uri.parse(qrString)
val encodedQuery = uri.encodedQuery ?: return ""
return encodedQuery.substringAfter("qr=")
}

private fun extractItemInfo(qrString: String): ItemInstance {
Expand All @@ -270,7 +280,7 @@ class ScannerFragment : Fragment(), SimpleScanDialogFragment.OnSimpleOKButtonSel
}

private fun getChipEventId(): String {
return chipIdToEventId[chipGroup.checkedChipId] ?: "ca7927242bcf76b9ee8c5e210a587a98" // default to check-in TODO: update every year
return chipIdToEventId[chipGroup.checkedChipId] ?: "728eeef366eea4ba1702c4d74a1b8915" // default to check-in TODO: update every year
}

private fun displayStaffScanResult(lastScanStatus: ScanStatus?) = lastScanStatus?.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ class StaffScannerFragment : Fragment() {
(context as MainActivity).switchFragment(scannerFragment, true)
}

val pointShopButton = view.findViewById<Button>(R.id.pointShopBtn)
pointShopButton.setOnClickListener {
if (appBar != null && scannerBtn != null) {
appBar.visibility = View.INVISIBLE
scannerBtn.visibility = View.INVISIBLE
}
val scannerFragment = ScannerFragment.newInstance("point-shop")
(context as MainActivity).switchFragment(scannerFragment, true)
}

return view
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import android.util.AttributeSet
import android.view.MotionEvent
import org.hackillinois.android.R

class PinkAnimatedButton : androidx.appcompat.widget.AppCompatButton {
class BurntBrownAnimatedButton : androidx.appcompat.widget.AppCompatButton {
constructor(context: Context?) : super(context!!) {}
constructor(context: Context?, attrs: AttributeSet?) : super(context!!, attrs) {}
constructor(context: Context?, attrs: AttributeSet?, defStyle: Int) : super(context!!, attrs, defStyle) {
Expand All @@ -18,10 +18,10 @@ class PinkAnimatedButton : androidx.appcompat.widget.AppCompatButton {
val dpAsPixels30 = (30 * scale + 0.5f).toInt()
if (event.action == MotionEvent.ACTION_DOWN) {
setPadding(0, dpAsPixels30, 0, dpAsPixels20)
setBackgroundResource(R.drawable.pink_scanner_button_pressed)
setBackgroundResource(R.drawable.burntbrown_scanner_button_pressed)
} else if (event.action == MotionEvent.ACTION_UP || event.action == MotionEvent.ACTION_CANCEL) {
setPadding(0, dpAsPixels20, 0, dpAsPixels30)
setBackgroundResource(R.drawable.pink_scanner_button)
setBackgroundResource(R.drawable.burntbrown_scanner_button)
}
}
return super.onTouchEvent(event)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.hackillinois.android.view.scanner.buttons

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import org.hackillinois.android.R

class ModerateOrangeAnimatedButton : androidx.appcompat.widget.AppCompatButton {
constructor(context: Context?) : super(context!!) {}
constructor(context: Context?, attrs: AttributeSet?) : super(context!!, attrs) {}
constructor(context: Context?, attrs: AttributeSet?, defStyle: Int) : super(context!!, attrs, defStyle) {
}

override fun onTouchEvent(event: MotionEvent?): Boolean {
if (event != null) {
val scale = resources.displayMetrics.density
val dpAsPixels20 = (20 * scale + 0.5f).toInt()
val dpAsPixels30 = (30 * scale + 0.5f).toInt()
if (event.action == MotionEvent.ACTION_DOWN) {
setPadding(0, dpAsPixels30, 0, dpAsPixels20)
setBackgroundResource(R.drawable.moderateorange_scanner_button_pressed)
} else if (event.action == MotionEvent.ACTION_UP || event.action == MotionEvent.ACTION_CANCEL) {
setPadding(0, dpAsPixels20, 0, dpAsPixels30)
setBackgroundResource(R.drawable.moderateorange_scanner_button)
}
}
return super.onTouchEvent(event)
}
}
Loading

0 comments on commit 780d1af

Please sign in to comment.