Skip to content

Commit

Permalink
Release 2.12.0
Browse files Browse the repository at this point in the history
Release 2.12.0
  • Loading branch information
prateek-kommunicate authored Dec 26, 2024
2 parents fb13996 + 2dbd537 commit b906b94
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 36 deletions.
2 changes: 1 addition & 1 deletion kommunicate/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ android {
compileSdk 34
targetSdkVersion 34
versionCode 1
versionName "2.11.1"
versionName "2.12.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField "String", "KOMMUNICATE_VERSION", "\"" + versionName + "\""
buildConfigField "String", "CHAT_SERVER_URL", '"https://chat.kommunicate.io"'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public static void launchChat(final KmChatBuilder launchChat, final KmCallback c
}
} else {
if (!TextUtils.isEmpty(launchChat.getApplicationId())) {
Kommunicate.init(launchChat.getContext(), launchChat.getApplicationId(), KmAppSettingPreferences.getInstance().isRootDetectionEnabled());
Kommunicate.init(launchChat.getContext(), launchChat.getApplicationId(), KmAppSettingPreferences.isRootDetectionEnabled());
} else {
if (TextUtils.isEmpty(Applozic.getInstance(launchChat.getContext()).getApplicationKey())) {
if (callback != null) {
Expand Down Expand Up @@ -265,7 +265,7 @@ public static void createChat(final KmChatBuilder launchChat, final KmCallback c
}
} else {
if (!TextUtils.isEmpty(launchChat.getApplicationId())) {
Kommunicate.init(launchChat.getContext(), launchChat.getApplicationId(), KmAppSettingPreferences.getInstance().isRootDetectionEnabled());
Kommunicate.init(launchChat.getContext(), launchChat.getApplicationId(), KmAppSettingPreferences.isRootDetectionEnabled());
} else {
if (TextUtils.isEmpty(Applozic.getInstance(launchChat.getContext()).getApplicationKey())) {
if (callback != null) {
Expand Down Expand Up @@ -465,7 +465,7 @@ public static void createOrLaunchConversation(final KmConversationBuilder conver
}
} else {
if (!TextUtils.isEmpty(conversationBuilder.getAppId())) {
Kommunicate.init(conversationBuilder.getContext(), conversationBuilder.getAppId(), KmAppSettingPreferences.getInstance().isRootDetectionEnabled());
Kommunicate.init(conversationBuilder.getContext(), conversationBuilder.getAppId(), KmAppSettingPreferences.isRootDetectionEnabled());
} else {
if (TextUtils.isEmpty(Applozic.getInstance(conversationBuilder.getContext()).getApplicationKey())) {
if (callback != null) {
Expand Down
6 changes: 5 additions & 1 deletion kommunicate/src/main/java/io/kommunicate/Kommunicate.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,18 @@ public static void init(Context context, String applicationKey, Boolean enableDe
} else {
Applozic.init(context, applicationKey);
}
KmAppSettingPreferences.getInstance().setRootDetection(enableDeviceRootDetection);
KmAppSettingPreferences.setRootDetection(enableDeviceRootDetection);
configureSentryWithKommunicate(context);
}

public static void init(Context context, String applicationKey) {
init(context, applicationKey, true);
}

public static void enableSSLPinning(boolean isEnable) {
KmAppSettingPreferences.setSSLPinningEnabled(isEnable);
}

public static void login(final Context context, final KMUser kmUser, final KMLoginHandler handler) {
configureSentryWithKommunicate(context);
if(KmUtils.isDeviceRooted() && handler != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package io.kommunicate.network
import android.annotation.SuppressLint
import android.util.Base64
import io.kommunicate.BuildConfig
import io.kommunicate.utils.KmAppSettingPreferences
import io.kommunicate.utils.KmUtils
import java.security.KeyManagementException
import java.security.MessageDigest
Expand Down Expand Up @@ -59,7 +60,8 @@ object SSLPinningConfig {
val publicKeyHash = md.digest(publicKeyBytes)
val publicKeyHashBase64 = Base64.encodeToString(publicKeyHash, Base64.NO_WRAP)

if (!expectedPublicKeyHash.contains(publicKeyHashBase64)) {
val isSSLPinningEnabled = KmAppSettingPreferences.isSSLPinningEnabled
if (isSSLPinningEnabled && !expectedPublicKeyHash.contains(publicKeyHashBase64)) {
throw CertificateException("Public key pinning failure")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ object KmAppSettingPreferences {
private const val UPLOAD_OVERRIDE_HEADER = "UPLOAD_OVERRIDE_HEADER"
private const val SINGLE_THREADED = "IS_SINGLE_THREADED"
private const val ROOT_DETECTION = "ROOT_DETECTION"
private const val SSL_PINNING = "SSL_PINNING"
private const val RATING_BASE = "RATING_BASE"

@JvmStatic
Expand All @@ -51,9 +52,17 @@ object KmAppSettingPreferences {
.getSharedPreferences(MobiComUserPreference.AL_USER_PREF_KEY, Context.MODE_PRIVATE)
}

@JvmStatic
val isRootDetectionEnabled: Boolean
get() = preferences.getBoolean(ROOT_DETECTION, true)

@JvmStatic
var isSSLPinningEnabled: Boolean
get() = preferences.getBoolean(SSL_PINNING, false)
set(isEnabled) {
preferences.edit().putBoolean(SSL_PINNING, isEnabled).apply()
}

var primaryColor: String?
get() = preferences.getString(KM_THEME_PRIMARY_COLOR, null)
private set(color) {
Expand Down Expand Up @@ -100,6 +109,7 @@ object KmAppSettingPreferences {
preferences.edit().putString(UPLOAD_OVERRIDE_URL, url).apply()
}

@JvmStatic
var ratingBase: Int
get() = preferences.getInt(RATING_BASE, 3)
private set(base) {
Expand Down
2 changes: 1 addition & 1 deletion kommunicateui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ android {
targetSdkVersion 34
minSdkVersion 21
versionCode 1
versionName "2.11.1"
versionName "2.12.0"
buildToolsVersion = '34.0.0'
consumerProguardFiles 'proguard-rules.txt'
vectorDrawables.useSupportLibrary = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@
import io.kommunicate.utils.KmAppSettingPreferences;
import io.kommunicate.utils.KmConstants;
import io.kommunicate.utils.KmUtils;
import io.sentry.Hint;
import io.sentry.Sentry;

import static android.view.View.GONE;
import static android.view.View.VISIBLE;
Expand Down Expand Up @@ -475,39 +477,52 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
} else if (type == 6) {
MyViewHolder6 myViewholder6 = (MyViewHolder6) holder;
if (message.getMetadata() != null) {
JSONObject jsonObject = new JSONObject(message.getMetadata().get(FEEDBACK));
int ratingValue = (int) jsonObject.get(RATING);
switch (ratingValue) {
case FeedbackInputFragment.RATING_POOR:
myViewholder6.imageViewFeedbackRating.setImageDrawable(ContextCompat.getDrawable(context, com.applozic.mobicomkit.uiwidgets.R.drawable.ic_sad_1));
break;
case FeedbackInputFragment.RATING_AVERAGE:
myViewholder6.imageViewFeedbackRating.setImageDrawable(ContextCompat.getDrawable(context, com.applozic.mobicomkit.uiwidgets.R.drawable.ic_confused));
break;
case FeedbackInputFragment.RATING_GOOD:
myViewholder6.imageViewFeedbackRating.setImageDrawable(ContextCompat.getDrawable(context, com.applozic.mobicomkit.uiwidgets.R.drawable.ic_happy));
break;
default:
myViewholder6.imageViewFeedbackRating.setImageDrawable(ContextCompat.getDrawable(context, com.applozic.mobicomkit.uiwidgets.R.drawable.ic_confused));

}
if (!jsonObject.has(COMMENTS)) {
myViewholder6.scrollViewFeedbackCommentWrap.setVisibility(GONE);
String json = message.getMetadata().get(FEEDBACK);
if (json == null) {
Sentry.captureException(new RuntimeException("Unable to find feedback in message of type feedback message " + message));
return;
}
String comment = String.valueOf(jsonObject.get(COMMENTS));
myViewholder6.scrollViewFeedbackCommentWrap.setVisibility(View.VISIBLE);
myViewholder6.textViewFeedbackComment.setText(comment);
if (alCustomizationSettings.isAgentApp()) {
myViewholder6.textViewFeedbackText.setText(context.getString(R.string.user_rating_text));

JSONObject jsonObject = new JSONObject(json);
int ratingValue = (int) jsonObject.get(RATING);

if (KmAppSettingPreferences.getRatingBase() != 3) {
switch (ratingValue) {
case 1:
myViewholder6.imageViewFeedbackRating.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.star));
break;
case 2:
myViewholder6.imageViewFeedbackRating.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_two_star_filled));
break;
case 4:
myViewholder6.imageViewFeedbackRating.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_four_star_filled));
break;
case 5:
myViewholder6.imageViewFeedbackRating.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_five_star_filled));
break;
default:
myViewholder6.imageViewFeedbackRating.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_three_star_filled));
}
if (alCustomizationSettings.isAgentApp()) {
myViewholder6.textViewFeedbackText.setText(context.getString(R.string.user_rating_text));
myViewholder6.textViewFeedbackText.setVisibility(View.VISIBLE);

} else {
myViewholder6.textViewFeedbackText.setText("");
myViewholder6.textViewFeedbackText.setVisibility(GONE);
}
if (!jsonObject.has(COMMENTS)) {
myViewholder6.scrollViewFeedbackCommentWrap.setVisibility(GONE);
return;
}
String comment = String.valueOf(jsonObject.get(COMMENTS));
myViewholder6.scrollViewFeedbackCommentWrap.setVisibility(View.VISIBLE);
myViewholder6.textViewFeedbackComment.setText(comment);
} else {
switch (ratingValue) {
case FeedbackInputFragment.RATING_POOR:
myViewholder6.imageViewFeedbackRating.setImageDrawable(ContextCompat.getDrawable(context, com.applozic.mobicomkit.uiwidgets.R.drawable.ic_sad_1));
break;
case FeedbackInputFragment.RATING_AVERAGE:
myViewholder6.imageViewFeedbackRating.setImageDrawable(ContextCompat.getDrawable(context, com.applozic.mobicomkit.uiwidgets.R.drawable.ic_confused));
break;
case FeedbackInputFragment.RATING_GOOD:
myViewholder6.imageViewFeedbackRating.setImageDrawable(ContextCompat.getDrawable(context, com.applozic.mobicomkit.uiwidgets.R.drawable.ic_happy));
break;
Expand All @@ -517,10 +532,11 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
}
myViewholder6.textViewFeedbackText.setVisibility(View.VISIBLE);

if (!jsonObject.has("comments")) {
if (!jsonObject.has(COMMENTS)) {
myViewholder6.scrollViewFeedbackCommentWrap.setVisibility(GONE);
return;
}
String comment = String.valueOf(jsonObject.get(COMMENTS));
myViewholder6.scrollViewFeedbackCommentWrap.setVisibility(View.VISIBLE);
myViewholder6.textViewFeedbackComment.setText(comment);

Expand All @@ -543,7 +559,9 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
bindMessageView(holder, message, position);
}
} catch (Exception e) {
e.printStackTrace();
Hint hint = new Hint();
hint.set("MESSAGE", message);
Sentry.captureException(e, hint);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,7 @@ public void openEmojiFeedbackFragment() {
}

public void openFeedbackFragment() {
if (KmAppSettingPreferences.getInstance().getRatingBase() != 3) {
if (KmAppSettingPreferences.getRatingBase() == 5) {
openFiveStarRatingFragment();
} else {
openEmojiFeedbackFragment();
Expand Down

0 comments on commit b906b94

Please sign in to comment.