Skip to content

Commit

Permalink
Merge pull request #145 from Philip2809/main
Browse files Browse the repository at this point in the history
Fix loyalty cards by adding a google signin option
  • Loading branch information
KieronQuinn authored Sep 7, 2024
2 parents ae495a7 + 6cbc137 commit 41a92e5
Show file tree
Hide file tree
Showing 104 changed files with 4,163 additions and 505 deletions.
10 changes: 10 additions & 0 deletions .idea/migrations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 32 additions & 6 deletions .idea/navEditor.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions .idea/other.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id 'com.google.protobuf'
id 'kotlin-parcelize'
id 'com.google.android.gms.oss-licenses-plugin'
id 'com.google.devtools.ksp'
}

def version = '1.8'
Expand Down Expand Up @@ -66,9 +67,17 @@ protobuf {
}

dependencies {
api "androidx.security:security-crypto:1.1.0-alpha06"

implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.3.2'


//Room for data storage
api "androidx.room:room-runtime:$room_version"
api "androidx.room:room-ktx:$room_version"
ksp "androidx.room:room-compiler:$room_version"

//AndroidX
def lifecycle_version = "2.8.4"
implementation 'androidx.core:core-ktx:1.13.1'
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
<intent>
<action android:name="android.nfc.cardemulation.action.HOST_APDU_SERVICE" />
</intent>
<package android:name="com.google.android.apps.walletnfcrel"/>
</queries>

<application
android:allowBackup="true"
android:fullBackupContent="@xml/backup_rules"
android:dataExtractionRules="@xml/data_extraction_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher"
Expand All @@ -41,6 +43,7 @@
android:theme="@style/Theme.ClassicPowerMenu.Fullscreen"
android:noHistory="true"
android:exported="true"
android:showOnLockScreen="true"
android:launchMode="singleInstance"
android:excludeFromRecents="true">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.content.Context
import android.os.HandlerThread
import android.os.Looper
import androidx.lifecycle.lifecycleScope
import androidx.navigation.Navigation
import com.android.systemui.broadcast.BroadcastDispatcher
import com.android.systemui.broadcast.logging.BroadcastDispatcherLogger
import com.android.systemui.controls.CustomIconCache
Expand Down Expand Up @@ -37,8 +36,6 @@ import com.kieronquinn.app.classicpowermenu.components.monet.MonetColorProvider
import com.kieronquinn.app.classicpowermenu.components.navigation.*
import com.kieronquinn.app.classicpowermenu.components.quickaccesswallet.WalletActivityStarterImpl
import com.kieronquinn.app.classicpowermenu.components.quickaccesswallet.WalletCardBlurProviderImpl
import com.kieronquinn.app.classicpowermenu.components.quickaccesswallet.loyaltycards.LoyaltyCardsRepository
import com.kieronquinn.app.classicpowermenu.components.quickaccesswallet.loyaltycards.LoyaltyCardsRepositoryImpl
import com.kieronquinn.app.classicpowermenu.components.settings.Settings
import com.kieronquinn.app.classicpowermenu.components.settings.SettingsImpl
import com.kieronquinn.app.classicpowermenu.components.starter.PowerMenuStarter
Expand Down Expand Up @@ -72,8 +69,21 @@ import com.kieronquinn.app.classicpowermenu.ui.screens.settings.quickaccesswalle
import com.kieronquinn.app.classicpowermenu.ui.screens.settings.quickaccesswallet.autoswitchservice.SettingsQuickAccessWalletAutoSwitchServiceViewModelImpl
import com.kieronquinn.app.classicpowermenu.components.quickaccesswallet.autoswitch.AutoSwitchServicesRepository
import com.kieronquinn.app.classicpowermenu.components.quickaccesswallet.autoswitch.AutoSwitchServicesRepositoryImpl
import com.kieronquinn.app.classicpowermenu.ui.screens.settings.quickaccesswallet.rearrange.SettingsQuickAccessWalletRearrangeViewModel
import com.kieronquinn.app.classicpowermenu.ui.screens.settings.quickaccesswallet.rearrange.SettingsQuickAccessWalletRearrangeViewModelImpl
import com.kieronquinn.app.classicpowermenu.components.quickaccesswallet.loyaltycards.GoogleApiRepository
import com.kieronquinn.app.classicpowermenu.components.quickaccesswallet.loyaltycards.GoogleApiRepositoryImpl
import com.kieronquinn.app.classicpowermenu.components.quickaccesswallet.loyaltycards.GoogleWalletRepository
import com.kieronquinn.app.classicpowermenu.components.quickaccesswallet.loyaltycards.GoogleWalletRepositoryImpl
import com.kieronquinn.app.classicpowermenu.components.quickaccesswallet.loyaltycards.ValuablesDatabaseRepository
import com.kieronquinn.app.classicpowermenu.components.quickaccesswallet.loyaltycards.ValuablesDatabaseRepositoryImpl
import com.kieronquinn.app.classicpowermenu.components.settings.EncryptedSettings
import com.kieronquinn.app.classicpowermenu.components.settings.EncryptedSettingsImpl
import com.kieronquinn.app.classicpowermenu.components.settings.RoomEncryptedSettingsRepository
import com.kieronquinn.app.classicpowermenu.components.settings.RoomEncryptedSettingsRepositoryImpl
import com.kieronquinn.app.classicpowermenu.model.quickaccesswallet.database.WalletDatabase
import com.kieronquinn.app.classicpowermenu.ui.screens.settings.quickaccesswallet.loyaltycards.SignInWithGoogleViewModel
import com.kieronquinn.app.classicpowermenu.ui.screens.settings.quickaccesswallet.loyaltycards.SignInWithGoogleViewModelImpl
import com.kieronquinn.app.classicpowermenu.ui.screens.settings.quickaccesswallet.manage.SettingsQuickAccessWalletManageViewModel
import com.kieronquinn.app.classicpowermenu.ui.screens.settings.quickaccesswallet.manage.SettingsQuickAccessWalletManageViewModelImpl
import com.kieronquinn.app.classicpowermenu.ui.screens.settings.rootcheck.SettingsRootCheckViewModel
import com.kieronquinn.app.classicpowermenu.ui.screens.settings.rootcheck.SettingsRootCheckViewModelImpl
import com.kieronquinn.app.classicpowermenu.ui.screens.settings.update.UpdateAvailableBottomSheetViewModel
Expand Down Expand Up @@ -125,16 +135,22 @@ class ClassicPowerMenu: LifecycleApplication() {
single<PowerMenuNavigation> { PowerMenuNavigationImpl() }
single<ContainerNavigation> { ContainerNavigationImpl() }
single<AppNavigation> { AppNavigationImpl() }
single { WalletDatabase.getDatabase(get()) }
single<ValuablesDatabaseRepository> { ValuablesDatabaseRepositoryImpl(get()) }
single { get<ValuablesDatabaseRepository>() as RoomEncryptedSettingsRepository }
single<Settings> { SettingsImpl(get()) }
single<EncryptedSettings> { EncryptedSettingsImpl(get()) }
single<RoomEncryptedSettingsRepository> { RoomEncryptedSettingsRepositoryImpl(get()) }
single { UpdateChecker() }
}
}

private val walletModule = module {
single<WalletActivityStarter> { WalletActivityStarterImpl(get(), get()) }
single<WalletCardBlurProvider> { WalletCardBlurProviderImpl(get(), get()) }
single<LoyaltyCardsRepository> { LoyaltyCardsRepositoryImpl(get(), get(), get()) }
single<AutoSwitchServicesRepository> { AutoSwitchServicesRepositoryImpl(get(), get()) }
single<GoogleWalletRepository> { GoogleWalletRepositoryImpl(get(), get(), get(), get(), get()) }
single<GoogleApiRepository> { GoogleApiRepositoryImpl(get(), get()) }
}

private val monetModule = module {
Expand All @@ -159,10 +175,11 @@ class ClassicPowerMenu: LifecycleApplication() {
viewModel<SettingsMainViewModel> { SettingsMainViewModelImpl(get(), get(), get()) }
viewModel<SettingsPowerOptionsViewModel> { SettingsPowerOptionsViewModelImpl(get(), get()) }
viewModel<SettingsPowerOptionsRearrangeViewModel> { SettingsPowerOptionsRearrangeViewModelImpl(get(), get()) }
viewModel<SettingsQuickAccessWalletViewModel> { SettingsQuickAccessWalletViewModelImpl(get(), get(), get(), get()) }
viewModel<SettingsQuickAccessWalletViewModel> { SettingsQuickAccessWalletViewModelImpl(get(), get(), get(), get(), get(), get(), get()) }
viewModel<SettingsDeviceControlsViewModel> { SettingsDeviceControlsViewModelImpl(get(), get()) }
viewModel<SettingsQuickAccessWalletRearrangeViewModel> { SettingsQuickAccessWalletRearrangeViewModelImpl(get(), get(), get()) }
viewModel<SettingsQuickAccessWalletManageViewModel> { SettingsQuickAccessWalletManageViewModelImpl(get(), get(), get(), get()) }
viewModel<SettingsQuickAccessWalletAutoSwitchServiceViewModel> { SettingsQuickAccessWalletAutoSwitchServiceViewModelImpl(get(), get(), get()) }
viewModel<SignInWithGoogleViewModel> { SignInWithGoogleViewModelImpl(get(), get(), get()) }
viewModel<SettingsDeveloperOptionsViewModel> { SettingsDeveloperOptionsViewModelImpl(get()) }
viewModel<SettingsRootCheckViewModel> { SettingsRootCheckViewModelImpl(get()) }
viewModel<UpdateAvailableBottomSheetViewModel> { UpdateAvailableBottomSheetViewModelImpl(get()) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package com.kieronquinn.app.classicpowermenu.components.quickaccesswallet

import android.content.ComponentName
import android.content.pm.PackageManager
import com.kieronquinn.app.classicpowermenu.utils.extensions.isAppInstalled

object GooglePayConstants {

const val WALLET_NFC_REL_PACKAGE_NAME = "com.google.android.apps.walletnfcrel"
const val NBU_PAISA_PACKAGE_NAME = "com.google.android.apps.nbu.paisa.user"
val WALLET_DEEP_LINK_COMPONENT = ComponentName(WALLET_NFC_REL_PACKAGE_NAME, "com.google.commerce.tapandpay.android.deeplink.DeepLinkActivity")
const val WALLET_PREF_NAME = "global_prefs"
const val WALLET_CURRENT_ACCOUNT_ID_PREF_KEY = "current_account_id"
const val WALLET_DEEP_LINK_VALUABLE = "https://pay.google.com/gp/v/valuable/%s?vs=gp_lp"
Expand Down
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()
}

}
Loading

0 comments on commit 41a92e5

Please sign in to comment.