Skip to content

Commit

Permalink
Merge pull request #552 from code-payments/release/2.1.10
Browse files Browse the repository at this point in the history
v2.1.10
  • Loading branch information
jeffyanta authored Sep 9, 2024
2 parents e4988a2 + ea19c9a commit 818d06e
Show file tree
Hide file tree
Showing 115 changed files with 1,559 additions and 555 deletions.
10 changes: 10 additions & 0 deletions api/src/main/java/com/getcode/analytics/AnalyticsManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,14 @@ class AnalyticsManager @Inject constructor(
)
}

override fun photoScanned(successful: Boolean, timeToScanInMillis: Long) {
track(
Name.PhotoScanned,
Property.Result to successful.toString(),
Property.Time to timeToScanInMillis.toInt().toString()
)
}

override fun action(action: Action, source: ActionSource?) {
track(
action = action,
Expand Down Expand Up @@ -343,6 +351,7 @@ class AnalyticsManager @Inject constructor(
PrivacyMigration("Privacy Migration"),
BackgroundSwap("Background Swap Initiated"),
Withdrawal("Withdrawal"),
PhotoScanned("Photo Scanned"),

// Errors
ErrorRequest("Error Request"),
Expand All @@ -365,6 +374,7 @@ class AnalyticsManager @Inject constructor(
Result("Result"),
MillisecondsToConfirm("Milliseconds to confirm"),
GrabTime("Grab Time"),
Time("Time"),

// Bill
State("State"),
Expand Down
4 changes: 4 additions & 0 deletions api/src/main/java/com/getcode/analytics/AnalyticsService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ interface AnalyticsService {

fun appSettingToggled(setting: AppSetting, value: Boolean)

fun photoScanned(successful: Boolean, timeToScanInMillis: Long)

fun action(action: Action, source: ActionSource? = null)
}

Expand Down Expand Up @@ -98,5 +100,7 @@ class AnalyticsServiceNull : AnalyticsService {
override fun backgroundSwapInitiated() = Unit
override fun unintentionalLogout() = Unit
override fun appSettingToggled(setting: AppSetting, value: Boolean) = Unit
override fun photoScanned(successful: Boolean, timeToScanInMillis: Long) = Unit

override fun action(action: Action, source: ActionSource?) = Unit
}
1 change: 1 addition & 0 deletions api/src/main/java/com/getcode/manager/SessionManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import javax.inject.Inject
import javax.inject.Singleton


// TODO: figure out a better naming paradigm b/w this and Session
@Singleton
class SessionManager @Inject constructor(
private val client: Client,
Expand Down
5 changes: 5 additions & 0 deletions api/src/main/java/com/getcode/model/Feature.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,9 @@ data class InvertedDragZoomFeature(
data class FlippableTipCardFeature(
override val enabled: Boolean = BetaOptions.Defaults.canFlipTipCard,
override val available: Boolean = true, // always available
): Feature

data class GalleryFeature(
override val enabled: Boolean = BetaOptions.Defaults.galleryEnabled,
override val available: Boolean = true, // always available
): Feature
20 changes: 12 additions & 8 deletions api/src/main/java/com/getcode/model/PrefBool.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ sealed interface AppSetting
sealed interface BetaFlag
// Dev settings
sealed interface DevSetting
// Once a feature behind a beta flag is made public, it becomes immutable
// This removes it from the UI in Settings -> Beta Flags
sealed interface Immutable
// Once a feature behind a beta flag is made public, it becomes immutable
sealed interface Launched: Immutable
// A feature flag can also be deemed deprecated and is also then immutable
sealed interface Deprecated : Immutable


sealed class PrefsBool(val value: String) {
Expand Down Expand Up @@ -52,18 +55,19 @@ sealed class PrefsBool(val value: String) {
data object DISPLAY_ERRORS: PrefsBool("debug_display_errors"), BetaFlag
data object SHOW_CONNECTIVITY_STATUS: PrefsBool("debug_no_network"), BetaFlag
data object GIVE_REQUESTS_ENABLED: PrefsBool("give_requests_enabled"), BetaFlag
data object BUY_MODULE_ENABLED : PrefsBool("buy_kin_enabled"), BetaFlag, Immutable
data object BUY_MODULE_ENABLED : PrefsBool("buy_kin_enabled"), BetaFlag, Launched
data object CHAT_UNSUB_ENABLED: PrefsBool("chat_unsub_enabled"), BetaFlag
data object TIPS_ENABLED : PrefsBool("tips_enabled"), BetaFlag, Immutable
data object TIPS_ENABLED : PrefsBool("tips_enabled"), BetaFlag, Launched
data object CONVERSATIONS_ENABLED: PrefsBool("conversations_enabled"), BetaFlag
data object CONVERSATION_CASH_ENABLED: PrefsBool("convo_cash_enabled"), BetaFlag
data object BALANCE_CURRENCY_SELECTION_ENABLED: PrefsBool("balance_currency_enabled"), BetaFlag, Immutable
data object BALANCE_CURRENCY_SELECTION_ENABLED: PrefsBool("balance_currency_enabled"), BetaFlag, Launched
data object KADO_WEBVIEW_ENABLED : PrefsBool("kado_inapp_enabled"), BetaFlag
data object SHARE_TWEET_TO_TIP : PrefsBool("share_tweet_to_tip"), BetaFlag, Immutable
data object TIP_CARD_ON_HOMESCREEN: PrefsBool("tip_card_on_home_screen"), BetaFlag, Immutable
data object SHARE_TWEET_TO_TIP : PrefsBool("share_tweet_to_tip"), BetaFlag, Launched
data object TIP_CARD_ON_HOMESCREEN: PrefsBool("tip_card_on_home_screen"), BetaFlag, Launched
data object TIP_CARD_FLIPPABLE: PrefsBool("tipcard_flippable"), BetaFlag
data object CAMERA_GESTURES_ENABLED: PrefsBool("camera_gestures_enabled"), BetaFlag, Immutable
data object CAMERA_DRAG_INVERTED: PrefsBool("camera_drag_inverted"), BetaFlag
data object CAMERA_GESTURES_ENABLED: PrefsBool("camera_gestures_enabled"), BetaFlag, Launched
data object CAMERA_DRAG_INVERTED: PrefsBool("camera_drag_inverted"), BetaFlag, Deprecated
data object GALLERY_ENABLED: PrefsBool("gallery_enabled"), BetaFlag, Launched
}

val APP_SETTINGS: List<AppSetting> = listOf(PrefsBool.CAMERA_START_BY_DEFAULT, PrefsBool.REQUIRE_BIOMETRICS)
2 changes: 1 addition & 1 deletion api/src/main/java/com/getcode/network/BalanceController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ open class BalanceController @Inject constructor(
transactionReceiver.receiveFromIncoming(organizer)
transactionRepository.swapIfNeeded(organizer)
} catch (ex: Exception) {
Timber.i("Error: ${ex.javaClass.simpleName} ${ex.cause}")
Timber.i("Error: ${ex.javaClass.simpleName} ${ex.message}")
val organizer =
SessionManager.getOrganizer() ?: throw IllegalStateException("Missing Organizer")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ data class BetaOptions(
val cameraGesturesEnabled: Boolean,
val invertedDragZoom: Boolean,
val canFlipTipCard: Boolean,
val galleryEnabled: Boolean,
) {
companion object {
// Default states for various beta flags in app.
Expand All @@ -45,7 +46,8 @@ data class BetaOptions(
tipCardOnHomeScreen = true,
cameraGesturesEnabled = true,
invertedDragZoom = false,
canFlipTipCard = false
canFlipTipCard = false,
galleryEnabled = true
)
}
}
Expand Down Expand Up @@ -85,7 +87,8 @@ class BetaFlagsRepository @Inject constructor(
observeBetaFlag(PrefsBool.TIP_CARD_ON_HOMESCREEN, defaults.tipCardOnHomeScreen),
observeBetaFlag(PrefsBool.CAMERA_GESTURES_ENABLED, defaults.cameraGesturesEnabled),
observeBetaFlag(PrefsBool.CAMERA_DRAG_INVERTED, defaults.invertedDragZoom),
observeBetaFlag(PrefsBool.TIP_CARD_FLIPPABLE, defaults.canFlipTipCard)
observeBetaFlag(PrefsBool.TIP_CARD_FLIPPABLE, defaults.canFlipTipCard),
observeBetaFlag(PrefsBool.GALLERY_ENABLED, defaults.galleryEnabled),
) {
BetaOptions(
showNetworkDropOff = it[0],
Expand All @@ -106,6 +109,7 @@ class BetaFlagsRepository @Inject constructor(
cameraGesturesEnabled = it[15],
invertedDragZoom = it[16],
canFlipTipCard = it[17],
galleryEnabled = it[18],
)
}
}
Expand All @@ -129,19 +133,34 @@ class BetaFlagsRepository @Inject constructor(
PrefsBool.BALANCE_CURRENCY_SELECTION_ENABLED -> balanceCurrencySelectionEnabled
PrefsBool.BUCKET_DEBUGGER_ENABLED -> canViewBuckets
PrefsBool.BUY_MODULE_ENABLED -> buyModuleEnabled
PrefsBool.CAMERA_GESTURES_ENABLED -> cameraGesturesEnabled
PrefsBool.CAMERA_DRAG_INVERTED -> invertedDragZoom
PrefsBool.CHAT_UNSUB_ENABLED -> chatUnsubEnabled
PrefsBool.CONVERSATIONS_ENABLED -> conversationsEnabled
PrefsBool.CONVERSATION_CASH_ENABLED -> conversationCashEnabled
PrefsBool.DISPLAY_ERRORS -> displayErrors
PrefsBool.GALLERY_ENABLED -> galleryEnabled
PrefsBool.GIVE_REQUESTS_ENABLED -> giveRequestsEnabled
PrefsBool.KADO_WEBVIEW_ENABLED -> kadoWebViewEnabled
PrefsBool.LOG_SCAN_TIMES -> debugScanTimesEnabled
PrefsBool.SHARE_TWEET_TO_TIP -> shareTweetToTip
PrefsBool.SHOW_CONNECTIVITY_STATUS -> showNetworkDropOff
PrefsBool.TIPS_ENABLED -> tipsEnabled
PrefsBool.TIP_CARD_FLIPPABLE -> canFlipTipCard
PrefsBool.TIP_CARD_ON_HOMESCREEN -> tipCardOnHomeScreen
PrefsBool.VIBRATE_ON_SCAN -> tickOnScan
else -> false
PrefsBool.BUY_MODULE_AVAILABLE -> false
PrefsBool.CAMERA_START_BY_DEFAULT -> false
PrefsBool.DISMISSED_TIP_CARD_BANNER -> false
PrefsBool.ESTABLISH_CODE_RELATIONSHIP -> false
PrefsBool.HAS_REMOVED_LOCAL_CURRENCY -> false
PrefsBool.IS_DEBUG_ACTIVE -> false
PrefsBool.IS_DEBUG_ALLOWED -> false
PrefsBool.IS_ELIGIBLE_GET_FIRST_KIN_AIRDROP -> false
PrefsBool.IS_ELIGIBLE_GIVE_FIRST_KIN_AIRDROP -> false
PrefsBool.REQUIRE_BIOMETRICS -> false
PrefsBool.SEEN_TIP_CARD -> false
PrefsBool.STARTED_TIP_CONNECT -> false
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.getcode.model.TipCardOnHomeScreenFeature
import com.getcode.model.ConversationCashFeature
import com.getcode.model.ConversationsFeature
import com.getcode.model.FlippableTipCardFeature
import com.getcode.model.GalleryFeature
import com.getcode.model.InvertedDragZoomFeature
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.map
Expand All @@ -25,20 +26,25 @@ class FeatureRepository @Inject constructor(
val buyModule = combine(
betaFlags.observe().map { it.buyModuleEnabled },
prefRepository.observeOrDefault(PrefsBool.BUY_MODULE_AVAILABLE, false)
) { enabled, available -> BuyModuleFeature(enabled, available) }
) { enabled, available -> BuyModuleFeature(enabled, available) }

val tipCards = betaFlags.observe().map { TipCardFeature(it.tipsEnabled) }
val tipCardOnHomeScreen = betaFlags.observe().map { TipCardOnHomeScreenFeature(it.tipCardOnHomeScreen) }
val tipCardOnHomeScreen =
betaFlags.observe().map { TipCardOnHomeScreenFeature(it.tipCardOnHomeScreen) }
val tipCardFlippable = betaFlags.observe().map { FlippableTipCardFeature(it.canFlipTipCard) }
val conversations = betaFlags.observe().map { ConversationsFeature(it.conversationsEnabled) }
val conversationsCash = betaFlags.observe().map { ConversationCashFeature(it.conversationCashEnabled) }
val conversationsCash =
betaFlags.observe().map { ConversationCashFeature(it.conversationCashEnabled) }

val cameraGestures = betaFlags.observe().map { CameraGesturesFeature(it.cameraGesturesEnabled) }
val invertedDragZoom = betaFlags.observe().map { InvertedDragZoomFeature(it.invertedDragZoom) }

val galleryEnabled = betaFlags.observe().map { GalleryFeature(it.galleryEnabled) }

val requestKin = betaFlags.observe().map { RequestKinFeature(it.giveRequestsEnabled) }

val balanceCurrencySelection = betaFlags.observe().map { BalanceCurrencyFeature(it.balanceCurrencySelectionEnabled) }
val balanceCurrencySelection =
betaFlags.observe().map { BalanceCurrencyFeature(it.balanceCurrencySelectionEnabled) }

suspend fun isEnabled(feature: PrefsBool): Boolean = betaFlags.isEnabled(feature)
}
36 changes: 34 additions & 2 deletions api/src/main/java/com/getcode/utils/Logging.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import com.bugsnag.android.BreadcrumbType
import com.bugsnag.android.Bugsnag
import timber.log.Timber
import kotlin.time.Duration
import kotlin.time.measureTime

sealed interface TraceType {
Expand Down Expand Up @@ -103,16 +104,47 @@ fun <T> timedTrace(
type: TraceType = TraceType.Log,
metadata: MetadataBuilder.() -> Unit = {},
error: Throwable? = null,
onComplete: (T, Duration) -> Unit = { _, _ -> },
block: () -> T
): T {
var result: T
val time = measureTime {
result = block()
}

val newMessage = "$message took ${time.inWholeMilliseconds}ms"
trace(newMessage, tag, type, metadata, error)
val timedMetadata: MetadataBuilder.() -> Unit = {
// Add the original metadata
metadata()
"duration" to time.inWholeMilliseconds
}

trace(message, tag, type, timedMetadata, error)
onComplete(result, time)
return result
}

suspend fun <T> timedTraceSuspend(
message: String,
tag: String? = null,
type: TraceType = TraceType.Log,
metadata: MetadataBuilder.() -> Unit = {},
error: Throwable? = null,
onComplete: (T, Duration) -> Unit = { _, _ -> },
block: suspend () -> T
): T {
var result: T
val time = measureTime {
result = block()
}

val timedMetadata: MetadataBuilder.() -> Unit = {
// Add the original metadata
metadata()
"duration" to time.inWholeMilliseconds
}

trace(message, tag, type, timedMetadata, error)
onComplete(result, time)
return result
}

Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/com/getcode/utils/Timber.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ suspend fun <T> timberTimerSuspend(message: String, block: suspend () -> T): T {
val result = block()
Timber.d(
"$message took ${
(System.nanoTime() - start).toDouble().div(1000000).roundToLong()
(System.nanoTime() - start).toDouble().div(1_000_000).roundToLong()
}ms",
)
result
Expand Down
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ dependencies {

implementation(Libs.androidx_biometrics)

implementation(Libs.androidx_activity)

// cameraX
implementation(Libs.androidx_camerax_core)
implementation(Libs.androidx_camerax_camera2)
Expand Down
36 changes: 26 additions & 10 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">

<uses-feature
android:name="android.hardware.camera"
Expand Down Expand Up @@ -54,6 +55,18 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="image/*"/>
</intent-filter>

<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />

Expand Down Expand Up @@ -151,17 +164,20 @@
</intent-filter>
</activity>

<activity-alias
android:name="com.getcode.view.TweetShareHandler"
android:exported="true"
android:targetActivity="com.getcode.view.MainActivity"
android:enabled="true">
<!--
Prompt Google Play services to install the backported photo picker module
https://developer.android.com/training/data-storage/shared/photopicker#device-availability
-->
<!--suppress AndroidDomInspection -->
<service android:name="com.google.android.gms.metadata.ModuleDependencies"
android:enabled="false"
android:exported="false"
tools:ignore="MissingClass">
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
<action android:name="com.google.android.gms.metadata.MODULE_DEPENDENCIES" />
</intent-filter>
</activity-alias>
<meta-data android:name="photopicker_activity:0:required" android:value="" />
</service>

<service
android:name="com.getcode.util.AuthenticatorService"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/getcode/CodeApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ import com.getcode.ui.components.bars.TopBarContainer
import com.getcode.ui.utils.getActivity
import com.getcode.ui.utils.getActivityScopedViewModel
import com.getcode.ui.utils.measured
import com.getcode.ui.utils.rememberBiometricsState
import com.getcode.util.BiometricsError
import com.getcode.view.main.home.components.BiometricsBlockingView
import com.getcode.view.main.home.components.rememberBiometricsState
import com.getcode.view.main.scanner.views.BiometricsBlockingView
import dev.bmcreations.tipkit.TipScaffold
import dev.bmcreations.tipkit.engines.TipsEngine

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/getcode/Locals.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import com.getcode.analytics.AnalyticsServiceNull
import com.getcode.network.exchange.Exchange
import com.getcode.network.exchange.ExchangeNull
import com.getcode.network.repository.BetaOptions
import com.getcode.ui.utils.BiometricsState
import com.getcode.util.CurrencyUtils
import com.getcode.util.DeeplinkHandler
import com.getcode.util.PhoneUtils
import com.getcode.utils.network.NetworkConnectivityListener
import com.getcode.utils.network.NetworkObserverStub
import com.getcode.view.main.home.components.BiometricsState

val LocalSession: ProvidableCompositionLocal<Session?> = staticCompositionLocalOf { null }
val LocalAnalytics: ProvidableCompositionLocal<AnalyticsService> = staticCompositionLocalOf { AnalyticsServiceNull() }
val LocalNetworkObserver: ProvidableCompositionLocal<NetworkConnectivityListener> = staticCompositionLocalOf { NetworkObserverStub() }
val LocalPhoneFormatter: ProvidableCompositionLocal<PhoneUtils?> = staticCompositionLocalOf { null }
Expand Down
Loading

0 comments on commit 818d06e

Please sign in to comment.