Skip to content

Commit b906b94

Browse files
Release 2.12.0
Release 2.12.0
2 parents fb13996 + 2dbd537 commit b906b94

File tree

8 files changed

+70
-36
lines changed

8 files changed

+70
-36
lines changed

kommunicate/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ android {
1818
compileSdk 34
1919
targetSdkVersion 34
2020
versionCode 1
21-
versionName "2.11.1"
21+
versionName "2.12.0"
2222
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2323
buildConfigField "String", "KOMMUNICATE_VERSION", "\"" + versionName + "\""
2424
buildConfigField "String", "CHAT_SERVER_URL", '"https://chat.kommunicate.io"'

kommunicate/src/main/java/io/kommunicate/KmConversationHelper.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public static void launchChat(final KmChatBuilder launchChat, final KmCallback c
188188
}
189189
} else {
190190
if (!TextUtils.isEmpty(launchChat.getApplicationId())) {
191-
Kommunicate.init(launchChat.getContext(), launchChat.getApplicationId(), KmAppSettingPreferences.getInstance().isRootDetectionEnabled());
191+
Kommunicate.init(launchChat.getContext(), launchChat.getApplicationId(), KmAppSettingPreferences.isRootDetectionEnabled());
192192
} else {
193193
if (TextUtils.isEmpty(Applozic.getInstance(launchChat.getContext()).getApplicationKey())) {
194194
if (callback != null) {
@@ -265,7 +265,7 @@ public static void createChat(final KmChatBuilder launchChat, final KmCallback c
265265
}
266266
} else {
267267
if (!TextUtils.isEmpty(launchChat.getApplicationId())) {
268-
Kommunicate.init(launchChat.getContext(), launchChat.getApplicationId(), KmAppSettingPreferences.getInstance().isRootDetectionEnabled());
268+
Kommunicate.init(launchChat.getContext(), launchChat.getApplicationId(), KmAppSettingPreferences.isRootDetectionEnabled());
269269
} else {
270270
if (TextUtils.isEmpty(Applozic.getInstance(launchChat.getContext()).getApplicationKey())) {
271271
if (callback != null) {
@@ -465,7 +465,7 @@ public static void createOrLaunchConversation(final KmConversationBuilder conver
465465
}
466466
} else {
467467
if (!TextUtils.isEmpty(conversationBuilder.getAppId())) {
468-
Kommunicate.init(conversationBuilder.getContext(), conversationBuilder.getAppId(), KmAppSettingPreferences.getInstance().isRootDetectionEnabled());
468+
Kommunicate.init(conversationBuilder.getContext(), conversationBuilder.getAppId(), KmAppSettingPreferences.isRootDetectionEnabled());
469469
} else {
470470
if (TextUtils.isEmpty(Applozic.getInstance(conversationBuilder.getContext()).getApplicationKey())) {
471471
if (callback != null) {

kommunicate/src/main/java/io/kommunicate/Kommunicate.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,18 @@ public static void init(Context context, String applicationKey, Boolean enableDe
124124
} else {
125125
Applozic.init(context, applicationKey);
126126
}
127-
KmAppSettingPreferences.getInstance().setRootDetection(enableDeviceRootDetection);
127+
KmAppSettingPreferences.setRootDetection(enableDeviceRootDetection);
128128
configureSentryWithKommunicate(context);
129129
}
130130

131131
public static void init(Context context, String applicationKey) {
132132
init(context, applicationKey, true);
133133
}
134134

135+
public static void enableSSLPinning(boolean isEnable) {
136+
KmAppSettingPreferences.setSSLPinningEnabled(isEnable);
137+
}
138+
135139
public static void login(final Context context, final KMUser kmUser, final KMLoginHandler handler) {
136140
configureSentryWithKommunicate(context);
137141
if(KmUtils.isDeviceRooted() && handler != null) {

kommunicate/src/main/java/io/kommunicate/network/SSLPinningConfig.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package io.kommunicate.network
33
import android.annotation.SuppressLint
44
import android.util.Base64
55
import io.kommunicate.BuildConfig
6+
import io.kommunicate.utils.KmAppSettingPreferences
67
import io.kommunicate.utils.KmUtils
78
import java.security.KeyManagementException
89
import java.security.MessageDigest
@@ -59,7 +60,8 @@ object SSLPinningConfig {
5960
val publicKeyHash = md.digest(publicKeyBytes)
6061
val publicKeyHashBase64 = Base64.encodeToString(publicKeyHash, Base64.NO_WRAP)
6162

62-
if (!expectedPublicKeyHash.contains(publicKeyHashBase64)) {
63+
val isSSLPinningEnabled = KmAppSettingPreferences.isSSLPinningEnabled
64+
if (isSSLPinningEnabled && !expectedPublicKeyHash.contains(publicKeyHashBase64)) {
6365
throw CertificateException("Public key pinning failure")
6466
}
6567
}

kommunicate/src/main/java/io/kommunicate/utils/KmAppSettingPreferences.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ object KmAppSettingPreferences {
2929
private const val UPLOAD_OVERRIDE_HEADER = "UPLOAD_OVERRIDE_HEADER"
3030
private const val SINGLE_THREADED = "IS_SINGLE_THREADED"
3131
private const val ROOT_DETECTION = "ROOT_DETECTION"
32+
private const val SSL_PINNING = "SSL_PINNING"
3233
private const val RATING_BASE = "RATING_BASE"
3334

3435
@JvmStatic
@@ -51,9 +52,17 @@ object KmAppSettingPreferences {
5152
.getSharedPreferences(MobiComUserPreference.AL_USER_PREF_KEY, Context.MODE_PRIVATE)
5253
}
5354

55+
@JvmStatic
5456
val isRootDetectionEnabled: Boolean
5557
get() = preferences.getBoolean(ROOT_DETECTION, true)
5658

59+
@JvmStatic
60+
var isSSLPinningEnabled: Boolean
61+
get() = preferences.getBoolean(SSL_PINNING, false)
62+
set(isEnabled) {
63+
preferences.edit().putBoolean(SSL_PINNING, isEnabled).apply()
64+
}
65+
5766
var primaryColor: String?
5867
get() = preferences.getString(KM_THEME_PRIMARY_COLOR, null)
5968
private set(color) {
@@ -100,6 +109,7 @@ object KmAppSettingPreferences {
100109
preferences.edit().putString(UPLOAD_OVERRIDE_URL, url).apply()
101110
}
102111

112+
@JvmStatic
103113
var ratingBase: Int
104114
get() = preferences.getInt(RATING_BASE, 3)
105115
private set(base) {

kommunicateui/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ android {
1616
targetSdkVersion 34
1717
minSdkVersion 21
1818
versionCode 1
19-
versionName "2.11.1"
19+
versionName "2.12.0"
2020
buildToolsVersion = '34.0.0'
2121
consumerProguardFiles 'proguard-rules.txt'
2222
vectorDrawables.useSupportLibrary = true

kommunicateui/src/main/java/com/applozic/mobicomkit/uiwidgets/conversation/adapter/DetailedConversationAdapter.java

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@
128128
import io.kommunicate.utils.KmAppSettingPreferences;
129129
import io.kommunicate.utils.KmConstants;
130130
import io.kommunicate.utils.KmUtils;
131+
import io.sentry.Hint;
132+
import io.sentry.Sentry;
131133

132134
import static android.view.View.GONE;
133135
import static android.view.View.VISIBLE;
@@ -475,39 +477,52 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
475477
} else if (type == 6) {
476478
MyViewHolder6 myViewholder6 = (MyViewHolder6) holder;
477479
if (message.getMetadata() != null) {
478-
JSONObject jsonObject = new JSONObject(message.getMetadata().get(FEEDBACK));
479-
int ratingValue = (int) jsonObject.get(RATING);
480-
switch (ratingValue) {
481-
case FeedbackInputFragment.RATING_POOR:
482-
myViewholder6.imageViewFeedbackRating.setImageDrawable(ContextCompat.getDrawable(context, com.applozic.mobicomkit.uiwidgets.R.drawable.ic_sad_1));
483-
break;
484-
case FeedbackInputFragment.RATING_AVERAGE:
485-
myViewholder6.imageViewFeedbackRating.setImageDrawable(ContextCompat.getDrawable(context, com.applozic.mobicomkit.uiwidgets.R.drawable.ic_confused));
486-
break;
487-
case FeedbackInputFragment.RATING_GOOD:
488-
myViewholder6.imageViewFeedbackRating.setImageDrawable(ContextCompat.getDrawable(context, com.applozic.mobicomkit.uiwidgets.R.drawable.ic_happy));
489-
break;
490-
default:
491-
myViewholder6.imageViewFeedbackRating.setImageDrawable(ContextCompat.getDrawable(context, com.applozic.mobicomkit.uiwidgets.R.drawable.ic_confused));
492-
493-
}
494-
if (!jsonObject.has(COMMENTS)) {
495-
myViewholder6.scrollViewFeedbackCommentWrap.setVisibility(GONE);
480+
String json = message.getMetadata().get(FEEDBACK);
481+
if (json == null) {
482+
Sentry.captureException(new RuntimeException("Unable to find feedback in message of type feedback message " + message));
496483
return;
497484
}
498-
String comment = String.valueOf(jsonObject.get(COMMENTS));
499-
myViewholder6.scrollViewFeedbackCommentWrap.setVisibility(View.VISIBLE);
500-
myViewholder6.textViewFeedbackComment.setText(comment);
501-
if (alCustomizationSettings.isAgentApp()) {
502-
myViewholder6.textViewFeedbackText.setText(context.getString(R.string.user_rating_text));
485+
486+
JSONObject jsonObject = new JSONObject(json);
487+
int ratingValue = (int) jsonObject.get(RATING);
488+
489+
if (KmAppSettingPreferences.getRatingBase() != 3) {
490+
switch (ratingValue) {
491+
case 1:
492+
myViewholder6.imageViewFeedbackRating.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.star));
493+
break;
494+
case 2:
495+
myViewholder6.imageViewFeedbackRating.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_two_star_filled));
496+
break;
497+
case 4:
498+
myViewholder6.imageViewFeedbackRating.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_four_star_filled));
499+
break;
500+
case 5:
501+
myViewholder6.imageViewFeedbackRating.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_five_star_filled));
502+
break;
503+
default:
504+
myViewholder6.imageViewFeedbackRating.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_three_star_filled));
505+
}
506+
if (alCustomizationSettings.isAgentApp()) {
507+
myViewholder6.textViewFeedbackText.setText(context.getString(R.string.user_rating_text));
508+
myViewholder6.textViewFeedbackText.setVisibility(View.VISIBLE);
509+
510+
} else {
511+
myViewholder6.textViewFeedbackText.setText("");
512+
myViewholder6.textViewFeedbackText.setVisibility(GONE);
513+
}
514+
if (!jsonObject.has(COMMENTS)) {
515+
myViewholder6.scrollViewFeedbackCommentWrap.setVisibility(GONE);
516+
return;
517+
}
518+
String comment = String.valueOf(jsonObject.get(COMMENTS));
519+
myViewholder6.scrollViewFeedbackCommentWrap.setVisibility(View.VISIBLE);
520+
myViewholder6.textViewFeedbackComment.setText(comment);
503521
} else {
504522
switch (ratingValue) {
505523
case FeedbackInputFragment.RATING_POOR:
506524
myViewholder6.imageViewFeedbackRating.setImageDrawable(ContextCompat.getDrawable(context, com.applozic.mobicomkit.uiwidgets.R.drawable.ic_sad_1));
507525
break;
508-
case FeedbackInputFragment.RATING_AVERAGE:
509-
myViewholder6.imageViewFeedbackRating.setImageDrawable(ContextCompat.getDrawable(context, com.applozic.mobicomkit.uiwidgets.R.drawable.ic_confused));
510-
break;
511526
case FeedbackInputFragment.RATING_GOOD:
512527
myViewholder6.imageViewFeedbackRating.setImageDrawable(ContextCompat.getDrawable(context, com.applozic.mobicomkit.uiwidgets.R.drawable.ic_happy));
513528
break;
@@ -517,10 +532,11 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
517532
}
518533
myViewholder6.textViewFeedbackText.setVisibility(View.VISIBLE);
519534

520-
if (!jsonObject.has("comments")) {
535+
if (!jsonObject.has(COMMENTS)) {
521536
myViewholder6.scrollViewFeedbackCommentWrap.setVisibility(GONE);
522537
return;
523538
}
539+
String comment = String.valueOf(jsonObject.get(COMMENTS));
524540
myViewholder6.scrollViewFeedbackCommentWrap.setVisibility(View.VISIBLE);
525541
myViewholder6.textViewFeedbackComment.setText(comment);
526542

@@ -543,7 +559,9 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
543559
bindMessageView(holder, message, position);
544560
}
545561
} catch (Exception e) {
546-
e.printStackTrace();
562+
Hint hint = new Hint();
563+
hint.set("MESSAGE", message);
564+
Sentry.captureException(e, hint);
547565
}
548566
}
549567

kommunicateui/src/main/java/com/applozic/mobicomkit/uiwidgets/conversation/fragment/MobiComConversationFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ public void openEmojiFeedbackFragment() {
13581358
}
13591359

13601360
public void openFeedbackFragment() {
1361-
if (KmAppSettingPreferences.getInstance().getRatingBase() != 3) {
1361+
if (KmAppSettingPreferences.getRatingBase() == 5) {
13621362
openFiveStarRatingFragment();
13631363
} else {
13641364
openEmojiFeedbackFragment();

0 commit comments

Comments
 (0)