Skip to content

Commit e19f31e

Browse files
committed
updates for
-3 fixes for issues that Mark G found -New version of Gradle -New version of Kotlin (1.7.10) -New version of JetPack Compose (1.2.1) -Updates to literally just about every package we use -Test pass!
1 parent c9f3c58 commit e19f31e

20 files changed

+81
-43
lines changed

src/app/build.gradle

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ plugins {
44
id "org.jetbrains.kotlin.plugin.serialization"
55
}
66
android {
7-
compileSdk 32
7+
compileSdk 33
88

99
defaultConfig {
1010
applicationId "com.couchbase.kotlin.learningpath"
1111
minSdk 24
12-
targetSdk 32
12+
targetSdk 33
1313
versionCode 1
1414
versionName "1.0"
1515

@@ -73,6 +73,7 @@ android {
7373
}
7474
}
7575
namespace 'com.couchbase.learningpath'
76+
buildToolsVersion '33.0.0'
7677
}
7778

7879
dependencies {
@@ -82,22 +83,22 @@ dependencies {
8283

8384
//core compose
8485
implementation "androidx.core:core-ktx:$core_ktx"
85-
implementation "androidx.compose.ui:ui:$compose_version"
86+
implementation "androidx.compose.ui:ui:$compose_ui_version"
8687

8788
// Tooling support (Previews, etc.)
88-
implementation "androidx.compose.ui:ui-tooling:$compose_version"
89+
implementation "androidx.compose.ui:ui-tooling:$compose_ui_version"
8990

9091
// Foundation (Border, Background, Box, Image, Scroll, shapes, animations, etc.)
91-
implementation "androidx.compose.foundation:foundation:$compose_version"
92-
implementation "androidx.compose.foundation:foundation-layout:$compose_version"
92+
implementation "androidx.compose.foundation:foundation:$compose_ui_version"
93+
implementation "androidx.compose.foundation:foundation-layout:$compose_ui_version"
9394

9495
// animation
95-
implementation "androidx.compose.animation:animation:$compose_version"
96+
implementation "androidx.compose.animation:animation:$compose_ui_version"
9697

9798
// Material design and icons
98-
implementation "androidx.compose.material:material:$compose_version"
99-
implementation "androidx.compose.material:material-icons-core:$compose_version"
100-
implementation "androidx.compose.material:material-icons-extended:$compose_version"
99+
implementation "androidx.compose.material:material:$compose_ui_version"
100+
implementation "androidx.compose.material:material-icons-core:$compose_ui_version"
101+
implementation "androidx.compose.material:material-icons-extended:$compose_ui_version"
101102
implementation "com.google.android.material:material:$android_materialdesign_version"
102103

103104
//lifecycle and integration with ViewModels
@@ -107,7 +108,7 @@ dependencies {
107108
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecyle_runtime_ktx_version"
108109

109110
// Integration with observables
110-
implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
111+
implementation "androidx.compose.runtime:runtime-livedata:$compose_ui_version"
111112

112113
// Integration with activities
113114
implementation "androidx.activity:activity-compose:$activity_compose_version"
@@ -125,7 +126,7 @@ dependencies {
125126
// Dependency injection
126127
implementation "io.insert-koin:koin-core:$koin_version"
127128
implementation "io.insert-koin:koin-android:$koin_version"
128-
implementation "io.insert-koin:koin-androidx-compose:$koin_version"
129+
implementation "io.insert-koin:koin-androidx-compose:$koin_version_compose"
129130

130131
//couchbase lite for kotlin
131132
implementation "com.couchbase.lite:couchbase-lite-android-ktx:$couchbase_lite_version"
@@ -138,9 +139,9 @@ dependencies {
138139
androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_tests_version"
139140
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
140141
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
141-
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
142+
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_ui_version"
142143
androidTestImplementation 'androidx.test:runner:1.4.0'
143144
androidTestUtil 'androidx.test:orchestrator:1.4.1'
144-
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
145-
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
145+
debugImplementation "androidx.compose.ui:ui-tooling:$compose_ui_version"
146+
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_ui_version"
146147
}

src/app/src/androidTest/java/com/couchbase/learningpath/DatabaseIntegrationTests.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ class DatabaseIntegrationTests {
282282
val stockItemCount = stockItemRepository.count()
283283

284284
//assert
285-
assertEquals(50, warehouseCount)
285+
assertEquals(55, warehouseCount)
286286
assertEquals(3000, stockItemCount)
287287
}
288288
}
@@ -296,7 +296,7 @@ class DatabaseIntegrationTests {
296296

297297
//assert
298298
assertNotNull(warehouses)
299-
assertEquals(50, warehouses.count())
299+
assertEquals(55, warehouses.count())
300300
}
301301
}
302302

src/app/src/main/java/com/couchbase/learningpath/InventoryNavGraph.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ object MainDestinations {
5757
}
5858

5959
//main function for handling navigation graph in the app
60+
@kotlinx.serialization.ExperimentalSerializationApi
6061
@ExperimentalMaterialApi
6162
@ExperimentalCoroutinesApi
6263
@Composable

src/app/src/main/java/com/couchbase/learningpath/services/ReplicatorServiceDb.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ReplicatorServiceDb (
3030
ReplicatorConfig(
3131
username = loggedInUser.username,
3232
password = loggedInUser.password,
33-
endpointUrl = "ws://10.0.2.2:4984/projects",
33+
endpointUrl = "ws://10.0.2.2:4984/projects",
3434
replicatorType = "PUSH AND PULL",
3535
heartBeat = 60L,
3636
continuous = true,
@@ -114,6 +114,9 @@ class ReplicatorServiceDb (
114114

115115
override fun startReplication() {
116116
try {
117+
if (databaseManager.inventoryDatabase == null){
118+
databaseManager.initializeDatabases(authenticationService.getCurrentUser())
119+
}
117120
replicatorManager?.replicator?.start()
118121
isReplicationStarted = true
119122
} catch (e: Exception){
@@ -125,7 +128,6 @@ class ReplicatorServiceDb (
125128
try {
126129
replicatorManager?.replicator?.stop()
127130
isReplicationStarted = false
128-
canStartReplication.value = false
129131
} catch (e: Exception){
130132
Log.e(e.message, e.stackTraceToString())
131133
}

src/app/src/main/java/com/couchbase/learningpath/ui/MainActivity.kt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.couchbase.learningpath.ui
22

33
import android.os.Bundle
4+
import android.util.Log
45
import androidx.activity.ComponentActivity
56
import androidx.activity.compose.setContent
67
import androidx.compose.material.*
@@ -31,6 +32,7 @@ import com.couchbase.learningpath.ui.profile.UserProfileViewModel
3132
import com.couchbase.learningpath.ui.theme.LearningPathTheme
3233
import kotlinx.coroutines.ExperimentalCoroutinesApi
3334

35+
@kotlinx.serialization.ExperimentalSerializationApi
3436
@ExperimentalMaterialApi
3537
@ExperimentalCoroutinesApi
3638
class MainActivity : ComponentActivity() {
@@ -151,10 +153,18 @@ fun MainView(startDatabase: () -> Unit,
151153
DisposableEffect(lifecycleOwner) {
152154
// Create an observer that triggers our remembered callbacks
153155
val observer = LifecycleEventObserver { _, event ->
154-
if (event == Lifecycle.Event.ON_START) {
155-
currentOnStart()
156-
} else if (event == Lifecycle.Event.ON_PAUSE) {
157-
currentOnStop()
156+
when (event) {
157+
Lifecycle.Event.ON_RESUME -> {
158+
Log.w("event","DEBUG: DANGER, WILL ROBINSON!! opening the database due to event: ${event.name}")
159+
currentOnStart()
160+
}
161+
Lifecycle.Event.ON_PAUSE, Lifecycle.Event.ON_STOP -> {
162+
Log.w("event","DEBUG: DANGER, WILL ROBINSON!! closing the database due to event: ${event.name}")
163+
currentOnStop()
164+
}
165+
else -> {
166+
Log.w("event","DEBUG: DANGER, WILL ROBINSON!! Event happened that we don't handle ${event.name}")
167+
}
158168
}
159169
}
160170
// Add the observer to the lifecycle

src/app/src/main/java/com/couchbase/learningpath/ui/audit/AuditCard.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ fun AuditCard(
8080
onDismissRequest = { expanded = false })
8181
{
8282
DropdownMenuItem(onClick = {
83-
val auditJson = audit.toJson()
8483
onEditChange(audit.projectId, audit.auditId)
8584
}) {
8685
Text("Edit")

src/app/src/main/java/com/couchbase/learningpath/ui/audit/AuditEditorViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class AuditEditorViewModel(
2828

2929
var navigateUpCallback: () -> Unit = { }
3030
var navigateToListSelection: (String, String) -> Unit =
31-
{ projectId: String, auditId: String -> }
31+
{ _: String, _: String -> }
3232

3333
fun loadAudit() {
3434
viewModelScope.launch {

src/app/src/main/java/com/couchbase/learningpath/ui/audit/StockItemCard.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import com.couchbase.learningpath.models.StockItem
1515
import com.couchbase.learningpath.ui.components.InventoryAppBar
1616
import com.couchbase.learningpath.ui.theme.LearningPathTheme
1717

18+
@kotlinx.serialization.ExperimentalSerializationApi
1819
@ExperimentalMaterialApi
1920
@Composable
2021
fun StockItemCard(
@@ -66,6 +67,7 @@ fun StockItemCard(
6667
}
6768

6869
@ExperimentalMaterialApi
70+
@kotlinx.serialization.ExperimentalSerializationApi
6971
@Preview(showBackground = true)
7072
@Composable
7173
fun StockItemCardPreview() {

src/app/src/main/java/com/couchbase/learningpath/ui/audit/StockItemSelectionView.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import com.couchbase.learningpath.ui.project.WarehouseSelector
2020
import com.couchbase.learningpath.ui.theme.LearningPathTheme
2121
import com.couchbase.learningpath.ui.theme.Red500
2222

23+
@kotlinx.serialization.ExperimentalSerializationApi
2324
@ExperimentalMaterialApi
2425
@Composable
2526
fun StockItemSelectionView(
@@ -61,7 +62,7 @@ fun StockItemSelectionView(
6162
}
6263
}
6364
}
64-
65+
@kotlinx.serialization.ExperimentalSerializationApi
6566
@ExperimentalMaterialApi
6667
@Composable
6768
fun StockItemSelector(
@@ -139,6 +140,7 @@ fun StockItemSelector(
139140
}
140141
}
141142

143+
@kotlinx.serialization.ExperimentalSerializationApi
142144
@ExperimentalMaterialApi
143145
@Preview(showBackground = true)
144146
@Composable

src/app/src/main/java/com/couchbase/learningpath/ui/audit/StockItemSelectionViewModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import kotlinx.coroutines.Dispatchers
1111
import kotlinx.coroutines.launch
1212
import kotlinx.coroutines.withContext
1313

14+
@kotlinx.serialization.ExperimentalSerializationApi
1415
class StockItemSelectionViewModel(
1516
private val auditRepository: AuditRepository,
1617
private val stockItemRepository: StockItemRepository

src/app/src/main/java/com/couchbase/learningpath/ui/developer/DevDatabaseInfoView.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import androidx.compose.ui.unit.dp
1515
import com.couchbase.learningpath.ui.components.InventoryAppBar
1616
import com.couchbase.learningpath.ui.theme.LearningPathTheme
1717

18+
@kotlinx.serialization.ExperimentalSerializationApi
1819
@Composable
1920
fun DevDatabaseInfoView(
2021
navigateUp: () -> Unit,
@@ -52,6 +53,7 @@ fun DevDatabaseInfoView(
5253
}
5354
}
5455

56+
@kotlinx.serialization.ExperimentalSerializationApi
5557
@Composable
5658
fun DeveloperInfoWidget(
5759
inventoryDatabaseName: String,
@@ -297,6 +299,7 @@ fun DeveloperInfoWidget(
297299
}
298300
}
299301

302+
@kotlinx.serialization.ExperimentalSerializationApi
300303
@Preview(showBackground = true)
301304
@Composable
302305
fun DeveloperInfoWidgetPreview() {

src/app/src/main/java/com/couchbase/learningpath/ui/developer/DevDatabaseInfoViewModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import com.couchbase.learningpath.data.warehouse.WarehouseRepository
1717
import com.couchbase.learningpath.services.AuthenticationService
1818
import kotlinx.coroutines.ExperimentalCoroutinesApi
1919

20+
@kotlinx.serialization.ExperimentalSerializationApi
2021
class DevDatabaseInfoViewModel(
2122
private val userProfileRepository: KeyValueRepository,
2223
private val warehouseRepository: WarehouseRepository,

src/app/src/main/java/com/couchbase/learningpath/ui/developer/DeveloperView.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import com.couchbase.learningpath.ui.theme.LearningPathTheme
2121
import com.couchbase.learningpath.ui.theme.Red500
2222

2323
//this screen shows stats about information in the database and location of the database
24+
@kotlinx.serialization.ExperimentalSerializationApi
2425
@Composable
2526
fun DeveloperView(
2627
scaffoldState: ScaffoldState = rememberScaffoldState(),
@@ -54,6 +55,7 @@ fun DeveloperView(
5455
}
5556
}
5657

58+
@kotlinx.serialization.ExperimentalSerializationApi
5759
@Composable
5860
fun DeveloperWidget(
5961
toastMessage: String?,
@@ -122,6 +124,7 @@ fun DeveloperWidget(
122124
}
123125
}
124126

127+
@kotlinx.serialization.ExperimentalSerializationApi
125128
@Preview(showBackground = true)
126129
@Composable
127130
fun DeveloperWidgetPreview() {

src/app/src/main/java/com/couchbase/learningpath/ui/developer/DeveloperViewModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import kotlinx.coroutines.launch
1111
import com.couchbase.learningpath.data.project.ProjectRepository
1212
import kotlinx.coroutines.ExperimentalCoroutinesApi
1313

14+
@kotlinx.serialization.ExperimentalSerializationApi
1415
class DeveloperViewModel(
1516
private val projectRepository: ProjectRepository,
1617
) : ViewModel() {

src/app/src/main/java/com/couchbase/learningpath/ui/login/LoginView.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.couchbase.learningpath.ui.login
22

33
import androidx.compose.foundation.Image
4+
import androidx.compose.foundation.clickable
45
import androidx.compose.foundation.layout.*
56
import androidx.compose.foundation.text.KeyboardActions
67
import androidx.compose.foundation.text.KeyboardOptions
@@ -96,7 +97,12 @@ fun LoginWindow(
9697
Image(
9798
rememberDrawablePainter(drawable = ContextCompat.getDrawable(context, R.drawable.logo)),
9899
contentDescription = "Logo",
99-
modifier = Modifier.padding(bottom = 32.dp)
100+
modifier = Modifier
101+
.padding(bottom = 32.dp)
102+
.clickable {
103+
onUsernameChanged("demo@example.com")
104+
onPasswordChanged("P@ssw0rd12")
105+
}
100106
)
101107
OutlinedTextField(
102108
modifier = Modifier.semantics { contentDescription = usernameResource },

src/app/src/main/java/com/couchbase/learningpath/ui/profile/UserProfileViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class UserProfileViewModel(
6565
userProfile["imageData"]?.let {
6666
val blob = userProfile["imageData"] as Blob
6767
val d = Drawable.createFromStream(blob.contentStream, "res")
68-
profilePic.value = d.toBitmap()
68+
profilePic.value = d?.toBitmap()
6969
}
7070
}
7171
}

src/app/src/main/java/com/couchbase/learningpath/ui/project/WarehouseSelectionView.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import com.couchbase.learningpath.ui.components.InventoryAppBar
1717
import com.couchbase.learningpath.ui.theme.LearningPathTheme
1818
import com.couchbase.learningpath.ui.theme.Red500
1919

20+
@kotlinx.serialization.ExperimentalSerializationApi
2021
@ExperimentalMaterialApi
2122
@Composable
2223
fun WarehouseSelectionView(
@@ -60,6 +61,7 @@ fun WarehouseSelectionView(
6061
}
6162
}
6263

64+
@kotlinx.serialization.ExperimentalSerializationApi
6365
@ExperimentalMaterialApi
6466
@Composable
6567
fun WarehouseSelector(
@@ -138,6 +140,7 @@ fun WarehouseSelector(
138140
}
139141
}
140142

143+
@kotlinx.serialization.ExperimentalSerializationApi
141144
@ExperimentalMaterialApi
142145
@Preview(showBackground = true)
143146
@Composable

src/app/src/main/java/com/couchbase/learningpath/ui/project/WarehouseSelectionViewModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import com.couchbase.learningpath.data.warehouse.WarehouseRepository
1515
import com.couchbase.learningpath.models.Warehouse
1616
import kotlinx.coroutines.ExperimentalCoroutinesApi
1717

18+
@kotlinx.serialization.ExperimentalSerializationApi
1819
class WarehouseSelectionViewModel(
1920
private val projectRepository: ProjectRepository,
2021
private val warehouseRepository: WarehouseRepository

0 commit comments

Comments
 (0)