Skip to content

Commit

Permalink
Upgrade a lot of libraries!
Browse files Browse the repository at this point in the history
  • Loading branch information
ForceTower committed Jul 19, 2024
1 parent bfc3ac2 commit 48adea5
Show file tree
Hide file tree
Showing 35 changed files with 82 additions and 612 deletions.
23 changes: 12 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ dependencies {

// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.8.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.8.1'

// Android X
implementation "androidx.core:core-ktx:$ktx"
Expand All @@ -219,6 +219,7 @@ dependencies {
api "androidx.lifecycle:lifecycle-common-java8:$lifecycle"
api "androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycle"
api "androidx.lifecycle:lifecycle-service:$lifecycle"
api "androidx.datastore:datastore-preferences:1.1.1"

// Paging
implementation "androidx.paging:paging-runtime-ktx:$paging"
Expand All @@ -233,8 +234,8 @@ dependencies {
kapt "androidx.hilt:hilt-compiler:$hilt_androidx"

// Firebase
implementation platform('com.google.firebase:firebase-bom:32.8.1')
implementation "com.google.firebase:firebase-auth-ktx"
implementation platform('com.google.firebase:firebase-bom:33.1.2')
// implementation "com.google.firebase:firebase-auth-ktx"
implementation "com.google.firebase:firebase-analytics-ktx"
implementation "com.google.firebase:firebase-messaging-ktx"
implementation "com.google.firebase:firebase-firestore-ktx"
Expand All @@ -245,8 +246,8 @@ dependencies {
implementation "com.firebaseui:firebase-ui-storage:$firebase_ui_storage"

// passkeys
implementation("androidx.credentials:credentials:1.3.0-alpha02")
implementation("androidx.credentials:credentials-play-services-auth:1.3.0-alpha02")
implementation("androidx.credentials:credentials:1.3.0-rc01")
implementation("androidx.credentials:credentials-play-services-auth:1.3.0-rc01")

debugImplementation "com.github.chuckerteam.chucker:library:4.0.0"
releaseImplementation "com.github.chuckerteam.chucker:library-no-op:4.0.0"
Expand All @@ -255,7 +256,7 @@ dependencies {
implementation "com.jakewharton.timber:timber:$timber"

// Google Play
implementation "com.google.android.gms:play-services-games-v2:20.0.0"
implementation 'com.google.android.gms:play-services-games-v2:20.1.2'
implementation "com.google.android.gms:play-services-auth:$gp_auth"
implementation "com.google.android.gms:play-services-location:$gp_location"
implementation "com.android.billingclient:billing:$gp_billing_client"
Expand All @@ -282,15 +283,15 @@ dependencies {
implementation "io.reactivex.rxjava2:rxkotlin:$rx_kotlin"
implementation 'com.getkeepsafe.taptargetview:taptargetview:1.13.3'

implementation 'com.google.android.gms:play-services-maps:18.2.0'
implementation 'com.google.android.gms:play-services-maps:19.0.0'

testImplementation 'junit:junit:4.13.2'
testImplementation 'io.mockk:mockk:1.13.10'
testImplementation 'io.mockk:mockk:1.13.12'
testImplementation 'androidx.arch.core:core-testing:2.2.0'
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.8.0'
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.8.1'

androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
}

task buildNotes {
Expand Down
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />

<application
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/forcetower/uefs/UApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class UApplication : Application(), Configuration.Provider {
var disciplineToolbarDevClickCount = 0
var messageToolbarDevClickCount = 0

override fun attachBaseContext(base: Context?) {
override fun attachBaseContext(base: Context) {
super.attachBaseContext(base)
SplitCompat.install(this)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import android.content.Context
import com.forcetower.uefs.R
import com.forcetower.uefs.core.constants.Constants.REMOTE_CONFIG_REFRESH
import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.functions.FirebaseFunctions
import com.google.firebase.messaging.FirebaseMessaging
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
Expand All @@ -41,10 +40,6 @@ import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
object FirebaseCoreModule {
@Provides
@Singleton
fun provideAuth(): FirebaseAuth = FirebaseAuth.getInstance()

@Provides
@Singleton
fun provideStorage(): FirebaseStorage = FirebaseStorage.getInstance()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.forcetower.uefs.core.model.edge

import com.google.gson.annotations.SerializedName

data class EdgeAccessToken(
@SerializedName("accessToken")
val accessToken: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.forcetower.uefs.core.model.edge

data class EdgeLoginBody(
val username: String,
val password: String,
val provider: String = "SNOWPIERCER"
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.forcetower.uefs.core.storage.network

import com.forcetower.uefs.core.model.edge.AssertionData
import com.forcetower.uefs.core.model.edge.CompleteAssertionData
import com.forcetower.uefs.core.model.edge.EdgeAccessToken
import com.forcetower.uefs.core.model.edge.EdgeLoginBody
import com.forcetower.uefs.core.model.edge.RegisterPasskeyCredential
import com.forcetower.uefs.core.model.edge.RegisterPasskeyStart
import com.forcetower.uefs.core.model.unes.AccessToken
Expand All @@ -10,6 +12,9 @@ import retrofit2.http.GET
import retrofit2.http.POST

interface EdgeService {
@POST("auth/login/anonymous")
suspend fun loginAnonymous(@Body data: EdgeLoginBody): EdgeAccessToken

@GET("auth/login/passkey/assertion/start")
suspend fun startAssertion(): AssertionData

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import com.forcetower.uefs.core.model.unes.Semester
import com.forcetower.uefs.core.storage.database.UDatabase
import com.forcetower.uefs.core.storage.network.UService
import com.forcetower.uefs.feature.shared.extensions.generateCalendarFromHour
import com.google.firebase.auth.FirebaseAuth
import java.util.Calendar
import java.util.Locale
import java.util.concurrent.TimeUnit
Expand All @@ -47,7 +46,6 @@ import kotlin.collections.set
class AdventureRepository @Inject constructor(
private val database: UDatabase,
private val executors: AppExecutors,
private val auth: FirebaseAuth,
private val preferences: SharedPreferences,
private val locations: AchLocationsRepository,
private val service: UService
Expand Down Expand Up @@ -102,9 +100,6 @@ class AdventureRepository @Inject constructor(
@WorkerThread
private fun internalCheckAchievements(): Map<Int, Int> {
val data = HashMap<Int, Int>()

auth.currentUser ?: return data

performCheckAchievements(data)
return data
}
Expand Down Expand Up @@ -193,9 +188,9 @@ class AdventureRepository @Inject constructor(

clazz.grades.forEach { grade ->
valid = true
val number = grade.gradeDouble() ?: -1
if (number == 7) data[R.string.achievement_medocre] = -1
if (number == 10) data[R.string.achievement_achei_fcil] = -1
val number = grade.gradeDouble() ?: -1.0
if (number == 7.0) data[R.string.achievement_medocre] = -1
if (number == 10.0) data[R.string.achievement_achei_fcil] = -1
}

if (clazz.grades.size == 3) {
Expand Down Expand Up @@ -266,9 +261,9 @@ class AdventureRepository @Inject constructor(
if (points in 9.5..9.9) data[R.string.achievement_to_perto_mas_to_longe] = -1

clazz.grades.forEach { grade ->
val number = grade.gradeDouble() ?: -1
if (number == 7) data[R.string.achievement_medocre] = -1
if (number == 10) data[R.string.achievement_achei_fcil] = -1
val number = grade.gradeDouble() ?: -1.0
if (number == 7.0) data[R.string.achievement_medocre] = -1
if (number == 10.0) data[R.string.achievement_achei_fcil] = -1
}

if (clazz.grades.size == 3) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,68 +20,11 @@

package com.forcetower.uefs.core.storage.repository

import android.os.Build
import androidx.annotation.AnyThread
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.forcetower.uefs.AppExecutors
import com.forcetower.uefs.core.model.service.Feedback
import com.forcetower.uefs.core.model.unes.Access
import com.forcetower.uefs.core.storage.database.UDatabase
import com.forcetower.uefs.feature.shared.extensions.toBase64
import com.google.android.gms.tasks.Tasks
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.firestore.CollectionReference
import com.google.firebase.messaging.FirebaseMessaging
import timber.log.Timber
import javax.inject.Inject
import javax.inject.Named
import javax.inject.Singleton

@Singleton
class FeedbackRepository @Inject constructor(
private val firebaseAuth: FirebaseAuth,
private val executors: AppExecutors,
private val database: UDatabase,
@Named(Feedback.COLLECTION)
private val collection: CollectionReference
) {

@AnyThread
fun onSendFeedback(text: String): LiveData<Boolean> {
val result = MutableLiveData<Boolean>()
executors.diskIO().execute {
val userId = firebaseAuth.currentUser?.uid
val access = database.accessDao().getAccessDirect()
?: Access(username = "random", password = "user")
val profile = database.profileDao().selectMeDirect()
val feedback = Feedback(
text = text,
username = access.username,
course = profile?.course,
email = profile?.email,
hash = access.toString().toBase64(),
firebaseId = userId,
manufacturer = Build.MANUFACTURER,
deviceModel = Build.MODEL,
android = Build.VERSION.SDK_INT
)
var token: String? = null
try {
token = Tasks.await(FirebaseMessaging.getInstance().token)
} catch (throwable: Throwable) {
Timber.e(throwable)
}

feedback.currentToken = token

try {
Tasks.await(collection.add(feedback))
} catch (throwable: Throwable) {
Timber.e(throwable)
}
}
result.postValue(true)
return result
}
}
private val database: UDatabase
)
Loading

0 comments on commit 48adea5

Please sign in to comment.