Skip to content

Commit

Permalink
Pull request #20: MM-4794 [Cordova] Update iOS and Android SDK versio…
Browse files Browse the repository at this point in the history
…n - chat UI fixes

Merge in MML/infobip-mobile-messaging-huawei from nbrel-MM-4794-new-sdk-version to master

Squashed commit of the following:

commit 7dfd964b2f81e9dadf0570f338cc1566db09a08b
Author: Olga Koroleva <Olga.Koroleva@infobip.com>
Date:   Mon Oct 25 14:09:00 2021 +0300

    merge android branch changes

commit 31485beff14cfd4bbfe04df9e213cd9aa455fbb5
Author: nbrel <nikolay.brel@infobip.com>
Date:   Mon Oct 25 10:50:19 2021 +0300

    MM-4794 [Cordova] Update iOS and Android SDK version - chat UI fixes
  • Loading branch information
riskpp committed Nov 3, 2021
1 parent 265fffb commit b1614b7
Show file tree
Hide file tree
Showing 11 changed files with 182 additions and 82 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ext {
mm_buildToolsVersion = "28.0.3"
mm_supportLibrariesVersion = "28.0.0"
mm_apiVersion = "3.0.4"
mm_androidSdkVersion = "5.3.0"
mm_androidSdkVersion = "5.3.3"
}

allprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ interface InAppChatMobile {
*/
void onError(String errorMessage);

/**
* Show/Hide input field
*
* @param isVisible
*/
void setControlsVisibility(boolean isVisible);

/**
* Open attachment preview in new webView window
* @param url link to cdn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ public void run() {
handler.post(myRunnable);
}

@Override
@JavascriptInterface
public void setControlsVisibility(final boolean isVisible) {
Runnable myRunnable = new Runnable() {
@Override
public void run() {
MobileMessagingLogger.d("WebView input visible: " + isVisible);
if (inAppChatWebViewManager != null) inAppChatWebViewManager.setControlsVisibility(isVisible);
}
};
handler.post(myRunnable);
}

@Override
@JavascriptInterface
public void openAttachmentPreview(final String url, final String type, final String caption) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public interface InAppChatWebViewManager {
void onPageFinished();
void setControlsEnabled(boolean enabled);
void onJSError();
void setControlsVisibility(boolean isVisible);
void openAttachmentPreview(String url, String type, String caption);
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
public class InAppChatFragment extends Fragment implements InAppChatWebViewManager, PermissionsRequestManager.PermissionsRequester {

private static final int CHAT_NOT_AVAILABLE_ANIM_DURATION_MILLIS = 500;
private static final int CHAT_INPUT_VISIBILITY_ANIM_DURATION_MILLIS = 300;
private static final int CONTENT_SELECTION_INTENT_CODE = 100;
private static final int USER_INPUT_CHECKER_DELAY_MS = 250;

Expand Down Expand Up @@ -112,6 +113,7 @@ public class InAppChatFragment extends Fragment implements InAppChatWebViewManag
private boolean fragmentCouldBePaused = true;
private boolean fragmentCouldBeResumed = true;
private boolean isToolbarHidden = false;
private boolean isInputControlsVisible = true;

/**
* Implement InAppChatActionBarProvider in your Activity, where InAppChatWebViewFragment will be added.
Expand Down Expand Up @@ -524,6 +526,28 @@ public void onJSError() {
msgInputWrapper.setVisibility(View.GONE);
}

@Override
public void setControlsVisibility(boolean isVisible) {
if (isInputControlsVisible == isVisible) {
return;
} else if (isVisible) {
msgInputWrapper.animate().translationY(0).setDuration(CHAT_INPUT_VISIBILITY_ANIM_DURATION_MILLIS).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
msgInputWrapper.setVisibility(View.VISIBLE);
}
});
} else {
msgInputWrapper.animate().translationY(msgInputWrapper.getHeight()).setDuration(CHAT_INPUT_VISIBILITY_ANIM_DURATION_MILLIS).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
msgInputWrapper.setVisibility(View.GONE);
}
});
}
isInputControlsVisible = isVisible;
}

@Override
public void openAttachmentPreview(String url, String type, String caption) {
fragmentCouldBePaused = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,21 @@
android:background="@android:color/white"
android:orientation="vertical"
android:paddingBottom="10dp"
android:animateLayoutChanges="true"
tools:context=".view.InAppChatFragment">

<TextView
android:id="@+id/ib_lc_tv_error_toast"
android:layout_width="match_parent"
android:layout_height="@dimen/chat_not_available_tv_height"
android:layout_alignBottom="@+id/appBarLayout"
android:background="@android:color/darker_gray"
android:gravity="center_horizontal|center_vertical"
android:text="@string/ib_chat_no_connection"
android:textColor="@android:color/black"
android:textSize="16sp"
android:visibility="invisible" />

<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
Expand All @@ -35,89 +48,83 @@
<org.infobip.mobile.messaging.chat.view.InAppChatWebView
android:id="@+id/ib_lc_wv_in_app_chat"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_height="match_parent"
android:layout_above="@+id/ib_lc_rl_msg_input_wrapper"
android:layout_below="@+id/appBarLayout"
android:visibility="invisible" />

<ImageView
android:id="@+id/ib_lc_iv_send_attachment_btn"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:contentDescription="@string/ib_iv_btn_send_attachment_desc"
android:enabled="false"
android:src="@drawable/ib_chat_attachment_btn_icon" />

<ImageView
android:id="@+id/ib_lc_iv_input_top_border"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_above="@id/ib_lc_rl_msg_input_wrapper"
android:contentDescription="@string/ib_iv_input_border_desc"
android:src="@drawable/light_top_border" />

<RelativeLayout
android:id="@+id/ib_lc_rl_msg_input_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toStartOf="@+id/ib_lc_iv_send_btn"
android:layout_toLeftOf="@+id/ib_lc_iv_send_btn"
android:layout_toEndOf="@+id/ib_lc_iv_send_attachment_btn"
android:layout_toRightOf="@+id/ib_lc_iv_send_attachment_btn"
android:minHeight="30dp"
android:orientation="horizontal"
android:paddingTop="10dp"
app:layout_anchorGravity="center">
android:layout_height="40dp"
android:layout_width="wrap_content">

<EditText
android:id="@+id/ib_lc_et_msg_input"
<ImageView
android:id="@+id/ib_lc_iv_input_top_border"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:background="@null"
android:layout_height="2dp"
android:layout_alignParentTop="true"
android:contentDescription="@string/ib_iv_input_border_desc"
android:src="@drawable/light_top_border" />

<ImageView
android:id="@+id/ib_lc_iv_send_attachment_btn"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:contentDescription="@string/ib_iv_btn_send_attachment_desc"
android:enabled="false"
android:hint="@string/ib_chat_message_hint"
android:importantForAutofill="no"
android:inputType="textMultiLine"
android:maxLines="5"
android:src="@drawable/ib_chat_attachment_btn_icon" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toStartOf="@+id/ib_lc_iv_send_btn"
android:layout_toLeftOf="@+id/ib_lc_iv_send_btn"
android:layout_toEndOf="@+id/ib_lc_iv_send_attachment_btn"
android:layout_toRightOf="@+id/ib_lc_iv_send_attachment_btn"
android:minHeight="30dp"
android:scrollbars="vertical"
android:textSize="16sp" />
android:orientation="horizontal"
android:paddingTop="10dp"
app:layout_anchorGravity="center">

</RelativeLayout>
<EditText
android:id="@+id/ib_lc_et_msg_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:background="@null"
android:enabled="false"
android:hint="@string/ib_chat_message_hint"
android:importantForAutofill="no"
android:inputType="textMultiLine"
android:maxLines="5"
android:minHeight="30dp"
android:scrollbars="vertical"
android:textSize="16sp" />

<ImageView
android:id="@+id/ib_lc_iv_send_btn"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:contentDescription="@string/ib_iv_btn_send_desc"
android:enabled="false"
android:src="@drawable/ib_chat_send_btn_icon" />
</RelativeLayout>

<TextView
android:id="@+id/ib_lc_tv_error_toast"
android:layout_width="match_parent"
android:layout_height="@dimen/chat_not_available_tv_height"
android:layout_alignBottom="@+id/appBarLayout"
android:background="@android:color/darker_gray"
android:gravity="center_horizontal|center_vertical"
android:text="@string/ib_chat_no_connection"
android:textColor="@android:color/black"
android:textSize="16sp"
android:visibility="invisible" />
<ImageView
android:id="@+id/ib_lc_iv_send_btn"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:contentDescription="@string/ib_iv_btn_send_desc"
android:enabled="false"
android:src="@drawable/ib_chat_send_btn_icon" />

</RelativeLayout>
</RelativeLayout>
1 change: 1 addition & 0 deletions infobip-mobile-messaging-huawei-demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ android {
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 }
}

release {
minifyEnabled true
debuggable false
Expand Down
10 changes: 5 additions & 5 deletions infobip-mobile-messaging-huawei-geo-sdk/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,27 @@
# Preserve all public classes, and their public and protected fields and
# methods.

-keep public class * {
-keep public class org.infobip.mobile.messaging.geo.** {
public protected *;
}

# Preserve all .class method names.

-keepclassmembernames class * {
-keepclassmembernames class org.infobip.mobile.messaging.geo.** {
java.lang.Class class$(java.lang.String);
java.lang.Class class$(java.lang.String, boolean);
}

# Preserve all native method names and the names of their classes.

-keepclasseswithmembernames class * {
-keepclasseswithmembernames class org.infobip.mobile.messaging.geo.** {
native <methods>;
}

# Preserve the special static methods that are required in all enumeration
# classes.

-keepclassmembers class * extends java.lang.Enum {
-keepclassmembers class org.infobip.mobile.messaging.geo.** extends java.lang.Enum {
public static **[] values();
public static ** valueOf(java.lang.String);
}
Expand All @@ -59,7 +59,7 @@
# If your code contains serializable classes that have to be backward
# compatible, please refer to the manual.

-keepclassmembers class * implements java.io.Serializable {
-keepclassmembers class org.infobip.mobile.messaging.geo.** implements java.io.Serializable {
static final long serialVersionUID;
static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
Expand Down
12 changes: 7 additions & 5 deletions infobip-mobile-messaging-huawei-sdk/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,29 @@
# Preserve all public classes, and their public and protected fields and
# methods.

-keep public class * {
-keep public class org.infobip.mobile.messaging.** {
public protected *;
}

# Preserve all .class method names.

-keepclassmembernames class * {
-keepclassmembernames class org.infobip.mobile.messaging.** {
java.lang.Class class$(java.lang.String);
java.lang.Class class$(java.lang.String, boolean);
}

-keepclassmembernames class org.infobip.mobile.messaging.mobileapi.common.ResultWrapper { *; }

# Preserve all native method names and the names of their classes.

-keepclasseswithmembernames class * {
-keepclasseswithmembernames class org.infobip.mobile.messaging.** {
native <methods>;
}

# Preserve the special static methods that are required in all enumeration
# classes.

-keepclassmembers class * extends java.lang.Enum {
-keepclassmembers class org.infobip.mobile.messaging.** extends java.lang.Enum {
<fields>;
public static **[] values();
public static ** valueOf(java.lang.String);
Expand All @@ -61,7 +63,7 @@
# If your code contains serializable classes that have to be backward
# compatible, please refer to the manual.

-keepclassmembers class * implements java.io.Serializable {
-keepclassmembers class org.infobip.mobile.messaging.** implements java.io.Serializable {
static final long serialVersionUID;
static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;

import fi.iki.elonen.NanoHTTPD;

Expand Down Expand Up @@ -110,4 +111,27 @@ public void shouldUseNewUrlForSecondRequest() {
assertTrue(e.getCause().getMessage().contains("customurl"));
}
}

@Test
public void shouldReplaceNotSupportedChars() {
Map<Integer, String> unsupportedCharCodes = new HashMap<Integer, String>();
unsupportedCharCodes.put(0x09,"&x09");
unsupportedCharCodes.put(0x0a,"&x0a");
unsupportedCharCodes.put(0x0b,"&x0b");
unsupportedCharCodes.put(0x0c,"&x0c");
unsupportedCharCodes.put(0x0d,"&x0d");
unsupportedCharCodes.put(0x11,"&x11");
unsupportedCharCodes.put(0x12, "&x12");
unsupportedCharCodes.put(0x13, "&x13");
unsupportedCharCodes.put(0x14, "&x14");

for (int charCode: unsupportedCharCodes.keySet()) {
char unsupported = (char) charCode;
String test = "someTest" + unsupported + "testEnd";
String should = "someTesttestEnd";
String result = mobileApiResourceProvider.removeNotSupportedChars(test);
assertEquals(result, should);
}
}

}

0 comments on commit b1614b7

Please sign in to comment.