diff --git a/README.md b/README.md index 5cc60b998..15cd606b2 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ allprojects { Then add to your app module build.gradle ```groovy dependencies { - compile 'com.qiscus.sdk:chat:1.10.7' + compile 'com.qiscus.sdk:chat:1.10.8' } ``` # Let's make cools chatting apps! diff --git a/chat/build.gradle b/chat/build.gradle index 7901ca373..573d6506f 100644 --- a/chat/build.gradle +++ b/chat/build.gradle @@ -32,7 +32,7 @@ ext { siteUrl = 'https://github.com/qiscus/qiscus-sdk-android' gitUrl = 'https://github.com/qiscus/qiscus-sdk-android.git' - libraryVersion = '1.10.7' + libraryVersion = '1.10.8' developerId = 'qiscustech' developerName = 'Qiscus Tech' diff --git a/chat/src/main/java/com/qiscus/sdk/data/model/QiscusChatConfig.java b/chat/src/main/java/com/qiscus/sdk/data/model/QiscusChatConfig.java index a5c4ea143..268946e50 100644 --- a/chat/src/main/java/com/qiscus/sdk/data/model/QiscusChatConfig.java +++ b/chat/src/main/java/com/qiscus/sdk/data/model/QiscusChatConfig.java @@ -73,6 +73,7 @@ public class QiscusChatConfig { private int[] swipeRefreshColorScheme = new int[]{R.color.qiscus_primary, R.color.qiscus_accent}; private int notificationSmallIcon = R.drawable.ic_qiscus_notif_app; private int notificationBigIcon = R.drawable.ic_qiscus_notif_app; + private QiscusImageCompressionConfig qiscusImageCompressionConfig = new QiscusImageCompressionConfig(); private NotificationTitleHandler notificationTitleHandler = qiscusComment -> qiscusComment.isGroupMessage() ? qiscusComment.getRoomName() : qiscusComment.getSender(); @@ -304,6 +305,11 @@ public QiscusChatConfig setChatRoomBackground(Drawable chatRoomBackground) { return this; } + public QiscusChatConfig setQiscusImageCompressionConfig(QiscusImageCompressionConfig qiscusImageCompressionConfig) { + this.qiscusImageCompressionConfig = qiscusImageCompressionConfig; + return this; + } + @ColorRes public int getStatusBarColor() { return statusBarColor; @@ -493,4 +499,8 @@ public boolean isOnlyEnablePushNotificationOutsideChatRoom() { public Drawable getChatRoomBackground() { return chatRoomBackground; } + + public QiscusImageCompressionConfig getQiscusImageCompressionConfig() { + return qiscusImageCompressionConfig; + } } diff --git a/chat/src/main/java/com/qiscus/sdk/data/model/QiscusImageCompressionConfig.java b/chat/src/main/java/com/qiscus/sdk/data/model/QiscusImageCompressionConfig.java new file mode 100644 index 000000000..4ca99706e --- /dev/null +++ b/chat/src/main/java/com/qiscus/sdk/data/model/QiscusImageCompressionConfig.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2016 Qiscus. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.qiscus.sdk.data.model; + +/** + * Created on : March 01, 2017 + * Author : zetbaitsu + * Name : Zetra + * GitHub : https://github.com/zetbaitsu + */ +public class QiscusImageCompressionConfig { + private float maxHeight = 900.0f; + private float maxWidth = 1440.0f; + private int quality = 80; + + public QiscusImageCompressionConfig() { + + } + + public QiscusImageCompressionConfig(float maxHeight, float maxWidth, int quality) { + this.maxHeight = maxHeight; + this.maxWidth = maxWidth; + this.quality = quality; + } + + public QiscusImageCompressionConfig setMaxHeight(float maxHeight) { + this.maxHeight = maxHeight; + return this; + } + + public QiscusImageCompressionConfig setMaxWidth(float maxWidth) { + this.maxWidth = maxWidth; + return this; + } + + public QiscusImageCompressionConfig setQuality(int quality) { + this.quality = quality; + return this; + } + + public float getMaxHeight() { + return maxHeight; + } + + public float getMaxWidth() { + return maxWidth; + } + + public int getQuality() { + return quality; + } +} diff --git a/chat/src/main/java/com/qiscus/sdk/util/QiscusImageUtil.java b/chat/src/main/java/com/qiscus/sdk/util/QiscusImageUtil.java index ec2044237..981a63a29 100644 --- a/chat/src/main/java/com/qiscus/sdk/util/QiscusImageUtil.java +++ b/chat/src/main/java/com/qiscus/sdk/util/QiscusImageUtil.java @@ -68,8 +68,8 @@ public static Bitmap getScaledBitmap(Uri imageUri) { } //max Height and width values of the compressed image is taken as 1440x900 - float maxHeight = 900.0f; - float maxWidth = 1440.0f; + float maxHeight = Qiscus.getChatConfig().getQiscusImageCompressionConfig().getMaxHeight(); + float maxWidth = Qiscus.getChatConfig().getQiscusImageCompressionConfig().getMaxWidth(); float imgRatio = actualWidth / actualHeight; float maxRatio = maxWidth / maxHeight; @@ -158,7 +158,8 @@ public static File compressImage(Uri imageUri, int topicId) { out = new FileOutputStream(filename); //write the compressed bitmap at the destination specified by filename. - QiscusImageUtil.getScaledBitmap(imageUri).compress(Bitmap.CompressFormat.JPEG, 80, out); + QiscusImageUtil.getScaledBitmap(imageUri).compress(Bitmap.CompressFormat.JPEG, + Qiscus.getChatConfig().getQiscusImageCompressionConfig().getQuality(), out); } catch (FileNotFoundException e) { e.printStackTrace();