Skip to content

Commit c38639c

Browse files
committed
Release v2.0.1
1 parent 362d669 commit c38639c

13 files changed

+679
-392
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## 2.0.1
6+
7+
### Changed
8+
- Improved the backward compatibility between v1.x.x and v2.x.x
9+
510
## 2.0.0
611

712
### Changed

sample/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ dependencies {
4848
implementation(versions["androidx.appcompat"]!!)
4949
implementation(versions["com.google.android.material"]!!)
5050
implementation(versions["androidx.constraintlayout"]!!)
51-
// implementation(versions["ai.devrev.sdk"]!!)
51+
implementation(versions["ai.devrev.sdk"]!!)
5252
implementation("androidx.navigation:navigation-fragment-ktx:2.3.5")
5353
implementation("androidx.navigation:navigation-ui-ktx:2.3.5")
5454
implementation("androidx.activity:activity-ktx:1.2.3")
@@ -63,7 +63,7 @@ dependencies {
6363
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.5.1")
6464
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
6565
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4")
66-
implementation(project(":core"))
66+
// implementation(project(":core"))
6767
implementation("androidx.compose.ui:ui:1.3.0")
6868
implementation("androidx.compose.ui:ui-tooling-preview:1.3.0")
6969
debugImplementation("androidx.compose.ui:ui-tooling:1.3.0")

sample/dependencies.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
val sdk_version = "1.1.4"
1+
val sdk_version = "1.1.5"
22

33
extra["versions"] = mapOf(
44
"androidx.core" to "androidx.core:core-ktx:1.9.0",

sample/src/main/java/ai/devrev/sdk/sample/DevRevApplication.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class DevRevApplication : Application() {
1616
FirebaseApp.initializeApp(this)
1717
DevRev.configure(
1818
context = this,
19-
appId = "DvRvStPZG9uOmNvcmU6ZHZydi1pbi0xOmRldm8vMjY5SVFhZEZ6ejpwbHVnX3NldHRpbmcvMV9ffHxfXzIwMjUtMDQtMjUgMTI6Mzc6MTkuNDc4MjEzNTc0ICswMDAwIFVUQw==xlxendsDvRv",
19+
appId = "APP_ID_HERE",
2020
)
2121

2222
DevRev.setShouldDismissModalsOnOpenLink(false)

sample/src/main/java/ai/devrev/sdk/sample/IdentificationFragment.kt

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package ai.devrev.sdk.sample
22

3+
import ai.devrev.sdk.model.Identity
4+
import ai.devrev.sdk.model.UserInfo
35
import ai.devrev.sdk.sample.viewmodel.IdentificationViewModel
46
import ai.devrev.sdk.sample.viewmodel.SharedViewModel
57
import android.os.Bundle
@@ -28,14 +30,17 @@ class IdentificationFragment : Fragment() {
2830
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
2931
super.onViewCreated(view, savedInstanceState)
3032

31-
val isUserIdentifiedCheckbox: CheckBox = view.findViewById(R.id.is_user_identified)
3233
val identifyUnverifiedUserButton: Button = view.findViewById(R.id.unverified_user_button)
3334
val identifyVerifiedUserButton: Button = view.findViewById(R.id.verified_user_button)
35+
val isUserIdentifiedCheckbox: CheckBox = view.findViewById(R.id.is_user_identified)
3436
val logOutButton: Button = view.findViewById(R.id.logout_button)
37+
val sessionTokenText: EditText = view.findViewById(R.id.session_token_text)
3538
val unverifiedUserIdText: EditText = view.findViewById(R.id.user_id_text)
39+
val updateUserButton: Button = view.findViewById(R.id.update_user_button)
40+
val updateUserEmail: EditText = view.findViewById(R.id.update_user_email)
3641
val verifiedUserIdText: EditText = view.findViewById(R.id.verified_user_id_text)
37-
val sessionTokenText: EditText = view.findViewById(R.id.session_token_text)
3842

43+
var userId : String = ""
3944

4045
sharedViewModel.isUserIdentified.observe(viewLifecycleOwner) { isUserIdentified ->
4146
isUserIdentifiedCheckbox.isChecked = isUserIdentified
@@ -44,7 +49,8 @@ class IdentificationFragment : Fragment() {
4449
identifyUnverifiedUserButton.setOnClickListener {
4550
if(unverifiedUserIdText.text.isNotBlank()) {
4651
try {
47-
viewModel.identifyUnverifiedUser(userId = unverifiedUserIdText.text.toString())
52+
userId = unverifiedUserIdText.text.toString()
53+
viewModel.identifyUnverifiedUser(userId = userId)
4854
alertDialogBox(getString(R.string.successful), getString(R.string.identification_successful))
4955
} catch (e: Exception) {
5056
alertDialogBox(getString(R.string.unsuccessful), getString(R.string.identification_unsuccessful))
@@ -55,7 +61,8 @@ class IdentificationFragment : Fragment() {
5561
identifyVerifiedUserButton.setOnClickListener {
5662
try {
5763
if (verifiedUserIdText.text.isNotBlank() and sessionTokenText.text.isNotBlank()) {
58-
viewModel.identifyVerifiedUser(verifiedUserIdText.text.toString(), sessionTokenText.text.toString())
64+
userId = verifiedUserIdText.text.toString()
65+
viewModel.identifyVerifiedUser(userId, sessionTokenText.text.toString())
5966
alertDialogBox(getString(R.string.successful), getString(R.string.identification_successful))
6067
}
6168
}catch (e: Exception) {
@@ -66,6 +73,21 @@ class IdentificationFragment : Fragment() {
6673
logOutButton.setOnClickListener {
6774
viewModel.logout(requireContext())
6875
}
76+
77+
updateUserButton.setOnClickListener {
78+
try {
79+
var userEmail: String? = null
80+
if (updateUserEmail.text.isNotBlank()) {
81+
userEmail = updateUserEmail.text.toString()
82+
}
83+
if (userId.isNotEmpty()) {
84+
viewModel.updateUser(Identity(userId = userId, userInfo = UserInfo(userEmail)))
85+
}
86+
alertDialogBox(getString(R.string.successful), getString(R.string.update_user_successful))
87+
} catch (e: Exception) {
88+
alertDialogBox(getString(R.string.unsuccessful), getString(R.string.update_user_unsuccessful))
89+
}
90+
}
6991
}
7092

7193
private fun alertDialogBox(title: String, message: String) {

sample/src/main/java/ai/devrev/sdk/sample/MainActivity.kt

Lines changed: 88 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import android.content.Intent
99
import android.os.Bundle
1010
import androidx.activity.compose.setContent
1111
import androidx.appcompat.app.AppCompatActivity
12+
import androidx.compose.animation.core.Animatable
13+
import androidx.compose.animation.core.spring
1214
import androidx.compose.foundation.background
1315
import androidx.compose.foundation.border
1416
import androidx.compose.foundation.clickable
@@ -34,7 +36,9 @@ import androidx.compose.runtime.*
3436
import androidx.compose.runtime.livedata.observeAsState
3537
import androidx.compose.ui.Alignment
3638
import androidx.compose.ui.Modifier
39+
import androidx.compose.ui.draw.scale
3740
import androidx.compose.ui.graphics.Color
41+
import androidx.compose.ui.graphics.graphicsLayer
3842
import androidx.compose.ui.platform.LocalContext
3943
import androidx.compose.ui.res.stringResource
4044
import androidx.compose.ui.text.font.FontWeight
@@ -51,6 +55,7 @@ import androidx.navigation.compose.NavHost
5155
import androidx.navigation.compose.composable
5256
import androidx.navigation.compose.currentBackStackEntryAsState
5357
import androidx.navigation.compose.rememberNavController
58+
import kotlinx.coroutines.launch
5459

5560
class MainActivity : AppCompatActivity() {
5661
private lateinit var notificationHandler: NotificationHandler
@@ -91,7 +96,7 @@ fun SampleApp(viewModel: SharedViewModel = viewModel()) {
9196
launchSingleTop = true
9297
}
9398
}
94-
MaterialTheme{
99+
MaterialTheme {
95100
Box(
96101
modifier = Modifier
97102
.fillMaxSize()
@@ -115,15 +120,19 @@ fun SampleApp(viewModel: SharedViewModel = viewModel()) {
115120
navigationIcon = {
116121
if (currentDestination?.route != AppRoute.HOME.route) {
117122
IconButton(onClick = { navController.navigateUp() }) {
118-
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back")
123+
Icon(
124+
Icons.AutoMirrored.Filled.ArrowBack,
125+
contentDescription = "Back"
126+
)
119127
}
120128
} else {
121129
Box(modifier = Modifier.size(48.dp))
122130
}
123131
},
124132
actions = {
125133
IconButton(onClick = {
126-
val currentRoute = navController.currentBackStackEntry?.destination?.route
134+
val currentRoute =
135+
navController.currentBackStackEntry?.destination?.route
127136
if (currentRoute != null) {
128137
when (currentRoute) {
129138
AppRoute.HOME.route -> {
@@ -132,6 +141,7 @@ fun SampleApp(viewModel: SharedViewModel = viewModel()) {
132141
launchSingleTop = true
133142
}
134143
}
144+
135145
else -> {
136146
val fragment = when (currentRoute) {
137147
AppRoute.IDENTIFICATION.route -> IdentificationFragment()
@@ -141,8 +151,13 @@ fun SampleApp(viewModel: SharedViewModel = viewModel()) {
141151
else -> null
142152
}
143153
if (fragment != null) {
144-
val fragmentManager = (context as FragmentActivity).supportFragmentManager
145-
reloadFragment(fragmentManager, fragment, R.id.fragment_container_view)
154+
val fragmentManager =
155+
(context as FragmentActivity).supportFragmentManager
156+
reloadFragment(
157+
fragmentManager,
158+
fragment,
159+
R.id.fragment_container_view
160+
)
146161
}
147162
}
148163
}
@@ -164,11 +179,15 @@ fun SampleApp(viewModel: SharedViewModel = viewModel()) {
164179
}
165180

166181
@Composable
167-
fun NavHostContainer(paddingValues: PaddingValues, navController: NavHostController, viewModel: SharedViewModel) {
182+
fun NavHostContainer(
183+
paddingValues: PaddingValues,
184+
navController: NavHostController,
185+
viewModel: SharedViewModel
186+
) {
168187
NavHost(navController, startDestination = AppRoute.HOME.route) {
169188
composable(AppRoute.HOME.route) {
170189
viewModel.resetTitle()
171-
HomeComposable(Modifier.padding(paddingValues), navController)
190+
HomeComposable(Modifier.padding(paddingValues), navController, viewModel)
172191
}
173192
composable(AppRoute.IDENTIFICATION.route) {
174193
viewModel.changeTitle(stringResource(R.string.identification))
@@ -190,18 +209,32 @@ fun NavHostContainer(paddingValues: PaddingValues, navController: NavHostControl
190209
}
191210

192211
@Composable
193-
fun HomeComposable(modifier: Modifier = Modifier, navController: NavHostController) {
212+
fun HomeComposable(
213+
modifier: Modifier = Modifier,
214+
navController: NavHostController,
215+
viewModel: SharedViewModel
216+
) {
194217
val isConfigured by remember { mutableStateOf(DevRev.isConfigured) }
195218
val isUserIdentified by remember { mutableStateOf(DevRev.isUserIdentified) }
196219
val isMonitoringEnabled by remember { mutableStateOf(DevRev.isMonitoringEnabled) }
220+
val scale = remember { Animatable(1f) }
221+
val coroutineScope = rememberCoroutineScope()
197222

198223
val buttonItems = listOf(
199224
ButtonItem(stringResource(R.string.identification)) { navController.navigate(AppRoute.IDENTIFICATION.route) },
200-
ButtonItem(stringResource(R.string.support_chat)) { navController.navigate(AppRoute.SUPPORT_CHAT.route) },
225+
ButtonItem(stringResource(R.string.support_chat)) {
226+
viewModel.setInScreenTransitioning(true)
227+
navController.navigate(AppRoute.SUPPORT_CHAT.route)
228+
},
201229
ButtonItem(stringResource(R.string.push_notifications)) { navController.navigate(AppRoute.PUSH_NOTIFICATIONS.route) },
202230
ButtonItem(stringResource(R.string.session_analytics)) { navController.navigate(AppRoute.SESSION_ANALYTICS.route) }
203231
)
204232

233+
val debugButtons = listOf(
234+
ButtonItem(stringResource(R.string.anr)) { viewModel.ANR() },
235+
ButtonItem(stringResource(R.string.crash)) { viewModel.crash() }
236+
)
237+
205238
Column(
206239
modifier = modifier
207240
.fillMaxSize()
@@ -216,39 +249,31 @@ fun HomeComposable(modifier: Modifier = Modifier, navController: NavHostControll
216249
LazyColumn {
217250
items(stateItems) { (label, state) ->
218251
Row(
219-
modifier = Modifier.padding(vertical = 8.dp, horizontal = 8.dp)
252+
modifier = Modifier
253+
.padding(vertical = 8.dp, horizontal = 8.dp)
220254
.fillMaxWidth(),
221255
verticalAlignment = Alignment.CenterVertically,
222256
horizontalArrangement = Arrangement.SpaceBetween
223257
) {
224258
Text(label)
225259
CircularCheckbox(
226260
checked = state,
227-
onCheckedChange = { }
261+
onCheckedChange = { }
228262
)
229263
}
230264
}
231265
item {
232266
textRow(stringResource(R.string.feature))
233-
}
234-
items(buttonItems) { item ->
235-
Button(
236-
onClick = item.onClick,
237-
modifier = Modifier
238-
.fillMaxWidth()
239-
.padding(vertical = 4.dp),
240-
colors = ButtonDefaults.buttonColors(
241-
containerColor = Color.LightGray,
242-
contentColor = Color.Black
243-
)
244-
) {
245-
Box(
246-
modifier = Modifier.fillMaxWidth(),
247-
contentAlignment = Alignment.CenterStart
248-
) {
249-
Text(item.label)
267+
ButtonsRow(buttonItems)
268+
textRow(stringResource(R.string.debug))
269+
ButtonsRow(debugButtons)
270+
textRow(stringResource(R.string.animation))
271+
Button(ButtonItem(stringResource(R.string.play_animation)) {coroutineScope.launch {
272+
repeat(4) {
273+
scale.animateTo(1.2f, animationSpec = spring(dampingRatio = 0.4f))
274+
scale.animateTo(1f, animationSpec = spring(dampingRatio = 0.4f))
250275
}
251-
}
276+
} }, Modifier.scale(scale.value))
252277
}
253278
}
254279
}
@@ -304,6 +329,40 @@ fun CircularCheckbox(
304329
}
305330
}
306331

332+
@Composable
333+
fun ButtonsRow(
334+
buttonList: List<ButtonItem>,
335+
modifier: Modifier = Modifier
336+
) {
337+
Column(modifier = modifier) {
338+
buttonList.forEach { item ->
339+
Button(item)
340+
}
341+
}
342+
}
343+
344+
@Composable
345+
fun Button(item: ButtonItem, additionalModifier: Modifier = Modifier) {
346+
Button(
347+
onClick = item.onClick,
348+
modifier = Modifier
349+
.fillMaxWidth()
350+
.padding(vertical = 4.dp)
351+
.then(additionalModifier),
352+
colors = ButtonDefaults.buttonColors(
353+
containerColor = Color.LightGray,
354+
contentColor = Color.Black
355+
)
356+
) {
357+
Box(
358+
modifier = Modifier.fillMaxWidth(),
359+
contentAlignment = Alignment.CenterStart
360+
) {
361+
Text(item.label)
362+
}
363+
}
364+
}
365+
307366
private fun reloadFragment(fragmentManager: FragmentManager, fragment: Fragment, containerId: Int) {
308367
fragmentManager.beginTransaction()
309368
.replace(containerId, fragment)

0 commit comments

Comments
 (0)