From b7f8118e244940fa90d607f4b32f18cdf80a1252 Mon Sep 17 00:00:00 2001 From: Shubham Goyal Date: Mon, 16 Oct 2023 14:20:51 -0500 Subject: [PATCH 1/5] Adds model class in test --- .../org/commcare/android/tests/processing/FormStorageTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/app/unit-tests/src/org/commcare/android/tests/processing/FormStorageTest.java b/app/unit-tests/src/org/commcare/android/tests/processing/FormStorageTest.java index f14bc6c834..62d344c8ff 100644 --- a/app/unit-tests/src/org/commcare/android/tests/processing/FormStorageTest.java +++ b/app/unit-tests/src/org/commcare/android/tests/processing/FormStorageTest.java @@ -353,6 +353,7 @@ public class FormStorageTest { , "org.commcare.suite.model.DetailGroup" , "org.commcare.services.FCMMessageData" , "org.commcare.suite.model.EndpointArgument" + , "org.commcare.suite.model.EndpointAction" ); From 81fccd9318b3068dc18fe454ba0becd940dacb3d Mon Sep 17 00:00:00 2001 From: Dave Viggiano Date: Mon, 30 Oct 2023 12:23:14 -0400 Subject: [PATCH 2/5] Fixed bug when trying to show rate limiting error message. --- .../org/commcare/activities/SyncCapableCommCareActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/org/commcare/activities/SyncCapableCommCareActivity.java b/app/src/org/commcare/activities/SyncCapableCommCareActivity.java index 0202ae5c16..502b4c308f 100644 --- a/app/src/org/commcare/activities/SyncCapableCommCareActivity.java +++ b/app/src/org/commcare/activities/SyncCapableCommCareActivity.java @@ -273,7 +273,7 @@ public void handleFormSendResult(String message, boolean success) { public void showRateLimitError(boolean userTriggered) { if (HiddenPreferences.isRateLimitPopupDisabled() || !userTriggered) { - handleFormUploadResult(FormUploadResult.RATE_LIMITED, null, userTriggered); + handleFormSendResult(Localization.get(FormUploadResult.RATE_LIMITED.getLocaleKeyBase()), false); return; } String title = Localization.get("form.send.rate.limit.error.title"); From 669a224971c0fa9cbece881b162b08f228f63d96 Mon Sep 17 00:00:00 2001 From: Dave Viggiano Date: Mon, 30 Oct 2023 12:27:40 -0400 Subject: [PATCH 3/5] Renamed handleFormSendResult to updateUiForFormUploadResult. --- .../activities/SyncCapableCommCareActivity.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/org/commcare/activities/SyncCapableCommCareActivity.java b/app/src/org/commcare/activities/SyncCapableCommCareActivity.java index 502b4c308f..d527bc5904 100644 --- a/app/src/org/commcare/activities/SyncCapableCommCareActivity.java +++ b/app/src/org/commcare/activities/SyncCapableCommCareActivity.java @@ -232,23 +232,23 @@ public void handleSyncNotAttempted(String message) { public void handleFormUploadResult(FormUploadResult result, String formLabel, boolean userTriggered) { switch (result) { case FULL_SUCCESS: - handleFormSendResult(formLabel, true); + updateUiForFormUploadResult(formLabel, true); break; case BAD_CERTIFICATE: CommCareApplication.notificationManager().reportNotificationMessage( NotificationMessageFactory.message(NotificationMessageFactory.StockMessages.BadSslCertificate, NotificationActionButtonInfo.ButtonAction.LAUNCH_DATE_SETTINGS)); - handleFormSendResult(Localization.get(result.getLocaleKeyBase()), false); + updateUiForFormUploadResult(Localization.get(result.getLocaleKeyBase()), false); break; case ACTIONABLE_FAILURE: - handleFormSendResult(result.getErrorMessage(), false); + updateUiForFormUploadResult(result.getErrorMessage(), false); break; case RATE_LIMITED: showRateLimitError(userTriggered); break; case CANCELLED: - handleFormSendResult(Localization.get(result.getLocaleKeyBase()) + updateUiForFormUploadResult(Localization.get(result.getLocaleKeyBase()) + " " + formLabel, false); break; case AUTH_FAILURE: @@ -258,12 +258,12 @@ public void handleFormUploadResult(FormUploadResult result, String formLabel, bo case INVALID_CASE_GRAPH: case FAILURE: default: - handleFormSendResult(Localization.get(result.getLocaleKeyBase()), false); + updateUiForFormUploadResult(Localization.get(result.getLocaleKeyBase()), false); break; } } - public void handleFormSendResult(String message, boolean success) { + public void updateUiForFormUploadResult(String message, boolean success) { updateUiAfterDataPullOrSend(message, success); if (success) { // Since we know that we just had connectivity, now is a great time to try this @@ -273,7 +273,7 @@ public void handleFormSendResult(String message, boolean success) { public void showRateLimitError(boolean userTriggered) { if (HiddenPreferences.isRateLimitPopupDisabled() || !userTriggered) { - handleFormSendResult(Localization.get(FormUploadResult.RATE_LIMITED.getLocaleKeyBase()), false); + updateUiForFormUploadResult(Localization.get(FormUploadResult.RATE_LIMITED.getLocaleKeyBase()), false); return; } String title = Localization.get("form.send.rate.limit.error.title"); From 5215db2f436772d7a22610b53d14eae41c1db0a8 Mon Sep 17 00:00:00 2001 From: Dave Viggiano Date: Wed, 1 Nov 2023 13:36:36 -0400 Subject: [PATCH 4/5] Added cccStaging build flavor to support Connect production and staging versions. --- app/build.gradle | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index 4f1623ade6..5e119e9b23 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -275,6 +275,9 @@ android { buildConfigField "String", "HQ_API_USERNAME", "\"${project.ext.HQ_API_USERNAME}\"" buildConfigField "String", "HQ_API_PASSWORD", "\"${project.ext.HQ_API_PASSWORD}\"" buildConfigField "String", "FIREBASE_DATABASE_URL", "\"${project.ext.FIREBASE_DATABASE_URL}\"" + + buildConfigField "String", "CCC_HOST", "\"connect.dimagi.com\"" + testInstrumentationRunner "org.commcare.CommCareJUnitRunner" } @@ -333,6 +336,10 @@ android { manifest.srcFile 'CommcareAndroidManifest.xml' } + cccStaging { + manifest.srcFile 'CommcareAndroidManifest.xml' + } + standalone { res.srcDirs = ['standalone/res'] assets.srcDirs = ['standalone/assets'] @@ -383,6 +390,15 @@ android { resValue "string", "application_name", applicationName } + + cccStaging { + buildConfigField "String", "CCC_HOST", "\"connect-staging.dimagi.com\"" + + // set the app name + def applicationName = "CommCare (CCC Staging)" + resValue "string", "application_name", applicationName + } + standalone { // Builds commcare w/ ccz app packaged in the apk. // Must be invoked from command-line w/ args pointing to app domain & From b375af2de505377723fa73bdc46b6245746a7817 Mon Sep 17 00:00:00 2001 From: Shubham Goyal Date: Mon, 20 Nov 2023 16:20:54 -0500 Subject: [PATCH 5/5] Adds a new notification channel for push notifications with default priority --- app/res/values/strings.xml | 4 +++- app/src/org/commcare/CommCareNoficationManager.java | 6 ++++++ .../commcare/services/CommCareFirebaseMessagingService.java | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/res/values/strings.xml b/app/res/values/strings.xml index a9902b6173..58722a00b6 100644 --- a/app/res/values/strings.xml +++ b/app/res/values/strings.xml @@ -393,6 +393,8 @@ Notification containing information around current user session like when the current session is scheduled to expire Server Communications Notifications for status of any background server communication happening at the moment like CommCare App updates, log submission etc. + Priority notifications from Server + Notifications sent from server directly to notify user of priority tasks Choose Reinstall Method @@ -451,6 +453,6 @@ Install from Store No Play Store found on your device FCM Notification - notification-channel-server-communications + notification-channel-push-notifications Required CommCare App is not installed on device diff --git a/app/src/org/commcare/CommCareNoficationManager.java b/app/src/org/commcare/CommCareNoficationManager.java index 2f6bd62efe..6180f9e0e2 100644 --- a/app/src/org/commcare/CommCareNoficationManager.java +++ b/app/src/org/commcare/CommCareNoficationManager.java @@ -38,6 +38,7 @@ public class CommCareNoficationManager { public static final String NOTIFICATION_CHANNEL_ERRORS_ID = "notification-channel-errors"; public static final String NOTIFICATION_CHANNEL_USER_SESSION_ID = "notification-channel-user-session"; public static final String NOTIFICATION_CHANNEL_SERVER_COMMUNICATIONS_ID = "notification-channel-server-communications"; + public static final String NOTIFICATION_CHANNEL_PUSH_NOTIFICATIONS_ID = "notification-channel-push-notifications"; /** * Handler to receive notifications and show them the user using toast. @@ -188,6 +189,11 @@ public void createNotificationChannels() { R.string.notification_channel_server_communication_title, R.string.notification_channel_server_communication_description, NotificationManager.IMPORTANCE_LOW); + + createNotificationChannel(NOTIFICATION_CHANNEL_PUSH_NOTIFICATIONS_ID, + R.string.notification_channel_push_notfications_title, + R.string.notification_channel_push_notfications_description, + NotificationManager.IMPORTANCE_DEFAULT); } @TargetApi(Build.VERSION_CODES.O) diff --git a/app/src/org/commcare/services/CommCareFirebaseMessagingService.java b/app/src/org/commcare/services/CommCareFirebaseMessagingService.java index 7fc2bc6d9d..f189193956 100644 --- a/app/src/org/commcare/services/CommCareFirebaseMessagingService.java +++ b/app/src/org/commcare/services/CommCareFirebaseMessagingService.java @@ -99,7 +99,7 @@ private void showNotification(RemoteMessage.Notification notification) { contentIntent = PendingIntent.getActivity(this, 0, i, 0); NotificationCompat.Builder fcmNotification = new NotificationCompat.Builder(this, - CommCareNoficationManager.NOTIFICATION_CHANNEL_SERVER_COMMUNICATIONS_ID) + CommCareNoficationManager.NOTIFICATION_CHANNEL_PUSH_NOTIFICATIONS_ID) .setContentTitle(notificationTitle) .setContentText(notificationText) .setContentIntent(contentIntent)