-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from cryptimeleon/feature/app-checkout
Feature/app checkout
- Loading branch information
Showing
78 changed files
with
2,067 additions
and
365 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...oid/app/src/main/java/org/cryptimeleon/incentive/app/data/database/BigIntegerConverter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.cryptimeleon.incentive.app.data.database | ||
|
||
import androidx.room.TypeConverter | ||
import com.google.gson.Gson | ||
import java.math.BigInteger | ||
|
||
class BigIntegerConverter { | ||
companion object { | ||
@JvmStatic | ||
@TypeConverter | ||
fun fromBigInteger(b: BigInteger): String = Gson().toJson(b) | ||
|
||
@JvmStatic | ||
@TypeConverter | ||
fun toBigInteger(s: String): BigInteger = Gson().fromJson(s, BigInteger::class.java) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...ava/org/cryptimeleon/incentive/app/data/database/promotion/TokenUpdateUserChoiceEntity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.cryptimeleon.incentive.app.data.database.promotion | ||
|
||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
import androidx.room.TypeConverter | ||
import androidx.room.TypeConverters | ||
import kotlinx.serialization.decodeFromString | ||
import kotlinx.serialization.encodeToString | ||
import kotlinx.serialization.json.Json | ||
import org.cryptimeleon.incentive.app.data.database.BigIntegerConverter | ||
import org.cryptimeleon.incentive.app.domain.model.UserUpdateChoice | ||
import org.cryptimeleon.incentive.app.domain.model.module | ||
import java.math.BigInteger | ||
|
||
private val json = Json { serializersModule = module } | ||
|
||
@TypeConverters(value = [TokenUpdateUserChoiceEntity.UserUpdateChoiceConverter::class, BigIntegerConverter::class]) | ||
@Entity(tableName = "token-update-user-choices") | ||
data class TokenUpdateUserChoiceEntity( | ||
@PrimaryKey | ||
val promotionId: BigInteger, | ||
val userUpdateChoice: UserUpdateChoice | ||
) { | ||
// Converter for storing the choices in the room database | ||
class UserUpdateChoiceConverter { | ||
companion object { | ||
@JvmStatic | ||
@TypeConverter | ||
fun fromChoice(userUpdateChoice: UserUpdateChoice): String = | ||
json.encodeToString(userUpdateChoice) | ||
|
||
@JvmStatic | ||
@TypeConverter | ||
fun toChoice(s: String): UserUpdateChoice = json.decodeFromString(s,) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.