Skip to content

Commit 2d66a86

Browse files
committed
MoEngage functionality
1 parent 9a491e9 commit 2d66a86

File tree

33 files changed

+941
-1
lines changed

33 files changed

+941
-1
lines changed

app/build.gradle.kts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ val configProps = Properties().apply {
8282
val ncTestServerUsername = configProps["NC_TEST_SERVER_USERNAME"]
8383
val ncTestServerPassword = configProps["NC_TEST_SERVER_PASSWORD"]
8484
val ncTestServerBaseUrl = configProps["NC_TEST_SERVER_BASEURL"]
85+
val moengageAppId = project.properties["MOENGAGE_APP_ID"]
8586

8687
android {
8788
// install this NDK version and Cmake to produce smaller APKs. Build will still work if not installed
@@ -104,6 +105,8 @@ android {
104105
targetSdk = 36
105106
compileSdk = 36
106107

108+
// NMC Customization
109+
buildConfigField("String", "MOENGAGE_APP_ID", moengageAppId.toString())
107110
buildConfigField("boolean", "CI", ciBuild.toString())
108111
buildConfigField("boolean", "RUNTIME_PERF_ANALYSIS", perfAnalysis.toString())
109112

@@ -480,6 +483,15 @@ dependencies {
480483
testImplementation(libs.bundles.unit.test)
481484
// endregion
482485

486+
// NMC region
487+
// core moengage features
488+
implementation(moengage.core)
489+
// optionally add this to use the Push Templates feature
490+
implementation(moengage.richNotification)
491+
// optionally add this to use the InApp feature
492+
implementation(moengage.inapp)
493+
// endregion
494+
483495
// region Mocking support
484496
androidTestImplementation(libs.bundles.mocking)
485497
// endregion
@@ -515,4 +527,7 @@ dependencies {
515527

516528
// kotlinx.serialization
517529
implementation(libs.kotlinx.serialization.json)
530+
531+
// NMC: dependency required to capture Advertising ID for Adjust & MoEngage SDK
532+
implementation(libs.play.services.ads.identifier)
518533
}

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
@@ -75,6 +76,9 @@ class ShortcutUtil @Inject constructor(private val mContext: Context) {
7576
)
7677

7778
ShortcutManagerCompat.requestPinShortcut(mContext, shortcutInfo, pendingIntent.intentSender)
79+
80+
// NMC: track pin to home screen event
81+
MoEngageSdkUtils.trackPinHomeScreenEvent(mContext, file)
7882
}
7983

8084
private fun createShortcutIcon(
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)