-
Notifications
You must be signed in to change notification settings - Fork 23
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 #145 from Philip2809/main
Fix loyalty cards by adding a google signin option
- Loading branch information
Showing
104 changed files
with
4,163 additions
and
505 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
2 changes: 0 additions & 2 deletions
2
...a/com/kieronquinn/app/classicpowermenu/components/quickaccesswallet/GooglePayConstants.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
60 changes: 60 additions & 0 deletions
60
...uinn/app/classicpowermenu/components/quickaccesswallet/loyaltycards/DatabaseRepository.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,60 @@ | ||
package com.kieronquinn.app.classicpowermenu.components.quickaccesswallet.loyaltycards | ||
|
||
import com.kieronquinn.app.classicpowermenu.components.settings.RoomEncryptedSettingsRepository | ||
import com.kieronquinn.app.classicpowermenu.model.quickaccesswallet.database.WalletDatabase | ||
import com.kieronquinn.app.classicpowermenu.model.quickaccesswallet.database.WalletValuable | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.sync.Mutex | ||
import kotlinx.coroutines.sync.withLock | ||
import kotlinx.coroutines.withContext | ||
|
||
interface ValuablesDatabaseRepository { | ||
|
||
fun getWalletValuables(): Flow<List<WalletValuable>> | ||
fun getWalletValuableById(id: String): Flow<WalletValuable?> | ||
|
||
suspend fun addWalletValuable(walletValuable: WalletValuable) | ||
suspend fun deleteWalletValuable(id: String) | ||
suspend fun deleteAllRecords() | ||
|
||
} | ||
|
||
class ValuablesDatabaseRepositoryImpl( | ||
database: WalletDatabase | ||
): ValuablesDatabaseRepository, RoomEncryptedSettingsRepository.RoomEncryptionFailedCallback { | ||
|
||
private val walletValuable = database.walletValuableDao() | ||
private val databaseLock = Mutex() | ||
|
||
override fun getWalletValuables() = walletValuable.getAll() | ||
|
||
override fun getWalletValuableById(id: String): Flow<WalletValuable?> { | ||
return walletValuable.getValuableById(id) | ||
} | ||
|
||
override suspend fun addWalletValuable( | ||
walletValuable: WalletValuable | ||
) = withContext(Dispatchers.IO) { | ||
databaseLock.withLock { | ||
this@ValuablesDatabaseRepositoryImpl.walletValuable.insert(walletValuable) | ||
} | ||
} | ||
|
||
override suspend fun deleteWalletValuable(id: String) = withContext(Dispatchers.IO) { | ||
databaseLock.withLock { | ||
this@ValuablesDatabaseRepositoryImpl.walletValuable.delete(id) | ||
} | ||
} | ||
|
||
override suspend fun deleteAllRecords() = withContext(Dispatchers.IO) { | ||
databaseLock.withLock { | ||
this@ValuablesDatabaseRepositoryImpl.walletValuable.clear() | ||
} | ||
} | ||
|
||
override fun onEncryptionFailed() { | ||
walletValuable.clear() | ||
} | ||
|
||
} |
Oops, something went wrong.