Skip to content

Commit

Permalink
Merge pull request #115 from CrisisCleanup/lists
Browse files Browse the repository at this point in the history
Lists
  • Loading branch information
hueachilles committed Jun 26, 2024
2 parents eb36878 + 5e08d02 commit 49c7092
Show file tree
Hide file tree
Showing 104 changed files with 8,939 additions and 462 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,9 @@ core/database/schemas/com.crisiscleanup.core.database.TestCrisisCleanupDatabase
# Direnv
!.envrc
.envrc.local

.crashlytics

app/dependencies

.kotlin
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class AppLogger @Inject constructor() : TagLogger {
override fun logCapture(message: String) {
Log.w(tag, message)
}

override fun setAccountId(id: String) {}
}

@Singleton
Expand Down
16 changes: 15 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsExtension
import com.google.samples.apps.nowinandroid.NiaBuildType

plugins {
Expand All @@ -9,11 +10,12 @@ plugins {
id("jacoco")
id("nowinandroid.android.application.firebase")
id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin")
id("com.google.firebase.crashlytics")
}

android {
defaultConfig {
val buildVersion = 203
val buildVersion = 211
applicationId = "com.crisiscleanup"
versionCode = buildVersion
versionName = "0.9.${buildVersion - 168}"
Expand Down Expand Up @@ -52,6 +54,14 @@ android {
debugSymbolLevel = "SYMBOL_TABLE"
}

configure<CrashlyticsExtension> {
// Enable processing and uploading of native symbols to Firebase servers.
// By default, this is disabled to improve build speeds.
// This flag must be enabled to see properly-symbolicated native
// stack traces in the Crashlytics dashboard.
nativeSymbolUploadEnabled = true
}

// To publish on the Play store a private signing key is required, but to allow anyone
// who clones the code to sign and run the release variant, use the debug signing key.
// Uncomment to install locally. Change to build for Play store.
Expand Down Expand Up @@ -115,6 +125,7 @@ dependencies {
implementation(projects.feature.caseeditor)
implementation(projects.feature.cases)
implementation(projects.feature.dashboard)
implementation(projects.feature.lists)
implementation(projects.feature.menu)
implementation(projects.feature.mediamanage)
implementation(projects.feature.organizationmanage)
Expand Down Expand Up @@ -166,6 +177,9 @@ dependencies {

// For Firebase support
implementation(platform(libs.firebase.bom))
// Crashlytics configuration
implementation(libs.firebase.crashlytics.ndk)
implementation(libs.firebase.analytics)

implementation(libs.kotlinx.coroutines.playservices)
implementation(libs.playservices.maps)
Expand Down
10 changes: 9 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,12 @@

# Android Studio Hedgehog require the following rules
-dontwarn io.grpc.internal.DnsNameResolverProvider
-dontwarn io.grpc.internal.PickFirstLoadBalancerProvider
-dontwarn io.grpc.internal.PickFirstLoadBalancerProvider

# Preserve information for crash reports
-keepattributes SourceFile,LineNumberTable # Keep file names and line numbers.
-renamesourcefileattribute SourceFile
-keep public class * extends java.lang.Exception # Optional: Keep custom exceptions.

# For using androidxLifecycle 2.8.2 or encounter LocalLifecycleOwner not present Error
-keep class androidx.compose.ui.platform.AndroidCompositionLocals_androidKt { *; }
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.crisiscleanup.core.common.event.ExternalEventBus
import com.crisiscleanup.core.common.log.AppLogger
import com.crisiscleanup.core.common.log.CrisisCleanupLoggers
import com.crisiscleanup.core.common.log.Logger
import com.crisiscleanup.core.common.queryParamMap
import javax.inject.Inject

class ExternalIntentProcessor @Inject constructor(
Expand Down Expand Up @@ -46,6 +47,8 @@ class ExternalIntentProcessor @Inject constructor(
if (code.isNotBlank()) {
externalEventBus.onOrgUserInvite(code)
}
} else if (urlPath.startsWith("/mobile_app_user_invite")) {
externalEventBus.onOrgPersistentInvite(url.queryParamMap)
} else {
return false
}
Expand Down
16 changes: 10 additions & 6 deletions app/src/main/java/com/crisiscleanup/MainActivityViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,17 @@ class MainActivityViewModel @Inject constructor(
init {
accountDataRepository.accountData
.onEach {
sync(false)
syncPuller.appPullIncident(incidentSelector.incidentId.first())
accountDataRefresher.updateMyOrganization(true)
accountDataRefresher.updateApprovedIncidents()
if (it.areTokensValid) {
sync(false)
syncPuller.appPullIncident(incidentSelector.incidentId.first())
accountDataRefresher.updateMyOrganization(true)
accountDataRefresher.updateApprovedIncidents()

if (!it.hasAcceptedTerms && !it.areTokensValid) {
authEventBus.onLogout()
logger.setAccountId(it.id.toString())
} else {
if (!it.hasAcceptedTerms) {
authEventBus.onLogout()
}
}
}
.launchIn(viewModelScope)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ class CrisisCleanupAppLogger @Inject constructor(
crashlytics.log(message)
}
}

override fun setAccountId(id: String) {
crashlytics.setUserId(id)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@ import com.crisiscleanup.feature.caseeditor.navigation.existingCaseTransferWorkT
import com.crisiscleanup.feature.caseeditor.navigation.navigateToCaseAddFlag
import com.crisiscleanup.feature.caseeditor.navigation.navigateToCaseEditor
import com.crisiscleanup.feature.caseeditor.navigation.navigateToTransferWorkType
import com.crisiscleanup.feature.caseeditor.navigation.navigateToViewCase
import com.crisiscleanup.feature.caseeditor.navigation.rerouteToCaseChange
import com.crisiscleanup.feature.cases.navigation.casesFilterScreen
import com.crisiscleanup.feature.cases.navigation.casesGraph
import com.crisiscleanup.feature.cases.navigation.casesSearchScreen
import com.crisiscleanup.feature.cases.navigation.navigateToCasesFilter
import com.crisiscleanup.feature.cases.navigation.navigateToCasesSearch
import com.crisiscleanup.feature.cases.ui.CasesAction
import com.crisiscleanup.feature.crisiscleanuplists.navigation.listsScreen
import com.crisiscleanup.feature.crisiscleanuplists.navigation.navigateToLists
import com.crisiscleanup.feature.crisiscleanuplists.navigation.navigateToViewList
import com.crisiscleanup.feature.crisiscleanuplists.navigation.viewListScreen
import com.crisiscleanup.feature.dashboard.navigation.dashboardScreen
import com.crisiscleanup.feature.mediamanage.navigation.viewSingleImageScreen
import com.crisiscleanup.feature.mediamanage.navigation.viewWorksiteImagesScreen
Expand Down Expand Up @@ -87,6 +92,12 @@ fun CrisisCleanupNavHost(
{ ids: ExistingWorksiteIdentifier -> navController.rerouteToCaseChange(ids) }
}

val openViewCase = remember(navController) {
{ ids: ExistingWorksiteIdentifier ->
navController.navigateToViewCase(ids.incidentId, ids.worksiteId)
}
}

val openFilterCases = remember(navController) { { navController.navigateToCasesFilter() } }

val openInviteTeammate =
Expand All @@ -97,6 +108,13 @@ fun CrisisCleanupNavHost(

val openUserFeedback = remember(navController) { { navController.navigateToUserFeedback() } }

val openLists = remember(navController) { { navController.navigateToLists() } }
val openList = remember(navController) {
{ listId: Long ->
navController.navigateToViewList(listId)
}
}

val openSyncLogs = remember(navController) { { navController.navigateToSyncInsights() } }

val navToCaseAddFlagNonEditing =
Expand Down Expand Up @@ -134,6 +152,7 @@ fun CrisisCleanupNavHost(
teamScreen()
menuScreen(
openAuthentication = openAuthentication,
openLists = openLists,
openInviteTeammate = openInviteTeammate,
openRequestRedeploy = openRequestRedeploy,
openUserFeedback = openUserFeedback,
Expand All @@ -144,6 +163,12 @@ fun CrisisCleanupNavHost(
inviteTeammateScreen(onBack)
requestRedeployScreen(onBack)
userFeedbackScreen(onBack)
listsScreen(navController, onBack)
viewListScreen(
onBack,
openList = openList,
openWorksite = openViewCase,
)
syncInsightsScreen(viewCase)

resetPasswordScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,7 @@ object RouteConstant {
const val WORKSITE_IMAGES_ROUTE = "worksite_images"

const val ACCOUNT_RESET_PASSWORD_ROUTE = "account_reset_password_route"

const val LISTS_ROUTE = "crisis_cleanup_lists"
const val VIEW_LIST_ROUTE = "view_list"
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ object PhoneNumberUtil {
private val twoPhoneNumbersRegex = """^(\d{10,11})\D+(\d{10,11})$""".toRegex()

fun getPhoneNumbers(possiblePhoneNumbers: List<String?>) = possiblePhoneNumbers
.filter { s -> s?.isNotBlank() == true }
.map { s -> s!! }
.filter { it?.isNotBlank() == true }
.map { it!! }
.map { phoneIn ->
val filtered = phoneIn.trim()
.trim()
val cleaned = filtered.replace(bracketsDashRegex, "")
.replace(letterRegex, " ")
.replace(twoPlusSpacesRegex, " ")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.crisiscleanup.core.common

import android.net.Uri

val Uri.queryParamMap: Map<String, String>
get() {
val params = mutableMapOf<String, String>()
for (key in queryParameterNames) {
getQueryParameter(key)?.let { value ->
params[key] = value
}
}
return params
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,34 @@ object LoggersModule {
return logger
}

@Provides
@Logger(CrisisCleanupLoggers.Incidents)
fun providesIncidentsLogger(logger: TagLogger): AppLogger {
logger.tag = "incidents"
return logger
}

@Provides
@Logger(CrisisCleanupLoggers.Language)
fun providesLanguageLogger(logger: TagLogger): AppLogger {
logger.tag = "language"
return logger
}

@Provides
@Logger(CrisisCleanupLoggers.Lists)
fun providesListsLogger(logger: TagLogger): AppLogger {
logger.tag = "lists"
return logger
}

@Provides
@Logger(CrisisCleanupLoggers.Media)
fun providesMediaLogger(logger: TagLogger): AppLogger {
logger.tag = "media"
return logger
}

@Provides
@Logger(CrisisCleanupLoggers.Navigation)
fun providesNavLogger(logger: TagLogger): AppLogger {
Expand Down Expand Up @@ -75,31 +103,10 @@ object LoggersModule {
return logger
}

@Provides
@Logger(CrisisCleanupLoggers.Incidents)
fun providesIncidentsLogger(logger: TagLogger): AppLogger {
logger.tag = "incidents"
return logger
}

@Provides
@Logger(CrisisCleanupLoggers.Worksites)
fun providesWorksitesLogger(logger: TagLogger): AppLogger {
logger.tag = "worksites"
return logger
}

@Provides
@Logger(CrisisCleanupLoggers.Language)
fun providesLanguageLogger(logger: TagLogger): AppLogger {
logger.tag = "language"
return logger
}

@Provides
@Logger(CrisisCleanupLoggers.Media)
fun providesMediaLogger(logger: TagLogger): AppLogger {
logger.tag = "media"
return logger
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ interface AppLogger {
fun logException(e: Exception)

fun logCapture(message: String)

fun setAccountId(id: String)
}

interface TagLogger : AppLogger {
Expand All @@ -25,6 +27,7 @@ enum class CrisisCleanupLoggers {
Cases,
Incidents,
Language,
Lists,
Media,
Navigation,
Network,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.crisiscleanup.core.commoncase.com.crisiscleanup.core.commoncase.ui
package com.crisiscleanup.core.commoncase.ui

import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
Expand Down
Loading

0 comments on commit 49c7092

Please sign in to comment.