Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed all code related to sign in through google from app. #3333

Merged
merged 7 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ plugins {
id("com.google.devtools.ksp")
id("com.google.gms.google-services")
id("com.google.firebase.crashlytics")
id("io.gitlab.arturbosch.detekt")
ILIYANGERMANOV marked this conversation as resolved.
Show resolved Hide resolved
}

android {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/ivy/IvyNavGraph.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import com.ivy.transactions.TransactionsScreen
@ExperimentalFoundationApi
@ExperimentalAnimationApi
@Composable
@Suppress("CyclomaticComplexMethod", "FunctionNaming")
fun BoxWithConstraintsScope.IvyNavGraph(screen: Screen?) {
when (screen) {
null -> {
Expand Down
61 changes: 10 additions & 51 deletions app/src/main/java/com/ivy/wallet/RootActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ import androidx.compose.runtime.getValue
import androidx.core.content.ContextCompat
import androidx.core.view.WindowCompat
import androidx.lifecycle.viewmodel.compose.viewModel
import com.google.android.gms.auth.api.signin.GoogleSignIn
import com.google.android.gms.auth.api.signin.GoogleSignInAccount
import com.google.android.gms.auth.api.signin.GoogleSignInClient
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
import com.google.android.gms.common.api.ApiException
import com.google.android.gms.tasks.Task
import com.google.android.material.datepicker.MaterialDatePicker
import com.google.android.material.timepicker.MaterialTimePicker
import com.google.android.material.timepicker.TimeFormat
Expand All @@ -56,12 +50,12 @@ import com.ivy.widget.balance.WalletBalanceWidgetReceiver
import com.ivy.widget.transaction.AddTransactionWidget
import com.ivy.widget.transaction.AddTransactionWidgetCompact
import dagger.hilt.android.AndroidEntryPoint
import timber.log.Timber
import java.time.LocalDate
import java.time.LocalTime
import javax.inject.Inject

@AndroidEntryPoint
@Suppress("TooManyFunctions")
class RootActivity : AppCompatActivity(), RootScreen {
@Inject
lateinit var ivyContext: IvyWalletCtx
Expand All @@ -72,9 +66,6 @@ class RootActivity : AppCompatActivity(), RootScreen {
@Inject
lateinit var customerJourneyLogic: CustomerJourneyCardsProvider

private lateinit var googleSignInLauncher: ActivityResultLauncher<GoogleSignInClient>
private lateinit var onGoogleSignInIdTokenResult: (idToken: String?) -> Unit

private lateinit var createFileLauncher: ActivityResultLauncher<String>
private lateinit var onFileCreated: (fileUri: Uri) -> Unit

Expand Down Expand Up @@ -154,9 +145,9 @@ class RootActivity : AppCompatActivity(), RootScreen {

private fun setupDatePicker() {
ivyContext.onShowDatePicker = { minDate,
maxDate,
initialDate,
onDatePicked ->
maxDate,
initialDate,
onDatePicked ->
val datePicker =
MaterialDatePicker.Builder.datePicker()
.setSelection(
Expand Down Expand Up @@ -203,53 +194,19 @@ class RootActivity : AppCompatActivity(), RootScreen {
.build()
picker.show(supportFragmentManager, "timePicker")
picker.addOnPositiveButtonClickListener {
onTimePicked(LocalTime.of(picker.hour, picker.minute).convertLocalToUTC().withSecond(0))
onTimePicked(
LocalTime.of(picker.hour, picker.minute).convertLocalToUTC().withSecond(0)
)
}
}
}

private fun setupActivityForResultLaunchers() {
googleSignInLauncher()

createFileLauncher()

openFileLauncher()
}

private fun googleSignInLauncher() {
googleSignInLauncher = activityForResultLauncher(
createIntent = { _, client ->
client.signInIntent
}
) { _, intent ->
try {
val task: Task<GoogleSignInAccount> =
GoogleSignIn.getSignedInAccountFromIntent(intent)
val account: GoogleSignInAccount = task.getResult(ApiException::class.java)
val idToken = account.idToken
Timber.d("idToken = $idToken")

onGoogleSignInIdTokenResult(idToken)
} catch (e: ApiException) {
e.sendToCrashlytics("GOOGLE_SIGN_IN - registerGoogleSignInContract(): ApiException")
e.printStackTrace()
onGoogleSignInIdTokenResult(null)
}
}

ivyContext.googleSignIn = { idTokenResult: (String?) -> Unit ->
onGoogleSignInIdTokenResult = idTokenResult

val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestProfile()
.requestIdToken("364763737033-t1d2qe7s0s8597k7anu3sb2nq79ot5tp.apps.googleusercontent.com")
.build()
val googleSignInClient = GoogleSignIn.getClient(this, gso)
googleSignInLauncher.launch(googleSignInClient)
}
}

private fun createFileLauncher() {
createFileLauncher = activityForResultLauncher(
createIntent = { _, fileName ->
Expand Down Expand Up @@ -344,7 +301,7 @@ class RootActivity : AppCompatActivity(), RootScreen {
)
.setAllowedAuthenticators(
BiometricManager.Authenticators.BIOMETRIC_WEAK or
BiometricManager.Authenticators.DEVICE_CREDENTIAL
BiometricManager.Authenticators.DEVICE_CREDENTIAL
)
.setConfirmationRequired(false)
.build()
Expand All @@ -362,6 +319,7 @@ class RootActivity : AppCompatActivity(), RootScreen {
}
}

@Suppress("TooGenericExceptionCaught", "PrintStackTrace")
override fun openUrlInBrowser(url: String) {
try {
val browserIntent = Intent(Intent.ACTION_VIEW)
Expand Down Expand Up @@ -390,6 +348,7 @@ class RootActivity : AppCompatActivity(), RootScreen {
startActivity(share)
}

@Suppress("SwallowedException")
override fun openGooglePlayAppPage(appId: String) {
try {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$appId")))
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/ivy/wallet/RootViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import java.util.concurrent.atomic.AtomicLong
import javax.inject.Inject

@HiltViewModel
@Suppress("LongParameterList", "TooManyFunctions")
class RootViewModel @Inject constructor(
private val ivyContext: IvyWalletCtx,
private val nav: Navigation,
Expand Down Expand Up @@ -103,6 +104,7 @@ class RootViewModel @Inject constructor(
}
}

@Suppress("SwallowedException")
private fun handleSpecialStart(intent: Intent): Boolean {
val addTrnType: TransactionType? = try {
intent.getSerializableExtra(EXTRA_ADD_TRANSACTION_TYPE) as? TransactionType
Expand All @@ -125,6 +127,7 @@ class RootViewModel @Inject constructor(
return false
}

@Suppress("EmptyFunctionBlock")
fun handleBiometricAuthResult(
onAuthSuccess: () -> Unit = {}
): BiometricPrompt.AuthenticationCallback {
Expand Down Expand Up @@ -169,6 +172,7 @@ class RootViewModel @Inject constructor(
private val userInactiveTime = AtomicLong(0)
private var userInactiveJob: Job? = null

@Suppress("MagicNumber")
fun startUserInactiveTimeCounter() {
if (userInactiveJob != null && userInactiveJob!!.isActive) return

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class MigrationsManager @Inject constructor(
)
}

@Suppress("TooGenericExceptionCaught", "PrintStackTrace", "MagicNumber")
suspend fun executeMigrations() {
delay(2_000L) // to not the make the app start slower

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ivy.wallet.ui.applocked

import android.annotation.SuppressLint
import android.content.Context
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
Expand Down Expand Up @@ -37,7 +38,9 @@ import com.ivy.wallet.ui.theme.Gray
import com.ivy.wallet.ui.theme.White
import com.ivy.wallet.ui.theme.components.IvyButton

@SuppressLint("ComposeModifierMissing")
@Composable
@Suppress("LongMethod", "FunctionNaming")
fun BoxWithConstraintsScope.AppLockedScreen(
onShowOSBiometricsModal: () -> Unit,
onContinueWithoutAuthentication: () -> Unit
Expand Down Expand Up @@ -135,6 +138,7 @@ private fun osAuthentication(

@Preview
@Composable
@Suppress("FunctionNaming", "UnusedPrivateMember")
private fun Preview_Locked() {
IvyWalletPreview {
AppLockedScreen(
Expand Down
1 change: 0 additions & 1 deletion config/detekt/baseline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10637,7 +10637,6 @@
<ID>UnusedParameter:Title.kt$initialTransactionId: UUID?</ID>
<ID>UnusedPrivateMember:EditTransactionViewModel.kt$EditTransactionViewModel$private suspend fun transferToAmount( amount: Double ): Double?</ID>
<ID>UnusedPrivateMember:Migration109to110_PlannedPayments.kt$Migration109to110_PlannedPayments$private fun SupportSQLiteDatabase.addSyncColumns(tableName: String)</ID>
<ID>UnusedPrivateMember:OnboardingSplashLogin.kt$@Composable private fun LoginWithGoogleExplanation()</ID>
<ID>UnusedPrivateMember:SettingsScreen.kt$@Composable private fun AccountCardButton( @DrawableRes icon: Int, text: String, onClick: () -&gt; Unit )</ID>
<ID>UnusedPrivateProperty:AccountModal.kt$val context = LocalContext.current</ID>
<ID>UnusedPrivateProperty:DateExt.kt$val seconds = TimeUnit.MILLISECONDS.toSeconds(timeLeftAfterCalculations)</ID>
Expand Down
6 changes: 0 additions & 6 deletions config/detekt/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -509,12 +509,6 @@ style:
active: false
singleLine: 'never'
multiLine: 'always'
# OptionalWhenBraces is the deprecated rule, use OptionalWhenBraces instead.
# Use it now because BracesOnWhenStatements doesn't work as expected
# https://github.com/detekt/detekt/issues/6377
# Delete OptionalWhenBraces rule config after detekt#6377 fix
OptionalWhenBraces:
active: false
ILIYANGERMANOV marked this conversation as resolved.
Show resolved Hide resolved
BracesOnWhenStatements:
active: false
singleLine: 'necessary'
Expand Down
2 changes: 0 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ hilt-gradle-plugin = { module = "com.google.dagger:hilt-android-gradle-plugin",

# Google
google-services-plugin = { module = "com.google.gms:google-services", version = "4.4.2" }
google-playservices-auth = { module = "com.google.android.gms:play-services-auth", version = "21.2.0" }
google-play-update = { module = "com.google.android.play:app-update", version = "2.1.0" }
google-play-services = { module = "com.google.android.gms:play-services-tasks", version = "18.2.0" }
google-play-review = { module = "com.google.android.play:review-ktx", version = "2.0.1" }
Expand Down Expand Up @@ -209,7 +208,6 @@ glance = [
"glance-material3"
]
google = [
"google-playservices-auth",
"google-play-update",
"google-play-services",
"google-play-review"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.ivy.wallet.domain.deprecated.logic.model.CreateCategoryData

sealed interface OnboardingEvent {

data object LoginWithGoogle : OnboardingEvent
data object LoginOfflineAccount : OnboardingEvent
data object StartImport : OnboardingEvent
data object ImportSkip : OnboardingEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,42 +292,6 @@ private fun LoginSection(
}
}

@Composable
private fun LoginWithGoogleExplanation() {
Row(
verticalAlignment = Alignment.CenterVertically
) {
Spacer(Modifier.width(24.dp))

IvyIcon(
icon = R.drawable.ic_secure,
tint = Green
)

Spacer(Modifier.width(4.dp))

Column {
Text(
text = stringResource(R.string.sync_data_ivy_cloud),
style = UI.typo.c.style(
color = Green,
fontWeight = FontWeight.ExtraBold
)
)

Spacer(Modifier.height(2.dp))

Text(
text = stringResource(R.string.data_integrity_protection_warning),
style = UI.typo.c.style(
color = UI.colors.pureInverse,
fontWeight = FontWeight.Medium
)
)
}
}
}

@Composable
private fun LocalAccountExplanation() {
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import com.ivy.data.db.dao.read.SettingsDao
import com.ivy.data.db.dao.write.WriteSettingsDao
import com.ivy.ui.ComposeViewModel
import com.ivy.domain.usecase.exchange.SyncExchangeRatesUseCase
import com.ivy.legacy.IvyWalletCtx
import com.ivy.legacy.LogoutLogic
import com.ivy.data.model.Category
import com.ivy.data.repository.CategoryRepository
Expand All @@ -22,7 +21,6 @@ import com.ivy.legacy.datamodel.Settings
import com.ivy.legacy.domain.deprecated.logic.AccountCreator
import com.ivy.legacy.utils.OpResult
import com.ivy.legacy.utils.ioThread
import com.ivy.legacy.utils.sendToCrashlytics
import com.ivy.navigation.Navigation
import com.ivy.navigation.OnboardingScreen
import com.ivy.onboarding.OnboardingDetailState
Expand All @@ -40,13 +38,11 @@ import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.launch
import timber.log.Timber
import javax.inject.Inject

@Stable
@HiltViewModel
class OnboardingViewModel @Inject constructor(
private val ivyContext: IvyWalletCtx,
private val nav: Navigation,
private val accountDao: AccountDao,
private val settingsDao: SettingsDao,
Expand Down Expand Up @@ -150,7 +146,6 @@ class OnboardingViewModel @Inject constructor(
is OnboardingEvent.ImportFinished -> importFinished(event.success)
OnboardingEvent.ImportSkip -> importSkip()
OnboardingEvent.LoginOfflineAccount -> loginOfflineAccount()
OnboardingEvent.LoginWithGoogle -> loginWithGoogle()
OnboardingEvent.OnAddAccountsDone -> onAddAccountsDone()
OnboardingEvent.OnAddAccountsSkip -> onAddAccountsSkip()
OnboardingEvent.OnAddCategoriesDone -> onAddCategoriesDone()
Expand All @@ -162,30 +157,6 @@ class OnboardingViewModel @Inject constructor(
}
}

// Step 1 ---------------------------------------------------------------------------------------
private suspend fun loginWithGoogle() {
ivyContext.googleSignIn { idToken ->
if (idToken != null) {
_opGoogleSignIn.value = OpResult.loading()
viewModelScope.launch {
try {
router.googleLoginNext()
_opGoogleSignIn.value = null // reset login with Google operation state
} catch (e: Exception) {
e.sendToCrashlytics("GOOGLE_SIGN_IN ERROR: generic exception when logging with GOOGLE")
e.printStackTrace()
Timber.e("Login with Google failed on Ivy server - ${e.message}")
_opGoogleSignIn.value = OpResult.failure(e)
}
}
} else {
sendToCrashlytics("GOOGLE_SIGN_IN ERROR: idToken is null!!")
Timber.e("Login with Google failed while getting idToken")
_opGoogleSignIn.value = OpResult.faliure("Login with Google failed, try again.")
}
}
}

private suspend fun loginOfflineAccount() {
router.offlineAccountNext()
}
Expand Down