-
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.
Reference app supports verification logs (#28)
This configures the app to store data using SQLite and adds a view to display and export it. This won't be used yet, but we are letting it ready for further development.
- Loading branch information
1 parent
236f0a0
commit ba478c8
Showing
23 changed files
with
604 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
plugins { | ||
id("com.android.application") version "8.2.0" apply false | ||
id("com.android.application") version "8.5.1" apply false | ||
id("org.jetbrains.kotlin.android") version "1.9.23" apply false | ||
id("com.android.library") version "8.2.0" apply false | ||
id("com.android.library") version "8.5.1" apply false | ||
id("com.gradleup.nmcp") version "0.0.4" apply true | ||
id("com.google.devtools.ksp") version "1.9.23-1.0.20" apply false | ||
} |
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
5 changes: 3 additions & 2 deletions
5
example/src/main/java/com/spruceid/mobilesdkexample/MainActivity.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
33 changes: 33 additions & 0 deletions
33
example/src/main/java/com/spruceid/mobilesdkexample/db/AppDatabase.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,33 @@ | ||
package com.spruceid.mobilesdkexample.db | ||
|
||
import android.content.Context | ||
import androidx.room.Database | ||
import androidx.room.Room | ||
import androidx.room.RoomDatabase | ||
import androidx.room.TypeConverters | ||
|
||
@Database(entities = [VerificationActivityLogs::class], version = 1) | ||
@TypeConverters(*[DateConverter::class]) | ||
abstract class AppDatabase : RoomDatabase() { | ||
abstract fun verificationActivityLogsDao(): VerificationActivityLogsDao | ||
|
||
companion object { | ||
@Volatile | ||
private var dbInstance: AppDatabase? = null | ||
|
||
fun getDatabase(context: Context): AppDatabase { | ||
return dbInstance ?: synchronized(this) { | ||
val instance = | ||
Room.databaseBuilder( | ||
context.applicationContext, | ||
AppDatabase::class.java, | ||
"verification_activity_logs", | ||
) | ||
.allowMainThreadQueries() | ||
.build() | ||
dbInstance = instance | ||
instance | ||
} | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
example/src/main/java/com/spruceid/mobilesdkexample/db/Converters.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,16 @@ | ||
package com.spruceid.mobilesdkexample.db | ||
|
||
import androidx.room.TypeConverter | ||
import java.sql.Date | ||
|
||
object DateConverter { | ||
@TypeConverter | ||
fun toDate(dateLong: Long?): Date? { | ||
return if (dateLong == null) null else Date(dateLong) | ||
} | ||
|
||
@TypeConverter | ||
fun fromDate(date: Date?): Long? { | ||
return date?.time | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
example/src/main/java/com/spruceid/mobilesdkexample/db/Daos.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,14 @@ | ||
package com.spruceid.mobilesdkexample.db | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Insert | ||
import androidx.room.Query | ||
|
||
@Dao | ||
interface VerificationActivityLogsDao { | ||
@Insert | ||
suspend fun insertVerificationActivity(verificationActivityLogs: VerificationActivityLogs) | ||
|
||
@Query("SELECT * FROM verification_activity_logs") | ||
fun getAllVerificationActivityLogs(): List<VerificationActivityLogs> | ||
} |
15 changes: 15 additions & 0 deletions
15
example/src/main/java/com/spruceid/mobilesdkexample/db/Entities.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,15 @@ | ||
package com.spruceid.mobilesdkexample.db | ||
|
||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
import java.sql.Date | ||
|
||
@Entity(tableName = "verification_activity_logs") | ||
data class VerificationActivityLogs( | ||
@PrimaryKey(autoGenerate = true) val id: Long = 0, | ||
val name: String, | ||
val credentialTitle: String, | ||
val date: Date, | ||
val expirationDate: Date, | ||
val status: String, | ||
) |
17 changes: 17 additions & 0 deletions
17
example/src/main/java/com/spruceid/mobilesdkexample/db/Repositories.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 com.spruceid.mobilesdkexample.db | ||
|
||
import androidx.annotation.WorkerThread | ||
|
||
class VerificationActivityLogsRepository(private val verificationActivityLogsDao: VerificationActivityLogsDao) { | ||
val verificationActivityLogs: List<VerificationActivityLogs> = verificationActivityLogsDao.getAllVerificationActivityLogs() | ||
|
||
@WorkerThread | ||
suspend fun insertVerificationActivityLog(verificationActivityLogs: VerificationActivityLogs) { | ||
verificationActivityLogsDao.insertVerificationActivity(verificationActivityLogs) | ||
} | ||
|
||
@WorkerThread | ||
suspend fun getVerificationActivityLogs(): List<VerificationActivityLogs> { | ||
return verificationActivityLogsDao.getAllVerificationActivityLogs() | ||
} | ||
} |
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
Oops, something went wrong.