Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous Changes and Bug Fixes 2024 #541

Merged
merged 22 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b84169d
Made bookmark tabs larger on schedule
leahlud Feb 15, 2024
a3ce724
Obtain and display point shop item name after buying
leahlud Feb 15, 2024
e89a690
Use user/following/ instead of user/follow/ to fetch favorited events
leahlud Feb 15, 2024
dcaf472
Updated onboarding images and backgrounds of app
leahlud Feb 16, 2024
905eccf
fixed light background positioning
leahlud Feb 16, 2024
cc7e394
Fixed paddings/margins on profile
leahlud Feb 16, 2024
f7b919e
Removed old drawables from last year
leahlud Feb 16, 2024
79062bf
ensured consistency across page backgrounds and titles
leahlud Feb 16, 2024
7818e93
removed unused layout files
leahlud Feb 16, 2024
3fc09f8
Small fixes to point shop item layout
leahlud Feb 16, 2024
0368057
Fetch profile, shop, and events upon entering the app (in MainViewMod…
leahlud Feb 16, 2024
9e1f8c6
Made coins on point shop slightly smaller
leahlud Feb 16, 2024
9192225
Hide bottom app bar when event info screen is opened
leahlud Feb 16, 2024
cd5ef62
Fixed background moving with scrollview on event info screen
leahlud Feb 16, 2024
6a177e8
Updated hacking end time and corresponding message
leahlud Feb 16, 2024
161e289
Added toast to give info about Point Shop if user clicks on item
leahlud Feb 16, 2024
4d1c3d8
Fixed scanner strings and event tile layout
leahlud Feb 16, 2024
ce39b4b
Added tiny shadow to bottom of profile card
leahlud Feb 16, 2024
6d08385
moved shadows inwards slightly
leahlud Feb 16, 2024
fcad83d
fixed schedule page opening lag
dominick-deseta Feb 18, 2024
c9b7284
Fixed ktlint errors
leahlud Feb 18, 2024
82360f7
fixed ktlint pt 2
leahlud Feb 18, 2024
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
5 changes: 3 additions & 2 deletions app/src/main/java/org/hackillinois/android/API.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import org.hackillinois.android.model.scanner.MentorId
import org.hackillinois.android.model.scanner.Points
import org.hackillinois.android.model.scanner.UserEventPair
import org.hackillinois.android.model.shop.ItemInstance
import org.hackillinois.android.model.shop.ItemName
import org.hackillinois.android.model.user.FavoritesResponse
import org.hackillinois.android.model.version.Version
import org.hackillinois.android.notifications.DeviceToken
Expand Down Expand Up @@ -67,7 +68,7 @@ interface API {
suspend fun shop(): List<ShopItem>

@POST("shop/item/buy/")
suspend fun buyShopItem(@Body body: ItemInstance)
suspend fun buyShopItem(@Body body: ItemInstance): ItemName

// STAFF

Expand All @@ -82,7 +83,7 @@ interface API {
@GET("user/")
suspend fun user(): User

@PUT("user/follow/")
@GET("user/following/")
suspend fun favoriteEvents(): FavoritesResponse

@PUT("user/follow/")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.hackillinois.android.model.shop

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

data class FavoritesResponse(val userId: String, val following: List<String>)
data class FavoritesResponse(val userId: String, val events: List<String>)
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ package org.hackillinois.android.repository
import android.util.Log
import androidx.lifecycle.LiveData
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import org.hackillinois.android.App
import org.hackillinois.android.database.entity.*

class EventRepository {
init {
Log.d("EventRepository", "eventRepository instance created")
}

private val eventDao = App.database.eventDao()

fun fetchEventsHappeningAtTime(time: Long): LiveData<List<Event>> {
Expand All @@ -26,13 +31,12 @@ class EventRepository {
return eventDao.getEventsAfter(currentTime / 1000L)
}

suspend fun refreshAllEvents() {
fun refreshAllEvents() {
// ensures database operation happens on the IO dispatcher
withContext(Dispatchers.IO) {
GlobalScope.launch(Dispatchers.IO) {
try {
val events = App.getAPI().allEvents().events
Log.d("Events Fetched", events.toString())
// TODO FavoritesManager.updateFavoriteNotifications(, eventDao.getAllEventsList(), events)
Log.d("Events Fetched", events[0].toString())
eventDao.clearTableAndInsertEvents(events)
} catch (e: Exception) {
Log.e("REFRESH EVENTS", e.toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class ShopRepository {
refreshAll()
// locally stored database
val lb = shopDao.getShop()
Log.d("SHOP CALL", lb.value.toString())
return lb
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class LoginActivity : AppCompatActivity() {
try {
val response: FavoritesResponse = api.favoriteEvents()
// loop through favorited event ids, wrap as Event object, and store in SharedPreferences
for (eventId in response.following) {
for (eventId in response.events) {
val dummyEvent = Event(eventId, "", "", 0, 0, emptyList(), "", "", "0", false, false, false, "", false)
FavoritesManager.favoriteEvent(applicationContext, dummyEvent)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ class CountdownManager(val listener: CountDownListener) {
timeInMillis = 1708736400000
}

// 02-25-2024 9:00:00
// 02-25-2024 7:00:00
private val hackingEndTime: Calendar = Calendar.getInstance().apply {
timeZone = TimeZone.getTimeZone("America/Chicago")
timeInMillis = 1708873200000
timeInMillis = 1708866000000
}

private var times = listOf(eventStartTime, hackingStartTime, hackingEndTime)
private val titles = listOf("HACKILLINOIS BEGINS IN", "HACKING BEGINS IN", "HACKING ENDS IN", "MEMORIES MADE")
private val titles = listOf("HACKILLINOIS BEGINS IN", "HACKING BEGINS IN", "HACKING ENDS IN", "QUEST COMPLETE")

private var timer: CountDownTimer? = null
private var state = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,13 @@ class DayFragment : Fragment(), EventClickListener {

private var listState: Parcelable? = null

override fun onResume() {
super.onResume()
mAdapter.notifyDataSetChanged()
}

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

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val sectionNumber = arguments?.getInt(ARG_SECTION_NUM) ?: 0

val viewModel = parentFragment?.let { ViewModelProvider(it).get(ScheduleViewModel::class.java) }

val liveEventData = when (sectionNumber) {
Expand All @@ -53,33 +50,36 @@ class DayFragment : Fragment(), EventClickListener {
}

isAttendeeViewing = viewModel?.isAttendeeViewing ?: true
mAdapter = EventsAdapter(listOf(), this, isAttendeeViewing)

viewModel?.showShifts?.observe(
this,
Observer {
showShifts = it
if (showShifts) {
// Log.d("Observe showShifts", "Switching to SHIFTS")
mAdapter.updateEvents(insertTimeItems(currentShifts))
} else {
// Log.d("Observe showShifts", "Switching to SCHEDULE")
updateEvents(currentEvents)
}
}
)

liveEventData?.observe(
this,
Observer { events ->
events?.let {
currentEvents = it
if (isAttendeeViewing || !showShifts) {
updateEvents(currentEvents)
}
}
}
)
val isLoaded = viewModel?.isLoaded?.value ?: false
mAdapter = EventsAdapter(listOf(), this, isAttendeeViewing, isLoaded)
recyclerView = view.activity_schedule_recyclerview.apply {
mLayoutManager = LinearLayoutManager(context)
this.layoutManager = mLayoutManager
this.adapter = mAdapter
}

if (currentEvents.isEmpty()) {
view.postDelayed(
{
liveEventData?.observe(
this,
Observer { events ->
events?.let {
if (currentEvents.isEmpty() && (isAttendeeViewing || !showShifts)) {
currentEvents = it
updateEvents(currentEvents)
viewModel?.isLoaded?.postValue(true)
}
}
},
)
},
100L,
)
} else {
updateEvents(currentEvents)
viewModel?.isLoaded?.postValue(true)
}

if (isStaff()) {
val liveShiftData = when (sectionNumber) {
Expand All @@ -88,16 +88,35 @@ class DayFragment : Fragment(), EventClickListener {
2 -> viewModel?.sundayShiftsLiveData
else -> viewModel?.fridayShiftsLiveData
}
liveShiftData?.observe(
viewModel?.showShifts?.observe(
this,
Observer { shifts ->
shifts?.let {
currentShifts = it
if (showShifts) {
mAdapter.updateEvents(insertTimeItems(currentShifts))
}
Observer {
showShifts = it
if (showShifts) {
// Log.d("Observe showShifts", "Switching to SHIFTS")
mAdapter.animateItems = false
mAdapter.updateEvents(insertTimeItems(currentShifts))
} else {
// Log.d("Observe showShifts", "Switching to SCHEDULE")
updateEvents(currentEvents)
}
}
},
)
view.postDelayed(
{
liveShiftData?.observe(
this,
Observer { shifts ->
shifts?.let {
currentShifts = it
if (showShifts) {
mAdapter.updateEvents(insertTimeItems(currentShifts))
}
}
},
)
},
100,
)
}

Expand All @@ -107,36 +126,24 @@ class DayFragment : Fragment(), EventClickListener {
Observer {
showFavorites = it
updateEvents(currentEvents)
}
},
)
}
}

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

recyclerView = view.activity_schedule_recyclerview.apply {
mLayoutManager = LinearLayoutManager(context)
this.layoutManager = mLayoutManager
this.adapter = mAdapter
}
return view
}

override fun onStart() {
super.onStart()
if (listState != null) {
mLayoutManager.onRestoreInstanceState(listState)
}
}

override fun onPause() {
super.onPause()
listState = mLayoutManager.onSaveInstanceState()
override fun onSaveInstanceState(state: Bundle) {
super.onSaveInstanceState(state)
// Save list state
state.putParcelable("recyclerview", mLayoutManager.onSaveInstanceState())
}

override fun openEventInfoActivity(event: Event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.Toast
import androidx.activity.OnBackPressedCallback
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import com.bumptech.glide.Glide
import com.google.android.material.bottomappbar.BottomAppBar
import com.google.android.material.floatingactionbutton.FloatingActionButton
import kotlinx.android.synthetic.main.fragment_event_info.*
import kotlinx.android.synthetic.main.fragment_event_info.view.*
import org.hackillinois.android.R
Expand Down Expand Up @@ -39,28 +42,51 @@ class EventInfoFragment : Fragment() {

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

// override back button being pressed to reload in bottom nav bar
activity?.onBackPressedDispatcher?.addCallback(
this,
object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
closeEventInfoPage()
}
}
)

// set bottom app bar invisible
val appBar = activity!!.findViewById<BottomAppBar>(R.id.bottomAppBar)
val scannerBtn = activity!!.findViewById<FloatingActionButton>(R.id.code_entry_fab)
appBar.visibility = View.INVISIBLE
scannerBtn.visibility = View.INVISIBLE

// get bundle arguments and set up viewModel
eventId = arguments?.getString(EVENT_ID_KEY) ?: ""
isAttendeeViewing = arguments?.getBoolean(IS_ATTENDEE_VIEWING) ?: false

viewModel = ViewModelProviders.of(this).get(EventInfoViewModel::class.java)
viewModel.init(eventId)
}

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

// set up observers
viewModel.event.observe(
this,
Observer { event ->
currentEvent = event
updateEventUI(currentEvent)
},
}
)
viewModel.isFavorited.observe(this, Observer { updateFavoritedUI(it) })
}

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View? {
val view = inflater.inflate(R.layout.fragment_event_info, container, false)
// set onClickListeners
view.exit_button.setOnClickListener {
activity?.supportFragmentManager?.popBackStackImmediate()
closeEventInfoPage()
}
view.favorites_button.setOnClickListener {
if (viewModel.changeFavoritedState()) {
Expand Down Expand Up @@ -121,4 +147,8 @@ class EventInfoFragment : Fragment() {
favorites_button.setImageResource(imageResource)
}
}

private fun closeEventInfoPage() {
activity?.supportFragmentManager?.popBackStackImmediate()
}
}
Loading
Loading