Skip to content
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 apps/flipcash/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ android {

lint {
checkReleaseBuilds = false
checkDependencies = true
baseline = file("lint-baseline.xml")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AppSettingMapper @Inject constructor(
override suspend fun map(from: AppSetting): AppSettingsItem {
return when (from.type) {
AppSettingValue.BiometricsRequired -> {
val biometricsState = biometricManager.canAuthenticate(Biometrics.TEST_AUTH)
val biometricsState = Biometrics.authenticationState(biometricManager)
val canUseBiometrics =
!(biometricsState == BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE ||
biometricsState == BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE ||
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.flipcash.shared.chat.ui.media

import android.net.Uri
import android.os.Build
import android.os.ext.SdkExtensions
import android.provider.MediaStore
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.PickVisualMediaRequest
Expand Down Expand Up @@ -30,7 +32,19 @@ fun rememberChatPhotoPicker(
val single = rememberLauncherForActivityResult(ActivityResultContracts.PickVisualMedia()) { uri ->
if (uri != null) currentOnPicked(listOf(uri))
}
val max = remaining.coerceIn(2, maxOf(2, MediaStore.getPickImagesMaxLimit()))
// getPickImagesMaxLimit() only exists where the system picker does (API 33+, or SDK
// extension R 2+). Without it, the open slots are the only cap.
val systemMax = remember {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU ||
(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R &&
SdkExtensions.getExtensionVersion(Build.VERSION_CODES.R) >= 2)
) {
MediaStore.getPickImagesMaxLimit()
} else {
null
}
}
val max = maxOf(2, systemMax?.let { minOf(remaining, it) } ?: remaining)
val multiple = rememberLauncherForActivityResult(
ActivityResultContracts.PickMultipleVisualMedia(max),
) { uris ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.os.Build
import android.os.Bundle
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult
Expand All @@ -17,6 +16,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.ui.platform.LocalContext
import androidx.core.content.ContextCompat
import androidx.core.os.BundleCompat
import com.getcode.utils.trace
import com.google.android.gms.auth.api.phone.SmsRetriever
Expand Down Expand Up @@ -95,14 +95,10 @@ fun SmsOtpAutofill(
}
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
context.registerReceiver(
receiver, filter, SmsRetriever.SEND_PERMISSION,
null, Context.RECEIVER_EXPORTED,
)
} else {
context.registerReceiver(receiver, filter, SmsRetriever.SEND_PERMISSION, null)
}
ContextCompat.registerReceiver(
context, receiver, filter, SmsRetriever.SEND_PERMISSION,
null, ContextCompat.RECEIVER_EXPORTED,
)

onDispose {
context.unregisterReceiver(receiver)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.fragment.app.FragmentActivity
import com.getcode.libs.biometrics.Biometrics.TEST_AUTH
import kotlinx.coroutines.delay
import kotlinx.coroutines.suspendCancellableCoroutine
import timber.log.Timber
Expand Down Expand Up @@ -55,10 +54,12 @@ object Biometrics {
private const val AUTHENTICATORS =
BiometricManager.Authenticators.BIOMETRIC_WEAK or BiometricManager.Authenticators.DEVICE_CREDENTIAL

const val TEST_AUTH = BiometricManager.Authenticators.BIOMETRIC_WEAK
private const val TEST_AUTH = BiometricManager.Authenticators.BIOMETRIC_WEAK

fun authenticationState(manager: BiometricManager): Int = manager.canAuthenticate(TEST_AUTH)

fun canAuthenticate(context: Context): Boolean {
val state = BiometricManager.from(context).canAuthenticate(TEST_AUTH)
val state = authenticationState(BiometricManager.from(context))

return !(state == BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE ||
state == BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE ||
Expand All @@ -67,7 +68,7 @@ object Biometrics {
}

fun hasNoneEnrolled(context: Context): Boolean {
val state = BiometricManager.from(context).canAuthenticate(TEST_AUTH)
val state = authenticationState(BiometricManager.from(context))

return state == BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.graphicsLayer

Expand Down Expand Up @@ -54,11 +54,7 @@ fun FlippableCard(
)
)
} else {
object : State<Float> {
override val value: Float
get() = cardFace.angle

}
rememberUpdatedState(cardFace.angle)
}

val showFront by remember { derivedStateOf { rotation.value <= 90f } }
Expand Down
Loading