Skip to content

Commit

Permalink
Merge branch 'aditya/profile-2024' of https://github.com/HackIllinois…
Browse files Browse the repository at this point in the history
…/android into aditya/profile-2024
  • Loading branch information
AdityaK2905 committed Feb 4, 2024
2 parents c96ccf1 + 64fa507 commit 117ab72
Show file tree
Hide file tree
Showing 83 changed files with 843 additions and 345 deletions.
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
android:name="org.hackillinois.android.App"
android:allowBackup="false"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher_23"
android:roundIcon="@mipmap/ic_launcher_23_round"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme">


Expand Down
1 change: 1 addition & 0 deletions app/src/main/assets/swirling_cauldron.json

Large diffs are not rendered by default.

Binary file modified app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 11 additions & 6 deletions app/src/main/java/org/hackillinois/android/API.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package org.hackillinois.android

import org.hackillinois.android.database.entity.*
import org.hackillinois.android.model.TimesWrapper
import org.hackillinois.android.model.checkin.CheckIn
import org.hackillinois.android.model.event.EventId
import org.hackillinois.android.model.event.EventsList
import org.hackillinois.android.model.leaderboard.LeaderboardList
import org.hackillinois.android.model.profile.Ranking
import org.hackillinois.android.model.user.FavoritesResponse
import org.hackillinois.android.model.version.Version
import org.hackillinois.android.notifications.DeviceToken
import retrofit2.Call
Expand Down Expand Up @@ -66,16 +67,20 @@ interface API {
@POST("staff/attendance/")
suspend fun staffMeetingCheckIn(@Body eventId: MeetingEventId): MeetingCheckInResponse

// UPLOAD

@GET("upload/blobstore/times/")
suspend fun times(): TimesWrapper

// USER

@GET("user/")
suspend fun user(): User

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

@PUT("user/follow/")
fun followEvent(@Body eventId: EventId): Call<FavoritesResponse>

@PUT("user/unfollow/")
fun unfollowEvent(@Body eventId: EventId): Call<FavoritesResponse>

@GET("user/qr/")
suspend fun qrCode(): QR

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.hackillinois.android.model.event

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

data class FavoritesResponse(val userId: String, val following: List<String>)
22 changes: 22 additions & 0 deletions app/src/main/java/org/hackillinois/android/view/LoginActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ import kotlinx.coroutines.withContext
import org.hackillinois.android.API
import org.hackillinois.android.App
import org.hackillinois.android.R
import org.hackillinois.android.common.FavoritesManager
import org.hackillinois.android.common.JWTUtilities
import org.hackillinois.android.database.entity.Event
import org.hackillinois.android.database.entity.Roles
import org.hackillinois.android.model.auth.JWT
import org.hackillinois.android.model.user.FavoritesResponse
import java.net.SocketTimeoutException

class LoginActivity : AppCompatActivity() {
Expand Down Expand Up @@ -96,8 +99,10 @@ class LoginActivity : AppCompatActivity() {
try {
val loginRoles: Roles = api.roles()
Log.d("ROLES", "${loginRoles.roles}")

// Check if user's roles are correct. If not, display corresponding error message
if (loginRoles.roles.contains(role)) {
getFavoritedEvents(api)
JWTUtilities.writeJWT(applicationContext, jwt) // save JWT to sharedPreferences for auto-login in the future
launchMainActivity()
} else {
Expand All @@ -113,6 +118,23 @@ class LoginActivity : AppCompatActivity() {
}
}

private fun getFavoritedEvents(api: API) {
// make api call to get list of event ids that user has favorited
GlobalScope.launch {
try {
val response: FavoritesResponse = api.favoriteEvents()
// loop through favorited event ids, wrap as Event object, and store in SharedPreferences
for (eventId in response.following) {
val dummyEvent = Event(eventId, "", "", 0, 0, emptyList(), "", "", "0", false, false, false)
FavoritesManager.favoriteEvent(applicationContext, dummyEvent)
}
Log.d("Fetched favorites", response.toString())
} catch (e: Exception) {
Log.d("Fetched favorites ERROR", e.message.toString())
}
}
}

private fun showFailedToLogin(message: String?) {
if (message != null) {
Snackbar.make(findViewById(android.R.id.content), message.toString(), Snackbar.LENGTH_SHORT,).show()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class MainActivity : AppCompatActivity() {
val bottomBarButtons = listOf(
bottomAppBar.homeButton,
bottomAppBar.scheduleButton,
bottomAppBar.leaderboard,
bottomAppBar.shop,
bottomAppBar.profile,
)

Expand All @@ -87,7 +87,7 @@ class MainActivity : AppCompatActivity() {
when (view) {
bottomAppBar.homeButton -> switchFragment(HomeFragment(), false)
bottomAppBar.scheduleButton -> switchFragment(ScheduleFragment(), false)
bottomAppBar.leaderboard -> switchFragment(LeaderboardFragment(), false)
bottomAppBar.shop -> switchFragment(LeaderboardFragment(), false)
bottomAppBar.profile -> switchFragment(ProfileFragment(), false)
else -> return@setOnClickListener
}
Expand All @@ -110,7 +110,7 @@ class MainActivity : AppCompatActivity() {
val bottomBarButtons = listOf(
bottomAppBar.homeButton,
bottomAppBar.scheduleButton,
bottomAppBar.leaderboard,
bottomAppBar.shop,
bottomAppBar.profile,
)
val unselectedIconColor = ContextCompat.getColor(this, R.color.unselectedAppBarIcon)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@ import org.hackillinois.android.view.onboarding.OnboardingPageFragment
class OnboardingActivity : FragmentActivity() {

private val images = listOf(
R.drawable.login_logo_2023,
R.drawable.countdown_2023,
R.drawable.schedule_2023,
R.drawable.scan_2023,
R.drawable.profile_2023,
R.drawable.leaderboard_2023,
R.drawable.login_logo_2024,
R.drawable.countdown_2024,
R.drawable.schedule_2024,
R.drawable.scanner_2024,
R.drawable.point_shop_2024,
R.drawable.profile_2024,
)

private val titles = listOf(
R.string.onboarding_welcome_title,
R.string.onboarding_countdown_title,
R.string.onboarding_schedule_title,
R.string.onboarding_scan_title,
R.string.onboarding_shop_title,
R.string.onboarding_profile_title,
R.string.onboarding_leaderboard_title,
)

private val descriptions = listOf(
R.string.onboarding_welcome_description,
R.string.onboarding_countdown_description,
R.string.onboarding_schedule_description,
R.string.onboarding_scan_description,
R.string.onboarding_shop_description,
R.string.onboarding_profile_description,
R.string.onboarding_leaderboard_description,
)

override fun onCreate(savedInstanceState: Bundle?) {
Expand Down
Loading

0 comments on commit 117ab72

Please sign in to comment.