() {{
- put("chatCustomData", new CustomAttributeValue(
- MJSONObject.create().add("key", "value").toString()));
- }});
- }};
-
- ChatParticipant participant = objectMapper.fromUserData(givenUser);
- assertEquals("userId", participant.getId());
- assertEquals("firstName", participant.getFirstName());
- assertEquals("lastName", participant.getLastName());
- assertEquals("middleName", participant.getMiddleName());
-// assertEquals("email@email.com", participant.getEmail());
-// assertEquals("msisdn", participant.getGsm());
- JSONAssert.assertEquals(MJSONObject.create().add("key", "value"), participant.getCustomData(), false);
- }
-
- @Test
- public void should_map_participant_to_user_data() throws Exception {
- ChatParticipant givenParticipant = new ChatParticipant(
- "participantId",
- "firstName",
- "lastName",
- "middleName",
- null,
- null,
- MJSONObject.create().add("key", "value"));
-
- User user = objectMapper.toUserData(givenParticipant);
-
- assertEquals("participantId", user.getExternalUserId());
- assertEquals("firstName", user.getFirstName());
- assertEquals("lastName", user.getLastName());
- assertEquals("middleName", user.getMiddleName());
-// assertEquals("participant@email.com", user.getEmail());
-// assertEquals("gsm", user.getMsisdn());
- assertEquals("{\"key\":\"value\"}", user.getCustomAttributes().get("chatCustomData").stringValue());
- }
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/androidTest/java/org/infobip/mobile/messaging/chat/core/UserProfileManagerTest.java b/infobip-mobile-messaging-android-chat-sdk/src/androidTest/java/org/infobip/mobile/messaging/chat/core/UserProfileManagerTest.java
deleted file mode 100644
index ca2e8a4e..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/androidTest/java/org/infobip/mobile/messaging/chat/core/UserProfileManagerTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package org.infobip.mobile.messaging.chat.core;
-
-import android.content.SharedPreferences;
-import android.support.test.runner.AndroidJUnit4;
-
-import org.infobip.mobile.messaging.Message;
-import org.infobip.mobile.messaging.chat.ChatParticipant;
-import org.infobip.mobile.messaging.chat.TestBase;
-import org.infobip.mobile.messaging.chat.repository.Participant;
-import org.infobip.mobile.messaging.chat.repository.ParticipantRepository;
-import org.infobip.mobile.messaging.chat.repository.RepositoryMapper;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertTrue;
-import static org.mockito.BDDMockito.then;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-/**
- * @author sslavin
- * @since 10/10/2017.
- */
-@RunWith(AndroidJUnit4.class)
-public class UserProfileManagerTest extends TestBase {
-
- private UserProfileManager userProfileManager;
- private ParticipantRepository participantRepository;
- private RepositoryMapper repositoryMapper;
- private SharedPreferences sharedPreferences;
- private SharedPreferences.Editor editor;
- private String pushRegistrationId;
-
- @Before
- public void before() {
- participantRepository = mock(ParticipantRepository.class);
- repositoryMapper = mock(RepositoryMapper.class);
- sharedPreferences = mock(SharedPreferences.class);
- editor = mock(SharedPreferences.Editor.class);
- pushRegistrationId = "d1aca8ed-c9d3-426f-a9e7-b10a1a43c864";
-
- when(sharedPreferences.edit()).thenReturn(editor);
- when(editor.putString(anyString(), anyString())).thenReturn(editor);
-
- userProfileManager = new UserProfileManager(participantRepository, repositoryMapper, sharedPreferences, pushRegistrationId);
- }
-
- @Test
- public void should_save_participant_to_db_and_id_to_preferences() {
- ChatParticipant givenChatParticipant = givenChatParticipant();
- Participant givenParticipant = givenParticipant(givenChatParticipant);
- when(repositoryMapper.dbParticipantFromChatParticipant(any(ChatParticipant.class))).thenReturn(givenParticipant);
-
- userProfileManager.save(givenChatParticipant);
-
- verify(participantRepository, times(1)).upsert(givenParticipant);
- then(editor.putString(eq("org.infobip.mobile.messaging.chat.PARTICIPANT_ID_TAG"), eq(givenChatParticipant.getId()))).should(times(1));
- }
-
- @Test
- public void should_determine_if_message_is_from_local_user() throws Exception {
- Message givenMessage = givenPushMessageFromUser("localId");
- when(sharedPreferences.getString(eq("org.infobip.mobile.messaging.chat.PARTICIPANT_ID_TAG"), anyString())).thenReturn("localId");
-
- assertTrue(userProfileManager.isUsersMessage(givenMessage));
- }
-
- @Test
- public void should_fallback_to_push_reg_id_as_user_id_if_no_user_info_provided() {
- when(sharedPreferences.getString(eq("org.infobip.mobile.messaging.chat.PARTICIPANT_ID_TAG"), anyString())).thenReturn(null);
-
- assertEquals(pushRegistrationId, userProfileManager.get().getId());
- }
-
- // region internal methods
-
- private Participant givenParticipant(final ChatParticipant chatParticipant) {
- return new Participant(){{
- id = chatParticipant.getId();
- }};
- }
-
- private Message givenPushMessageFromUser(String userId) throws JSONException {
- Message message = new Message();
- message.setCustomPayload(new JSONObject().putOpt("sender", userId));
- return message;
- }
-
- // endregion
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/AndroidManifest.xml b/infobip-mobile-messaging-android-chat-sdk/src/main/AndroidManifest.xml
deleted file mode 100644
index 3eab4b6b..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/ChatEvent.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/ChatEvent.java
deleted file mode 100644
index a515606a..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/ChatEvent.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.infobip.mobile.messaging.chat;
-
-/**
- * Contains all chat-related events produced by the library.
- *
- * @author sslavin
- * @since 06/10/2017.
- */
-
-public enum ChatEvent {
-
- /**
- * Triggered when chat message is received from the server.
- *
- * {@code
- * ChatMessage message = ChatMessage.createFrom(intent);
- * }
- *
- */
- CHAT_MESSAGE_RECEIVED("org.infobip.mobile.messaging.chat.CHAT_MESSAGE_RECEIVED"),
-
- /**
- * Triggered when chat message is successfully sent to the server.
- *
- * {@code
- * ChatMessage message = ChatMessage.createFrom(intent);
- * }
- *
- */
- CHAT_MESSAGE_SENT("org.infobip.mobile.messaging.chat.CHAT_MESSAGE_SENT"),
-
- /**
- * Triggered when chat message is tapped.
- *
- * {@code
- * ChatMessage message = ChatMessage.createFrom(intent);
- * }
- *
- */
- CHAT_MESSAGE_TAPPED("org.infobip.mobile.messaging.chat.CHAT_MESSAGE_TAPPED"),
-
- /**
- * Triggered when action tapped inside chat view.
- *
- * {@code
- * ChatMessage message = ChatMessage.createFrom(intent);
- * String actionId = intent.getStringExtra(MobileChat.EXTRA_ACTION_ID);
- * }
- *
- */
- CHAT_MESSAGE_VIEW_ACTION_TAPPED("org.infobip.mobile.messaging.chat.CHAT_MESSAGE_VIEW_ACTION_TAPPED"),
-
- /**
- * Triggered when information of current user is saved on server.
- *
- * {@code
- * ChatParticipant info = ChatParticipant.createFrom(intent);
- * }
- *
- */
- CHAT_USER_INFO_SYNCHRONIZED("org.infobip.mobile.messaging.chat.CHAT_USER_INFO_SYNCHRONIZED");
-
- private final String key;
-
- ChatEvent(String key) {
- this.key = key;
- }
-
- public String getKey() {
- return key;
- }
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/ChatMessage.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/ChatMessage.java
deleted file mode 100644
index bdbc5af6..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/ChatMessage.java
+++ /dev/null
@@ -1,231 +0,0 @@
-package org.infobip.mobile.messaging.chat;
-
-import android.content.Intent;
-import android.support.annotation.NonNull;
-
-import org.infobip.mobile.messaging.Message;
-import org.infobip.mobile.messaging.chat.broadcast.ChatBundleMapper;
-import org.infobip.mobile.messaging.platform.Time;
-import org.json.JSONObject;
-
-import java.util.UUID;
-
-/**
- * One simple message from chat
- *
- * @author sslavin
- * @since 05/10/2017.
- */
-
-@SuppressWarnings({"unused", "WeakerAccess"})
-public class ChatMessage implements Comparable {
- /**
- * Unique message id
- */
- private String id;
-
- /**
- * Message text
- */
- private String body;
-
- /**
- * ID of a chat which this message belongs to
- */
- private String chatId;
-
- /**
- * Date when this message was created
- */
- private long createdAt;
-
- /**
- * Date when this message was received
- */
- private long receivedAt;
-
- /**
- * Date when this message was seen
- */
- private long readAt;
-
- /**
- * Message category for actionable notifications
- */
- private String category;
-
- /**
- * Url for media content provided with message
- */
- private String contentUrl;
-
- /**
- * Author of this message
- */
- private ChatParticipant author;
-
- /**
- * Current status of message
- */
- private Message.Status status;
-
- /**
- * Any custom data attached to message
- */
- private JSONObject customData;
-
- /**
- * Flag that indicates that message belongs to current user
- */
- private boolean isYours;
-
- /**
- * Creates message based on provided intent
- *
- * @param intent intent with data
- * @return message object
- */
- public static ChatMessage createFrom(@NonNull Intent intent) {
- return mapper.chatMessageFromBundle(intent.getExtras());
- }
-
- @Override
- public int compareTo(@NonNull ChatMessage o) {
- if (createdAt != 0 && o.createdAt != 0) {
- return (int) Math.signum(createdAt - o.createdAt);
- }
- return (int) Math.signum(receivedAt - o.receivedAt);
- }
-
- // region Boilerplate code
-
- private final static ChatBundleMapper mapper = new ChatBundleMapper();
-
- public ChatMessage(String id, String body, String chatId, long createdAt, long receivedAt, long readAt, String category, String contentUrl, ChatParticipant author, Message.Status status, JSONObject customData, boolean isYours) {
- this.id = id;
- this.body = body;
- this.chatId = chatId;
- this.createdAt = createdAt;
- this.receivedAt = receivedAt;
- this.readAt = readAt;
- this.category = category;
- this.contentUrl = contentUrl;
- this.author = author;
- this.status = status;
- this.customData = customData;
- this.isYours = isYours;
- }
-
- public ChatMessage() {
- this(UUID.randomUUID().toString(),
- null,
- null,
- Time.now(),
- 0,
- 0,
- null,
- null,
- null,
- Message.Status.UNKNOWN,
- null,
- false);
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getBody() {
- return body;
- }
-
- public void setBody(String body) {
- this.body = body;
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public void setChatId(String chatId) {
- this.chatId = chatId;
- }
-
- public long getCreatedAt() {
- return createdAt;
- }
-
- public void setCreatedAt(long createdAt) {
- this.createdAt = createdAt;
- }
-
- public long getReceivedAt() {
- return receivedAt;
- }
-
- public void setReceivedAt(long receivedAt) {
- this.receivedAt = receivedAt;
- }
-
- public long getReadAt() {
- return readAt;
- }
-
- public void setReadAt(long readAt) {
- this.readAt = readAt;
- }
-
- public String getCategory() {
- return category;
- }
-
- public void setCategory(String category) {
- this.category = category;
- }
-
- public String getContentUrl() {
- return contentUrl;
- }
-
- public void setContentUrl(String contentUrl) {
- this.contentUrl = contentUrl;
- }
-
- public ChatParticipant getAuthor() {
- return author;
- }
-
- public void setAuthor(ChatParticipant author) {
- this.author = author;
- }
-
- public Message.Status getStatus() {
- return status;
- }
-
- public void setStatus(Message.Status status) {
- this.status = status;
- }
-
- public JSONObject getCustomData() {
- return customData;
- }
-
- public void setCustomData(JSONObject customData) {
- this.customData = customData;
- }
-
- public boolean isYours() {
- return isYours;
- }
-
- public void setYours(boolean isYours) {
- this.isYours = isYours;
- }
-
- // endregion
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/ChatMessageStorage.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/ChatMessageStorage.java
deleted file mode 100644
index 00b54be1..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/ChatMessageStorage.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package org.infobip.mobile.messaging.chat;
-
-import java.util.List;
-
-/**
- * Set of interfaces to access chat messages stored on a device
- *
- * @author sslavin
- * @since 17/10/2017.
- */
-
-public interface ChatMessageStorage {
-
- /**
- * Set of callback methods for chat message storage
- */
- interface Listener {
- /**
- * Called when new message is added to the storage.
- * Invoked after {@link ChatMessageStorage#save(ChatMessage)}} for new message.
- * @param message new message
- */
- void onNew(ChatMessage message);
-
- /**
- * Called when message is updated.
- * Invoked after {@link ChatMessageStorage#save(ChatMessage)}}.
- * @param message message that was updated in storage
- */
- void onUpdated(ChatMessage message);
-
- /**
- * Called when messages are deleted in storage.
- * Invoked after {@link ChatMessageStorage#delete(String)}.
- * Is not invoked after {@link ChatMessageStorage#deleteAll()}}.
- * @param messageId ids of messages that were deleted
- */
- void onDeleted(String messageId);
-
- /**
- * Called when all messages are deleted in message storage.
- * Invoked after {@link ChatMessageStorage#deleteAll()}}.
- */
- void onAllDeleted();
- }
-
- /**
- * Returnes all received chat messages
- * @return list if messages
- */
- List findAllMessages();
-
- /**
- * Returns number of messages stored locally
- * @return number of messages
- */
- long countAllMessages();
-
- /**
- * Returns number of all unread messages stored locally
- * @return number of messages
- */
- long countAllUnreadMessages();
-
- /**
- * Returns message based on id
- * @param id id of message
- * @return chat message
- */
- ChatMessage findMessage(String id);
-
- /**
- * Saves message to storage
- * @param message message ot save
- */
- void save(ChatMessage message);
-
- /**
- * Deletes message by id
- * @param id id of message
- */
- void delete(String id);
-
- /**
- * Deletes all messages
- */
- void deleteAll();
-
- /**
- * Registers listener for message storage updates
- * @param listener listener callback
- */
- void registerListener(Listener listener);
-
- /**
- * Unregisters listener from message storage updates
- * @param listener listener callback
- */
- void unregisterListener(Listener listener);
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/ChatParticipant.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/ChatParticipant.java
deleted file mode 100644
index 4fe654fa..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/ChatParticipant.java
+++ /dev/null
@@ -1,136 +0,0 @@
-package org.infobip.mobile.messaging.chat;
-
-import android.text.TextUtils;
-
-import org.json.JSONObject;
-
-/**
- * A simple participant of a chat
- *
- * @author sslavin
- * @since 05/10/2017.
- */
-
-@SuppressWarnings({"WeakerAccess", "unused"})
-public class ChatParticipant {
- /**
- * Unique ID of a participant
- */
- private String id;
-
- /**
- * First name
- */
- private String firstName;
-
- /**
- * Last name
- */
- private String lastName;
-
- /**
- * Middle name
- */
- private String middleName;
-
- /**
- * Email
- */
- private String email;
-
- /**
- * GSM
- */
- private String gsm;
-
- /**
- * Any custom data that can be attached to a participant
- */
- private JSONObject customData;
-
- // region Boilerplate code
-
- public ChatParticipant(String id, String firstName, String lastName, String middleName, String email, String gsm, JSONObject customData) {
- this.id = id;
- this.firstName = firstName;
- this.lastName = lastName;
- this.middleName = middleName;
- this.email = email;
- this.gsm = gsm;
- this.customData = customData;
- }
-
- public ChatParticipant(String id) {
- this(id, null, null, null, null, null, null);
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getFirstName() {
- return firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
-
- public String getMiddleName() {
- return middleName;
- }
-
- public void setMiddleName(String middleName) {
- this.middleName = middleName;
- }
-
- public String getUserName() {
- String userName;
- if (!TextUtils.isEmpty(firstName) && !TextUtils.isEmpty(lastName)) {
- userName = firstName.trim() + " " + lastName.trim();
- } else {
- userName = !TextUtils.isEmpty(firstName) ? firstName.trim()
- : !TextUtils.isEmpty(lastName) ? lastName.trim() : "";
- }
-
- return userName.trim();
- }
-
- public String getEmail() {
- return email;
- }
-
- public void setEmail(String email) {
- this.email = email;
- }
-
- public String getGsm() {
- return gsm;
- }
-
- public void setGsm(String gsm) {
- this.gsm = gsm;
- }
-
- public JSONObject getCustomData() {
- return customData;
- }
-
- public void setCustomData(JSONObject customData) {
- this.customData = customData;
- }
-
- // endregion
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/MobileChat.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/MobileChat.java
deleted file mode 100644
index 4606e4ab..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/MobileChat.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package org.infobip.mobile.messaging.chat;
-
-import android.content.Context;
-
-import org.infobip.mobile.messaging.MobileMessaging;
-import org.infobip.mobile.messaging.MobileMessagingCore;
-import org.infobip.mobile.messaging.chat.core.MobileChatImpl;
-import org.json.JSONObject;
-
-/**
- * Main interface for chat communication
- *
- * @author sslavin
- * @since 05/10/2017.
- */
-@SuppressWarnings("unused")
-public abstract class MobileChat {
-
- /**
- * @see ChatEvent#CHAT_MESSAGE_VIEW_ACTION_TAPPED
- */
- public static final String EXTRA_ACTION_ID = "org.infobip.mobile.messaging.chat.EXTRA_ACTION_ID";
-
- /**
- * Returns unstance of chat api
- * @param context android context
- * @return instance of chat api
- */
- public static MobileChat getInstance(Context context) {
- return MobileMessagingCore.getInstance(context).getMessageHandlerModule(MobileChatImpl.class);
- }
-
- /**
- * Sends message to chat
- * @param text text of message
- */
- public abstract void sendMessage(String text);
-
- /**
- * Sends message to chat
- * @param text text of message
- * @param customData any custom data attached to message
- */
- public abstract void sendMessage(String text, JSONObject customData);
-
- /**
- * Sends message to chat
- * @param text text of message
- * @param listener callback that receives the result
- */
- public abstract void sendMessage(String text, MobileMessaging.ResultListener listener);
-
- /**
- * Sends message to chat
- * @param text text of message
- * @param customData any custom data attached to message
- * @param listener callback that receives the result
- */
- public abstract void sendMessage(String text, JSONObject customData, MobileMessaging.ResultListener listener);
-
- /**
- * Marks chat message as read
- * @param id message id
- */
- public abstract void markMessageRead(String id);
-
- /**
- * Marks all stored messages as read
- */
- public abstract void markAllMessagesRead();
-
- /**
- * Sets user info for current user
- * @param info participant information
- */
- public abstract void setUserInfo(ChatParticipant info);
-
- /**
- * Sets user info for current user
- * @param info participant information
- * @param listener callback that receives the result of operation
- */
- public abstract void setUserInfo(ChatParticipant info, MobileMessaging.ResultListener listener);
-
- /**
- * Returns user profile cached locally
- * @return user profile
- */
- public abstract ChatParticipant getUserInfo();
-
- /**
- * Fetches current profile from server
- * (prefer {@link #getUserInfo()} if user profile is changed only on mobile)
- * @param listener callback that receives user profile
- */
- public abstract void fetchUserInfo(MobileMessaging.ResultListener listener);
-
- /**
- * Fetches current profile from server and caches it in library
- * (prefer {@link #getUserInfo()} if user profile is changed only on mobile)
- */
- public abstract void fetchUserInfo();
-
- /**
- * Returns message storage to access messages stored on a device
- * @return chat message storage
- */
- public abstract ChatMessageStorage getChatMessageStorage();
-
- /**
- * Creates chat view activity.
- * @see MobileChatView#show()
- * @return chat view object
- */
- public abstract MobileChatView chatView();
-
- /**
- * Sets which activities to start when user taps on chat notification. Last one in array will be show, others will be put to task stack.
- * Library will also provide appropriate message together with intent, use following code to retrieve the message:
- * *
- * {@code
- * ChatMessage message = ChatMessage.createFrom(intent);
- * }
- *
- * @param activityClasses array of activities to put into task stack when message is tapped
- */
- public abstract void setActivitiesToStartOnMessageTap(Class... activityClasses);
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/MobileChatView.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/MobileChatView.java
deleted file mode 100644
index 0f435be3..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/MobileChatView.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.infobip.mobile.messaging.chat;
-
-import org.infobip.mobile.messaging.interactive.NotificationCategory;
-
-/**
- * @author sslavin
- * @since 19/11/2017.
- */
-
-public interface MobileChatView {
-
- /**
- * Will register action categories in chat view. All messages containing these categories will also have buttons for corresponding actions.
- * @param categories categories to register
- * @return view
- */
- MobileChatView withActionCategories(NotificationCategory... categories);
-
- /**
- * Call this method to show the view
- */
- void show();
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/broadcast/ChatBroadcaster.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/broadcast/ChatBroadcaster.java
deleted file mode 100644
index fc2339e9..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/broadcast/ChatBroadcaster.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.infobip.mobile.messaging.chat.broadcast;
-
-import org.infobip.mobile.messaging.chat.ChatMessage;
-import org.infobip.mobile.messaging.chat.ChatParticipant;
-
-/**
- * @author sslavin
- * @since 09/10/2017.
- */
-
-public interface ChatBroadcaster {
-
- /**
- * Sends broadcast when chat message is received
- *
- * @param message message to send broadcast for
- */
- void chatMessageReceived(ChatMessage message);
-
- /**
- * Sends broadcast when chat message is sent out
- *
- * @param message message to send broadcast for
- */
- void chatMessageSent(ChatMessage message);
-
- /**
- * Sends broadcast when chat message is tapped
- *
- * @param message message to send broadcast for
- */
- void chatMessageTapped(ChatMessage message);
-
- /**
- * Sends broadcast when action tapped
- *
- * @param message message to send broadcast for
- * @param actionId tapped action id
- */
- void chatMessageViewActionTapped(ChatMessage message, String actionId);
-
- /**
- * Sends broadcast when user information is saved on server
- *
- * @param participant user information
- */
- void userInfoSynchronized(ChatParticipant participant);
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/broadcast/ChatBroadcasterImpl.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/broadcast/ChatBroadcasterImpl.java
deleted file mode 100644
index 1719c616..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/broadcast/ChatBroadcasterImpl.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package org.infobip.mobile.messaging.chat.broadcast;
-
-import android.content.Context;
-import android.content.Intent;
-import android.support.annotation.VisibleForTesting;
-
-import org.infobip.mobile.messaging.chat.ChatMessage;
-import org.infobip.mobile.messaging.chat.ChatParticipant;
-import org.infobip.mobile.messaging.chat.ChatEvent;
-import org.infobip.mobile.messaging.chat.MobileChat;
-
-/**
- * @author sslavin
- * @since 09/10/2017.
- */
-
-public class ChatBroadcasterImpl implements ChatBroadcaster {
-
- private final Context context;
- private final LocalBroadcastManagerWrapper localBroadcastManagerWrapper;
- private final ChatBundleMapper mapper;
-
- public ChatBroadcasterImpl(Context context) {
- this.context = context;
- this.localBroadcastManagerWrapper = new LocalBroadcastManagerWrapper(context);
- this.mapper = new ChatBundleMapper();
- }
-
- @VisibleForTesting
- ChatBroadcasterImpl(Context context, LocalBroadcastManagerWrapper localBroadcastManagerWrapper, ChatBundleMapper mapper) {
- this.context = context;
- this.localBroadcastManagerWrapper = localBroadcastManagerWrapper;
- this.mapper = mapper;
- }
-
- @Override
- public void chatMessageReceived(ChatMessage message) {
- sendIntent(prepareIntent(ChatEvent.CHAT_MESSAGE_RECEIVED)
- .putExtras(mapper.chatMessageToBundle(message)));
- }
-
- @Override
- public void chatMessageSent(ChatMessage message) {
- sendIntent(prepareIntent(ChatEvent.CHAT_MESSAGE_SENT)
- .putExtras(mapper.chatMessageToBundle(message)));
- }
-
- @Override
- public void chatMessageTapped(ChatMessage message) {
- sendIntent(prepareIntent(ChatEvent.CHAT_MESSAGE_TAPPED)
- .putExtras(mapper.chatMessageToBundle(message)));
- }
-
- @Override
- public void chatMessageViewActionTapped(ChatMessage message, String actionId) {
- sendIntent(prepareIntent(ChatEvent.CHAT_MESSAGE_VIEW_ACTION_TAPPED)
- .putExtras(mapper.chatMessageToBundle(message))
- .putExtra(MobileChat.EXTRA_ACTION_ID, actionId));
- }
-
- @Override
- public void userInfoSynchronized(ChatParticipant info) {
- sendIntent(prepareIntent(ChatEvent.CHAT_USER_INFO_SYNCHRONIZED)
- .putExtras(mapper.chatParticipantToBundle(info)));
- }
-
- // region private methods
-
- private Intent prepareIntent(ChatEvent event) {
- return prepareIntent(event.getKey());
- }
-
- private Intent prepareIntent(String event) {
- return new Intent(event)
- .setPackage(context.getPackageName());
- }
-
- private void sendIntent(Intent intent) {
- context.sendBroadcast(intent);
- localBroadcastManagerWrapper.sendBroadcast(intent);
- }
-
- // endregion
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/broadcast/ChatBundleMapper.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/broadcast/ChatBundleMapper.java
deleted file mode 100644
index 5f438723..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/broadcast/ChatBundleMapper.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package org.infobip.mobile.messaging.chat.broadcast;
-
-import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.annotation.VisibleForTesting;
-
-import org.infobip.mobile.messaging.chat.ChatMessage;
-import org.infobip.mobile.messaging.chat.ChatParticipant;
-import org.infobip.mobile.messaging.dal.bundle.BundleMapper;
-
-import static android.support.annotation.VisibleForTesting.PACKAGE_PRIVATE;
-
-/**
- * @author sslavin
- * @since 09/10/2017.
- */
-
-public class ChatBundleMapper extends BundleMapper {
-
- private static final String BUNDLED_MESSAGE_TAG = ChatBundleMapper.class.getName() + ".message";
- private static final String BUNDLED_PARTICIPANT_TAG = ChatBundleMapper.class.getName() + ".participant";
-
- /**
- * Converts chat message to bundle
- * @param message chat message
- * @return resulting bundle
- */
- @NonNull
- public Bundle chatMessageToBundle(@NonNull ChatMessage message) {
- return objectToBundle(message, BUNDLED_MESSAGE_TAG);
- }
-
- /**
- * Converts bundle to chat message
- * @param bundle bundle with data
- * @return chat message
- */
- @Nullable
- public ChatMessage chatMessageFromBundle(Bundle bundle) {
- return objectFromBundle(bundle, BUNDLED_MESSAGE_TAG, ChatMessage.class);
- }
-
- /**
- * Converts chat participant to bundle
- * @param participant participant information
- * @return resuting bundle
- */
- @NonNull
- @VisibleForTesting(otherwise = PACKAGE_PRIVATE)
- public Bundle chatParticipantToBundle(@NonNull ChatParticipant participant) {
- return objectToBundle(participant, BUNDLED_PARTICIPANT_TAG);
- }
-
- /**
- * Converts bundle to chat participant
- * @param bundle bundle with data
- * @return chat participant
- */
- @Nullable
- public ChatParticipant chatParticipantFromBundle(Bundle bundle) {
- return objectFromBundle(bundle, BUNDLED_PARTICIPANT_TAG, ChatParticipant.class);
- }
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/broadcast/LocalBroadcastManagerWrapper.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/broadcast/LocalBroadcastManagerWrapper.java
deleted file mode 100644
index b33400af..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/broadcast/LocalBroadcastManagerWrapper.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.infobip.mobile.messaging.chat.broadcast;
-
-import android.content.Context;
-import android.content.Intent;
-import android.support.v4.content.LocalBroadcastManager;
-
-/**
- * Needed for proper testing
- *
- * @author sslavin
- * @since 10/10/2017.
- */
-
-
-public class LocalBroadcastManagerWrapper {
-
- private final LocalBroadcastManager localBroadcastManager;
-
- public LocalBroadcastManagerWrapper(Context context) {
- localBroadcastManager = LocalBroadcastManager.getInstance(context);
- }
-
- public void sendBroadcast(Intent intent) {
- localBroadcastManager.sendBroadcast(intent);
- }
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/ChatMessageStorageImpl.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/ChatMessageStorageImpl.java
deleted file mode 100644
index 1af1887a..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/ChatMessageStorageImpl.java
+++ /dev/null
@@ -1,190 +0,0 @@
-package org.infobip.mobile.messaging.chat.core;
-
-import android.text.TextUtils;
-
-import org.infobip.mobile.messaging.chat.ChatMessage;
-import org.infobip.mobile.messaging.chat.ChatMessageStorage;
-import org.infobip.mobile.messaging.chat.repository.Message;
-import org.infobip.mobile.messaging.chat.repository.MessageRepository;
-import org.infobip.mobile.messaging.chat.repository.Participant;
-import org.infobip.mobile.messaging.chat.repository.ParticipantRepository;
-import org.infobip.mobile.messaging.chat.repository.RepositoryMapper;
-import org.infobip.mobile.messaging.dal.sqlite.PrimaryKeyViolationException;
-import org.infobip.mobile.messaging.mobile.common.MAsyncTask;
-import org.infobip.mobile.messaging.platform.Time;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author sslavin
- * @since 17/10/2017.
- */
-
-public class ChatMessageStorageImpl implements ChatMessageStorage {
-
- private final MessageRepository messageRepository;
- private final ParticipantRepository participantRepository;
- private final RepositoryMapper repositoryMapper;
- private final Set listeners = new HashSet<>();
-
- ChatMessageStorageImpl(MessageRepository messageRepository, ParticipantRepository participantRepository, RepositoryMapper repositoryMapper) {
- this.messageRepository = messageRepository;
- this.participantRepository = participantRepository;
- this.repositoryMapper = repositoryMapper;
- }
-
- @Override
- public List findAllMessages() {
- List repositoryMessages = messageRepository.findAll();
- List chatMessages = new ArrayList<>(repositoryMessages.size());
- for (Message message : repositoryMessages) {
- chatMessages.add(repositoryMapper.chatMessageFromDbMessageAndParticipant(message, participantRepository.findAuthor(message)));
- }
- return chatMessages;
- }
-
- @Override
- public long countAllMessages() {
- return messageRepository.countAll();
- }
-
- @Override
- public long countAllUnreadMessages() {
- return messageRepository.countAllUnread();
- }
-
- @Override
- public ChatMessage findMessage(String id) {
- Message message = messageRepository.findOne(id);
- if (message == null) {
- return null;
- }
-
- Participant participant = participantRepository.findAuthor(message);
- return repositoryMapper.chatMessageFromDbMessageAndParticipant(message, participant);
- }
-
- @Override
- public void save(ChatMessage message) {
-
- if (message.getAuthor() != null && !TextUtils.isEmpty(message.getAuthor().getId())) {
- Participant participant = repositoryMapper.dbParticipantFromChatParticipant(message.getAuthor());
- participantRepository.upsert(participant);
- }
-
- Message repositoryMessage = repositoryMapper.dbMessageFromChatMessage(message);
- try {
- messageRepository.insert(repositoryMessage);
- invokeOnNew(message);
- } catch (PrimaryKeyViolationException e) {
- messageRepository.upsert(repositoryMessage);
- invokeOnUpdated(message);
- }
- }
-
- @Override
- public void delete(String id) {
- messageRepository.remove(id);
- invokeOnDeleted(id);
- }
-
- @Override
- public void deleteAll() {
- messageRepository.clear();
- invokeOnAllDeleted();
- }
-
- @Override
- public void registerListener(Listener listener) {
- listeners.add(listener);
- }
-
- @Override
- public void unregisterListener(Listener listener) {
- listeners.remove(listener);
- }
-
- void markRead(String messageId) {
- Message message = messageRepository.markRead(messageId, Time.now());
- if (message == null) {
- return;
- }
-
- Participant participant = participantRepository.findAuthor(message);
- invokeOnUpdated(repositoryMapper.chatMessageFromDbMessageAndParticipant(message, participant));
- }
-
- Set markAllRead() {
- Set ids = messageRepository.markAllMessagesRead(Time.now());
- for (String id : ids) {
- markRead(id);
- }
- return ids;
- }
-
- // region private methods
-
- private void invokeOnNew(final ChatMessage message) {
- invokeOnUiThread(new Runnable() {
- @Override
- public void run() {
- for (Listener listener : listeners) {
- listener.onNew(message);
- }
- }
- });
- }
-
- private void invokeOnUpdated(final ChatMessage message) {
- invokeOnUiThread(new Runnable() {
- @Override
- public void run() {
- for (Listener listener : listeners) {
- listener.onUpdated(message);
- }
- }
- });
- }
-
- private void invokeOnDeleted(final String id) {
- invokeOnUiThread(new Runnable() {
- @Override
- public void run() {
- for (Listener listener : listeners) {
- listener.onDeleted(id);
- }
- }
- });
- }
-
- private void invokeOnAllDeleted() {
- invokeOnUiThread(new Runnable() {
- @Override
- public void run() {
- for (Listener listener : listeners) {
- listener.onAllDeleted();
- }
- }
- });
- }
-
- private void invokeOnUiThread(final Runnable runnable) {
- new MAsyncTask() {
-
- @Override
- public Void run(Void[] objects) {
- return null;
- }
-
- @Override
- public void after(Void o) {
- runnable.run();
- }
- }.execute();
- }
-
- // endregion
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/CoreBroadcastReceiver.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/CoreBroadcastReceiver.java
deleted file mode 100644
index 20aba19f..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/CoreBroadcastReceiver.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.infobip.mobile.messaging.chat.core;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.support.annotation.VisibleForTesting;
-
-import org.infobip.mobile.messaging.Event;
-import org.infobip.mobile.messaging.User;
-import org.infobip.mobile.messaging.chat.ChatParticipant;
-import org.infobip.mobile.messaging.chat.broadcast.ChatBroadcaster;
-import org.infobip.mobile.messaging.chat.broadcast.ChatBroadcasterImpl;
-
-/**
- * @author sslavin
- * @since 10/10/2017.
- */
-
-public class CoreBroadcastReceiver extends BroadcastReceiver {
-
- private ChatBroadcaster broadcaster;
- private final ObjectMapper mapper;
- private UserProfileManager userProfileManager;
-
- @SuppressWarnings("unused")
- public CoreBroadcastReceiver() {
- this.mapper = new ObjectMapper();
- }
-
- @VisibleForTesting
- public CoreBroadcastReceiver(ChatBroadcaster broadcaster, ObjectMapper mapper, UserProfileManager userProfileManager) {
- this.broadcaster = broadcaster;
- this.mapper = mapper;
- this.userProfileManager = userProfileManager;
- }
-
- @Override
- public void onReceive(Context context, Intent intent) {
- if (intent == null) {
- return;
- }
-
- if (!Event.USER_UPDATED.getKey().equals(intent.getAction())) {
- return;
- }
-
- User user = User.createFrom(intent.getExtras());
- if (user != null) {
- ChatParticipant participant = mapper.fromUserData(user);
- userProfileManager(context).save(participant);
- broadcaster(context).userInfoSynchronized(participant);
- }
- }
-
- // region private methods
-
- private ChatBroadcaster broadcaster(Context context) {
- if (broadcaster == null) {
- broadcaster = new ChatBroadcasterImpl(context);
- }
- return broadcaster;
- }
-
- private UserProfileManager userProfileManager(Context context) {
- if (userProfileManager == null) {
- userProfileManager = new UserProfileManager(context);
- }
- return userProfileManager;
- }
-
- // endregion
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/MobileChatImpl.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/MobileChatImpl.java
deleted file mode 100644
index 4ed0881a..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/MobileChatImpl.java
+++ /dev/null
@@ -1,347 +0,0 @@
-package org.infobip.mobile.messaging.chat.core;
-
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.v4.app.TaskStackBuilder;
-
-import org.infobip.mobile.messaging.Message;
-import org.infobip.mobile.messaging.MessageHandlerModule;
-import org.infobip.mobile.messaging.MobileMessaging;
-import org.infobip.mobile.messaging.MobileMessagingCore;
-import org.infobip.mobile.messaging.NotificationSettings;
-import org.infobip.mobile.messaging.User;
-import org.infobip.mobile.messaging.chat.ChatMessage;
-import org.infobip.mobile.messaging.chat.ChatMessageStorage;
-import org.infobip.mobile.messaging.chat.ChatParticipant;
-import org.infobip.mobile.messaging.chat.MobileChat;
-import org.infobip.mobile.messaging.chat.broadcast.ChatBroadcaster;
-import org.infobip.mobile.messaging.chat.broadcast.ChatBroadcasterImpl;
-import org.infobip.mobile.messaging.chat.broadcast.ChatBundleMapper;
-import org.infobip.mobile.messaging.chat.properties.MobileChatProperty;
-import org.infobip.mobile.messaging.chat.properties.PropertyHelper;
-import org.infobip.mobile.messaging.chat.repository.MessageRepositoryImpl;
-import org.infobip.mobile.messaging.chat.repository.ParticipantRepositoryImpl;
-import org.infobip.mobile.messaging.chat.repository.RepositoryMapper;
-import org.infobip.mobile.messaging.interactive.MobileInteractive;
-import org.infobip.mobile.messaging.interactive.NotificationAction;
-import org.infobip.mobile.messaging.mobile.MobileMessagingError;
-import org.infobip.mobile.messaging.mobile.Result;
-import org.infobip.mobile.messaging.platform.Time;
-import org.json.JSONObject;
-
-import java.util.Set;
-
-import static org.infobip.mobile.messaging.chat.ChatEvent.CHAT_MESSAGE_TAPPED;
-
-/**
- * @author sslavin
- * @since 09/10/2017.
- */
-
-public class MobileChatImpl extends MobileChat implements MessageHandlerModule {
-
- private Context context;
- private MobileMessagingCore mobileMessagingCore;
- private MobileInteractive mobileInteractive;
- private final ObjectMapper objectMapper = new ObjectMapper();
- private final RepositoryMapper repositoryMapper = new RepositoryMapper();
- private final ChatBundleMapper bundleMapper = new ChatBundleMapper();
- private ChatBroadcaster broadcaster;
- private UserProfileManager userProfileManager;
- private ChatMessageStorageImpl chatMessageStorage;
- private MobileChatViewImpl mobileChatView;
- private PropertyHelper propertyHelper;
- private ParticipantRepositoryImpl participantRepository;
-
- @Override
- public void init(Context appContext) {
- this.context = appContext;
- }
-
- @Override
- public boolean handleMessage(Message message) {
- if (!isChatMessage(message)) {
- return false;
- }
-
- ChatMessage chatMessage = objectMapper.fromBaseMessage(message, userProfileManager().isUsersMessage(message));
- chatMessageStorage().save(chatMessage);
- broadcaster().chatMessageReceived(chatMessage);
- mobileMessagingCore().getNotificationHandler().displayNotification(message);
- return true;
- }
-
- @Override
- public boolean messageTapped(Message message) {
- if (!isChatMessage(message)) {
- return false;
- }
-
- ChatMessage chatMessage = objectMapper.fromBaseMessage(message, userProfileManager().isUsersMessage(message));
- broadcaster().chatMessageTapped(chatMessage);
- doCoreTappedActions(chatMessage);
- return true;
- }
-
- @Override
- public void sendMessage(String text) {
- sendChatMessage(text, null, null);
- }
-
- @Override
- public void sendMessage(String text, JSONObject customData) {
- sendChatMessage(text, customData, null);
- }
-
- @Override
- public void sendMessage(String text, MobileMessaging.ResultListener listener) {
- sendChatMessage(text, null, listener);
- }
-
- @Override
- public void sendMessage(String text, JSONObject customData, MobileMessaging.ResultListener listener) {
- sendChatMessage(text, customData, listener);
- }
-
- @Override
- public void markMessageRead(String id) {
- chatMessageStorage().markRead(id);
- mobileMessagingCore().setMessagesSeenDontStore(id);
- }
-
- @Override
- public void markAllMessagesRead() {
- Set ids = chatMessageStorage().markAllRead();
- mobileMessagingCore().setMessagesSeenDontStore(ids.toArray(new String[0]));
- }
-
- @Override
- public void setUserInfo(ChatParticipant info) {
- setChatUserInfo(info, null);
- }
-
- @Override
- public void setUserInfo(ChatParticipant info, MobileMessaging.ResultListener listener) {
- setChatUserInfo(info, listener);
- }
-
- @Override
- public ChatParticipant getUserInfo() {
- return userProfileManager().get();
- }
-
- @Override
- public void fetchUserInfo() {
- fetchUserInfo(null);
- }
-
- @Override
- public void fetchUserInfo(final MobileMessaging.ResultListener listener) {
- mobileMessagingCore().fetchUser(new MobileMessaging.ResultListener() {
- @Override
- public void onResult(Result result) {
- if (listener == null) {
- return;
- }
-
- if (result.getData() == null) {
- listener.onResult(new Result(MobileMessagingError.createFrom(new RuntimeException())));
- return;
- }
-
- listener.onResult(new Result<>(objectMapper.fromUserData(result.getData()), result.getError()));
- }
- });
- }
-
- @Override
- public ChatMessageStorage getChatMessageStorage() {
- return chatMessageStorage();
- }
-
- @Override
- public MobileChatViewImpl chatView() {
- if (mobileChatView == null) {
- mobileChatView = new MobileChatViewImpl(context);
- }
- return mobileChatView;
- }
-
- @Override
- public void setActivitiesToStartOnMessageTap(Class... activityClasses) {
- propertyHelper().saveClasses(MobileChatProperty.ON_MESSAGE_TAP_ACTIVITY_CLASSES, activityClasses);
- }
-
- // region private methods
-
- private void sendChatMessage(String text, JSONObject customData, final MobileMessaging.ResultListener listener) {
- final ChatMessage message = new ChatMessage();
- message.setBody(text);
- message.setAuthor(userProfileManager().get());
- message.setCustomData(customData);
- message.setReceivedAt(Time.now());
- message.setYours(true);
- chatMessageStorage().save(message);
- Message baseMessage = objectMapper.toBaseMessage(message);
- mobileMessagingCore().sendMessagesDontStore(new MobileMessaging.ResultListener() {
- @Override
- public void onResult(Result result) {
- if (listener == null) {
- return;
- }
-
- Message[] messages = result.getData();
- if (messages == null || messages.length == 0) {
- listener.onResult(new Result(MobileMessagingError.createFrom(new RuntimeException())));
- return;
- }
-
- ChatMessage sentMessage = objectMapper.fromBaseMessage(messages[0], userProfileManager().isUsersMessage(messages[0]));
- chatMessageStorage().save(sentMessage);
-
- broadcaster().chatMessageSent(sentMessage);
- listener.onResult(new Result<>(sentMessage, result.getError()));
- }
- }, baseMessage);
- }
-
- private void setChatUserInfo(ChatParticipant info, final MobileMessaging.ResultListener listener) {
- userProfileManager().save(info);
- User user = objectMapper.toUserData(info);
- mobileMessagingCore().saveUser(user, new MobileMessaging.ResultListener() {
- @Override
- public void onResult(Result result) {
- if (listener == null) {
- return;
- }
-
- if (result == null) {
- listener.onResult(new Result(MobileMessagingError.createFrom(new RuntimeException())));
- return;
- }
-
- ChatParticipant participant = objectMapper.fromUserData(result.getData());
- userProfileManager.save(participant);
- broadcaster().userInfoSynchronized(participant);
- listener.onResult(new Result<>(participant, result.getError()));
- }
- });
- }
-
- private static boolean isChatMessage(Message message) {
- return message.getCustomPayload() != null &&
- message.getCustomPayload().optBoolean("isChat", false);
- }
-
- synchronized private MobileMessagingCore mobileMessagingCore() {
- if (mobileMessagingCore == null) {
- mobileMessagingCore = MobileMessagingCore.getInstance(context);
- }
- return mobileMessagingCore;
- }
-
- synchronized private ChatBroadcaster broadcaster() {
- if (broadcaster == null) {
- broadcaster = new ChatBroadcasterImpl(context);
- }
- return broadcaster;
- }
-
- synchronized private UserProfileManager userProfileManager() {
- if (userProfileManager == null) {
- userProfileManager = new UserProfileManager(context);
- }
- return userProfileManager;
- }
-
- synchronized private ChatMessageStorageImpl chatMessageStorage() {
- if (chatMessageStorage == null) {
- chatMessageStorage = new ChatMessageStorageImpl(new MessageRepositoryImpl(context), participantRepository(), repositoryMapper);
- }
- return chatMessageStorage;
- }
-
- synchronized private ParticipantRepositoryImpl participantRepository() {
- if (participantRepository == null) {
- participantRepository = new ParticipantRepositoryImpl(context);
- }
- return participantRepository;
- }
-
- synchronized private MobileInteractive mobileInteractive() {
- if (mobileInteractive == null) {
- mobileInteractive = MobileInteractive.getInstance(context);
- }
- return mobileInteractive;
- }
-
- synchronized private PropertyHelper propertyHelper() {
- if (propertyHelper == null) {
- propertyHelper = new PropertyHelper(context);
- }
- return propertyHelper;
- }
-
- @Override
- public void applicationInForeground() {
- // do nothing
- }
-
- @Override
- public void cleanup() {
- chatMessageStorage().deleteAll();
- participantRepository().clear();
- propertyHelper().remove(MobileChatProperty.USER_NAME_DIALOG_SHOWN);
- }
-
- @Override
- public void depersonalize() {
- chatMessageStorage().deleteAll();
- participantRepository().clear();
- propertyHelper().remove(MobileChatProperty.USER_NAME_DIALOG_SHOWN);
- }
-
- public void processTappedAction(ChatMessage chatMessage, NotificationAction action) {
- broadcaster().chatMessageViewActionTapped(chatMessage, action.getId());
- mobileInteractive().triggerSdkActionsFor(action, objectMapper.toBaseMessage(chatMessage));
- }
-
- @NonNull
- private TaskStackBuilder stackBuilderForNotificationTap(ChatMessage message) {
- TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
- Bundle messageBundle = bundleMapper.chatMessageToBundle(message);
- Class[] classes = propertyHelper().findClasses(MobileChatProperty.ON_MESSAGE_TAP_ACTIVITY_CLASSES);
- if (classes != null) {
- for (Class cls : classes) {
- stackBuilder.addNextIntent(new Intent(context, cls)
- .setAction(CHAT_MESSAGE_TAPPED.getKey())
- .putExtras(messageBundle));
- }
- }
-
- NotificationSettings notificationSettings = mobileMessagingCore().getNotificationSettings();
- if (stackBuilder.getIntentCount() == 0 && notificationSettings != null && notificationSettings.getCallbackActivity() != null) {
- stackBuilder.addNextIntent(new Intent(context, notificationSettings.getCallbackActivity())
- .setAction(CHAT_MESSAGE_TAPPED.getKey())
- .putExtras(messageBundle));
- }
-
- return stackBuilder;
- }
-
- private void doCoreTappedActions(ChatMessage chatMessage) {
- NotificationSettings notificationSettings = mobileMessagingCore().getNotificationSettings();
- if (notificationSettings != null && notificationSettings.markSeenOnTap()) {
- markMessageRead(chatMessage.getId());
- }
-
- TaskStackBuilder stackBuilder = stackBuilderForNotificationTap(chatMessage);
- if (stackBuilder.getIntentCount() != 0) {
- stackBuilder.startActivities();
- }
- }
-
- // endregion
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/ObjectMapper.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/ObjectMapper.java
deleted file mode 100644
index 5846e03c..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/ObjectMapper.java
+++ /dev/null
@@ -1,126 +0,0 @@
-package org.infobip.mobile.messaging.chat.core;
-
-import android.support.annotation.VisibleForTesting;
-
-import org.infobip.mobile.messaging.CustomAttributeValue;
-import org.infobip.mobile.messaging.Message;
-import org.infobip.mobile.messaging.User;
-import org.infobip.mobile.messaging.chat.ChatMessage;
-import org.infobip.mobile.messaging.chat.ChatParticipant;
-import org.infobip.mobile.messaging.chat.repository.MJSONObject;
-import org.json.JSONObject;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static android.support.annotation.VisibleForTesting.PACKAGE_PRIVATE;
-
-/**
- * @author sslavin
- * @since 09/10/2017.
- */
-
-@VisibleForTesting(otherwise = PACKAGE_PRIVATE)
-public class ObjectMapper {
-
- public ChatMessage fromBaseMessage(Message message, boolean isYours) {
- JSONObject originalData = message.getCustomPayload();
- JSONObject data = MJSONObject.copy(message.getCustomPayload(), "chatId", "sender", "senderFirstName",
- "senderLastName", "senderMiddleName", "senderEmail", "senderGsm", "senderData", "isChat");
- return new ChatMessage(
- message.getMessageId(),
- message.getBody(),
- originalData.optString("chatId", null),
- message.getSentTimestamp(),
- message.getReceivedTimestamp(),
- message.getSeenTimestamp(),
- message.getCategory(),
- message.getContentUrl(),
- new ChatParticipant(
- originalData.optString("sender", null),
- originalData.optString("senderFirstName", null),
- originalData.optString("senderLastName", null),
- originalData.optString("senderMiddleName", null),
- originalData.optString("senderEmail", null),
- originalData.optString("senderGsm", null),
- MJSONObject.create(originalData.optString("senderData", null))),
- message.getStatus(),
- data,
- isYours
- );
- }
-
- public Message toBaseMessage(ChatMessage message) {
- MJSONObject customData = MJSONObject.copy(message.getCustomData());
- if (customData == null) customData = MJSONObject.create();
- if (message.getAuthor() != null) {
- ChatParticipant author = message.getAuthor();
- customData
- .add("sender", author.getId())
- .add("senderFirstName", author.getFirstName())
- .add("senderLastName", author.getLastName())
- .add("senderMiddleName", author.getMiddleName())
- .add("senderEmail", author.getEmail())
- .add("senderGsm", author.getGsm())
- .add("senderData", author.getCustomData() == null ? null : author.getCustomData().toString())
- .add("isChat", true);
- }
- customData.add("chatId", message.getChatId());
- return new Message(
- message.getId(),
- null,
- message.getBody(),
- null,
- true,
- null,
- false,
- message.getCategory(),
- null,
- message.getReceivedAt(),
- message.getReadAt(),
- message.getCreatedAt(),
- customData,
- null,
- null,
- message.getStatus(),
- null,
- message.getContentUrl(),
- null,
- 0);
- }
-
- public ChatParticipant fromUserData(User user) {
- MJSONObject data = null;
- Map customData = user.getCustomAttributes();
- if (customData != null) {
- CustomAttributeValue value = customData.get("chatCustomData");
- if (value != null) {
- data = MJSONObject.create(value.stringValue());
- }
- }
- return new ChatParticipant(
- user.getExternalUserId(),
- user.getFirstName(),
- user.getLastName(),
- user.getMiddleName(),
- null,
- null,
- data);
- }
-
- public User toUserData(ChatParticipant participant) {
- Map customData = new HashMap<>();
- if (participant.getCustomData() != null) {
- customData.put("chatCustomData", new CustomAttributeValue(participant.getCustomData().toString()));
- }
- User user = new User();
- user.setExternalUserId(participant.getId());
- user.setFirstName(participant.getFirstName());
- user.setLastName(participant.getLastName());
- user.setMiddleName(participant.getMiddleName());
-// user.setEmail(participant.getEmail());
-// user.setMsisdn(participant.getGsm());
- user.setCustomAttributes(customData);
- return user;
- }
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/UserProfileManager.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/UserProfileManager.java
deleted file mode 100644
index 4e70e005..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/UserProfileManager.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package org.infobip.mobile.messaging.chat.core;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.support.annotation.NonNull;
-import android.support.annotation.VisibleForTesting;
-import android.text.TextUtils;
-
-import org.infobip.mobile.messaging.Message;
-import org.infobip.mobile.messaging.MobileMessaging;
-import org.infobip.mobile.messaging.chat.ChatParticipant;
-import org.infobip.mobile.messaging.chat.repository.Participant;
-import org.infobip.mobile.messaging.chat.repository.ParticipantRepository;
-import org.infobip.mobile.messaging.chat.repository.ParticipantRepositoryImpl;
-import org.infobip.mobile.messaging.chat.repository.RepositoryMapper;
-import org.infobip.mobile.messaging.util.PreferenceHelper;
-
-import static android.support.annotation.VisibleForTesting.PACKAGE_PRIVATE;
-
-/**
- * @author sslavin
- * @since 10/10/2017.
- */
-
-@VisibleForTesting(otherwise = PACKAGE_PRIVATE)
-public class UserProfileManager {
-
- private final String PARTICIPANT_ID_TAG = "org.infobip.mobile.messaging.chat.PARTICIPANT_ID_TAG";
-
- private final ParticipantRepository participantRepository;
- private final RepositoryMapper repositoryMapper;
- private final SharedPreferences sharedPreferences;
- private final String pushRegistrationId;
-
- UserProfileManager(Context context) {
- this.participantRepository = new ParticipantRepositoryImpl(context);
- this.repositoryMapper = new RepositoryMapper();
- this.sharedPreferences = PreferenceHelper.getDefaultMMSharedPreferences(context);
- this.pushRegistrationId = MobileMessaging.getInstance(context).getInstallation().getPushRegistrationId();
- }
-
- @VisibleForTesting
- UserProfileManager(ParticipantRepository participantRepository, RepositoryMapper repositoryMapper, SharedPreferences sharedPreferences, @NonNull String pushRegistrationId) {
- this.participantRepository = participantRepository;
- this.repositoryMapper = repositoryMapper;
- this.sharedPreferences = sharedPreferences;
- this.pushRegistrationId = pushRegistrationId;
- }
-
- @VisibleForTesting(otherwise = PACKAGE_PRIVATE)
- public void save(ChatParticipant profile) {
- if (profile == null || profile.getId() == null) {
- return;
- }
- participantRepository.upsert(repositoryMapper.dbParticipantFromChatParticipant(profile));
- sharedPreferences
- .edit()
- .putString(PARTICIPANT_ID_TAG, profile.getId())
- .apply();
- }
-
- ChatParticipant get() {
- String id = sharedPreferences.getString(PARTICIPANT_ID_TAG, null);
- if (id == null) {
- return new ChatParticipant(pushRegistrationId);
- }
-
- Participant participant = participantRepository.findOne(id);
- return repositoryMapper.chatParticipantFromDbParticipant(participant);
- }
-
- boolean isUsersMessage(Message message) {
- if (message == null || message.getCustomPayload() == null) {
- return false;
- }
-
- String authorId = message.getCustomPayload().optString("sender", null);
- String userId = sharedPreferences.getString(PARTICIPANT_ID_TAG, "");
- return userId.equalsIgnoreCase(authorId) || (TextUtils.isEmpty(userId) && pushRegistrationId.equalsIgnoreCase(authorId));
- }
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/properties/MobileChatProperty.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/properties/MobileChatProperty.java
deleted file mode 100644
index 130eaa9c..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/properties/MobileChatProperty.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.infobip.mobile.messaging.chat.properties;
-
-/**
- * @author sslavin
- * @since 01/11/2017.
- */
-
-public enum MobileChatProperty {
- USER_NAME_DIALOG_SHOWN("org.infobip.mobile.messaging.infobip.chat.USER_NAME_DIALOG_SHOWN", false),
- ON_MESSAGE_TAP_ACTIVITY_CLASSES("org.infobip.mobile.messaging.infobip.chat.ON_MESSAGE_TAP_ACTIVITY_CLASSES", new Class[0]);
-
- private final String key;
- private final Object defaultValue;
-
- MobileChatProperty(String key, Object defaultValue) {
- this.key = key;
- this.defaultValue = defaultValue;
- }
-
- public Object getDefaultValue() {
- return defaultValue;
- }
-
- public String getKey() {
- return key;
- }
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/MJSONObject.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/MJSONObject.java
deleted file mode 100644
index 39f8e665..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/MJSONObject.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package org.infobip.mobile.messaging.chat.repository;
-
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-
-import org.infobip.mobile.messaging.logging.MobileMessagingLogger;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author sslavin
- * @since 09/10/2017.
- */
-
-public class MJSONObject extends JSONObject {
-
- private MJSONObject() {
- super();
- }
-
- private MJSONObject(String json) throws JSONException {
- super(json);
- }
-
- private MJSONObject(JSONObject o, String... names) throws JSONException {
- super(o, names);
- }
-
- public static MJSONObject copy(JSONObject object, String... keysToExclude) {
- if (object == null) {
- return null;
- }
-
- try {
- return new MJSONObject(object, iteratorToArray(object.keys(), keysToExclude));
- } catch (Exception e) {
- MobileMessagingLogger.e("Cannot clone json object", e);
- return new MJSONObject();
- }
- }
-
- public static @Nullable MJSONObject create(String json) {
- if (json == null) {
- return null;
- }
-
- try {
- return new MJSONObject(json);
- } catch (Exception e) {
- MobileMessagingLogger.e("Cannot create json object from " + json, e);
- return null;
- }
- }
-
- public static @NonNull MJSONObject create() {
- return new MJSONObject();
- }
-
- public MJSONObject add(String key, Object value) {
- try {
- super.putOpt(key, value);
- } catch (JSONException e) {
- MobileMessagingLogger.e("Cannot put data to json object (" + key + ":" + value.toString() + ")", e);
- }
- return this;
- }
-
- // region private methods
-
- private static String[] iteratorToArray(Iterator iterator, String... toExclude) {
- Set exclude = arrayToSet(toExclude);
- List values = new ArrayList<>();
- while (iterator.hasNext()) {
- String value = iterator.next();
- if (!exclude.contains(value)) {
- values.add(value);
- }
- }
- return values.toArray(new String[0]);
- }
-
- private static Set arrayToSet(String... values) {
- return new HashSet<>(Arrays.asList(values));
- }
-
- // endregion
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/Message.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/Message.java
deleted file mode 100644
index 6536adef..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/Message.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.infobip.mobile.messaging.chat.repository;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-
-import org.infobip.mobile.messaging.chat.repository.db.ChatDatabaseContract;
-import org.infobip.mobile.messaging.dal.sqlite.DatabaseContract;
-
-/**
- * @author sslavin
- * @since 09/10/2017.
- */
-
-public class Message implements DatabaseContract.DatabaseObject {
-
- protected String id;
- String chatId;
- String body;
- Long receivedAt;
- Long createdAt;
- Long readAt;
- String category;
- String contentUrl;
- String authorId;
- String status;
- String customData;
- boolean isYours;
-
- @Override
- public String getTableName() {
- return ChatDatabaseContract.Tables.MESSAGES;
- }
-
- @Override
- public String getPrimaryKeyColumnName() {
- return ChatDatabaseContract.MessageColumns.ID;
- }
-
- @Override
- public void fillFromCursor(Cursor cursor) throws Exception {
- id = cursor.getString(cursor.getColumnIndexOrThrow(ChatDatabaseContract.MessageColumns.ID));
- chatId = cursor.getString(cursor.getColumnIndexOrThrow(ChatDatabaseContract.MessageColumns.CHAT_ID));
- body = cursor.getString(cursor.getColumnIndexOrThrow(ChatDatabaseContract.MessageColumns.BODY));
- receivedAt = cursor.getLong(cursor.getColumnIndexOrThrow(ChatDatabaseContract.MessageColumns.RECEIVED_TIMESTAMP));
- createdAt = cursor.getLong(cursor.getColumnIndexOrThrow(ChatDatabaseContract.MessageColumns.CREATED_TIMESTAMP));
- readAt = cursor.getLong(cursor.getColumnIndexOrThrow(ChatDatabaseContract.MessageColumns.READ_TIMESTAMP));
- category = cursor.getString(cursor.getColumnIndexOrThrow(ChatDatabaseContract.MessageColumns.CATEGORY));
- contentUrl = cursor.getString(cursor.getColumnIndexOrThrow(ChatDatabaseContract.MessageColumns.CONTENT_URL));
- authorId = cursor.getString(cursor.getColumnIndexOrThrow(ChatDatabaseContract.MessageColumns.AUTHOR_ID));
- status = cursor.getString(cursor.getColumnIndexOrThrow(ChatDatabaseContract.MessageColumns.STATUS));
- customData = cursor.getString(cursor.getColumnIndexOrThrow(ChatDatabaseContract.MessageColumns.CUSTOM_DATA));
- isYours = cursor.getShort(cursor.getColumnIndexOrThrow(ChatDatabaseContract.MessageColumns.YOURS)) == 1;
- }
-
- @Override
- public ContentValues getContentValues() {
- ContentValues contentValues = new ContentValues();
- contentValues.put(ChatDatabaseContract.MessageColumns.ID, id);
- contentValues.put(ChatDatabaseContract.MessageColumns.CHAT_ID, chatId);
- contentValues.put(ChatDatabaseContract.MessageColumns.BODY, body);
- contentValues.put(ChatDatabaseContract.MessageColumns.RECEIVED_TIMESTAMP, receivedAt);
- contentValues.put(ChatDatabaseContract.MessageColumns.CREATED_TIMESTAMP, createdAt);
- contentValues.put(ChatDatabaseContract.MessageColumns.READ_TIMESTAMP, readAt);
- contentValues.put(ChatDatabaseContract.MessageColumns.CATEGORY, category);
- contentValues.put(ChatDatabaseContract.MessageColumns.CONTENT_URL, contentUrl);
- contentValues.put(ChatDatabaseContract.MessageColumns.AUTHOR_ID, authorId);
- contentValues.put(ChatDatabaseContract.MessageColumns.STATUS, status);
- contentValues.put(ChatDatabaseContract.MessageColumns.CUSTOM_DATA, customData);
- contentValues.put(ChatDatabaseContract.MessageColumns.YOURS, isYours ? 1 : 0);
- return contentValues;
- }
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/MessageRepository.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/MessageRepository.java
deleted file mode 100644
index 43a0155c..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/MessageRepository.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package org.infobip.mobile.messaging.chat.repository;
-
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-
-import org.infobip.mobile.messaging.dal.sqlite.PrimaryKeyViolationException;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author sslavin
- * @since 09/10/2017.
- */
-
-public interface MessageRepository {
-
- /**
- * Returns all messages
- * @return list of all messages
- */
- @NonNull
- List findAll();
-
- /**
- * Returns count of all stored messages
- * @return number of stored messages
- */
- long countAll();
-
- /**
- * Returns count of all unread messages
- * @return number of unread messages
- */
- long countAllUnread();
-
- /**
- * Finds one message by id
- * @param id message id
- * @return message or null
- */
- @Nullable
- Message findOne(@NonNull String id);
-
- /**
- * Saves provided messages to database
- * @param message message to save to repository
- */
- void upsert(Message message);
-
- /**
- * Inserts new message or throws exception
- * @param message message to insert
- * @throws PrimaryKeyViolationException exception when same message already exists in database
- */
- void insert(Message message) throws PrimaryKeyViolationException;
-
- /**
- * Finds message and marks it read with the provided time if message is present
- * @param id message id
- * @param time timestamp ms
- * @return updated message
- */
- @Nullable
- Message markRead(String id, long time);
-
- /**
- * Finds all messages and marks them read with the provided time.
- * Will keep existing read timestamps untouched.
- * @param time timestamp ms
- * @return returns set of ids of messages that were marked read
- */
- Set markAllMessagesRead(long time);
-
- /**
- * Removes messages from database using provided ids
- * @param ids set of ids to remove messages for
- */
- void remove(String... ids);
-
- /**
- * Clears repository and removes all messages
- */
- void clear();
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/MessageRepositoryImpl.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/MessageRepositoryImpl.java
deleted file mode 100644
index 0b813ad5..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/MessageRepositoryImpl.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package org.infobip.mobile.messaging.chat.repository;
-
-import android.content.Context;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.annotation.VisibleForTesting;
-
-import org.infobip.mobile.messaging.chat.repository.db.ChatDatabaseContract;
-import org.infobip.mobile.messaging.chat.repository.db.DatabaseHelperImpl;
-import org.infobip.mobile.messaging.dal.sqlite.DatabaseHelper;
-import org.infobip.mobile.messaging.dal.sqlite.PrimaryKeyViolationException;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author sslavin
- * @since 09/10/2017.
- */
-
-public class MessageRepositoryImpl implements MessageRepository {
-
- private final Context context;
- private DatabaseHelper databaseHelper;
-
- public MessageRepositoryImpl(@NonNull Context context) {
- this.context = context;
- }
-
- @VisibleForTesting
- public MessageRepositoryImpl(@NonNull Context context, @NonNull DatabaseHelper databaseHelper) {
- this.context = context;
- this.databaseHelper = databaseHelper;
- }
-
- @NonNull
- @Override
- public List findAll() {
- return databaseHelper().findAll(Message.class);
- }
-
- @Override
- public long countAll() {
- return databaseHelper().countAll(Message.class);
- }
-
- @Override
- public long countAllUnread() {
- return databaseHelper().countAll(Message.class,
- ChatDatabaseContract.MessageColumns.READ_TIMESTAMP + "IS NOT NULL AND " + ChatDatabaseContract.MessageColumns.READ_TIMESTAMP + "IS NOT 0");
- }
-
- @Nullable
- @Override
- public Message findOne(@NonNull String id) {
- return databaseHelper().find(Message.class, id);
- }
-
- @Override
- public void upsert(Message message) {
- databaseHelper().save(message);
- }
-
- @Override
- public void insert(Message message) throws PrimaryKeyViolationException {
- databaseHelper().insert(message);
- }
-
- @Override
- public Message markRead(String id, long time) {
- Message message = databaseHelper().find(Message.class, id);
- if (message == null) {
- return null;
- }
-
- message.readAt = time;
- databaseHelper().save(message);
- return message;
- }
-
- @Override
- public Set markAllMessagesRead(long time) {
- Set ids = new HashSet<>();
- for (Message message : databaseHelper().findAll(Message.class)) {
- if (message.readAt != null && message.readAt > 0) {
- continue;
- }
-
- message.readAt = time;
- databaseHelper().save(message);
- ids.add(message.id);
- }
- return ids;
- }
-
- @Override
- public void remove(String... ids) {
- databaseHelper().delete(Message.class, ids);
- }
-
- @Override
- public void clear() {
- databaseHelper().deleteAll(Message.class);
- }
-
- // region private methods
-
- private DatabaseHelper databaseHelper() {
- if (databaseHelper == null) {
- databaseHelper = new DatabaseHelperImpl(context);
- }
- return databaseHelper;
- }
-
- // endregion
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/Participant.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/Participant.java
deleted file mode 100644
index cff68f4d..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/Participant.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.infobip.mobile.messaging.chat.repository;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-
-import org.infobip.mobile.messaging.chat.repository.db.ChatDatabaseContract;
-import org.infobip.mobile.messaging.dal.sqlite.DatabaseContract;
-
-/**
- * @author sslavin
- * @since 09/10/2017.
- */
-
-public class Participant implements DatabaseContract.DatabaseObject {
-
- protected String id;
- String firstName;
- String lastName;
- String middleName;
- String email;
- String phone;
- String customData;
-
- @Override
- public String getTableName() {
- return ChatDatabaseContract.Tables.PARTICIPANTS;
- }
-
- @Override
- public String getPrimaryKeyColumnName() {
- return ChatDatabaseContract.ParticipantColumns.ID;
- }
-
- @Override
- public void fillFromCursor(Cursor cursor) throws Exception {
- id = cursor.getString(cursor.getColumnIndexOrThrow(ChatDatabaseContract.ParticipantColumns.ID));
- firstName = cursor.getString(cursor.getColumnIndexOrThrow(ChatDatabaseContract.ParticipantColumns.FIRST_NAME));
- lastName = cursor.getString(cursor.getColumnIndexOrThrow(ChatDatabaseContract.ParticipantColumns.LAST_NAME));
- middleName = cursor.getString(cursor.getColumnIndexOrThrow(ChatDatabaseContract.ParticipantColumns.MIDDLE_NAME));
- email = cursor.getString(cursor.getColumnIndexOrThrow(ChatDatabaseContract.ParticipantColumns.EMAIL));
- phone = cursor.getString(cursor.getColumnIndexOrThrow(ChatDatabaseContract.ParticipantColumns.GSM));
- customData = cursor.getString(cursor.getColumnIndexOrThrow(ChatDatabaseContract.ParticipantColumns.CUSTOM_DATA));
- }
-
- @Override
- public ContentValues getContentValues() {
- ContentValues contentValues = new ContentValues();
- contentValues.put(ChatDatabaseContract.ParticipantColumns.ID, id);
- contentValues.put(ChatDatabaseContract.ParticipantColumns.FIRST_NAME, firstName);
- contentValues.put(ChatDatabaseContract.ParticipantColumns.LAST_NAME, lastName);
- contentValues.put(ChatDatabaseContract.ParticipantColumns.MIDDLE_NAME, middleName);
- contentValues.put(ChatDatabaseContract.ParticipantColumns.EMAIL, email);
- contentValues.put(ChatDatabaseContract.ParticipantColumns.GSM, phone);
- contentValues.put(ChatDatabaseContract.ParticipantColumns.CUSTOM_DATA, customData);
- return contentValues;
- }
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/ParticipantRepository.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/ParticipantRepository.java
deleted file mode 100644
index e9ed65fb..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/ParticipantRepository.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.infobip.mobile.messaging.chat.repository;
-
-import android.support.annotation.NonNull;
-
-import java.util.List;
-
-/**
- * @author sslavin
- * @since 09/10/2017.
- */
-
-public interface ParticipantRepository {
-
- /**
- * Returns all known participants
- *
- * @return list of participants
- */
- List findAll();
-
- /**
- * Returns participant based on provided id
- *
- * @param id id of participant
- * @return participant
- */
- Participant findOne(@NonNull String id);
-
- /**
- * Find author of message
- *
- * @param message message to look author for
- * @return participant
- */
- Participant findAuthor(@NonNull Message message);
-
- /**
- * Saves participant to database
- *
- * @param participant data to save
- */
- void upsert(@NonNull Participant participant);
-
- /**
- * Clears repository and removes all participants
- */
- void clear();
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/ParticipantRepositoryImpl.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/ParticipantRepositoryImpl.java
deleted file mode 100644
index 9c2c9761..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/ParticipantRepositoryImpl.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package org.infobip.mobile.messaging.chat.repository;
-
-import android.content.Context;
-import android.support.annotation.NonNull;
-
-import org.infobip.mobile.messaging.chat.repository.db.DatabaseHelperImpl;
-import org.infobip.mobile.messaging.dal.sqlite.DatabaseHelper;
-
-import java.util.List;
-
-/**
- * @author sslavin
- * @since 09/10/2017.
- */
-
-public class ParticipantRepositoryImpl implements ParticipantRepository {
-
- private final Context context;
- private DatabaseHelper databaseHelper;
-
- public ParticipantRepositoryImpl(Context context) {
- this.context = context;
- }
-
- @Override
- public List findAll() {
- return databaseHelper().findAll(Participant.class);
- }
-
- @Override
- public Participant findOne(@NonNull String id) {
- return databaseHelper().find(Participant.class, id);
- }
-
- @Override
- public Participant findAuthor(@NonNull Message message) {
- if (message.authorId == null) {
- return null;
- }
- return databaseHelper().find(Participant.class, message.authorId);
- }
-
- @Override
- public void upsert(@NonNull Participant participant) {
- databaseHelper().save(participant);
- }
-
- @Override
- public void clear() {
- databaseHelper().deleteAll(Participant.class);
- }
-
- // region private methods
-
- private DatabaseHelper databaseHelper() {
- if (databaseHelper == null) {
- databaseHelper = new DatabaseHelperImpl(context);
- }
- return databaseHelper;
- }
-
- // endregion
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/RepositoryMapper.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/RepositoryMapper.java
deleted file mode 100644
index f936b67c..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/RepositoryMapper.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package org.infobip.mobile.messaging.chat.repository;
-
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-
-import org.infobip.mobile.messaging.chat.ChatMessage;
-import org.infobip.mobile.messaging.chat.ChatParticipant;
-
-/**
- * @author sslavin
- * @since 09/10/2017.
- */
-
-public class RepositoryMapper {
-
- @NonNull
- public ChatMessage chatMessageFromDbMessageAndParticipant(@NonNull Message message, @Nullable Participant participant) {
- return new ChatMessage(
- message.id,
- message.body,
- message.chatId,
- message.createdAt,
- message.receivedAt,
- message.readAt,
- message.category,
- message.contentUrl,
- chatParticipantFromDbParticipant(participant),
- org.infobip.mobile.messaging.Message.Status.valueOf(message.status),
- MJSONObject.create(message.customData),
- message.isYours);
- }
-
- @Nullable
- public ChatParticipant chatParticipantFromDbParticipant(@Nullable Participant participant) {
- return participant == null ? null : new ChatParticipant(
- participant.id,
- participant.firstName,
- participant.lastName,
- participant.middleName,
- participant.email,
- participant.phone,
- MJSONObject.create(participant.customData));
- }
-
- @NonNull
- public Message dbMessageFromChatMessage(@NonNull ChatMessage chatMessage) {
- Message message = new Message();
- message.id = chatMessage.getId();
- message.body = chatMessage.getBody();
- message.chatId = chatMessage.getChatId();
- message.createdAt = chatMessage.getCreatedAt();
- message.receivedAt = chatMessage.getReceivedAt();
- message.readAt = chatMessage.getReadAt();
- message.category = chatMessage.getCategory();
- message.contentUrl = chatMessage.getContentUrl();
- message.authorId = chatMessage.getAuthor() == null ? null : chatMessage.getAuthor().getId();
- message.status = chatMessage.getStatus() == null ? null : chatMessage.getStatus().name();
- message.customData = chatMessage.getCustomData() == null ? null : chatMessage.getCustomData().toString();
- message.isYours = chatMessage.isYours();
- return message;
- }
-
- @NonNull
- public Participant dbParticipantFromChatParticipant(@NonNull ChatParticipant chatParticipant) {
- Participant participant = new Participant();
- participant.id = chatParticipant.getId();
- participant.firstName = chatParticipant.getFirstName();
- participant.lastName = chatParticipant.getLastName();
- participant.middleName = chatParticipant.getMiddleName();
- participant.email = chatParticipant.getEmail();
- participant.phone = chatParticipant.getGsm();
- participant.customData = chatParticipant.getCustomData() == null ? null : chatParticipant.getCustomData().toString();
- return participant;
- }
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/db/ChatDatabaseContract.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/db/ChatDatabaseContract.java
deleted file mode 100644
index e71c7c41..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/db/ChatDatabaseContract.java
+++ /dev/null
@@ -1,140 +0,0 @@
-package org.infobip.mobile.messaging.chat.repository.db;
-
-/**
- * @author sslavin
- * @since 09/10/2017.
- */
-
-public interface ChatDatabaseContract {
-
- interface Tables {
- /**
- * Table for messages
- */
- String MESSAGES = "messages";
-
- /**
- * Table for participants
- */
- String PARTICIPANTS = "participants";
- }
-
- interface MessageColumns {
- /**
- * Unique string identifier, typically UUID, primary key
- * [TEXT]
- */
- String ID = "id";
-
- /**
- * Unique string identifier of chat
- * [TEXT]
- */
- String CHAT_ID = "chat_id";
-
- /**
- * Message body text
- * [TEXT]
- */
- String BODY = "body";
-
- /**
- * Timestamp when message was received
- * [INTEGER]
- */
- String RECEIVED_TIMESTAMP = "received_timestamp";
-
- /**
- * Timestamp when message was created
- * [INTEGER]
- */
- String CREATED_TIMESTAMP = "created_timestamp";
-
- /**
- * Timestamp when message was seen
- * [INTEGER]
- */
- String READ_TIMESTAMP = "read_timestamp";
-
- /**
- * Actionable category
- * [TEXT]
- */
- String CATEGORY = "category";
-
- /**
- * Actionable category
- * [TEXT]
- */
- String CONTENT_URL = "content_url";
-
-
- /**
- * ID of author of message (Participant)
- * [TEXT]
- */
- String AUTHOR_ID = "author_id";
-
- /**
- * Message status name
- * [TEXT]
- */
- String STATUS = "status";
-
- /**
- * Custom data json
- * [TEXT]
- */
- String CUSTOM_DATA = "custom_data";
-
- /**
- * 1 if message belongs to current user, 0 otherwise
- * [INTEGER]
- */
- String YOURS = "yours";
- }
-
- interface ParticipantColumns {
- /**
- * Unique string identifier, typically UUID, primary key
- * [TEXT]
- */
- String ID = "id";
-
- /**
- * First name of participant
- * [TEXT]
- */
- String FIRST_NAME = "first_name";
-
- /**
- * Last name of participant
- * [TEXT]
- */
- String LAST_NAME = "last_name";
-
- /**
- * Middle name of participant
- * [TEXT]
- */
- String MIDDLE_NAME = "middle_name";
-
- /**
- * Email of participant
- * [TEXT]
- */
- String EMAIL = "email";
-
- /**
- * GSM number of participant
- * [TEXT]
- */
- String GSM = "gsm";
-
- /**
- * Custom data json
- * [TEXT]
- */
- String CUSTOM_DATA = "custom_data";
- }
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/db/DatabaseHelperImpl.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/db/DatabaseHelperImpl.java
deleted file mode 100644
index 44e4026c..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/repository/db/DatabaseHelperImpl.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package org.infobip.mobile.messaging.chat.repository.db;
-
-import android.content.Context;
-import android.database.sqlite.SQLiteDatabase;
-import android.support.annotation.VisibleForTesting;
-
-import org.infobip.mobile.messaging.dal.sqlite.BaseDatabaseHelper;
-
-/**
- * @author sslavin
- * @since 09/10/2017.
- */
-
-public class DatabaseHelperImpl extends BaseDatabaseHelper {
-
- @VisibleForTesting
- static final int VER_2018_APR_24 = 1; // Initial version
- private static final int VER_CURRENT = VER_2018_APR_24;
-
- @SuppressWarnings("WeakerAccess")
- static final String DATABASE_NAME = "mm_infobip_database_chat.db";
-
- private static final String SQL_CREATE_CHAT_MESSAGES_TABLE = "CREATE TABLE " + ChatDatabaseContract.Tables.MESSAGES + " (" +
- ChatDatabaseContract.MessageColumns.ID + " TEXT PRIMARY KEY NOT NULL ON CONFLICT FAIL, " +
- ChatDatabaseContract.MessageColumns.CHAT_ID + " TEXT, " +
- ChatDatabaseContract.MessageColumns.BODY + " TEXT, " +
- ChatDatabaseContract.MessageColumns.RECEIVED_TIMESTAMP + " INTEGER, " +
- ChatDatabaseContract.MessageColumns.CREATED_TIMESTAMP + " INTEGER, " +
- ChatDatabaseContract.MessageColumns.READ_TIMESTAMP + " INTEGER, " +
- ChatDatabaseContract.MessageColumns.CATEGORY + " TEXT, " +
- ChatDatabaseContract.MessageColumns.CONTENT_URL + " TEXT, " +
- ChatDatabaseContract.MessageColumns.AUTHOR_ID + " TEXT, " +
- ChatDatabaseContract.MessageColumns.STATUS + " TEXT, " +
- ChatDatabaseContract.MessageColumns.CUSTOM_DATA + " TEXT," +
- ChatDatabaseContract.MessageColumns.YOURS + " INTEGER)";
-
- private static final String SQL_CREATE_CHAT_PARTICIPANTS_TABLE = "CREATE TABLE " + ChatDatabaseContract.Tables.PARTICIPANTS + " (" +
- ChatDatabaseContract.ParticipantColumns.ID + " TEXT PRIMARY KEY NOT NULL ON CONFLICT FAIL, " +
- ChatDatabaseContract.ParticipantColumns.FIRST_NAME + " TEXT, " +
- ChatDatabaseContract.ParticipantColumns.LAST_NAME + " TEXT, " +
- ChatDatabaseContract.ParticipantColumns.MIDDLE_NAME + " TEXT, " +
- ChatDatabaseContract.ParticipantColumns.EMAIL + " TEXT, " +
- ChatDatabaseContract.ParticipantColumns.GSM + " TEXT, " +
- ChatDatabaseContract.MessageColumns.CUSTOM_DATA + " TEXT)";
-
- public DatabaseHelperImpl(Context context) {
- super(context, DATABASE_NAME, VER_CURRENT);
- }
-
- @Override
- public void onCreate(SQLiteDatabase db) {
- db.beginTransaction();
- db.execSQL(SQL_CREATE_CHAT_MESSAGES_TABLE);
- db.execSQL(SQL_CREATE_CHAT_PARTICIPANTS_TABLE);
- db.setTransactionSuccessful();
- db.endTransaction();
- }
-
- @Override
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- // has single version now, do nothing
- }
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/view/ChatActivity.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/view/ChatActivity.java
deleted file mode 100644
index 200c4e0e..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/view/ChatActivity.java
+++ /dev/null
@@ -1,658 +0,0 @@
-package org.infobip.mobile.messaging.chat.view;
-
-import android.animation.Animator;
-import android.animation.AnimatorInflater;
-import android.annotation.SuppressLint;
-import android.app.NotificationManager;
-import android.app.ProgressDialog;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.graphics.PorterDuff;
-import android.graphics.drawable.ColorDrawable;
-import android.graphics.drawable.Drawable;
-import android.net.ConnectivityManager;
-import android.os.Bundle;
-import android.os.Handler;
-import android.support.design.widget.Snackbar;
-import android.support.v4.content.ContextCompat;
-import android.support.v4.content.LocalBroadcastManager;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.AlertDialog;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
-import android.text.Html;
-import android.text.TextUtils;
-import android.text.method.LinkMovementMethod;
-import android.util.TypedValue;
-import android.view.ActionMode;
-import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.AbsListView;
-import android.widget.AdapterView;
-import android.widget.EditText;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.ListView;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import org.infobip.mobile.messaging.Message;
-import org.infobip.mobile.messaging.MobileMessaging;
-import org.infobip.mobile.messaging.MobileMessagingCore;
-import org.infobip.mobile.messaging.User;
-import org.infobip.mobile.messaging.chat.ChatMessage;
-import org.infobip.mobile.messaging.chat.ChatMessageStorage;
-import org.infobip.mobile.messaging.chat.ChatParticipant;
-import org.infobip.mobile.messaging.chat.R;
-import org.infobip.mobile.messaging.chat.core.MobileChatImpl;
-import org.infobip.mobile.messaging.chat.properties.MobileChatProperty;
-import org.infobip.mobile.messaging.chat.properties.PropertyHelper;
-import org.infobip.mobile.messaging.interactive.NotificationAction;
-import org.infobip.mobile.messaging.mobile.MobileMessagingError;
-import org.infobip.mobile.messaging.mobile.Result;
-import org.infobip.mobile.messaging.mobile.common.MAsyncTask;
-import org.infobip.mobile.messaging.util.StringUtils;
-import org.json.JSONObject;
-
-import static org.infobip.mobile.messaging.BroadcastParameter.EXTRA_EXCEPTION;
-import static org.infobip.mobile.messaging.Event.API_COMMUNICATION_ERROR;
-import static org.infobip.mobile.messaging.chat.ChatEvent.CHAT_MESSAGE_RECEIVED;
-
-public class ChatActivity extends AppCompatActivity implements ChatAdapter.ActionTappedReceiver {
-
- public static final String MESSAGE_TEXT_EXTRA = "messageText";
-
- public static final String MO_ROUTE_NOT_ENABLED_ERROR_CODE = "14";
- public static final int CONNECTIVITY_ANIMATION_DELAY_MILLIS = 4000;
- public static final int CLEAR_NOTIFICATIONS_DELAY_MILLIS = 3000;
-
- private EditText etReply;
- private ListView messagesListView;
- private TextView connectionIndicatorView;
- private ChatAdapter listAdapter = null;
- private ChatViewSettingsResolver chatViewSettingsResolver;
- private ChatMessageStorage messageStore;
- private MobileChatImpl mobileChat;
- private boolean receiversRegistered = false;
- private boolean inForeground = false;
- private ActionMode actionMode;
- private Boolean internetConnected = null;
-
- private Handler handler;
- private Runnable clearNotificationsRunnable;
- private Runnable connectivityRunnable;
-
- private PropertyHelper propertyHelper;
- private ProgressDialog progressDialog;
-
- private final BroadcastReceiver messageReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- ChatMessage message = ChatMessage.createFrom(intent);
-
- onMessageReceived(message);
- listAdapter.notifyDataSetChanged();
-
- if (inForeground) {
- clearNotificationsWithDelay();
- }
- }
- };
- private final BroadcastReceiver connectivityReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- if (intent.hasExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY)) {
- handleNotConnectedState(context);
- } else {
- handleConnectedState();
- }
- }
- };
-
- private void handleNotConnectedState(Context context) {
- if (messagesListView != null) {
- Snackbar noConnectivitySnackbar = Snackbar.make(messagesListView, R.string.no_internet_connection, Snackbar.LENGTH_SHORT);
- noConnectivitySnackbar.show();
- }
-
- if (connectionIndicatorView != null) {
- connectionIndicatorView.setBackgroundColor(ContextCompat.getColor(context, R.color.connectivityStateColor));
- connectionIndicatorView.setText(R.string.no_connection);
- connectionIndicatorView.setVisibility(View.VISIBLE);
- }
- internetConnected = false;
- }
-
- private void handleConnectedState() {
- if (connectionIndicatorView != null && internetConnected != null && !internetConnected) {
- Animator animator = AnimatorInflater.loadAnimator(ChatActivity.this, R.animator.connectivity_state);
- animator.setTarget(connectionIndicatorView);
- animator.start();
- connectionIndicatorView.setText(R.string.connected);
- }
-
- connectivityRunnable = new Runnable() {
- @Override
- public void run() {
- if (connectionIndicatorView != null) {
- connectionIndicatorView.setVisibility(View.GONE);
- }
- }
- };
- handler.postDelayed(connectivityRunnable, CONNECTIVITY_ANIMATION_DELAY_MILLIS);
- internetConnected = true;
- }
-
- private void clearNotificationsWithDelay() {
- if (actionMode == null) {
- // fix for reported bug that chat notification isn't canceled when user is on the chat screen
- // we need notification displayed event in lib for this delayed behaviour to be changed
- if (clearNotificationsRunnable == null) {
- clearNotificationsRunnable = new Runnable() {
- @Override
- public void run() {
- clearNotifications();
- }
- };
- }
- handler.postDelayed(clearNotificationsRunnable, CLEAR_NOTIFICATIONS_DELAY_MILLIS);
- }
- }
-
- private final BroadcastReceiver errorReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- MobileMessagingError mobileMessagingError = null;
- if (intent.hasExtra(EXTRA_EXCEPTION)) {
- mobileMessagingError = (MobileMessagingError) intent.getSerializableExtra(EXTRA_EXCEPTION);
- }
-
- if (mobileMessagingError == null) {
- return;
- }
-
- if (MO_ROUTE_NOT_ENABLED_ERROR_CODE.equals(mobileMessagingError.getCode())) {
- showMoRouteNotEnabledDialog();
- }
- }
- };
-
- protected void onMessageReceived(ChatMessage message) {
- String body = message.getBody();
- if (StringUtils.isBlank(message.getCategory())) {
- Toast.makeText(this, String.format(getString(R.string.toast_message_received), body), Toast.LENGTH_LONG).show();
- }
-
- configureEmptyState();
- if (listAdapter != null) {
- listAdapter.notifyDataSetChanged();
- scrollToBottom();
- }
- }
-
- private void showMoRouteNotEnabledDialog() {
- AlertDialog.Builder alertDialogBuilderUserInput = new AlertDialog.Builder(ChatActivity.this);
- alertDialogBuilderUserInput
- .setCancelable(true)
- .setMessage(getString(R.string.dialog_text_mo_route_not_enabled))
- .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- dialogInterface.cancel();
- }
- });
- AlertDialog alertDialog = alertDialogBuilderUserInput.create();
- alertDialog.show();
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- chatViewSettingsResolver = new ChatViewSettingsResolver(this);
- setTheme(chatViewSettingsResolver.getChatViewTheme());
-
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_chat);
- Toolbar toolbar = findViewById(R.id.toolbar);
- setUpToolbar(toolbar, chatViewSettingsResolver.getChatViewTitle(), true);
-
- mobileChat = (MobileChatImpl) MobileChatImpl.getInstance(this);
- messageStore = mobileChat.getChatMessageStorage();
- configureEmptyState();
-
- propertyHelper = new PropertyHelper(this);
-
- etReply = findViewById(R.id.et_reply);
- ImageView ivReply = findViewById(R.id.iv_reply);
- messagesListView = findViewById(R.id.messagesListView);
- connectionIndicatorView = findViewById(R.id.connection_indicator);
-
- LinearLayout llEmptyState = findViewById(R.id.ll_empty_state);
- messagesListView.setEmptyView(llEmptyState);
-
- messagesListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
- @Override
- public boolean onItemLongClick(AdapterView> parent, View view, int position, long id) {
- messagesListView.setItemChecked(position, !messagesListView.isItemChecked(position));
- return true;
- }
- });
-
- messagesListView.setMultiChoiceModeListener(new ChatMultiChoiceModeListener());
- messagesListView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
-
- listAdapter = new ChatAdapter(this, mobileChat.chatView().getNotificationCategories(), messageStore.findAllMessages(), this);
- messagesListView.setAdapter(listAdapter);
- messageStore.registerListener(listAdapter);
-
- if (ivReply != null) {
- ivReply.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (TextUtils.isEmpty(getUserNameFromAuthor()) ||
- !propertyHelper.findBoolean(MobileChatProperty.USER_NAME_DIALOG_SHOWN)) {
- showUserNameInputDialog();
- } else {
- sendMessage();
- }
- }
- });
- }
-
- handler = new Handler();
-
- registerReceivers();
- scrollToBottom();
-
- processSendRequestIfAny(getIntent());
- }
-
- @Override
- protected void onDestroy() {
- unregisterReceivers();
- messageStore.unregisterListener(listAdapter);
- if (handler != null) {
- if (clearNotificationsRunnable != null) {
- handler.removeCallbacks(clearNotificationsRunnable);
- }
- if (connectivityRunnable != null) {
- handler.removeCallbacks(connectivityRunnable);
- }
- }
- super.onDestroy();
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- inForeground = true;
- if (listAdapter != null) {
- listAdapter.notifyDataSetChanged();
- }
- if (actionMode == null) {
- clearNotifications();
- }
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- inForeground = false;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- int id = item.getItemId();
-
- if (id == android.R.id.home) {
- onBackPressed();
- return true;
- }
-
- if (id == R.id.action_mark_all_seen) {
- markAllSeen();
- return true;
- }
-
- if (id == R.id.action_clear_chat) {
- clearChatHistory();
- return true;
- }
-
- return super.onOptionsItemSelected(item);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.menu_chat, menu);
- return true;
- }
-
- @Override
- public void actionTapped(ChatMessage message, NotificationAction action) {
- mobileChat.processTappedAction(message, action);
- }
-
- private void processSendRequestIfAny(Intent intent) {
- final String text = intent.getStringExtra(MESSAGE_TEXT_EXTRA);
- if (TextUtils.isEmpty(text)) {
- return;
- }
-
- etReply.setText(text);
- etReply.setSelection(text.length());
- etReply.requestFocus();
-
- if (TextUtils.isEmpty(getUserNameFromAuthor()) ||
- !propertyHelper.findBoolean(MobileChatProperty.USER_NAME_DIALOG_SHOWN)) {
- showUserNameInputDialog();
- } else {
- sendMessage();
- }
- }
-
- protected void markAllSeen() {
-
- new MAsyncTask() {
-
- ProgressDialog progressDialog;
-
- @Override
- public void before() {
- progressDialog = ProgressDialog.show(ChatActivity.this, getString(R.string.progress_title_wait), getString(R.string.progress_processing_messages), true);
- }
-
- @Override
- public Void run(Void... params) {
- mobileChat.markAllMessagesRead();
- return null;
- }
-
- @Override
- public void after(Void aVoid) {
- progressDialog.dismiss();
- }
- }.execute();
- }
-
- protected void clearChatHistory() {
- if (messageStore != null) {
- messageStore.deleteAll();
- }
- configureEmptyState();
- if (listAdapter != null) {
- listAdapter.notifyDataSetChanged();
- }
- clearNotifications();
- }
-
- private void onMessageSent(ChatMessage message) {
- if (message.getStatus() == Message.Status.SUCCESS) {
- Toast.makeText(ChatActivity.this, R.string.message_sent, Toast.LENGTH_SHORT).show();
- }
-
- if (listAdapter != null) {
- listAdapter.notifyDataSetChanged();
- }
- }
-
- private void sendMessage() {
- String text = etReply.getText().toString();
- if (text.trim().length() == 0) {
- return;
- }
-
- mobileChat.sendMessage(text, new JSONObject(), new MobileMessaging.ResultListener() {
- @Override
- public void onResult(Result result) {
- if (result.isSuccess()) {
- if (internetConnected != null && !internetConnected) {
- showToast(R.string.sending_message_failed_no_connection);
- }
-
- onMessageSent(result.getData());
- scrollToBottom();
- }
- }
- });
-
- configureEmptyState();
- if (listAdapter != null) {
- listAdapter.notifyDataSetChanged();
- scrollToBottom();
- }
-
- etReply.setText("");
- }
-
- private void scrollToBottom() {
- if (messagesListView == null) {
- return;
- }
-
- messagesListView.post(new Runnable() {
- @Override
- public void run() {
- if (listAdapter != null && !listAdapter.isEmpty()) {
- messagesListView.setSelection(listAdapter.getCount() - 1);
- }
- }
- });
- }
-
- protected void registerReceivers() {
- if (!receiversRegistered) {
- LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(this);
- localBroadcastManager.registerReceiver(errorReceiver, new IntentFilter(API_COMMUNICATION_ERROR.getKey()));
- localBroadcastManager.registerReceiver(messageReceiver, new IntentFilter(CHAT_MESSAGE_RECEIVED.getKey()));
- registerReceiver(connectivityReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
- receiversRegistered = true;
- }
- }
-
- protected void unregisterReceivers() {
- if (receiversRegistered) {
- LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(this);
- localBroadcastManager.unregisterReceiver(errorReceiver);
- localBroadcastManager.unregisterReceiver(messageReceiver);
- unregisterReceiver(connectivityReceiver);
- receiversRegistered = false;
- }
- }
-
- protected void clearNotifications() {
- NotificationManager notificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
- if (notificationManager != null) notificationManager.cancelAll();
- }
-
- private void showUserNameInputDialog() {
- User user = MobileMessagingCore.getInstance(this).getUser();
- if (user != null) {
- String firstName = user.getFirstName();
- String lastName = user.getLastName();
-
- if (StringUtils.isNotBlank(firstName) || StringUtils.isNotBlank(lastName)) {
- createChatParticipantAndSendMessage(firstName, lastName);
- return;
- }
- }
-
- LayoutInflater inflater = LayoutInflater.from(this);
- @SuppressLint("InflateParams")
- View mView = inflater.inflate(R.layout.username_dialog, null);
- AlertDialog.Builder alertDialogBuilderUserInput = new AlertDialog.Builder(this);
- alertDialogBuilderUserInput.setView(mView);
-
- final EditText etUserName = mView.findViewById(R.id.etUserName);
- etUserName.setText(getUserNameFromAuthor());
- alertDialogBuilderUserInput
- .setCancelable(false)
- .setNegativeButton(android.R.string.cancel, null)
- .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogBox, int id) {
- dialogBox.dismiss();
- showProgressDialog(getString(R.string.progress_title_wait));
-
- String userName = etUserName.getText().toString();
-
- createChatParticipantAndSendMessage(userName, null);
- }
- });
-
- AlertDialog alertDialogAndroid = alertDialogBuilderUserInput.create();
- alertDialogAndroid.show();
- }
-
- void createChatParticipantAndSendMessage(String firstName, String lastName) {
- ChatParticipant chatParticipant = mobileChat.getUserInfo();
- chatParticipant.setFirstName(firstName);
- if (StringUtils.isNotBlank(lastName)) {
- chatParticipant.setLastName(lastName);
- }
- chatParticipant.setCustomData(new JSONObject());
-
- mobileChat.setUserInfo(chatParticipant, new MobileMessaging.ResultListener() {
- @Override
- public void onResult(Result result) {
- if (!result.isSuccess()) {
- hideProgressDialog();
- Toast.makeText(ChatActivity.this, result.getError().getMessage(), Toast.LENGTH_SHORT).show();
- return;
- }
-
- propertyHelper.saveBoolean(MobileChatProperty.USER_NAME_DIALOG_SHOWN, true);
- sendMessage();
- hideProgressDialog();
- }
- });
- }
-
- String getUserNameFromAuthor() {
- ChatParticipant author = mobileChat.getUserInfo();
- return author.getUserName();
- }
-
- private class ChatMultiChoiceModeListener implements AbsListView.MultiChoiceModeListener {
- @Override
- public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
- final int checkedCount = messagesListView.getCheckedItemCount();
-
- mode.setTitle(String.format(getString(R.string.chat_selected), checkedCount));
- }
-
- @Override
- public boolean onCreateActionMode(ActionMode mode, Menu menu) {
- actionMode = mode;
- ChatActivity.this.getMenuInflater().inflate(R.menu.menu_chat_item, menu);
- return true;
- }
-
- @Override
- public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
- return false;
- }
-
- @Override
- public boolean onActionItemClicked(ActionMode mode, MenuItem menuItem) {
- if (menuItem.getItemId() == R.id.action_delete) {
- for (int i = 0; i < messagesListView.getCount(); i++) {
- if (messagesListView.isItemChecked(i)) {
- messageStore.delete(listAdapter.getItem(i).getId());
- }
- }
- }
- actionMode.finish();
- configureEmptyState();
- return true;
- }
-
- @Override
- public void onDestroyActionMode(ActionMode mode) {
- actionMode = null;
- listAdapter.notifyDataSetChanged();
- clearNotifications();
- }
- }
-
- protected void showProgressDialog(String message) {
- if (progressDialog == null) {
- progressDialog = new ProgressDialog(this);
- }
- progressDialog.setMessage(message);
- progressDialog.show();
- }
-
- protected void hideProgressDialog() {
- if (progressDialog != null) {
- progressDialog.dismiss();
- }
- }
-
- protected void showToast(int resId) {
- showToast(getString(resId));
- }
-
- protected void showToast(String text) {
- Toast.makeText(this, text, Toast.LENGTH_LONG).show();
- }
-
- protected void setUpToolbar(Toolbar toolbar, String title, boolean displayHomeAsUpEnabled) {
- if (toolbar == null) return;
-
- setSupportActionBar(toolbar);
- ActionBar supportActionBar = getSupportActionBar();
- if (supportActionBar != null) {
- supportActionBar.setTitle("");
-
- TypedValue colorValue = new TypedValue();
- getTheme().resolveAttribute(R.attr.colorPrimary, colorValue, true);
- supportActionBar.setBackgroundDrawable(new ColorDrawable(colorValue.data));
-
- if (title != null) {
- setToolbarTitle(title);
- }
-
- if (displayHomeAsUpEnabled) {
- supportActionBar.setDisplayHomeAsUpEnabled(true);
-
- // set back arrow color to white
- Drawable drawable = toolbar.getNavigationIcon();
- if (drawable != null) {
- drawable.setColorFilter(ContextCompat.getColor(this, android.R.color.white), PorterDuff.Mode.SRC_ATOP);
- }
- } else {
- toolbar.setNavigationIcon(R.drawable.ic_menu_white);
- }
- }
- }
-
- protected void setToolbarTitle(String title) {
- TextView tvTitle = findViewById(R.id.tv_toolbar_title);
- if (tvTitle == null) {
- return;
- }
- tvTitle.setText(title);
- }
-
- private void configureEmptyState() {
- TextView tv = findViewById(R.id.tv_empty_state);
- RelativeLayout rl = findViewById(R.id.rl_chat_messages);
- if (messageStore.countAllMessages() == 0) {
- tv.setVisibility(View.VISIBLE);
- tv.setText(Html.fromHtml(chatViewSettingsResolver.getChatViewEmptyStateText()));
- tv.setClickable(true);
- tv.setMovementMethod(LinkMovementMethod.getInstance());
- rl.setVisibility(View.GONE);
- } else {
- tv.setVisibility(View.GONE);
- rl.setVisibility(View.VISIBLE);
- }
- }
-}
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/view/ChatAdapter.java b/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/view/ChatAdapter.java
deleted file mode 100644
index fa03df58..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/view/ChatAdapter.java
+++ /dev/null
@@ -1,237 +0,0 @@
-package org.infobip.mobile.messaging.chat.view;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.annotation.VisibleForTesting;
-import android.text.TextUtils;
-import android.text.format.DateUtils;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.Button;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import org.infobip.mobile.messaging.Message.Status;
-import org.infobip.mobile.messaging.chat.ChatMessage;
-import org.infobip.mobile.messaging.chat.ChatMessageStorage;
-import org.infobip.mobile.messaging.chat.ChatParticipant;
-import org.infobip.mobile.messaging.chat.R;
-import org.infobip.mobile.messaging.interactive.NotificationAction;
-import org.infobip.mobile.messaging.interactive.NotificationCategory;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static android.support.annotation.VisibleForTesting.PACKAGE_PRIVATE;
-
-public class ChatAdapter extends BaseAdapter implements ChatMessageStorage.Listener {
-
- private static final int MAX_ACTION_BUTTONS_IN_MESSAGE = 3;
-
- private final Context context;
- private final List messages = new ArrayList<>();
- private final Map> notificationActions = new HashMap<>();
- private final ActionTappedReceiver actionTappedReceiver;
-
- public interface ActionTappedReceiver {
- void actionTapped(ChatMessage message, NotificationAction action);
- }
-
- @VisibleForTesting(otherwise = PACKAGE_PRIVATE)
- public ChatAdapter(Context context, Set notificationCategories, List existingMessages, ActionTappedReceiver actionTappedReceiver) {
- this.context = context;
- this.messages.addAll(existingMessages);
- this.actionTappedReceiver = actionTappedReceiver;
-
- for (NotificationCategory category : notificationCategories) {
- List actions = new ArrayList<>(category.getNotificationActions().length);
- for (NotificationAction action : category.getNotificationActions()) {
- if (!action.hasInput()) {
- actions.add(action);
- }
- }
- actions = actions.subList(0, Math.min(actions.size(), MAX_ACTION_BUTTONS_IN_MESSAGE));
- notificationActions.put(category.getCategoryId(), actions);
- }
- }
-
- @Override
- public int getCount() {
- return messages.size();
- }
-
- @Override
- public ChatMessage getItem(int position) {
- return messages.get(position);
- }
-
- @Override
- public long getItemId(int position) {
- return position;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- ChatMessage message = messages.get(position);
- View view = initViewHolder(convertView, message.isYours());
- fillView(view, message);
- return view;
- }
-
- @Override
- public int getViewTypeCount() {
- return 2;
- }
-
- @Override
- public int getItemViewType(int position) {
- ChatMessage message = messages.get(position);
- return message.isYours() ? 1 : 0;
- }
-
- @Override
- public void onNew(ChatMessage message) {
- messages.add(message);
- Collections.sort(messages);
- notifyDataSetChanged();
- }
-
- @Override
- public void onUpdated(ChatMessage message) {
- int position = getPosition(message.getId());
- if (position >= 0) {
- messages.set(position, message);
- } else {
- messages.add(message);
- }
- Collections.sort(messages);
- notifyDataSetChanged();
- }
-
- @Override
- public void onDeleted(String messageId) {
- int position = getPosition(messageId);
- if (position >= 0) {
- messages.remove(position);
- notifyDataSetChanged();
- }
- }
-
- @Override
- public void onAllDeleted() {
- messages.clear();
- notifyDataSetChanged();
- }
-
- // region private methods
-
- private static class ViewHolder {
- private ImageView messageStatus;
- private TextView messageTextView;
- private TextView timeTextView;
- private TextView senderTextView;
- private Button[] buttons;
- }
-
- private String getUserName(ChatMessage message) {
- if (message == null || message.getAuthor() == null) {
- return "";
- }
-
- ChatParticipant author = message.getAuthor();
- return author.getUserName();
- }
-
- private int getPosition(String messageId) {
- for (int position = 0; position < messages.size(); position++) {
- if (messages.get(position).getId().equalsIgnoreCase(messageId)) {
- return position;
- }
- }
- return -1;
- }
-
- @SuppressLint("InflateParams")
- @NonNull
- private View initViewHolder(@Nullable View convertView, boolean isYours) {
- if (convertView != null) {
- return convertView;
- }
-
- View view;
- if (isYours) {
- view = LayoutInflater.from(context).inflate(R.layout.list_item_chat_message_outgoing, null, false);
- ViewHolder holder = new ViewHolder();
- holder.messageTextView = view.findViewById(R.id.message_text);
- holder.timeTextView = view.findViewById(R.id.time_text);
- holder.messageStatus = view.findViewById(R.id.user_reply_status);
- view.setTag(holder);
- } else {
- view = LayoutInflater.from(context).inflate(R.layout.list_item_chat_message_incoming, null, false);
- ViewHolder holder = new ViewHolder();
- holder.messageTextView = view.findViewById(R.id.message_text);
- holder.timeTextView = view.findViewById(R.id.time_text);
- holder.senderTextView = view.findViewById(R.id.chat_company_reply_author);
- holder.buttons = new Button[]{view.findViewById(R.id.btn_action_1), view.findViewById(R.id.btn_action_2), view.findViewById(R.id.btn_action_3)};
- view.setTag(holder);
- }
- return view;
- }
-
- private void fillView(@NonNull View view, final ChatMessage message) {
- ViewHolder holder = (ViewHolder) view.getTag();
- if (message.isYours()) {
- holder.messageTextView.setText(message.getBody());
- holder.timeTextView.setText(DateUtils.getRelativeTimeSpanString(context, message.getCreatedAt()));
-
- if (message.getStatus() == Status.UNKNOWN) {
- holder.messageStatus.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_clock));
- } else if (message.getStatus() == Status.SUCCESS) {
- holder.messageStatus.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_single_tick));
- } else {
- holder.messageStatus.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_error));
- }
- } else {
- holder.messageTextView.setText(message.getBody());
- holder.timeTextView.setText(DateUtils.getRelativeTimeSpanString(context, message.getCreatedAt()));
-
- String userName = getUserName(message);
- if (!TextUtils.isEmpty(userName)) {
- holder.senderTextView.setText(userName);
- holder.senderTextView.setVisibility(View.VISIBLE);
- } else {
- holder.senderTextView.setVisibility(View.GONE);
- }
-
- List actions = notificationActions.get(message.getCategory());
- if (actions == null) actions = Collections.emptyList();
- for (int index = 0; index < holder.buttons.length; index++) {
- final NotificationAction action = index < actions.size() ? actions.get(index) : null;
- if (action != null) {
- holder.buttons[index].setVisibility(View.VISIBLE);
- holder.buttons[index].setText(action.getTitleResourceId());
- holder.buttons[index].setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (actionTappedReceiver != null) {
- actionTappedReceiver.actionTapped(message, action);
- }
- }
- });
- } else {
- holder.buttons[index].setVisibility(View.GONE);
- }
- }
- }
- }
-
- // endregion
-}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/res/animator/connectivity_state.xml b/infobip-mobile-messaging-android-chat-sdk/src/main/res/animator/connectivity_state.xml
deleted file mode 100644
index 56fa9e2e..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/res/animator/connectivity_state.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/res/drawable-xxhdpi/balloon_incoming_normal.9.png b/infobip-mobile-messaging-android-chat-sdk/src/main/res/drawable-xxhdpi/balloon_incoming_normal.9.png
deleted file mode 100644
index c9a3f766..00000000
Binary files a/infobip-mobile-messaging-android-chat-sdk/src/main/res/drawable-xxhdpi/balloon_incoming_normal.9.png and /dev/null differ
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/res/drawable-xxhdpi/balloon_outgoing_normal.9.png b/infobip-mobile-messaging-android-chat-sdk/src/main/res/drawable-xxhdpi/balloon_outgoing_normal.9.png
deleted file mode 100644
index 31b56706..00000000
Binary files a/infobip-mobile-messaging-android-chat-sdk/src/main/res/drawable-xxhdpi/balloon_outgoing_normal.9.png and /dev/null differ
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/res/drawable-xxhdpi/ic_chat_send.png b/infobip-mobile-messaging-android-chat-sdk/src/main/res/drawable-xxhdpi/ic_chat_send.png
deleted file mode 100644
index fb8fa3c7..00000000
Binary files a/infobip-mobile-messaging-android-chat-sdk/src/main/res/drawable-xxhdpi/ic_chat_send.png and /dev/null differ
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/res/drawable-xxhdpi/ic_error.png b/infobip-mobile-messaging-android-chat-sdk/src/main/res/drawable-xxhdpi/ic_error.png
deleted file mode 100644
index fccac99a..00000000
Binary files a/infobip-mobile-messaging-android-chat-sdk/src/main/res/drawable-xxhdpi/ic_error.png and /dev/null differ
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/res/drawable-xxhdpi/ic_single_tick.png b/infobip-mobile-messaging-android-chat-sdk/src/main/res/drawable-xxhdpi/ic_single_tick.png
deleted file mode 100644
index c5611e1e..00000000
Binary files a/infobip-mobile-messaging-android-chat-sdk/src/main/res/drawable-xxhdpi/ic_single_tick.png and /dev/null differ
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/res/drawable/ic_clock.xml b/infobip-mobile-messaging-android-chat-sdk/src/main/res/drawable/ic_clock.xml
deleted file mode 100644
index 9c506de3..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/res/drawable/ic_clock.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/res/layout/activity_chat.xml b/infobip-mobile-messaging-android-chat-sdk/src/main/res/layout/activity_chat.xml
deleted file mode 100644
index 2d3e0caf..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/res/layout/activity_chat.xml
+++ /dev/null
@@ -1,119 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/res/layout/list_item_chat_message_incoming.xml b/infobip-mobile-messaging-android-chat-sdk/src/main/res/layout/list_item_chat_message_incoming.xml
deleted file mode 100644
index 7e208bb5..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/res/layout/list_item_chat_message_incoming.xml
+++ /dev/null
@@ -1,115 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/res/layout/list_item_chat_message_outgoing.xml b/infobip-mobile-messaging-android-chat-sdk/src/main/res/layout/list_item_chat_message_outgoing.xml
deleted file mode 100644
index 407bc87a..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/res/layout/list_item_chat_message_outgoing.xml
+++ /dev/null
@@ -1,83 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/res/layout/username_dialog.xml b/infobip-mobile-messaging-android-chat-sdk/src/main/res/layout/username_dialog.xml
deleted file mode 100644
index 7b1c64cd..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/res/layout/username_dialog.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/res/menu/menu_chat.xml b/infobip-mobile-messaging-android-chat-sdk/src/main/res/menu/menu_chat.xml
deleted file mode 100644
index 60f31f95..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/res/menu/menu_chat.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/res/menu/menu_chat_item.xml b/infobip-mobile-messaging-android-chat-sdk/src/main/res/menu/menu_chat_item.xml
deleted file mode 100644
index 5073b6d3..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/res/menu/menu_chat_item.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/res/values/strings.xml b/infobip-mobile-messaging-android-chat-sdk/src/main/res/values/strings.xml
deleted file mode 100644
index f8919d2f..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
- Connected
- No connection
- No internet connection
- Chat demo is not available for your account. Please contact your account manager.
- Type a message…
- Please wait
- Processing messages…
- Message sent
- Failed to send a message. No internet connection
- Enter your name
- %d Selected
- Delete
- User name
- Message text
- 12:31
-
-
- Clear Chat
- Mark All as Seen
-
-
- Message received: %s
- Send message
-
-
- Chat
- Welcome to in-app messaging.\nAll incoming and outgoing messages will appear on this screen.\nVisit Infobip website]]> for more details.
-
-
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/res/values/styles.xml b/infobip-mobile-messaging-android-chat-sdk/src/main/res/values/styles.xml
deleted file mode 100644
index 70c640be..00000000
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
diff --git a/infobip-mobile-messaging-android-demo/src/chat/java/org/infobip/mobile/messaging/demo/ChatMessagesAdapter.java b/infobip-mobile-messaging-android-demo/src/chat/java/org/infobip/mobile/messaging/demo/ChatMessagesAdapter.java
deleted file mode 100644
index 958eb0ee..00000000
--- a/infobip-mobile-messaging-android-demo/src/chat/java/org/infobip/mobile/messaging/demo/ChatMessagesAdapter.java
+++ /dev/null
@@ -1,122 +0,0 @@
-package org.infobip.mobile.messaging.demo;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.support.annotation.NonNull;
-import android.support.v7.widget.RecyclerView;
-import android.support.v7.widget.RecyclerView.Adapter;
-import android.text.format.DateUtils;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-import org.infobip.mobile.messaging.chat.ChatMessage;
-import org.infobip.mobile.messaging.chat.ChatMessageStorage;
-
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * @author sslavin
- * @since 14/11/2017.
- */
-
-public class ChatMessagesAdapter extends Adapter implements ChatMessageStorage.Listener {
-
- private final Context context;
- private final List messages = new LinkedList<>();
-
- ChatMessagesAdapter(@NonNull Context context, @NonNull List initialMessages) {
- this.context = context;
- messages.addAll(initialMessages);
- Collections.sort(messages);
- }
-
- @Override
- public int getItemCount() {
- return messages.size();
- }
-
- @SuppressLint("InflateParams")
- @Override
- public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int isYours) {
- ViewHolder holder;
- View v = LayoutInflater.from(context)
- .inflate(isYours == 1 ? R.layout.list_item_message_outgoing : R.layout.list_item_message_incoming,
- null, false);
- holder = new ViewHolder(v);
- holder.tvMessageText = v.findViewById(R.id.tv_message_text);
- holder.tvReceivedTime = v.findViewById(R.id.tv_timestamp);
- return holder;
- }
-
- @Override
- public void onBindViewHolder(ViewHolder viewHolder, int position) {
- ChatMessage message = messages.get(position);
- viewHolder.tvMessageText.setText(message.getBody());
- viewHolder.tvReceivedTime.setText(DateUtils.getRelativeTimeSpanString(context, message.getReceivedAt()));
- }
-
- @Override
- public int getItemViewType(int position) {
- return messages.get(position).isYours() ? 1 : 0;
- }
-
- @Override
- public void onNew(ChatMessage message) {
- messages.add(message);
- Collections.sort(messages);
- notifyDataSetChanged();
- }
-
- @Override
- public void onUpdated(ChatMessage message) {
- int position = getPosition(message.getId());
- if (position >= 0) {
- messages.set(position, message);
- } else {
- messages.add(message);
- }
- Collections.sort(messages);
- notifyDataSetChanged();
- }
-
- @Override
- public void onDeleted(String messageId) {
- int position = getPosition(messageId);
- if (position >= 0) {
- messages.remove(position);
- }
- }
-
- @Override
- public void onAllDeleted() {
- messages.clear();
- notifyDataSetChanged();
- }
-
- // region private methods
-
- private int getPosition(String messageId) {
- for (int postion = 0; postion < messages.size(); postion++) {
- if (messages.get(postion).getId().equalsIgnoreCase(messageId)) {
- return postion;
- }
- }
- return -1;
- }
-
- @SuppressWarnings("WeakerAccess")
- public static class ViewHolder extends RecyclerView.ViewHolder {
- TextView tvMessageText;
- TextView tvReceivedTime;
-
- public ViewHolder(View itemView) {
- super(itemView);
- }
- }
-
- // endregion
-}
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-demo/src/chat/res/layout/activity_main.xml b/infobip-mobile-messaging-android-demo/src/chat/res/layout/activity_main.xml
deleted file mode 100644
index 97ff2a58..00000000
--- a/infobip-mobile-messaging-android-demo/src/chat/res/layout/activity_main.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-demo/src/chat/res/layout/list_item_message_incoming.xml b/infobip-mobile-messaging-android-demo/src/chat/res/layout/list_item_message_incoming.xml
deleted file mode 100644
index 4bd6286c..00000000
--- a/infobip-mobile-messaging-android-demo/src/chat/res/layout/list_item_message_incoming.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-demo/src/chat/res/layout/list_item_message_outgoing.xml b/infobip-mobile-messaging-android-demo/src/chat/res/layout/list_item_message_outgoing.xml
deleted file mode 100644
index 54ca1294..00000000
--- a/infobip-mobile-messaging-android-demo/src/chat/res/layout/list_item_message_outgoing.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-demo/src/main/res/values/strings.xml b/infobip-mobile-messaging-android-demo/src/main/res/values/strings.xml
deleted file mode 100644
index 793e61af..00000000
--- a/infobip-mobile-messaging-android-demo/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- Mobile Messaging Example
-
diff --git a/infobip-mobile-messaging-android-resources/build.gradle b/infobip-mobile-messaging-android-resources/build.gradle
deleted file mode 100644
index 625da622..00000000
--- a/infobip-mobile-messaging-android-resources/build.gradle
+++ /dev/null
@@ -1,117 +0,0 @@
-buildscript {
- repositories {
- jcenter()
- maven {
- url 'https://maven.google.com/'
- name 'Google'
- }
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:3.5.3'
- classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
- classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
- }
-}
-
-apply plugin: 'com.android.library'
-apply plugin: 'com.github.dcendents.android-maven'
-apply plugin: 'idea'
-apply plugin: 'com.jfrog.bintray'
-
-android {
- compileSdkVersion mm_compileSdkVersion
- buildToolsVersion mm_buildToolsVersion
-
- defaultConfig {
- minSdkVersion mm_minSdkVersion
- targetSdkVersion mm_targetSdkVersion
- versionCode 1
- versionName project.version
- consumerProguardFiles 'proguard-rules.pro'
- }
-
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
-
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_7
- targetCompatibility JavaVersion.VERSION_1_7
- }
-
- lintOptions {
- abortOnError false
- }
-}
-
-android.libraryVariants.all { variant ->
- def name = variant.buildType.name
- def jar = project.tasks.create(name: "jar${name.capitalize()}", type: Jar) {
- Task javaCompileTask
- if (variant.hasProperty('javaCompileProvider')) {
- // Android 3.3.0+
- javaCompileTask = variant.javaCompileProvider.get()
- } else {
- javaCompileTask = variant.javaCompile
- }
-
- dependsOn javaCompileTask
- from javaCompileTask.destinationDir
-
- manifest {
- attributes(
- "Bundle-Name": 'parse-android',
- "Bundle-Version": project.version
- )
- }
-
- exclude '**/R.class'
- exclude '**/R\$*.class'
- exclude '**/Manifest.class'
- exclude '**/Manifest\$*.class'
- exclude '**/BuildConfig.class'
- }
-
- artifacts {
- archives jar
- }
-}
-
-bintray {
- user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
- key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
- configurations = ['archives']
- publish = true
- pkg {
- repo = 'maven'
- name = project.name
- userOrg = 'infobip'
- vcsUrl = "https://github.com/infobip/mobile-messaging-sdk-android"
- licenses = ['Apache-2.0']
- labels = ['aar', 'android']
- }
-}
-task sourcesJar(type: Jar) {
- from android.sourceSets.main.java.srcDirs
- archiveClassifier.set('sources')
-}
-
-task javadoc(type: Javadoc) {
- failOnError false
- source = android.sourceSets.main.java.srcDirs
- classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
-}
-
-task javadocJar(type: Jar, dependsOn: javadoc) {
- archiveClassifier.set('javadoc')
- from javadoc.destinationDir
-}
-
-artifacts {
- archives javadocJar
- archives sourcesJar
-}
-
diff --git a/infobip-mobile-messaging-android-resources/proguard-rules.pro b/infobip-mobile-messaging-android-resources/proguard-rules.pro
deleted file mode 100644
index 25f71ae3..00000000
--- a/infobip-mobile-messaging-android-resources/proguard-rules.pro
+++ /dev/null
@@ -1,25 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /Users/tjuric/Library/Android/sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
-
-# Uncomment this to preserve the line number information for
-# debugging stack traces.
-#-keepattributes SourceFile,LineNumberTable
-
-# If you keep the line number information, uncomment this to
-# hide the original source file name.
-#-renamesourcefileattribute SourceFile
diff --git a/infobip-mobile-messaging-android-resources/src/main/AndroidManifest.xml b/infobip-mobile-messaging-android-resources/src/main/AndroidManifest.xml
deleted file mode 100644
index daa4b4aa..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/drawable-hdpi/mm_ic_button_accept.png b/infobip-mobile-messaging-android-resources/src/main/res/drawable-hdpi/mm_ic_button_accept.png
deleted file mode 100644
index a639410a..00000000
Binary files a/infobip-mobile-messaging-android-resources/src/main/res/drawable-hdpi/mm_ic_button_accept.png and /dev/null differ
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/drawable-hdpi/mm_ic_button_decline.png b/infobip-mobile-messaging-android-resources/src/main/res/drawable-hdpi/mm_ic_button_decline.png
deleted file mode 100644
index 1645c0a2..00000000
Binary files a/infobip-mobile-messaging-android-resources/src/main/res/drawable-hdpi/mm_ic_button_decline.png and /dev/null differ
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/drawable-mdpi/mm_ic_button_accept.png b/infobip-mobile-messaging-android-resources/src/main/res/drawable-mdpi/mm_ic_button_accept.png
deleted file mode 100644
index 4c1713e0..00000000
Binary files a/infobip-mobile-messaging-android-resources/src/main/res/drawable-mdpi/mm_ic_button_accept.png and /dev/null differ
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/drawable-mdpi/mm_ic_button_decline.png b/infobip-mobile-messaging-android-resources/src/main/res/drawable-mdpi/mm_ic_button_decline.png
deleted file mode 100644
index ffa6ffde..00000000
Binary files a/infobip-mobile-messaging-android-resources/src/main/res/drawable-mdpi/mm_ic_button_decline.png and /dev/null differ
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/drawable-xhdpi/mm_ic_button_accept.png b/infobip-mobile-messaging-android-resources/src/main/res/drawable-xhdpi/mm_ic_button_accept.png
deleted file mode 100644
index 4c6ef880..00000000
Binary files a/infobip-mobile-messaging-android-resources/src/main/res/drawable-xhdpi/mm_ic_button_accept.png and /dev/null differ
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/drawable-xhdpi/mm_ic_button_decline.png b/infobip-mobile-messaging-android-resources/src/main/res/drawable-xhdpi/mm_ic_button_decline.png
deleted file mode 100644
index 17554bbd..00000000
Binary files a/infobip-mobile-messaging-android-resources/src/main/res/drawable-xhdpi/mm_ic_button_decline.png and /dev/null differ
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/drawable-xxhdpi/mm_ic_button_accept.png b/infobip-mobile-messaging-android-resources/src/main/res/drawable-xxhdpi/mm_ic_button_accept.png
deleted file mode 100644
index 39663dfc..00000000
Binary files a/infobip-mobile-messaging-android-resources/src/main/res/drawable-xxhdpi/mm_ic_button_accept.png and /dev/null differ
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/drawable-xxhdpi/mm_ic_button_decline.png b/infobip-mobile-messaging-android-resources/src/main/res/drawable-xxhdpi/mm_ic_button_decline.png
deleted file mode 100644
index 4cca8080..00000000
Binary files a/infobip-mobile-messaging-android-resources/src/main/res/drawable-xxhdpi/mm_ic_button_decline.png and /dev/null differ
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-ar/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-ar/strings.xml
deleted file mode 100644
index e1cf541d..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-ar/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- قبول
- رفض
- فتح
- إلغاء
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-cs/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-cs/strings.xml
deleted file mode 100644
index 742a3509..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-cs/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- Přijmout
- Odmítnout
- Otevřít
- Zrušit
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-da/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-da/strings.xml
deleted file mode 100644
index ef7b5241..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-da/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- Acceptér
- Afvis
- Åbn
- Annullér
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-de/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-de/strings.xml
deleted file mode 100644
index ab54ac6f..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-de/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- Akzeptieren
- Ablehnen
- Öffnen
- Abbrechen
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-es-rES/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-es-rES/strings.xml
deleted file mode 100644
index b61cad98..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-es-rES/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- Aceptar
- Rechazar
- Abrir
- Cancelar
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-es/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-es/strings.xml
deleted file mode 100644
index edbb5605..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-es/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- Aceptar
- Rechazar
- Cancelar
- Abrir
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-fi/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-fi/strings.xml
deleted file mode 100644
index eb6b1441..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-fi/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- Hyväksy
- Hylkää
- Avaa
- Peruuta
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-fr/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-fr/strings.xml
deleted file mode 100644
index 53dca1a8..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-fr/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- Accepter
- Refuser
- Ouvrir
- Annuler
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-hi/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-hi/strings.xml
deleted file mode 100644
index c098152e..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-hi/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- स्वीकार करें
- अस्वीकारें
- रद्द करें
- खोलें
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-hr/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-hr/strings.xml
deleted file mode 100644
index c805f10b..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-hr/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- Prihvati
- Odbaci
- Otvori
- Poništi
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-hu/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-hu/strings.xml
deleted file mode 100644
index 1e759fdd..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-hu/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- Fogadd el
- Utasítsd el
- Mégse
- Megnyitás
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-in/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-in/strings.xml
deleted file mode 100644
index a2f81a42..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-in/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- Setujui
- Tolak
- Buka
- Batal
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-it/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-it/strings.xml
deleted file mode 100644
index 99c9511a..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-it/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- Accetta
- Rifiuta
- Annulla
- Apri
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-iw/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-iw/strings.xml
deleted file mode 100644
index 6d4b7b7c..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-iw/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- אשר
- דחה
- ביטול
- פתח
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-ja/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-ja/strings.xml
deleted file mode 100644
index f56b24b6..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-ja/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- 同意
- 拒否
- キャンセルする
- 開く
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-ko/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-ko/strings.xml
deleted file mode 100644
index a715c94f..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-ko/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- 수락
- 거절
- 취소
- 열기
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-ms/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-ms/strings.xml
deleted file mode 100644
index f9ba399b..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-ms/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- Terima
- Tolak
- Batal
- Buka
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-nl/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-nl/strings.xml
deleted file mode 100644
index a1ffee72..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-nl/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- Accepteer
- Wijs af
- Openen
- Annuleer
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-no/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-no/strings.xml
deleted file mode 100644
index e8f91f18..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-no/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- Aksepter
- Avslå
- Avbryt
- Åpne
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-pl/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-pl/strings.xml
deleted file mode 100644
index bb510f56..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-pl/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- Akceptuj
- Odrzuć
- Anuluj
- Otwórz
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-pt-rPT/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-pt-rPT/strings.xml
deleted file mode 100644
index d102b496..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-pt-rPT/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- Aceitar
- Declinar
- Abrir
- Cancelar
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-pt/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-pt/strings.xml
deleted file mode 100644
index e114ad66..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-pt/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- Aceitar
- Recusar
- Cancelar
- Abrir
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-ro/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-ro/strings.xml
deleted file mode 100644
index eae318fe..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-ro/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- Acceptă
- Refiză
- Anulează
- Deschide
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-ru/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-ru/strings.xml
deleted file mode 100644
index 3f0a1545..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-ru/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- Принять
- Отклонить
- Отмена
- Открыть
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-sk/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-sk/strings.xml
deleted file mode 100644
index ab162a8e..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-sk/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- Prijať
- Odmietnuť
- Otvoriť
- Zrušiť
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-sv/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-sv/strings.xml
deleted file mode 100644
index 301c435e..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-sv/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- Acceptera
- Neka
- Avbryt
- Öppna
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-th/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-th/strings.xml
deleted file mode 100644
index 19ba3b56..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-th/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- ยอมรับ
- ปฏิเสธ
- เปิด
- ยกเลิก
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-tr/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-tr/strings.xml
deleted file mode 100644
index 239a036a..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-tr/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- Kabul Et
- Reddet
- Aç
- İptal
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-vi/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-vi/strings.xml
deleted file mode 100644
index 5ab05de6..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-vi/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- Chấp nhận
- Từ chối
- Hủy bỏ
- Mở
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-zh-rCN/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-zh-rCN/strings.xml
deleted file mode 100644
index 99f9b0e2..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-zh-rCN/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- 接受
- 拒绝
- 打开
- 取消
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values-zh-rTW/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values-zh-rTW/strings.xml
deleted file mode 100644
index 780eb24f..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values-zh-rTW/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- 接受
- 拒絕
- 打開
- 取消
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-resources/src/main/res/values/strings.xml b/infobip-mobile-messaging-android-resources/src/main/res/values/strings.xml
deleted file mode 100644
index 62b33149..00000000
--- a/infobip-mobile-messaging-android-resources/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- Accept
- Decline
- Open
- Cancel
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-sdk/src/main/java/org/infobip/mobile/messaging/cloud/firebase/FirebaseManifestHelper.java b/infobip-mobile-messaging-android-sdk/src/main/java/org/infobip/mobile/messaging/cloud/firebase/FirebaseManifestHelper.java
deleted file mode 100644
index cef51aed..00000000
--- a/infobip-mobile-messaging-android-sdk/src/main/java/org/infobip/mobile/messaging/cloud/firebase/FirebaseManifestHelper.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.infobip.mobile.messaging.cloud.firebase;
-
-import android.content.Context;
-
-import org.infobip.mobile.messaging.util.ComponentUtil;
-
-
-public class FirebaseManifestHelper {
-
- public static void verifyAndConfigureManifest(Context context) {
- // this component needs to be enabled for legacy migration reasons for versions that used GCM
- // it was disabled if GCM component was used instead of Firebase and not re-enabled programmatically if Firebase was used again
- ComponentUtil.enableComponent(context, "com.google.firebase.iid.FirebaseInstanceIdReceiver");
- ComponentUtil.enableComponent(context, MobileMessagingFirebaseService.class);
- }
-}
diff --git a/infobip-mobile-messaging-android-sdk/src/main/java/org/infobip/mobile/messaging/cloud/firebase/FirebaseRegistrationTokenHandler.java b/infobip-mobile-messaging-android-sdk/src/main/java/org/infobip/mobile/messaging/cloud/firebase/FirebaseRegistrationTokenHandler.java
deleted file mode 100644
index 7b06b532..00000000
--- a/infobip-mobile-messaging-android-sdk/src/main/java/org/infobip/mobile/messaging/cloud/firebase/FirebaseRegistrationTokenHandler.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.infobip.mobile.messaging.cloud.firebase;
-
-import android.support.annotation.NonNull;
-
-import com.google.android.gms.tasks.OnFailureListener;
-import com.google.android.gms.tasks.OnSuccessListener;
-import com.google.firebase.iid.FirebaseInstanceId;
-import com.google.firebase.iid.InstanceIdResult;
-import com.google.firebase.messaging.FirebaseMessaging;
-
-import org.infobip.mobile.messaging.MobileMessagingCore;
-import org.infobip.mobile.messaging.cloud.RegistrationTokenHandler;
-import org.infobip.mobile.messaging.logging.MobileMessagingLogger;
-import org.infobip.mobile.messaging.platform.Broadcaster;
-import org.infobip.mobile.messaging.util.StringUtils;
-
-import java.io.IOException;
-
-/**
- * @author sslavin
- * @since 03/09/2018.
- */
-public class FirebaseRegistrationTokenHandler extends RegistrationTokenHandler {
-
- private static final String TAG = FirebaseRegistrationTokenHandler.class.getSimpleName();
-
- private final Broadcaster broadcaster;
-
- public FirebaseRegistrationTokenHandler(MobileMessagingCore mobileMessagingCore, Broadcaster broadcaster) {
- super(mobileMessagingCore);
- this.broadcaster = broadcaster;
- }
-
- public void handleNewToken(String senderId, String token) {
- MobileMessagingLogger.v(TAG, "RECEIVED FCM TOKEN", token);
- broadcaster.tokenReceived(token);
- sendRegistrationToServer(token);
- }
-
- public void cleanupToken(String senderId) {
- if (StringUtils.isBlank(senderId)) {
- return;
- }
-
- try {
- FirebaseInstanceId.getInstance().deleteToken(senderId, FirebaseMessaging.INSTANCE_ID_SCOPE);
- } catch (IOException e) {
- MobileMessagingLogger.e(TAG, "Error while deleting token", e);
- }
- }
-
- public void acquireNewToken(final String senderId) {
- FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(new OnSuccessListener() {
- @Override
- public void onSuccess(InstanceIdResult instanceIdResult) {
- final String token = instanceIdResult.getToken();
- if (StringUtils.isNotBlank(token)) handleNewToken(senderId, token);
- }
- }).addOnFailureListener(new OnFailureListener() {
- @Override
- public void onFailure(@NonNull Exception e) {
- MobileMessagingLogger.e(TAG, "Error while acquiring token", e);
- }
- });
- }
-}
diff --git a/infobip-mobile-messaging-android-sdk/src/main/res/values/styles.xml b/infobip-mobile-messaging-android-sdk/src/main/res/values/styles.xml
deleted file mode 100644
index 9648f138..00000000
--- a/infobip-mobile-messaging-android-sdk/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-sdk/src/test/java/org/infobip/mobile/messaging/UserMapperTest.java b/infobip-mobile-messaging-android-sdk/src/test/java/org/infobip/mobile/messaging/UserMapperTest.java
deleted file mode 100644
index 1b829f9c..00000000
--- a/infobip-mobile-messaging-android-sdk/src/test/java/org/infobip/mobile/messaging/UserMapperTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.infobip.mobile.messaging;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-public class UserMapperTest {
-
- @Test
- public void test_customValueNull() throws Exception {
- Object backendCustomValue = UserMapper.customValueToBackend(null);
-
- assertNull(backendCustomValue);
- }
-
- @Test
- public void test_customValueString() throws Exception {
- Object backendCustomValue = UserMapper.customValueToBackend(new CustomAttributeValue("string"));
-
- assertEquals("string", backendCustomValue);
- }
-}
diff --git a/infobip-mobile-messaging-android-test/.gitignore b/infobip-mobile-messaging-android-test/.gitignore
deleted file mode 100644
index 796b96d1..00000000
--- a/infobip-mobile-messaging-android-test/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build
diff --git a/infobip-mobile-messaging-api-java/.gitignore b/infobip-mobile-messaging-api-java/.gitignore
deleted file mode 100644
index 796b96d1..00000000
--- a/infobip-mobile-messaging-api-java/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build
diff --git a/infobip-mobile-messaging-api-java/build.gradle b/infobip-mobile-messaging-api-java/build.gradle
deleted file mode 100644
index ce2e4683..00000000
--- a/infobip-mobile-messaging-api-java/build.gradle
+++ /dev/null
@@ -1,105 +0,0 @@
-buildscript {
- dependencies {
- classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
- }
-}
-
-plugins {
- id 'java'
- id 'com.github.johnrengelman.shadow' version '2.0.4'
- id 'maven'
- id 'idea'
- id 'io.freefair.lombok' version '4.1.0'
-}
-
-apply plugin: 'com.jfrog.bintray'
-
-sourceCompatibility = JavaVersion.VERSION_1_7
-targetCompatibility = JavaVersion.VERSION_1_7
-
-shadowJar {
- archiveClassifier.set('shaded')
- zip64 = true
- relocate('com.google.gson', 'org.infobip.mobile.messaging.api.shaded.google.gson')
- manifest {
- attributes("Implementation-Title": "Gradle", "Implementation-Version": version)
- }
-}
-
-jar.dependsOn(shadowJar)
-
-jar {
- from{
- zipTree(shadowJar.archivePath)
- }{
- include 'org/infobip/mobile/messaging/api/shaded/**'
- }
-}
-
-configurations {
- provided
-}
-
-sourceSets {
- main { compileClasspath += configurations.provided }
- test { compileClasspath += configurations.provided }
-}
-
-task sourcesJar(type: Jar, dependsOn: classes) {
- archiveClassifier.set('sources')
- from sourceSets.main.allSource
-}
-
-javadoc {
- failOnError = false
-}
-
-task javadocJar(type: Jar, dependsOn: javadoc) {
- archiveClassifier.set('javadoc')
- from javadoc.destinationDir
-}
-
-artifacts {
- archives sourcesJar
- archives javadocJar
-}
-
-idea {
- module {
- try {
- scopes.PROVIDED.plus += [project.configurations.provided]
-
- //scopes.PROVIDED.plus += project.configurations.provided.compile
- //scopes.PROVIDED.plus += project.configurations.provided.runtime
- //scopes.COMPILE.minus += project.configurations.provided.compile
- //scopes.RUNTIME.minus += project.configurations.provided.runtime
- } catch (NullPointerException e) {
- println ":${project.name} ${e}"
- }
- }
-}
-
-dependencies {
- compile "com.google.code.gson:gson:2.8.5"
- implementation "commons-codec:commons-codec:1.10"
-
- testImplementation "junit:junit:4.12"
- testImplementation "org.assertj:assertj-core:2.3.0"
- testImplementation "com.nanohttpd:nanohttpd:2.1.0"
- testImplementation "org.skyscreamer:jsonassert:1.5.0"
- testImplementation "org.mockito:mockito-core:1.10.19"
-}
-
-bintray {
- user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
- key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
- configurations = ['archives']
- publish = true
- pkg {
- repo = 'maven'
- name = 'infobip-mobile-messaging-api-java'
- userOrg = 'infobip'
- licenses = ['Apache-2.0']
- vcsUrl = "https://github.com/infobip/mobile-messaging-sdk-android"
- }
-}
diff --git a/infobip-mobile-messaging-api-java/lombok.config b/infobip-mobile-messaging-api-java/lombok.config
deleted file mode 100644
index 6aa51d71..00000000
--- a/infobip-mobile-messaging-api-java/lombok.config
+++ /dev/null
@@ -1,2 +0,0 @@
-# This file is generated by the 'io.freefair.lombok' Gradle plugin
-config.stopBubbling = true
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/AppInstance.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/AppInstance.java
deleted file mode 100644
index 44954f57..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/AppInstance.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.infobip.mobile.messaging.api.appinstance;
-
-import java.util.Map;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Data
-@AllArgsConstructor
-@NoArgsConstructor
-public class AppInstance {
-
- private String pushRegId;
- private Boolean regEnabled;
- private Boolean notificationsEnabled;
- private Boolean geoEnabled;
- private String sdkVersion;
- private String appVersion;
- private String os;
- private String osVersion;
- private String deviceManufacturer;
- private String deviceModel;
- private Boolean deviceSecure;
- private String language;
- private String deviceTimezoneOffset;
- private String applicationUserId;
- private String deviceName;
- private Map customAttributes;
- private Boolean isPrimary;
- private PushServiceType pushServiceType;
- private String pushServiceToken;
-
- public AppInstance(String pushRegId) {
- this.pushRegId = pushRegId;
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/AppInstanceAtts.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/AppInstanceAtts.java
deleted file mode 100644
index d2711490..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/AppInstanceAtts.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.infobip.mobile.messaging.api.appinstance;
-
-public class AppInstanceAtts {
- public static final String pushRegId = "pushRegId";
- public static final String regEnabled = "regEnabled";
- public static final String notificationsEnabled = "notificationsEnabled";
- public static final String geoEnabled = "geoEnabled";
- public static final String sdkVersion = "sdkVersion";
- public static final String appVersion = "appVersion";
- public static final String os = "os";
- public static final String osVersion = "osVersion";
- public static final String deviceManufacturer = "deviceManufacturer";
- public static final String deviceModel = "deviceModel";
- public static final String deviceSecure = "deviceSecure";
- public static final String language = "language";
- public static final String deviceTimezoneOffset = "deviceTimezoneOffset";
- public static final String applicationUserId = "applicationUserId";
- public static final String deviceName = "deviceName";
- public static final String customAttributes = "customAttributes";
- public static final String isPrimary = "isPrimary";
- public static final String pushServiceType = "pushServiceType";
- public static final String pushServiceToken = "pushServiceToken";
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/MobileApiAppInstance.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/MobileApiAppInstance.java
deleted file mode 100644
index ad66c153..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/MobileApiAppInstance.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package org.infobip.mobile.messaging.api.appinstance;
-
-import org.infobip.mobile.messaging.api.support.Generator;
-import org.infobip.mobile.messaging.api.support.http.ApiKey;
-import org.infobip.mobile.messaging.api.support.http.Body;
-import org.infobip.mobile.messaging.api.support.http.HttpRequest;
-import org.infobip.mobile.messaging.api.support.http.Path;
-import org.infobip.mobile.messaging.api.support.http.Query;
-import org.infobip.mobile.messaging.api.support.http.Version;
-import org.infobip.mobile.messaging.api.support.http.client.HttpMethod;
-
-import java.util.Map;
-
-/**
- * User and app instance related mobile API.
- *
- * Usage:
- *
{@code
- * MobileApiAppInstance mobileApiAppInstance = new Generator.Builder().build().create(MobileApiAppInstance.class);
- * }
- *
- * @see Generator
- * @see Generator.Builder
- */
-@ApiKey("${api.key}")
-@HttpRequest("/mobile/{version}/appinstance")
-@Version("1")
-public interface MobileApiAppInstance {
-
- @HttpRequest(method = HttpMethod.POST)
- @Query(name = "ri", value = "true")
- AppInstance createInstance(@Body AppInstance instance);
-
- @HttpRequest(method = HttpMethod.PATCH, value = "{regId}")
- void patchInstance(@Path(name = "regId") String regId,
- @Body Map instance);
-
- @HttpRequest(method = HttpMethod.GET, value = "{regId}")
- AppInstance getInstance(@Path(name = "regId") String regId);
-
- @HttpRequest(method = HttpMethod.PATCH, value = "{regId}/user")
- void patchUser(@Path(name = "regId") String regId,
- @Body Map user);
-
- @HttpRequest(method = HttpMethod.GET, value = "{regId}/user")
- @Query(name = "ri", value = "true")
- UserBody getUser(@Path(name = "regId") String regId);
-
- @HttpRequest(method = HttpMethod.POST, value = "{regId}/repersonalize")
- void repersonalize(@Path(name = "regId") String regId,
- @Body UserPersonalizeBody userPersonalizeBody);
-
- @HttpRequest(method = HttpMethod.POST, value = "{regId}/depersonalize")
- void depersonalize(@Path(name = "regId") String regId);
-
- @HttpRequest(method = HttpMethod.POST, value = "{regId}/personalize")
- void personalize(@Path(name = "regId") String regId,
- @Query(name = "forceDepersonalize", value = "false") boolean forceDepersonalize,
- @Body UserPersonalizeBody userPersonalizeBody);
-
- @HttpRequest(method = HttpMethod.POST, value = "{regId}/user/events/session")
- void sendUserSessionReport(@Path(name = "regId") String regId,
- @Body UserSessionEventBody userSessionEventBody);
-
- @HttpRequest(method = HttpMethod.POST, value = "{regId}/user/events/custom")
- void sendUserCustomEvents(@Path(name = "regId") String regId,
- @Query(name = "validate", value = "false") boolean validate,
- @Body UserCustomEventBody userCustomEventBody);
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/PushServiceType.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/PushServiceType.java
deleted file mode 100644
index 6f51d506..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/PushServiceType.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package org.infobip.mobile.messaging.api.appinstance;
-
-public enum PushServiceType {
- GCM,
- Firebase
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/UserAtts.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/UserAtts.java
deleted file mode 100644
index ca6b531c..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/UserAtts.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.infobip.mobile.messaging.api.appinstance;
-
-public class UserAtts {
- public static final String externalUserId = "externalUserId";
- public static final String firstName = "firstName";
- public static final String lastName = "lastName";
- public static final String middleName = "middleName";
- public static final String birthday = "birthday";
- public static final String gender = "gender";
- public static final String emails = "emails";
- public static final String phones = "phones";
- public static final String tags = "tags";
- public static final String customAttributes = "customAttributes";
-
- public static final String phoneNumber = "number";
- public static final String emailAddress = "address";
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/UserBody.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/UserBody.java
deleted file mode 100644
index 9da3bf37..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/UserBody.java
+++ /dev/null
@@ -1,147 +0,0 @@
-package org.infobip.mobile.messaging.api.appinstance;
-
-import org.infobip.mobile.messaging.api.support.http.serialization.JsonSerializer;
-import org.infobip.mobile.messaging.api.support.util.StringUtils;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-/**
- * User data synchronization response.
- *
- * @author sslavin
- * @since 15/07/16.
- */
-@Data
-@NoArgsConstructor
-public class UserBody {
-
- private static final JsonSerializer serializer = new JsonSerializer(false);
-
- private String externalUserId;
- private String firstName;
- private String lastName;
- private String middleName;
- private String birthday;
- private String gender;
-
- private Set emails;
- private Set phones;
- private Set tags;
- private Map customAttributes;
- private List instances;
-
- public abstract static class Destination {
-
- public abstract String getDestinationId();
- public abstract Boolean getPreferred();
-
- @Override
- public int hashCode() {
- final int prime = 9;
- int result = 1;
- result = appendToHash(result, prime, getDestinationId());
- result = appendToHash(result, prime, getPreferred());
- return result;
- }
-
- private static int appendToHash(int result, int prime, Object o) {
- return prime * result + (o == null ? 0 : o.hashCode());
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
-
- if (o == null || this.getClass() != o.getClass()) {
- return false;
- }
-
- Destination other = (Destination) o;
- return StringUtils.equals(other.getDestinationId(), this.getDestinationId());
- }
- }
-
- public static class Phone extends Destination {
- String number;
- Boolean preferred;
-
- public Phone(String number) {
- this(number, null);
- }
-
- public Phone(String number, Boolean preferred) {
- this.number = number;
- this.preferred = null;
- }
-
- public String getNumber() {
- return number;
- }
-
- public void setNumber(String number) {
- this.number = number;
- }
-
- @Override
- public String getDestinationId() {
- return getNumber();
- }
-
- @Override
- public Boolean getPreferred() {
- return preferred;
- }
-
- public void setPreferred(Boolean preferred) {
- this.preferred = preferred;
- }
- }
-
- public static class Email extends Destination {
- String address;
- Boolean preferred;
-
- public Email(String address) {
- this(address, null);
- }
-
- public Email(String address, Boolean preferred) {
- this.address = address;
- this.preferred = null;
- }
-
- public String getAddress() {
- return address;
- }
-
- public void setAddress(String address) {
- this.address = address;
- }
-
- @Override
- public String getDestinationId() {
- return getAddress();
- }
-
- @Override
- public Boolean getPreferred() {
- return preferred;
- }
-
- public void setPreferred(Boolean preferred) {
- this.preferred = preferred;
- }
- }
-
- @Override
- public String toString() {
- return serializer.serialize(this);
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/UserCustomEventAtts.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/UserCustomEventAtts.java
deleted file mode 100644
index 0f0a7040..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/UserCustomEventAtts.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.infobip.mobile.messaging.api.appinstance;
-
-public class UserCustomEventAtts {
-
- public static final String properties = "properties";
- public static final String definitionId = "definitionId";
- public static final String eventDate = "eventDate";
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/UserCustomEventBody.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/UserCustomEventBody.java
deleted file mode 100644
index 68e6ca74..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/UserCustomEventBody.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.infobip.mobile.messaging.api.appinstance;
-
-import org.infobip.mobile.messaging.api.support.http.serialization.JsonSerializer;
-
-import java.util.Map;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class UserCustomEventBody {
-
- private static final JsonSerializer serializer = new JsonSerializer(false);
-
- @Data
- @NoArgsConstructor
- @AllArgsConstructor
- public static class CustomEvent {
- private String definitionId;
- private String date;
- private Map properties;
- }
-
- /**
- * Array of custom events to report.
- */
- private CustomEvent[] events;
-
- @Override
- public String toString() {
- return serializer.serialize(this);
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/UserPersonalizeBody.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/UserPersonalizeBody.java
deleted file mode 100644
index 4cd2fbb9..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/UserPersonalizeBody.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.infobip.mobile.messaging.api.appinstance;
-
-import org.infobip.mobile.messaging.api.support.http.serialization.JsonSerializer;
-
-import java.util.Map;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class UserPersonalizeBody {
-
- private static final JsonSerializer serializer = new JsonSerializer(false);
-
- private Map userIdentity;
- private Map userAttributes;
-
- @Override
- public String toString() {
- return serializer.serialize(this);
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/UserSessionEventBody.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/UserSessionEventBody.java
deleted file mode 100644
index cda23ecc..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/appinstance/UserSessionEventBody.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.infobip.mobile.messaging.api.appinstance;
-
-import java.util.Map;
-import java.util.Set;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class UserSessionEventBody {
-
- AppInstance systemData; //no custom atts!
- Set sessionStarts; //session start dates in yyyy-MM-dd'T'HH:mm:ssZ format
- Map sessionBounds; //map of session start/end dates in yyyy-MM-dd'T'HH:mm:ssZ format
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/geo/EventReport.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/geo/EventReport.java
deleted file mode 100644
index 0e4fec60..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/geo/EventReport.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.infobip.mobile.messaging.api.geo;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-/**
- * @author sslavin
- * @since 19/10/2016.
- */
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class EventReport {
- EventType event;
- String geoAreaId;
- String campaignId;
- String messageId;
- String sdkMessageId;
- Long timestampDelta;
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/geo/EventReportBody.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/geo/EventReportBody.java
deleted file mode 100644
index 78018443..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/geo/EventReportBody.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.infobip.mobile.messaging.api.geo;
-
-import java.util.Set;
-
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-
-/**
- * @author sslavin
- * @since 24/10/2016.
- */
-
-@AllArgsConstructor
-@NoArgsConstructor
-@Getter
-public class EventReportBody {
- final String platformType = "GCM";
-
- Set messages;
- Set reports;
- String deviceApplicationInstanceId;
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/geo/EventReportResponse.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/geo/EventReportResponse.java
deleted file mode 100644
index 4a560263..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/geo/EventReportResponse.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.infobip.mobile.messaging.api.geo;
-
-import java.util.Map;
-import java.util.Set;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-
-/**
- * Servers' response on reporting events. Contains statuses of registered campaigns.
- *
- * @see MobileApiGeo
- * @see MobileApiGeo#report(EventReportBody)
- */
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class EventReportResponse {
- Set finishedCampaignIds;
- Set suspendedCampaignIds;
- Map messageIds;
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/geo/EventType.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/geo/EventType.java
deleted file mode 100644
index 9267f154..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/geo/EventType.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.infobip.mobile.messaging.api.geo;
-
-/**
- * @author sslavin
- * @since 24/10/2016.
- */
-
-public enum EventType {
- entry,
- exit,
- dwell
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/geo/MessagePayload.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/geo/MessagePayload.java
deleted file mode 100644
index 6a262838..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/geo/MessagePayload.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.infobip.mobile.messaging.api.geo;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-/**
- * @author sslavin
- * @since 06/02/2017.
- */
-
-@Data
-@AllArgsConstructor
-@NoArgsConstructor
-public class MessagePayload {
- String messageId;
- String title;
- String body;
- String sound;
- Boolean vibrate;
- String category;
- Boolean silent;
-
- String customPayload;
- String internalData;
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/geo/MobileApiGeo.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/geo/MobileApiGeo.java
deleted file mode 100644
index 452ca375..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/geo/MobileApiGeo.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.infobip.mobile.messaging.api.geo;
-
-import org.infobip.mobile.messaging.api.support.Generator;
-import org.infobip.mobile.messaging.api.support.http.ApiKey;
-import org.infobip.mobile.messaging.api.support.http.Body;
-import org.infobip.mobile.messaging.api.support.http.HttpRequest;
-import org.infobip.mobile.messaging.api.support.http.Version;
-import org.infobip.mobile.messaging.api.support.http.client.HttpMethod;
-
-/**
- * Geo-related mobile API.
- *
- * Usage:
- *
{@code
- * MobileApiGeo mobileApiGeo = new Generator.Builder().build().create(MobileApiGeo.class);
- * }
- *
- * @author sslavin
- * @see Generator
- * @see Generator.Builder
- * @since 19.10.2016.
- */
-@ApiKey("${api.key}")
-@HttpRequest("/mobile/{version}/geo")
-@Version("4")
-public interface MobileApiGeo {
-
- @HttpRequest(method = HttpMethod.POST, value = "event")
- EventReportResponse report(@Body() EventReportBody reports);
-}
\ No newline at end of file
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/MessageResponse.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/MessageResponse.java
deleted file mode 100644
index e5c5f190..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/MessageResponse.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.infobip.mobile.messaging.api.messages;
-
-import com.google.gson.annotations.Expose;
-import com.google.gson.annotations.SerializedName;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-/**
- * @author pandric on 09/09/16.
- */
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class MessageResponse {
- @SerializedName("gcm.notification.messageId")
- String messageId;
-
- @SerializedName("gcm.notification.title")
- String title;
-
- @SerializedName("gcm.notification.body")
- String body;
-
- @SerializedName("gcm.notification.sound")
- String sound;
-
- @SerializedName("gcm.notification.vibrate")
- String vibrate;
-
- @SerializedName("gcm.notification.silent")
- String silent;
-
- @SerializedName("gcm.notification.category")
- String category;
-
- @Expose
- String customPayload;
-
- @Expose
- String internalData;
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/MoMessage.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/MoMessage.java
deleted file mode 100644
index 043b4a3f..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/MoMessage.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.infobip.mobile.messaging.api.messages;
-
-import java.util.Map;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-/**
- * @author sslavin
- * @since 21/07/16.
- */
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class MoMessage {
- String messageId;
- String destination;
- String text;
- String initialMessageId;
- String bulkId;
- Map customPayload;
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/MoMessageDelivery.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/MoMessageDelivery.java
deleted file mode 100644
index 9e889dfc..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/MoMessageDelivery.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.infobip.mobile.messaging.api.messages;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.NoArgsConstructor;
-
-/**
- * @author sslavin
- * @since 21/07/16.
- */
-@Data
-@EqualsAndHashCode(callSuper = true)
-@NoArgsConstructor
-@AllArgsConstructor
-public class MoMessageDelivery extends MoMessage {
- int statusCode;
- String status;
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/MoMessagesBody.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/MoMessagesBody.java
deleted file mode 100644
index cc185133..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/MoMessagesBody.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.infobip.mobile.messaging.api.messages;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-/**
- * @author sslavin
- * @since 21/07/16.
- */
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class MoMessagesBody {
- String from;
- MoMessage[] messages;
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/MoMessagesResponse.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/MoMessagesResponse.java
deleted file mode 100644
index e6f0df7e..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/MoMessagesResponse.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.infobip.mobile.messaging.api.messages;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-/**
- * @author sslavin
- * @since 21/07/16.
- */
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class MoMessagesResponse {
- MoMessageDelivery[] messages;
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/MobileApiMessages.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/MobileApiMessages.java
deleted file mode 100644
index 21d12393..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/MobileApiMessages.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.infobip.mobile.messaging.api.messages;
-
-import org.infobip.mobile.messaging.api.support.Generator;
-import org.infobip.mobile.messaging.api.support.http.ApiKey;
-import org.infobip.mobile.messaging.api.support.http.Body;
-import org.infobip.mobile.messaging.api.support.http.HttpRequest;
-import org.infobip.mobile.messaging.api.support.http.Query;
-import org.infobip.mobile.messaging.api.support.http.Version;
-import org.infobip.mobile.messaging.api.support.http.client.HttpMethod;
-
-/**
- * Message-related mobile API.
- *
- * Usage:
- *
{@code
- * MobileApiMessages mobileApiMessages = new Generator.Builder().build().create(MobileApiMessages.class);
- * }
- *
- * @author sslavin
- * @see Generator
- * @see Generator.Builder
- * @since 25.03.2016.
- */
-@ApiKey("${api.key}")
-@HttpRequest("/mobile/{version}/messages")
-public interface MobileApiMessages {
- @Version("1")
- @HttpRequest(method = HttpMethod.POST, value = "seen")
- void reportSeen(@Body() SeenMessages seenReport);
-
- @Version("1")
- @HttpRequest(method = HttpMethod.POST, value = "mo")
- @Query(name = "platformType", value = "${platform.type:GCM}")
- MoMessagesResponse sendMO(@Body() MoMessagesBody moMessagesBody);
-
- @Version("5")
- @HttpRequest(method = HttpMethod.POST)
- @Query(name = "platformType", value = "${platform.type:GCM}")
- SyncMessagesResponse sync(@Body() SyncMessagesBody pushMessagesBody);
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/SeenMessages.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/SeenMessages.java
deleted file mode 100644
index cd4c247e..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/SeenMessages.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.infobip.mobile.messaging.api.messages;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-/**
- * Seen messages report body encapsulation.
- *
- * @author sslavin
- * @see MobileApiMessages
- * @see MobileApiMessages#reportSeen(SeenMessages)
- * @since 25.04.2016.
- */
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class SeenMessages {
-
- public static class Message {
- /**
- * Id of a message.
- */
- private final String messageId;
- /**
- * Delta timestamp (now - seenTimestamp) - delta between timestamp in seconds between now (time when seen status is sent to the backend)
- * and seenTimestamp (when seen timestamp was actually recorded).
- */
- private final long timestampDelta;
-
- /**
- * Constructs message using only the message Id, timestamp is set to current time.
- *
- * @param messageId - id of a message to report.
- */
- public Message(String messageId, long timestampDelta) {
- this.messageId = messageId;
- this.timestampDelta = timestampDelta;
- }
- }
-
- /**
- * Array of messages to report.
- */
- private Message[] messages;
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/SyncMessagesBody.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/SyncMessagesBody.java
deleted file mode 100644
index 7ef75365..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/SyncMessagesBody.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.infobip.mobile.messaging.api.messages;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-/**
- * @author pandric on 09/09/16.
- */
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class SyncMessagesBody {
- String[] mIDs;
- String[] drIDs;
-
- static public SyncMessagesBody make(String[] mIDs, String[] drIDs) {
- if (mIDs.length == 0 && drIDs.length == 0) {
- return null;
- }
- SyncMessagesBody result = new SyncMessagesBody();
- result.mIDs = mIDs.length > 0 ? mIDs : null;
- result.drIDs = drIDs.length > 0 ? drIDs : null;
- return result;
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/SyncMessagesResponse.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/SyncMessagesResponse.java
deleted file mode 100644
index 7827cf9f..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/messages/SyncMessagesResponse.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.infobip.mobile.messaging.api.messages;
-
-import java.util.List;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-/**
- * @author pandric on 09/09/16.
- */
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class SyncMessagesResponse {
- List payloads;
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/ApiBackendException.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/ApiBackendException.java
deleted file mode 100644
index 8f8647e9..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/ApiBackendException.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.infobip.mobile.messaging.api.support;
-
-/**
- * @author mstipanov
- * @since 17.03.2016.
- */
-public class ApiBackendException extends ApiIOException {
- public ApiBackendException(String code, String message) {
- super(code, message);
- }
-
- public ApiBackendException(String code, String message, Throwable cause) {
- super(code, message, cause);
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/ApiBackendExceptionWithContent.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/ApiBackendExceptionWithContent.java
deleted file mode 100644
index c56aaa86..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/ApiBackendExceptionWithContent.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.infobip.mobile.messaging.api.support;
-
-/**
- * @author sslavin
- * @since 17/10/2017.
- */
-
-public class ApiBackendExceptionWithContent extends ApiIOException {
-
- private final Object content;
-
- public ApiBackendExceptionWithContent(String code, String message, Object content) {
- super(code, message);
- this.content = content;
- }
-
- public Object getContent() {
- return content;
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/ApiErrorCode.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/ApiErrorCode.java
deleted file mode 100644
index ff58fe3f..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/ApiErrorCode.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.infobip.mobile.messaging.api.support;
-
-/**
- * @author sslavin
- * @since 19/07/16.
- */
-@SuppressWarnings("unused")
-public class ApiErrorCode {
- public static final String UNKNOWN = "0";
- public static final String INVALID_APPLICATION_CODE = "1";
- public static final String INVALID_CLOUD_TYPE = "2";
- public static final String UNSUPPORTED_CLOUD_TYPE = "4";
- public static final String MESSAGE_IDS_EMPTY = "6";
- public static final String INVALID_INTERNAL_REGISTRATION_ID = "7";
- public static final String INVALID_VALUE = "9";
-
- public static final String EMAIL_INVALID = "EMAIL_INVALID";
- public static final String PHONE_INVALID = "PHONE_INVALID";
- public static final String USER_IDENTITY_INVALID = "USER_IDENTITY_INVALID";
- public static final String REQUEST_FORMAT_INVALID = "REQUEST_FORMAT_INVALID";
- public static final String USER_MERGE_INTERRUPTED = "USER_MERGE_INTERRUPTED";
- public static final String USER_DATA_RESTRICTED = "USER_DATA_RESTRICTED";
- public static final String PERSONALIZATION_IMPOSSIBLE = "PERSONALIZATION_IMPOSSIBLE";
- public static final String AMBIGUOUS_PERSONALIZE_CANDIDATES = "AMBIGUOUS_PERSONALIZE_CANDIDATES";
- public static final String NO_REGISTRATION = "NO_REGISTRATION";
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/ApiException.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/ApiException.java
deleted file mode 100644
index b3a55b60..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/ApiException.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.infobip.mobile.messaging.api.support;
-
-/**
- * @author mstipanov
- * @since 17.03.2016.
- */
-public class ApiException extends ApiIOException {
- public ApiException(String code, String message) {
- super(code, message);
- }
-
- public ApiException(String code, String message, Throwable cause) {
- super(code, message, cause);
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/ApiIOException.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/ApiIOException.java
deleted file mode 100644
index 3248258d..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/ApiIOException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.infobip.mobile.messaging.api.support;
-
-import org.infobip.mobile.messaging.api.support.util.StringUtils;
-
-/**
- * @author mstipanov
- * @since 17.03.2016.
- */
-public class ApiIOException extends RuntimeException {
- private final String code;
-
- public ApiIOException(String code, String message) {
- super(message);
- this.code = code;
- }
-
- public ApiIOException(String code, String message, Throwable cause) {
- super(message, cause);
- this.code = code;
- }
-
- public String getCode() {
- return code;
- }
-
- public String toString() {
- String s = getClass().getName();
- String message = getLocalizedMessage();
- String code = getCode();
- if (StringUtils.isNotBlank(code)) {
- if (StringUtils.isNotBlank(message)) {
- message = code + ", "+ message;
- } else {
- message = code;
- }
- }
- return (message != null) ? (s + ": " + message) : s;
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/CustomApiHeaders.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/CustomApiHeaders.java
deleted file mode 100644
index 9be09017..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/CustomApiHeaders.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.infobip.mobile.messaging.api.support;
-
-/**
- * @author pandric on 10/04/2017.
- */
-
-public enum CustomApiHeaders {
- FOREGROUND("foreground"),
- SESSION_ID("sessionId"),
- PUSH_REGISTRATION_ID("pushregistrationid"),
- NEW_BASE_URL("newbaseurl"),
- APPLICATION_CODE("applicationcode");
-
- private final String value;
-
- CustomApiHeaders(String value) {
- this.value = value;
- }
-
- public String getValue() {
- return value;
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/Generator.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/Generator.java
deleted file mode 100644
index 1bea3d0d..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/Generator.java
+++ /dev/null
@@ -1,551 +0,0 @@
-package org.infobip.mobile.messaging.api.support;
-
-import org.infobip.mobile.messaging.api.support.http.ApiKey;
-import org.infobip.mobile.messaging.api.support.http.Body;
-import org.infobip.mobile.messaging.api.support.http.Credentials;
-import org.infobip.mobile.messaging.api.support.http.Header;
-import org.infobip.mobile.messaging.api.support.http.Headers;
-import org.infobip.mobile.messaging.api.support.http.HttpRequest;
-import org.infobip.mobile.messaging.api.support.http.Path;
-import org.infobip.mobile.messaging.api.support.http.Paths;
-import org.infobip.mobile.messaging.api.support.http.Queries;
-import org.infobip.mobile.messaging.api.support.http.Query;
-import org.infobip.mobile.messaging.api.support.http.Version;
-import org.infobip.mobile.messaging.api.support.http.client.DefaultApiClient;
-import org.infobip.mobile.messaging.api.support.http.client.HttpMethod;
-import org.infobip.mobile.messaging.api.support.http.client.Logger;
-import org.infobip.mobile.messaging.api.support.http.client.RequestInterceptor;
-import org.infobip.mobile.messaging.api.support.http.client.ResponsePreProcessor;
-import org.infobip.mobile.messaging.api.support.util.StringUtils;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Array;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.ConcurrentHashMap;
-
-import lombok.Data;
-import lombok.NonNull;
-
-import static org.infobip.mobile.messaging.api.support.util.ReflectionUtils.loadPackageInfo;
-
-/**
- * Generates Mobile API proxies.
- * {@code
- * MobileApiRegistration mobileApiRegistration = new Generator.Builder().build().create(MobileApiRegistration.class);
- * }
- *
- * @author mstipanov
- * @see Builder
- * @since 17.03.2016.
- */
-@Data
-public class Generator {
-
- private DefaultApiClient apiClient;
- private String baseUrl = "https://mobile.infobip.com/";
- private ConcurrentHashMap, CachingInvocationHandler> proxyCacheMap = new ConcurrentHashMap<>();
- private Properties properties = System.getProperties();
- private int connectTimeout = DefaultApiClient.DEFAULT_CONNECT_TIMEOUT;
- private int readTimeout = DefaultApiClient.DEFAULT_READ_TIMEOUT;
- private String[] userAgentAdditions = new String[0];
- private RequestInterceptor[] requestInterceptors = new RequestInterceptor[0];
- private ResponsePreProcessor[] responsePreProcessors = new ResponsePreProcessor[0];
- private Logger logger = new Logger();
- private boolean allowUntrustedSSLOnError = false;
-
- private DefaultApiClient getApiClient() {
- if (null != apiClient) {
- return apiClient;
- }
- String libraryVersion = properties.getProperty("library.version");
- apiClient = new DefaultApiClient(connectTimeout, readTimeout, libraryVersion, requestInterceptors, responsePreProcessors, logger, allowUntrustedSSLOnError, userAgentAdditions);
- return apiClient;
- }
-
- @SuppressWarnings("unchecked")
- public T create(@NonNull Class type) {
- CachingInvocationHandler> cachingInvocationHandler = proxyCacheMap.get(type);
- if (null == cachingInvocationHandler) {
- cachingInvocationHandler = new CachingInvocationHandler<>(type);
- proxyCacheMap.put(type, cachingInvocationHandler);
- }
- return (T) cachingInvocationHandler.getProxy();
- }
-
- private Version getVersionAnnotation(Method method) {
- Version version = method.getAnnotation(Version.class);
- if (null != version) {
- return version;
- }
-
- version = method.getDeclaringClass().getAnnotation(Version.class);
- if (null != version) {
- return version;
- }
-
- return getPackageAnnotation(method.getDeclaringClass().getPackage().getName(), Version.class);
- }
-
- private ApiKey getApiKeyAnnotation(Method method) {
- ApiKey apiKey = method.getAnnotation(ApiKey.class);
- if (null != apiKey) {
- return apiKey;
- }
-
- apiKey = method.getDeclaringClass().getAnnotation(ApiKey.class);
- if (null != apiKey) {
- return apiKey;
- }
-
- return getPackageAnnotation(method.getDeclaringClass().getPackage().getName(), ApiKey.class);
- }
-
- private Credentials getCredentialsAnnotation(Method method) {
- Credentials credentials = method.getAnnotation(Credentials.class);
- if (null != credentials) {
- return credentials;
- }
-
- credentials = method.getDeclaringClass().getAnnotation(Credentials.class);
- if (null != credentials) {
- return credentials;
- }
-
- return getPackageAnnotation(method.getDeclaringClass().getPackage().getName(), Credentials.class);
- }
-
- private T getPackageAnnotation(String pkg, Class annotationClass) {
- Package p = Package.getPackage(pkg);
- if (null == p) {
- try {
- loadPackageInfo(pkg);
- p = Package.getPackage(pkg);
- } catch (Exception e) {
- //ignore
- }
- }
- if (null != p) {
- T t = p.getAnnotation(annotationClass);
- if (null != t) {
- return t;
- }
- }
-
- if (pkg.length() == 0) {
- return null;
- }
-
- int endIndex = pkg.lastIndexOf('.');
- if (endIndex < 0) {
- pkg = "";
- } else {
- pkg = pkg.substring(0, endIndex);
- }
- return getPackageAnnotation(pkg, annotationClass);
- }
-
- @SuppressWarnings("unchecked")
- private T getAnnotation(Annotation[] annotations, Class type) {
- for (Annotation annotation : annotations) {
- if (!type.isAssignableFrom(annotation.annotationType())) {
- continue;
- }
- return (T) annotation;
- }
- return null;
- }
-
- private Collection toCollection(Object arg) {
- if (null == arg) {
- return null;
- }
-
- if (arg instanceof Collection) {
- return (Collection) arg;
- }
-
- if (arg.getClass().isArray()) {
- int length = Array.getLength(arg);
- ArrayList objects = new ArrayList<>();
- for (int i = 0; i < length; i++) {
- objects.add(Array.get(arg, i));
- }
- return objects;
- }
-
- return Collections.singleton(arg);
- }
-
- /**
- * Builds {@link Generator}
- *
- * @see Generator
- * @see Builder#withBaseUrl(String)
- * @see Builder#withProperties(Properties)
- * @see Builder#withConnectTimeout(int)
- * @see Builder#withReadTimeout(int)
- * @see Builder#withUserAgentAdditions(String...)
- */
- public static class Builder {
- private final Generator generator;
-
- public Builder() {
- generator = new Generator();
- }
-
- /**
- * It will set the base API URL. By default it will be https://mobile.infobip.com/
- *
- * @return {@link Builder}
- */
- public Builder withBaseUrl(@NonNull String baseUrl) {
- generator.setBaseUrl(baseUrl);
- return this;
- }
-
- /**
- * It will set the base properties from which User-Agent header will be constructed.
- *
- * Used properties:
- *
- * api.key - for Mobile API API-KEY. You must use application code as the API-KEY!
- * library.version - for Mobile Messaging library version
- *
- *
- * @return {@link Builder}
- */
- public Builder withProperties(@NonNull Properties properties) {
- generator.setProperties(properties);
- return this;
- }
-
- /**
- * It will set the connect timeout. Default is: 5s
- *
- * @return {@link Builder}
- */
- public Builder withConnectTimeout(int connectTimeout) {
- generator.setConnectTimeout(connectTimeout);
- return this;
- }
-
- /**
- * It will set the read timeout. Default is: 1min
- *
- * @return {@link Builder}
- */
- public Builder withReadTimeout(int readTimeout) {
- generator.setReadTimeout(readTimeout);
- return this;
- }
-
- /**
- * It will custom string array to append to User-Agent header.
- *
- * @return {@link Builder}
- */
- public Builder withUserAgentAdditions(@NonNull String... userAgentAdditions) {
- generator.setUserAgentAdditions(userAgentAdditions);
- return this;
- }
-
- /**
- * It will set request interceptors for http client.
- *
- * @param requestInterceptors interceptors to add to chain.
- * @return {@link Builder}
- */
- public Builder withRequestInterceptors(@NonNull RequestInterceptor... requestInterceptors) {
- generator.requestInterceptors = requestInterceptors;
- return this;
- }
-
- /**
- * Will set response header interceptors for http client
- *
- * @param responsePreProcessors interceptors to add
- * @return {@link Builder}
- */
- public Builder withResponseHeaderInterceptors(@NonNull ResponsePreProcessor... responsePreProcessors) {
- generator.responsePreProcessors = responsePreProcessors;
- return this;
- }
-
-
- /**
- * Will set custom logger for http client
- * @param logger logger
- * @return {@link Builder}
- */
- public Builder withLogger(@NonNull Logger logger) {
- generator.logger = logger;
- return this;
- }
-
- /**
- * Will allow untrusted SSL if `true` supplied
- * @param allowUntrustedSSLOnError setting
- * @return {@link Builder}
- */
- public Builder withAllowUntrustedSSLOnError(boolean allowUntrustedSSLOnError) {
- generator.allowUntrustedSSLOnError = allowUntrustedSSLOnError;
- return this;
- }
-
- public Generator build() {
- if (StringUtils.isBlank(generator.getBaseUrl())) {
- throw new IllegalArgumentException("baseUrl is mandatory");
- }
-
- return generator;
- }
- }
-
- @Data
- private class CachingInvocationHandler implements InvocationHandler {
- private final Class type;
- private ConcurrentHashMap proxyCacheMap = new ConcurrentHashMap<>();
-
- @SuppressWarnings("unchecked")
- public T getProxy() {
- return (T) Proxy.newProxyInstance(type.getClassLoader(), new Class[]{type}, this);
- }
-
- @Override
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- ProxyCache proxyCache = getProxyCache(method);
- String uri = StringUtils.join("/", baseUrl, proxyCache.getUri());
-
- Map> queryParams = new HashMap<>(proxyCache.getDefaultQueryParams());
- Map> headerMap = new HashMap<>(proxyCache.getDefaultHeaderMap());
- String apiKey = proxyCache.getApiKey();
- Tuple credentials = proxyCache.getCredentials();
-
- Parameter[] parameters = proxyCache.getParameters();
- Object body = null;
- for (int i = 0, parametersLength = parameters.length; i < parametersLength; i++) {
- Parameter parameter = parameters[i];
- Object arg = args[i];
- if (null != parameter.getBody()) {
- body = arg;
- }
-
- Version version = parameter.getVersion();
- if (null != version) {
- uri = uri.replace("{version}", arg.toString());
- }
-
- Path p = parameter.getPath();
- if (null != p) {
- uri = uri.replace("{" + p.name() + "}", arg.toString());
- }
-
- Query q = parameter.getQuery();
- if (null != q) {
- String name = q.name();
- queryParams.put(name, toCollection(arg));
- }
-
- Header h = parameter.getHeader();
- if (null != h) {
- String name = h.name();
- headerMap.put(name, toCollection(arg));
- }
- }
-
- if (uri.endsWith("/")) {
- uri = uri.substring(0, uri.length() - 1);
- }
-
- return getApiClient().execute(getHttpRequestMethod(proxyCache.httpRequests), uri, apiKey, credentials, queryParams, headerMap, body, method.getReturnType());
- }
-
- private HttpMethod getHttpRequestMethod(HttpRequest[] httpRequests) {
- HttpMethod method = HttpMethod.GET;
- for (HttpRequest httpRequest : httpRequests) {
- method = httpRequest.method();
- }
- return method;
- }
-
- private ProxyCache getProxyCache(Method method) {
- ProxyCache proxyCache = proxyCacheMap.get(method);
- if (null != proxyCache) {
- return proxyCache;
- }
-
- proxyCache = new ProxyCache(method);
- proxyCacheMap.put(method, proxyCache);
- return proxyCache;
- }
- }
-
- @Data
- private class Parameter {
- private final Body body;
- private final Path path;
- private final Query query;
- private final Header header;
- private final Version version;
- }
-
- @Data
- private class ProxyCache {
- private final HttpRequest[] httpRequests;
- private final String uri;
- private final HashMap> defaultQueryParams;
- private final HashMap> defaultHeaderMap;
- private final Parameter[] parameters;
- private final String apiKey;
- private final Tuple credentials;
-
- public ProxyCache(Method method) {
- this.httpRequests = createHttpRequest(method);
- this.uri = createUri(method);
- this.defaultQueryParams = createDefaultQueryParams(method);
- this.defaultHeaderMap = createDefaultHeaderMap(method);
- this.parameters = createParameters(method);
- this.apiKey = findApiKey(method);
- this.credentials = findCredentials(method);
- }
-
- private String findApiKey(Method method) {
- ApiKey apiKeyAnotation = getApiKeyAnnotation(method);
- if (null == apiKeyAnotation) {
- return null;
- }
- return injectProperty(apiKeyAnotation.value());
- }
-
- private Tuple findCredentials(Method method) {
- Credentials credentialsAnnotation = getCredentialsAnnotation(method);
- if (null == credentialsAnnotation) {
- return null;
- }
- return new Tuple<>(injectProperty(credentialsAnnotation.user()), injectProperty(credentialsAnnotation.password()));
- }
-
- private Parameter[] createParameters(Method method) {
- Annotation[][] parameterAnnotations = method.getParameterAnnotations();
- Parameter[] parameters = new Parameter[parameterAnnotations.length];
- int i = 0;
- for (Annotation[] annotations : parameterAnnotations) {
- Parameter parameter = new Parameter(
- getAnnotation(annotations, Body.class)
- , getAnnotation(annotations, Path.class)
- , getAnnotation(annotations, Query.class)
- , getAnnotation(annotations, Header.class)
- , getAnnotation(annotations, Version.class)
- );
- parameters[i++] = parameter;
- }
- return parameters;
- }
-
- private HttpRequest[] createHttpRequest(Method method) {
- HttpRequest httpRequestOnClass = method.getDeclaringClass().getAnnotation(HttpRequest.class);
- HttpRequest httpRequest = method.getAnnotation(HttpRequest.class);
- if (null != httpRequest && null != httpRequestOnClass) {
- return new HttpRequest[]{httpRequestOnClass, httpRequest};
- }
- if (null != httpRequest) {
- return new HttpRequest[]{httpRequest};
- }
- if (null != httpRequestOnClass) {
- return new HttpRequest[]{httpRequestOnClass};
- }
- throw new NoHttpRequestAnnotation("Method '" + method.getName() + "' must be annotated with @HttpRequest!");
- }
-
- private String createUri(Method method) {
- String uri = getHttpRequestValue();
- Version version = getVersionAnnotation(method);
- if (null != version) {
- uri = uri.replace("{version}", injectProperty(version.value()));
- }
-
- Path path = method.getAnnotation(Path.class);
- if (null != path) {
- uri = uri.replace("{" + path.name() + "}", injectProperty(path.value()));
- }
- Paths paths = method.getAnnotation(Paths.class);
- if (null != paths) {
- for (Path p : paths.value()) {
- uri = uri.replace("{" + p.name() + "}", injectProperty(p.value()));
- }
- }
- return uri;
- }
-
- private String getHttpRequestValue() {
- String uri = "";
- for (HttpRequest httpRequest : httpRequests) {
- uri = StringUtils.join("/", uri, httpRequest.value());
- }
- return uri;
- }
-
- private String injectProperty(String s) {
- if (StringUtils.isBlank(s)) {
- return s;
- }
- if (s.startsWith("${") && s.endsWith("}")) {
- s = s.substring(2, s.length() - 1);
- String[] split = s.split(":");
- return properties.getProperty(split[0], split.length > 1 ? split[1] : null);
- }
- return s;
- }
-
- private Collection injectProperty(String[] strings) {
- if (null == strings) {
- return null;
- }
-
- ArrayList objects = new ArrayList<>();
- for (String s : strings) {
- objects.add(injectProperty(s));
- }
- return objects;
- }
-
- private HashMap> createDefaultQueryParams(Method method) {
- HashMap> queryParams = new HashMap<>();
- Query query = method.getAnnotation(Query.class);
- if (null != query) {
- queryParams.put(query.name(), injectProperty(query.value()));
- }
- Queries queries = method.getAnnotation(Queries.class);
- if (null != queries) {
- for (Query q : queries.value()) {
- queryParams.put(q.name(), injectProperty(q.value()));
- }
- }
- return queryParams;
- }
-
- private HashMap> createDefaultHeaderMap(Method method) {
- HashMap> headerMap = new HashMap<>();
- Header header = method.getAnnotation(Header.class);
- if (null != header) {
- headerMap.put(header.name(), injectProperty(header.value()));
- }
- Headers headers = method.getAnnotation(Headers.class);
- if (null != headers) {
- for (Header q : headers.value()) {
- headerMap.put(q.name(), injectProperty(q.value()));
- }
- }
-
- return headerMap;
- }
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/MapModel.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/MapModel.java
deleted file mode 100644
index 9ab1f3a3..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/MapModel.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.infobip.mobile.messaging.api.support;
-
-import org.infobip.mobile.messaging.api.support.http.serialization.JsonSerializer;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class MapModel {
-
- private static final JsonSerializer nullSerializer = new JsonSerializer(true);
-
- private final Map map = new HashMap<>();
-
- public Map getMap() {
- return map;
- }
-
- public T getField(String name) {
- //noinspection unchecked
- return (T) map.get(name);
- }
-
- public void setField(String name, T value) {
- map.put(name, value);
- }
-
- public boolean containsField(String name) {
- return map.containsKey(name);
- }
-
- public boolean hasDataToReport() {
- return !map.isEmpty();
- }
-
- public void clearUnreportedData() {
- map.clear();
- }
-
- @Override
- public String toString() {
- return nullSerializer.serialize(map);
- }
-}
\ No newline at end of file
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/NoHttpRequestAnnotation.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/NoHttpRequestAnnotation.java
deleted file mode 100644
index f63301b9..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/NoHttpRequestAnnotation.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.infobip.mobile.messaging.api.support;
-
-/**
- * @author mstipanov
- * @since 17.03.2016.
- */
-public class NoHttpRequestAnnotation extends RuntimeException {
- public NoHttpRequestAnnotation(String message) {
- super(message);
- }
-
- public NoHttpRequestAnnotation(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/Tuple.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/Tuple.java
deleted file mode 100644
index 6d484aae..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/Tuple.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.infobip.mobile.messaging.api.support;
-
-import lombok.Data;
-
-/**
- * @author mstipanov
- * @since 17.03.2016.
- */
-@Data
-public class Tuple {
- private final L left;
- private final R right;
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/ApiKey.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/ApiKey.java
deleted file mode 100644
index cffff0d4..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/ApiKey.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.infobip.mobile.messaging.api.support.http;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-/**
- * Make a POST request.
- */
-@Documented
-@Target({METHOD, TYPE, PACKAGE})
-@Retention(RUNTIME)
-public @interface ApiKey {
- String value() default "";
-}
\ No newline at end of file
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Body.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Body.java
deleted file mode 100644
index 77d98107..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Body.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.infobip.mobile.messaging.api.support.http;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-/**
- * Make a POST request.
- */
-@Documented
-@Target(PARAMETER)
-@Retention(RUNTIME)
-public @interface Body {
-}
\ No newline at end of file
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Credentials.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Credentials.java
deleted file mode 100644
index dbc1f17c..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Credentials.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.infobip.mobile.messaging.api.support.http;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-/**
- * Sets credentials for basic authorization.
- */
-@Documented
-@Target({METHOD, TYPE, PACKAGE})
-@Retention(RUNTIME)
-public @interface Credentials {
- String user() default "";
- String password() default "";
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Header.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Header.java
deleted file mode 100644
index 6de1db87..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Header.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.infobip.mobile.messaging.api.support.http;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-/**
- * Make a POST request.
- */
-@Documented
-@Target({PARAMETER, METHOD})
-@Retention(RUNTIME)
-public @interface Header {
- String name() default "";
- String[] value() default "";
-}
\ No newline at end of file
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Headers.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Headers.java
deleted file mode 100644
index 3a9a57da..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Headers.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.infobip.mobile.messaging.api.support.http;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-/**
- * Make a POST request.
- */
-@Documented
-@Target(METHOD)
-@Retention(RUNTIME)
-public @interface Headers {
- Header[] value() default {};
-}
\ No newline at end of file
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/HttpRequest.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/HttpRequest.java
deleted file mode 100644
index 3e774ad0..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/HttpRequest.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.infobip.mobile.messaging.api.support.http;
-
-import org.infobip.mobile.messaging.api.support.http.client.HttpMethod;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-/**
- * Make a HTTP request.
- */
-@Documented
-@Target({METHOD, TYPE})
-@Retention(RUNTIME)
-public @interface HttpRequest {
-
- HttpMethod method() default HttpMethod.GET;
-
- /**
- * A relative or absolute path, or full URL of the endpoint. This value is optional if the first
- * parameter of the method is annotated with @Url.
- */
- String value() default "";
-}
\ No newline at end of file
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Path.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Path.java
deleted file mode 100644
index c0b98b6c..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Path.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.infobip.mobile.messaging.api.support.http;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-/**
- * Make a POST request.
- */
-@Documented
-@Target({PARAMETER, METHOD})
-@Retention(RUNTIME)
-public @interface Path {
- String name() default "";
- String value() default "";
-}
\ No newline at end of file
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Paths.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Paths.java
deleted file mode 100644
index a5acb955..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Paths.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.infobip.mobile.messaging.api.support.http;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-/**
- * Make a POST request.
- */
-@Documented
-@Target(METHOD)
-@Retention(RUNTIME)
-public @interface Paths {
- Path[] value() default {};
-}
\ No newline at end of file
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Queries.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Queries.java
deleted file mode 100644
index 182a725a..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Queries.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.infobip.mobile.messaging.api.support.http;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-/**
- * Make a POST request.
- */
-@Documented
-@Target(METHOD)
-@Retention(RUNTIME)
-public @interface Queries {
- Query[] value() default {};
-}
\ No newline at end of file
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Query.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Query.java
deleted file mode 100644
index 3b1a0104..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Query.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.infobip.mobile.messaging.api.support.http;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-/**
- * Make a POST request.
- */
-@Documented
-@Target({PARAMETER, METHOD})
-@Retention(RUNTIME)
-public @interface Query {
- String name() default "";
- String[] value() default "";
-}
\ No newline at end of file
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Version.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Version.java
deleted file mode 100644
index caf82874..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/Version.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.infobip.mobile.messaging.api.support.http;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-/**
- * Make a HTTP request.
- */
-@Documented
-@Target({PACKAGE, TYPE, METHOD})
-@Retention(RUNTIME)
-public @interface Version {
- String value() default "";
-}
\ No newline at end of file
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/ApiClient.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/ApiClient.java
deleted file mode 100644
index 4682efc4..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/ApiClient.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.infobip.mobile.messaging.api.support.http.client;
-
-import org.infobip.mobile.messaging.api.support.Tuple;
-
-import java.util.Collection;
-import java.util.Map;
-
-/**
- * @author mstipanov
- * @since 08.03.2016.
- */
-public interface ApiClient {
- R execute(HttpMethod method, String uri, String apiKey, Tuple credentials, Map> queryParams, Map> headers, B body, Class returnType);
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/DefaultApiClient.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/DefaultApiClient.java
deleted file mode 100644
index d822f671..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/DefaultApiClient.java
+++ /dev/null
@@ -1,332 +0,0 @@
-package org.infobip.mobile.messaging.api.support.http.client;
-
-import org.infobip.mobile.messaging.api.support.ApiBackendException;
-import org.infobip.mobile.messaging.api.support.ApiBackendExceptionWithContent;
-import org.infobip.mobile.messaging.api.support.ApiException;
-import org.infobip.mobile.messaging.api.support.ApiIOException;
-import org.infobip.mobile.messaging.api.support.Tuple;
-import org.infobip.mobile.messaging.api.support.http.client.model.ApiResponse;
-import org.infobip.mobile.messaging.api.support.http.serialization.JsonSerializer;
-import org.infobip.mobile.messaging.api.support.util.Base64Encoder;
-import org.infobip.mobile.messaging.api.support.util.StreamUtils;
-import org.infobip.mobile.messaging.api.support.util.StringUtils;
-
-import java.io.BufferedOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.net.URLEncoder;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.SSLHandshakeException;
-
-/**
- * @author mstipanov
- * @since 08.03.2016.
- */
-public class DefaultApiClient implements ApiClient {
- public static final int DEFAULT_CONNECT_TIMEOUT = 5000;
-
- public static final int DEFAULT_READ_TIMEOUT = 60000;
-
- public static final JsonSerializer JSON_SERIALIZER = new JsonSerializer();
- private static final JsonSerializer JSON_SERIALIZER_WITH_NULLS = new JsonSerializer(true);
-
- private final int connectTimeout;
- private final int readTimeout;
- private final String libraryVersion;
- private final String[] userAgentAdditions;
- private final RequestInterceptor[] requestInterceptors;
- private final ResponsePreProcessor[] responsePreProcessors;
- private final Logger logger;
- private final boolean allowUntrustedSSLOnError;
- private String userAgent;
-
- public DefaultApiClient() {
- this(DEFAULT_CONNECT_TIMEOUT, DEFAULT_READ_TIMEOUT, null, new RequestInterceptor[0], new ResponsePreProcessor[0], new Logger(), false);
- }
-
- public DefaultApiClient(int connectTimeout, int readTimeout, String libraryVersion, RequestInterceptor[] interceptors, ResponsePreProcessor[] responsePreProcessors, Logger logger, boolean allowUntrustedSSLOnError, String... userAgentAdditions) {
- this.connectTimeout = connectTimeout;
- this.readTimeout = readTimeout;
- this.libraryVersion = libraryVersion;
- this.requestInterceptors = interceptors;
- this.responsePreProcessors = responsePreProcessors;
- this.userAgentAdditions = userAgentAdditions;
- this.logger = logger;
- this.allowUntrustedSSLOnError = allowUntrustedSSLOnError;
- }
-
- @Override
- public R execute(HttpMethod method, String uri, String apiKey, Tuple credentials, Map> queryParams, Map> headers, B body, Class responseType) {
- Request request = new Request(method, uri, apiKey, credentials, headers, queryParams, body);
- for (RequestInterceptor interceptor : requestInterceptors) {
- try {
- request = interceptor.intercept(request);
- } catch (Exception e) {
- logger.e("Request interceptor " + interceptor + " thrown an exception " + e);
- }
- }
-
- logger.d("REQUEST: " + request);
-
- try {
- StringBuilder sb = new StringBuilder();
- for (Map.Entry> entry : request.queryParams.entrySet()) {
- appendValue(sb, entry);
- }
-
- try {
- return executeHTTP(request, responseType, false);
- } catch (SSLHandshakeException ex) {
- logger.w("Got SSL handshake exception " + ex);
- if (allowUntrustedSSLOnError) {
- logger.w("Will re-try in untrusted mode");
- return executeHTTP(request, responseType, true);
- } else {
- throw ex;
- }
- }
- } catch (Exception e) {
- interceptErrorResponse(e);
- if (e instanceof ApiIOException) {
- throw (ApiIOException) e;
- }
- throw new ApiIOException(ErrorCode.API_IO_ERROR.value, ErrorCode.API_IO_ERROR.description + " : " + request.uri, e);
- }
- }
-
- private R executeHTTP(Request request, Class responseType, boolean tryUntrustedSSL) throws IOException {
- HttpURLConnection urlConnection = null;
- try {
- StringBuilder sb = new StringBuilder();
- for (Map.Entry> entry : request.queryParams.entrySet()) {
- appendValue(sb, entry);
- }
-
- urlConnection = (HttpURLConnection) new URL(request.uri + sb.toString()).openConnection();
-
- if (request.httpMethod == HttpMethod.PATCH) {
- urlConnection.setRequestProperty("X-HTTP-Method-Override", HttpMethod.PATCH.name());
- urlConnection.setRequestMethod(HttpMethod.POST.name());
- } else {
- urlConnection.setRequestMethod(request.httpMethod.name());
- }
-
- if (request.httpMethod != HttpMethod.GET) {
- urlConnection.setDoOutput(true);
- }
-
- urlConnection.setUseCaches(false);
- urlConnection.setDoInput(true);
- urlConnection.setConnectTimeout(connectTimeout);
- urlConnection.setReadTimeout(readTimeout);
-
- if (tryUntrustedSSL && urlConnection instanceof HttpsURLConnection) {
- UntrustedSSLHelper.trustAllCerts(((HttpsURLConnection) urlConnection));
- }
-
- if (null != request.headers) {
- for (Map.Entry> entry : request.headers.entrySet()) {
- Collection value = entry.getValue();
- if (null == value || value.isEmpty()) {
- continue;
- }
-
- String key = entry.getKey().trim();
- if (key.equalsIgnoreCase("Content-Length")) {
- continue;
- }
- for (Object v : value) {
- if (v == null) continue;
- urlConnection.setRequestProperty(key, v.toString());
- }
- }
- }
- if (StringUtils.isNotBlank(request.apiKey)) {
- urlConnection.setRequestProperty("Authorization", "App " + request.apiKey);
- } else if (request.credentials != null && StringUtils.isNotBlank(request.credentials.getLeft()) && StringUtils.isNotBlank(request.credentials.getRight())) {
- String basicApiKey = Base64Encoder.encode(request.credentials.getLeft() + ":" + request.credentials.getRight());
- urlConnection.setRequestProperty("Authorization", "Basic " + basicApiKey);
- }
- urlConnection.setRequestProperty("Accept", "application/json");
- String userAgent = urlConnection.getRequestProperty("User-Agent");
- if (null == userAgent) {
- urlConnection.setRequestProperty("User-Agent", getUserAgent());
- }
-
- if (null != request.body) {
- byte[] bytes = jsonSerializer(request.httpMethod).serialize(request.body).getBytes("UTF-8");
- urlConnection.setRequestProperty("Content-Length", "" + bytes.length);
- urlConnection.setRequestProperty("Content-Type", "application/json");
- OutputStream outputStream = null;
- try {
- outputStream = new BufferedOutputStream(urlConnection.getOutputStream());
- outputStream.write(bytes);
- outputStream.flush();
- } finally {
- StreamUtils.closeSafely(outputStream);
- }
- }
-
- int responseCode = urlConnection.getResponseCode();
- interceptResponse(responseCode, urlConnection.getHeaderFields());
- int contentLength = urlConnection.getContentLength();
- if (responseCode >= 400) {
- ApiResponse apiResponse = new ApiResponse(ErrorCode.UNKNOWN_ERROR.value, ErrorCode.UNKNOWN_ERROR.description);
- if (contentLength > 0) {
- InputStream inputStream = urlConnection.getErrorStream();
- String s = StreamUtils.readToString(inputStream, "UTF-8", contentLength);
- apiResponse = jsonSerializer(request.httpMethod).deserialize(s, ApiResponse.class);
- }
-
- if (responseCode >= 500) {
- Tuple tuple = safeGetErrorInfo(apiResponse, ErrorCode.UNKNOWN_API_BACKEND_ERROR.value, ErrorCode.UNKNOWN_API_BACKEND_ERROR.description);
- throw new ApiBackendException(tuple.getLeft(), tuple.getRight());
- }
-
- Tuple tuple = safeGetErrorInfo(apiResponse, ErrorCode.UNKNOWN_API_ERROR.value, ErrorCode.UNKNOWN_API_ERROR.description);
- throw new ApiException(tuple.getLeft(), tuple.getRight());
- }
-
- if (Void.class.equals(responseType) || void.class.equals(responseType) || responseType == null) {
- return null;
- }
-
- InputStream inputStream = urlConnection.getInputStream();
- String s = StreamUtils.readToString(inputStream, "UTF-8", contentLength);
- inputStream.close();
-
- R response = jsonSerializer(request.httpMethod).deserialize(s, responseType);
- ApiResponse apiResponse = null;
- try {
- apiResponse = jsonSerializer(request.httpMethod).deserialize(s, ApiResponse.class);
- } catch (Exception ignored) {
- }
-
- if (apiResponse != null && apiResponse.getRequestError() != null) {
- Tuple tuple = safeGetErrorInfo(apiResponse, ErrorCode.UNKNOWN_API_BACKEND_ERROR.value, ErrorCode.UNKNOWN_API_BACKEND_ERROR.description);
- throw new ApiBackendExceptionWithContent(tuple.getLeft(), tuple.getRight(), response);
- }
-
- return response;
- } finally {
- try {
- if (urlConnection != null) {
- urlConnection.disconnect();
- }
- } catch (Exception ignored) {
-
- }
- }
- }
-
- private void interceptErrorResponse(Exception error) {
- for (ResponsePreProcessor responsePreProcessor : responsePreProcessors) {
- try {
- responsePreProcessor.beforeResponse(error);
- } catch (Exception e) {
- logger.e("Response interceptor " + responsePreProcessor + " thrown an exception " + e);
- }
- }
- }
-
- private void interceptResponse(int httpStatusCode, Map> responseHeaders) {
- for (ResponsePreProcessor responsePreProcessor : responsePreProcessors) {
- try {
- responsePreProcessor.beforeResponse(httpStatusCode, responseHeaders);
- } catch (Exception e) {
- logger.e("Response interceptor " + responsePreProcessor + " thrown an exception " + e);
- }
- }
- }
-
- private String getUserAgent() {
- if (null != userAgent) {
- return userAgent;
- }
- StringBuilder sb = new StringBuilder();
- sb.append("Infobip Mobile API Client");
- if (StringUtils.isNotBlank(libraryVersion)) {
- sb.append("/").append(libraryVersion);
- }
- sb.append("(");
- if (null != userAgentAdditions) {
- sb.append(StringUtils.join(";", userAgentAdditions));
- }
- sb.append(")");
- userAgent = sb.toString();
- return userAgent;
- }
-
- private Tuple safeGetErrorInfo(ApiResponse apiResponse, String code, String message) {
- if (null == apiResponse) {
- return new Tuple<>(code, message);
- }
-
- if (null == apiResponse.getRequestError()) {
- return new Tuple<>(code, message);
- }
-
- if (null == apiResponse.getRequestError().getServiceException()) {
- return new Tuple<>(code, message);
- }
-
- return new Tuple<>(apiResponse.getRequestError().getServiceException().getMessageId(), apiResponse.getRequestError().getServiceException().getText());
- }
-
- private void appendValue(StringBuilder sb, Map.Entry> entry) throws UnsupportedEncodingException {
- if (null == entry) {
- return;
- }
-
- Collection value = entry.getValue();
- if (null == value || value.isEmpty()) {
- return;
- }
-
- for (Object v : value) {
- String s = v.toString();
- if (StringUtils.isBlank(s)) {
- s = "";
- }
- sb.append(sb.length() == 0 ? "?" : "&").append(URLEncoder.encode(entry.getKey(), "UTF-8")).append("=").append(URLEncoder.encode(s, "UTF-8"));
- }
- }
-
- private static JsonSerializer jsonSerializer(HttpMethod httpMethod) {
- if (httpMethod == HttpMethod.PATCH) {
- return JSON_SERIALIZER_WITH_NULLS;
- }
- return JSON_SERIALIZER;
- }
-
- public enum ErrorCode {
- UNKNOWN_ERROR("-1", "Unknown error"), // responseCode >= 400
- UNKNOWN_API_BACKEND_ERROR("-2", "Unknown API backend error"), // responseCode >= 500
- UNKNOWN_API_ERROR("-3", "Unknown API error"), // apiResponse == null
- API_IO_ERROR("-4", "Can't access URI"); // Can't access URI (404?)
-
- private final String value;
- private final String description;
-
- ErrorCode(String value, String description) {
- this.value = value;
- this.description = description;
- }
-
- public String getValue() {
- return value;
- }
-
- public String getDescription() {
- return description;
- }
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/HttpMethod.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/HttpMethod.java
deleted file mode 100644
index 3f6e86e4..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/HttpMethod.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.infobip.mobile.messaging.api.support.http.client;
-
-/**
- * @author mstipanov
- * @since 08.03.2016.
- */
-public enum HttpMethod {
- GET, POST, PUT, DELETE, PATCH, OPTIONS
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/Logger.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/Logger.java
deleted file mode 100644
index 41d4b70c..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/Logger.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.infobip.mobile.messaging.api.support.http.client;
-
-/**
- * Logger for http layer, empty by default
- *
- * @author sslavin
- * @since 27/11/2017.
- */
-
-public class Logger {
- public void i(String message) {
- }
-
- public void w(String message) {
- }
-
- public void e(String message) {
- }
-
- public void d(String message) {
-
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/Request.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/Request.java
deleted file mode 100644
index 4d8cee11..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/Request.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.infobip.mobile.messaging.api.support.http.client;
-
-import org.infobip.mobile.messaging.api.support.Tuple;
-
-import java.util.Collection;
-import java.util.Map;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-
-/**
- * @author sslavin
- * @since 27/11/2017.
- */
-
-@Data
-@AllArgsConstructor
-public class Request {
- protected HttpMethod httpMethod;
- protected String uri;
- protected String apiKey;
- protected Tuple credentials;
- protected Map> headers;
- protected Map> queryParams;
- protected Object body;
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/RequestInterceptor.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/RequestInterceptor.java
deleted file mode 100644
index cf408415..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/RequestInterceptor.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.infobip.mobile.messaging.api.support.http.client;
-
-/**
- * @author sslavin
- * @since 27/11/2017.
- */
-
-public interface RequestInterceptor {
- Request intercept(Request request);
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/ResponsePreProcessor.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/ResponsePreProcessor.java
deleted file mode 100644
index 6502425f..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/ResponsePreProcessor.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.infobip.mobile.messaging.api.support.http.client;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author sslavin
- * @since 27/11/2017.
- */
-
-public interface ResponsePreProcessor {
- void beforeResponse(int responseCode, Map> headers);
- void beforeResponse(Exception error);
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/UntrustedSSLHelper.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/UntrustedSSLHelper.java
deleted file mode 100644
index 3abf4fa7..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/UntrustedSSLHelper.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.infobip.mobile.messaging.api.support.http.client;
-
-import java.security.SecureRandom;
-import java.security.cert.X509Certificate;
-
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
-
-class UntrustedSSLHelper {
-
- private static TrustManager[] trustAllCerts = new TrustManager[]{
- new X509TrustManager() {
- public X509Certificate[] getAcceptedIssuers() {
- return null;
- }
-
- public void checkClientTrusted(X509Certificate[] certs, String authType) {
- }
-
- public void checkServerTrusted(X509Certificate[] certs, String authType) {
- }
- }
- };
-
- static void trustAllCerts(HttpsURLConnection urlConnection) {
- try {
- SSLContext sc = SSLContext.getInstance("SSL");
- sc.init(null, trustAllCerts, new SecureRandom());
- urlConnection.setSSLSocketFactory(sc.getSocketFactory());
- } catch (Exception e) {
- System.err.println("Cannot instantiate trust-all ssl context: " + e);
- }
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/model/ApiError.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/model/ApiError.java
deleted file mode 100644
index 5654e46a..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/model/ApiError.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.infobip.mobile.messaging.api.support.http.client.model;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-/**
- * @author mstipanov
- * @since 08.03.2016.
- */
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class ApiError {
- private ApiServiceException serviceException;
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/model/ApiResponse.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/model/ApiResponse.java
deleted file mode 100644
index edfd07c5..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/model/ApiResponse.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.infobip.mobile.messaging.api.support.http.client.model;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-/**
- * @author mstipanov
- * @since 08.03.2016.
- */
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class ApiResponse {
- private ApiError requestError;
-
- public ApiResponse(String code, String text) {
- requestError = new ApiError(new ApiServiceException(code, text));
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/model/ApiServiceException.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/model/ApiServiceException.java
deleted file mode 100644
index f7a9bbe2..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/client/model/ApiServiceException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.infobip.mobile.messaging.api.support.http.client.model;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.NoArgsConstructor;
-
-/**
- * @author mstipanov
- * @since 08.03.2016.
- */
-@SuppressWarnings("DefaultAnnotationParam")
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-@EqualsAndHashCode(callSuper = false)
-public class ApiServiceException extends RuntimeException {
- private String messageId;
- private String text;
-
- @Override
- public String getMessage() {
- return getText();
- }
-
- @Override
- public String getLocalizedMessage() {
- return getText();
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/serialization/JsonSerializer.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/serialization/JsonSerializer.java
deleted file mode 100644
index cb61eddb..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/http/serialization/JsonSerializer.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package org.infobip.mobile.messaging.api.support.http.serialization;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParser;
-import com.google.gson.TypeAdapter;
-import com.google.gson.stream.JsonReader;
-import com.google.gson.stream.JsonWriter;
-
-import java.io.IOException;
-import java.lang.reflect.Type;
-
-/**
- * @author mstipanov
- * @since 08.03.2016.
- */
-public class JsonSerializer {
-
- public interface ObjectAdapter {
- Class getCls();
- T deserialize(String value);
- String serialize(T value);
- }
-
- private class CustomTypeAdapter extends TypeAdapter {
-
- private final ObjectAdapter adapter;
-
- CustomTypeAdapter(ObjectAdapter adapter) {
- this.adapter = adapter;
- }
-
- @Override
- public void write(JsonWriter out, Object value) throws IOException {
- //noinspection unchecked
- out.jsonValue(adapter.serialize(value));
- }
-
- @Override
- public Object read(JsonReader in) throws IOException {
- JsonElement element = new JsonParser().parse(in);
- return adapter.deserialize(element.toString());
- }
- }
-
- public JsonSerializer() {
- gson = new GsonBuilder().create();
- }
-
- public JsonSerializer(boolean serializeNulls, ObjectAdapter... adapters) {
- GsonBuilder builder = new GsonBuilder();
- if (serializeNulls) {
- builder.serializeNulls();
- }
- if (adapters.length > 0) {
- for (ObjectAdapter adapter : adapters) {
- builder.registerTypeHierarchyAdapter(adapter.getCls(), new CustomTypeAdapter(adapter));
- }
- }
- gson = builder.create();
- }
-
- private final Gson gson;
-
- public T deserialize(String s, Class type) {
- return gson.fromJson(s, type);
- }
-
- public T deserialize(String s, Type type) {
- return gson.fromJson(s, type);
- }
-
- public String serialize(T t) {
- return gson.toJson(t);
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/util/Base64Encoder.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/util/Base64Encoder.java
deleted file mode 100644
index a4499905..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/util/Base64Encoder.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package org.infobip.mobile.messaging.api.support.util;
-
-// taken from: https://gist.github.com/EmilHernvall/953733
-public class Base64Encoder {
-
- public static String encode(String string) {
- return encode(string.getBytes());
- }
-
- public static String encode(byte[] data) {
- char[] tbl = {
- 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
- 'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',
- 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
- 'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/' };
-
- StringBuilder buffer = new StringBuilder();
- int pad = 0;
- for (int i = 0; i < data.length; i += 3) {
-
- int b = ((data[i] & 0xFF) << 16) & 0xFFFFFF;
- if (i + 1 < data.length) {
- b |= (data[i+1] & 0xFF) << 8;
- } else {
- pad++;
- }
- if (i + 2 < data.length) {
- b |= (data[i+2] & 0xFF);
- } else {
- pad++;
- }
-
- for (int j = 0; j < 4 - pad; j++) {
- int c = (b & 0xFC0000) >> 18;
- buffer.append(tbl[c]);
- b <<= 6;
- }
- }
- for (int j = 0; j < pad; j++) {
- buffer.append("=");
- }
-
- return buffer.toString();
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/util/CollectionUtils.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/util/CollectionUtils.java
deleted file mode 100644
index 5f54d5c2..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/util/CollectionUtils.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package org.infobip.mobile.messaging.api.support.util;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-public class CollectionUtils {
- public static boolean isEmpty(Collection collection) {
- return collection == null || collection.isEmpty();
- }
-
- public static boolean isNotEmpty(Collection collection) {
- return !isEmpty(collection);
- }
-
- @SafeVarargs
- public static , T> C concat(C... cs) {
- List collections = new LinkedList<>(Arrays.asList(cs));
- for (Iterator iterator = collections.iterator(); iterator.hasNext(); ) {
- C collection = iterator.next();
- if (collection == null) {
- iterator.remove();
- }
- }
-
- if (collections.isEmpty()) {
- return null;
- }
-
- C result = collections.get(0);
- for (int i = 1; i < collections.size(); i++) {
- result.addAll(collections.get(i));
- }
- return result;
- }
-
- @SafeVarargs
- public static Set setOf(T... ts) {
- return new HashSet<>(Arrays.asList(ts));
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/util/MapUtils.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/util/MapUtils.java
deleted file mode 100644
index f8e7d895..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/util/MapUtils.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.infobip.mobile.messaging.api.support.util;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author mstipanov
- * @since 08.03.2016.
- */
-public abstract class MapUtils {
- public static Map> map(Object... kvargs) {
- HashMap> hashMap = new HashMap<>();
- for (int i = 0; i < kvargs.length; i += 2) {
- hashMap.put(kvargs[i].toString(), Collections.singleton(kvargs[i + 1]));
- }
- return hashMap;
- }
-
- @SafeVarargs
- public static Map concat(Map... mps) {
- return concat(null, mps);
- }
-
- @SafeVarargs
- public static Map concatOrEmpty(Map... mps) {
- return MapUtils.concat(Collections.emptyMap(), mps);
- }
-
- @SafeVarargs
- private static Map concat(Map valueIfEmpty, Map... mps) {
- List> maps = new LinkedList<>(Arrays.asList(mps));
- for (Iterator> iterator = maps.iterator(); iterator.hasNext(); ) {
- Map map = iterator.next();
- if (map == null) {
- iterator.remove();
- }
- }
-
- if (maps.isEmpty()) {
- return valueIfEmpty;
- }
-
- Map result = new HashMap<>();
- for (int i = 0; i < maps.size(); i++) {
- result.putAll(maps.get(i));
- }
- return result;
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/util/ReflectionUtils.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/util/ReflectionUtils.java
deleted file mode 100644
index 4822ebf6..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/util/ReflectionUtils.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.infobip.mobile.messaging.api.support.util;
-
-import java.io.IOException;
-import java.net.URL;
-
-/**
- * @author mstipanov
- * @since 07.03.2016.
- */
-public abstract class ReflectionUtils {
- private ReflectionUtils() {
- }
-
- public static void loadPackageInfo(String packageName) throws ClassNotFoundException, IOException {
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- assert classLoader != null;
- URL pgkInfo = classLoader.getResource(packageName.replace('.', '/') + "/package-info.class");
- if (null != pgkInfo) {
- Class.forName(packageName + '.' + "package-info");
- }
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/util/StreamUtils.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/util/StreamUtils.java
deleted file mode 100644
index 24f8b6ed..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/util/StreamUtils.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.infobip.mobile.messaging.api.support.util;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * @author mstipanov
- * @since 03.03.2016.
- */
-public abstract class StreamUtils {
- private StreamUtils() {
- }
-
- public static String readToString(InputStream inputStream, String charsetName, long length) throws IOException {
- ByteArrayOutputStream buf = new ByteArrayOutputStream();
- int result = inputStream.read();
- long count = 1;
- while (result != -1) {
- byte b = (byte) result;
- buf.write(b);
- if (count == length) {
- break;
- }
- result = inputStream.read();
- count++;
- }
-
- String stringFromStream = buf.toString(charsetName);
- if (stringFromStream.length() < 1) {
- return "";
- }
- return stringFromStream;
- }
-
- public static long write(String s, OutputStream outputStream, String charsetName) throws IOException {
- return write(s.getBytes(charsetName), outputStream);
- }
-
- private static long write(byte[] bytes, OutputStream outputStream) throws IOException {
- outputStream.write(bytes);
- return bytes.length;
- }
-
- public static void closeSafely(OutputStream outputStream) {
- if (null == outputStream) {
- return;
- }
-
- try {
- outputStream.close();
- } catch (IOException e) {
- //ignore
- }
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/util/StringUtils.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/util/StringUtils.java
deleted file mode 100644
index 7f06d9a7..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/support/util/StringUtils.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package org.infobip.mobile.messaging.api.support.util;
-
-/**
- * @author mstipanov
- * @since 07.03.2016.
- */
-public abstract class StringUtils {
- private StringUtils() {
- }
-
- public static boolean isNotBlank(String s) {
- return !isBlank(s);
- }
-
- public static boolean isBlank(String s) {
- return null == s || s.trim().isEmpty();
- }
-
- public static String join(String separator, String... uris) {
- if (null == uris || uris.length == 0) {
- return null;
- }
-
- StringBuilder sb = new StringBuilder();
- boolean endingWithSeparator = true;
- for (String uri : uris) {
- if (null == uri) {
- uri = "";
- }
- if (!endingWithSeparator && !uri.startsWith(separator)) {
- sb.append(separator);
- endingWithSeparator = true;
- }
-
- if (endingWithSeparator && uri.startsWith(separator) && sb.length() > 0) {
- sb.setLength(sb.length() - 1);
- }
-
- sb.append(uri);
- endingWithSeparator = uri.endsWith(separator);
- }
- return sb.toString();
- }
-
- public static boolean equals(String one, String two) {
- if (isBlank(one) && isBlank(two)) {
- return true;
- }
-
- return ("" + one).equals(two);
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/version/LatestReleaseResponse.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/version/LatestReleaseResponse.java
deleted file mode 100644
index f88d1668..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/version/LatestReleaseResponse.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.infobip.mobile.messaging.api.version;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-/**
- * Latest release version response.
- *
- * @author sslavin
- * @see MobileApiVersion
- * @see MobileApiVersion#getLatestRelease()
- * @since 03.10.2016.
- */
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class LatestReleaseResponse {
- String platformType;
- String libraryVersion;
- String updateUrl;
-}
diff --git a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/version/MobileApiVersion.java b/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/version/MobileApiVersion.java
deleted file mode 100644
index 2f30373e..00000000
--- a/infobip-mobile-messaging-api-java/src/main/java/org/infobip/mobile/messaging/api/version/MobileApiVersion.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.infobip.mobile.messaging.api.version;
-
-import org.infobip.mobile.messaging.api.support.Generator;
-import org.infobip.mobile.messaging.api.support.http.ApiKey;
-import org.infobip.mobile.messaging.api.support.http.HttpRequest;
-import org.infobip.mobile.messaging.api.support.http.Query;
-import org.infobip.mobile.messaging.api.support.http.Version;
-import org.infobip.mobile.messaging.api.support.http.client.HttpMethod;
-
-/**
- * Mobile API to retrieve details of latest library release.
- *
- * Usage:
- *
{@code
- * MobileApiVersion mobileApiLibraryVersion = new Generator.Builder().build().create(MobileApiVersion.class);
- * }
- *
- * @author sslavin
- * @see Generator
- * @see Generator.Builder
- * @since 03.10.2016.
- */
-@Version("3")
-@ApiKey("${api.key}")
-@HttpRequest("/mobile/{version}")
-public interface MobileApiVersion {
-
- /**
- * Retrieves latest library release version from the server.
- *
- * @return {@link LatestReleaseResponse}
- */
- @HttpRequest(method = HttpMethod.GET, value = "version")
- @Query(name = "platformType", value = "${platform.type:GCM}")
- LatestReleaseResponse getLatestRelease();
-}
diff --git a/infobip-mobile-messaging-api-java/src/test/java/it/org/infobip/mobile/messaging/api/MobileApiAppInstanceTest.java b/infobip-mobile-messaging-api-java/src/test/java/it/org/infobip/mobile/messaging/api/MobileApiAppInstanceTest.java
deleted file mode 100644
index 3217b4da..00000000
--- a/infobip-mobile-messaging-api-java/src/test/java/it/org/infobip/mobile/messaging/api/MobileApiAppInstanceTest.java
+++ /dev/null
@@ -1,393 +0,0 @@
-package it.org.infobip.mobile.messaging.api;
-
-import org.infobip.mobile.messaging.api.appinstance.AppInstance;
-import org.infobip.mobile.messaging.api.appinstance.MobileApiAppInstance;
-import org.infobip.mobile.messaging.api.appinstance.UserBody;
-import org.infobip.mobile.messaging.api.appinstance.UserCustomEventBody;
-import org.infobip.mobile.messaging.api.appinstance.UserPersonalizeBody;
-import org.infobip.mobile.messaging.api.appinstance.UserSessionEventBody;
-import org.infobip.mobile.messaging.api.support.ApiBackendException;
-import org.infobip.mobile.messaging.api.support.ApiException;
-import org.infobip.mobile.messaging.api.support.ApiIOException;
-import org.infobip.mobile.messaging.api.support.Generator;
-import org.infobip.mobile.messaging.api.support.http.client.DefaultApiClient;
-import org.infobip.mobile.messaging.api.support.http.client.HttpMethod;
-import org.infobip.mobile.messaging.api.support.http.client.model.ApiResponse;
-import org.infobip.mobile.messaging.api.tools.DebugServer;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Properties;
-
-import fi.iki.elonen.NanoHTTPD;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-
-public class MobileApiAppInstanceTest {
-
- private DebugServer debugServer;
- private MobileApiAppInstance mobileApiAppInstance;
- private String regId = "1234regId567";
-
- @Before
- public void setUp() throws Exception {
- debugServer = new DebugServer();
- debugServer.start();
-
- Properties properties = new Properties();
- properties.put("api.key", "my_API_key");
- Generator generator = new Generator.Builder()
- .withBaseUrl("http://127.0.0.1:" + debugServer.getListeningPort() + "/")
- .withProperties(properties)
- .build();
-
- mobileApiAppInstance = generator.create(MobileApiAppInstance.class);
- }
-
- @After
- public void tearDown() throws Exception {
- if (null != debugServer) {
- try {
- debugServer.stop();
- } catch (Exception e) {
- //ignore
- }
- }
- }
-
- @Test
- public void create_instance_success_examineResponse() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.OK, null);
-
- mobileApiAppInstance.createInstance(new AppInstance());
-
- //inspect http context
- assertEquals("/mobile/1/appinstance", debugServer.getUri());
- assertEquals(1, debugServer.getRequestCount());
- assertEquals(NanoHTTPD.Method.POST, debugServer.getRequestMethod());
- assertEquals(1, debugServer.getQueryParametersCount());
- assertEquals("true", debugServer.getQueryParameter("ri"));
- assertEquals("App my_API_key", debugServer.getHeader("Authorization"));
- }
-
- @Test
- public void patch_instance_success_examineResponse() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.OK, null);
-
- mobileApiAppInstance.patchInstance(regId, new HashMap());
-
- //inspect http context
- assertEquals("/mobile/1/appinstance/1234regId567", debugServer.getUri());
- assertEquals(1, debugServer.getRequestCount());
- assertEquals(NanoHTTPD.Method.POST, debugServer.getRequestMethod());
- assertEquals(HttpMethod.PATCH.name(), debugServer.getHeader("X-HTTP-Method-Override"));
- assertEquals("App my_API_key", debugServer.getHeader("Authorization"));
- assertEquals(0, debugServer.getQueryParametersCount());
- }
-
- @Test
- public void get_instance_success_examineResponse() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.OK, null);
-
- mobileApiAppInstance.getInstance(regId);
-
- //inspect http context
- assertEquals("/mobile/1/appinstance/1234regId567", debugServer.getUri());
- assertEquals(NanoHTTPD.Method.GET, debugServer.getRequestMethod());
- assertEquals("App my_API_key", debugServer.getHeader("Authorization"));
- assertEquals(1, debugServer.getRequestCount());
- assertEquals(0, debugServer.getQueryParametersCount());
- }
-
- @Test
- public void patch_userData_success_examineResponse() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.OK, null);
-
- mobileApiAppInstance.patchUser(regId, new HashMap());
-
- //inspect http context
- assertEquals("/mobile/1/appinstance/1234regId567/user", debugServer.getUri());
- assertEquals(NanoHTTPD.Method.POST, debugServer.getRequestMethod());
- assertEquals(HttpMethod.PATCH.name(), debugServer.getHeader("X-HTTP-Method-Override"));
- assertEquals("App my_API_key", debugServer.getHeader("Authorization"));
- assertEquals(1, debugServer.getRequestCount());
- assertEquals(0, debugServer.getQueryParametersCount());
- }
-
- @Test
- public void get_userData_success_examineResponse() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.OK, null);
-
- mobileApiAppInstance.getUser(regId);
-
- //inspect http context
- assertEquals("/mobile/1/appinstance/1234regId567/user", debugServer.getUri());
- assertEquals(NanoHTTPD.Method.GET, debugServer.getRequestMethod());
- assertEquals("App my_API_key", debugServer.getHeader("Authorization"));
- assertEquals("true", debugServer.getQueryParameter("ri"));
- assertEquals(1, debugServer.getRequestCount());
- assertEquals(1, debugServer.getQueryParametersCount());
- }
-
- @Test
- public void repersonalize_success_examineResponse() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.OK, null);
-
- mobileApiAppInstance.repersonalize(regId, new UserPersonalizeBody());
-
- //inspect http context
- assertEquals("/mobile/1/appinstance/1234regId567/repersonalize", debugServer.getUri());
- assertEquals(NanoHTTPD.Method.POST, debugServer.getRequestMethod());
- assertEquals("App my_API_key", debugServer.getHeader("Authorization"));
- assertEquals(1, debugServer.getRequestCount());
- assertEquals(0, debugServer.getQueryParametersCount());
- }
-
- @Test
- public void personalize_success_examineResponse() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.OK, null);
-
- mobileApiAppInstance.personalize(regId, true, new UserPersonalizeBody());
-
- //inspect http context
- assertEquals("/mobile/1/appinstance/1234regId567/personalize", debugServer.getUri());
- assertEquals("true", debugServer.getQueryParameter("forceDepersonalize"));
- assertEquals(NanoHTTPD.Method.POST, debugServer.getRequestMethod());
- assertEquals("App my_API_key", debugServer.getHeader("Authorization"));
- assertEquals(1, debugServer.getRequestCount());
- assertEquals(1, debugServer.getQueryParametersCount());
- }
-
- @Test
- public void depersonalize_success_examineResponse() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.OK, null);
-
- mobileApiAppInstance.depersonalize(regId);
-
- //inspect http context
- assertEquals("/mobile/1/appinstance/1234regId567/depersonalize", debugServer.getUri());
- assertEquals(NanoHTTPD.Method.POST, debugServer.getRequestMethod());
- assertEquals("App my_API_key", debugServer.getHeader("Authorization"));
- assertEquals(1, debugServer.getRequestCount());
- assertEquals(0, debugServer.getQueryParametersCount());
- }
-
- @Test(expected = ApiIOException.class)
- public void createInstance_onConnectionError_throwsError() throws Exception {
- debugServer.stop();
- debugServer = null;
-
- mobileApiAppInstance.createInstance(new AppInstance());
- }
-
- @Test(expected = ApiException.class)
- public void createInstance_onResponseError_throwsError() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.BAD_REQUEST, DefaultApiClient.JSON_SERIALIZER.serialize(new ApiResponse("XY", "Some error!")));
-
- mobileApiAppInstance.createInstance(new AppInstance());
- }
-
- @Test(expected = ApiBackendException.class)
- public void createInstance_onBackendError_throwsError() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.INTERNAL_ERROR, DefaultApiClient.JSON_SERIALIZER.serialize(new ApiResponse("XY", "Some internal error!")));
-
- mobileApiAppInstance.createInstance(new AppInstance());
- }
-
- @Test
- public void getUser_examineResponse() {
- String jsonResponse = "{\n" +
- " \"customAttributes\": {\n" +
- " \"number_1\": 1234.3,\n" +
- " \"string_1\": \"blabla\",\n" +
- " \"date_1\": \"2018-12-13\"\n" +
- " },\n" +
- " \"externalUserId\":\"father_of_luke\",\n" +
- " \"emails\": [\n" +
- " {\n" +
- " \"address\": \"darth_vader@mail.com\",\n" +
- " \"preferred\": false\n" +
- " }\n" +
- " ],\n" +
- " \"firstName\": \"Darth\",\n" +
- " \"middleName\": \"Beloved\",\n" +
- " \"lastName\": \"Vader\",\n" +
- " \"birthday\": \"1988-07-31\",\n" +
- " \"gender\": \"Male\",\n" +
- " \"phones\": [\n" +
- " {\n" +
- " \"number\": \"385991111666\",\n" +
- " \"preferred\": false\n" +
- " }\n" +
- " ],\n" +
- " \"instances\": [\n" +
- " {\n" +
- " \"appVersion\": \"1.18.0-SNAPSHOT\",\n" +
- " \"deviceManufacturer\": \"motorola\",\n" +
- " \"deviceModel\": \"Nexus 6\",\n" +
- " \"deviceName\": \"Nexus 6\",\n" +
- " \"deviceSecure\": true,\n" +
- " \"geoEnabled\": true,\n" +
- " \"isPrimary\": false,\n" +
- " \"notificationsEnabled\": true,\n" +
- " \"os\": \"Android\",\n" +
- " \"language\": \"en\",\n" +
- " \"osVersion\": \"7.1.1\",\n" +
- " \"pushRegId\": \"pushRegId\",\n" +
- " \"regEnabled\": true,\n" +
- " \"sdkVersion\": \"1.18.0\"\n" +
- " }\n" +
- " ],\n" +
- " \"tags\": [\n" +
- " \"music\",\n" +
- " \"darkSide\"\n" +
- " ]\n" +
- "}";
-
- debugServer.respondWith(NanoHTTPD.Response.Status.OK, jsonResponse);
-
- UserBody response = mobileApiAppInstance.getUser(regId);
-
- //inspect http context
- assertEquals("/mobile/1/appinstance/1234regId567/user", debugServer.getUri());
- assertEquals(NanoHTTPD.Method.GET, debugServer.getRequestMethod());
- assertEquals("App my_API_key", debugServer.getHeader("Authorization"));
- assertEquals("true", debugServer.getQueryParameter("ri"));
- assertEquals(1, debugServer.getRequestCount());
- assertEquals(1, debugServer.getQueryParametersCount());
- assertNull(debugServer.getBody());
-
- //inspect response
- assertEquals("Darth", response.getFirstName());
- assertEquals("Beloved", response.getMiddleName());
- assertEquals("Vader", response.getLastName());
- assertEquals("1988-07-31", response.getBirthday());
- assertEquals("Male", response.getGender());
- assertEquals("father_of_luke", response.getExternalUserId());
- HashMap expectedCustomAtts = new HashMap<>();
- expectedCustomAtts.put("number_1", 1234.3);
- expectedCustomAtts.put("string_1", "blabla");
- expectedCustomAtts.put("date_1", "2018-12-13");
- assertEquals(expectedCustomAtts, response.getCustomAttributes());
- assertEquals(new HashSet() {{
- add("music");
- add("darkSide");
- }}, response.getTags());
- assertEquals(new UserBody.Phone("385991111666"), response.getPhones().toArray()[0]);
- assertEquals(new UserBody.Email("darth_vader@mail.com"), response.getEmails().toArray()[0]);
- }
-
- @Test
- public void getInstance_examineResponse() {
- String jsonResponse = "{" +
- " \"appVersion\": \"1.18.0-SNAPSHOT\",\n" +
- " \"deviceManufacturer\": \"motorola\",\n" +
- " \"deviceModel\": \"Nexus 6\",\n" +
- " \"deviceName\": \"Nexus 6\",\n" +
- " \"deviceSecure\": true,\n" +
- " \"geoEnabled\": true,\n" +
- " \"isPrimary\": false,\n" +
- " \"notificationsEnabled\": true,\n" +
- " \"os\": \"Android\",\n" +
- " \"language\": \"en\",\n" +
- " \"osVersion\": \"7.1.1\",\n" +
- " \"pushRegId\": \"pushRegId\",\n" +
- " \"regEnabled\": true,\n" +
- " \"sdkVersion\": \"1.18.0\"\n" +
- " }";
-
- debugServer.respondWith(NanoHTTPD.Response.Status.OK, jsonResponse);
-
- AppInstance response = mobileApiAppInstance.getInstance(regId);
-
- //inspect http context
- assertEquals("/mobile/1/appinstance/1234regId567", debugServer.getUri());
- assertEquals(NanoHTTPD.Method.GET, debugServer.getRequestMethod());
- assertEquals("App my_API_key", debugServer.getHeader("Authorization"));
- assertEquals(1, debugServer.getRequestCount());
- assertEquals(0, debugServer.getQueryParametersCount());
- assertNull(debugServer.getBody());
-
- assertEquals("1.18.0-SNAPSHOT", response.getAppVersion());
- assertEquals("motorola", response.getDeviceManufacturer());
- assertEquals("Nexus 6", response.getDeviceModel());
- assertEquals("Nexus 6", response.getDeviceName());
- assertEquals(true, response.getDeviceSecure());
- assertEquals(true, response.getGeoEnabled());
- assertEquals(false, response.getIsPrimary());
- assertEquals(true, response.getNotificationsEnabled());
- assertEquals("Android", response.getOs());
- assertEquals("en", response.getLanguage());
- assertEquals("7.1.1", response.getOsVersion());
- assertEquals("pushRegId", response.getPushRegId());
- assertEquals(true, response.getRegEnabled());
- assertEquals("1.18.0", response.getSdkVersion());
- }
-
- @Test
- public void send_user_session_report__success_examineResponse() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.OK, null);
-
- mobileApiAppInstance.sendUserSessionReport(regId, new UserSessionEventBody());
-
- //inspect http context
- assertEquals("/mobile/1/appinstance/1234regId567/user/events/session", debugServer.getUri());
- assertEquals(1, debugServer.getRequestCount());
- assertEquals(NanoHTTPD.Method.POST, debugServer.getRequestMethod());
- assertEquals(0, debugServer.getQueryParametersCount());
- assertEquals("App my_API_key", debugServer.getHeader("Authorization"));
- }
-
- @Test
- public void send_user_custom_event__success_examineReqAndResponse() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.OK, null);
-
- String userCustomEventRequest =
- "{\"events\":[" +
- "{\"definitionId\":\"123\",\"date\":\"2.2.22\",\"properties\":{}}" +
- "]}";
- UserCustomEventBody.CustomEvent customEvent = new UserCustomEventBody.CustomEvent("123", "2.2.22", new HashMap());
- UserCustomEventBody userCustomEventBody = new UserCustomEventBody(new UserCustomEventBody.CustomEvent[]{customEvent});
-
- mobileApiAppInstance.sendUserCustomEvents(regId, false, userCustomEventBody);
-
- //inspect http context
- assertEquals("/mobile/1/appinstance/1234regId567/user/events/custom", debugServer.getUri());
- assertEquals(1, debugServer.getRequestCount());
- assertEquals(NanoHTTPD.Method.POST, debugServer.getRequestMethod());
- assertEquals(1, debugServer.getQueryParametersCount());
- assertEquals("false", debugServer.getQueryParameter("validate"));
- assertEquals("App my_API_key", debugServer.getHeader("Authorization"));
- assertEquals(userCustomEventBody.toString(), userCustomEventRequest);
- assertEquals(userCustomEventBody.toString(), debugServer.getBody());
- }
-
- @Test
- public void send_user_custom_event_with_validation__success_examineReqAndResponse() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.OK, null);
-
- String userCustomEventRequest =
- "{\"events\":[" +
- "{\"definitionId\":\"123\",\"date\":\"2.2.22\",\"properties\":{}}" +
- "]}";
- UserCustomEventBody.CustomEvent customEvent = new UserCustomEventBody.CustomEvent("123", "2.2.22", new HashMap());
- UserCustomEventBody userCustomEventBody = new UserCustomEventBody(new UserCustomEventBody.CustomEvent[]{customEvent});
-
- mobileApiAppInstance.sendUserCustomEvents(regId, true, userCustomEventBody);
-
- //inspect http context
- assertEquals("/mobile/1/appinstance/1234regId567/user/events/custom", debugServer.getUri());
- assertEquals(1, debugServer.getRequestCount());
- assertEquals(NanoHTTPD.Method.POST, debugServer.getRequestMethod());
- assertEquals(1, debugServer.getQueryParametersCount());
- assertEquals("true", debugServer.getQueryParameter("validate"));
- assertEquals("App my_API_key", debugServer.getHeader("Authorization"));
- assertEquals(userCustomEventBody.toString(), userCustomEventRequest);
- assertEquals(userCustomEventBody.toString(), debugServer.getBody());
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/test/java/it/org/infobip/mobile/messaging/api/MobileApiGeoTest.java b/infobip-mobile-messaging-api-java/src/test/java/it/org/infobip/mobile/messaging/api/MobileApiGeoTest.java
deleted file mode 100644
index dde258e7..00000000
--- a/infobip-mobile-messaging-api-java/src/test/java/it/org/infobip/mobile/messaging/api/MobileApiGeoTest.java
+++ /dev/null
@@ -1,158 +0,0 @@
-package it.org.infobip.mobile.messaging.api;
-
-import org.infobip.mobile.messaging.api.geo.EventReport;
-import org.infobip.mobile.messaging.api.geo.EventReportBody;
-import org.infobip.mobile.messaging.api.geo.EventReportResponse;
-import org.infobip.mobile.messaging.api.geo.EventType;
-import org.infobip.mobile.messaging.api.geo.MessagePayload;
-import org.infobip.mobile.messaging.api.geo.MobileApiGeo;
-import org.infobip.mobile.messaging.api.support.Generator;
-import org.infobip.mobile.messaging.api.tools.DebugServer;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.skyscreamer.jsonassert.JSONAssert;
-import org.skyscreamer.jsonassert.JSONCompareMode;
-
-import java.util.HashSet;
-import java.util.Properties;
-import java.util.Set;
-
-import fi.iki.elonen.NanoHTTPD;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-/**
- * @author sslavin
- * @since 19/10/2016.
- */
-
-public class MobileApiGeoTest {
- private DebugServer debugServer;
- private MobileApiGeo mobileApiGeo;
-
- @Before
- public void setUp() throws Exception {
- debugServer = new DebugServer();
- debugServer.start();
-
- Properties properties = new Properties();
- properties.put("api.key", "my_API_key");
- Generator generator = new Generator.Builder()
- .withBaseUrl("http://127.0.0.1:" + debugServer.getListeningPort() + "/")
- .withProperties(properties)
- .build();
-
- mobileApiGeo = generator.create(MobileApiGeo.class);
- }
-
- @After
- public void tearDown() throws Exception {
- if (null != debugServer) {
- try {
- debugServer.stop();
- } catch (Exception e) {
- //ignore
- }
- }
- }
-
- @Test
- public void create_eventReport_success() throws Exception {
- String jsonResponse = "{" +
- " 'finishedCampaignIds':['id1', 'id2', 'id3']," +
- " 'suspendedCampaignIds':['id4', 'id5', 'id6']," +
- " 'messageIds':{'messageId1':'newMessageId1', 'messageId2':'newMessageId2', 'messageId3':'newMessageId3'}" +
- "}";
-
- Set events = new HashSet(){{
- add(new EventReport(EventType.entry, "myAreaId1", "campaignId1", "messageId1", "sdkMessageId1", 1L));
- add(new EventReport(EventType.exit, "myAreaId2", "campaignId1", "messageId1", "sdkMessageId2", 2L));
- add(new EventReport(EventType.dwell, "myAreaId3", "campaignId2", "messageId2", "sdkMessageId3", 3L));
- }};
-
- Set messages = new HashSet() {{
- add(new MessagePayload("messageId1", null, null, null, null, null, null, null, null));
- add(new MessagePayload("messageId2", null, null, null, null, null, null, null, null));
- }};
-
- debugServer.respondWith(NanoHTTPD.Response.Status.OK, jsonResponse);
-
- EventReportResponse response = mobileApiGeo.report(new EventReportBody(messages, events, "SomeDeviceInstanceId"));
-
- //inspect http context
- assertThat(debugServer.getUri()).isEqualTo("/mobile/4/geo/event");
- assertThat(debugServer.getRequestCount()).isEqualTo(1);
- assertThat(debugServer.getRequestMethod()).isEqualTo(NanoHTTPD.Method.POST);
- assertThat(debugServer.getQueryParametersCount()).isEqualTo(0);
-
- assertThat(response.getFinishedCampaignIds().size()).isEqualTo(3);
- assertThat(response.getFinishedCampaignIds()).contains("id1");
- assertThat(response.getFinishedCampaignIds()).contains("id2");
- assertThat(response.getFinishedCampaignIds()).contains("id3");
- assertThat(response.getSuspendedCampaignIds().size()).isEqualTo(3);
- assertThat(response.getSuspendedCampaignIds()).contains("id4");
- assertThat(response.getSuspendedCampaignIds()).contains("id5");
- assertThat(response.getSuspendedCampaignIds()).contains("id6");
- assertThat(response.getMessageIds().get("messageId1")).isEqualTo("newMessageId1");
- assertThat(response.getMessageIds().get("messageId2")).isEqualTo("newMessageId2");
- assertThat(response.getMessageIds().get("messageId3")).isEqualTo("newMessageId3");
-
- JSONAssert.assertEquals(debugServer.getBody(),
- "{" +
- "\"platformType\":\"GCM\"," +
- "\"deviceApplicationInstanceId\":\"SomeDeviceInstanceId\"," +
- "\"messages\": [" +
- "{\n" +
- " \"messageId\": \"messageId1\",\n" +
- " \"title\": null,\n" +
- " \"body\": null,\n" +
- " \"sound\": null,\n" +
- " \"vibrate\": null,\n" +
- " \"category\": null,\n" +
- " \"silent\": null,\n" +
- " \"customPayload\": null,\n" +
- " \"internalData\": null\n" +
- " },\n" +
- " {\n" +
- " \"messageId\": \"messageId2\",\n" +
- " \"title\": null,\n" +
- " \"body\": null,\n" +
- " \"sound\": null,\n" +
- " \"vibrate\": null,\n" +
- " \"category\": null,\n" +
- " \"silent\": null,\n" +
- " \"customPayload\": null,\n" +
- " \"internalData\": null\n" +
- " }" +
- "]," +
- "\"reports\": [" +
- "{" +
- "\"event\":\"entry\"," +
- "\"geoAreaId\":\"myAreaId1\"," +
- "\"campaignId\":\"campaignId1\"," +
- "\"messageId\":\"messageId1\"," +
- "\"sdkMessageId\":\"sdkMessageId1\"," +
- "\"timestampDelta\":1" +
- "}," +
- "{" +
- "\"event\":\"exit\"," +
- "\"geoAreaId\":\"myAreaId2\"," +
- "\"campaignId\":\"campaignId1\"," +
- "\"messageId\":\"messageId1\"," +
- "\"sdkMessageId\":\"sdkMessageId2\"," +
- "\"timestampDelta\":2" +
- "}," +
- "{" +
- "\"event\":\"dwell\"," +
- "\"geoAreaId\":\"myAreaId3\"," +
- "\"campaignId\":\"campaignId2\"," +
- "\"messageId\":\"messageId2\"," +
- "\"sdkMessageId\":\"sdkMessageId3\"," +
- "\"timestampDelta\":3" +
- "}" +
- "]" +
- "}"
- , JSONCompareMode.LENIENT);
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/test/java/it/org/infobip/mobile/messaging/api/MobileApiMessagesTest.java b/infobip-mobile-messaging-api-java/src/test/java/it/org/infobip/mobile/messaging/api/MobileApiMessagesTest.java
deleted file mode 100644
index cedb899a..00000000
--- a/infobip-mobile-messaging-api-java/src/test/java/it/org/infobip/mobile/messaging/api/MobileApiMessagesTest.java
+++ /dev/null
@@ -1,253 +0,0 @@
-package it.org.infobip.mobile.messaging.api;
-
-import org.infobip.mobile.messaging.api.messages.MessageResponse;
-import org.infobip.mobile.messaging.api.messages.MoMessage;
-import org.infobip.mobile.messaging.api.messages.MoMessagesBody;
-import org.infobip.mobile.messaging.api.messages.MoMessagesResponse;
-import org.infobip.mobile.messaging.api.messages.MobileApiMessages;
-import org.infobip.mobile.messaging.api.messages.SeenMessages;
-import org.infobip.mobile.messaging.api.messages.SyncMessagesBody;
-import org.infobip.mobile.messaging.api.messages.SyncMessagesResponse;
-import org.infobip.mobile.messaging.api.support.Generator;
-import org.infobip.mobile.messaging.api.tools.DebugServer;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Properties;
-
-import fi.iki.elonen.NanoHTTPD;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-
-/**
- * @author sslavin
- * @since 06/05/16.
- */
-public class MobileApiMessagesTest {
- private DebugServer debugServer;
- private MobileApiMessages mobileApiMessages;
-
- @Before
- public void setUp() throws Exception {
- debugServer = new DebugServer();
- debugServer.start();
-
- Properties properties = new Properties();
- properties.put("api.key", "my_API_key");
- Generator generator = new Generator.Builder()
- .withBaseUrl("http://127.0.0.1:" + debugServer.getListeningPort() + "/")
- .withProperties(properties)
- .build();
-
- mobileApiMessages = generator.create(MobileApiMessages.class);
- }
-
- @After
- public void tearDown() throws Exception {
- if (null != debugServer) {
- try {
- debugServer.stop();
- } catch (Exception e) {
- //ignore
- }
- }
- }
-
- @Test
- public void create_seenReport_success() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.OK, null);
-
- SeenMessages messages = new SeenMessages() {{
- setMessages(new ArrayList() {{
- add(new Message("myMessageId", System.currentTimeMillis()));
- }}.toArray(new Message[1]));
- }};
-
- mobileApiMessages.reportSeen(messages);
-
- //inspect http context
- assertThat(debugServer.getUri()).isEqualTo("/mobile/1/messages/seen");
- assertThat(debugServer.getRequestCount()).isEqualTo(1);
- assertThat(debugServer.getRequestMethod()).isEqualTo(NanoHTTPD.Method.POST);
- assertThat(debugServer.getQueryParametersCount()).isEqualTo(0);
- }
-
- @Test
- public void create_sendMO_success() throws Exception {
-
- String serverResponse =
- "{" +
- "\"messages\":" +
- "[" +
- "{" +
- "\"status\" : \"myStatusId\"," +
- "\"statusCode\" : 0," +
- "\"messageId\" : \"myMessageId\"," +
- "\"destination\" : \"myDestination\"," +
- "\"text\" : \"myText\"," +
- "\"customPayload\":" +
- "{" +
- "\"myStringKey\" : \"string\"," +
- "\"myBooleanKey\": true," +
- "\"myNumberKey\" : 1" +
- "}" +
- "}," +
- "{" +
- "\"status\" : \"myStatusId2\"," +
- "\"statusCode\" : 1," +
- "\"messageId\" : \"myMessageId2\"," +
- "\"destination\" : \"myDestination2\"," +
- "\"text\" : \"myText2\"," +
- "\"customPayload\":" +
- "{" +
- "\"myStringKey\" : \"string2\"," +
- "\"myBooleanKey\": false," +
- "\"myNumberKey\" : 2" +
- "}" +
- "}" +
- "]" +
- "}";
-
- debugServer.respondWith(NanoHTTPD.Response.Status.OK, serverResponse);
-
- MoMessage[] moMessages =
- {
- new MoMessage("myMessageId", "myDestination", "myText", "myInitialMessageId", "myBulkId", new HashMap() {{
- put("myStringKey", "string1");
- put("myNubmberKey", 1);
- put("myBooleanKey", true);
- }}),
- new MoMessage("myMessageId2", "myDestination2", "myText2", null, "myBulkId2", new HashMap() {{
- put("myStringKey", "string2");
- put("myNubmberKey", 2);
- put("myBooleanKey", false);
- }})
- };
-
- MoMessagesBody requestBody = new MoMessagesBody();
- requestBody.setFrom("fromTest");
- requestBody.setMessages(moMessages);
-
- MoMessagesResponse moMessagesResponse = mobileApiMessages.sendMO(requestBody);
-
- // inspect http context
- assertThat(debugServer.getUri()).isEqualTo("/mobile/1/messages/mo");
- assertThat(debugServer.getRequestCount()).isEqualTo(1);
- assertThat(debugServer.getRequestMethod()).isEqualTo(NanoHTTPD.Method.POST);
- assertThat(debugServer.getQueryParametersCount()).isEqualTo(1);
-
- // inspect parameters
- assertEquals("GCM", debugServer.getQueryParameter("platformType"));
-
- // inspect response
- assertEquals(2, moMessagesResponse.getMessages().length);
- assertEquals("myMessageId", moMessagesResponse.getMessages()[0].getMessageId());
- assertEquals("myStatusId", moMessagesResponse.getMessages()[0].getStatus());
- assertEquals(0, moMessagesResponse.getMessages()[0].getStatusCode());
- assertEquals("myDestination", moMessagesResponse.getMessages()[0].getDestination());
- assertEquals("myText", moMessagesResponse.getMessages()[0].getText());
- assertEquals("string", moMessagesResponse.getMessages()[0].getCustomPayload().get("myStringKey"));
- assertEquals(1.0, moMessagesResponse.getMessages()[0].getCustomPayload().get("myNumberKey"));
- assertEquals(true, moMessagesResponse.getMessages()[0].getCustomPayload().get("myBooleanKey"));
- assertEquals("myMessageId2", moMessagesResponse.getMessages()[1].getMessageId());
- assertEquals("myStatusId2", moMessagesResponse.getMessages()[1].getStatus());
- assertEquals(1, moMessagesResponse.getMessages()[1].getStatusCode());
- assertEquals("myDestination2", moMessagesResponse.getMessages()[1].getDestination());
- assertEquals("myText2", moMessagesResponse.getMessages()[1].getText());
- assertEquals("string2", moMessagesResponse.getMessages()[1].getCustomPayload().get("myStringKey"));
- assertEquals(2.0, moMessagesResponse.getMessages()[1].getCustomPayload().get("myNumberKey"));
- assertEquals(false, moMessagesResponse.getMessages()[1].getCustomPayload().get("myBooleanKey"));
- }
-
- @Test
- public void sync_messages_success() {
- String serverResponse = "{\n" +
- " \"payloads\": [\n" +
- " {\n" +
- " \"gcm.notification.messageId\": \"test-message-id\",\n" +
- " \"gcm.notification.title\": \"this is title\",\n" +
- " \"gcm.notification.body\": \"body\",\n" +
- " \"gcm.notification.sound\": \"true\",\n" +
- " \"gcm.notification.vibrate\": \"true\",\n" +
- " \"gcm.notification.silent\": \"true\",\n" +
- " \"gcm.notification.category\": \"UNKNOWN\"\n" +
- " }\n" +
- " ]\n" +
- "}";
-
- debugServer.respondWith(NanoHTTPD.Response.Status.OK, serverResponse);
-
- String[] mIDs = new String[1];
- mIDs[0] = "test-message-id";
- String[] drIDs = new String[1];
- drIDs[0] = "test-message-id";
-
- SyncMessagesBody syncMessagesBody = SyncMessagesBody.make(mIDs, drIDs);
- SyncMessagesResponse syncMessagesResponse = mobileApiMessages.sync(syncMessagesBody);
-
- // inspect http context
- assertThat(debugServer.getUri()).isEqualTo("/mobile/5/messages");
- assertThat(debugServer.getRequestCount()).isEqualTo(1);
- assertThat(debugServer.getRequestMethod()).isEqualTo(NanoHTTPD.Method.POST);
- assertThat(debugServer.getQueryParametersCount()).isEqualTo(1);
- assertThat(debugServer.getBody()).isNotEqualTo(null);
-
- // inspect response
- assertEquals(1, syncMessagesResponse.getPayloads().size());
- MessageResponse messageResponse = syncMessagesResponse.getPayloads().get(0);
- assertEquals("test-message-id", messageResponse.getMessageId());
- assertEquals("this is title", messageResponse.getTitle());
- assertEquals("body", messageResponse.getBody());
- assertEquals("true", messageResponse.getSound());
- assertEquals("true", messageResponse.getVibrate());
- assertEquals("true", messageResponse.getSilent());
- assertEquals("UNKNOWN", messageResponse.getCategory());
- }
-
- @Test
- public void testThatNullBodyIsBeingSentInCaseOfEmptyMessageIDArrays() {
- String serverResponse = "{\n" +
- " \"payloads\": [\n" +
- " {\n" +
- " \"gcm.notification.messageId\": \"test-message-id\",\n" +
- " \"gcm.notification.title\": \"this is title\",\n" +
- " \"gcm.notification.body\": \"body\",\n" +
- " \"gcm.notification.sound\": \"true\",\n" +
- " \"gcm.notification.vibrate\": \"true\",\n" +
- " \"gcm.notification.silent\": \"true\",\n" +
- " \"gcm.notification.category\": \"UNKNOWN\"\n" +
- " }\n" +
- " ]\n" +
- "}";
-
- debugServer.respondWith(NanoHTTPD.Response.Status.OK, serverResponse);
-
- String[] mIDs = new String[0];
- String[] drIDs = new String[0];
-
- SyncMessagesBody syncMessagesBody = SyncMessagesBody.make(mIDs, drIDs);
- SyncMessagesResponse syncMessagesResponse = mobileApiMessages.sync(syncMessagesBody);
-
- // inspect http context
- assertThat(debugServer.getUri()).isEqualTo("/mobile/5/messages");
- assertThat(debugServer.getRequestCount()).isEqualTo(1);
- assertThat(debugServer.getRequestMethod()).isEqualTo(NanoHTTPD.Method.POST);
- assertThat(debugServer.getQueryParametersCount()).isEqualTo(1);
- assertThat(debugServer.getBody()).isEqualTo(null);
-
- // inspect response
- assertEquals(1, syncMessagesResponse.getPayloads().size());
- MessageResponse messageResponse = syncMessagesResponse.getPayloads().get(0);
- assertEquals("test-message-id", messageResponse.getMessageId());
- assertEquals("this is title", messageResponse.getTitle());
- assertEquals("body", messageResponse.getBody());
- assertEquals("true", messageResponse.getSound());
- assertEquals("true", messageResponse.getVibrate());
- assertEquals("true", messageResponse.getSilent());
- assertEquals("UNKNOWN", messageResponse.getCategory());
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/test/java/it/org/infobip/mobile/messaging/api/MobileApiVersionTest.java b/infobip-mobile-messaging-api-java/src/test/java/it/org/infobip/mobile/messaging/api/MobileApiVersionTest.java
deleted file mode 100644
index cace3ac4..00000000
--- a/infobip-mobile-messaging-api-java/src/test/java/it/org/infobip/mobile/messaging/api/MobileApiVersionTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package it.org.infobip.mobile.messaging.api;
-
-import org.infobip.mobile.messaging.api.support.Generator;
-import org.infobip.mobile.messaging.api.support.http.client.DefaultApiClient;
-import org.infobip.mobile.messaging.api.tools.DebugServer;
-import org.infobip.mobile.messaging.api.version.LatestReleaseResponse;
-import org.infobip.mobile.messaging.api.version.MobileApiVersion;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.Properties;
-
-import fi.iki.elonen.NanoHTTPD;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-/**
- * @author sslavin
- * @since 03/10/2016.
- */
-
-public class MobileApiVersionTest {
-
- private DebugServer debugServer;
- private MobileApiVersion mobileApiVersion;
-
- @Before
- public void setUp() throws Exception {
- debugServer = new DebugServer();
- debugServer.start();
-
- Properties properties = new Properties();
- properties.put("api.key", "my_API_key");
- Generator generator = new Generator.Builder()
- .withBaseUrl("http://127.0.0.1:" + debugServer.getListeningPort() + "/")
- .withProperties(properties)
- .build();
-
- mobileApiVersion = generator.create(MobileApiVersion.class);
- }
-
- @After
- public void tearDown() throws Exception {
- if (null != debugServer) {
- try {
- debugServer.stop();
- } catch (Exception e) {
- //ignore
- }
- }
- }
-
- @Test
- public void create_success() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.OK,
- DefaultApiClient.JSON_SERIALIZER.serialize(new LatestReleaseResponse("GCM", "3.2.1", "www")));
-
- LatestReleaseResponse response = mobileApiVersion.getLatestRelease();
-
- //inspect http context
- assertEquals("/mobile/3/version", debugServer.getUri());
- assertEquals(1, debugServer.getRequestCount());
- assertEquals(NanoHTTPD.Method.GET, debugServer.getRequestMethod());
- assertEquals("App my_API_key", debugServer.getHeader("Authorization"));
- assertNull(debugServer.getBody());
-
- //inspect response
- assertEquals("GCM", response.getPlatformType());
- assertEquals("3.2.1", response.getLibraryVersion());
- assertEquals("www", response.getUpdateUrl());
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/test/java/org/infobip/mobile/messaging/api/support/GeneratorTest.java b/infobip-mobile-messaging-api-java/src/test/java/org/infobip/mobile/messaging/api/support/GeneratorTest.java
deleted file mode 100644
index da090922..00000000
--- a/infobip-mobile-messaging-api-java/src/test/java/org/infobip/mobile/messaging/api/support/GeneratorTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package org.infobip.mobile.messaging.api.support;
-
-import org.infobip.mobile.messaging.api.support.http.HttpRequest;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * @author mstipanov
- * @since 18.03.2016.
- */
-public class GeneratorTest {
-
- private Generator generator;
-
- @Before
- public void setUp() throws Exception {
- generator = new Generator.Builder().withBaseUrl("X").build();
- }
-
- @Test
- public void build_noBaseUrl_default() throws Exception {
- Generator build = new Generator.Builder().build();
- assertEquals("https://mobile.infobip.com/", build.getBaseUrl());
- }
-
- @Test(expected = NullPointerException.class)
- public void build_nullBaseUrl_shouldThrow() throws Exception {
- new Generator.Builder().withBaseUrl(null).build();
- }
-
- @Test(expected = NullPointerException.class)
- public void build_nullProperties_shouldThrow() throws Exception {
- new Generator.Builder().withBaseUrl("X").withProperties(null).build();
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void build_emptyBaseUrl_shouldThrow() throws Exception {
- new Generator.Builder().withBaseUrl("").build();
- }
-
- @Test(expected = NoHttpRequestAnnotation.class)
- public void invoke_nonAnnotatedMethod_shouldThrow() throws Exception {
- generator.create(WrongClass.class).bar();
- }
-
- private interface WrongClass {
- @HttpRequest
- String foo();
-
- String bar();
- }
-}
\ No newline at end of file
diff --git a/infobip-mobile-messaging-api-java/src/test/java/org/infobip/mobile/messaging/api/support/http/client/DefaultApiClientTest.java b/infobip-mobile-messaging-api-java/src/test/java/org/infobip/mobile/messaging/api/support/http/client/DefaultApiClientTest.java
deleted file mode 100644
index c434fec0..00000000
--- a/infobip-mobile-messaging-api-java/src/test/java/org/infobip/mobile/messaging/api/support/http/client/DefaultApiClientTest.java
+++ /dev/null
@@ -1,324 +0,0 @@
-package org.infobip.mobile.messaging.api.support.http.client;
-
-import org.infobip.mobile.messaging.api.support.ApiBackendExceptionWithContent;
-import org.infobip.mobile.messaging.api.support.ApiException;
-import org.infobip.mobile.messaging.api.support.Tuple;
-import org.infobip.mobile.messaging.api.support.http.client.model.ApiError;
-import org.infobip.mobile.messaging.api.support.http.client.model.ApiResponse;
-import org.infobip.mobile.messaging.api.support.http.client.model.ApiServiceException;
-import org.infobip.mobile.messaging.api.support.util.Base64Encoder;
-import org.infobip.mobile.messaging.api.support.util.MapUtils;
-import org.infobip.mobile.messaging.api.tools.DebugServer;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.ArgumentMatcher;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import fi.iki.elonen.NanoHTTPD;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.NoArgsConstructor;
-
-import static org.infobip.mobile.messaging.api.support.http.client.DefaultApiClient.DEFAULT_CONNECT_TIMEOUT;
-import static org.infobip.mobile.messaging.api.support.http.client.DefaultApiClient.DEFAULT_READ_TIMEOUT;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.argThat;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-/**
- * @author mstipanov
- * @since 08.03.2016.
- */
-public class DefaultApiClientTest {
- private DebugServer debugServer;
- private DefaultApiClient apiClient;
-
- private RequestInterceptor requestInterceptorMock;
- private ResponsePreProcessor responsePreProcessorMock;
-
- @Before
- public void setUp() throws Exception {
- requestInterceptorMock = mock(RequestInterceptor.class);
- responsePreProcessorMock = mock(ResponsePreProcessor.class);
-
- when(requestInterceptorMock.intercept(any(Request.class))).thenAnswer(new Answer() {
- @Override
- public Request answer(InvocationOnMock invocation) throws Throwable {
- return (Request) invocation.getArguments()[0];
- }
- });
-
- apiClient = new DefaultApiClient(
- DEFAULT_CONNECT_TIMEOUT,
- DEFAULT_READ_TIMEOUT,
- null,
- new RequestInterceptor[]{requestInterceptorMock},
- new ResponsePreProcessor[]{responsePreProcessorMock},
- new Logger(),
- false);
-
- debugServer = new DebugServer();
- debugServer.start();
- }
-
- @After
- public void tearDown() throws Exception {
- debugServer.stop();
- }
-
- @Test(expected = ApiException.class)
- public void execute_withQueryParams_noHeaders_noBody_receivesError() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.UNAUTHORIZED,
- DefaultApiClient.JSON_SERIALIZER.serialize(new ApiResponse(
- new ApiError(new ApiServiceException("1", "Invalid Application ID")))));
-
- apiClient.execute(HttpMethod.GET, "http://127.0.0.1:" + debugServer.getListeningPort(), null, null, MapUtils.map("applicationId", "xyz", "currentRegistrationId", "1234"), null, null, ApiResponse.class);
- }
-
- @Test
- public void execute_withQueryParams_noHeaders_noBody_receivesOK() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.OK, DefaultApiClient.JSON_SERIALIZER.serialize(new SomeApiResponse(11)));
-
- SomeApiResponse result = apiClient.execute(HttpMethod.GET, "http://127.0.0.1:" + debugServer.getListeningPort(), "12345", null, MapUtils.map("applicationId", "xyz", "currentRegistrationId", "1234"), null, null, SomeApiResponse.class);
-
- Assert.assertEquals(11, result.getInternalRegistrationId());
- Assert.assertEquals(1, debugServer.getRequestCount());
- Assert.assertEquals(NanoHTTPD.Method.GET, debugServer.getRequestMethod());
- Assert.assertEquals("/", debugServer.getUri());
- Assert.assertEquals("xyz", debugServer.getQueryParameter("applicationId"));
- Assert.assertEquals("1234", debugServer.getQueryParameter("currentRegistrationId"));
- Assert.assertNull(debugServer.getQueryParameter("oldRegistrationId"));
- Assert.assertEquals("App 12345", debugServer.getHeader("Authorization"));
- }
-
- @Test(expected = ApiException.class)
- public void execute_withQueryParams_noHeaders_withBody_receivesError() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.UNAUTHORIZED,
- DefaultApiClient.JSON_SERIALIZER.serialize(new ApiResponse(
- new ApiError(new ApiServiceException("1", "Invalid Application ID")))));
-
- apiClient.execute(HttpMethod.POST, "http://127.0.0.1:" + debugServer.getListeningPort(), null, null, MapUtils.map("applicationId", "xyz", "currentRegistrationId", "1234"), null, new SomeApiRequest("Test"), ApiResponse.class);
- }
-
- @Test
- public void execute_withQueryParams_noHeaders_withBody_receivesOK() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.OK, DefaultApiClient.JSON_SERIALIZER.serialize(new SomeApiResponse(11)));
-
- SomeApiResponse result = apiClient.execute(HttpMethod.POST, "http://127.0.0.1:" + debugServer.getListeningPort(), null, null, MapUtils.map("applicationId", "xyz", "currentRegistrationId", "1234"), null, new SomeApiRequest("Test"), SomeApiResponse.class);
-
- Assert.assertEquals(11, result.getInternalRegistrationId());
- Assert.assertEquals(1, debugServer.getRequestCount());
- Assert.assertEquals(NanoHTTPD.Method.POST, debugServer.getRequestMethod());
- Assert.assertEquals("/", debugServer.getUri());
- Assert.assertEquals("xyz", debugServer.getQueryParameter("applicationId"));
- Assert.assertEquals("1234", debugServer.getQueryParameter("currentRegistrationId"));
- Assert.assertNull(debugServer.getQueryParameter("oldRegistrationId"));
- Assert.assertEquals("{\"name\":\"Test\"}", debugServer.getBody());
- }
-
- @Test(expected = ApiException.class)
- public void execute_withQueryParams_withHeaders_noBody_receivesError() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.UNAUTHORIZED,
- DefaultApiClient.JSON_SERIALIZER.serialize(new ApiResponse(
- new ApiError(new ApiServiceException("1", "Invalid Application ID")))));
-
- apiClient.execute(HttpMethod.GET, "http://127.0.0.1:" + debugServer.getListeningPort(), null, null, MapUtils.map("applicationId", "xyz", "currentRegistrationId", "1234"), MapUtils.map("X-Test-1", "test1", "X-Test-2", "test2"), null, ApiResponse.class);
- }
-
- @Test
- public void execute_withQueryParams_withHeaders_noBody_receivesOK() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.OK, DefaultApiClient.JSON_SERIALIZER.serialize(new SomeApiResponse(11)));
-
- SomeApiResponse result = apiClient.execute(HttpMethod.GET, "http://127.0.0.1:" + debugServer.getListeningPort(), null, null, MapUtils.map("applicationId", "xyz", "currentRegistrationId", "1234"), MapUtils.map("X-Test-1", "test1", "X-Test-2", "test2"), null, SomeApiResponse.class);
-
- Assert.assertEquals(11, result.getInternalRegistrationId());
- Assert.assertEquals(1, debugServer.getRequestCount());
- Assert.assertEquals(NanoHTTPD.Method.GET, debugServer.getRequestMethod());
- Assert.assertEquals("/", debugServer.getUri());
- Assert.assertEquals("xyz", debugServer.getQueryParameter("applicationId"));
- Assert.assertEquals("1234", debugServer.getQueryParameter("currentRegistrationId"));
- Assert.assertNull(debugServer.getQueryParameter("oldRegistrationId"));
- Assert.assertEquals("test1", debugServer.getHeader("X-Test-1"));
- Assert.assertEquals("test2", debugServer.getHeader("X-Test-2"));
- }
-
- @Test(expected = ApiException.class)
- public void execute_withQueryParams_withHeaders_withBody_receivesError() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.UNAUTHORIZED,
- DefaultApiClient.JSON_SERIALIZER.serialize(new ApiResponse(
- new ApiError(new ApiServiceException("1", "Invalid Application ID")))));
-
- apiClient.execute(HttpMethod.POST, "http://127.0.0.1:" + debugServer.getListeningPort(), null, null, MapUtils.map("applicationId", "xyz", "currentRegistrationId", "1234"), MapUtils.map("X-Test-1", "test1", "X-Test-2", "test2"), new SomeApiRequest("Test"), ApiResponse.class);
- }
-
- @Test
- public void execute_withQueryParams_withHeaders_withBody_receivesOK() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.OK, DefaultApiClient.JSON_SERIALIZER.serialize(new SomeApiResponse(11)));
-
- SomeApiResponse result = apiClient.execute(HttpMethod.POST, "http://127.0.0.1:" + debugServer.getListeningPort(), null, null, MapUtils.map("applicationId", "xyz", "currentRegistrationId", "1234"), MapUtils.map("X-Test-1", "test1", "X-Test-2", "test2"), new SomeApiRequest("Test"), SomeApiResponse.class);
-
- Assert.assertEquals(11, result.getInternalRegistrationId());
- Assert.assertEquals(1, debugServer.getRequestCount());
- Assert.assertEquals(NanoHTTPD.Method.POST, debugServer.getRequestMethod());
- Assert.assertEquals("/", debugServer.getUri());
- Assert.assertEquals("xyz", debugServer.getQueryParameter("applicationId"));
- Assert.assertEquals("1234", debugServer.getQueryParameter("currentRegistrationId"));
- Assert.assertNull(debugServer.getQueryParameter("oldRegistrationId"));
- Assert.assertEquals("{\"name\":\"Test\"}", debugServer.getBody());
- Assert.assertEquals("test1", debugServer.getHeader("X-Test-1"));
- Assert.assertEquals("test2", debugServer.getHeader("X-Test-2"));
- }
-
- @Test
- public void execute_noQueryParams_noHeaders_noBody_basicAuth_receivesOK() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.OK, null);
-
- String user = "user";
- String password = "password";
- Tuple credentials = new Tuple<>(user, password);
- String base64Auth = Base64Encoder.encode(user + ":" + password);
-
- apiClient.execute(HttpMethod.POST, "http://127.0.0.1:" + debugServer.getListeningPort(), null, credentials, MapUtils.map("applicationId", "xyz", "currentRegistrationId", "1234"), null, null, null);
- Assert.assertEquals(debugServer.getHeader("Authorization"), "Basic " + base64Auth);
- }
-
- @Test
- public void execute_receivesOK_withRequestErrorAndResponseBody() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.OK, DefaultApiClient.JSON_SERIALIZER.serialize(new SomeApiResponse("1", "Invalid Application ID", 123)));
-
- try {
- apiClient.execute(HttpMethod.POST, "http://127.0.0.1:" + debugServer.getListeningPort(), null, null, MapUtils.map(), null, null, SomeApiResponse.class);
- Assert.fail("Expected exception ApiBackendExceptionWithContent is not thrown");
- } catch (ApiBackendExceptionWithContent error) {
- Assert.assertEquals("1", error.getCode());
- Assert.assertEquals("Invalid Application ID", error.getMessage());
- Assert.assertEquals(123, ((SomeApiResponse) error.getContent()).getInternalRegistrationId());
- }
- }
-
- @Test
- public void execute_withRequestInterceptors_interceptorsShouldReceiveAllData() throws Exception {
- Map> givenQueryParams = new HashMap>() {{
- put("param1", new ArrayList<>());
- put("param2", new ArrayList<>());
- }};
-
- Map> givenHeaders = new HashMap>() {{
- put("header1", new ArrayList<>());
- put("header2", new ArrayList<>());
- }};
-
- Map givenBody = new HashMap() {{
- put("key", "value");
- }};
-
- try {
- apiClient.execute(HttpMethod.GET,
- "http://some_url",
- "someApiKey",
- new Tuple<>("user", "pass"),
- givenQueryParams,
- givenHeaders,
- givenBody,
- Map.class);
- } catch (Exception ignored) {
-
- }
-
- verify(requestInterceptorMock, times(1)).intercept(matches(new Request(
- HttpMethod.GET,
- "http://some_url",
- "someApiKey",
- new Tuple<>("user", "pass"),
- givenHeaders,
- givenQueryParams,
- givenBody)));
- }
-
- @Test
- public void execute_withResponseHeaderInterceptors_interceptorsShouldReceiveAllData() throws Exception {
- debugServer.respondWith(NanoHTTPD.Response.Status.OK, null, new HashMap() {{
- put("header1", "value1");
- put("header2", "value2");
- }});
-
- apiClient.execute(HttpMethod.POST, "http://127.0.0.1:" + debugServer.getListeningPort(), null, null, MapUtils.map(), MapUtils.map(), null, SomeApiResponse.class);
-
- verify(responsePreProcessorMock, times(1))
- .beforeResponse(eq(NanoHTTPD.Response.Status.OK.getRequestStatus()), contansAll(new HashMap>() {{
- put("header1", Collections.singleton("value1"));
- put("header2", Collections.singleton("value2"));
- }}));
- }
-
- @Data
- @NoArgsConstructor
- @AllArgsConstructor
- private static class SomeApiRequest {
- private String name;
- }
-
- @Data
- @EqualsAndHashCode(callSuper = true)
- @NoArgsConstructor
- @AllArgsConstructor
- private static class SomeApiResponse extends ApiResponse {
- private int internalRegistrationId;
-
- public SomeApiResponse(String code, String text, int internalRegistrationId) {
- super(code, text);
- this.internalRegistrationId = internalRegistrationId;
- }
- }
-
- private static Request matches(final Request givenRequest) {
- return argThat(new ArgumentMatcher() {
- @Override
- public boolean matches(Object argument) {
- Request another = (Request) argument;
- return givenRequest.uri.equalsIgnoreCase(another.uri) &&
- givenRequest.body.equals(another.body) &&
- givenRequest.credentials.equals(another.credentials) &&
- givenRequest.apiKey.equalsIgnoreCase(another.apiKey) &&
- givenRequest.headers.keySet().equals(another.headers.keySet()) &&
- givenRequest.queryParams.keySet().equals(another.queryParams.keySet()) &&
- givenRequest.httpMethod.equals(another.httpMethod);
- }
- });
- }
-
- private static Map> contansAll(final Map> headers) {
- return argThat(new ArgumentMatcher>>() {
- @Override
- public boolean matches(Object argument) {
- @SuppressWarnings("unchecked")
- Map> arg = (Map>) argument;
- for (String key : arg.keySet()) {
- if (key == null || !headers.containsKey(key)) {
- continue;
- }
-
- if (!headers.get(key).containsAll(arg.get(key))) {
- return false;
- }
- }
- return true;
- }
- });
- }
-}
\ No newline at end of file
diff --git a/infobip-mobile-messaging-api-java/src/test/java/org/infobip/mobile/messaging/api/support/http/serialization/JsonSerializerTest.java b/infobip-mobile-messaging-api-java/src/test/java/org/infobip/mobile/messaging/api/support/http/serialization/JsonSerializerTest.java
deleted file mode 100644
index 8ebc1a36..00000000
--- a/infobip-mobile-messaging-api-java/src/test/java/org/infobip/mobile/messaging/api/support/http/serialization/JsonSerializerTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package org.infobip.mobile.messaging.api.support.http.serialization;
-
-import com.google.gson.internal.LinkedTreeMap;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.skyscreamer.jsonassert.JSONAssert;
-
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * @author sslavin
- * @since 15/07/16.
- */
-public class JsonSerializerTest {
-
- @Test
- public void execute_JSON_to_Map() throws Exception {
- String json =
- "{" +
- "\"string\":\"String\"," +
- "\"boolean\":true," +
- "\"double\":1.0" +
- "}";
-
- Map, ?> jsonMap = new JsonSerializer().deserialize(json, Map.class);
- Map map = new LinkedTreeMap<>();
- assertEquals(map.getClass(), jsonMap.getClass());
-
- map = (Map) jsonMap;
- Assert.assertTrue(getMessageForClassMismatch(String.class, map.get("string").getClass()), map.get("string") instanceof String);
- Assert.assertTrue(getMessageForClassMismatch(Boolean.class, map.get("boolean").getClass()), map.get("boolean") instanceof Boolean);
- Assert.assertTrue(getMessageForClassMismatch(Double.class, map.get("double").getClass()), map.get("double") instanceof Double);
- }
-
- @Test
- public void should_support_custom_types() throws Exception {
-
- JsonSerializer givenSerializer = new JsonSerializer(false, new JsonSerializer.ObjectAdapter() {
- @Override
- public Class getCls() {
- return GivenClass.class;
- }
-
- @Override
- public GivenClass deserialize(String value) {
- GivenClass obj = new GivenClass();
- obj.string = value.split(":")[1].split("}")[0].split("\"")[1];
- return obj;
- }
-
- @Override
- public String serialize(GivenClass value) {
- return "{\"strrr\":\"" + value.string + "\"}";
- }
- });
- GivenClass givenObject = new GivenClass();
- givenObject.string = "someValue";
-
- // When
- String actualSerialized = givenSerializer.serialize(givenObject);
- GivenClass actualDeserialized = givenSerializer.deserialize(actualSerialized, GivenClass.class);
-
- // Then
- JSONAssert.assertEquals("{\"strrr\":\"someValue\"}", actualSerialized, true);
- assertEquals(givenObject.string, actualDeserialized.string);
- }
-
- private String getMessageForClassMismatch(Class expeceted, Class observed) {
- return "Expected <" + expeceted.toString() + "> found <" + observed.toString() + ">";
- }
-
- // Given
- public static class GivenClass {
- String string;
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/test/java/org/infobip/mobile/messaging/api/support/util/Base64EncoderTest.java b/infobip-mobile-messaging-api-java/src/test/java/org/infobip/mobile/messaging/api/support/util/Base64EncoderTest.java
deleted file mode 100644
index e9298389..00000000
--- a/infobip-mobile-messaging-api-java/src/test/java/org/infobip/mobile/messaging/api/support/util/Base64EncoderTest.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.infobip.mobile.messaging.api.support.util;
-
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class Base64EncoderTest {
-
- @Test
- public void should_encode() {
- String s = " !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
-
- assertThat(Base64Encoder.encode(s))
- .isEqualTo("ICEiIyQlJicoKSorLC0uLzAxMjM0NTY3ODk6Ozw9Pj9AQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVpbXF1eX2BhYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ent8fX4=");
- }
-}
diff --git a/infobip-mobile-messaging-api-java/src/test/java/org/infobip/mobile/messaging/api/support/util/ReflectionUtilsTest.java b/infobip-mobile-messaging-api-java/src/test/java/org/infobip/mobile/messaging/api/support/util/ReflectionUtilsTest.java
deleted file mode 100644
index 224ffcaa..00000000
--- a/infobip-mobile-messaging-api-java/src/test/java/org/infobip/mobile/messaging/api/support/util/ReflectionUtilsTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.infobip.mobile.messaging.api.support.util;
-
-import org.junit.Ignore;
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-/**
- * TODO make this work on gradle!
- *
- * @author mstipanov
- * @since 21.03.2016.
- */
-@Ignore
-public class ReflectionUtilsTest {
-
- @Test
- public void loadPackageInfo_fromFile() throws Exception {
- Package p = Package.getPackage("org.infobip.mobile.messaging.api");
- assertThat(p).isNull();
- ReflectionUtils.loadPackageInfo("org.infobip.mobile.messaging.api");
- p = Package.getPackage("org.infobip.mobile.messaging.api");
- assertThat(p).isNotNull();
- }
-
- @Test
- public void loadPackageInfo_fromJar() throws Exception {
- Package p = Package.getPackage("lombok.experimental");
- assertThat(p).isNull();
- ReflectionUtils.loadPackageInfo("lombok.experimental");
- p = Package.getPackage("lombok.experimental");
- assertThat(p).isNotNull();
- }
-}
\ No newline at end of file
diff --git a/infobip-mobile-messaging-api-java/src/test/java/org/infobip/mobile/messaging/api/support/util/StringUtilsTest.java b/infobip-mobile-messaging-api-java/src/test/java/org/infobip/mobile/messaging/api/support/util/StringUtilsTest.java
deleted file mode 100644
index 67e4a5a0..00000000
--- a/infobip-mobile-messaging-api-java/src/test/java/org/infobip/mobile/messaging/api/support/util/StringUtilsTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.infobip.mobile.messaging.api.support.util;
-
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-/**
- * @author mstipanov
- * @since 18.03.2016.
- */
-public class StringUtilsTest {
-
- @Test
- public void join_nullSeparator_noStrings_mustReturn_null() throws Exception {
- assertThat(StringUtils.join(null)).isNull();
- }
-
- @Test
- public void join_emptySeparator_noStrings_mustReturn_null() throws Exception {
- assertThat(StringUtils.join("")).isNull();
- }
-
- @Test
- public void join_emptySeparator_noString_mustReturn_empty() throws Exception {
- assertThat(StringUtils.join("", "")).isEmpty();
- }
-
- @Test
- public void join_noSeparatorsInStrings() throws Exception {
- assertThat(StringUtils.join("/", "a")).isEqualTo("a");
- assertThat(StringUtils.join("/", "a", "b")).isEqualTo("a/b");
- }
-
- @Test
- public void join_endsWithSeparator() throws Exception {
- assertThat(StringUtils.join("/", "a", "/")).isEqualTo("a/");
- }
-
- @Test
- public void join_manySeparators() throws Exception {
- assertThat(StringUtils.join("/", "a/", "/b", "/c/", "d/")).isEqualTo("a/b/c/d/");
- assertThat(StringUtils.join("/", "/", "a/", "/b", "/c/", "d/")).isEqualTo("/a/b/c/d/");
- }
-}
\ No newline at end of file
diff --git a/infobip-mobile-messaging-api-java/src/test/java/org/infobip/mobile/messaging/api/tools/DebugServer.java b/infobip-mobile-messaging-api-java/src/test/java/org/infobip/mobile/messaging/api/tools/DebugServer.java
deleted file mode 100644
index 404aa284..00000000
--- a/infobip-mobile-messaging-api-java/src/test/java/org/infobip/mobile/messaging/api/tools/DebugServer.java
+++ /dev/null
@@ -1,118 +0,0 @@
-package org.infobip.mobile.messaging.api.tools;
-
-import org.infobip.mobile.messaging.api.support.util.StreamUtils;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import fi.iki.elonen.NanoHTTPD;
-
-public class DebugServer extends NanoHTTPD {
- private Map queryParameters = new HashMap<>();
- private Map headers = new HashMap<>();
- private Map responseHeaders = new HashMap<>();
- private AtomicInteger requestCount = new AtomicInteger(0);
- private Response.Status status;
- private String mimeType;
- private String txt;
- private Method requestMethod;
- private String uri;
- private String body;
-
- public DebugServer() {
- super(0);
- }
-
- @Override
- public Response serve(IHTTPSession session) {
- requestCount.incrementAndGet();
-
- requestMethod = session.getMethod();
- uri = session.getUri();
- queryParameters = session.getParms();
- headers = session.getHeaders();
- body = readBody(session);
-
- Response response = new Response(status, mimeType, txt);
- for (String key : responseHeaders.keySet()) {
- response.addHeader(key, responseHeaders.get(key));
- }
-
- return response;
- }
-
- private String readBody(IHTTPSession session) {
- if (null != headers) {
- String contentLength = headers.get("content-length");
- if (null != contentLength) {
- long length = Long.parseLong(contentLength);
- if (length > 0) {
- try {
- return StreamUtils.readToString(session.getInputStream(), "UTF-8", length);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
-/*
- try {
- return StreamUtils.readToString(session.getInputStream(), "UTF-8");
- } catch (IOException e) {
- e.printStackTrace();
- }
-*/
- return null;
- }
-
- public void respondWith(Response.Status status, String json) {
- this.respondWith(status, "application/json", json);
- }
-
- public void respondWith(Response.Status status, String mimeType, String txt) {
- this.status = status;
- this.mimeType = mimeType;
- this.txt = txt;
- }
-
- public void respondWith(Response.Status status, String body, Map headers) {
- this.status = status;
- this.txt = body;
- this.mimeType = "application/json";
- this.responseHeaders = headers;
- }
-
- public String getQueryParameter(String paramName) {
- return queryParameters.get(paramName);
- }
-
- public int getRequestCount() {
- return requestCount.get();
- }
-
- public Method getRequestMethod() {
- return requestMethod;
- }
-
- public String getUri() {
- return uri;
- }
-
- public String getBody() {
- return body;
- }
-
- public String getHeader(String headerName) {
- return headers.get(headerName.toLowerCase());
- }
-
- public int getQueryParametersCount() {
- return queryParameters.size();
- }
-
- public int getHeadersCount() {
- return headers.size();
- }
-}
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-chat-sdk/.gitignore b/infobip-mobile-messaging-huawei-chat-sdk/.gitignore
similarity index 100%
rename from infobip-mobile-messaging-android-chat-sdk/.gitignore
rename to infobip-mobile-messaging-huawei-chat-sdk/.gitignore
diff --git a/infobip-mobile-messaging-android-chat-sdk/build.gradle b/infobip-mobile-messaging-huawei-chat-sdk/build.gradle
similarity index 88%
rename from infobip-mobile-messaging-android-chat-sdk/build.gradle
rename to infobip-mobile-messaging-huawei-chat-sdk/build.gradle
index 88278e5c..c693699a 100644
--- a/infobip-mobile-messaging-android-chat-sdk/build.gradle
+++ b/infobip-mobile-messaging-huawei-chat-sdk/build.gradle
@@ -7,7 +7,7 @@ buildscript {
}
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.5.3'
+ classpath 'com.android.tools.build:gradle:3.6.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
}
@@ -49,20 +49,20 @@ android {
}
dependencies {
- implementation project(":infobip-mobile-messaging-android-sdk")
- api project(":infobip-mobile-messaging-android-resources")
- implementation project(":infobip-mobile-messaging-api-java")
+ implementation project(':infobip-mobile-messaging-huawei-sdk')
+ api ('org.infobip.mobile.messaging.api:infobip-mobile-messaging-android-resources:3.0.4@aar')
+ implementation 'org.infobip.mobile.messaging.api:infobip-mobile-messaging-api-java:3.0.4'
implementation "com.android.support:support-v4:${mm_supportLibrariesVersion}"
implementation "com.android.support:appcompat-v7:${mm_supportLibrariesVersion}"
implementation "com.android.support:design:${mm_supportLibrariesVersion}"
- androidTestImplementation project(":infobip-mobile-messaging-android-test")
+ androidTestImplementation project(':infobip-mobile-messaging-huawei-test')
androidTestImplementation "com.android.support.test:runner:1.0.2"
androidTestImplementation "junit:junit:4.12"
androidTestImplementation "org.mockito:mockito-core:1.10.19"
androidTestImplementation 'com.nanohttpd:nanohttpd:2.1.0'
- testImplementation project(":infobip-mobile-messaging-android-test")
+ testImplementation project(':infobip-mobile-messaging-huawei-test')
testImplementation "junit:junit:4.12"
testImplementation "org.mockito:mockito-core:1.10.19"
}
diff --git a/infobip-mobile-messaging-android-chat-sdk/proguard-rules.pro b/infobip-mobile-messaging-huawei-chat-sdk/proguard-rules.pro
similarity index 100%
rename from infobip-mobile-messaging-android-chat-sdk/proguard-rules.pro
rename to infobip-mobile-messaging-huawei-chat-sdk/proguard-rules.pro
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/androidTest/java/org/infobip/mobile/messaging/chat/TestBase.java b/infobip-mobile-messaging-huawei-chat-sdk/src/androidTest/java/org/infobip/mobile/messaging/chat/TestBase.java
new file mode 100644
index 00000000..5479ed87
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/androidTest/java/org/infobip/mobile/messaging/chat/TestBase.java
@@ -0,0 +1,60 @@
+package org.infobip.mobile.messaging.chat;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+
+import org.infobip.mobile.messaging.Event;
+import org.mockito.ArgumentMatcher;
+
+import java.util.Objects;
+import java.util.Set;
+
+import static org.mockito.Matchers.argThat;
+
+/**
+ * @author sslavin
+ * @since 10/10/2017.
+ */
+
+public abstract class TestBase {
+
+ protected Intent eqIntentWith(final Event action, final Bundle givenBundle) {
+ return argThat(new ArgumentMatcher() {
+ @Override
+ public boolean matches(Object argument) {
+ Intent intent = (Intent) argument;
+ return checkEquals(intent.getExtras(), givenBundle)
+ && action.getKey().equals(intent.getAction());
+ }
+ });
+ }
+
+ @NonNull
+ protected Bundle givenBundle() {
+ Bundle bundle = new Bundle();
+ bundle.putString("key", "value");
+ return bundle;
+ }
+
+ // region internal methods
+
+ private boolean checkEquals(Bundle first, Bundle second) {
+ Set aks = first.keySet();
+ Set bks = second.keySet();
+
+ if (!aks.containsAll(bks)) {
+ return false;
+ }
+
+ for (String key : aks) {
+ if (!Objects.equals(first.get(key), second.get(key))) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ // endregion
+}
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/AndroidManifest.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..e266aa3e
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/AndroidManifest.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/assets/inappchat-widget.html b/infobip-mobile-messaging-huawei-chat-sdk/src/main/assets/inappchat-widget.html
new file mode 100644
index 00000000..7c9c9d69
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/assets/inappchat-widget.html
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/InAppChat.java b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/InAppChat.java
new file mode 100644
index 00000000..7db78923
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/InAppChat.java
@@ -0,0 +1,47 @@
+package org.infobip.mobile.messaging.chat;
+
+import android.content.Context;
+
+/**
+ * Main interface for in-app chat communication
+ */
+@SuppressWarnings("unused")
+public abstract class InAppChat {
+
+ /**
+ * Returns instance of chat api
+ *
+ * @param context android context
+ * @return instance of chat api
+ */
+ public synchronized static InAppChat getInstance(Context context) {
+ return InAppChatImpl.getInstance(context);
+ }
+
+ /**
+ * Creates in-app chat view activity
+ *
+ * @return chat view object
+ * @see InAppChatView#show()
+ */
+ public abstract InAppChatView inAppChatView();
+
+ /**
+ * Sets which activities to start when user taps on chat notification. Last one in array will be shown, others will be put to task stack.
+ * Library will also provide appropriate message together with intent, use following code to retrieve the message:
+ * *
+ * {@code
+ * Message message = Message.createFrom(intent);
+ * }
+ *
+ *
+ * @param activityClasses array of activities to put into task stack when message is tapped
+ */
+ public abstract void setActivitiesToStartOnMessageTap(Class... activityClasses);
+
+ /**
+ * Cleans up all InAppChat data.
+ * NOTE: There is no need to invoke this method manually as library manages web view data
+ */
+ public abstract void cleanup();
+}
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/InAppChatErrors.java b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/InAppChatErrors.java
new file mode 100644
index 00000000..2d6a1834
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/InAppChatErrors.java
@@ -0,0 +1,45 @@
+package org.infobip.mobile.messaging.chat;
+
+import android.support.annotation.StringDef;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.HashSet;
+import java.util.Set;
+
+public class InAppChatErrors {
+
+ @Retention(RetentionPolicy.SOURCE)
+ @StringDef({INTERNET_CONNECTION_ERROR, CONFIG_SYNC_ERROR, JS_ERROR})
+ @interface ChatErrorsDef {
+ }
+
+ public static final String INTERNET_CONNECTION_ERROR = "INTERNET_CONNECTION_ERROR";
+ public static final String CONFIG_SYNC_ERROR = "CONFIG_SYNC_ERROR";
+ public static final String JS_ERROR = "JS_ERROR";
+
+ public InAppChatErrors(OnChangeListener listener) {
+ this.listener = listener;
+ }
+
+ private OnChangeListener listener;
+ private Set errors = new HashSet();
+
+ public void insertError(@ChatErrorsDef String error) {
+ if (!errors.contains(error)) {
+ errors.add(error);
+ listener.onErrorsChange(errors, null, error);
+ }
+ }
+
+ public void removeError(@ChatErrorsDef String error) {
+ if (errors.contains(error)) {
+ errors.remove(error);
+ listener.onErrorsChange(errors, error, null);
+ }
+ }
+
+ public interface OnChangeListener {
+ void onErrorsChange(Set currentErrors, String removedError, String insertedError);
+ }
+}
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/InAppChatImpl.java b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/InAppChatImpl.java
new file mode 100644
index 00000000..2a9f495c
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/InAppChatImpl.java
@@ -0,0 +1,209 @@
+package org.infobip.mobile.messaging.chat;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.v4.app.TaskStackBuilder;
+import android.webkit.WebView;
+
+import org.infobip.mobile.messaging.Event;
+import org.infobip.mobile.messaging.Message;
+import org.infobip.mobile.messaging.MessageHandlerModule;
+import org.infobip.mobile.messaging.MobileMessaging;
+import org.infobip.mobile.messaging.MobileMessagingCore;
+import org.infobip.mobile.messaging.NotificationSettings;
+import org.infobip.mobile.messaging.api.chat.WidgetInfo;
+import org.infobip.mobile.messaging.chat.core.InAppChatBroadcasterImpl;
+import org.infobip.mobile.messaging.chat.core.InAppChatViewImpl;
+import org.infobip.mobile.messaging.chat.mobileapi.InAppChatSynchronizer;
+import org.infobip.mobile.messaging.chat.properties.MobileMessagingChatProperty;
+import org.infobip.mobile.messaging.chat.properties.PropertyHelper;
+import org.infobip.mobile.messaging.dal.bundle.MessageBundleMapper;
+import org.infobip.mobile.messaging.mobileapi.MobileApiResourceProvider;
+import org.infobip.mobile.messaging.mobileapi.MobileMessagingError;
+import org.infobip.mobile.messaging.mobileapi.Result;
+import org.infobip.mobile.messaging.platform.AndroidBroadcaster;
+
+
+public class InAppChatImpl extends InAppChat implements MessageHandlerModule {
+
+ private static InAppChatImpl instance;
+ private Context context;
+ private AndroidBroadcaster coreBroadcaster;
+ private InAppChatBroadcasterImpl inAppChatBroadcaster;
+ private InAppChatViewImpl inAppChatView;
+ private PropertyHelper propertyHelper;
+ private WebView webView;
+ private MobileApiResourceProvider mobileApiResourceProvider;
+ private InAppChatSynchronizer inAppChatSynchronizer;
+ private static Boolean isChatWidgetConfigSynced = null;
+
+ public static InAppChatImpl getInstance(Context context) {
+ if (instance == null) {
+ instance = MobileMessagingCore.getInstance(context).getMessageHandlerModule(InAppChatImpl.class);
+ }
+ return instance;
+ }
+
+ public InAppChatImpl() {
+ }
+
+ @Override
+ public void init(Context appContext) {
+ this.context = appContext;
+ }
+
+ @Override
+ public boolean handleMessage(Message message) {
+ if (!message.isChatMessage()) {
+ return false;
+ }
+ coreBroadcaster().messageReceived(message);
+ MobileMessagingCore.getInstance(context).getNotificationHandler().displayNotification(message);
+ return true;
+ }
+
+ @Override
+ public boolean messageTapped(Message message) {
+ if (!message.isChatMessage()) {
+ return false;
+ }
+ coreBroadcaster().notificationTapped(message);
+ doCoreTappedActions(message);
+ return true;
+ }
+
+ @Override
+ public InAppChatViewImpl inAppChatView() {
+ if (inAppChatView == null) {
+ inAppChatView = new InAppChatViewImpl(context);
+ }
+ return inAppChatView;
+ }
+
+ @Override
+ public void setActivitiesToStartOnMessageTap(Class... activityClasses) {
+ propertyHelper().saveClasses(MobileMessagingChatProperty.ON_MESSAGE_TAP_ACTIVITY_CLASSES, activityClasses);
+ }
+
+ public static Boolean getIsChatWidgetConfigSynced() {
+ return isChatWidgetConfigSynced;
+ }
+
+ // region private methods
+
+ synchronized private AndroidBroadcaster coreBroadcaster() {
+ if (coreBroadcaster == null) {
+ coreBroadcaster = new AndroidBroadcaster(context);
+ }
+ return coreBroadcaster;
+ }
+
+ synchronized private InAppChatBroadcasterImpl inAppChatBroadcaster() {
+ if (inAppChatBroadcaster == null) {
+ inAppChatBroadcaster = new InAppChatBroadcasterImpl(context);
+ }
+ return inAppChatBroadcaster;
+ }
+
+ private MobileApiResourceProvider mobileApiResourceProvider() {
+ if (mobileApiResourceProvider == null) {
+ mobileApiResourceProvider = new MobileApiResourceProvider();
+ }
+ return mobileApiResourceProvider;
+ }
+
+ synchronized private InAppChatSynchronizer inAppChatSynchronizer() {
+ if (inAppChatSynchronizer == null) {
+ inAppChatSynchronizer = new InAppChatSynchronizer(
+ context,
+ MobileMessagingCore.getInstance(context),
+ coreBroadcaster(),
+ inAppChatBroadcaster(),
+ mobileApiResourceProvider().getMobileApiChat(context));
+ }
+ return inAppChatSynchronizer;
+ }
+
+ synchronized private PropertyHelper propertyHelper() {
+ if (propertyHelper == null) {
+ propertyHelper = new PropertyHelper(context);
+ }
+ return propertyHelper;
+ }
+
+ synchronized private WebView webView() {
+ if (webView == null) {
+ webView = new WebView(context);
+ }
+ return webView;
+ }
+
+ @Override
+ public void applicationInForeground() {
+ performSyncActions();
+ }
+
+ @Override
+ public void cleanup() {
+ isChatWidgetConfigSynced = false;
+ webView().clearHistory();
+ webView().clearCache(true);
+ 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());
+ }
+
+ @Override
+ public void depersonalize() {
+ isChatWidgetConfigSynced = false;
+ webView().clearHistory();
+ webView().clearCache(true);
+ }
+
+ @Override
+ public void performSyncActions() {
+ if (isChatWidgetConfigSynced == null || !isChatWidgetConfigSynced) {
+ inAppChatSynchronizer().getWidgetConfiguration(new MobileMessaging.ResultListener() {
+ @Override
+ public void onResult(Result result) {
+ isChatWidgetConfigSynced = result.isSuccess();
+ }
+ });
+ }
+ }
+
+ @NonNull
+ private TaskStackBuilder stackBuilderForNotificationTap(Message message) {
+ TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
+ Bundle messageBundle = MessageBundleMapper.messageToBundle(message);
+ Class[] classes = propertyHelper().findClasses(MobileMessagingChatProperty.ON_MESSAGE_TAP_ACTIVITY_CLASSES);
+ if (classes != null) {
+ for (Class cls : classes) {
+ stackBuilder.addNextIntent(new Intent(context, cls)
+ .setAction(Event.NOTIFICATION_TAPPED.getKey())
+ .putExtras(messageBundle));
+ }
+ }
+
+ NotificationSettings notificationSettings = MobileMessagingCore.getInstance(context).getNotificationSettings();
+ if (stackBuilder.getIntentCount() == 0 && notificationSettings != null && notificationSettings.getCallbackActivity() != null) {
+ stackBuilder.addNextIntent(new Intent(context, notificationSettings.getCallbackActivity())
+ .setAction(Event.NOTIFICATION_TAPPED.getKey())
+ .putExtras(messageBundle));
+ }
+
+ return stackBuilder;
+ }
+
+ private void doCoreTappedActions(Message chatMessage) {
+ TaskStackBuilder stackBuilder = stackBuilderForNotificationTap(chatMessage);
+ if (stackBuilder.getIntentCount() != 0) {
+ stackBuilder.startActivities();
+ }
+ }
+
+ // endregion
+}
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/InAppChatView.java b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/InAppChatView.java
new file mode 100644
index 00000000..16011296
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/InAppChatView.java
@@ -0,0 +1,14 @@
+package org.infobip.mobile.messaging.chat;
+
+/**
+ * @author sslavin
+ * @since 19/11/2017.
+ */
+
+public interface InAppChatView {
+
+ /**
+ * Call this method to show the view
+ */
+ void show();
+}
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatBroadcaster.java b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatBroadcaster.java
new file mode 100644
index 00000000..6a31cde5
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatBroadcaster.java
@@ -0,0 +1,10 @@
+package org.infobip.mobile.messaging.chat.core;
+
+public interface InAppChatBroadcaster {
+
+ /**
+ * Sends broadcast that In-app chat widget configuration is synced
+ */
+ void chatConfigurationSynced();
+
+}
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatBroadcasterImpl.java b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatBroadcasterImpl.java
new file mode 100644
index 00000000..36c0f7b9
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatBroadcasterImpl.java
@@ -0,0 +1,40 @@
+package org.infobip.mobile.messaging.chat.core;
+
+import android.content.Context;
+import android.content.Intent;
+import android.support.annotation.NonNull;
+import android.support.v4.content.LocalBroadcastManager;
+
+import org.infobip.mobile.messaging.logging.MobileMessagingLogger;
+
+public class InAppChatBroadcasterImpl implements InAppChatBroadcaster {
+ private final Context context;
+
+ public InAppChatBroadcasterImpl(@NonNull Context context) {
+ this.context = context;
+ }
+
+ @Override
+ public void chatConfigurationSynced() {
+ send(prepare(InAppChatEvent.CHAT_CONFIGURATION_SYNCED));
+ }
+
+ private void send(Intent intent) {
+ try {
+ context.sendBroadcast(intent);
+ LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
+ } catch (Exception ex) {
+ MobileMessagingLogger.e("Failed to send broadcast for action " + intent.getAction() + " due to exception " + ex.getMessage());
+ }
+ }
+
+ private Intent prepare(InAppChatEvent event) {
+ return prepare(event.getKey());
+ }
+
+ private Intent prepare(String event) {
+ return new Intent(event)
+ .setPackage(context.getPackageName());
+ }
+
+}
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatClient.java b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatClient.java
new file mode 100644
index 00000000..15925bb6
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatClient.java
@@ -0,0 +1,14 @@
+package org.infobip.mobile.messaging.chat.core;
+
+/**
+ * Declaration of interaction with client-side.
+ */
+public interface InAppChatClient {
+
+ /**
+ * Send typed message to agent from user
+ *
+ * @param message user message
+ */
+ void sendChatMessage(String message);
+}
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatClientImpl.java b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatClientImpl.java
new file mode 100644
index 00000000..1e411966
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatClientImpl.java
@@ -0,0 +1,39 @@
+package org.infobip.mobile.messaging.chat.core;
+
+import android.webkit.WebView;
+
+public class InAppChatClientImpl implements InAppChatClient {
+
+ private final WebView webView;
+
+ public InAppChatClientImpl(WebView webView) {
+ this.webView = webView;
+ }
+
+ @Override
+ public void sendChatMessage(String message) {
+ if (webView != null && message != null && !message.isEmpty()) {
+ webView.loadUrl(buildWidgetMethodInvocation(InAppChatWidgetMethods.handleMessageSend.name(), message));
+ }
+ }
+
+ private String buildWidgetMethodInvocation(String methodName, String... params) {
+ StringBuilder builder = new StringBuilder();
+ builder
+ .append("javascript:")
+ .append(methodName)
+ .append("(");
+ if (params.length > 0) {
+ for (String param : params) {
+ builder
+ .append("'")
+ .append(param)
+ .append("'")
+ .append(", ");
+ }
+ }
+ builder.delete(builder.lastIndexOf(","), builder.length());
+ builder.append(")");
+ return builder.toString();
+ }
+}
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatEvent.java b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatEvent.java
new file mode 100644
index 00000000..06f1de39
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatEvent.java
@@ -0,0 +1,18 @@
+package org.infobip.mobile.messaging.chat.core;
+
+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");
+
+ private final String key;
+
+ InAppChatEvent(String key) {
+ this.key = key;
+ }
+
+ public String getKey() {
+ return key;
+ }
+}
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatMobile.java b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatMobile.java
new file mode 100644
index 00000000..d8a107c4
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatMobile.java
@@ -0,0 +1,23 @@
+package org.infobip.mobile.messaging.chat.core;
+
+/**
+ * Declaration of interaction of inappchat-widget.html script with mobile-side.
+ * All methods intended for widget invocation on mobile (for client-side) will be put here.
+ */
+interface InAppChatMobile {
+
+ /**
+ * Enables/disables control elements (such as text input view, send button etc).
+ * Will be applied after widget initialization.
+ *
+ * @param isEnabled set to true to enable control elements or to false otherwise
+ */
+ void setControlsEnabled(boolean isEnabled);
+
+ /**
+ * Provides widget (client-side) errors.
+ *
+ * @param errorMessage description of an error
+ */
+ void onError(String errorMessage);
+}
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatMobileImpl.java b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatMobileImpl.java
new file mode 100644
index 00000000..eb9a5d40
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatMobileImpl.java
@@ -0,0 +1,55 @@
+package org.infobip.mobile.messaging.chat.core;
+
+import android.app.Activity;
+import android.os.Handler;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+import android.webkit.JavascriptInterface;
+
+import org.infobip.mobile.messaging.logging.MobileMessagingLogger;
+
+public class InAppChatMobileImpl implements InAppChatMobile {
+
+ private final InAppChatWebViewManager inAppChatWebViewManager;
+ private Handler handler;
+
+ public InAppChatMobileImpl(InAppChatWebViewManager inAppChatWebViewManager) {
+ this.inAppChatWebViewManager = inAppChatWebViewManager;
+ if (inAppChatWebViewManager instanceof Fragment) {
+ FragmentActivity activity = ((Fragment) inAppChatWebViewManager).getActivity();
+ if (activity != null) {
+ this.handler = new Handler(activity.getMainLooper());
+ }
+ } else if (inAppChatWebViewManager instanceof Activity) {
+ Activity inAppChatWebViewManagerActivity = (Activity) inAppChatWebViewManager;
+ this.handler = new Handler(inAppChatWebViewManagerActivity.getMainLooper());
+ }
+ }
+
+ @Override
+ @JavascriptInterface
+ public void setControlsEnabled(final boolean isEnabled) {
+ MobileMessagingLogger.d("WebView setting controls enabled: " + isEnabled);
+ Runnable myRunnable = new Runnable() {
+ @Override
+ public void run() {
+ if (inAppChatWebViewManager != null)
+ inAppChatWebViewManager.setControlsEnabled(isEnabled);
+ }
+ };
+ handler.post(myRunnable);
+ }
+
+ @Override
+ @JavascriptInterface
+ public void onError(final String errorMessage) {
+ Runnable myRunnable = new Runnable() {
+ @Override
+ public void run() {
+ MobileMessagingLogger.d("WebView loading error", errorMessage);
+ if (inAppChatWebViewManager != null) inAppChatWebViewManager.onJSError();
+ }
+ };
+ handler.post(myRunnable);
+ }
+}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/MobileChatViewImpl.java b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatViewImpl.java
similarity index 55%
rename from infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/MobileChatViewImpl.java
rename to infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatViewImpl.java
index 076439ab..ac9df837 100644
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/MobileChatViewImpl.java
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatViewImpl.java
@@ -5,55 +5,34 @@
import android.content.Intent;
import android.support.annotation.Nullable;
-import org.infobip.mobile.messaging.chat.MobileChatView;
-import org.infobip.mobile.messaging.chat.properties.MobileChatProperty;
+import org.infobip.mobile.messaging.chat.InAppChatView;
+import org.infobip.mobile.messaging.chat.properties.MobileMessagingChatProperty;
import org.infobip.mobile.messaging.chat.properties.PropertyHelper;
-import org.infobip.mobile.messaging.chat.view.ChatActivity;
-import org.infobip.mobile.messaging.interactive.NotificationCategory;
+import org.infobip.mobile.messaging.chat.view.InAppChatActivity;
import org.infobip.mobile.messaging.util.StringUtils;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-/**
- * @author sslavin
- * @since 19/11/2017.
- */
+public class InAppChatViewImpl implements InAppChatView {
-public class MobileChatViewImpl implements MobileChatView {
-
- private static final Set notificationCategories = new HashSet<>();
private final Context context;
private final PropertyHelper propertyHelper;
@SuppressWarnings("unused")
- private MobileChatViewImpl() {
+ private InAppChatViewImpl() {
context = null;
propertyHelper = null;
}
- MobileChatViewImpl(Context context) {
+ public InAppChatViewImpl(Context context) {
this.context = context;
this.propertyHelper = new PropertyHelper(context);
}
- @Override
- public MobileChatView withActionCategories(NotificationCategory... categories) {
- notificationCategories.clear();
- notificationCategories.addAll(Arrays.asList(categories));
- return this;
- }
-
@SuppressWarnings("ConstantConditions")
@Override
public void show() {
- propertyHelper.saveClasses(MobileChatProperty.ON_MESSAGE_TAP_ACTIVITY_CLASSES, getTapActivityClasses());
- context.startActivity(new Intent(context, ChatActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
- }
-
- public Set getNotificationCategories() {
- return notificationCategories;
+ propertyHelper.saveClasses(MobileMessagingChatProperty.ON_MESSAGE_TAP_ACTIVITY_CLASSES, getTapActivityClasses());
+ context.startActivity(new Intent(context, InAppChatActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}
// region private methods
@@ -61,9 +40,9 @@ public Set getNotificationCategories() {
private Class[] getTapActivityClasses() {
Class launchActivityClass = getLaunchActivityClass();
if (launchActivityClass != null) {
- return new Class[]{launchActivityClass, ChatActivity.class};
+ return new Class[]{launchActivityClass, InAppChatActivity.class};
}
- return new Class[]{ChatActivity.class};
+ return new Class[]{InAppChatActivity.class};
}
@Nullable
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatWebViewClient.java b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatWebViewClient.java
new file mode 100644
index 00000000..3f838764
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatWebViewClient.java
@@ -0,0 +1,51 @@
+package org.infobip.mobile.messaging.chat.core;
+
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.net.Uri;
+import android.webkit.WebResourceError;
+import android.webkit.WebResourceRequest;
+import android.webkit.WebResourceResponse;
+import android.webkit.WebView;
+import android.webkit.WebViewClient;
+
+public class InAppChatWebViewClient extends WebViewClient {
+
+ private final InAppChatWebViewManager inAppChatWebViewManager;
+
+ public InAppChatWebViewClient(InAppChatWebViewManager inAppChatWebViewManager) {
+ this.inAppChatWebViewManager = inAppChatWebViewManager;
+ }
+
+ @Override
+ public void onPageStarted(WebView view, String url, Bitmap favicon) {
+ if (inAppChatWebViewManager != null) inAppChatWebViewManager.onPageStarted();
+ super.onPageStarted(view, url, favicon);
+ }
+
+ @Override
+ public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
+ super.onReceivedError(view, request, error);
+ }
+
+ @Override
+ public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
+ super.onReceivedHttpError(view, request, errorResponse);
+ }
+
+ @Override
+ public void onPageFinished(WebView view, String url) {
+ if (inAppChatWebViewManager != null) inAppChatWebViewManager.onPageFinished();
+ super.onPageFinished(view, url);
+ }
+
+ @Override
+ public boolean shouldOverrideUrlLoading(WebView view, String url) {
+ if (url != null && (url.startsWith("http://") || url.startsWith("https://"))) {
+ view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatWebViewManager.java b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatWebViewManager.java
new file mode 100644
index 00000000..280691db
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatWebViewManager.java
@@ -0,0 +1,12 @@
+package org.infobip.mobile.messaging.chat.core;
+
+/**
+ * Interface for Views with lifecycle (Activity, Fragment) that manage WebView
+ */
+public interface InAppChatWebViewManager {
+
+ void onPageStarted();
+ void onPageFinished();
+ void setControlsEnabled(boolean enabled);
+ void onJSError();
+}
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatWidgetMethods.java b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatWidgetMethods.java
new file mode 100644
index 00000000..442edeb5
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/core/InAppChatWidgetMethods.java
@@ -0,0 +1,6 @@
+package org.infobip.mobile.messaging.chat.core;
+
+public enum InAppChatWidgetMethods {
+
+ handleMessageSend
+}
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/mobileapi/InAppChatSynchronizer.java b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/mobileapi/InAppChatSynchronizer.java
new file mode 100644
index 00000000..25731d67
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/mobileapi/InAppChatSynchronizer.java
@@ -0,0 +1,102 @@
+package org.infobip.mobile.messaging.chat.mobileapi;
+
+import android.content.Context;
+
+import org.infobip.mobile.messaging.MobileMessaging;
+import org.infobip.mobile.messaging.MobileMessagingCore;
+import org.infobip.mobile.messaging.SuccessPending;
+import org.infobip.mobile.messaging.api.chat.MobileApiChat;
+import org.infobip.mobile.messaging.api.chat.WidgetInfo;
+import org.infobip.mobile.messaging.chat.core.InAppChatBroadcaster;
+import org.infobip.mobile.messaging.chat.properties.MobileMessagingChatProperty;
+import org.infobip.mobile.messaging.logging.MobileMessagingLogger;
+import org.infobip.mobile.messaging.mobileapi.InternalSdkError;
+import org.infobip.mobile.messaging.mobileapi.MobileMessagingError;
+import org.infobip.mobile.messaging.mobileapi.Result;
+import org.infobip.mobile.messaging.mobileapi.common.MRetryPolicy;
+import org.infobip.mobile.messaging.mobileapi.common.MRetryableTask;
+import org.infobip.mobile.messaging.mobileapi.common.RetryPolicyProvider;
+import org.infobip.mobile.messaging.mobileapi.common.exceptions.BackendInvalidParameterException;
+import org.infobip.mobile.messaging.platform.AndroidBroadcaster;
+import org.infobip.mobile.messaging.util.PreferenceHelper;
+
+
+public class InAppChatSynchronizer {
+
+ private final Context context;
+ private final MobileMessagingCore mobileMessagingCore;
+ private final AndroidBroadcaster coreBroadcaster;
+ private final InAppChatBroadcaster inAppChatBroadcaster;
+ private final MobileApiChat mobileApiChat;
+ private final MRetryPolicy retryPolicy;
+
+ public InAppChatSynchronizer(Context context,
+ MobileMessagingCore mobileMessagingCore,
+ AndroidBroadcaster coreBroadcaster,
+ InAppChatBroadcaster inAppChatBroadcaster,
+ MobileApiChat mobileApiChat) {
+ this.context = context;
+ this.mobileMessagingCore = mobileMessagingCore;
+ this.coreBroadcaster = coreBroadcaster;
+ this.inAppChatBroadcaster = inAppChatBroadcaster;
+ this.mobileApiChat = mobileApiChat;
+ this.retryPolicy = new RetryPolicyProvider(context).DEFAULT();
+ }
+
+ public void getWidgetConfiguration(final MobileMessaging.ResultListener listener) {
+ if (!mobileMessagingCore.isRegistrationAvailable()) {
+ if (listener != null) {
+ listener.onResult(new Result(InternalSdkError.NO_VALID_REGISTRATION.getError()));
+ }
+ return;
+ }
+
+ if (mobileMessagingCore.isDepersonalizeInProgress()) {
+ MobileMessagingLogger.w("Depersonalization is in progress, will report custom event later");
+ if (listener != null) {
+ listener.onResult(new Result(InternalSdkError.DEPERSONALIZATION_IN_PROGRESS.getError()));
+ }
+ return;
+ }
+
+ new MRetryableTask() {
+
+ @Override
+ public WidgetInfo run(Void[] voids) {
+ MobileMessagingLogger.v("GET WIDGET CONFIGURATION >>>");
+ return mobileApiChat.getWidgetConfiguration();
+ }
+
+ @Override
+ public void after(WidgetInfo widgetInfo) {
+ MobileMessagingLogger.v("GET WIDGET CONFIGURATION DONE <<<");
+ PreferenceHelper.saveString(context, MobileMessagingChatProperty.IN_APP_CHAT_WIDGET_ID.getKey(), widgetInfo.getId());
+ PreferenceHelper.saveString(context, MobileMessagingChatProperty.IN_APP_CHAT_WIDGET_TITLE.getKey(), widgetInfo.getTitle());
+ PreferenceHelper.saveString(context, MobileMessagingChatProperty.IN_APP_CHAT_WIDGET_PRIMARY_COLOR.getKey(), widgetInfo.getPrimaryColor());
+ PreferenceHelper.saveString(context, MobileMessagingChatProperty.IN_APP_CHAT_WIDGET_BACKGROUND_COLOR.getKey(), widgetInfo.getBackgroundColor());
+ if (listener != null) {
+ listener.onResult(new Result<>(widgetInfo));
+ }
+ inAppChatBroadcaster.chatConfigurationSynced();
+ }
+
+ @Override
+ public void error(Throwable error) {
+ MobileMessagingLogger.v("GET WIDGET CONFIGURATION ERROR <<<", error);
+ MobileMessagingError mobileMessagingError = MobileMessagingError.createFrom(error);
+
+ if (error instanceof BackendInvalidParameterException) {
+ mobileMessagingCore.handleNoRegistrationError(mobileMessagingError);
+ }
+
+ MobileMessagingCore.getInstance(context).setLastHttpException(error);
+ coreBroadcaster.error(MobileMessagingError.createFrom(error));
+ if (listener != null) {
+ listener.onResult(new Result(MobileMessagingError.createFrom(error)));
+ }
+ }
+ }
+ .retryWith(retryPolicy)
+ .execute();
+ }
+}
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/properties/MobileMessagingChatProperty.java b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/properties/MobileMessagingChatProperty.java
new file mode 100644
index 00000000..f709ff86
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/properties/MobileMessagingChatProperty.java
@@ -0,0 +1,27 @@
+package org.infobip.mobile.messaging.chat.properties;
+
+public enum MobileMessagingChatProperty {
+
+ ON_MESSAGE_TAP_ACTIVITY_CLASSES("org.infobip.mobile.messaging.infobip.chat.ON_MESSAGE_TAP_ACTIVITY_CLASSES", new Class[0]),
+ IN_APP_CHAT_WIDGET_ID("org.infobip.mobile.messaging.infobip.IN_APP_CHAT_WIDGET_ID", null),
+ IN_APP_CHAT_WIDGET_TITLE("org.infobip.mobile.messaging.infobip.IN_APP_CHAT_WIDGET_TITLE", null),
+ IN_APP_CHAT_WIDGET_PRIMARY_COLOR("org.infobip.mobile.messaging.infobip.IN_APP_CHAT_WIDGET_PRIMARY_COLOR", null),
+ IN_APP_CHAT_WIDGET_BACKGROUND_COLOR("org.infobip.mobile.messaging.infobip.IN_APP_CHAT_WIDGET_BACKGROUND_COLOR", null);
+
+ private final String key;
+ private final Object defaultValue;
+
+ MobileMessagingChatProperty(String key, Object defaultValue) {
+ this.key = key;
+ this.defaultValue = defaultValue;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public Object getDefaultValue() {
+ return defaultValue;
+ }
+}
+
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/properties/PropertyHelper.java b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/properties/PropertyHelper.java
similarity index 64%
rename from infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/properties/PropertyHelper.java
rename to infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/properties/PropertyHelper.java
index 4c50682d..a4fd9f05 100644
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/properties/PropertyHelper.java
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/properties/PropertyHelper.java
@@ -20,15 +20,15 @@ public PropertyHelper(Context context) {
this.context = context;
}
- public boolean findBoolean(MobileChatProperty property) {
+ public boolean findBoolean(MobileMessagingChatProperty property) {
return findBoolean(context, property.getKey(), (Boolean) property.getDefaultValue());
}
- public void saveBoolean(MobileChatProperty property, boolean value) {
+ public void saveBoolean(MobileMessagingChatProperty property, boolean value) {
saveBoolean(context, property.getKey(), value);
}
- public Class[] findClasses(MobileChatProperty property) {
+ public Class[] findClasses(MobileMessagingChatProperty property) {
String[] classNames = findStringArray(context, property.getKey(), new String[0]);
if (classNames == null) {
return (Class[]) property.getDefaultValue();
@@ -44,7 +44,7 @@ public Class[] findClasses(MobileChatProperty property) {
return classes.toArray(new Class[0]);
}
- public void saveClasses(MobileChatProperty property, Class... classes) {
+ public void saveClasses(MobileMessagingChatProperty property, Class... classes) {
if (classes == null) {
return;
}
@@ -60,7 +60,14 @@ public void saveClasses(MobileChatProperty property, Class... classes) {
saveStringArray(context, property.getKey(), classNames.toArray(new String[0]));
}
- public void remove(MobileChatProperty property) {
+ public void remove(MobileMessagingChatProperty property) {
remove(context, property.getKey());
}
+
+ public void removeChatPrefs() {
+ PreferenceHelper.remove(context, MobileMessagingChatProperty.IN_APP_CHAT_WIDGET_ID.getKey());
+ PreferenceHelper.remove(context, MobileMessagingChatProperty.IN_APP_CHAT_WIDGET_TITLE.getKey());
+ PreferenceHelper.remove(context, MobileMessagingChatProperty.IN_APP_CHAT_WIDGET_PRIMARY_COLOR.getKey());
+ PreferenceHelper.remove(context, MobileMessagingChatProperty.IN_APP_CHAT_WIDGET_BACKGROUND_COLOR.getKey());
+ }
}
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/view/InAppChatActivity.java b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/view/InAppChatActivity.java
new file mode 100644
index 00000000..836813c2
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/view/InAppChatActivity.java
@@ -0,0 +1,453 @@
+package org.infobip.mobile.messaging.chat.view;
+
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.annotation.SuppressLint;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.SharedPreferences;
+import android.content.res.Resources;
+import android.graphics.Color;
+import android.graphics.PorterDuff;
+import android.graphics.drawable.Drawable;
+import android.net.ConnectivityManager;
+import android.net.Uri;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.annotation.ColorInt;
+import android.support.v4.graphics.ColorUtils;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.util.Log;
+import android.util.TypedValue;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+import android.webkit.WebSettings;
+import android.webkit.WebView;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.ProgressBar;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import org.infobip.mobile.messaging.BroadcastParameter;
+import org.infobip.mobile.messaging.Event;
+import org.infobip.mobile.messaging.MobileMessagingCore;
+import org.infobip.mobile.messaging.api.chat.WidgetInfo;
+import org.infobip.mobile.messaging.api.support.http.serialization.JsonSerializer;
+import org.infobip.mobile.messaging.chat.InAppChat;
+import org.infobip.mobile.messaging.chat.InAppChatErrors;
+import org.infobip.mobile.messaging.chat.InAppChatImpl;
+import org.infobip.mobile.messaging.chat.R;
+import org.infobip.mobile.messaging.chat.core.InAppChatClient;
+import org.infobip.mobile.messaging.chat.core.InAppChatClientImpl;
+import org.infobip.mobile.messaging.chat.core.InAppChatEvent;
+import org.infobip.mobile.messaging.chat.core.InAppChatMobileImpl;
+import org.infobip.mobile.messaging.chat.core.InAppChatWebViewClient;
+import org.infobip.mobile.messaging.chat.core.InAppChatWebViewManager;
+import org.infobip.mobile.messaging.chat.properties.MobileMessagingChatProperty;
+import org.infobip.mobile.messaging.chat.properties.PropertyHelper;
+import org.infobip.mobile.messaging.mobileapi.MobileMessagingError;
+import org.infobip.mobile.messaging.util.ResourceLoader;
+import org.infobip.mobile.messaging.util.StringUtils;
+
+import java.util.Set;
+
+public class InAppChatActivity extends AppCompatActivity implements InAppChatWebViewManager {
+
+ private static final String IN_APP_CHAT_MOBILE_INTERFACE = "InAppChatMobile";
+ private static final String RES_ID_IN_APP_CHAT_WIDGET_URI = "ib_inappchat_widget_uri";
+ private static final int CHAT_NOT_AVAILABLE_ANIM_DURATION_MILLIS = 500;
+
+ private boolean sendButtonIsColored;
+ private WidgetInfo widgetInfo;
+
+ /* View components */
+ private WebView webView;
+ private EditText editText;
+ private ImageView btnSend;
+ private ProgressBar progressBar;
+ private Toolbar toolbar;
+ private RelativeLayout relativeLayout;
+ private TextView chatNotAvailableView;
+ private InAppChatClient inAppChatClient;
+ private InAppChatViewSettingsResolver inAppChatViewSettingsResolver;
+ private Boolean shouldUseWidgetConfig = null;
+ private boolean receiversRegistered = false;
+ private Boolean chatNotAvailableViewShown = false;
+ private String widgetUri;
+ private boolean isWebViewLoaded = false;
+ private float chatNotAvailableViewHeight;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ widgetUri = ResourceLoader.loadStringResourceByName(this, RES_ID_IN_APP_CHAT_WIDGET_URI);
+ inAppChatViewSettingsResolver = new InAppChatViewSettingsResolver(this);
+ setTheme(inAppChatViewSettingsResolver.getChatViewTheme());
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.ib_activity_chat);
+
+ initViews();
+ updateViews();
+
+ loadWebPage(widgetUri);
+
+ registerReceivers();
+
+ Boolean chatWidgetConfigSynced = InAppChatImpl.getIsChatWidgetConfigSynced();
+ if (chatWidgetConfigSynced != null && !chatWidgetConfigSynced) {
+ chatErrors.insertError(InAppChatErrors.CONFIG_SYNC_ERROR);
+ }
+
+ }
+
+ @Override
+ protected void onDestroy() {
+ unregisterReceivers();
+ super.onDestroy();
+ }
+
+ private void updateViews() {
+ widgetInfo = prepareWidgetInfo();
+ if (widgetInfo != null) {
+ updateToolbarConfigs();
+ }
+ }
+
+ private WidgetInfo prepareWidgetInfo() {
+ SharedPreferences prefs = PropertyHelper.getDefaultMMSharedPreferences(this);
+ String widgetId = prefs.getString(MobileMessagingChatProperty.IN_APP_CHAT_WIDGET_ID.getKey(), null);
+ String widgetTitle = prefs.getString(MobileMessagingChatProperty.IN_APP_CHAT_WIDGET_TITLE.getKey(), null);
+ String widgetPrimaryColor = prefs.getString(MobileMessagingChatProperty.IN_APP_CHAT_WIDGET_PRIMARY_COLOR.getKey(), null);
+ String widgetBackgroundColor = prefs.getString(MobileMessagingChatProperty.IN_APP_CHAT_WIDGET_BACKGROUND_COLOR.getKey(), null);
+
+ if (widgetId != null) {
+ return new WidgetInfo(widgetId, widgetTitle, widgetPrimaryColor, widgetBackgroundColor);
+ }
+ return null;
+ }
+
+ private void initViews() {
+ progressBar = findViewById(R.id.ib_pb_chat);
+ relativeLayout = findViewById(R.id.ib_rl_send_message);
+ chatNotAvailableView = findViewById(R.id.ib_tv_chat_not_connected);
+ chatNotAvailableViewHeight = getResources().getDimension(R.dimen.chat_not_available_tv_height);
+ initToolbar();
+ initWebView();
+ initTextBar();
+ initSendButton();
+ }
+
+ private void initToolbar() {
+ toolbar = findViewById(R.id.ib_toolbar_chat);
+ if (toolbar == null) return;
+ setSupportActionBar(toolbar);
+ ActionBar supportActionBar = getSupportActionBar();
+ if (supportActionBar == null) {
+ toolbar.setNavigationIcon(R.drawable.ic_menu_white);
+ return;
+ }
+ supportActionBar.setDisplayHomeAsUpEnabled(true);
+ toolbar.setNavigationOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ closeChatPage();
+ }
+ });
+ }
+
+ public void closeChatPage() {
+ webView.freeMemory();
+ webView.removeAllViews();
+ webView.destroy();
+ finish();
+ }
+
+ private void initTextBar() {
+ editText = findViewById(R.id.ib_et_message_text);
+ editText.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ // nothing
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ if (s.length() > 0 && !sendButtonIsColored) {
+ fillSendButtonByPrimaryColor();
+ sendButtonIsColored = true;
+ } else if (s.length() == 0) {
+ btnSend.getDrawable().clearColorFilter();
+ sendButtonIsColored = false;
+ }
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ // nothing
+ }
+ });
+ }
+
+ private void fillSendButtonByPrimaryColor() {
+ @ColorInt int widgetPrimaryColor = Color.parseColor(widgetInfo.getPrimaryColor());
+ if (!shouldUseWidgetConfig()) {
+ TypedValue typedValue = new TypedValue();
+ Resources.Theme theme = getTheme();
+ theme.resolveAttribute(R.attr.colorPrimary, typedValue, true);
+ widgetPrimaryColor = typedValue.data;
+ }
+ btnSend.getDrawable().setColorFilter(widgetPrimaryColor, PorterDuff.Mode.SRC_ATOP);
+ }
+
+ private void updateToolbarConfigs() {
+ ActionBar actionBar = getSupportActionBar();
+ if (toolbar == null || actionBar == null) {
+ return;
+ }
+
+ @ColorInt int primaryColor = Color.parseColor(widgetInfo.getPrimaryColor());
+ @ColorInt int titleTextColor = Color.parseColor(widgetInfo.getBackgroundColor());
+ @ColorInt int navigationIconColor = titleTextColor;
+ @ColorInt int primaryDarkColor = calculatePrimaryDarkColor(primaryColor);
+
+ // setup colors (from widget or local config)
+ if (shouldUseWidgetConfig()) {
+ setStatusBarColor(primaryDarkColor);
+ } else {
+ TypedValue typedValue = new TypedValue();
+ Resources.Theme theme = getTheme();
+ // toolbar background color
+ theme.resolveAttribute(R.attr.colorPrimary, typedValue, true);
+ if (typedValue.data != 0) primaryColor = typedValue.data;
+ // titleFromRes text color
+ theme.resolveAttribute(R.attr.titleTextColor, typedValue, true);
+ if (typedValue.data != 0) titleTextColor = typedValue.data;
+ // back arrow color
+ theme.resolveAttribute(R.attr.colorControlNormal, typedValue, true);
+ if (typedValue.data != 0) navigationIconColor = typedValue.data;
+
+ theme.resolveAttribute(R.attr.colorPrimaryDark, typedValue, true);
+ if (typedValue.data != 0) primaryDarkColor = typedValue.data;
+ }
+
+ // set colors to views
+ try {
+ progressBar.getIndeterminateDrawable().setColorFilter(primaryDarkColor, PorterDuff.Mode.SRC_IN);
+ } catch (Exception ignored) {
+ }
+ toolbar.setBackgroundColor(primaryColor);
+
+ String title = inAppChatViewSettingsResolver.getChatViewTitle();
+ if (StringUtils.isBlank(title)) {
+ title = widgetInfo.getTitle();
+ }
+ actionBar.setTitle(title);
+ toolbar.setTitleTextColor(titleTextColor);
+
+ Drawable drawable = toolbar.getNavigationIcon();
+ if (drawable != null) {
+ drawable.setColorFilter(navigationIconColor, PorterDuff.Mode.SRC_ATOP);
+ }
+ }
+
+ private int calculatePrimaryDarkColor(int primaryColor) {
+ return ColorUtils.blendARGB(primaryColor, Color.BLACK, 0.2f);
+ }
+
+ private void setStatusBarColor(int statusBarColor) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ Window window = this.getWindow();
+ window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
+ window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
+ window.setStatusBarColor(statusBarColor);
+ }
+ }
+
+ private boolean shouldUseWidgetConfig() {
+ if (shouldUseWidgetConfig != null) return shouldUseWidgetConfig;
+
+ TypedValue typedValue = new TypedValue();
+ Resources.Theme theme = getTheme();
+ theme.resolveAttribute(R.attr.colorPrimary, typedValue, true);
+ int primaryColor = typedValue.data;
+
+ theme.resolveAttribute(R.attr.colorControlNormal, typedValue, true);
+ int colorControlNormal = typedValue.data;
+
+ theme.resolveAttribute(R.attr.titleTextColor, typedValue, true);
+ int titleTextColor = typedValue.data;
+
+ shouldUseWidgetConfig = (primaryColor == colorControlNormal) && (colorControlNormal == titleTextColor);
+ return shouldUseWidgetConfig;
+ }
+
+ @SuppressLint({"AddJavascriptInterface", "SetJavaScriptEnabled"})
+ private void initWebView() {
+ webView = findViewById(R.id.ib_wv_in_app_chat);
+
+ WebSettings webViewSettings = webView.getSettings();
+ webViewSettings.setJavaScriptEnabled(true);
+ webViewSettings.setDomStorageEnabled(true);
+
+ webView.setClickable(true);
+ webView.setWebViewClient(new InAppChatWebViewClient(this));
+ webView.addJavascriptInterface(new InAppChatMobileImpl(this), IN_APP_CHAT_MOBILE_INTERFACE);
+
+ inAppChatClient = new InAppChatClientImpl(webView);
+ }
+
+ private void initSendButton() {
+ btnSend = findViewById(R.id.ib_btn_send);
+ btnSend.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Editable text = editText.getText();
+ if (text != null) {
+ inAppChatClient.sendChatMessage(escapeString(text.toString()));
+ text.clear();
+ }
+ }
+ });
+ }
+
+ private String escapeString(String source) {
+ String serialize = new JsonSerializer().serialize(source);
+ return serialize.substring(1, serialize.length() - 1);
+ }
+
+ private void loadWebPage(String url) {
+ String pushRegistrationId = MobileMessagingCore.getInstance(this).getPushRegistrationId();
+ if (pushRegistrationId != null && webView != null && widgetInfo != null) {
+ String resultUrl = new Uri.Builder()
+ .encodedPath(url)
+ .appendQueryParameter("pushRegId", pushRegistrationId)
+ .appendQueryParameter("widgetId", widgetInfo.getId())
+ .build()
+ .toString();
+ webView.loadUrl(resultUrl);
+ }
+ }
+
+ @Override
+ public void onPageStarted() {
+ progressBar.setVisibility(View.VISIBLE);
+ webView.setVisibility(View.INVISIBLE);
+ }
+
+ @Override
+ public void onPageFinished() {
+ progressBar.setVisibility(View.GONE);
+ webView.setVisibility(View.VISIBLE);
+ }
+
+ @Override
+ public void setControlsEnabled(boolean isEnabled) {
+ editText.setEnabled(isEnabled);
+ btnSend.setEnabled(isEnabled);
+ isWebViewLoaded = isEnabled;
+ }
+
+ @Override
+ public void onJSError() {
+ chatErrors.insertError(InAppChatErrors.JS_ERROR);
+ webView.setVisibility(View.GONE);
+ progressBar.setVisibility(View.GONE);
+ relativeLayout.setVisibility(View.GONE);
+ }
+
+ /*
+ Errors handling
+ */
+
+ private static final String CHAT_SERVICE_ERROR = "12";
+ private static final String CHAT_WIDGET_NOT_FOUND = "24";
+
+ private final BroadcastReceiver broadcastEventsReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ if (action == null) {
+ return;
+ }
+ if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
+ if (intent.hasExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY)) {
+ chatErrors.insertError(InAppChatErrors.INTERNET_CONNECTION_ERROR);
+ } else {
+ chatErrors.removeError(InAppChatErrors.INTERNET_CONNECTION_ERROR);
+ }
+ } else if (action.equals(InAppChatEvent.CHAT_CONFIGURATION_SYNCED.getKey())) {
+ chatErrors.removeError(InAppChatErrors.CONFIG_SYNC_ERROR);
+ } else if (action.equals(Event.API_COMMUNICATION_ERROR.getKey()) && intent.hasExtra(BroadcastParameter.EXTRA_EXCEPTION)) {
+ MobileMessagingError mobileMessagingError = (MobileMessagingError) intent.getSerializableExtra(BroadcastParameter.EXTRA_EXCEPTION);
+ String errorCode = mobileMessagingError.getCode();
+ if (errorCode.equals(CHAT_SERVICE_ERROR) || errorCode.equals(CHAT_WIDGET_NOT_FOUND)) {
+ chatErrors.insertError(InAppChatErrors.CONFIG_SYNC_ERROR);
+ }
+ }
+ }
+ };
+
+ private InAppChatErrors chatErrors = new InAppChatErrors(new InAppChatErrors.OnChangeListener() {
+ @Override
+ public void onErrorsChange(Set newErrors, String removedError, String insertedError) {
+
+ if (removedError != null) {
+ //reload webView if it wasn't loaded in case when internet connection appeared
+ if (removedError.equals(InAppChatErrors.INTERNET_CONNECTION_ERROR) && !isWebViewLoaded) {
+ loadWebPage(widgetUri);
+ }
+
+ //update views configuration and reload webPage in case there was config sync error
+ if (removedError.equals(InAppChatErrors.CONFIG_SYNC_ERROR)) {
+ updateViews();
+ loadWebPage(widgetUri);
+ }
+ }
+
+ if (newErrors.isEmpty()) {
+ hideChatNotAvailableView();
+ } else {
+ showChatNotAvailableView();
+ }
+ }
+ });
+
+ private void showChatNotAvailableView() {
+ if (!chatNotAvailableViewShown) {
+ chatNotAvailableView.animate().translationY(chatNotAvailableViewHeight).setDuration(CHAT_NOT_AVAILABLE_ANIM_DURATION_MILLIS);
+ }
+ chatNotAvailableViewShown = true;
+ }
+
+ private void hideChatNotAvailableView() {
+ if (chatNotAvailableViewShown) {
+ chatNotAvailableView.animate().translationY(0).setDuration(CHAT_NOT_AVAILABLE_ANIM_DURATION_MILLIS);
+ }
+ chatNotAvailableViewShown = false;
+ }
+
+ protected void registerReceivers() {
+ if (!receiversRegistered) {
+ IntentFilter intentFilter = new IntentFilter();
+ intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
+ intentFilter.addAction(InAppChatEvent.CHAT_CONFIGURATION_SYNCED.getKey());
+ intentFilter.addAction(Event.API_COMMUNICATION_ERROR.getKey());
+ registerReceiver(broadcastEventsReceiver, intentFilter);
+ receiversRegistered = true;
+ }
+ }
+
+ protected void unregisterReceivers() {
+ if (receiversRegistered) {
+ unregisterReceiver(broadcastEventsReceiver);
+ receiversRegistered = false;
+ }
+ }
+}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/view/ChatViewSettingsResolver.java b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/view/InAppChatViewSettingsResolver.java
similarity index 61%
rename from infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/view/ChatViewSettingsResolver.java
rename to infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/view/InAppChatViewSettingsResolver.java
index 519b3454..4f096ee2 100644
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/view/ChatViewSettingsResolver.java
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/java/org/infobip/mobile/messaging/chat/view/InAppChatViewSettingsResolver.java
@@ -7,46 +7,31 @@
/**
* Contains custom chat view settings that can be changed by user
- *
- * @author sslavin
- * @since 07/11/2017.
*/
+class InAppChatViewSettingsResolver {
-public class ChatViewSettingsResolver {
-
- private static final String RES_ID_CHAT_VIEW_TITLE = "mm_chat_view_title";
- private static final String RES_ID_CHAT_VIEW_EMPTY_STATE_TEXT = "mm_chat_view_empty_state_text";
- private static final String RES_ID_CHAT_VIEW_THEME = "mm_chat_view_theme";
+ private static final String RES_ID_CHAT_VIEW_TITLE = "ib_in_app_chat_view_title";
+ private static final String RES_ID_CHAT_VIEW_THEME = "IB_AppTheme.Chat";
private static String chatViewTitle;
- private static String chatViewEmptyStateText;
private static int chatViewTheme;
private final Context context;
- public ChatViewSettingsResolver(Context context) {
+ InAppChatViewSettingsResolver(Context context) {
this.context = context;
}
- public String getChatViewTitle() {
+ String getChatViewTitle() {
if (chatViewTitle != null) {
return chatViewTitle;
}
- chatViewTitle = getStringResourceByName(RES_ID_CHAT_VIEW_TITLE, R.string.IB_chat_view_title);
+ chatViewTitle = getStringResourceByName(RES_ID_CHAT_VIEW_TITLE, R.string.ib_chat_view_title);
return chatViewTitle;
}
- public String getChatViewEmptyStateText() {
- if (chatViewEmptyStateText != null) {
- return chatViewEmptyStateText;
- }
-
- chatViewEmptyStateText = getStringResourceByName(RES_ID_CHAT_VIEW_EMPTY_STATE_TEXT, R.string.IB_chat_view_empty_state_text);
- return chatViewEmptyStateText;
- }
-
- public int getChatViewTheme() {
+ int getChatViewTheme() {
if (chatViewTheme != 0) {
return chatViewTheme;
}
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/res/drawable-v21/button_background.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/drawable-v21/button_background.xml
similarity index 100%
rename from infobip-mobile-messaging-android-chat-sdk/src/main/res/drawable-v21/button_background.xml
rename to infobip-mobile-messaging-huawei-chat-sdk/src/main/res/drawable-v21/button_background.xml
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/res/drawable-xxhdpi/button_background.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/drawable-xxhdpi/button_background.xml
similarity index 100%
rename from infobip-mobile-messaging-android-chat-sdk/src/main/res/drawable-xxhdpi/button_background.xml
rename to infobip-mobile-messaging-huawei-chat-sdk/src/main/res/drawable-xxhdpi/button_background.xml
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/res/drawable-xxhdpi/ic_menu_white.png b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/drawable-xxhdpi/ic_menu_white.png
similarity index 100%
rename from infobip-mobile-messaging-android-chat-sdk/src/main/res/drawable-xxhdpi/ic_menu_white.png
rename to infobip-mobile-messaging-huawei-chat-sdk/src/main/res/drawable-xxhdpi/ic_menu_white.png
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/drawable/ib_chat_send_btn_icon.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/drawable/ib_chat_send_btn_icon.xml
new file mode 100644
index 00000000..310255d4
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/drawable/ib_chat_send_btn_icon.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/drawable/light_border.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/drawable/light_border.xml
new file mode 100644
index 00000000..47232c9b
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/drawable/light_border.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/layout/ib_activity_chat.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/layout/ib_activity_chat.xml
new file mode 100644
index 00000000..ac28a2b7
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/layout/ib_activity_chat.xml
@@ -0,0 +1,97 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-ar/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-ar/strings.xml
new file mode 100644
index 00000000..a49f6ee7
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-ar/strings.xml
@@ -0,0 +1,4 @@
+
+
+ لا يوجد اتصال
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-cs/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-cs/strings.xml
new file mode 100644
index 00000000..d4a5d894
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-cs/strings.xml
@@ -0,0 +1,4 @@
+
+
+ Žádné připojení
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-da/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-da/strings.xml
new file mode 100644
index 00000000..1ea5bf76
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-da/strings.xml
@@ -0,0 +1,4 @@
+
+
+ Ingen forbindelse
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-de/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-de/strings.xml
new file mode 100644
index 00000000..7aa9f8a7
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-de/strings.xml
@@ -0,0 +1,4 @@
+
+
+ Keine Verbindung
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-es-rES/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-es-rES/strings.xml
new file mode 100644
index 00000000..b463a786
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-es-rES/strings.xml
@@ -0,0 +1,4 @@
+
+
+ Sin conexión
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-es/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-es/strings.xml
new file mode 100644
index 00000000..b463a786
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-es/strings.xml
@@ -0,0 +1,4 @@
+
+
+ Sin conexión
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-fi/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-fi/strings.xml
new file mode 100644
index 00000000..95e677a7
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-fi/strings.xml
@@ -0,0 +1,4 @@
+
+
+ Ei yhteyttä
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-fr/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-fr/strings.xml
new file mode 100644
index 00000000..3a6ba43a
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-fr/strings.xml
@@ -0,0 +1,4 @@
+
+
+ Pas de connection
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-hi/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-hi/strings.xml
new file mode 100644
index 00000000..92433f2a
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-hi/strings.xml
@@ -0,0 +1,4 @@
+
+
+ कोई कनेक्शन नहीं
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-hr/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-hr/strings.xml
new file mode 100644
index 00000000..926d5f02
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-hr/strings.xml
@@ -0,0 +1,4 @@
+
+
+ Nema veze
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-hu/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-hu/strings.xml
new file mode 100644
index 00000000..6ecb7d37
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-hu/strings.xml
@@ -0,0 +1,4 @@
+
+
+ Nincs kapcsolat
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-in/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-in/strings.xml
new file mode 100644
index 00000000..c57992fb
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-in/strings.xml
@@ -0,0 +1,4 @@
+
+
+ Tidak ada koneksi
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-it/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-it/strings.xml
new file mode 100644
index 00000000..2b6e7bf2
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-it/strings.xml
@@ -0,0 +1,4 @@
+
+
+ Nessuna connessione
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-iw/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-iw/strings.xml
new file mode 100644
index 00000000..13c27931
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-iw/strings.xml
@@ -0,0 +1,4 @@
+
+
+ אין חיבור
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-ja/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-ja/strings.xml
new file mode 100644
index 00000000..fdc9ee54
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-ja/strings.xml
@@ -0,0 +1,4 @@
+
+
+ 接続なし
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-ko/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-ko/strings.xml
new file mode 100644
index 00000000..b6b35b9f
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-ko/strings.xml
@@ -0,0 +1,4 @@
+
+
+ 연결이 없습니다
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-la/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-la/strings.xml
new file mode 100644
index 00000000..ba1570c0
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-la/strings.xml
@@ -0,0 +1,4 @@
+
+
+ No connection
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-ms/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-ms/strings.xml
new file mode 100644
index 00000000..d0ca0940
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-ms/strings.xml
@@ -0,0 +1,4 @@
+
+
+ Tiada sambungan
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-nl/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-nl/strings.xml
new file mode 100644
index 00000000..6383e73d
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-nl/strings.xml
@@ -0,0 +1,4 @@
+
+
+ Geen connectie
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-no/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-no/strings.xml
new file mode 100644
index 00000000..1ea5bf76
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-no/strings.xml
@@ -0,0 +1,4 @@
+
+
+ Ingen forbindelse
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-pl/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-pl/strings.xml
new file mode 100644
index 00000000..2dad8cb7
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-pl/strings.xml
@@ -0,0 +1,4 @@
+
+
+ Brak połączenia
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-pt-rPT/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-pt-rPT/strings.xml
new file mode 100644
index 00000000..8f304298
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-pt-rPT/strings.xml
@@ -0,0 +1,4 @@
+
+
+ Sem conexão
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-pt/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-pt/strings.xml
new file mode 100644
index 00000000..8f304298
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-pt/strings.xml
@@ -0,0 +1,4 @@
+
+
+ Sem conexão
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-ro/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-ro/strings.xml
new file mode 100644
index 00000000..d77444b3
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-ro/strings.xml
@@ -0,0 +1,4 @@
+
+
+ Nici o legătură
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-ru/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-ru/strings.xml
new file mode 100644
index 00000000..2712e73f
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-ru/strings.xml
@@ -0,0 +1,4 @@
+
+
+ Нет соединения
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-sk/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-sk/strings.xml
new file mode 100644
index 00000000..7149c0cc
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-sk/strings.xml
@@ -0,0 +1,4 @@
+
+
+ Žiadne spojenie
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-sv/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-sv/strings.xml
new file mode 100644
index 00000000..63b10a00
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-sv/strings.xml
@@ -0,0 +1,4 @@
+
+
+ Ingen förbindelse
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-th/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-th/strings.xml
new file mode 100644
index 00000000..e0950ffb
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-th/strings.xml
@@ -0,0 +1,4 @@
+
+
+ ไม่มีการเชื่อมต่อ
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-tr/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-tr/strings.xml
new file mode 100644
index 00000000..e74529b3
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-tr/strings.xml
@@ -0,0 +1,4 @@
+
+
+ Bağlantı yok
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-vi/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-vi/strings.xml
new file mode 100644
index 00000000..a12ba763
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-vi/strings.xml
@@ -0,0 +1,4 @@
+
+
+ Không có kết nối
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/res/values-w820dp/dimens.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-w820dp/dimens.xml
similarity index 100%
rename from infobip-mobile-messaging-android-chat-sdk/src/main/res/values-w820dp/dimens.xml
rename to infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-w820dp/dimens.xml
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-zh-rCN/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-zh-rCN/strings.xml
new file mode 100644
index 00000000..1a97822e
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-zh-rCN/strings.xml
@@ -0,0 +1,4 @@
+
+
+ 无连接
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-zh-rTW/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-zh-rTW/strings.xml
new file mode 100644
index 00000000..26fa6a12
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values-zh-rTW/strings.xml
@@ -0,0 +1,4 @@
+
+
+ 無連接
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/res/values/colors.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values/colors.xml
similarity index 100%
rename from infobip-mobile-messaging-android-chat-sdk/src/main/res/values/colors.xml
rename to infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values/colors.xml
diff --git a/infobip-mobile-messaging-android-chat-sdk/src/main/res/values/dimens.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values/dimens.xml
similarity index 84%
rename from infobip-mobile-messaging-android-chat-sdk/src/main/res/values/dimens.xml
rename to infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values/dimens.xml
index 72af4e09..72f259da 100644
--- a/infobip-mobile-messaging-android-chat-sdk/src/main/res/values/dimens.xml
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values/dimens.xml
@@ -4,4 +4,5 @@
16dp
8dp
2dp
+ 30dp
diff --git a/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values/strings.xml b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values/strings.xml
new file mode 100644
index 00000000..39e985b7
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-chat-sdk/src/main/res/values/strings.xml
@@ -0,0 +1,10 @@
+
+ file:///android_asset/inappchat-widget.html
+
+
+ ""
+ Send a message…
+ No connection
+ Send chat message
+
+
diff --git a/infobip-mobile-messaging-android-demo/.gitignore b/infobip-mobile-messaging-huawei-demo/.gitignore
similarity index 100%
rename from infobip-mobile-messaging-android-demo/.gitignore
rename to infobip-mobile-messaging-huawei-demo/.gitignore
diff --git a/infobip-mobile-messaging-android-demo/build.gradle b/infobip-mobile-messaging-huawei-demo/build.gradle
similarity index 71%
rename from infobip-mobile-messaging-android-demo/build.gradle
rename to infobip-mobile-messaging-huawei-demo/build.gradle
index 5258ee77..f24f1ae1 100644
--- a/infobip-mobile-messaging-android-demo/build.gradle
+++ b/infobip-mobile-messaging-huawei-demo/build.gradle
@@ -1,15 +1,18 @@
buildscript {
repositories {
jcenter()
+ maven { url 'http://developer.huawei.com/repo/' }
}
dependencies {
- classpath 'com.google.gms:google-services:4.1.0'
+ // classpath 'com.huawei.hms:push:4.0.2.300'
+ classpath 'com.huawei.agconnect:agcp:1.2.1.301'
}
}
apply plugin: 'com.android.application'
+apply plugin: 'com.huawei.agconnect'
android {
- compileSdkVersion mm_compileSdkVersion
+ compileSdkVersion 29
buildToolsVersion mm_buildToolsVersion
defaultConfig {
@@ -17,7 +20,7 @@ android {
targetSdkVersion mm_targetSdkVersion
versionCode 1
versionName version
- applicationId "org.infobip.mobile.messaging.demo"
+ applicationId "org.infobip.mobile.messaging.hmsdemo"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
@@ -27,6 +30,12 @@ android {
}
signingConfigs {
+ debug {
+ keyAlias 'hmsdemo'
+ keyPassword '123456'
+ storeFile file('src/HmsDemo.jks')
+ storePassword '123456'
+ }
release {
storeFile file("${property(project, 'signingKeystore', 'KEYSTORE')}")
storePassword "${property(project, 'signingKeystorePassword', 'KEYSTORE_PASSWORD')}"
@@ -38,7 +47,7 @@ android {
buildTypes {
all {
- property(project, 'google_app_id', 'GOOGLE_APP_ID')?.with { resValue "string", "google_app_id", delegate }
+ property(project, 'app_id', 'APP_ID')?.with { resValue "string", "app_id", delegate }
property(project, 'infobip_application_code', 'INFOBIP_APPLICATION_CODE')?.with { resValue "string", "infobip_application_code", delegate }
property(project, 'infobip_api_uri', 'INFOBIP_API_URI')?.with { resValue "string", "infobip_api_uri", delegate }
}
@@ -79,11 +88,15 @@ dependencies {
testImplementation "junit:junit:4.12"
androidTestImplementation "com.android.support.test:runner:1.0.2"
- implementation project(":infobip-mobile-messaging-android-chat-sdk")
- implementation project(":infobip-mobile-messaging-android-geo-sdk")
- implementation project(":infobip-mobile-messaging-android-resources")
- implementation project(":infobip-mobile-messaging-android-sdk")
- implementation project(":infobip-mobile-messaging-api-java")
+ implementation project(':infobip-mobile-messaging-huawei-chat-sdk')
+ implementation project(':infobip-mobile-messaging-huawei-geo-sdk')
+ implementation ('org.infobip.mobile.messaging.api:infobip-mobile-messaging-android-resources:3.0.4@aar')
+ implementation project(':infobip-mobile-messaging-huawei-sdk')
+
+ implementation 'org.infobip.mobile.messaging.api:infobip-mobile-messaging-api-java:3.0.4'
+
+ implementation 'com.huawei.hms:push:4.0.2.300'
+
implementation "com.android.support:appcompat-v7:${mm_supportLibrariesVersion}"
implementation "com.android.support:design:${mm_supportLibrariesVersion}"
implementation "com.android.support:support-v4:${mm_supportLibrariesVersion}"
diff --git a/infobip-mobile-messaging-android-demo/proguard-rules.pro b/infobip-mobile-messaging-huawei-demo/proguard-rules.pro
similarity index 100%
rename from infobip-mobile-messaging-android-demo/proguard-rules.pro
rename to infobip-mobile-messaging-huawei-demo/proguard-rules.pro
diff --git a/infobip-mobile-messaging-android-demo/src/androidTest/java/org/infobip/mobile/messaging/demo/ExampleInstrumentedTest.java b/infobip-mobile-messaging-huawei-demo/src/androidTest/java/org/infobip/mobile/messaging/demo/ExampleInstrumentedTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/androidTest/java/org/infobip/mobile/messaging/demo/ExampleInstrumentedTest.java
rename to infobip-mobile-messaging-huawei-demo/src/androidTest/java/org/infobip/mobile/messaging/demo/ExampleInstrumentedTest.java
diff --git a/infobip-mobile-messaging-android-demo/src/chat/AndroidManifest.xml b/infobip-mobile-messaging-huawei-demo/src/chat/AndroidManifest.xml
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/chat/AndroidManifest.xml
rename to infobip-mobile-messaging-huawei-demo/src/chat/AndroidManifest.xml
diff --git a/infobip-mobile-messaging-android-demo/src/chat/java/org/infobip/mobile/messaging/demo/MainActivity.java b/infobip-mobile-messaging-huawei-demo/src/chat/java/org/infobip/mobile/messaging/demo/MainActivity.java
similarity index 59%
rename from infobip-mobile-messaging-android-demo/src/chat/java/org/infobip/mobile/messaging/demo/MainActivity.java
rename to infobip-mobile-messaging-huawei-demo/src/chat/java/org/infobip/mobile/messaging/demo/MainActivity.java
index 6b0cfb59..870ac5df 100644
--- a/infobip-mobile-messaging-android-demo/src/chat/java/org/infobip/mobile/messaging/demo/MainActivity.java
+++ b/infobip-mobile-messaging-huawei-demo/src/chat/java/org/infobip/mobile/messaging/demo/MainActivity.java
@@ -6,20 +6,15 @@
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
-import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
-import android.widget.EditText;
import android.widget.Toast;
import org.infobip.mobile.messaging.MobileMessaging;
-import org.infobip.mobile.messaging.chat.ChatMessageStorage;
-import org.infobip.mobile.messaging.chat.MobileChat;
+import org.infobip.mobile.messaging.chat.InAppChat;
/**
* @author sslavin
@@ -28,46 +23,22 @@
public class MainActivity extends AppCompatActivity {
- private MobileChat mobileChat;
- private ChatMessageStorage messageStorage;
- private ChatMessagesAdapter messagesAdapter;
-
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setSupportActionBar(this.findViewById(R.id.toolbar));
- mobileChat = MobileChat.getInstance(this);
- messageStorage = mobileChat.getChatMessageStorage();
-
- RecyclerView rv = findViewById(R.id.rv_messages);
- rv.setLayoutManager(new LinearLayoutManager(this));
-
- messagesAdapter = new ChatMessagesAdapter(this, messageStorage.findAllMessages());
- messageStorage.registerListener(messagesAdapter);
- rv.setAdapter(messagesAdapter);
-
- Button btn = findViewById(R.id.btn_send);
+ Button btn = findViewById(R.id.btn_open);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- EditText et = findViewById(R.id.et_message_text);
- String text = et.getText().toString();
- et.setText("");
- if (!TextUtils.isEmpty(text)) {
- mobileChat.sendMessage(text);
- }
+ InAppChat.getInstance(MainActivity.this).inAppChatView().show();
+
}
});
}
- @Override
- protected void onDestroy() {
- messageStorage.unregisterListener(messagesAdapter);
- super.onDestroy();
- }
-
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
diff --git a/infobip-mobile-messaging-android-demo/src/chat/res/drawable/ic_content_copy_white_24dp.xml b/infobip-mobile-messaging-huawei-demo/src/chat/res/drawable/ic_content_copy_white_24dp.xml
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/chat/res/drawable/ic_content_copy_white_24dp.xml
rename to infobip-mobile-messaging-huawei-demo/src/chat/res/drawable/ic_content_copy_white_24dp.xml
diff --git a/infobip-mobile-messaging-huawei-demo/src/chat/res/layout/activity_main.xml b/infobip-mobile-messaging-huawei-demo/src/chat/res/layout/activity_main.xml
new file mode 100644
index 00000000..5bd58bc4
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-demo/src/chat/res/layout/activity_main.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-demo/src/chat/res/menu/menu_main.xml b/infobip-mobile-messaging-huawei-demo/src/chat/res/menu/menu_main.xml
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/chat/res/menu/menu_main.xml
rename to infobip-mobile-messaging-huawei-demo/src/chat/res/menu/menu_main.xml
diff --git a/infobip-mobile-messaging-android-demo/src/chat/res/values/strings.xml b/infobip-mobile-messaging-huawei-demo/src/chat/res/values/strings.xml
similarity index 82%
rename from infobip-mobile-messaging-android-demo/src/chat/res/values/strings.xml
rename to infobip-mobile-messaging-huawei-demo/src/chat/res/values/strings.xml
index 773aac5f..ce600e4b 100644
--- a/infobip-mobile-messaging-android-demo/src/chat/res/values/strings.xml
+++ b/infobip-mobile-messaging-huawei-demo/src/chat/res/values/strings.xml
@@ -2,7 +2,7 @@
Chat Example
- SEND
+ Go to chat screen
Write your message
Registration ID
diff --git a/infobip-mobile-messaging-android-demo/src/deeplink/AndroidManifest.xml b/infobip-mobile-messaging-huawei-demo/src/deeplink/AndroidManifest.xml
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/deeplink/AndroidManifest.xml
rename to infobip-mobile-messaging-huawei-demo/src/deeplink/AndroidManifest.xml
diff --git a/infobip-mobile-messaging-android-demo/src/deeplink/java/org.infobip.mobile.messaging.demo/BlueScreenActivity.java b/infobip-mobile-messaging-huawei-demo/src/deeplink/java/org.infobip.mobile.messaging.demo/BlueScreenActivity.java
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/deeplink/java/org.infobip.mobile.messaging.demo/BlueScreenActivity.java
rename to infobip-mobile-messaging-huawei-demo/src/deeplink/java/org.infobip.mobile.messaging.demo/BlueScreenActivity.java
diff --git a/infobip-mobile-messaging-android-demo/src/deeplink/java/org.infobip.mobile.messaging.demo/ColoredScreenActivity.java b/infobip-mobile-messaging-huawei-demo/src/deeplink/java/org.infobip.mobile.messaging.demo/ColoredScreenActivity.java
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/deeplink/java/org.infobip.mobile.messaging.demo/ColoredScreenActivity.java
rename to infobip-mobile-messaging-huawei-demo/src/deeplink/java/org.infobip.mobile.messaging.demo/ColoredScreenActivity.java
diff --git a/infobip-mobile-messaging-android-demo/src/deeplink/java/org.infobip.mobile.messaging.demo/GreenScreenActivity.java b/infobip-mobile-messaging-huawei-demo/src/deeplink/java/org.infobip.mobile.messaging.demo/GreenScreenActivity.java
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/deeplink/java/org.infobip.mobile.messaging.demo/GreenScreenActivity.java
rename to infobip-mobile-messaging-huawei-demo/src/deeplink/java/org.infobip.mobile.messaging.demo/GreenScreenActivity.java
diff --git a/infobip-mobile-messaging-android-demo/src/deeplink/java/org.infobip.mobile.messaging.demo/MainActivity.java b/infobip-mobile-messaging-huawei-demo/src/deeplink/java/org.infobip.mobile.messaging.demo/MainActivity.java
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/deeplink/java/org.infobip.mobile.messaging.demo/MainActivity.java
rename to infobip-mobile-messaging-huawei-demo/src/deeplink/java/org.infobip.mobile.messaging.demo/MainActivity.java
diff --git a/infobip-mobile-messaging-android-demo/src/deeplink/java/org.infobip.mobile.messaging.demo/NotificationTappedReceiver.java b/infobip-mobile-messaging-huawei-demo/src/deeplink/java/org.infobip.mobile.messaging.demo/NotificationTappedReceiver.java
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/deeplink/java/org.infobip.mobile.messaging.demo/NotificationTappedReceiver.java
rename to infobip-mobile-messaging-huawei-demo/src/deeplink/java/org.infobip.mobile.messaging.demo/NotificationTappedReceiver.java
diff --git a/infobip-mobile-messaging-android-demo/src/deeplink/java/org.infobip.mobile.messaging.demo/RedScreenActivity.java b/infobip-mobile-messaging-huawei-demo/src/deeplink/java/org.infobip.mobile.messaging.demo/RedScreenActivity.java
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/deeplink/java/org.infobip.mobile.messaging.demo/RedScreenActivity.java
rename to infobip-mobile-messaging-huawei-demo/src/deeplink/java/org.infobip.mobile.messaging.demo/RedScreenActivity.java
diff --git a/infobip-mobile-messaging-android-demo/src/deeplink/res/layout/activity_colored_screen.xml b/infobip-mobile-messaging-huawei-demo/src/deeplink/res/layout/activity_colored_screen.xml
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/deeplink/res/layout/activity_colored_screen.xml
rename to infobip-mobile-messaging-huawei-demo/src/deeplink/res/layout/activity_colored_screen.xml
diff --git a/infobip-mobile-messaging-android-demo/src/deeplink/res/layout/activity_main.xml b/infobip-mobile-messaging-huawei-demo/src/deeplink/res/layout/activity_main.xml
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/deeplink/res/layout/activity_main.xml
rename to infobip-mobile-messaging-huawei-demo/src/deeplink/res/layout/activity_main.xml
diff --git a/infobip-mobile-messaging-android-demo/src/deeplink/res/values/strings.xml b/infobip-mobile-messaging-huawei-demo/src/deeplink/res/values/strings.xml
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/deeplink/res/values/strings.xml
rename to infobip-mobile-messaging-huawei-demo/src/deeplink/res/values/strings.xml
diff --git a/infobip-mobile-messaging-android-demo/src/main/AndroidManifest.xml b/infobip-mobile-messaging-huawei-demo/src/main/AndroidManifest.xml
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/main/AndroidManifest.xml
rename to infobip-mobile-messaging-huawei-demo/src/main/AndroidManifest.xml
diff --git a/infobip-mobile-messaging-android-demo/src/main/java/org/infobip/mobile/messaging/demo/Application.java b/infobip-mobile-messaging-huawei-demo/src/main/java/org/infobip/mobile/messaging/demo/Application.java
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/main/java/org/infobip/mobile/messaging/demo/Application.java
rename to infobip-mobile-messaging-huawei-demo/src/main/java/org/infobip/mobile/messaging/demo/Application.java
diff --git a/infobip-mobile-messaging-android-demo/src/main/java/org/infobip/mobile/messaging/demo/RunnableWithParameter.java b/infobip-mobile-messaging-huawei-demo/src/main/java/org/infobip/mobile/messaging/demo/RunnableWithParameter.java
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/main/java/org/infobip/mobile/messaging/demo/RunnableWithParameter.java
rename to infobip-mobile-messaging-huawei-demo/src/main/java/org/infobip/mobile/messaging/demo/RunnableWithParameter.java
diff --git a/infobip-mobile-messaging-android-demo/src/main/res/drawable-hdpi/ic_notification.png b/infobip-mobile-messaging-huawei-demo/src/main/res/drawable-hdpi/ic_notification.png
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/main/res/drawable-hdpi/ic_notification.png
rename to infobip-mobile-messaging-huawei-demo/src/main/res/drawable-hdpi/ic_notification.png
diff --git a/infobip-mobile-messaging-android-demo/src/main/res/drawable-mdpi/ic_notification.png b/infobip-mobile-messaging-huawei-demo/src/main/res/drawable-mdpi/ic_notification.png
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/main/res/drawable-mdpi/ic_notification.png
rename to infobip-mobile-messaging-huawei-demo/src/main/res/drawable-mdpi/ic_notification.png
diff --git a/infobip-mobile-messaging-android-demo/src/main/res/drawable-v21/ic_notification.xml b/infobip-mobile-messaging-huawei-demo/src/main/res/drawable-v21/ic_notification.xml
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/main/res/drawable-v21/ic_notification.xml
rename to infobip-mobile-messaging-huawei-demo/src/main/res/drawable-v21/ic_notification.xml
diff --git a/infobip-mobile-messaging-android-demo/src/main/res/drawable-xhdpi/ic_notification.png b/infobip-mobile-messaging-huawei-demo/src/main/res/drawable-xhdpi/ic_notification.png
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/main/res/drawable-xhdpi/ic_notification.png
rename to infobip-mobile-messaging-huawei-demo/src/main/res/drawable-xhdpi/ic_notification.png
diff --git a/infobip-mobile-messaging-android-demo/src/main/res/drawable-xxhdpi/ic_notification.png b/infobip-mobile-messaging-huawei-demo/src/main/res/drawable-xxhdpi/ic_notification.png
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/main/res/drawable-xxhdpi/ic_notification.png
rename to infobip-mobile-messaging-huawei-demo/src/main/res/drawable-xxhdpi/ic_notification.png
diff --git a/infobip-mobile-messaging-android-demo/src/main/res/drawable-xxxhdpi/ic_notification.png b/infobip-mobile-messaging-huawei-demo/src/main/res/drawable-xxxhdpi/ic_notification.png
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/main/res/drawable-xxxhdpi/ic_notification.png
rename to infobip-mobile-messaging-huawei-demo/src/main/res/drawable-xxxhdpi/ic_notification.png
diff --git a/infobip-mobile-messaging-android-demo/src/main/res/layout/dialog_text.xml b/infobip-mobile-messaging-huawei-demo/src/main/res/layout/dialog_text.xml
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/main/res/layout/dialog_text.xml
rename to infobip-mobile-messaging-huawei-demo/src/main/res/layout/dialog_text.xml
diff --git a/infobip-mobile-messaging-android-demo/src/main/res/layout/toolbar.xml b/infobip-mobile-messaging-huawei-demo/src/main/res/layout/toolbar.xml
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/main/res/layout/toolbar.xml
rename to infobip-mobile-messaging-huawei-demo/src/main/res/layout/toolbar.xml
diff --git a/infobip-mobile-messaging-android-demo/src/main/res/mipmap-hdpi/ic_launcher.png b/infobip-mobile-messaging-huawei-demo/src/main/res/mipmap-hdpi/ic_launcher.png
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/main/res/mipmap-hdpi/ic_launcher.png
rename to infobip-mobile-messaging-huawei-demo/src/main/res/mipmap-hdpi/ic_launcher.png
diff --git a/infobip-mobile-messaging-android-demo/src/main/res/mipmap-mdpi/ic_launcher.png b/infobip-mobile-messaging-huawei-demo/src/main/res/mipmap-mdpi/ic_launcher.png
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/main/res/mipmap-mdpi/ic_launcher.png
rename to infobip-mobile-messaging-huawei-demo/src/main/res/mipmap-mdpi/ic_launcher.png
diff --git a/infobip-mobile-messaging-android-demo/src/main/res/mipmap-xhdpi/ic_launcher.png b/infobip-mobile-messaging-huawei-demo/src/main/res/mipmap-xhdpi/ic_launcher.png
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/main/res/mipmap-xhdpi/ic_launcher.png
rename to infobip-mobile-messaging-huawei-demo/src/main/res/mipmap-xhdpi/ic_launcher.png
diff --git a/infobip-mobile-messaging-android-demo/src/main/res/mipmap-xxhdpi/ic_launcher.png b/infobip-mobile-messaging-huawei-demo/src/main/res/mipmap-xxhdpi/ic_launcher.png
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/main/res/mipmap-xxhdpi/ic_launcher.png
rename to infobip-mobile-messaging-huawei-demo/src/main/res/mipmap-xxhdpi/ic_launcher.png
diff --git a/infobip-mobile-messaging-android-demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/infobip-mobile-messaging-huawei-demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png
rename to infobip-mobile-messaging-huawei-demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png
diff --git a/infobip-mobile-messaging-android-demo/src/main/res/values-v21/styles.xml b/infobip-mobile-messaging-huawei-demo/src/main/res/values-v21/styles.xml
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/main/res/values-v21/styles.xml
rename to infobip-mobile-messaging-huawei-demo/src/main/res/values-v21/styles.xml
diff --git a/infobip-mobile-messaging-android-demo/src/main/res/values-w820dp/dimens.xml b/infobip-mobile-messaging-huawei-demo/src/main/res/values-w820dp/dimens.xml
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/main/res/values-w820dp/dimens.xml
rename to infobip-mobile-messaging-huawei-demo/src/main/res/values-w820dp/dimens.xml
diff --git a/infobip-mobile-messaging-android-demo/src/main/res/values/colors.xml b/infobip-mobile-messaging-huawei-demo/src/main/res/values/colors.xml
similarity index 85%
rename from infobip-mobile-messaging-android-demo/src/main/res/values/colors.xml
rename to infobip-mobile-messaging-huawei-demo/src/main/res/values/colors.xml
index c6d209da..3271af18 100644
--- a/infobip-mobile-messaging-android-demo/src/main/res/values/colors.xml
+++ b/infobip-mobile-messaging-huawei-demo/src/main/res/values/colors.xml
@@ -2,7 +2,7 @@
#df531b
#d84315
- #FF4081
+ #ff8449
#FFA8B1
#BAFFB7
diff --git a/infobip-mobile-messaging-android-demo/src/main/res/values/dimens.xml b/infobip-mobile-messaging-huawei-demo/src/main/res/values/dimens.xml
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/main/res/values/dimens.xml
rename to infobip-mobile-messaging-huawei-demo/src/main/res/values/dimens.xml
diff --git a/infobip-mobile-messaging-huawei-demo/src/main/res/values/strings.xml b/infobip-mobile-messaging-huawei-demo/src/main/res/values/strings.xml
new file mode 100644
index 00000000..e73be8ae
--- /dev/null
+++ b/infobip-mobile-messaging-huawei-demo/src/main/res/values/strings.xml
@@ -0,0 +1,4 @@
+
+ Mobile Messaging Example
+
+
diff --git a/infobip-mobile-messaging-android-demo/src/main/res/values/styles.xml b/infobip-mobile-messaging-huawei-demo/src/main/res/values/styles.xml
similarity index 52%
rename from infobip-mobile-messaging-android-demo/src/main/res/values/styles.xml
rename to infobip-mobile-messaging-huawei-demo/src/main/res/values/styles.xml
index 16dbab30..2b906487 100644
--- a/infobip-mobile-messaging-android-demo/src/main/res/values/styles.xml
+++ b/infobip-mobile-messaging-huawei-demo/src/main/res/values/styles.xml
@@ -14,4 +14,18 @@
+
+
+
+
diff --git a/infobip-mobile-messaging-android-demo/src/push/AndroidManifest.xml b/infobip-mobile-messaging-huawei-demo/src/push/AndroidManifest.xml
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/push/AndroidManifest.xml
rename to infobip-mobile-messaging-huawei-demo/src/push/AndroidManifest.xml
diff --git a/infobip-mobile-messaging-android-demo/src/push/java/org/infobip/mobile/messaging/demo/MainActivity.java b/infobip-mobile-messaging-huawei-demo/src/push/java/org/infobip/mobile/messaging/demo/MainActivity.java
similarity index 98%
rename from infobip-mobile-messaging-android-demo/src/push/java/org/infobip/mobile/messaging/demo/MainActivity.java
rename to infobip-mobile-messaging-huawei-demo/src/push/java/org/infobip/mobile/messaging/demo/MainActivity.java
index bb2c1a38..e247b120 100644
--- a/infobip-mobile-messaging-android-demo/src/push/java/org/infobip/mobile/messaging/demo/MainActivity.java
+++ b/infobip-mobile-messaging-huawei-demo/src/push/java/org/infobip/mobile/messaging/demo/MainActivity.java
@@ -33,8 +33,8 @@
import org.infobip.mobile.messaging.User;
import org.infobip.mobile.messaging.api.support.util.CollectionUtils;
import org.infobip.mobile.messaging.geo.MobileGeo;
-import org.infobip.mobile.messaging.mobile.MobileMessagingError;
-import org.infobip.mobile.messaging.mobile.Result;
+import org.infobip.mobile.messaging.mobileapi.MobileMessagingError;
+import org.infobip.mobile.messaging.mobileapi.Result;
import org.infobip.mobile.messaging.storage.MessageStore;
public class MainActivity extends AppCompatActivity {
diff --git a/infobip-mobile-messaging-android-demo/src/push/res/drawable-hdpi/ic_info_black_24dp.png b/infobip-mobile-messaging-huawei-demo/src/push/res/drawable-hdpi/ic_info_black_24dp.png
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/push/res/drawable-hdpi/ic_info_black_24dp.png
rename to infobip-mobile-messaging-huawei-demo/src/push/res/drawable-hdpi/ic_info_black_24dp.png
diff --git a/infobip-mobile-messaging-android-demo/src/push/res/drawable-mdpi/ic_info_black_24dp.png b/infobip-mobile-messaging-huawei-demo/src/push/res/drawable-mdpi/ic_info_black_24dp.png
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/push/res/drawable-mdpi/ic_info_black_24dp.png
rename to infobip-mobile-messaging-huawei-demo/src/push/res/drawable-mdpi/ic_info_black_24dp.png
diff --git a/infobip-mobile-messaging-android-demo/src/push/res/drawable-v21/ic_info_black_24dp.xml b/infobip-mobile-messaging-huawei-demo/src/push/res/drawable-v21/ic_info_black_24dp.xml
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/push/res/drawable-v21/ic_info_black_24dp.xml
rename to infobip-mobile-messaging-huawei-demo/src/push/res/drawable-v21/ic_info_black_24dp.xml
diff --git a/infobip-mobile-messaging-android-demo/src/push/res/drawable-xhdpi/ic_info_black_24dp.png b/infobip-mobile-messaging-huawei-demo/src/push/res/drawable-xhdpi/ic_info_black_24dp.png
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/push/res/drawable-xhdpi/ic_info_black_24dp.png
rename to infobip-mobile-messaging-huawei-demo/src/push/res/drawable-xhdpi/ic_info_black_24dp.png
diff --git a/infobip-mobile-messaging-android-demo/src/push/res/drawable-xxhdpi/ic_info_black_24dp.png b/infobip-mobile-messaging-huawei-demo/src/push/res/drawable-xxhdpi/ic_info_black_24dp.png
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/push/res/drawable-xxhdpi/ic_info_black_24dp.png
rename to infobip-mobile-messaging-huawei-demo/src/push/res/drawable-xxhdpi/ic_info_black_24dp.png
diff --git a/infobip-mobile-messaging-android-demo/src/push/res/drawable-xxxhdpi/ic_info_black_24dp.png b/infobip-mobile-messaging-huawei-demo/src/push/res/drawable-xxxhdpi/ic_info_black_24dp.png
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/push/res/drawable-xxxhdpi/ic_info_black_24dp.png
rename to infobip-mobile-messaging-huawei-demo/src/push/res/drawable-xxxhdpi/ic_info_black_24dp.png
diff --git a/infobip-mobile-messaging-android-demo/src/push/res/layout/activity_main.xml b/infobip-mobile-messaging-huawei-demo/src/push/res/layout/activity_main.xml
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/push/res/layout/activity_main.xml
rename to infobip-mobile-messaging-huawei-demo/src/push/res/layout/activity_main.xml
diff --git a/infobip-mobile-messaging-android-demo/src/push/res/layout/message_details.xml b/infobip-mobile-messaging-huawei-demo/src/push/res/layout/message_details.xml
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/push/res/layout/message_details.xml
rename to infobip-mobile-messaging-huawei-demo/src/push/res/layout/message_details.xml
diff --git a/infobip-mobile-messaging-android-demo/src/push/res/layout/message_row.xml b/infobip-mobile-messaging-huawei-demo/src/push/res/layout/message_row.xml
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/push/res/layout/message_row.xml
rename to infobip-mobile-messaging-huawei-demo/src/push/res/layout/message_row.xml
diff --git a/infobip-mobile-messaging-android-demo/src/push/res/menu/menu_main.xml b/infobip-mobile-messaging-huawei-demo/src/push/res/menu/menu_main.xml
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/push/res/menu/menu_main.xml
rename to infobip-mobile-messaging-huawei-demo/src/push/res/menu/menu_main.xml
diff --git a/infobip-mobile-messaging-android-demo/src/push/res/values/strings.xml b/infobip-mobile-messaging-huawei-demo/src/push/res/values/strings.xml
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/push/res/values/strings.xml
rename to infobip-mobile-messaging-huawei-demo/src/push/res/values/strings.xml
diff --git a/infobip-mobile-messaging-android-demo/src/web/AndroidManifest.xml b/infobip-mobile-messaging-huawei-demo/src/web/AndroidManifest.xml
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/web/AndroidManifest.xml
rename to infobip-mobile-messaging-huawei-demo/src/web/AndroidManifest.xml
diff --git a/infobip-mobile-messaging-android-demo/src/web/java/org.infobip.mobile.messaging.demo/MainActivity.java b/infobip-mobile-messaging-huawei-demo/src/web/java/org.infobip.mobile.messaging.demo/MainActivity.java
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/web/java/org.infobip.mobile.messaging.demo/MainActivity.java
rename to infobip-mobile-messaging-huawei-demo/src/web/java/org.infobip.mobile.messaging.demo/MainActivity.java
diff --git a/infobip-mobile-messaging-android-demo/src/web/java/org.infobip.mobile.messaging.demo/WebViewActivity.java b/infobip-mobile-messaging-huawei-demo/src/web/java/org.infobip.mobile.messaging.demo/WebViewActivity.java
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/web/java/org.infobip.mobile.messaging.demo/WebViewActivity.java
rename to infobip-mobile-messaging-huawei-demo/src/web/java/org.infobip.mobile.messaging.demo/WebViewActivity.java
diff --git a/infobip-mobile-messaging-android-demo/src/web/res/layout/activity_main.xml b/infobip-mobile-messaging-huawei-demo/src/web/res/layout/activity_main.xml
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/web/res/layout/activity_main.xml
rename to infobip-mobile-messaging-huawei-demo/src/web/res/layout/activity_main.xml
diff --git a/infobip-mobile-messaging-android-demo/src/web/res/layout/webview.xml b/infobip-mobile-messaging-huawei-demo/src/web/res/layout/webview.xml
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/web/res/layout/webview.xml
rename to infobip-mobile-messaging-huawei-demo/src/web/res/layout/webview.xml
diff --git a/infobip-mobile-messaging-android-demo/src/web/res/values/strings.xml b/infobip-mobile-messaging-huawei-demo/src/web/res/values/strings.xml
similarity index 100%
rename from infobip-mobile-messaging-android-demo/src/web/res/values/strings.xml
rename to infobip-mobile-messaging-huawei-demo/src/web/res/values/strings.xml
diff --git a/infobip-mobile-messaging-android-geo-sdk/.gitignore b/infobip-mobile-messaging-huawei-geo-sdk/.gitignore
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/.gitignore
rename to infobip-mobile-messaging-huawei-geo-sdk/.gitignore
diff --git a/infobip-mobile-messaging-android-geo-sdk/build.gradle b/infobip-mobile-messaging-huawei-geo-sdk/build.gradle
similarity index 88%
rename from infobip-mobile-messaging-android-geo-sdk/build.gradle
rename to infobip-mobile-messaging-huawei-geo-sdk/build.gradle
index 7482a7b0..825f6f5a 100644
--- a/infobip-mobile-messaging-android-geo-sdk/build.gradle
+++ b/infobip-mobile-messaging-huawei-geo-sdk/build.gradle
@@ -1,13 +1,14 @@
buildscript {
repositories {
jcenter()
+ maven { url 'http://developer.huawei.com/repo/' }
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.5.3'
+ classpath 'com.android.tools.build:gradle:3.6.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
}
@@ -49,11 +50,12 @@ android {
}
dependencies {
- implementation project(":infobip-mobile-messaging-android-sdk")
- implementation project(":infobip-mobile-messaging-api-java")
+ implementation project(':infobip-mobile-messaging-huawei-sdk')
+ implementation 'org.infobip.mobile.messaging.api:infobip-mobile-messaging-api-java:3.0.4'
+ implementation('com.huawei.hms:location:4.0.2.300')
implementation "com.android.support:support-v4:${mm_supportLibrariesVersion}"
- androidTestImplementation project(":infobip-mobile-messaging-android-test")
+ androidTestImplementation project(':infobip-mobile-messaging-huawei-test')
androidTestImplementation "junit:junit:4.12"
androidTestImplementation "org.mockito:mockito-core:1.10.19"
androidTestImplementation 'com.nanohttpd:nanohttpd:2.1.0'
@@ -61,7 +63,7 @@ dependencies {
exclude group: "org.json", module: "json"
}
- testImplementation project(":infobip-mobile-messaging-android-test")
+ testImplementation project(':infobip-mobile-messaging-huawei-test')
}
android.libraryVariants.all { variant ->
diff --git a/infobip-mobile-messaging-android-geo-sdk/proguard-rules.pro b/infobip-mobile-messaging-huawei-geo-sdk/proguard-rules.pro
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/proguard-rules.pro
rename to infobip-mobile-messaging-huawei-geo-sdk/proguard-rules.pro
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoAreasHandlerTests.java b/infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoAreasHandlerTests.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoAreasHandlerTests.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoAreasHandlerTests.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoDeliveryTimeWindowTest.java b/infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoDeliveryTimeWindowTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoDeliveryTimeWindowTest.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoDeliveryTimeWindowTest.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoEnabledConsistencyReceiverTest.java b/infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoEnabledConsistencyReceiverTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoEnabledConsistencyReceiverTest.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoEnabledConsistencyReceiverTest.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoEventsTest.java b/infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoEventsTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoEventsTest.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoEventsTest.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoHelper.java b/infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoHelper.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoHelper.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoHelper.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoNotificationHelperTest.java b/infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoNotificationHelperTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoNotificationHelperTest.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoNotificationHelperTest.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoReportHelperTest.java b/infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoReportHelperTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoReportHelperTest.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoReportHelperTest.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoReporterTest.java b/infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoReporterTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoReporterTest.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeoReporterTest.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeofencingTest.java b/infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeofencingTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeofencingTest.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/GeofencingTest.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/FCMMessageTest.java b/infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/HMSMessageTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/FCMMessageTest.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/HMSMessageTest.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/MessageStoreTest.java b/infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/MessageStoreTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/MessageStoreTest.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/MessageStoreTest.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/MobileMessageHandlerTest.java b/infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/MobileMessageHandlerTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/MobileMessageHandlerTest.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/MobileMessageHandlerTest.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/PushUnregisteredTest.java b/infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/PushUnregisteredTest.java
similarity index 94%
rename from infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/PushUnregisteredTest.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/PushUnregisteredTest.java
index 5d3d55bb..25ed9a91 100644
--- a/infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/PushUnregisteredTest.java
+++ b/infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/PushUnregisteredTest.java
@@ -16,12 +16,12 @@
import org.infobip.mobile.messaging.geo.report.GeoReport;
import org.infobip.mobile.messaging.geo.report.GeoReporter;
import org.infobip.mobile.messaging.geo.tools.MobileMessagingTestCase;
-import org.infobip.mobile.messaging.mobile.BatchReporter;
-import org.infobip.mobile.messaging.mobile.appinstance.InstallationSynchronizer;
-import org.infobip.mobile.messaging.mobile.common.MRetryPolicy;
-import org.infobip.mobile.messaging.mobile.common.RetryPolicyProvider;
-import org.infobip.mobile.messaging.mobile.messages.MessagesSynchronizer;
-import org.infobip.mobile.messaging.mobile.seen.SeenStatusReporter;
+import org.infobip.mobile.messaging.mobileapi.BatchReporter;
+import org.infobip.mobile.messaging.mobileapi.appinstance.InstallationSynchronizer;
+import org.infobip.mobile.messaging.mobileapi.common.MRetryPolicy;
+import org.infobip.mobile.messaging.mobileapi.common.RetryPolicyProvider;
+import org.infobip.mobile.messaging.mobileapi.messages.MessagesSynchronizer;
+import org.infobip.mobile.messaging.mobileapi.seen.SeenStatusReporter;
import org.infobip.mobile.messaging.stats.MobileMessagingStats;
import org.infobip.mobile.messaging.util.PreferenceHelper;
import org.junit.Test;
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/RetryableSynchronizerTest.java b/infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/RetryableSynchronizerTest.java
similarity index 94%
rename from infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/RetryableSynchronizerTest.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/RetryableSynchronizerTest.java
index f67d72c9..80bc1665 100644
--- a/infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/RetryableSynchronizerTest.java
+++ b/infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/RetryableSynchronizerTest.java
@@ -8,8 +8,8 @@
import org.infobip.mobile.messaging.api.support.ApiIOException;
import org.infobip.mobile.messaging.geo.report.GeoReporter;
import org.infobip.mobile.messaging.geo.tools.MobileMessagingTestCase;
-import org.infobip.mobile.messaging.mobile.MobileMessagingError;
-import org.infobip.mobile.messaging.mobile.common.exceptions.BackendCommunicationException;
+import org.infobip.mobile.messaging.mobileapi.MobileMessagingError;
+import org.infobip.mobile.messaging.mobileapi.common.exceptions.BackendCommunicationException;
import org.infobip.mobile.messaging.util.PreferenceHelper;
import org.junit.Test;
import org.mockito.Mockito;
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/storage/TestMessageStore.java b/infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/storage/TestMessageStore.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/storage/TestMessageStore.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/storage/TestMessageStore.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/tools/MobileMessagingTestCase.java b/infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/tools/MobileMessagingTestCase.java
similarity index 99%
rename from infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/tools/MobileMessagingTestCase.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/tools/MobileMessagingTestCase.java
index 568cfc8f..ffcb819f 100644
--- a/infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/tools/MobileMessagingTestCase.java
+++ b/infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/tools/MobileMessagingTestCase.java
@@ -25,7 +25,7 @@
import org.infobip.mobile.messaging.geo.report.GeoReport;
import org.infobip.mobile.messaging.geo.storage.TestMessageStore;
import org.infobip.mobile.messaging.logging.MobileMessagingLogger;
-import org.infobip.mobile.messaging.mobile.MobileApiResourceProvider;
+import org.infobip.mobile.messaging.mobileapi.MobileApiResourceProvider;
import org.infobip.mobile.messaging.notification.NotificationHandler;
import org.infobip.mobile.messaging.platform.Broadcaster;
import org.infobip.mobile.messaging.platform.Time;
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/tools/MobileMessagingTestable.java b/infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/tools/MobileMessagingTestable.java
similarity index 93%
rename from infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/tools/MobileMessagingTestable.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/tools/MobileMessagingTestable.java
index 2c3551f0..140ca5bc 100644
--- a/infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/tools/MobileMessagingTestable.java
+++ b/infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/org/infobip/mobile/messaging/geo/tools/MobileMessagingTestable.java
@@ -3,7 +3,7 @@
import android.content.Context;
import org.infobip.mobile.messaging.MobileMessagingCore;
-import org.infobip.mobile.messaging.mobile.MobileApiResourceProvider;
+import org.infobip.mobile.messaging.mobileapi.MobileApiResourceProvider;
import org.infobip.mobile.messaging.platform.Broadcaster;
import org.infobip.mobile.messaging.platform.Platform;
import org.infobip.mobile.messaging.util.ModuleLoader;
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/platform/AndroidGeoBroadcasterTest.java b/infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/platform/AndroidGeoBroadcasterTest.java
similarity index 98%
rename from infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/platform/AndroidGeoBroadcasterTest.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/platform/AndroidGeoBroadcasterTest.java
index c9388f83..80fe9143 100644
--- a/infobip-mobile-messaging-android-geo-sdk/src/androidTest/java/platform/AndroidGeoBroadcasterTest.java
+++ b/infobip-mobile-messaging-huawei-geo-sdk/src/androidTest/java/platform/AndroidGeoBroadcasterTest.java
@@ -13,7 +13,7 @@
import org.infobip.mobile.messaging.geo.platform.AndroidGeoBroadcaster;
import org.infobip.mobile.messaging.geo.report.GeoReport;
import org.infobip.mobile.messaging.geo.tools.MobileMessagingTestCase;
-import org.infobip.mobile.messaging.mobile.MobileMessagingError;
+import org.infobip.mobile.messaging.mobileapi.MobileMessagingError;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/AndroidManifest.xml b/infobip-mobile-messaging-huawei-geo-sdk/src/main/AndroidManifest.xml
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/AndroidManifest.xml
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/AndroidManifest.xml
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/Area.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/Area.java
similarity index 81%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/Area.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/Area.java
index e6d98651..314a576b 100644
--- a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/Area.java
+++ b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/Area.java
@@ -1,6 +1,6 @@
package org.infobip.mobile.messaging.geo;
-import com.google.android.gms.location.Geofence;
+import com.huawei.hms.location.Geofence;
import org.infobip.mobile.messaging.platform.Time;
@@ -53,14 +53,14 @@ public Geofence toGeofence(Date expiryDate) {
expirationDurationMillis = expiryDate.getTime() - Time.now();
}
if (expirationDurationMillis <= 0) {
- expirationDurationMillis = Geofence.NEVER_EXPIRE;
+ expirationDurationMillis = Geofence.GEOFENCE_NEVER_EXPIRE;
}
return new Geofence.Builder()
- .setCircularRegion(getLatitude(), getLongitude(), getRadius())
- .setRequestId(getId())
- .setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER)
- .setExpirationDuration(expirationDurationMillis)
+ .setRoundArea(getLatitude(), getLongitude(), getRadius())
+ .setUniqueId(getId())
+ .setConversions(Geofence.ENTER_GEOFENCE_CONVERSION)
+ .setValidContinueTime(expirationDurationMillis)
.build();
}
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/BootReceiver.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/BootReceiver.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/BootReceiver.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/BootReceiver.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/DeliveryTime.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/DeliveryTime.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/DeliveryTime.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/DeliveryTime.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/Geo.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/Geo.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/Geo.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/Geo.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoEnabledConsistencyReceiver.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoEnabledConsistencyReceiver.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoEnabledConsistencyReceiver.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoEnabledConsistencyReceiver.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoEvent.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoEvent.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoEvent.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoEvent.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoEventSettings.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoEventSettings.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoEventSettings.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoEventSettings.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoEventType.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoEventType.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoEventType.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoEventType.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoLatLng.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoLatLng.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoLatLng.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoLatLng.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoMessage.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoMessage.java
similarity index 90%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoMessage.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoMessage.java
index f6a4c977..23f1c7c9 100644
--- a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoMessage.java
+++ b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoMessage.java
@@ -17,7 +17,7 @@ public static GeoMessage createFrom(Message message, Geo geo) {
return new GeoMessage(message.getMessageId(), message.getTitle(), message.getBody(), message.getSound(), message.isVibrate(), message.getIcon(),
message.isSilent(), message.getCategory(), message.getFrom(), message.getReceivedTimestamp(), message.getSeenTimestamp(), message.getSentTimestamp(),
message.getCustomPayload(), message.getInternalData(), message.getDestination(), message.getStatus(), message.getStatusMessage(), message.getContentUrl(),
- geo, message.getInAppStyle(), message.getInAppExpiryTimestamp());
+ geo, message.getInAppStyle(), message.getInAppExpiryTimestamp(), message.getWebViewUrl(), message.getMessageType());
}
public static GeoMessage createFrom(Bundle bundle) {
@@ -28,14 +28,15 @@ static Message toMessage(GeoMessage geoMessage) {
return new Message(geoMessage.getMessageId(), geoMessage.getTitle(), geoMessage.getBody(), geoMessage.getSound(), geoMessage.isVibrate(), geoMessage.getIcon(),
geoMessage.isSilent(), geoMessage.getCategory(), geoMessage.getFrom(), geoMessage.getReceivedTimestamp(), geoMessage.getSeenTimestamp(), geoMessage.getSentTimestamp(),
geoMessage.getCustomPayload(), geoMessage.getInternalData(), geoMessage.getDestination(), geoMessage.getStatus(), geoMessage.getStatusMessage(), geoMessage.getContentUrl(),
- geoMessage.getInAppStyle(), geoMessage.getInAppExpiryTimestamp());
+ geoMessage.getInAppStyle(), geoMessage.getInAppExpiryTimestamp(), geoMessage.getWebViewUrl(), geoMessage.getMessageType());
}
private GeoMessage(String messageId, String title, String body, String sound, boolean vibrate, String icon, boolean silent, String category,
String from, long receivedTimestamp, long seenTimestamp, long sentTimestamp, JSONObject customPayload, String internalData,
- String destination, Status status, String statusMessage, String contentUrl, Geo geo, InAppStyle inAppStyle, long expiryTime) {
+ String destination, Status status, String statusMessage, String contentUrl, Geo geo, InAppStyle inAppStyle, long expiryTime,
+ String webViewUrl, String messageType) {
super(messageId, title, body, sound, vibrate, icon, silent, category, from, receivedTimestamp, seenTimestamp, seenTimestamp, customPayload,
- internalData, destination, status, statusMessage, contentUrl, inAppStyle, expiryTime);
+ internalData, destination, status, statusMessage, contentUrl, inAppStyle, expiryTime, webViewUrl, messageType);
this.geo = geo;
}
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoReportSynchronization.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoReportSynchronization.java
similarity index 90%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoReportSynchronization.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoReportSynchronization.java
index 23245067..71b97e33 100644
--- a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoReportSynchronization.java
+++ b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeoReportSynchronization.java
@@ -5,7 +5,7 @@
import org.infobip.mobile.messaging.MobileMessagingCore;
import org.infobip.mobile.messaging.geo.platform.AndroidGeoBroadcaster;
import org.infobip.mobile.messaging.geo.report.GeoReporter;
-import org.infobip.mobile.messaging.mobile.MobileApiResourceProvider;
+import org.infobip.mobile.messaging.mobileapi.MobileApiResourceProvider;
class GeoReportSynchronization {
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeofencingConsistencyIntentService.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeofencingConsistencyIntentService.java
similarity index 95%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeofencingConsistencyIntentService.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeofencingConsistencyIntentService.java
index 7611ed8a..85442711 100644
--- a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeofencingConsistencyIntentService.java
+++ b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeofencingConsistencyIntentService.java
@@ -5,7 +5,7 @@
import android.net.Uri;
import android.support.annotation.NonNull;
-import com.google.android.gms.common.GoogleApiAvailability;
+import com.huawei.hms.api.HuaweiApiAvailability;
import org.infobip.mobile.messaging.geo.geofencing.GeofencingHelper;
import org.infobip.mobile.messaging.logging.MobileMessagingLogger;
@@ -81,7 +81,8 @@ private void handleGeoConsistencyAction(Context context, Intent intent, String a
*/
case Intent.ACTION_PACKAGE_DATA_CLEARED:
final Uri data = intent.getData();
- if (data != null && GoogleApiAvailability.GOOGLE_PLAY_SERVICES_PACKAGE.equals(data.getSchemeSpecificPart())) {
+ // TODO: SERVICES_PACKAGE is deprecated
+ if (data != null && HuaweiApiAvailability.SERVICES_PACKAGE.equals(data.getSchemeSpecificPart())) {
startGeoMonitoringFromScratch(context);
}
break;
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeofencingConsistencyReceiver.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeofencingConsistencyReceiver.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeofencingConsistencyReceiver.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/GeofencingConsistencyReceiver.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/MobileGeo.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/MobileGeo.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/MobileGeo.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/MobileGeo.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/MobileGeoImpl.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/MobileGeoImpl.java
similarity index 98%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/MobileGeoImpl.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/MobileGeoImpl.java
index 09d09e94..f194d011 100644
--- a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/MobileGeoImpl.java
+++ b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/MobileGeoImpl.java
@@ -87,6 +87,11 @@ public void depersonalize() {
PreferenceHelper.remove(context, MobileMessagingGeoProperty.UNREPORTED_GEO_EVENTS.getKey());
}
+ @Override
+ public void performSyncActions() {
+ // do nothing
+ }
+
@Override
public void init(Context appContext) {
this.context = appContext;
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/MobileMessagingGeoProperty.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/MobileMessagingGeoProperty.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/MobileMessagingGeoProperty.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/MobileMessagingGeoProperty.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/geofencing/Geofencing.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/geofencing/Geofencing.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/geofencing/Geofencing.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/geofencing/Geofencing.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/geofencing/GeofencingHelper.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/geofencing/GeofencingHelper.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/geofencing/GeofencingHelper.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/geofencing/GeofencingHelper.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/geofencing/GeofencingImpl.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/geofencing/GeofencingImpl.java
similarity index 84%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/geofencing/GeofencingImpl.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/geofencing/GeofencingImpl.java
index b9e83167..447ed4d4 100644
--- a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/geofencing/GeofencingImpl.java
+++ b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/geofencing/GeofencingImpl.java
@@ -9,20 +9,18 @@
import android.content.pm.PackageManager;
import android.location.LocationManager;
import android.os.Build;
-import android.os.Bundle;
import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.support.v4.content.ContextCompat;
import android.util.Pair;
-import com.google.android.gms.common.ConnectionResult;
-import com.google.android.gms.common.api.GoogleApiClient;
-import com.google.android.gms.common.api.ResultCallback;
-import com.google.android.gms.common.api.Status;
-import com.google.android.gms.location.Geofence;
-import com.google.android.gms.location.GeofencingRequest;
-import com.google.android.gms.location.LocationServices;
+import com.huawei.hmf.tasks.OnCompleteListener;
+import com.huawei.hmf.tasks.Task;
+import com.huawei.hms.api.ConnectionResult;
+import com.huawei.hms.api.HuaweiApiClient;
+import com.huawei.hms.location.Geofence;
+import com.huawei.hms.location.GeofenceRequest;
+import com.huawei.hms.location.LocationServices;
import org.infobip.mobile.messaging.ConfigurationException;
import org.infobip.mobile.messaging.ConfigurationException.Reason;
@@ -50,7 +48,7 @@
import java.util.Map;
import java.util.Set;
-public class GeofencingImpl extends Geofencing implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
+public class GeofencingImpl extends Geofencing implements HuaweiApiClient.ConnectionCallbacks, HuaweiApiClient.OnConnectionFailedListener {
private static final String TAG = "GeofencingImpl";
@@ -58,12 +56,17 @@ public class GeofencingImpl extends Geofencing implements GoogleApiClient.Connec
private final Context context;
private static GeoEnabledConsistencyReceiver geoEnabledConsistencyReceiver;
private final GeofencingHelper geofencingHelper;
- private final GoogleApiClient googleApiClient;
+ private final HuaweiApiClient hmsClient;
private final MessageStore messageStore;
private List geofences;
private PendingIntent geofencePendingIntent;
private GoogleApiClientRequestType requestType;
+ @Override
+ public void onConnectionFailed(ConnectionResult connectionResult) {
+
+ }
+
private enum GoogleApiClientRequestType {
ADD_GEOFENCES,
REMOVE_GEOFENCES,
@@ -76,10 +79,11 @@ private GeofencingImpl(Context context) {
geofences = new ArrayList<>();
geofencingHelper = new GeofencingHelper(context);
messageStore = geofencingHelper.getMessageStoreForGeo();
- googleApiClient = new GoogleApiClient.Builder(context)
+ hmsClient = new HuaweiApiClient.Builder(context)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
- .addApi(LocationServices.API)
+ // FIXME: Find how to add. Or there is other way
+ // .addApi(LocationServices. .API)
.build();
}
@@ -266,18 +270,20 @@ public void startGeoMonitoring() {
}
requestType = GoogleApiClientRequestType.ADD_GEOFENCES;
- if (!googleApiClient.isConnected()) {
- googleApiClient.connect();
+ // FIXME: Find analog:
+/*
+ if (!hmsClient.isConnected()) {
+ hmsClient.connect();
return;
- }
+ }*/
- LocationServices.GeofencingApi.addGeofences(googleApiClient, geofencingRequest(), geofencePendingIntent())
- .setResultCallback(new ResultCallback() {
+ LocationServices.getGeofenceService(context).createGeofenceList(geofencingRequest(), geofencePendingIntent())
+ .addOnCompleteListener(new OnCompleteListener() {
@Override
- public void onResult(@NonNull Status status) {
- logGeofenceStatus(status, true);
+ public void onComplete(Task task) {
+ logGeofenceStatus(task, true);
+ GeofencingHelper.setAllActiveGeoAreasMonitored(context, task.isSuccessful());
requestType = GoogleApiClientRequestType.NONE;
- GeofencingHelper.setAllActiveGeoAreasMonitored(context, status.isSuccess());
}
});
}
@@ -292,16 +298,17 @@ public void stopGeoMonitoring() {
}
requestType = GoogleApiClientRequestType.REMOVE_GEOFENCES;
- if (!googleApiClient.isConnected()) {
- googleApiClient.connect();
+ // FIXME: Find analog:
+/* if (!hmsClient.isConnected()) {
+ hmsClient.connect(context);
return;
- }
+ }*/
- LocationServices.GeofencingApi.removeGeofences(googleApiClient, geofencePendingIntent())
- .setResultCallback(new ResultCallback() {
+ LocationServices.getGeofenceService(context).deleteGeofenceList(geofencePendingIntent())
+ .addOnCompleteListener(new OnCompleteListener() {
@Override
- public void onResult(@NonNull Status status) {
- logGeofenceStatus(status, false);
+ public void onComplete(Task task) {
+ logGeofenceStatus(task, false);
requestType = GoogleApiClientRequestType.NONE;
}
});
@@ -360,19 +367,19 @@ private boolean checkRequiredPermissions() {
return true;
}
- private void logGeofenceStatus(@NonNull Status status, boolean activated) {
- if (status.isSuccess()) {
+ private void logGeofenceStatus(@NonNull Task task, boolean activated) {
+ if (task.isSuccessful()) {
MobileMessagingLogger.d(TAG, "Geofencing monitoring " + (activated ? "" : "de-") + "activated successfully");
} else {
- MobileMessagingLogger.e(TAG, "Geofencing monitoring " + (activated ? "" : "de-") + "activation failed: " + status.toString());
+ MobileMessagingLogger.e(TAG, "Geofencing monitoring " + (activated ? "" : "de-") + "activation failed: " + task.getException());
}
}
- private GeofencingRequest geofencingRequest() {
- GeofencingRequest.Builder builder = new GeofencingRequest.Builder();
- builder.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER);
- builder.addGeofences(geofences);
+ private GeofenceRequest geofencingRequest() {
+ GeofenceRequest.Builder builder = new GeofenceRequest.Builder();
+ builder.setInitConversions(GeofenceRequest.ENTER_INIT_CONVERSION);
+ builder.createGeofenceList(geofences);
return builder.build();
}
@@ -386,8 +393,8 @@ private PendingIntent geofencePendingIntent() {
}
@Override
- public void onConnected(@Nullable Bundle bundle) {
- MobileMessagingLogger.d(TAG, "GoogleApiClient connected");
+ public void onConnected() {
+ MobileMessagingLogger.d(TAG, "HuaweiApiClient connected");
if (GoogleApiClientRequestType.ADD_GEOFENCES.equals(requestType)) {
startGeoMonitoring();
@@ -398,11 +405,7 @@ public void onConnected(@Nullable Bundle bundle) {
@Override
public void onConnectionSuspended(int i) {
-
- }
-
- @Override
- public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
- MobileMessagingLogger.e(TAG, connectionResult.getErrorMessage(), new ConfigurationException(Reason.CHECK_LOCATION_SETTINGS));
+ // TODO: Refactor, describe error codes
+ MobileMessagingLogger.e(TAG, "onConnectionSuspended, code: " + i, new ConfigurationException(Reason.CHECK_LOCATION_SETTINGS));
}
}
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/mapper/GeoBundleMapper.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/mapper/GeoBundleMapper.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/mapper/GeoBundleMapper.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/mapper/GeoBundleMapper.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/mapper/GeoDataMapper.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/mapper/GeoDataMapper.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/mapper/GeoDataMapper.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/mapper/GeoDataMapper.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/platform/AndroidGeoBroadcaster.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/platform/AndroidGeoBroadcaster.java
similarity index 97%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/platform/AndroidGeoBroadcaster.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/platform/AndroidGeoBroadcaster.java
index 3a34ebee..8dd370d4 100644
--- a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/platform/AndroidGeoBroadcaster.java
+++ b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/platform/AndroidGeoBroadcaster.java
@@ -12,7 +12,7 @@
import org.infobip.mobile.messaging.geo.GeoMessage;
import org.infobip.mobile.messaging.geo.mapper.GeoBundleMapper;
import org.infobip.mobile.messaging.geo.report.GeoReport;
-import org.infobip.mobile.messaging.mobile.MobileMessagingError;
+import org.infobip.mobile.messaging.mobileapi.MobileMessagingError;
import java.util.HashMap;
import java.util.List;
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/platform/GeoBroadcaster.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/platform/GeoBroadcaster.java
similarity index 92%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/platform/GeoBroadcaster.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/platform/GeoBroadcaster.java
index 80afe263..3bd9ba29 100644
--- a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/platform/GeoBroadcaster.java
+++ b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/platform/GeoBroadcaster.java
@@ -4,7 +4,7 @@
import org.infobip.mobile.messaging.geo.GeoEventType;
import org.infobip.mobile.messaging.geo.GeoMessage;
import org.infobip.mobile.messaging.geo.report.GeoReport;
-import org.infobip.mobile.messaging.mobile.MobileMessagingError;
+import org.infobip.mobile.messaging.mobileapi.MobileMessagingError;
import java.util.List;
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/push/PushMessageHandler.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/push/PushMessageHandler.java
similarity index 93%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/push/PushMessageHandler.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/push/PushMessageHandler.java
index 2a00f20e..4c0a89e4 100644
--- a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/push/PushMessageHandler.java
+++ b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/push/PushMessageHandler.java
@@ -6,7 +6,7 @@
import org.infobip.mobile.messaging.Message;
import org.infobip.mobile.messaging.logging.MobileMessagingLogger;
import org.infobip.mobile.messaging.geo.geofencing.GeofencingHelper;
-import org.infobip.mobile.messaging.mobile.InternalSdkError;
+import org.infobip.mobile.messaging.mobileapi.InternalSdkError;
import org.infobip.mobile.messaging.storage.MessageStore;
public class PushMessageHandler {
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/report/GeoReport.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/report/GeoReport.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/report/GeoReport.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/report/GeoReport.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/report/GeoReportHelper.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/report/GeoReportHelper.java
similarity index 98%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/report/GeoReportHelper.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/report/GeoReportHelper.java
index 7d98ab18..b8cd4d6a 100644
--- a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/report/GeoReportHelper.java
+++ b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/report/GeoReportHelper.java
@@ -200,7 +200,9 @@ private static Message createNewMessageForReport(@NonNull final GeoReport report
originalMessage.getStatusMessage(),
originalMessage.getContentUrl(),
originalMessage.getInAppStyle(),
- originalMessage.getInAppExpiryTimestamp()
+ originalMessage.getInAppExpiryTimestamp(),
+ originalMessage.getWebViewUrl(),
+ originalMessage.getMessageType()
);
}
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/report/GeoReporter.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/report/GeoReporter.java
similarity index 96%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/report/GeoReporter.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/report/GeoReporter.java
index c2eae8ef..02357b90 100644
--- a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/report/GeoReporter.java
+++ b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/report/GeoReporter.java
@@ -16,10 +16,10 @@
import org.infobip.mobile.messaging.geo.platform.GeoBroadcaster;
import org.infobip.mobile.messaging.geo.transition.GeoAreasHandler;
import org.infobip.mobile.messaging.logging.MobileMessagingLogger;
-import org.infobip.mobile.messaging.mobile.MobileMessagingError;
-import org.infobip.mobile.messaging.mobile.common.MRetryPolicy;
-import org.infobip.mobile.messaging.mobile.common.MRetryableTask;
-import org.infobip.mobile.messaging.mobile.common.RetryPolicyProvider;
+import org.infobip.mobile.messaging.mobileapi.MobileMessagingError;
+import org.infobip.mobile.messaging.mobileapi.common.MRetryPolicy;
+import org.infobip.mobile.messaging.mobileapi.common.MRetryableTask;
+import org.infobip.mobile.messaging.mobileapi.common.RetryPolicyProvider;
import org.infobip.mobile.messaging.platform.Time;
import org.infobip.mobile.messaging.stats.MobileMessagingStats;
import org.infobip.mobile.messaging.stats.MobileMessagingStatsError;
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/report/GeoReportingResult.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/report/GeoReportingResult.java
similarity index 94%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/report/GeoReportingResult.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/report/GeoReportingResult.java
index c69dc658..ef1aaa6c 100644
--- a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/report/GeoReportingResult.java
+++ b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/report/GeoReportingResult.java
@@ -2,7 +2,7 @@
import org.infobip.mobile.messaging.api.geo.EventReportResponse;
-import org.infobip.mobile.messaging.mobile.UnsuccessfulResult;
+import org.infobip.mobile.messaging.mobileapi.UnsuccessfulResult;
import java.util.Map;
import java.util.Set;
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/storage/GeoSQLiteMessageStore.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/storage/GeoSQLiteMessageStore.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/storage/GeoSQLiteMessageStore.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/storage/GeoSQLiteMessageStore.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/storage/SQLiteGeoMessage.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/storage/SQLiteGeoMessage.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/storage/SQLiteGeoMessage.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/storage/SQLiteGeoMessage.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeoAreasHandler.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeoAreasHandler.java
similarity index 99%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeoAreasHandler.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeoAreasHandler.java
index f8baeb56..095f7562 100644
--- a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeoAreasHandler.java
+++ b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeoAreasHandler.java
@@ -18,7 +18,7 @@
import org.infobip.mobile.messaging.geo.report.GeoReporter;
import org.infobip.mobile.messaging.geo.report.GeoReportingResult;
import org.infobip.mobile.messaging.logging.MobileMessagingLogger;
-import org.infobip.mobile.messaging.mobile.MobileApiResourceProvider;
+import org.infobip.mobile.messaging.mobileapi.MobileApiResourceProvider;
import org.infobip.mobile.messaging.platform.AndroidBroadcaster;
import org.infobip.mobile.messaging.storage.MessageStore;
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeoNotificationHelper.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeoNotificationHelper.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeoNotificationHelper.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeoNotificationHelper.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeoTransition.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeoTransition.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeoTransition.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeoTransition.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeoTransitionHelper.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeoTransitionHelper.java
similarity index 61%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeoTransitionHelper.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeoTransitionHelper.java
index a0d61aab..bec99fca 100644
--- a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeoTransitionHelper.java
+++ b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeoTransitionHelper.java
@@ -5,9 +5,10 @@
import android.support.v4.util.ArraySet;
import android.util.SparseArray;
-import com.google.android.gms.location.Geofence;
-import com.google.android.gms.location.GeofenceStatusCodes;
-import com.google.android.gms.location.GeofencingEvent;
+import com.huawei.hms.location.Geofence;
+import com.huawei.hms.location.GeofenceData;
+import com.huawei.hms.location.GeofenceErrorCodes;
+import com.huawei.hms.support.api.entity.location.fence.GeofenceEntity;
import org.infobip.mobile.messaging.geo.GeoEventType;
import org.infobip.mobile.messaging.geo.GeoLatLng;
@@ -28,7 +29,7 @@ static class GeofenceNotAvailableException extends RuntimeException {
* Supported geofence transition events
*/
private static final SparseArray supportedTransitionEvents = new SparseArray() {{
- put(Geofence.GEOFENCE_TRANSITION_ENTER, GeoEventType.entry);
+ put(Geofence.ENTER_GEOFENCE_CONVERSION, GeoEventType.entry);
}};
/**
@@ -39,29 +40,29 @@ static class GeofenceNotAvailableException extends RuntimeException {
* @throws RuntimeException if information cannot be resolved
*/
static GeoTransition resolveTransitionFromIntent(Intent intent) throws RuntimeException {
- GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);
- if (geofencingEvent == null) {
+ GeofenceData geofenceData = GeofenceData.getDataFromIntent(intent);
+ if (geofenceData == null) {
throw new RuntimeException("Geofencing event is null, cannot process");
}
- if (geofencingEvent.hasError()) {
- if (geofencingEvent.getErrorCode() == GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE) {
+ if (geofenceData.isFailure()) {
+ if (geofenceData.getErrorCode() == GeofenceErrorCodes.GEOFENCE_UNAVAILABLE) {
throw new GeofenceNotAvailableException();
}
- throw new RuntimeException("ERROR: " + GeofenceStatusCodes.getStatusCodeString(geofencingEvent.getErrorCode()));
+ throw new RuntimeException("ERROR: " + GeofenceErrorCodes.getStatusCodeString(geofenceData.getErrorCode()));
}
- GeoEventType event = supportedTransitionEvents.get(geofencingEvent.getGeofenceTransition());
+ GeoEventType event = supportedTransitionEvents.get(geofenceData.getConversion()); // TODO: Double-check is it same as getGeofenceTransition
if (event == null) {
- throw new RuntimeException("Transition is not supported: " + geofencingEvent.getGeofenceTransition());
+ throw new RuntimeException("Transition is not supported: " + geofenceData.getConversion());
}
Set triggeringRequestIds = new ArraySet<>();
- for (Geofence geofence : geofencingEvent.getTriggeringGeofences()) {
- triggeringRequestIds.add(geofence.getRequestId());
+ for (Geofence geofence : geofenceData.getConvertingGeofenceList()) {
+ triggeringRequestIds.add(geofence.getUniqueId());
}
- Location location = geofencingEvent.getTriggeringLocation();
+ Location location = geofenceData.getConvertingLocation();
return new GeoTransition(event, triggeringRequestIds, new GeoLatLng(location.getLatitude(), location.getLongitude()));
}
}
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeofenceTransitionsIntentService.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeofenceTransitionsIntentService.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeofenceTransitionsIntentService.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeofenceTransitionsIntentService.java
diff --git a/infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeofenceTransitionsReceiver.java b/infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeofenceTransitionsReceiver.java
similarity index 100%
rename from infobip-mobile-messaging-android-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeofenceTransitionsReceiver.java
rename to infobip-mobile-messaging-huawei-geo-sdk/src/main/java/org/infobip/mobile/messaging/geo/transition/GeofenceTransitionsReceiver.java
diff --git a/infobip-mobile-messaging-android-sdk/.gitignore b/infobip-mobile-messaging-huawei-sdk/.gitignore
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/.gitignore
rename to infobip-mobile-messaging-huawei-sdk/.gitignore
diff --git a/infobip-mobile-messaging-android-sdk/build.gradle b/infobip-mobile-messaging-huawei-sdk/build.gradle
similarity index 83%
rename from infobip-mobile-messaging-android-sdk/build.gradle
rename to infobip-mobile-messaging-huawei-sdk/build.gradle
index 80ffd2f2..cc94cbe3 100644
--- a/infobip-mobile-messaging-android-sdk/build.gradle
+++ b/infobip-mobile-messaging-huawei-sdk/build.gradle
@@ -1,19 +1,19 @@
buildscript {
repositories {
jcenter()
- maven {
- url 'https://maven.google.com/'
- name 'Google'
- }
+ google()
+ maven { url 'http://developer.huawei.com/repo/' }
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.5.3'
+ classpath 'com.android.tools.build:gradle:3.6.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
+ classpath 'com.huawei.agconnect:agcp:1.2.1.301'
}
}
apply plugin: 'com.android.library'
+apply plugin: 'com.huawei.agconnect'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'idea'
apply plugin: 'com.jfrog.bintray'
@@ -42,14 +42,15 @@ android {
}
dependencies {
- api project(":infobip-mobile-messaging-api-java")
- api project(":infobip-mobile-messaging-android-resources")
- api "com.google.firebase:firebase-messaging:${mm_firebaseMessagingVersion}"
- api "com.google.android.gms:play-services-location:${mm_gmsLocationVersion}"
+ api 'org.infobip.mobile.messaging.api:infobip-mobile-messaging-api-java:3.0.4'
+ api 'org.infobip.mobile.messaging.api:infobip-mobile-messaging-android-resources:3.0.4@aar'
api "com.android.support:support-v4:${mm_supportLibrariesVersion}"
api "com.android.support:appcompat-v7:${mm_supportLibrariesVersion}"
- androidTestImplementation project(":infobip-mobile-messaging-android-test")
+ // push kit
+ implementation 'com.huawei.hms:push:4.0.2.300'
+
+ androidTestImplementation project(':infobip-mobile-messaging-huawei-test')
androidTestImplementation "com.android.support.test:runner:1.0.2"
androidTestImplementation "junit:junit:4.12"
androidTestImplementation "org.mockito:mockito-core:1.10.19"
@@ -58,7 +59,7 @@ dependencies {
exclude group: "org.json", module: "json"
}
- testImplementation project(":infobip-mobile-messaging-android-test")
+ testImplementation project(':infobip-mobile-messaging-huawei-test')
testImplementation "junit:junit:4.12"
}
@@ -104,7 +105,7 @@ bintray {
repo = 'maven'
name = project.name
userOrg = 'infobip'
- vcsUrl = "https://github.com/infobip/mobile-messaging-sdk-android"
+ vcsUrl = "https://github.com/infobip/mobile-messaging-sdk-huawei"
licenses = ['Apache-2.0']
labels = ['aar', 'android']
}
@@ -131,21 +132,18 @@ artifacts {
archives sourcesJar
}
-// Remove this when Gradle bug is fixed.
-// https://github.com/gradle/gradle/issues/3170
task modifyPomBeforeUpload {
doLast {
def pom = "${project.buildDir}/poms/pom-default.xml"
if (!file(pom).exists()) { install }
def project = new XmlParser().parse(pom)
- project.dependencies
- .dependency
- .find { dependency -> dependency.artifactId[0].text() == 'infobip-mobile-messaging-android-resources' }
- .appendNode('type', 'aar')
//noinspection UnnecessaryQualifiedReference
groovy.xml.XmlUtil.serialize(project, new FileWriter(pom))
}
}
+
+// Remove this when Gradle bug is fixed.
+// https://github.com/gradle/gradle/issues/3170
modifyPomBeforeUpload.dependsOn(install)
artifactoryPublish.dependsOn(modifyPomBeforeUpload)
bintrayUpload.dependsOn(modifyPomBeforeUpload)
\ No newline at end of file
diff --git a/infobip-mobile-messaging-android-sdk/proguard-rules.pro b/infobip-mobile-messaging-huawei-sdk/proguard-rules.pro
similarity index 88%
rename from infobip-mobile-messaging-android-sdk/proguard-rules.pro
rename to infobip-mobile-messaging-huawei-sdk/proguard-rules.pro
index 7a62b2f5..977b46d5 100644
--- a/infobip-mobile-messaging-android-sdk/proguard-rules.pro
+++ b/infobip-mobile-messaging-huawei-sdk/proguard-rules.pro
@@ -53,7 +53,7 @@
public static **[] values();
public static ** valueOf(java.lang.String);
}
--keep public enum org.infobip.mobile.messaging.** { *; }
+-keep public enum org.infobip.mobile.messaging.* { *; }
# Explicitly preserve all serialization members. The Serializable interface
# is only a marker interface, so it wouldn't save them.
@@ -74,7 +74,7 @@
-dontwarn lombok.NonNull
# Mobile Messaging API classes
--keep class org.infobip.mobile.messaging.api.** { *; }
+-keep class org.infobip.mobile.messaging.api.* { *; }
# Fix for JobIntentService
-keep class org.infobip.mobile.messaging.platform.JobIntentService$* { *; }
@@ -82,12 +82,12 @@
# GSON-related
# Gson specific classes
--keep class sun.misc.Unsafe { *; }
--dontwarn sun.misc.Unsafe
+-keep class sun.misc.Unsafe.* { *; }
+#-dontwarn sun.misc.Unsafe
#-keep class com.google.gson.stream.** { *; }
# Application classes that will be serialized/deserialized over Gson
--keep class org.infobip.mobile.messaging.dal.json.** { *; }
+-keep class org.infobip.mobile.messaging.dal.json.* { *; }
-keep class org.infobip.mobile.messaging.Installation { *; }
-keep class org.infobip.mobile.messaging.Message { *; }
-keep class org.infobip.mobile.messaging.User { *; }
@@ -95,9 +95,9 @@
-keep class org.infobip.mobile.messaging.interactive.NotificationAction { *; }
-keep class org.infobip.mobile.messaging.interactive.NotificationAction$* { *; }
-keep class org.infobip.mobile.messaging.interactive.NotificationCategory { *; }
--keep class org.infobip.mobile.messaging.cloud.firebase.FirebaseMessageMapper { *; }
--keep class org.infobip.mobile.messaging.cloud.firebase.FirebaseMessageMapper$* { *; }
--keep class org.infobip.mobile.messaging.mobile.** { *; }
+-keep class org.infobip.mobile.messaging.cloud.hms.HmsMessageMapper { *; }
+-keep class org.infobip.mobile.messaging.cloud.hms.HmsMessageMapper$* { *; }
+-keep class org.infobip.mobile.messaging.mobile.* { *; }
# Prevent proguard from stripping interface information from TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/AndroidManifest.xml b/infobip-mobile-messaging-huawei-sdk/src/androidTest/AndroidManifest.xml
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/AndroidManifest.xml
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/AndroidManifest.xml
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/CallbackActivityStarterWrapperTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/ActivityStarterWrapperTest.java
similarity index 83%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/CallbackActivityStarterWrapperTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/ActivityStarterWrapperTest.java
index 4c5bec82..8fdec3bf 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/CallbackActivityStarterWrapperTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/ActivityStarterWrapperTest.java
@@ -4,7 +4,7 @@
import android.app.Activity;
import android.content.Intent;
-import org.infobip.mobile.messaging.app.CallbackActivityStarterWrapper;
+import org.infobip.mobile.messaging.app.ActivityStarterWrapper;
import org.infobip.mobile.messaging.tools.MobileMessagingTestCase;
import org.infobip.mobile.messaging.util.PreferenceHelper;
import org.junit.Test;
@@ -15,10 +15,10 @@
import static junit.framework.Assert.assertNotNull;
import static org.mockito.Mockito.mock;
-public class CallbackActivityStarterWrapperTest extends MobileMessagingTestCase {
+public class ActivityStarterWrapperTest extends MobileMessagingTestCase {
private ArgumentCaptor intentArgumentCaptor;
- private CallbackActivityStarterWrapper callbackActivityStarterWrapper;
+ private ActivityStarterWrapper activityStarterWrapper;
private NotificationSettings notificationSettings;
private int givenFlags = Intent.FLAG_ACTIVITY_NO_HISTORY;
@@ -29,7 +29,7 @@ public void setUp() throws Exception {
MobileMessagingCore mobileMessagingCore = mock(MobileMessagingCore.class);
notificationSettings = new NotificationSettings(contextMock);
intentArgumentCaptor = ArgumentCaptor.forClass(Intent.class);
- callbackActivityStarterWrapper = new CallbackActivityStarterWrapper(contextMock, mobileMessagingCore);
+ activityStarterWrapper = new ActivityStarterWrapper(contextMock, mobileMessagingCore);
PreferenceHelper.saveInt(context, MobileMessagingProperty.INTENT_FLAGS, givenFlags);
PreferenceHelper.saveClass(contextMock, MobileMessagingProperty.CALLBACK_ACTIVITY, Activity.class);
@@ -43,7 +43,7 @@ public void testShouldStartActivityWithActionCalled() throws Exception {
Intent givenIntent = new Intent();
// When
- callbackActivityStarterWrapper.startActivity(givenIntent);
+ activityStarterWrapper.startCallbackActivity(givenIntent);
// Then
Mockito.verify(contextMock, Mockito.times(1)).startActivity(intentArgumentCaptor.capture());
@@ -63,7 +63,7 @@ public void testShouldNotStartActivityIfCallbackActivityDoesNotExist() throws Ex
Intent givenIntent = new Intent();
// When
- callbackActivityStarterWrapper.startActivity(givenIntent);
+ activityStarterWrapper.startCallbackActivity(givenIntent);
// Then
Mockito.verify(contextMock, Mockito.never()).startActivity(givenIntent);
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/ApplicationCodeProviderTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/ApplicationCodeProviderTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/ApplicationCodeProviderTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/ApplicationCodeProviderTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/BatchReporterTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/BatchReporterTest.java
similarity index 95%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/BatchReporterTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/BatchReporterTest.java
index f507fd80..d93c69c3 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/BatchReporterTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/BatchReporterTest.java
@@ -1,6 +1,6 @@
package org.infobip.mobile.messaging;
-import org.infobip.mobile.messaging.mobile.BatchReporter;
+import org.infobip.mobile.messaging.mobileapi.BatchReporter;
import org.infobip.mobile.messaging.tools.MobileMessagingTestCase;
import org.junit.Test;
import org.mockito.Mockito;
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/CustomAttributeTypeTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/CustomAttributeTypeTest.java
similarity index 89%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/CustomAttributeTypeTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/CustomAttributeTypeTest.java
index 990cf428..ca9b143f 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/CustomAttributeTypeTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/CustomAttributeTypeTest.java
@@ -48,7 +48,7 @@ public void test_save_user_custom_attributes() {
User userResponse = userCaptor.getValue();
assertEquals(SOME_STRING_VALUE, userResponse.getCustomAttributeValue(KEY_FOR_STRING).stringValue());
assertEquals(SOME_NUMBER_VALUE, userResponse.getCustomAttributeValue(KEY_FOR_NUMBER).numberValue().intValue());
- assertEquals(DateTimeUtil.DateToYMDString(SOME_DATE_VALUE), DateTimeUtil.DateToYMDString(userResponse.getCustomAttributeValue(KEY_FOR_DATE).dateValue()));
+ assertEquals(DateTimeUtil.dateToYMDString(SOME_DATE_VALUE), DateTimeUtil.dateToYMDString(userResponse.getCustomAttributeValue(KEY_FOR_DATE).dateValue()));
assertEquals(CustomAttributeValue.Type.String, userResponse.getCustomAttributeValue(KEY_FOR_STRING).getType());
assertEquals(CustomAttributeValue.Type.Number, userResponse.getCustomAttributeValue(KEY_FOR_NUMBER).getType());
assertEquals(CustomAttributeValue.Type.Date, userResponse.getCustomAttributeValue(KEY_FOR_DATE).getType());
@@ -66,7 +66,7 @@ public void test_save_installation_custom_attributes() {
Installation installationResponse = installationCaptor.getValue();
assertEquals(SOME_STRING_VALUE, installationResponse.getCustomAttributeValue(KEY_FOR_STRING).stringValue());
assertEquals(SOME_NUMBER_VALUE, installationResponse.getCustomAttributeValue(KEY_FOR_NUMBER).numberValue().intValue());
- assertEquals(DateTimeUtil.DateToYMDString(SOME_DATE_VALUE), DateTimeUtil.DateToYMDString(installationResponse.getCustomAttributeValue(KEY_FOR_DATE).dateValue()));
+ assertEquals(DateTimeUtil.dateToYMDString(SOME_DATE_VALUE), DateTimeUtil.dateToYMDString(installationResponse.getCustomAttributeValue(KEY_FOR_DATE).dateValue()));
assertEquals(CustomAttributeValue.Type.String, installationResponse.getCustomAttributeValue(KEY_FOR_STRING).getType());
assertEquals(CustomAttributeValue.Type.Number, installationResponse.getCustomAttributeValue(KEY_FOR_NUMBER).getType());
assertEquals(CustomAttributeValue.Type.Date, installationResponse.getCustomAttributeValue(KEY_FOR_DATE).getType());
@@ -78,7 +78,7 @@ public void test_get_custom_attributes_value_from_json_string() {
Map customAtts = new HashMap<>();
customAtts.put(KEY_FOR_STRING, SOME_STRING_VALUE);
- customAtts.put(KEY_FOR_DATE, DateTimeUtil.DateToYMDString(SOME_DATE_VALUE));
+ customAtts.put(KEY_FOR_DATE, DateTimeUtil.dateToYMDString(SOME_DATE_VALUE));
customAtts.put(KEY_FOR_NUMBER, SOME_NUMBER_VALUE);
serverResponse.setCustomAttributes(customAtts);
@@ -89,7 +89,7 @@ public void test_get_custom_attributes_value_from_json_string() {
assertEquals(SOME_STRING_VALUE, keyForString);
assertEquals(SOME_NUMBER_VALUE, keyForNumber.intValue());
- assertEquals(DateTimeUtil.DateToYMDString(SOME_DATE_VALUE), DateTimeUtil.DateToYMDString(keyForDate));
+ assertEquals(DateTimeUtil.dateToYMDString(SOME_DATE_VALUE), DateTimeUtil.dateToYMDString(keyForDate));
Map customUserData = user.getCustomAttributes();
assertEquals(3, customUserData.size());
@@ -101,18 +101,18 @@ public void test_get_custom_installation_data_value_from_json_string() {
Map customAtts = new HashMap<>();
customAtts.put(KEY_FOR_STRING, SOME_STRING_VALUE);
- customAtts.put(KEY_FOR_DATE, DateTimeUtil.DateToYMDString(SOME_DATE_VALUE));
+ customAtts.put(KEY_FOR_DATE, DateTimeUtil.dateToYMDString(SOME_DATE_VALUE));
customAtts.put(KEY_FOR_NUMBER, SOME_NUMBER_VALUE);
serverResponse.setCustomAttributes(customAtts);
- Map customAttsFromBackend = UserMapper.customAttsFromBackend(serverResponse.getCustomAttributes());
+ Map customAttsFromBackend = CustomAttributesMapper.customAttsFromBackend(serverResponse.getCustomAttributes());
String keyForString = customAttsFromBackend.get(KEY_FOR_STRING).stringValue();
Number keyForNumber = customAttsFromBackend.get(KEY_FOR_NUMBER).numberValue();
Date keyForDate = customAttsFromBackend.get(KEY_FOR_DATE).dateValue();
assertEquals(SOME_STRING_VALUE, keyForString);
assertEquals(SOME_NUMBER_VALUE, keyForNumber.intValue());
- assertEquals(DateTimeUtil.DateToYMDString(SOME_DATE_VALUE), DateTimeUtil.DateToYMDString(keyForDate));
+ assertEquals(DateTimeUtil.dateToYMDString(SOME_DATE_VALUE), DateTimeUtil.dateToYMDString(keyForDate));
assertEquals(3, customAttsFromBackend.size());
}
@@ -134,7 +134,7 @@ public void test_set_multi_custom_attributes_user() throws ParseException {
assertEquals(SOME_STRING_VALUE, keyForString);
assertEquals(SOME_NUMBER_VALUE, keyForNumber.intValue());
- assertEquals(DateTimeUtil.DateToYMDString(date), DateTimeUtil.DateToYMDString(keyForDate));
+ assertEquals(DateTimeUtil.dateToYMDString(date), DateTimeUtil.dateToYMDString(keyForDate));
Map customUserAtts = user.getCustomAttributes();
assertEquals(3, customUserAtts.size());
@@ -157,7 +157,7 @@ public void test_set_multi_custom_attributes_installation() throws ParseExceptio
assertEquals(SOME_STRING_VALUE, keyForString);
assertEquals(SOME_NUMBER_VALUE, keyForNumber.intValue());
- assertEquals(DateTimeUtil.DateToYMDString(date), DateTimeUtil.DateToYMDString(keyForDate));
+ assertEquals(DateTimeUtil.dateToYMDString(date), DateTimeUtil.dateToYMDString(keyForDate));
Map customInstallationAtts = installation.getCustomAttributes();
assertEquals(3, customInstallationAtts.size());
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/MessageHandlerModuleTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/MessageHandlerModuleTest.java
similarity index 95%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/MessageHandlerModuleTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/MessageHandlerModuleTest.java
index bfc0360d..7009d688 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/MessageHandlerModuleTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/MessageHandlerModuleTest.java
@@ -36,6 +36,11 @@ public void init(Context appContext) {}
public void applicationInForeground() {}
public void cleanup() {}
public void depersonalize() {}
+
+ @Override
+ public void performSyncActions() {
+
+ }
}
// When
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/MobileMessagingConnectivityReceiverTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/MobileMessagingConnectivityReceiverTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/MobileMessagingConnectivityReceiverTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/MobileMessagingConnectivityReceiverTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/MobileMessagingTestable.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/MobileMessagingTestable.java
similarity index 93%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/MobileMessagingTestable.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/MobileMessagingTestable.java
index 0533d9d4..f614f3bf 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/MobileMessagingTestable.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/MobileMessagingTestable.java
@@ -2,7 +2,7 @@
import android.content.Context;
-import org.infobip.mobile.messaging.mobile.MobileApiResourceProvider;
+import org.infobip.mobile.messaging.mobileapi.MobileApiResourceProvider;
import org.infobip.mobile.messaging.platform.Broadcaster;
import org.infobip.mobile.messaging.platform.Platform;
import org.infobip.mobile.messaging.util.ModuleLoader;
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/MockMessageHandlerModule.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/MockMessageHandlerModule.java
similarity index 91%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/MockMessageHandlerModule.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/MockMessageHandlerModule.java
index fe0a37e0..6e526429 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/MockMessageHandlerModule.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/MockMessageHandlerModule.java
@@ -38,4 +38,9 @@ public void cleanup() {
public void depersonalize() {
}
+
+ @Override
+ public void performSyncActions() {
+
+ }
}
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/PersonalizeSynchronizerTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/PersonalizeSynchronizerTest.java
similarity index 99%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/PersonalizeSynchronizerTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/PersonalizeSynchronizerTest.java
index f44bd8b4..5e563522 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/PersonalizeSynchronizerTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/PersonalizeSynchronizerTest.java
@@ -8,8 +8,8 @@
import org.infobip.mobile.messaging.api.support.ApiIOException;
import org.infobip.mobile.messaging.api.support.http.serialization.JsonSerializer;
import org.infobip.mobile.messaging.api.support.util.CollectionUtils;
-import org.infobip.mobile.messaging.mobile.MobileMessagingError;
-import org.infobip.mobile.messaging.mobile.Result;
+import org.infobip.mobile.messaging.mobileapi.MobileMessagingError;
+import org.infobip.mobile.messaging.mobileapi.Result;
import org.infobip.mobile.messaging.tools.MobileMessagingTestCase;
import org.infobip.mobile.messaging.util.PreferenceHelper;
import org.junit.Test;
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/RetryableSynchronizersTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/RetryableSynchronizersTest.java
similarity index 92%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/RetryableSynchronizersTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/RetryableSynchronizersTest.java
index 1923151e..6941333e 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/RetryableSynchronizersTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/RetryableSynchronizersTest.java
@@ -6,13 +6,13 @@
import org.infobip.mobile.messaging.api.messages.SyncMessagesBody;
import org.infobip.mobile.messaging.api.support.ApiIOException;
import org.infobip.mobile.messaging.cloud.MobileMessageHandler;
-import org.infobip.mobile.messaging.mobile.MobileMessagingError;
-import org.infobip.mobile.messaging.mobile.appinstance.InstallationSynchronizer;
-import org.infobip.mobile.messaging.mobile.common.MRetryPolicy;
-import org.infobip.mobile.messaging.mobile.common.RetryPolicyProvider;
-import org.infobip.mobile.messaging.mobile.common.exceptions.BackendCommunicationException;
-import org.infobip.mobile.messaging.mobile.messages.MessagesSynchronizer;
-import org.infobip.mobile.messaging.mobile.user.UserDataReporter;
+import org.infobip.mobile.messaging.mobileapi.MobileMessagingError;
+import org.infobip.mobile.messaging.mobileapi.appinstance.InstallationSynchronizer;
+import org.infobip.mobile.messaging.mobileapi.common.MRetryPolicy;
+import org.infobip.mobile.messaging.mobileapi.common.RetryPolicyProvider;
+import org.infobip.mobile.messaging.mobileapi.common.exceptions.BackendCommunicationException;
+import org.infobip.mobile.messaging.mobileapi.messages.MessagesSynchronizer;
+import org.infobip.mobile.messaging.mobileapi.user.UserDataReporter;
import org.infobip.mobile.messaging.stats.MobileMessagingStats;
import org.infobip.mobile.messaging.tools.MobileMessagingTestCase;
import org.infobip.mobile.messaging.util.DeviceInformation;
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/SeenStatusReporterTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/SeenStatusReporterTest.java
similarity index 92%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/SeenStatusReporterTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/SeenStatusReporterTest.java
index 98de6629..1b750519 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/SeenStatusReporterTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/SeenStatusReporterTest.java
@@ -1,8 +1,8 @@
package org.infobip.mobile.messaging;
import org.infobip.mobile.messaging.api.messages.MobileApiMessages;
-import org.infobip.mobile.messaging.mobile.BatchReporter;
-import org.infobip.mobile.messaging.mobile.seen.SeenStatusReporter;
+import org.infobip.mobile.messaging.mobileapi.BatchReporter;
+import org.infobip.mobile.messaging.mobileapi.seen.SeenStatusReporter;
import org.infobip.mobile.messaging.stats.MobileMessagingStats;
import org.infobip.mobile.messaging.tools.MobileMessagingTestCase;
import org.junit.Test;
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/SeenStatusStorageTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/SeenStatusStorageTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/SeenStatusStorageTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/SeenStatusStorageTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/SystemDataReportTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/SystemDataReportTest.java
similarity index 98%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/SystemDataReportTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/SystemDataReportTest.java
index 86e7c161..988a2959 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/SystemDataReportTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/SystemDataReportTest.java
@@ -1,7 +1,7 @@
package org.infobip.mobile.messaging;
import org.infobip.mobile.messaging.api.appinstance.AppInstance;
-import org.infobip.mobile.messaging.mobile.MobileMessagingError;
+import org.infobip.mobile.messaging.mobileapi.MobileMessagingError;
import org.infobip.mobile.messaging.tools.MobileMessagingTestCase;
import org.infobip.mobile.messaging.util.PreferenceHelper;
import org.junit.Test;
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/UserStoreTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/UserStoreTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/UserStoreTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/UserStoreTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/UserSyncTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/UserSyncTest.java
similarity index 98%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/UserSyncTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/UserSyncTest.java
index d5ce5d94..138e8a50 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/UserSyncTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/UserSyncTest.java
@@ -3,7 +3,7 @@
import org.infobip.mobile.messaging.api.appinstance.UserAtts;
import org.infobip.mobile.messaging.api.appinstance.UserBody;
import org.infobip.mobile.messaging.api.support.util.CollectionUtils;
-import org.infobip.mobile.messaging.mobile.Result;
+import org.infobip.mobile.messaging.mobileapi.Result;
import org.infobip.mobile.messaging.tools.MobileMessagingTestCase;
import org.infobip.mobile.messaging.util.DateTimeUtil;
import org.junit.Test;
@@ -120,7 +120,7 @@ public void test_add_custom_element() throws Exception {
HashMap customAtts = new HashMap<>();
customAtts.put("myKey1", "Some string");
customAtts.put("myKey2", 12345);
- customAtts.put("myKey3", DateTimeUtil.DateToYMDString(new Date()));
+ customAtts.put("myKey3", DateTimeUtil.dateToYMDString(new Date()));
customAtts.put("myKey4", false);
HashMap report = new HashMap<>();
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/cloud/MobileMessageHandlerTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/cloud/MobileMessageHandlerTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/cloud/MobileMessageHandlerTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/cloud/MobileMessageHandlerTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/cloud/MobileMessagingCloudHandlerTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/cloud/MobileMessagingCloudHandlerTest.java
similarity index 92%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/cloud/MobileMessagingCloudHandlerTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/cloud/MobileMessagingCloudHandlerTest.java
index ad7a1772..fceda92a 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/cloud/MobileMessagingCloudHandlerTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/cloud/MobileMessagingCloudHandlerTest.java
@@ -65,7 +65,7 @@ public void test_shouldHandleTokenCleanup() {
handler.handleWork(context, intent);
- Mockito.verify(registrationTokenHandler, Mockito.times(1)).cleanupToken(Mockito.eq("senderId"));
+ Mockito.verify(registrationTokenHandler, Mockito.times(1)).cleanupToken(Mockito.eq("senderId"), Mockito.any(Context.class));
}
@Test
@@ -75,8 +75,8 @@ public void test_shouldHandleTokenReset() {
handler.handleWork(context, intent);
- Mockito.verify(registrationTokenHandler, Mockito.times(1)).cleanupToken(Mockito.eq("senderId"));
- Mockito.verify(registrationTokenHandler, Mockito.times(1)).acquireNewToken(Mockito.eq("senderId"));
+ Mockito.verify(registrationTokenHandler, Mockito.times(1)).cleanupToken(Mockito.eq("senderId"), Mockito.any(Context.class));
+ Mockito.verify(registrationTokenHandler, Mockito.times(1)).acquireNewToken(Mockito.eq("senderId"), Mockito.any(Context.class));
}
@Test
@@ -86,6 +86,6 @@ public void test_shouldHandleTokenAcquisition() {
handler.handleWork(context, intent);
- Mockito.verify(registrationTokenHandler, Mockito.times(1)).acquireNewToken(Mockito.eq("senderId"));
+ Mockito.verify(registrationTokenHandler, Mockito.times(1)).acquireNewToken(Mockito.eq("senderId"), Mockito.any(Context.class));
}
}
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/cloud/MobileMessagingCloudServiceTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/cloud/MobileMessagingCloudServiceTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/cloud/MobileMessagingCloudServiceTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/cloud/MobileMessagingCloudServiceTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/cloud/firebase/FirebaseMessageMapperTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/cloud/hms/HmsMessageMapperTest.java
similarity index 81%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/cloud/firebase/FirebaseMessageMapperTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/cloud/hms/HmsMessageMapperTest.java
index 1848dc99..b293f56f 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/cloud/firebase/FirebaseMessageMapperTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/cloud/hms/HmsMessageMapperTest.java
@@ -1,8 +1,8 @@
-package org.infobip.mobile.messaging.cloud.firebase;
+package org.infobip.mobile.messaging.cloud.hms;
import android.os.Bundle;
-import com.google.firebase.messaging.RemoteMessage;
+import com.huawei.hms.push.RemoteMessage;
import junit.framework.TestCase;
@@ -14,11 +14,11 @@
* @author sslavin
* @since 05/09/2018.
*/
-public class FirebaseMessageMapperTest extends TestCase {
+public class HmsMessageMapperTest extends TestCase {
public void test_shouldMapRemoteMessage() throws JSONException {
- final String ibData = dqjson("{" +
+ final String ibData = dqjson("{'org_ib_d':{" +
"'messageId':'messageId'," +
"'text':'text'," +
"'notification': {" +
@@ -40,15 +40,16 @@ public void test_shouldMapRemoteMessage() throws JSONException {
" 'sendDateTime':123," +
" 'key': 'value'" +
"}" +
- "}");
+ "}}");
// workaround start (RemoteMessage is final, cannot mock)
Bundle bundle = new Bundle();
- bundle.putString("org_ib_d", ibData);
+ bundle.putByteArray("message_body", ibData.getBytes());
+ bundle.putInt("inputType", 1);
RemoteMessage remoteMessage = new RemoteMessage(bundle);
// workaround end
- Message message = new FirebaseMessageMapper().createMessage(remoteMessage);
+ Message message = new HmsMessageMapper().createMessage(remoteMessage);
assertEquals("messageId", message.getMessageId());
assertEquals("text", message.getBody());
@@ -69,21 +70,22 @@ public void test_shouldMapRemoteMessage() throws JSONException {
public void test_shouldMapInAppStyleStringInRemoteMessage() {
- final String ibData = dqjson("{" +
+ final String ibData = dqjson("{'org_ib_d':{" +
"'messageId':'messageId'," +
"'text':'text'," +
"'notification': {" +
" 'inAppStyle':'BANNER'" +
"}" +
- "}");
+ "}}");
// workaround start (RemoteMessage is final, cannot mock)
Bundle bundle = new Bundle();
- bundle.putString("org_ib_d", ibData);
+ bundle.putByteArray("message_body", ibData.getBytes());
+ bundle.putInt("inputType", 1);
RemoteMessage remoteMessage = new RemoteMessage(bundle);
// workaround end
- Message message = new FirebaseMessageMapper().createMessage(remoteMessage);
+ Message message = new HmsMessageMapper().createMessage(remoteMessage);
assertEquals("messageId", message.getMessageId());
assertEquals("text", message.getBody());
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/bundle/BundleMapperTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/bundle/BundleMapperTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/bundle/BundleMapperTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/bundle/BundleMapperTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/bundle/MessageBundleMapperTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/bundle/MessageBundleMapperTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/bundle/MessageBundleMapperTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/bundle/MessageBundleMapperTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/sqlite/DatabaseHelperTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/sqlite/DatabaseHelperTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/sqlite/DatabaseHelperTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/sqlite/DatabaseHelperTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/sqlite/SharedPreferencesMigrationTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/sqlite/SharedPreferencesMigrationTest.java
similarity index 64%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/sqlite/SharedPreferencesMigrationTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/sqlite/SharedPreferencesMigrationTest.java
index ac617fd8..31a15d67 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/sqlite/SharedPreferencesMigrationTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/sqlite/SharedPreferencesMigrationTest.java
@@ -15,6 +15,7 @@
import java.util.UUID;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
/**
* @author sslavin
@@ -49,6 +50,9 @@ public void test_shouldMigrateAllMessagesToSqlite() throws Exception {
internalData.put("atts", attachments);
internalData.put("silent", new JSONObject());
+ internalData.put("webViewUrl", "http://www.bla.com");
+ internalData.put("messageType", "some msg type");
+
for (int i = 0; i < numberOfMessages; i++) {
sharedPreferencesMessageStore.save(context, new Message(
i + uuid.toString(),
@@ -70,7 +74,9 @@ public void test_shouldMigrateAllMessagesToSqlite() throws Exception {
"SomeStatusMessage" + i,
"http://www.some-content.com.ru.hr",
null,
- 0
+ 0,
+ "http://www.bla.com",
+ "some msg type"
));
}
@@ -105,6 +111,63 @@ public void test_shouldMigrateAllMessagesToSqlite() throws Exception {
assertEquals("SomeStatusMessage" + i, message.getStatusMessage());
assertEquals("http://www.some-content.com.ru.hr", message.getContentUrl());
assertEquals(0, message.getInAppExpiryTimestamp());
+ assertEquals("http://www.bla.com", message.getWebViewUrl());
+ assertEquals("some msg type", message.getMessageType());
+ }
+ }
+
+ @Test
+ public void test_shouldNotMigrateChatMessagesToSqlite() throws Exception {
+
+ UUID uuid = UUID.randomUUID();
+ int numberOfMessages = 10;
+
+ JSONObject internalData = new JSONObject();
+
+ internalData.put("webViewUrl", "http://www.bla.com");
+ internalData.put("messageType", "chat");
+
+ for (int i = 0; i < numberOfMessages; i++) {
+ sharedPreferencesMessageStore.save(context, new Message(
+ i + uuid.toString(),
+ "SomeTitle" + i,
+ "SomeBody" + i,
+ "SomeSound" + i,
+ true,
+ "SomeIcon" + i,
+ false,
+ "SomeCategory" + i,
+ "SomeFrom" + i,
+ 0,
+ 0,
+ 0,
+ null,
+ internalData.toString(),
+ "SomeDestination" + i,
+ Message.Status.SUCCESS,
+ "SomeStatusMessage" + i,
+ "http://www.some-content.com.ru.hr",
+ null,
+ 0,
+ "http://www.bla.com",
+ "chat"
+ ));
+ }
+
+ MessageStore store = new SQLiteMessageStore();
+ List messages = store.findAll(context);
+ HashMap map = new HashMap<>();
+ for (Message m : messages) map.put(m.getMessageId(), m);
+
+ // we are not removing messages from shared prefs
+ // in case user still uses SharedPreferencesMessageStore
+ assertEquals(0, sharedPreferencesMessageStore.findAll(context).size());
+ assertEquals(0, map.size());
+
+ for (int i = 0; i < numberOfMessages; i++) {
+ String id = i + uuid.toString();
+ Message message = map.get(id);
+ assertNull(message);
}
}
}
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/sqlite/SomethingInDatabase.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/sqlite/SomethingInDatabase.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/sqlite/SomethingInDatabase.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/sqlite/SomethingInDatabase.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/sqlite/SqliteMessageMigrationTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/sqlite/SqliteMessageMigrationTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/sqlite/SqliteMessageMigrationTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/sqlite/SqliteMessageMigrationTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/sqlite/SqliteMessageTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/sqlite/SqliteMessageTest.java
similarity index 91%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/sqlite/SqliteMessageTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/sqlite/SqliteMessageTest.java
index 6bd37856..a2736d39 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/sqlite/SqliteMessageTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/dal/sqlite/SqliteMessageTest.java
@@ -46,9 +46,11 @@ public void test_message_toFromSqlite() throws Exception {
"SomeDestination",
Message.Status.SUCCESS,
"SomeStatusMessage",
- "http://www.some-content.com.ru.hr",
+ "http://www.some-content.com.ru.hr/image.jpg",
Message.InAppStyle.MODAL,
- 1881L
+ 1881L,
+ "http://www.some-content.com.ru.hr",
+ "some msg type"
);
databaseHelper.save(new SqliteMessage(message));
@@ -75,7 +77,9 @@ public void test_message_toFromSqlite() throws Exception {
assertEquals("SomeDestination", message.getDestination());
assertEquals(Message.Status.SUCCESS, message.getStatus());
assertEquals("SomeStatusMessage", message.getStatusMessage());
- assertEquals("http://www.some-content.com.ru.hr", message.getContentUrl());
+ assertEquals("http://www.some-content.com.ru.hr/image.jpg", message.getContentUrl());
+ assertEquals("http://www.some-content.com.ru.hr", message.getWebViewUrl());
+ assertEquals("some msg type", message.getMessageType());
assertEquals(Message.InAppStyle.MODAL, message.getInAppStyle());
}
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/MobileInteractiveImplTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/MobileInteractiveImplTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/MobileInteractiveImplTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/MobileInteractiveImplTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/NotificationCategoriesTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/NotificationCategoriesTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/NotificationCategoriesTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/NotificationCategoriesTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/InAppNotificationHandlerImplTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/InAppNotificationHandlerImplTest.java
similarity index 95%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/InAppNotificationHandlerImplTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/InAppNotificationHandlerImplTest.java
index a2306dd2..b731b61e 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/InAppNotificationHandlerImplTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/InAppNotificationHandlerImplTest.java
@@ -4,7 +4,7 @@
import android.content.Intent;
import org.infobip.mobile.messaging.Message;
-import org.infobip.mobile.messaging.app.CallbackActivityStarterWrapper;
+import org.infobip.mobile.messaging.app.ActivityStarterWrapper;
import org.infobip.mobile.messaging.interactive.MobileInteractive;
import org.infobip.mobile.messaging.interactive.NotificationAction;
import org.infobip.mobile.messaging.interactive.NotificationCategory;
@@ -45,7 +45,7 @@ public class InAppNotificationHandlerImplTest {
private InAppView inAppView = mock(InAppView.class);
private DialogStack dialogStack = mock(DialogStack.class);
private InteractiveBroadcaster interactiveBroadcaster = mock(InteractiveBroadcaster.class);
- private CallbackActivityStarterWrapper callbackActivityStarterWrapper = mock(CallbackActivityStarterWrapper.class);
+ private ActivityStarterWrapper activityStarterWrapper = mock(ActivityStarterWrapper.class);
private Activity activity = mock(Activity.class);
@@ -53,7 +53,7 @@ public class InAppNotificationHandlerImplTest {
public void before() {
reset(mobileInteractive, inAppViewFactory, inAppRules, oneMessageCache, inAppView);
when(inAppViewFactory.create(eq(activity), any(InAppView.Callback.class))).thenReturn(inAppView);
- inAppNotificationHandler = new InAppNotificationHandlerImpl(mobileInteractive, inAppViewFactory, inAppRules, oneMessageCache, dialogStack, interactiveBroadcaster, callbackActivityStarterWrapper);
+ inAppNotificationHandler = new InAppNotificationHandlerImpl(mobileInteractive, inAppViewFactory, inAppRules, oneMessageCache, dialogStack, interactiveBroadcaster, activityStarterWrapper);
}
@Test
@@ -146,7 +146,7 @@ public void shouldStartCallbackActivityIfActionShouldBringAppToForegroundWhenBut
inAppNotificationHandler.buttonPressedFor(inAppView, message, category, actions[0]);
assertTrue(actions[0].bringsAppToForeground());
- verify(callbackActivityStarterWrapper, times(1)).startActivity(any(Intent.class));
+ verify(activityStarterWrapper, times(1)).startCallbackActivity(any(Intent.class));
}
@Test
@@ -158,7 +158,7 @@ public void shouldNotStartCallbackActivityIfActionShouldNotBringAppToForegroundW
inAppNotificationHandler.buttonPressedFor(inAppView, message, category, actions[0]);
assertFalse(actions[0].bringsAppToForeground());
- verify(callbackActivityStarterWrapper, never()).startActivity(any(Intent.class));
+ verify(activityStarterWrapper, never()).startCallbackActivity(any(Intent.class));
}
@Test
@@ -171,7 +171,7 @@ public void shouldTriggerSdkActionsAndBroadcastAndStartCallbackActivityWhenOpenB
verify(mobileInteractive, times(1)).triggerSdkActionsFor(eq(action), eq(message));
verify(interactiveBroadcaster, times(1)).notificationActionTapped(eq(message), eq(category), eq(action));
- verify(callbackActivityStarterWrapper, times(1)).startActivity(any(Intent.class));
+ verify(activityStarterWrapper, times(1)).startCallbackActivity(any(Intent.class));
}
@Test
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/cache/OneMessagePreferenceCacheTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/cache/OneMessagePreferenceCacheTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/cache/OneMessagePreferenceCacheTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/cache/OneMessagePreferenceCacheTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/foreground/ForegroundStateMonitorImplTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/foreground/ForegroundStateMonitorImplTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/foreground/ForegroundStateMonitorImplTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/foreground/ForegroundStateMonitorImplTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/rules/InAppRulesTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/rules/InAppRulesTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/rules/InAppRulesTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/rules/InAppRulesTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/view/InAppViewDialogClickListenerTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/view/InAppViewDialogClickListenerTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/view/InAppViewDialogClickListenerTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/view/InAppViewDialogClickListenerTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/view/InAppViewDialogDismissListenerTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/view/InAppViewDialogDismissListenerTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/view/InAppViewDialogDismissListenerTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/view/InAppViewDialogDismissListenerTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/view/InAppViewDialogTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/view/InAppViewDialogTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/view/InAppViewDialogTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/view/InAppViewDialogTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/view/QueuedDialogStackTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/view/QueuedDialogStackTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/view/QueuedDialogStackTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/inapp/view/QueuedDialogStackTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/notification/NotificationActionTapReceiverTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/notification/NotificationActionTapReceiverTest.java
similarity index 95%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/notification/NotificationActionTapReceiverTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/notification/NotificationActionTapReceiverTest.java
index 883bd67d..c8f077e0 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/notification/NotificationActionTapReceiverTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/notification/NotificationActionTapReceiverTest.java
@@ -7,7 +7,7 @@
import org.infobip.mobile.messaging.Message;
import org.infobip.mobile.messaging.MobileMessagingCore;
import org.infobip.mobile.messaging.NotificationSettings;
-import org.infobip.mobile.messaging.app.CallbackActivityStarterWrapper;
+import org.infobip.mobile.messaging.app.ActivityStarterWrapper;
import org.infobip.mobile.messaging.interactive.MobileInteractiveImpl;
import org.infobip.mobile.messaging.interactive.NotificationAction;
import org.infobip.mobile.messaging.interactive.NotificationCategory;
@@ -32,7 +32,7 @@ public class NotificationActionTapReceiverTest extends MobileMessagingTestCase {
private ArgumentCaptor notificationCategoryArgumentCaptor;
private ArgumentCaptor messageArgumentCaptor;
private NotificationActionTapReceiver notificationActionTapReceiver;
- private CallbackActivityStarterWrapper callbackActivityStarterWrapper;
+ private ActivityStarterWrapper activityStarterWrapper;
@Override
public void setUp() throws Exception {
@@ -42,11 +42,11 @@ public void setUp() throws Exception {
notificationManagerMock = Mockito.mock(NotificationManager.class);
mobileMessagingCore = Mockito.mock(MobileMessagingCore.class);
mobileInteractive = Mockito.mock(MobileInteractiveImpl.class);
- callbackActivityStarterWrapper = Mockito.mock(CallbackActivityStarterWrapper.class);
+ activityStarterWrapper = Mockito.mock(ActivityStarterWrapper.class);
notificationCategoryArgumentCaptor = ArgumentCaptor.forClass(NotificationCategory.class);
notificationActionArgumentCaptor = ArgumentCaptor.forClass(NotificationAction.class);
messageArgumentCaptor = ArgumentCaptor.forClass(Message.class);
- notificationActionTapReceiver = new NotificationActionTapReceiver(broadcastSender, mobileMessagingCore, mobileInteractive, callbackActivityStarterWrapper);
+ notificationActionTapReceiver = new NotificationActionTapReceiver(broadcastSender, mobileMessagingCore, mobileInteractive, activityStarterWrapper);
NotificationSettings notificationSettings = new NotificationSettings.Builder(context)
.withDefaultIcon(android.R.drawable.ic_dialog_alert) // if not set throws -> IllegalArgumentException("defaultIcon doesn't exist");
@@ -106,7 +106,7 @@ public void test_should_send_action_clicked_event_and_open_activity_if_action_sh
notificationActionArgumentCaptor.capture());
verifyProperPayloadWasSentAndActionsTriggered(givenTappedNotificationAction, givenNotificationCategory, givenMessage);
- Mockito.verify(callbackActivityStarterWrapper, Mockito.times(1)).startActivity(givenIntent);
+ Mockito.verify(activityStarterWrapper, Mockito.times(1)).startCallbackActivity(givenIntent);
}
@Test
@@ -133,7 +133,7 @@ public void test_should_send_action_clicked_event_and_not_open_activity_if_actio
notificationActionArgumentCaptor.capture());
verifyProperPayloadWasSentAndActionsTriggered(givenTappedNotificationAction, givenNotificationCategory, givenMessage);
- Mockito.verify(callbackActivityStarterWrapper, Mockito.never()).startActivity(givenIntent);
+ Mockito.verify(activityStarterWrapper, Mockito.never()).startCallbackActivity(givenIntent);
}
@Test
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/platform/AndroidInteractiveBroadcasterTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/platform/AndroidInteractiveBroadcasterTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/platform/AndroidInteractiveBroadcasterTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/platform/AndroidInteractiveBroadcasterTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/platform/MockActivity.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/platform/MockActivity.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/platform/MockActivity.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/platform/MockActivity.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/tools/MobileMessagingTestCase.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/tools/MobileMessagingTestCase.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/tools/MobileMessagingTestCase.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/tools/MobileMessagingTestCase.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/tools/MobileMessagingTestable.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/tools/MobileMessagingTestable.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/tools/MobileMessagingTestable.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/interactive/tools/MobileMessagingTestable.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobile/MobileApiResourceProviderTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobileapi/MobileApiResourceProviderTest.java
similarity index 98%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobile/MobileApiResourceProviderTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobileapi/MobileApiResourceProviderTest.java
index 0ca3e367..92162d27 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobile/MobileApiResourceProviderTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobileapi/MobileApiResourceProviderTest.java
@@ -1,4 +1,4 @@
-package org.infobip.mobile.messaging.mobile;
+package org.infobip.mobile.messaging.mobileapi;
import org.infobip.mobile.messaging.MobileMessagingCore;
import org.infobip.mobile.messaging.MobileMessagingProperty;
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobile/MobileMessagingErrorTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobileapi/MobileMessagingErrorTest.java
similarity index 96%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobile/MobileMessagingErrorTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobileapi/MobileMessagingErrorTest.java
index 11abca68..c42a3a46 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobile/MobileMessagingErrorTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobileapi/MobileMessagingErrorTest.java
@@ -1,4 +1,4 @@
-package org.infobip.mobile.messaging.mobile;
+package org.infobip.mobile.messaging.mobileapi;
import org.infobip.mobile.messaging.api.support.ApiBackendException;
import org.infobip.mobile.messaging.tools.MobileMessagingTestCase;
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobile/appinstance/InstallationSynchronizerTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobileapi/appinstance/InstallationSynchronizerTest.java
similarity index 97%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobile/appinstance/InstallationSynchronizerTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobileapi/appinstance/InstallationSynchronizerTest.java
index 9d919da4..af5a0c59 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobile/appinstance/InstallationSynchronizerTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobileapi/appinstance/InstallationSynchronizerTest.java
@@ -1,4 +1,4 @@
-package org.infobip.mobile.messaging.mobile.appinstance;
+package org.infobip.mobile.messaging.mobileapi.appinstance;
import android.support.annotation.NonNull;
@@ -11,9 +11,9 @@
import org.infobip.mobile.messaging.api.support.ApiErrorCode;
import org.infobip.mobile.messaging.api.support.ApiIOException;
import org.infobip.mobile.messaging.api.support.util.CollectionUtils;
-import org.infobip.mobile.messaging.mobile.MobileMessagingError;
-import org.infobip.mobile.messaging.mobile.Result;
-import org.infobip.mobile.messaging.mobile.common.RetryPolicyProvider;
+import org.infobip.mobile.messaging.mobileapi.MobileMessagingError;
+import org.infobip.mobile.messaging.mobileapi.Result;
+import org.infobip.mobile.messaging.mobileapi.common.RetryPolicyProvider;
import org.infobip.mobile.messaging.platform.Broadcaster;
import org.infobip.mobile.messaging.stats.MobileMessagingStats;
import org.infobip.mobile.messaging.tools.MobileMessagingTestCase;
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobile/common/MAsyncTaskTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobileapi/common/MAsyncTaskTest.java
similarity index 95%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobile/common/MAsyncTaskTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobileapi/common/MAsyncTaskTest.java
index 1254986f..7baec156 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobile/common/MAsyncTaskTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobileapi/common/MAsyncTaskTest.java
@@ -1,14 +1,14 @@
-package org.infobip.mobile.messaging.mobile.common;
+package org.infobip.mobile.messaging.mobileapi.common;
import android.support.annotation.NonNull;
import org.infobip.mobile.messaging.api.support.ApiBackendExceptionWithContent;
import org.infobip.mobile.messaging.api.support.ApiErrorCode;
import org.infobip.mobile.messaging.api.support.ApiIOException;
-import org.infobip.mobile.messaging.mobile.common.exceptions.BackendBaseException;
-import org.infobip.mobile.messaging.mobile.common.exceptions.BackendCommunicationExceptionWithContent;
-import org.infobip.mobile.messaging.mobile.common.exceptions.BackendInvalidParameterException;
-import org.infobip.mobile.messaging.mobile.common.exceptions.BackendInvalidParameterExceptionWithContent;
+import org.infobip.mobile.messaging.mobileapi.common.exceptions.BackendBaseException;
+import org.infobip.mobile.messaging.mobileapi.common.exceptions.BackendCommunicationExceptionWithContent;
+import org.infobip.mobile.messaging.mobileapi.common.exceptions.BackendInvalidParameterException;
+import org.infobip.mobile.messaging.mobileapi.common.exceptions.BackendInvalidParameterExceptionWithContent;
import org.infobip.mobile.messaging.tools.MobileMessagingTestCase;
import org.junit.Test;
import org.mockito.ArgumentMatcher;
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobile/common/MRetryableTaskTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobileapi/common/MRetryableTaskTest.java
similarity index 99%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobile/common/MRetryableTaskTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobileapi/common/MRetryableTaskTest.java
index ebff0c8d..d1b032da 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobile/common/MRetryableTaskTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobileapi/common/MRetryableTaskTest.java
@@ -1,4 +1,4 @@
-package org.infobip.mobile.messaging.mobile.common;
+package org.infobip.mobile.messaging.mobileapi.common;
import android.support.annotation.NonNull;
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobile/events/UserEventsSynchronizerTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobileapi/events/UserEventsSynchronizerTest.java
similarity index 78%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobile/events/UserEventsSynchronizerTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobileapi/events/UserEventsSynchronizerTest.java
index 50f8f3e5..bfa8ff74 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobile/events/UserEventsSynchronizerTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobileapi/events/UserEventsSynchronizerTest.java
@@ -1,8 +1,9 @@
-package org.infobip.mobile.messaging.mobile.events;
+package org.infobip.mobile.messaging.mobileapi.events;
import android.support.annotation.NonNull;
import org.infobip.mobile.messaging.CustomAttributeValue;
+import org.infobip.mobile.messaging.CustomEvent;
import org.infobip.mobile.messaging.MobileMessaging;
import org.infobip.mobile.messaging.MobileMessagingProperty;
import org.infobip.mobile.messaging.api.appinstance.MobileApiAppInstance;
@@ -11,10 +12,10 @@
import org.infobip.mobile.messaging.api.support.ApiErrorCode;
import org.infobip.mobile.messaging.api.support.ApiIOException;
import org.infobip.mobile.messaging.api.support.util.CollectionUtils;
-import org.infobip.mobile.messaging.mobile.BatchReporter;
-import org.infobip.mobile.messaging.mobile.MobileMessagingError;
-import org.infobip.mobile.messaging.mobile.common.MRetryPolicy;
-import org.infobip.mobile.messaging.mobile.common.RetryPolicyProvider;
+import org.infobip.mobile.messaging.mobileapi.BatchReporter;
+import org.infobip.mobile.messaging.mobileapi.MobileMessagingError;
+import org.infobip.mobile.messaging.mobileapi.common.MRetryPolicy;
+import org.infobip.mobile.messaging.mobileapi.common.RetryPolicyProvider;
import org.infobip.mobile.messaging.platform.Broadcaster;
import org.infobip.mobile.messaging.platform.Time;
import org.infobip.mobile.messaging.tools.MobileMessagingTestCase;
@@ -24,8 +25,10 @@
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
+import java.text.ParseException;
import java.util.Date;
import java.util.HashMap;
+import java.util.TimeZone;
import java.util.concurrent.Executor;
import static org.junit.Assert.assertEquals;
@@ -56,6 +59,7 @@ public void execute(@NonNull Runnable command) {
command.run();
}
};
+ private final long date = System.currentTimeMillis();
@Override
public void setUp() throws Exception {
@@ -82,22 +86,19 @@ public void shouldReportSessionEventsOnServer() throws Exception {
userEventsSynchronizer.reportSessions();
+ verify(broadcaster, after(300).times(1)).userSessionsReported();
+ verify(mobileApiAppInstance, times(1)).sendUserSessionReport(anyString(), userSessionEventCaptor.capture());
assertEquals(sessionStartMillis, mobileMessagingCore.getActiveSessionStartTime());
assertEquals(sessionEndMillis, mobileMessagingCore.getActiveSessionEndTime());
assertEquals(0, UserEventsRequestMapper.getSessionBounds(mobileMessagingCore.getStoredSessionBounds()).size());
-
- verify(mobileApiAppInstance, times(1)).sendUserSessionReport(anyString(), userSessionEventCaptor.capture());
UserSessionEventBody userSessionEventBody = userSessionEventCaptor.getValue();
assertEquals(sessionBounds, userSessionEventBody.getSessionBounds());
- assertEquals(CollectionUtils.setOf(DateTimeUtil.ISO8601DateUTCToString(new Date(sessionStartMillis))), userSessionEventBody.getSessionStarts());
- verify(broadcaster, after(300).times(1)).userSessionsReported();
+ assertEquals(CollectionUtils.setOf(DateTimeUtil.dateToISO8601UTCString(new Date(sessionStartMillis))), userSessionEventBody.getSessionStarts());
}
@Test
public void shouldReportOneCustomEventOnServerWithValidationSync() throws Exception {
- CustomEvent customEvent = new CustomEvent();
- customEvent.setProperty("key", new CustomAttributeValue(true));
- customEvent.setDefinitionId("12345");
+ CustomEvent customEvent = setupCustomEventWithProperties();
userEventsSynchronizer.reportCustomEvent(customEvent, eventResultListener);
@@ -110,9 +111,7 @@ public void shouldReportOneCustomEventOnServerWithValidationSync() throws Except
@Test
public void shouldPropagateValidationErrorOnReportingOneCustomEventOnServerSync() throws Exception {
- CustomEvent customEvent = new CustomEvent();
- customEvent.setProperty("key", new CustomAttributeValue(true));
- customEvent.setDefinitionId("12345");
+ CustomEvent customEvent = setupCustomEventWithProperties();
doThrow(new ApiIOException(ApiErrorCode.INVALID_VALUE, "Request is invalid"))
.when(mobileApiAppInstance).sendUserCustomEvents(anyString(), anyBoolean(), any(UserCustomEventBody.class));
@@ -127,9 +126,7 @@ public void shouldPropagateValidationErrorOnReportingOneCustomEventOnServerSync(
@Test
public void shouldReportOneCustomEventOnServerAsync() throws Exception {
- CustomEvent customEvent = new CustomEvent();
- customEvent.setProperty("key", new CustomAttributeValue(true));
- customEvent.setDefinitionId("12345");
+ CustomEvent customEvent = setupCustomEventWithProperties();
mobileMessagingCore.addUnreportedUserCustomEvent(customEvent);
assertEquals(1, PreferenceHelper.findStringArray(context, MobileMessagingProperty.USER_CUSTOM_EVENTS).length);
@@ -143,9 +140,7 @@ public void shouldReportOneCustomEventOnServerAsync() throws Exception {
@Test
public void shouldReportMultipleCustomEventsOnServerAsync() throws Exception {
- CustomEvent customEvent = new CustomEvent();
- customEvent.setProperty("key", new CustomAttributeValue(true));
- customEvent.setDefinitionId("12345");
+ CustomEvent customEvent = setupCustomEventWithProperties();
CustomEvent customEvent2 = new CustomEvent();
customEvent2.setProperty("yay", new CustomAttributeValue("kk"));
customEvent2.setDefinitionId("9876");
@@ -162,10 +157,31 @@ public void shouldReportMultipleCustomEventsOnServerAsync() throws Exception {
assertNull(PreferenceHelper.findStringArray(context, MobileMessagingProperty.USER_CUSTOM_EVENTS));
}
- private void verifyCustomEventRequestBody(CustomEvent customEvent) {
+ @NonNull
+ private CustomEvent setupCustomEventWithProperties() {
+ CustomEvent customEvent = new CustomEvent();
+ customEvent.setProperty("someBool", new CustomAttributeValue(true));
+ customEvent.setProperty("someString", new CustomAttributeValue("string"));
+ customEvent.setProperty("someDate", new CustomAttributeValue(new Date(date)));
+ customEvent.setProperty("someNumber", new CustomAttributeValue(1.1));
+ customEvent.setDefinitionId("12345");
+ return customEvent;
+ }
+
+ private void verifyCustomEventRequestBody(CustomEvent customEvent) throws ParseException {
UserCustomEventBody userCustomEventBody = customEventCaptor.getValue();
assertEquals(customEvent.getDefinitionId(), userCustomEventBody.getEvents()[0].getDefinitionId());
assertEquals(customEvent.getProperties().keySet(), userCustomEventBody.getEvents()[0].getProperties().keySet());
- assertEquals(customEvent.getProperties().get("key").booleanValue(), userCustomEventBody.getEvents()[0].getProperties().get("key"));
+ assertEquals(customEvent.getProperties().get("someBool").booleanValue(), userCustomEventBody.getEvents()[0].getProperties().get("someBool"));
+ assertEquals(customEvent.getProperties().get("someString").stringValue(), userCustomEventBody.getEvents()[0].getProperties().get("someString"));
+ assertEquals(customEvent.getProperties().get("someNumber").numberValue(), userCustomEventBody.getEvents()[0].getProperties().get("someNumber"));
+
+ Date someDateInUtc = DateTimeUtil.dateFromISO8601DateUTCString((String) userCustomEventBody.getEvents()[0].getProperties().get("someDate"));
+ Date someDate = customEvent.getProperties().get("someDate").dateValue();
+
+ int offsetUtcDate = TimeZone.getDefault().getOffset(someDateInUtc.getTime());
+ int offsetLocalDate = TimeZone.getDefault().getOffset(someDate.getTime());
+
+ assertEquals(someDate.getTime() - offsetLocalDate, someDateInUtc.getTime());
}
}
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobile/messages/MessagesSynchronizerTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobileapi/messages/MessagesSynchronizerTest.java
similarity index 97%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobile/messages/MessagesSynchronizerTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobileapi/messages/MessagesSynchronizerTest.java
index ba3f79b8..71b29b04 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobile/messages/MessagesSynchronizerTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobileapi/messages/MessagesSynchronizerTest.java
@@ -1,12 +1,12 @@
-package org.infobip.mobile.messaging.mobile.messages;
+package org.infobip.mobile.messaging.mobileapi.messages;
import org.infobip.mobile.messaging.Message;
import org.infobip.mobile.messaging.api.messages.MessageResponse;
import org.infobip.mobile.messaging.api.messages.SyncMessagesBody;
import org.infobip.mobile.messaging.api.messages.SyncMessagesResponse;
import org.infobip.mobile.messaging.cloud.MobileMessageHandler;
-import org.infobip.mobile.messaging.mobile.common.MRetryPolicy;
-import org.infobip.mobile.messaging.mobile.common.RetryPolicyProvider;
+import org.infobip.mobile.messaging.mobileapi.common.MRetryPolicy;
+import org.infobip.mobile.messaging.mobileapi.common.RetryPolicyProvider;
import org.infobip.mobile.messaging.tools.MobileMessagingTestCase;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobile/messages/MoMessageSenderTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobileapi/messages/MoMessageSenderTest.java
similarity index 98%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobile/messages/MoMessageSenderTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobileapi/messages/MoMessageSenderTest.java
index 8a0d7880..b9af6afc 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobile/messages/MoMessageSenderTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/mobileapi/messages/MoMessageSenderTest.java
@@ -1,4 +1,4 @@
-package org.infobip.mobile.messaging.mobile.messages;
+package org.infobip.mobile.messaging.mobileapi.messages;
import android.support.annotation.NonNull;
@@ -11,7 +11,7 @@
import org.infobip.mobile.messaging.api.messages.MoMessagesResponse;
import org.infobip.mobile.messaging.api.messages.MobileApiMessages;
import org.infobip.mobile.messaging.api.support.http.serialization.JsonSerializer;
-import org.infobip.mobile.messaging.mobile.common.MRetryPolicy;
+import org.infobip.mobile.messaging.mobileapi.common.MRetryPolicy;
import org.infobip.mobile.messaging.platform.Time;
import org.infobip.mobile.messaging.storage.MessageStoreWrapper;
import org.infobip.mobile.messaging.storage.SQLiteMessageStore;
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/notification/BaseNotificationHandlerTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/notification/BaseNotificationHandlerTest.java
similarity index 99%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/notification/BaseNotificationHandlerTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/notification/BaseNotificationHandlerTest.java
index 527ee31e..e7e99551 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/notification/BaseNotificationHandlerTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/notification/BaseNotificationHandlerTest.java
@@ -174,7 +174,9 @@ private Message prepareMessageWithBanner() {
"SomeStatusMessage",
"http://www.some-content.com.ru.hr",
Message.InAppStyle.BANNER,
- 0
+ 0,
+ null,
+ null
);
}
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/notification/MockNotificationHandler.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/notification/MockNotificationHandler.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/notification/MockNotificationHandler.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/notification/MockNotificationHandler.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/notification/NotificationTapReceiverTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/notification/NotificationTapReceiverTest.java
similarity index 92%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/notification/NotificationTapReceiverTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/notification/NotificationTapReceiverTest.java
index ad77a389..bad07c7a 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/notification/NotificationTapReceiverTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/notification/NotificationTapReceiverTest.java
@@ -8,7 +8,7 @@
import org.infobip.mobile.messaging.MobileMessagingCore;
import org.infobip.mobile.messaging.MobileMessagingProperty;
import org.infobip.mobile.messaging.NotificationSettings;
-import org.infobip.mobile.messaging.app.CallbackActivityStarterWrapper;
+import org.infobip.mobile.messaging.app.ActivityStarterWrapper;
import org.infobip.mobile.messaging.dal.bundle.MessageBundleMapper;
import org.infobip.mobile.messaging.platform.Broadcaster;
import org.infobip.mobile.messaging.platform.MockActivity;
@@ -28,7 +28,7 @@ public class NotificationTapReceiverTest extends MobileMessagingTestCase {
private NotificationTapReceiver notificationTapReceiver;
private Broadcaster broadcastSender;
private MobileMessagingCore mobileMessagingCore;
- private CallbackActivityStarterWrapper callbackActivityStarterWrapper;
+ private ActivityStarterWrapper activityStarterWrapper;
@Override
public void setUp() throws Exception {
@@ -36,10 +36,10 @@ public void setUp() throws Exception {
broadcastSender = Mockito.mock(Broadcaster.class);
mobileMessagingCore = Mockito.mock(MobileMessagingCore.class);
- callbackActivityStarterWrapper = Mockito.mock(CallbackActivityStarterWrapper.class);
+ activityStarterWrapper = Mockito.mock(ActivityStarterWrapper.class);
intentArgumentCaptor = ArgumentCaptor.forClass(Intent.class);
messageArgumentCaptor = ArgumentCaptor.forClass(Message.class);
- notificationTapReceiver = new NotificationTapReceiver(broadcastSender, mobileMessagingCore, callbackActivityStarterWrapper);
+ notificationTapReceiver = new NotificationTapReceiver(broadcastSender, mobileMessagingCore, activityStarterWrapper);
notificationSettings = new NotificationSettings.Builder(context)
.withDefaultIcon(android.R.drawable.ic_dialog_alert) // if not set throws -> IllegalArgumentException("defaultIcon doesn't exist");
@@ -63,7 +63,7 @@ public void test_should_set_flags_and_message_for_activity_intent() throws Excep
// Then
Intent expectedIntent = new Intent(Event.NOTIFICATION_TAPPED.getKey());
expectedIntent.putExtras(givenIntent);
- Mockito.verify(callbackActivityStarterWrapper, Mockito.times(1)).startActivity(intentArgumentCaptor.capture());
+ Mockito.verify(activityStarterWrapper, Mockito.times(1)).startCallbackActivity(intentArgumentCaptor.capture());
Intent intent = intentArgumentCaptor.getValue();
assertEquals(notificationSettings.getIntentFlags(), intent.getFlags());
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/platform/AndroidBroadcasterTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/platform/AndroidBroadcasterTest.java
similarity index 99%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/platform/AndroidBroadcasterTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/platform/AndroidBroadcasterTest.java
index 1fd4adb8..bcc230eb 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/platform/AndroidBroadcasterTest.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/platform/AndroidBroadcasterTest.java
@@ -8,7 +8,7 @@
import org.infobip.mobile.messaging.Installation;
import org.infobip.mobile.messaging.Message;
import org.infobip.mobile.messaging.User;
-import org.infobip.mobile.messaging.mobile.MobileMessagingError;
+import org.infobip.mobile.messaging.mobileapi.MobileMessagingError;
import org.infobip.mobile.messaging.tools.MobileMessagingTestCase;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/platform/MobileMessagingJobServiceTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/platform/MobileMessagingJobServiceTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/platform/MobileMessagingJobServiceTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/platform/MobileMessagingJobServiceTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/platform/MockActivity.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/platform/MockActivity.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/platform/MockActivity.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/platform/MockActivity.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/platform/PlatformTestCase.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/platform/PlatformTestCase.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/platform/PlatformTestCase.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/platform/PlatformTestCase.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/storage/StoredMessageMapperTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/storage/StoredMessageMapperTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/storage/StoredMessageMapperTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/storage/StoredMessageMapperTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/storage/TestMessageStore.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/storage/TestMessageStore.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/storage/TestMessageStore.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/storage/TestMessageStore.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/tools/MobileMessagingTestCase.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/tools/MobileMessagingTestCase.java
similarity index 99%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/tools/MobileMessagingTestCase.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/tools/MobileMessagingTestCase.java
index 21734447..dcdc8bcd 100644
--- a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/tools/MobileMessagingTestCase.java
+++ b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/tools/MobileMessagingTestCase.java
@@ -16,7 +16,7 @@
import org.infobip.mobile.messaging.dal.sqlite.DatabaseHelper;
import org.infobip.mobile.messaging.dal.sqlite.SqliteDatabaseProvider;
import org.infobip.mobile.messaging.logging.MobileMessagingLogger;
-import org.infobip.mobile.messaging.mobile.MobileApiResourceProvider;
+import org.infobip.mobile.messaging.mobileapi.MobileApiResourceProvider;
import org.infobip.mobile.messaging.notification.NotificationHandler;
import org.infobip.mobile.messaging.platform.Broadcaster;
import org.infobip.mobile.messaging.platform.Time;
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/util/CryptorTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/util/CryptorTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/util/CryptorTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/util/CryptorTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/util/EncryptUtilTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/util/EncryptUtilTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/util/EncryptUtilTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/util/EncryptUtilTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/util/MobileNetworkInformationTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/util/MobileNetworkInformationTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/util/MobileNetworkInformationTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/util/MobileNetworkInformationTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/util/ModuleLoaderTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/util/ModuleLoaderTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/util/ModuleLoaderTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/util/ModuleLoaderTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/util/PreferenceHelperTest.java b/infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/util/PreferenceHelperTest.java
similarity index 100%
rename from infobip-mobile-messaging-android-sdk/src/androidTest/java/org/infobip/mobile/messaging/util/PreferenceHelperTest.java
rename to infobip-mobile-messaging-huawei-sdk/src/androidTest/java/org/infobip/mobile/messaging/util/PreferenceHelperTest.java
diff --git a/infobip-mobile-messaging-android-sdk/src/main/AndroidManifest.xml b/infobip-mobile-messaging-huawei-sdk/src/main/AndroidManifest.xml
similarity index 71%
rename from infobip-mobile-messaging-android-sdk/src/main/AndroidManifest.xml
rename to infobip-mobile-messaging-huawei-sdk/src/main/AndroidManifest.xml
index 95096799..8d801f0b 100644
--- a/infobip-mobile-messaging-android-sdk/src/main/AndroidManifest.xml
+++ b/infobip-mobile-messaging-huawei-sdk/src/main/AndroidManifest.xml
@@ -1,11 +1,14 @@
-
+