Skip to content

Commit

Permalink
Pull request #19: Okoroleva MM-4727
Browse files Browse the repository at this point in the history
Merge in MML/infobip-mobile-messaging-huawei from okoroleva-MM-4727 to master

Squashed commit of the following:

commit 49710756a76c7904124288c6ec8557631b592c42
Author: Olga Koroleva <[email protected]>
Date:   Mon Aug 30 10:38:07 2021 +0300

    android sdk version updated

commit 7e3ebf39b4b27bbc102af0a42a022bf327119bda
Merge: 0cd9eab 6f1648cf
Author: Olga Koroleva <[email protected]>
Date:   Mon Aug 30 10:30:47 2021 +0300

    Merge commit '6f1648cf5bb166d8997dfba6dfd5f528e73a6150' into okoroleva-MM-4727

    # Conflicts:
    #	README.md
    #	build.gradle
    #	gradle.properties
    #	infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/attachments/InAppChatAttachmentHelper.java
    #	infobip-mobile-messaging-android-demo/src/chat/res/values/strings.xml
    #	infobip-mobile-messaging-android-sdk/src/main/java/org/infobip/mobile/messaging/cloud/firebase/FirebaseRegistrationTokenHandler.java
    #	infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/serialization/JsonSerializer.java
    #	infobip-mobile-messaging-huawei-sdk/src/main/java/org/infobip/mobile/messaging/MobileMessagingProperty.java
    #	infobip-mobile-messaging-huawei-sdk/src/main/java/org/infobip/mobile/messaging/cloud/RegistrationTokenHandler.java

commit 6f1648cf5bb166d8997dfba6dfd5f528e73a6150
Author: infobip-ci <[email protected]>
Date:   Thu Aug 26 11:57:25 2021 +0000

    [Gradle Release Plugin] - new version commit:  '5.4.0-SNAPSHOT'.

commit 80439b79a9eb3a906e18b543effa34d7a42fc73c
Author: infobip-ci <[email protected]>
Date:   Thu Aug 26 11:57:23 2021 +0000

    [Gradle Release Plugin] - pre tag commit:  '5.3.0'.

commit 7ab164f8ace21dd766e0281589f04c18cdd02647
Author: Tereza Jurić <[email protected]>
Date:   Thu Aug 26 11:17:30 2021 +0000

    Pull request #243: MM-4686 Added unread chat push messages counter

    Merge in MML/infobip-mobile-messaging-android from tjuric-MM-4686-Unread-chat-push-counter to master

    Squashed commit of the following:

    commit 343a1dbe7437b86384cb3b92200e9553d5cd46c6
    Author: tjuric <Sankt12Rundek##3>
    Date:   Thu Aug 26 12:25:08 2021 +0200

        typo fix

    commit baaa89d1895d58109ae1c9ea58509eea924eb1a2
    Author: tjuric <Sankt12Rundek##3>
    Date:   Thu Aug 26 12:20:13 2021 +0200

        MM-4686 Added unread chat push messages counter

commit 71035aa539902a8652ae9471658d0430e0237cad
Author: infobip-ci <[email protected]>
Date:   Wed Aug 25 13:01:20 2021 +0000

    [Gradle Release Plugin] - new version commit:  '5.3.0-SNAPSHOT'.

commit a1eeb53ec530b83d43e99414449a0a5374d0932f
Author: infobip-ci <[email protected]>
Date:   Wed Aug 25 13:01:18 2021 +0000

    [Gradle Release Plugin] - pre tag commit:  '5.2.7'.

commit a61172b6bd0c22c7048dcc9357ee7fa35055131e
Author: Olga Koroleva <[email protected]>
Date:   Wed Aug 25 09:53:48 2021 +0000

    Pull request #242: Refactoring to not use Legacy storage

    Merge in MML/infobip-mobile-messaging-android from okoroleva-MM-4693 to master

    Squashed commit of the following:

    commit 7d44f50511dd292181973fca7162095e2f12761a
    Author: Olga Koroleva <[email protected]>
    Date:   Fri Aug 20 10:10:31 2021 +0300

        removed commented lines

    commit 030aac3bceba1b17ee9bebfc65907c0bc79ac4d9
    Author: Olga Koroleva <[email protected]>
    Date:   Thu Aug 19 18:04:47 2021 +0300

        1 - MediaStore for API 29 instead of legacy getExternalStoragePublicDirectory
        2 - FileDescriptor for decoding bitmap
        3 - Input stream for API >=24 for getting Exif, because getting it from Uri returns null always, without using legacy storage

commit 7242f93b5460b4df3dd0c4af656cf5a0e21545d9
Author: infobip-ci <[email protected]>
Date:   Thu Aug 12 12:25:27 2021 +0000

    [Gradle Release Plugin] - new version commit:  '5.3.0-SNAPSHOT'.

commit df35f8f308c5edaf84e98f3502a32340da59ac81
Author: infobip-ci <[email protected]>
Date:   Thu Aug 12 12:25:24 2021 +0000

    [Gradle Release Plugin] - pre tag commit:  '5.2.5'.

commit 96e9d2cffcfd1306e523e0bf923308c75c232f5e
Author: Tereza Jurić <[email protected]>
Date:   Thu Aug 12 11:58:05 2021 +0000

    Pull request #241: MM-4632 Fixed possible issue with wrong token after depersonalization

    Merge in MML/infobip-mobile-messaging-android from tjuric-MM-4632-Depersonalization to master

    Squashed commit of the following:

    commit 70813e30a80c3ba18c0129a414c853f0a210a476
    Author: tjuric <Sankt12Rundek##3>
    Date:   Thu Aug 12 13:47:35 2021 +0200

        Minor PR fix

    commit f2727ad80e3782d397b9f2a0d8bddc3b3a001893
    Author: tjuric <Sankt12Rundek##3>
    Date:   Thu Aug 12 13:36:50 2021 +0200

        Fixed test

    commit f80e9f594329ac82faf2c4d752be245cbedcb3eb
    Author: tjuric <Sankt12Rundek##3>
    Date:   Thu Aug 12 13:18:40 2021 +0200

        MM-4632 Fixed possible issue with wrong token on (de)personalization. MM-4662 Fixed issue with app code old cryptor implementation migration. MM-4694 App code hash persisted and checked if it's changed. Fixed too often calling of base URL endpoint.

commit 580c4b264a1e8877230f1fe805af206722da0bf4
Author: infobip-ci <[email protected]>
Date:   Thu Aug 5 08:23:49 2021 +0000

    [Gradle Release Plugin] - new version commit:  '5.3.0-SNAPSHOT'.

commit 232ab472f892e550e28583974cbdc37a4a85d381
Author: infobip-ci <[email protected]>
Date:   Thu Aug 5 08:23:46 2021 +0000

    [Gradle Release Plugin] - pre tag commit:  '5.2.4'.

commit 4c50fd6edc5a09d56344fb24ac3f74074d66a0d6
Author: Olga Koroleva <[email protected]>
Date:   Thu Aug 5 07:49:21 2021 +0000

    Pull request #240: Okoroleva LCZ-193 ImageCompression

    Merge in MML/infobip-mobile-messaging-android from okoroleva-LCZ-193_ImageCompression to master

    Squashed commit of the following:

    commit b7ef9df14268a633b8bfcb071e65dfdfe4f0bd38
    Author: Olga Koroleva <[email protected]>
    Date:   Wed Aug 4 17:50:45 2021 +0300

        removed unused method

    commit f9cf55df5e89518a7936385e1bf63e67e86941b2
    Author: Olga Koroleva <[email protected]>
    Date:   Wed Aug 4 17:43:22 2021 +0300

        gradle

    commit 033bbefe546ec8e15eabeddbe696a8eb0ea85828
    Author: Olga Koroleva <[email protected]>
    Date:   Wed Aug 4 17:41:09 2021 +0300

        Fix of attachment compression

    commit dd3e66653342e721f6de2db7ca7d82c01db4b6ae
    Author: Olga Koroleva <[email protected]>
    Date:   Wed Aug 4 10:37:33 2021 +0300

        inprogress

commit aaa3ba3edfd5c6a91669415b4961fde24ad779c4
Author: Olga Koroleva <[email protected]>
Date:   Wed Jun 30 17:26:19 2021 +0300

    readme enchancement

commit d79cac451b7d93bf5c58468ebbe9bcbd84a5dcea
Author: infobip-ci <[email protected]>
Date:   Fri May 14 09:42:25 2021 +0000

    [Gradle Release Plugin] - new version commit:  '5.3.0-SNAPSHOT'.

commit e53c53f41d24e3cf45ec78a093319e76334fba5a
Author: infobip-ci <[email protected]>
Date:   Fri May 14 09:42:21 2021 +0000

    [Gradle Release Plugin] - pre tag commit:  '5.2.3'.

commit bb8bc4ad62e1e8c383204f232f89304d651d1dc2
Author: Tereza Jurić <[email protected]>
Date:   Fri May 14 09:04:41 2021 +0000

    Pull request #239: MM-4314 - Fix of possible DLR delay in case of 2 different DLRs trying to be reported or messages synced in the same second.

    Merge in MML/infobip-mobile-messaging-android from tjuric-MM-4314-Possibly_delayed_DLR_fix to master

    Squashed commit of the following:

    commit df458d25b76c7f201135ae1fef12de33775a3a52
    Author: tjuric <[email protected]>
    Date:   Thu May 13 18:11:41 2021 +0200

        MM-4314 - Fixed test behaviour

    commit 9e4e223000a7bb717d5282195e62e10d43c279fd
    Author: tjuric <[email protected]>
    Date:   Thu May 13 16:25:44 2021 +0200

        MM-4314 - Fix of possible DLR delay in case of 2 different DLRs trying to be reported or messages synced in the same second.

commit c339f51aca82671a8f0b30e67903e747d4ddd557
Author: Tereza Jurić <[email protected]>
Date:   Wed May 12 06:51:54 2021 +0000

    Pull request #238: MM-4534 Code cleanup

    Merge in MML/infobip-mobile-messaging-android from tjuric-MM-4534-Minor_fixes to master

    Squashed commit of the following:

    commit da91494ef70e5bf916d681f9aa75641e58997ef9
    Author: tjuric <[email protected]>
    Date:   Tue May 11 19:04:25 2021 +0200

        MM-4534 Minor code cleanup after code analysis: optimized imports, null checks verified, repersonalize verification of arguments existence, removed unused resources.

commit 86bcb67cb3a8144f52582d8d57d2e16a8b0cdc85
Author: infobip-ci <[email protected]>
Date:   Tue May 4 18:17:58 2021 +0000

    [Gradle Release Plugin] - new version commit:  '5.3.0-SNAPSHOT'.

... and 7 more commits
  • Loading branch information
riskpp committed Aug 30, 2021
1 parent 0cd9eab commit 1c4cc70
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 11 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ext {
mm_buildToolsVersion = "28.0.3"
mm_supportLibrariesVersion = "28.0.0"
mm_apiVersion = "3.0.4"
mm_androidSdkVersion = "5.2.3"
mm_androidSdkVersion = "5.3.0"
}

allprojects {
Expand Down Expand Up @@ -94,4 +94,4 @@ release {
requireBranch = ''
pushToRemote = 'origin'
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,14 @@ public synchronized static InAppChat getInstance(Context context) {
*/
public abstract void hideInAppChatFragment(FragmentManager fragmentManager);

/**
* Resets current unread chat push message counter to zero. MM SDK automatically resets the counter when InAppChatFragment/Activity appears on screen.
*/
public abstract void resetMessageCounter();

/**
* Returns current unread chat push message counter.
*/
public abstract int getMessageCounter();

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import org.infobip.mobile.messaging.chat.properties.MobileMessagingChatProperty;
import org.infobip.mobile.messaging.chat.properties.PropertyHelper;
import org.infobip.mobile.messaging.chat.view.InAppChatActivity;
import org.infobip.mobile.messaging.chat.view.InAppChatWebView;
import org.infobip.mobile.messaging.chat.view.InAppChatFragment;
import org.infobip.mobile.messaging.chat.view.InAppChatWebView;
import org.infobip.mobile.messaging.dal.bundle.MessageBundleMapper;
import org.infobip.mobile.messaging.logging.MobileMessagingLogger;
import org.infobip.mobile.messaging.mobileapi.MobileApiResourceProvider;
Expand Down Expand Up @@ -78,6 +78,9 @@ public boolean handleMessage(Message message) {
if (!message.isChatMessage()) {
return false;
}
int unreadChatMessageCount = propertyHelper().findInt(MobileMessagingChatProperty.UNREAD_CHAT_MESSAGES_COUNT) + 1;
propertyHelper().saveInt(MobileMessagingChatProperty.UNREAD_CHAT_MESSAGES_COUNT, unreadChatMessageCount);
inAppChatBroadcaster().unreadMessagesCounterUpdated(unreadChatMessageCount);
coreBroadcaster().messageReceived(message);
if (!isChatWidgetOnForeground()) {
MobileMessagingCore.getInstance(context).getNotificationHandler().displayNotification(message);
Expand All @@ -99,7 +102,7 @@ private boolean isChatWidgetOnForeground() {

if (activity instanceof AppCompatActivity) {
//InAppChatFragment is visible and resumed
Fragment inAppChatFragment = ((AppCompatActivity)activity).getSupportFragmentManager().findFragmentByTag(IN_APP_CHAT_FRAGMENT_TAG);
Fragment inAppChatFragment = ((AppCompatActivity) activity).getSupportFragmentManager().findFragmentByTag(IN_APP_CHAT_FRAGMENT_TAG);
return inAppChatFragment != null && inAppChatFragment.isVisible() && inAppChatFragment.isResumed();
}
return false;
Expand Down Expand Up @@ -202,11 +205,12 @@ public void cleanup() {
mobileApiResourceProvider = null;
inAppChatSynchronizer = null;
cleanupWidgetData();
PropertyHelper.remove(context, MobileMessagingChatProperty.IN_APP_CHAT_WIDGET_ID.getKey());
PropertyHelper.remove(context, MobileMessagingChatProperty.IN_APP_CHAT_WIDGET_TITLE.getKey());
PropertyHelper.remove(context, MobileMessagingChatProperty.IN_APP_CHAT_WIDGET_PRIMARY_COLOR.getKey());
PropertyHelper.remove(context, MobileMessagingChatProperty.IN_APP_CHAT_WIDGET_BACKGROUND_COLOR.getKey());
PropertyHelper.remove(context, MobileMessagingChatProperty.IN_APP_CHAT_WIDGET_MAX_UPLOAD_CONTENT_SIZE.getKey());
propertyHelper().remove(MobileMessagingChatProperty.IN_APP_CHAT_WIDGET_ID);
propertyHelper().remove(MobileMessagingChatProperty.IN_APP_CHAT_WIDGET_TITLE);
propertyHelper().remove(MobileMessagingChatProperty.IN_APP_CHAT_WIDGET_PRIMARY_COLOR);
propertyHelper().remove(MobileMessagingChatProperty.IN_APP_CHAT_WIDGET_BACKGROUND_COLOR);
propertyHelper().remove(MobileMessagingChatProperty.IN_APP_CHAT_WIDGET_MAX_UPLOAD_CONTENT_SIZE);
resetMessageCounter();
}

// must be done on separate thread if it's not invoked by UI thread
Expand All @@ -231,6 +235,7 @@ public void run() {
@Override
public void depersonalize() {
cleanupWidgetData();
resetMessageCounter();
}

@Override
Expand Down Expand Up @@ -300,5 +305,16 @@ public void hideInAppChatFragment(FragmentManager fragmentManager) {
fragmentTransaction.commit();
}

@Override
public void resetMessageCounter() {
MobileMessagingLogger.d("Resetting unread message counter to 0");
propertyHelper().remove(MobileMessagingChatProperty.UNREAD_CHAT_MESSAGES_COUNT);
inAppChatBroadcaster().unreadMessagesCounterUpdated(0);
}

@Override
public int getMessageCounter() {
return propertyHelper().findInt(MobileMessagingChatProperty.UNREAD_CHAT_MESSAGES_COUNT);
}
// endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@ public interface InAppChatBroadcaster {
*/
void chatConfigurationSynced();

/**
* Called whenever a new chat push message arrives, contains current unread message counter value
* @param unreadMessagesCount new unread message count
*/
void unreadMessagesCounterUpdated(int unreadMessagesCount);

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.support.annotation.NonNull;
import android.support.v4.content.LocalBroadcastManager;

import org.infobip.mobile.messaging.BroadcastParameter;
import org.infobip.mobile.messaging.logging.MobileMessagingLogger;

public class InAppChatBroadcasterImpl implements InAppChatBroadcaster {
Expand All @@ -19,6 +20,12 @@ public void chatConfigurationSynced() {
send(prepare(InAppChatEvent.CHAT_CONFIGURATION_SYNCED));
}

@Override
public void unreadMessagesCounterUpdated(int unreadMessagesCount) {
send(prepare(InAppChatEvent.UNREAD_MESSAGES_COUNTER_UPDATED)
.putExtra(BroadcastParameter.EXTRA_UNREAD_CHAT_MESSAGES_COUNT, unreadMessagesCount));
}

private void send(Intent intent) {
try {
context.sendBroadcast(intent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ public enum InAppChatEvent {
/**
* It is triggered when In-app chat widget configuration is synced.
*/
CHAT_CONFIGURATION_SYNCED("org.infobip.mobile.messaging.chat.CHAT_CONFIGURATION_SYNCED");
CHAT_CONFIGURATION_SYNCED("org.infobip.mobile.messaging.chat.CHAT_CONFIGURATION_SYNCED"),
UNREAD_MESSAGES_COUNTER_UPDATED("org.infobip.mobile.messaging.chat.UNREAD_MESSAGES_COUNTER_UPDATED");

private final String key;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public enum MobileMessagingChatProperty {
IN_APP_CHAT_WIDGET_BACKGROUND_COLOR("org.infobip.mobile.messaging.infobip.IN_APP_CHAT_WIDGET_BACKGROUND_COLOR", null),
IN_APP_CHAT_WIDGET_MAX_UPLOAD_CONTENT_SIZE("org.infobip.mobile.messaging.infobip.IN_APP_CHAT_WIDGET_MAX_UPLOAD_CONTENT_SIZE", null),
IN_APP_CHAT_PERMISSION_FIRST_TIME_ASK("org.infobip.mobile.messaging.infobip.IN_APP_CHAT_PERMISSION_FIRST_TIME_ASK", null),
IN_APP_CHAT_ACTIVATED("org.infobip.mobile.messaging.infobip.IN_APP_CHAT_ACTIVATED", false);
IN_APP_CHAT_ACTIVATED("org.infobip.mobile.messaging.infobip.IN_APP_CHAT_ACTIVATED", false),
UNREAD_CHAT_MESSAGES_COUNT("org.infobip.mobile.messaging.infobip.UNREAD_CHAT_MESSAGES_COUNT", 0);

private final String key;
private final Object defaultValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ public void saveBoolean(MobileMessagingChatProperty property, boolean value) {
saveBoolean(context, property.getKey(), value);
}

public int findInt(MobileMessagingChatProperty property) {
return findInt(context, property.getKey(), (int) property.getDefaultValue());
}

public void saveInt(MobileMessagingChatProperty property, int value) {
saveInt(context, property.getKey(), value);
}

public Class[] findClasses(MobileMessagingChatProperty property) {
String[] classNames = findStringArray(context, property.getKey(), new String[0]);
if (classNames == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ public void setControlsEnabled(boolean isEnabled) {
sendMessageButton.setEnabled(isEnabled);
sendAttachmentButton.setEnabled(isEnabled);
isWebViewLoaded = isEnabled;
if (isEnabled) InAppChatImpl.getInstance(getContext()).resetMessageCounter();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public final class BroadcastParameter {
public static final String EXTRA_NOTIFICATION_ID = "org.infobip.mobile.messaging.notification.id";
public static final String EXTRA_INSTALLATION = "org.infobip.mobile.messaging.installation";

public static final String EXTRA_UNREAD_CHAT_MESSAGES_COUNT = "org.infobip.mobile.messaging.unread.chat.messages.count";

public static final int NOTIFICATION_NOT_DISPLAYED_ID = -1;

private BroadcastParameter() {
Expand Down

0 comments on commit 1c4cc70

Please sign in to comment.