Skip to content

Commit

Permalink
Fixed issue with property names, obfuscation caused on release builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
HLCaptain committed Feb 26, 2023
1 parent 092fac3 commit 3f87f1c
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package illyan.jay.data.disk.model

import androidx.room.Entity
import androidx.room.PrimaryKey
import illyan.jay.domain.model.DomainPreferences
import java.time.ZonedDateTime
import java.util.UUID

Expand All @@ -29,8 +30,8 @@ import java.util.UUID
data class RoomPreferences(
@PrimaryKey
val userUUID: String = UUID.randomUUID().toString(),
val freeDriveAutoStart: Boolean = false,
val analyticsEnabled: Boolean = false,
val freeDriveAutoStart: Boolean = DomainPreferences.default.freeDriveAutoStart,
val analyticsEnabled: Boolean = DomainPreferences.default.analyticsEnabled,
val lastUpdate: Long = ZonedDateTime.now().toInstant().toEpochMilli(),
val shouldSync: Boolean = false
val shouldSync: Boolean = DomainPreferences.default.shouldSync
)
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class PreferencesNetworkDataSource @Inject constructor(
val userRef = firestore
.collection(FirestoreUser.CollectionName)
.document(authInteractor.userUUID!!)
val fieldMapToSet = mapOf(FirestoreUser.FieldSettings to preferences.toFirestoreModel())
val fieldMapToSet = mapOf(FirestoreUser.FieldPreferences to preferences.toFirestoreModel())
batch.set(
userRef,
fieldMapToSet,
Expand Down
31 changes: 16 additions & 15 deletions app/src/main/java/illyan/jay/data/network/model/FirestorePath.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import android.os.Parcelable
import com.google.firebase.Timestamp
import com.google.firebase.firestore.DocumentId
import com.google.firebase.firestore.GeoPoint
import com.google.firebase.firestore.PropertyName
import kotlinx.parcelize.Parcelize
import kotlinx.parcelize.TypeParceler

Expand All @@ -31,21 +32,21 @@ import kotlinx.parcelize.TypeParceler
data class FirestorePath(
@DocumentId
val uuid: String = "",
val sessionUUID: String = "", // reference of the session this path is part of
val ownerUUID: String = "",
val accuracyChangeTimestamps: List<Timestamp> = emptyList(),
val accuracyChanges: List<Int> = emptyList(),
val altitudes: List<Int> = emptyList(),
val bearingAccuracyChangeTimestamps: List<Timestamp> = emptyList(),
val bearingAccuracyChanges: List<Int> = emptyList(),
val bearings: List<Int> = emptyList(),
val coords: List<GeoPoint> = emptyList(),
val speeds: List<Float> = emptyList(),
val speedAccuracyChangeTimestamps: List<Timestamp> = emptyList(),
val speedAccuracyChanges: List<Float> = emptyList(),
val timestamps: List<Timestamp> = emptyList(),
val verticalAccuracyChangeTimestamps: List<Timestamp> = emptyList(),
val verticalAccuracyChanges: List<Int> = emptyList()
@PropertyName(FieldSessionUUID) val sessionUUID: String = "", // reference of the session this path is part of
@PropertyName(FieldOwnerUUID) val ownerUUID: String = "",
@PropertyName(FieldAccuracyChangeTimestamps) val accuracyChangeTimestamps: List<Timestamp> = emptyList(),
@PropertyName(FieldAccuracyChanges) val accuracyChanges: List<Int> = emptyList(),
@PropertyName(FieldAltitudes) val altitudes: List<Int> = emptyList(),
@PropertyName(FieldBearingAccuracyChangeTimestamps) val bearingAccuracyChangeTimestamps: List<Timestamp> = emptyList(),
@PropertyName(FieldBearingAccuracyChanges) val bearingAccuracyChanges: List<Int> = emptyList(),
@PropertyName(FieldBearings) val bearings: List<Int> = emptyList(),
@PropertyName(FieldCoords) val coords: List<GeoPoint> = emptyList(),
@PropertyName(FieldSpeeds) val speeds: List<Float> = emptyList(),
@PropertyName(FieldSpeedAccuracyChangeTimestamps) val speedAccuracyChangeTimestamps: List<Timestamp> = emptyList(),
@PropertyName(FieldSpeedAccuracyChanges) val speedAccuracyChanges: List<Float> = emptyList(),
@PropertyName(FieldTimestamps) val timestamps: List<Timestamp> = emptyList(),
@PropertyName(FieldVerticalAccuracyChangeTimestamps) val verticalAccuracyChangeTimestamps: List<Timestamp> = emptyList(),
@PropertyName(FieldVerticalAccuracyChanges) val verticalAccuracyChanges: List<Int> = emptyList()
) : Parcelable {
companion object {
const val CollectionName = "paths"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@ package illyan.jay.data.network.model

import com.google.firebase.Timestamp
import com.google.firebase.firestore.GeoPoint
import com.google.firebase.firestore.PropertyName
import illyan.jay.util.toTimestamp
import java.time.Instant

data class FirestoreSession(
val uuid: String = "",
val startDateTime: Timestamp = Instant.EPOCH.toTimestamp(),
val endDateTime: Timestamp? = null,
val startLocation: GeoPoint? = null,
val endLocation: GeoPoint? = null,
val startLocationName: String? = null,
val endLocationName: String? = null,
val distance: Float? = null,
val clientUUID: String? = null
@PropertyName(FieldUUID) val uuid: String = "",
@PropertyName(FieldStartDateTime) val startDateTime: Timestamp = Instant.EPOCH.toTimestamp(),
@PropertyName(FieldEndDateTime) val endDateTime: Timestamp? = null,
@PropertyName(FieldStartLocation) val startLocation: GeoPoint? = null,
@PropertyName(FieldEndLocation) val endLocation: GeoPoint? = null,
@PropertyName(FieldStartLocationName) val startLocationName: String? = null,
@PropertyName(FieldEndLocationName) val endLocationName: String? = null,
@PropertyName(FieldDistance) val distance: Float? = null,
@PropertyName(FieldClientUUID) val clientUUID: String? = null
) {
companion object {
const val FieldUUID = "uuid"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@
package illyan.jay.data.network.model

import com.google.firebase.firestore.DocumentId
import com.google.firebase.firestore.PropertyName

data class FirestoreUser(
@DocumentId
val uuid: String = "",
val sessions: List<FirestoreSession> = emptyList(),
val preferences: FirestoreUserPreferences? = null
@PropertyName(FieldSessions) val sessions: List<FirestoreSession> = emptyList(),
@PropertyName(FieldPreferences) val preferences: FirestoreUserPreferences? = null
) {
companion object {
const val CollectionName = "users"
const val FieldSessions = "sessions"
const val FieldSettings = "preferences"
const val FieldPreferences = "preferences"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@
package illyan.jay.data.network.model

import com.google.firebase.Timestamp
import com.google.firebase.firestore.PropertyName
import illyan.jay.domain.model.DomainPreferences

data class FirestoreUserPreferences(
val analyticsEnabled: Boolean = false,
val freeDriveAutoStart: Boolean = false,
val lastUpdate: Timestamp = Timestamp.now()
@PropertyName(FieldAnalyticsEnabled) val analyticsEnabled: Boolean = DomainPreferences.default.analyticsEnabled,
@PropertyName(FieldFreeDriveAutoStart) val freeDriveAutoStart: Boolean = DomainPreferences.default.freeDriveAutoStart,
@PropertyName(FieldLastUpdate) val lastUpdate: Timestamp = Timestamp.now()
) {
companion object {
const val FieldAnalyticsEnabled = "analyticsEnabled"
const val FieldFreeDriveAutoStart = "freeDriveAutoStart"
const val FieldLastUpdate = "lastUpdate"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ data class DomainPreferences(
val freeDriveAutoStart: Boolean = false,
@Serializable(with = ZonedDateTimeSerializer::class)
val lastUpdate: ZonedDateTime = ZonedDateTime.now(),
val shouldSync: Boolean = false // FIXME: change this to true, because user preferences would break bcuz it would never download cloud preferences. Maybe make sync not update lastupdate?
val shouldSync: Boolean = false
) {
override fun equals(other: Any?): Boolean {
return if (other != null && other is DomainPreferences) {
Expand Down

0 comments on commit 3f87f1c

Please sign in to comment.