Skip to content

Commit

Permalink
Merge branch 'master' into encrypt-credentials-in-memory
Browse files Browse the repository at this point in the history
  • Loading branch information
avazirna committed Dec 6, 2023
2 parents ce84ea1 + b0b712b commit 8609871
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
4 changes: 3 additions & 1 deletion app/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@
<string name="notification_channel_user_session_description" cc:translatable="true">Notification containing information around current user session like when the current session is scheduled to expire</string>
<string name="notification_channel_server_communication_title" cc:translatable="true">Server Communications</string>
<string name="notification_channel_server_communication_description" cc:translatable="true">Notifications for status of any background server communication happening at the moment like CommCare App updates, log submission etc.</string>
<string name="notification_channel_push_notfications_title" cc:translatable="true">Priority notifications from Server</string>
<string name="notification_channel_push_notfications_description" cc:translatable="true">Notifications sent from server directly to notify user of priority tasks</string>

<!--Recovery Measures-->
<string name="recovery_measure_reinstall_method" cc:translatable="true">Choose Reinstall Method</string>
Expand Down Expand Up @@ -451,6 +453,6 @@
<string name="dependency_missing_dialog_go_to_store" cc:translatable="true">Install from Store</string>
<string name="dependency_missing_dialog_playstore_not_found" cc:translatable="true">No Play Store found on your device</string>
<string name="fcm_notification">FCM Notification</string>
<string name="fcm_default_notification_channel">notification-channel-server-communications</string>
<string name="fcm_default_notification_channel">notification-channel-push-notifications</string>
<string name="app_with_id_not_found">Required CommCare App is not installed on device</string>
</resources>
6 changes: 6 additions & 0 deletions app/src/org/commcare/CommCareNoficationManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions app/src/org/commcare/activities/SyncCapableCommCareActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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);
updateUiForFormUploadResult(Localization.get(FormUploadResult.RATE_LIMITED.getLocaleKeyBase()), false);
return;
}
String title = Localization.get("form.send.rate.limit.error.title");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
);


Expand Down

0 comments on commit 8609871

Please sign in to comment.