Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
zetbaitsu committed Mar 1, 2017
2 parents acd52a3 + 90535e1 commit 5565988
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
2 changes: 1 addition & 1 deletion chat/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
10 changes: 10 additions & 0 deletions chat/src/main/java/com/qiscus/sdk/data/model/QiscusChatConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -493,4 +499,8 @@ public boolean isOnlyEnablePushNotificationOutsideChatRoom() {
public Drawable getChatRoomBackground() {
return chatRoomBackground;
}

public QiscusImageCompressionConfig getQiscusImageCompressionConfig() {
return qiscusImageCompressionConfig;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
7 changes: 4 additions & 3 deletions chat/src/main/java/com/qiscus/sdk/util/QiscusImageUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 5565988

Please sign in to comment.