Skip to content

Commit cc49aac

Browse files
committed
MoEngage functionality
1 parent 104d1e6 commit cc49aac

File tree

33 files changed

+955
-3
lines changed

33 files changed

+955
-3
lines changed

app/build.gradle.kts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ plugins {
4040
apply(from = "${rootProject.projectDir}/jacoco.gradle.kts")
4141

4242
println("Gradle uses Java ${Jvm.current()}")
43-
43+
// apply MoEngage SDK for NMC
44+
apply(from = "${rootProject.projectDir}/nmc_moengage-dependencies.gradle")
4445
configurations.configureEach {
4546
// via prism4j, already using annotations explicitly
4647
exclude(group = "org.jetbrains", module = "annotations-java5")
@@ -82,6 +83,8 @@ val configProps = Properties().apply {
8283
val ncTestServerUsername = configProps["NC_TEST_SERVER_USERNAME"]
8384
val ncTestServerPassword = configProps["NC_TEST_SERVER_PASSWORD"]
8485
val ncTestServerBaseUrl = configProps["NC_TEST_SERVER_BASEURL"]
86+
// NMC Customization
87+
val moengageAppId = configProps["MOENGAGE_APP_ID"]
8588

8689
android {
8790
// install this NDK version and Cmake to produce smaller APKs. Build will still work if not installed
@@ -98,6 +101,8 @@ android {
98101
targetSdk = 36
99102
compileSdk = 36
100103

104+
// NMC Customization
105+
buildConfigField("String", "MOENGAGE_APP_ID", moengageAppId.toString())
101106
buildConfigField("boolean", "CI", ciBuild.toString())
102107
buildConfigField("boolean", "RUNTIME_PERF_ANALYSIS", perfAnalysis.toString())
103108

@@ -515,4 +520,7 @@ dependencies {
515520

516521
// kotlinx.serialization
517522
implementation(libs.kotlinx.serialization.json)
523+
524+
// NMC: dependency required to capture Advertising ID for Adjust & MoEngage SDK
525+
implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
518526
}

app/src/generic/java/com/nextcloud/android/appReview/InAppReviewHelperImpl.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@ class InAppReviewHelperImpl(appPreferences: AppPreferences) : InAppReviewHelper
1717

1818
override fun showInAppReview(activity: AppCompatActivity) {
1919
}
20+
21+
override fun performNativeReview(activity: AppCompatActivity){
22+
23+
}
2024
}

app/src/gplay/AndroidManifest.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@
6565
</intent-filter>
6666
</service>
6767

68+
<!-- NMC: MoEngage Activity to handle the Rich Landing page -->
69+
<activity
70+
android:name="com.moe.pushlibrary.activities.MoEActivity"
71+
android:exported="false"
72+
android:parentActivityName=".ui.activity.FileDisplayActivity" />
73+
6874
</application>
6975

7076
</manifest>

app/src/gplay/java/com/nextcloud/android/appReview/InAppReviewHelperImpl.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ class InAppReviewHelperImpl(val appPreferences: AppPreferences) : InAppReviewHel
7070
}
7171
}
7272

73+
override fun performNativeReview(activity: AppCompatActivity) {
74+
doAppReview(activity)
75+
}
76+
7377
private fun doAppReview(activity: AppCompatActivity) {
7478
val manager = ReviewManagerFactory.create(activity)
7579
val request: Task<ReviewInfo> = manager.requestReviewFlow()

app/src/gplay/java/com/owncloud/android/services/firebase/NCFirebaseMessagingService.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import com.google.firebase.messaging.Constants.MessageNotificationKeys;
1414
import com.google.firebase.messaging.FirebaseMessagingService;
1515
import com.google.firebase.messaging.RemoteMessage;
16+
import com.moengage.firebase.MoEFireBaseHelper;
17+
import com.moengage.pushbase.MoEPushHelper;
1618
import com.nextcloud.client.account.UserAccountManager;
1719
import com.nextcloud.client.jobs.BackgroundJobManager;
1820
import com.nextcloud.client.jobs.NotificationWork;
@@ -82,6 +84,12 @@ public void handleIntent(Intent intent) {
8284
@Override
8385
public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
8486
Log_OC.d(TAG, "onMessageReceived");
87+
// NMC: check and pass the Notification payload to MoEngage to handle it
88+
if (MoEPushHelper.getInstance().isFromMoEngagePlatform(remoteMessage.getData())) {
89+
MoEFireBaseHelper.getInstance().passPushPayload(getApplicationContext(), remoteMessage.getData());
90+
return;
91+
}
92+
8593
final Map<String, String> data = remoteMessage.getData();
8694
final String subject = data.get(NotificationWork.KEY_NOTIFICATION_SUBJECT);
8795
final String signature = data.get(NotificationWork.KEY_NOTIFICATION_SIGNATURE);

app/src/huawei/java/com/nextcloud/android/appReview/InAppReviewHelperImpl.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@ class InAppReviewHelperImpl(appPreferences: AppPreferences) : InAppReviewHelper
1717

1818
override fun showInAppReview(activity: AppCompatActivity) {
1919
}
20+
21+
override fun performNativeReview(activity: AppCompatActivity){
22+
23+
}
2024
}

app/src/main/java/com/nextcloud/appReview/InAppReviewHelper.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,12 @@ interface InAppReviewHelper {
3030
* once all the conditions satisfies it will trigger In-App Review manager to show the flow
3131
*/
3232
fun showInAppReview(activity: AppCompatActivity)
33+
34+
/**
35+
* NMC customization
36+
* method to perform direct native review without the logic of app launch count
37+
* this will be triggered when MoEngage push comes to show native rating
38+
* === DO NOT CALL THIS FUNCTION DIRECTLY FOR ANY OTHER USE CASE ===
39+
*/
40+
fun performNativeReview(activity: AppCompatActivity)
3341
}

app/src/main/java/com/nextcloud/client/jobs/AccountRemovalWork.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import com.nextcloud.client.core.Clock
2323
import com.nextcloud.client.preferences.AppPreferences
2424
import com.nextcloud.common.NextcloudClient
2525
import com.owncloud.android.MainApp
26+
import com.nmc.android.marketTracking.MoEngageSdkUtils
2627
import com.owncloud.android.R
2728
import com.owncloud.android.datamodel.ArbitraryDataProvider
2829
import com.owncloud.android.datamodel.ArbitraryDataProviderImpl
@@ -142,6 +143,8 @@ class AccountRemovalWork(
142143

143144
if (userRemoved) {
144145
eventBus.post(AccountRemovedEvent())
146+
// NMC: track user logout
147+
MoEngageSdkUtils.trackUserLogout(context)
145148
}
146149

147150
return Result.success()

app/src/main/java/com/nextcloud/utils/ShortcutUtil.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import androidx.core.graphics.drawable.IconCompat
2222
import androidx.core.graphics.drawable.toBitmap
2323
import androidx.core.graphics.drawable.toDrawable
2424
import com.nextcloud.client.account.User
25+
import com.nmc.android.marketTracking.MoEngageSdkUtils
2526
import com.owncloud.android.R
2627
import com.owncloud.android.datamodel.OCFile
2728
import com.owncloud.android.datamodel.SyncedFolderProvider
@@ -102,6 +103,9 @@ class ShortcutUtil @Inject constructor(private val mContext: Context) {
102103
mContext,
103104
MimeTypeUtil.getFileTypeIconId(file.mimeType, file.fileName)
104105
)
106+
107+
// NMC: track pin to home screen event
108+
MoEngageSdkUtils.trackPinHomeScreenEvent(mContext, file)
105109
}
106110
}
107111

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
package com.nmc.android.marketTracking
9+
10+
enum class EventFileType(val fileType: String) {
11+
PHOTO("foto"),
12+
SCAN("scan"),
13+
VIDEO("video"),
14+
AUDIO("audio"),
15+
TEXT("text"),
16+
PDF("pdf"),
17+
DOCUMENT("docx"),
18+
SPREADSHEET("xlsx"),
19+
PRESENTATION("pptx"),
20+
OTHER("other"), // default
21+
}
22+
23+
enum class EventFolderType(val folderType: String) {
24+
ENCRYPTED("encrypted"),
25+
NOT_ENCRYPTED("not encrypted")
26+
}

0 commit comments

Comments
 (0)