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
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 @@ -51,4 +51,9 @@ data class CameraGesturesFeature(
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
1 change: 1 addition & 0 deletions api/src/main/java/com/getcode/model/PrefBool.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ sealed class PrefsBool(val value: String) {
data object TIP_CARD_ON_HOMESCREEN: PrefsBool("tip_card_on_home_screen"), BetaFlag, Immutable
data object TIP_CARD_FLIPPABLE: PrefsBool("tipcard_flippable"), BetaFlag
data object CAMERA_GESTURES_ENABLED: PrefsBool("camera_gestures_enabled"), BetaFlag
data object GALLERY_ENABLED: PrefsBool("gallery_enabled"), BetaFlag
}

val APP_SETTINGS: List<AppSetting> = listOf(PrefsBool.CAMERA_START_BY_DEFAULT, PrefsBool.REQUIRE_BIOMETRICS)
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ data class BetaOptions(
val tipCardOnHomeScreen: Boolean,
val cameraGesturesEnabled: Boolean,
val canFlipTipCard: Boolean,
val galleryEnabled: Boolean,
) {
companion object {
// Default states for various beta flags in app.
Expand All @@ -43,7 +44,8 @@ data class BetaOptions(
shareTweetToTip = true,
tipCardOnHomeScreen = true,
cameraGesturesEnabled = true,
canFlipTipCard = false
canFlipTipCard = false,
galleryEnabled = false
)
}
}
Expand Down Expand Up @@ -82,7 +84,8 @@ class BetaFlagsRepository @Inject constructor(
observeBetaFlag(PrefsBool.SHARE_TWEET_TO_TIP, default = defaults.shareTweetToTip),
observeBetaFlag(PrefsBool.TIP_CARD_ON_HOMESCREEN, defaults.tipCardOnHomeScreen),
observeBetaFlag(PrefsBool.CAMERA_GESTURES_ENABLED, defaults.cameraGesturesEnabled),
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 @@ -102,6 +105,8 @@ class BetaFlagsRepository @Inject constructor(
tipCardOnHomeScreen = it[14],
cameraGesturesEnabled = it[15],
canFlipTipCard = it[16],
galleryEnabled = it[17],

)
}
}
Expand All @@ -125,19 +130,33 @@ 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.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 kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.map
import javax.inject.Inject
Expand All @@ -24,7 +25,7 @@ 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) }
Expand All @@ -34,6 +35,8 @@ class FeatureRepository @Inject constructor(

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

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

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

val balanceCurrencySelection = betaFlags.observe().map { BalanceCurrencyFeature(it.balanceCurrencySelectionEnabled) }
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
6 changes: 6 additions & 0 deletions app/src/main/java/com/getcode/inject/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import com.getcode.util.vibration.Vibrator
import com.getcode.utils.network.Api24NetworkObserver
import com.getcode.utils.network.Api29NetworkObserver
import com.getcode.utils.network.NetworkConnectivityListener
import com.kik.kikx.kikcodes.KikCodeScanner
import com.kik.kikx.kikcodes.implementation.KikCodeScannerImpl
import com.mixpanel.android.mpmetrics.MixpanelAPI
import dagger.Module
import dagger.Provides
Expand Down Expand Up @@ -120,4 +122,8 @@ object AppModule {
fun providesBiometricsManager(
@ApplicationContext context: Context
): BiometricManager = BiometricManager.from(context)

@Provides
@Singleton
fun providesCodeScanner(): KikCodeScanner = KikCodeScannerImpl()
}
21 changes: 21 additions & 0 deletions app/src/main/java/com/getcode/models/PaymentRequest.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.getcode.models

import android.net.Uri
import com.getcode.model.CurrencyCode
import com.getcode.model.Domain
import com.getcode.model.Fee
Expand All @@ -22,6 +23,7 @@ data class DeepLinkRequest(
val paymentRequest: PaymentRequest? = null,
val loginRequest: LoginRequest? = null,
val tipRequest: TipRequest? = null,
val imageRequest: ImageRequest? = null,
val successUrl: String?,
val cancelUrl: String?,

Expand All @@ -32,9 +34,20 @@ data class DeepLinkRequest(
@SerialName("donation") Donation,
@SerialName("login") Login,
@SerialName("tip") Tip,
@SerialName("internal:image") Image,
}

companion object {
fun fromImage(uri: Uri): DeepLinkRequest {
return DeepLinkRequest(
mode = Mode.Image,
clientSecret = emptyList(),
imageRequest = ImageRequest(uri),
cancelUrl = null,
successUrl = null,
)
}

fun fromTipCardUsername(platform: String, username: String): DeepLinkRequest {
return DeepLinkRequest(
mode = Mode.Tip,
Expand Down Expand Up @@ -138,6 +151,10 @@ data class DeepLinkRequest(
tipRequest = TipRequest(platform.name, platform.username)
)
}

Mode.Image -> {
return baseRequest
}
}
}
}
Expand All @@ -158,6 +175,10 @@ data class TipRequest(
val username: String,
)

data class ImageRequest(
val uri: Uri
)

private inline fun <reified T> JsonObject.decode(key: String): T? {
return runCatching { Json.decodeFromJsonElement<T>(getValue(key)) }
.onFailure { Timber.e("failed to decode $key from result") }
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/getcode/ui/components/AuthCheck.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ fun AuthCheck(
is DeeplinkHandler.Type.Login -> true
is DeeplinkHandler.Type.Cash,
is DeeplinkHandler.Type.Tip,
is DeeplinkHandler.Type.Image,
is DeeplinkHandler.Type.Sdk -> {
val hasAuth = state.isAuthenticated == true
if (!hasAuth) {
Expand Down
Loading