Skip to content

Commit 9059ff6

Browse files
committed
Dependency segregation
1 parent 1acb878 commit 9059ff6

File tree

5 files changed

+46
-21
lines changed

5 files changed

+46
-21
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
@@ -108,8 +109,6 @@ android {
108109
targetSdkVersion 34
109110
compileSdk 34
110111

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

@@ -426,19 +425,11 @@ dependencies {
426425

427426
implementation "io.coil-kt:coil:2.7.0"
428427

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

444435
configurations.configureEach {

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
<intent-filter>
149149
<action android:name="android.intent.action.SEARCH" />
150150
</intent-filter>
151-
<intent-filter>
151+
<intent-filter android:autoVerify="true">
152152
<action android:name="android.intent.action.VIEW" />
153153

154154
<category android:name="android.intent.category.DEFAULT" />

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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import com.nextcloud.client.network.ClientFactory
2828
import com.nextcloud.client.network.ClientFactory.CreationException
2929
import com.nextcloud.utils.extensions.getParcelableArgument
3030
import com.owncloud.android.MainApp
31+
import com.nmc.android.marketTracking.MoEngageSdkUtils
3132
import com.owncloud.android.R
3233
import com.owncloud.android.databinding.ChooseTemplateBinding
3334
import com.owncloud.android.datamodel.FileDataStorageManager
@@ -384,6 +385,11 @@ class ChooseRichDocumentsTemplateDialogFragment :
384385
putExtra(ExternalSiteWebView.EXTRA_TEMPLATE, template)
385386
}
386387

388+
// NMC: track create office file event
389+
file?.let {
390+
MoEngageSdkUtils.trackCreateFileEvent(MainApp.getAppContext(), it, template.type)
391+
}
392+
387393
fragment.run {
388394
startActivity(intent)
389395
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)