Skip to content

Commit

Permalink
Merge branch 'main' into fix-issue-3138
Browse files Browse the repository at this point in the history
  • Loading branch information
suyash01 committed Jul 12, 2024
2 parents 5f7c762 + 77c1df1 commit c9ff4e5
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 166 deletions.
48 changes: 8 additions & 40 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,39 @@
## Pull request (PR) checklist

Please check if your pull request fulfills the following requirements:

<!-- 💡 Tip: Tick checkboxes like this: [x] -->

- [ ] The PR is submitted to the `main` branch.
<!--💡 Tip: Tick checkboxes like this: [x] 💡-->
- [ ] I've read the [Contribution Guidelines](https://github.com/Ivy-Apps/ivy-wallet/blob/main/CONTRIBUTING.md) and my PR doesn't break the rules.
- [ ] I've read and understand the [Developer Guidelines](https://github.com/Ivy-Apps/ivy-wallet/blob/main/docs/Guidelines.md).
- [ ] I confirm that I've run the code locally and everything works as expected.
- [ ] My PR includes only the necessary changes to fix the issue (i.e., no unnecessary files or lines of code are changed).
- [ ] 🎬 I've attached a **screen recording** of using the new code to the next paragraph (if applicable).


## Screen recording of interacting with your changes:

<!-- 💡 Tip: Drag & drop the video here. -->


<!--💡 Tip: Drag & drop the video here. 💡-->

## What's changed?
Describe with a few bullets **what's new:**

<!-- 💡 Tip: After each more important point leave one line empty and show your changes in markdown table with screenshots or screen recordings replacing {media}. In the end, it should look like this:
<!--💡 Tip: After each more important point leave one line empty and show your changes in markdown table with screenshots or screen recordings replacing {media}. In the end, it should look like this: 💡-->
- I've fixed...

Before|After
-------|-------
---------|---------
{media}|{media}
{media}|{media}
-->


- ...


- ...


## Risk factors

**What may go wrong if we merge your PR?**

- ...
- ...

**In what cases won't your code work?**

- ...
- ...


## Does this PR close any GitHub issues?

- Closes #{ISSUE_NUMBER}
<!-- For example:
- Closes #123
-->

<!-- 💡 Tip: Replace {ISSUE_NUMBER} with the number of Ivy Wallet ISSUE (https://github.com/Ivy-Apps/ivy-wallet/issues) (❗NOT PR❗) which this pull request fixes. If done correctly, you'll see the issue title linked on PR preview. -->

<!-- 💡 Tip: Multiple issues:
<!--❗For example: - Closes #123 ❗-->
<!--💡 Tip: Replace {ISSUE_NUMBER} with the number of Ivy Wallet ISSUE (https://github.com/Ivy-Apps/ivy-wallet/issues)(❗NOT PR❗) which this pull request fixes. If done correctly, you'll see the issue title linked on PR preview. 💡-->
<!--💡 Tip: Multiple issues:
- Closes #{ISSUE_NUMBER_1}, closes #{ISSUE_NUMBER_2}, closes #{ISSUE_NUMBER_3}
-->


💡-->
## Troubleshooting CI failures ❌

Pull request checks failing? Read our [CI Troubleshooting guide](https://github.com/Ivy-Apps/ivy-wallet/blob/main/docs/CI-Troubleshooting.md).
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")
}

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 @@ -28,12 +28,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 @@ -60,12 +54,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 @@ -76,9 +70,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 @@ -177,9 +168,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 @@ -226,53 +217,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 @@ -367,7 +324,7 @@ class RootActivity : AppCompatActivity(), RootScreen {
)
.setAllowedAuthenticators(
BiometricManager.Authenticators.BIOMETRIC_WEAK or
BiometricManager.Authenticators.DEVICE_CREDENTIAL
BiometricManager.Authenticators.DEVICE_CREDENTIAL
)
.setConfirmationRequired(false)
.build()
Expand All @@ -385,6 +342,7 @@ class RootActivity : AppCompatActivity(), RootScreen {
}
}

@Suppress("TooGenericExceptionCaught", "PrintStackTrace")
override fun openUrlInBrowser(url: String) {
try {
val browserIntent = Intent(Intent.ACTION_VIEW)
Expand Down Expand Up @@ -413,6 +371,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
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
Loading

0 comments on commit c9ff4e5

Please sign in to comment.