Basics for user prefs, logging in, etc

This commit is contained in:
Damontecres 2025-09-21 19:56:40 -04:00
parent 763521aabf
commit 76d78246db
No known key found for this signature in database
15 changed files with 613 additions and 35 deletions

View file

@ -0,0 +1,27 @@
package com.github.damontecres.dolphin.preferences
import androidx.datastore.core.CorruptionException
import androidx.datastore.core.Serializer
import com.google.protobuf.InvalidProtocolBufferException
import java.io.InputStream
import java.io.OutputStream
import javax.inject.Inject
class UserPreferencesSerializer
@Inject
constructor() : Serializer<UserPreferences> {
override val defaultValue: UserPreferences = UserPreferences.getDefaultInstance()
override suspend fun readFrom(input: InputStream): UserPreferences {
try {
return UserPreferences.parseFrom(input)
} catch (exception: InvalidProtocolBufferException) {
throw CorruptionException("Cannot read proto.", exception)
}
}
override suspend fun writeTo(
t: UserPreferences,
output: OutputStream,
) = t.writeTo(output)
}