Skip to content

Commit 5f23b8d

Browse files
committed
Dependency segregation
1 parent 4773c2c commit 5f23b8d

File tree

4 files changed

+46
-20
lines changed

4 files changed

+46
-20
lines changed

app/build.gradle

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ apply plugin: 'com.google.devtools.ksp'
5353

5454

5555
println "Gradle uses Java ${Jvm.current()}"
56-
56+
// apply MoEngage SDK for NMC
57+
apply from: "$rootProject.projectDir/nmc_moengage-dependencies.gradle"
5758
configurations {
5859
configureEach {
5960
exclude group: 'org.jetbrains', module: 'annotations-java5' // via prism4j, already using annotations explicitly
@@ -109,8 +110,6 @@ android {
109110
targetSdkVersion 34
110111
compileSdk 34
111112

112-
// NMC Customization
113-
buildConfigField "String", "MOENGAGE_APP_ID", "${MOENGAGE_APP_ID}"
114113
buildConfigField 'boolean', 'CI', ciBuild.toString()
115114
buildConfigField 'boolean', 'RUNTIME_PERF_ANALYSIS', perfAnalysis.toString()
116115

@@ -428,19 +427,11 @@ dependencies {
428427

429428
implementation "io.coil-kt:coil:2.7.0"
430429

431-
// NMC: MoEngage Dependencies
432-
// core moengage features
433-
implementation(moengage.core)
434-
// optionally add this to use the Push Templates feature
435-
implementation(moengage.richNotification)
436-
// optionally add this to use the InApp feature
437-
implementation(moengage.inapp)
438-
// Required for MoEngage to provide accurate analytics based on Advertising Identifier
439-
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
440-
// NMC: end
441-
442430
// splash screen dependency ref: https://developer.android.com/develop/ui/views/launch/splash-screen/migrate
443431
implementation 'androidx.core:core-splashscreen:1.0.1'
432+
433+
// NMC: dependency required to capture Advertising ID for Adjust & MoEngage SDK
434+
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
444435
}
445436

446437
configurations.configureEach {

app/src/main/java/com/nmc/android/marketTracking/MoEngageSdkUtils.kt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import com.owncloud.android.utils.MimeTypeUtil
4040
import com.owncloud.android.utils.PermissionUtil
4141
import kotlin.math.ceil
4242
import kotlin.math.floor
43+
import kotlin.math.round
4344

4445
object MoEngageSdkUtils {
4546

@@ -95,7 +96,9 @@ object MoEngageSdkUtils {
9596
.configureNotificationMetaData(
9697
NotificationConfig(
9798
R.drawable.notification_icon,
98-
R.drawable.notification_icon
99+
R.drawable.notification_icon,
100+
R.color.primary,
101+
false
99102
)
100103
)
101104
.build()
@@ -227,9 +230,10 @@ object MoEngageSdkUtils {
227230

228231
val properties = Properties()
229232
properties.addAttribute(PROPERTIES__FILE_TYPE, getOfficeFileType(type) { getFileType(file) }.fileType)
230-
properties.addAttribute(PROPERTIES__FILE_SIZE, bytesToMB(file.fileLength).toString())
233+
properties.addAttribute(PROPERTIES__FILE_SIZE, bytesToMBInDecimal(file.fileLength).toString())
231234
properties.addAttribute(
232235
PROPERTIES__CREATION_DATE,
236+
// using modification timestamp as this will always have value
233237
file.modificationTimestamp.getFormattedStringDate(DATE_FORMAT)
234238
)
235239

@@ -244,6 +248,7 @@ object MoEngageSdkUtils {
244248
properties.addAttribute(PROPERTIES__FOLDER_TYPE, getFolderType(file).folderType)
245249
properties.addAttribute(
246250
PROPERTIES__CREATION_DATE,
251+
// using modification timestamp because for folder creationTimeStamp is always 0
247252
file.modificationTimestamp.getFormattedStringDate(DATE_FORMAT)
248253
)
249254

@@ -323,21 +328,23 @@ object MoEngageSdkUtils {
323328
private fun getCommonProperties(file: OCFile, isScan: Boolean = false): Properties {
324329
val properties = Properties()
325330
properties.addAttribute(PROPERTIES__FILE_TYPE, getFileType(file, isScan).fileType)
326-
properties.addAttribute(PROPERTIES__FILE_SIZE, bytesToMB(file.fileLength).toString())
331+
properties.addAttribute(PROPERTIES__FILE_SIZE, bytesToMBInDecimal(file.fileLength).toString())
327332
properties.addAttribute(
328333
PROPERTIES__CREATION_DATE,
334+
// using modification timestamp as this will always have value
329335
file.modificationTimestamp.getFormattedStringDate(DATE_FORMAT)
330336
)
331-
properties.addAttribute(PROPERTIES__UPLOAD_DATE, file.modificationTimestamp.getFormattedStringDate(DATE_FORMAT))
337+
properties.addAttribute(PROPERTIES__UPLOAD_DATE, file.uploadTimestamp.getFormattedStringDate(DATE_FORMAT))
332338
return properties
333339
}
334340

335341
private fun bytesToGB(bytes: Long): Int {
336342
return floor((bytes / GIGABYTE).toDouble()).toInt()
337343
}
338344

339-
private fun bytesToMB(bytes: Long): Int {
340-
return floor((bytes / MEGABYTE).toDouble()).toInt()
345+
private fun bytesToMBInDecimal(bytes: Long): Double {
346+
val mb = bytes.toDouble() / MEGABYTE
347+
return round((mb * 10)) / 10 // Round down to 1 decimal place
341348
}
342349

343350
private fun getFileType(file: OCFile, isScan: Boolean = false): EventFileType {

app/src/main/java/com/owncloud/android/ui/dialog/ChooseRichDocumentsTemplateDialogFragment.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import com.nextcloud.client.network.ClientFactory.CreationException
2929
import com.nextcloud.utils.extensions.getParcelableArgument
3030
import com.nextcloud.utils.fileNameValidator.FileNameValidator
3131
import com.owncloud.android.MainApp
32+
import com.nmc.android.marketTracking.MoEngageSdkUtils
3233
import com.owncloud.android.R
3334
import com.owncloud.android.databinding.ChooseTemplateBinding
3435
import com.owncloud.android.datamodel.FileDataStorageManager
@@ -401,6 +402,12 @@ class ChooseRichDocumentsTemplateDialogFragment :
401402
putExtra(ExternalSiteWebView.EXTRA_TEMPLATE, template)
402403
}
403404

405+
// NMC: track create office file event & open event
406+
file?.let {
407+
MoEngageSdkUtils.trackCreateFileEvent(MainApp.getAppContext(), it, template.type)
408+
MoEngageSdkUtils.trackOnlineOfficeUsedEvent(MainApp.getAppContext(), it)
409+
}
410+
404411
fragment.run {
405412
startActivity(intent)
406413
dismiss()

nmc_moengage-dependencies.gradle

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Nextcloud - Android Client
3+
*
4+
* SPDX-FileCopyrightText: 2024 Your Name <your@email.com>
5+
* SPDX-License-Identifier: AGPL-3.0-or-later
6+
*/
7+
8+
android {
9+
buildTypes.each {
10+
it.buildConfigField "String", "MOENGAGE_APP_ID", "${MOENGAGE_APP_ID}"
11+
}
12+
}
13+
14+
dependencies {
15+
// core moengage features
16+
implementation(moengage.core)
17+
// optionally add this to use the Push Templates feature
18+
implementation(moengage.richNotification)
19+
// optionally add this to use the InApp feature
20+
implementation(moengage.inapp)
21+
}

0 commit comments

Comments
 (0)