Skip to content

Commit 4006cf6

Browse files
authoredApr 4, 2022
Merge pull request #787 from QuickBlox/sample-chat-java
4.2.8-chat-java
2 parents 686ea42 + ae87d09 commit 4006cf6

16 files changed

+229
-268
lines changed
 

‎sample-chat-java/app/build.gradle

+13-21
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,32 @@ buildscript {
22
repositories {
33
google()
44
mavenCentral()
5-
maven { url 'https://maven.fabric.io/public' }
6-
}
7-
8-
dependencies {
9-
classpath "io.fabric.tools:gradle:$rootProject.fabricToolsVersion"
105
}
116
}
127

138
apply plugin: 'com.android.application'
14-
apply plugin: 'io.fabric'
159

1610
repositories {
1711
google()
18-
jcenter()
12+
mavenCentral()
1913
maven {
2014
url "https://github.com/QuickBlox/quickblox-android-sdk-releases/raw/master/"
2115
}
22-
maven { url 'https://maven.fabric.io/public' }
23-
flatDir { dirs 'libs' }
2416
}
2517

2618
android {
2719
def versionQACode = 1
2820

29-
compileSdkVersion 29
30-
buildToolsVersion "29.0.3"
21+
compileSdkVersion 31
22+
buildToolsVersion "31.0.0"
3123
flavorDimensions dimensionDefault
3224

3325
defaultConfig {
3426
applicationId "com.quickblox.sample.chat.java"
35-
minSdkVersion 16
36-
targetSdkVersion 29
37-
versionCode 427000
38-
versionName '4.2.7-java'
27+
minSdkVersion 21
28+
targetSdkVersion 31
29+
versionCode 428000
30+
versionName '4.2.8-java'
3931
multiDexEnabled true
4032
}
4133

@@ -59,12 +51,14 @@ android {
5951
minifyEnabled false
6052
shrinkResources false
6153
proguardFile 'proguard-rules.pro'
62-
zipAlignEnabled false
6354
resValue "string", "versionName", "QuickBlox Chat Java\nBuild version " + defaultConfig.getVersionName()
6455
}
6556

6657
release {
6758
signingConfig signingConfigs.debug
59+
minifyEnabled true
60+
shrinkResources true
61+
proguardFile 'proguard-rules.pro'
6862
resValue "string", "versionName", "QuickBlox Chat Java\nBuild version " + defaultConfig.getVersionName()
6963
}
7064
}
@@ -101,11 +95,9 @@ dependencies {
10195

10296
implementation "com.timehop.stickyheadersrecyclerview:library:$rootProject.stickylistheadersVersion@aar"
10397
implementation "com.github.orangegangsters:swipy:$rootProject.swipyVersion@aar"
104-
implementation("com.crashlytics.sdk.android:crashlytics:$rootProject.crashlyticsVersion@aar") {
105-
transitive = true
106-
}
107-
implementation "android.arch.lifecycle:extensions:1.1.1"
108-
annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
98+
99+
implementation "android.arch.lifecycle:extensions:$rootProject.lifecircleExtensionVersion"
100+
annotationProcessor "androidx.lifecycle:lifecycle-common-java8:$rootProject.lifecircleCommonVersion"
109101
}
110102

111103
apply from: "../artifacts.gradle"

‎sample-chat-java/app/proguard-rules.pro

+11-35
Original file line numberDiff line numberDiff line change
@@ -23,48 +23,24 @@
2323
##---------------Begin: proguard configuration for Gson ----------
2424
# Gson uses generic type information stored in a class file when working with fields. Proguard
2525
# removes such information by default, so configure it to keep all of it.
26+
-keepattributes EnclosingMethod
27+
-keepattributes InnerClasses
2628
-keepattributes Signature
29+
-keepattributes Exceptions
2730

2831
# For using GSON @Expose annotation
2932
-keepattributes *Annotation*
3033

31-
# Gson specific classes
32-
-keep class sun.misc.Unsafe { *; }
33-
#-keep class com.google.gson.stream.** { *; }
34-
35-
# Application classes that will be serialized/deserialized over Gson
36-
-keep class com.quickblox.core.account.model.** { *; }
37-
38-
39-
##---------------End: proguard configuration for Gson ----------
40-
#quickblox sample chat
41-
42-
-keep class com.quickblox.auth.parsers.** { *; }
43-
-keep class com.quickblox.auth.model.** { *; }
44-
-keep class com.quickblox.core.parser.** { *; }
45-
-keep class com.quickblox.core.model.** { *; }
46-
-keep class com.quickblox.core.server.** { *; }
47-
-keep class com.quickblox.core.rest.** { *; }
48-
-keep class com.quickblox.core.error.** { *; }
49-
-keep class com.quickblox.core.Query { *; }
50-
51-
-keep class com.quickblox.users.parsers.** { *; }
52-
-keep class com.quickblox.users.model.** { *; }
53-
54-
-keep class com.quickblox.chat.parser.** { *; }
55-
-keep class com.quickblox.chat.model.** { *; }
56-
57-
-keep class com.quickblox.messages.parsers.** { *; }
58-
-keep class com.quickblox.messages.model.** { *; }
59-
60-
-keep class com.quickblox.content.parsers.** { *; }
61-
-keep class com.quickblox.content.model.** { *; }
34+
#quickblox sdk
35+
-keep class com.quickblox.** { *; }
6236

37+
#smack xmpp library
38+
-keep class org.jxmpp.** { *; }
6339
-keep class org.jivesoftware.** { *; }
40+
-dontwarn org.jivesoftware.**
6441

65-
#sample chat
66-
-keep class android.support.v7.** { *; }
42+
#glide
6743
-keep class com.bumptech.** { *; }
6844

69-
-dontwarn org.jivesoftware.smackx.**
70-
-dontwarn android.support.v4.app.**
45+
#google gms
46+
-keep class com.google.android.gms.** { *; }

‎sample-chat-java/app/src/main/AndroidManifest.xml

+7-7
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020
android:allowBackup="false"
2121
android:icon="@mipmap/ic_launcher_new"
2222
android:label="@string/app_name"
23+
android:requestLegacyExternalStorage="true"
2324
android:theme="@style/AppTheme"
24-
tools:ignore="GoogleAppIndexingWarning"
25-
android:requestLegacyExternalStorage="true">
25+
tools:ignore="GoogleAppIndexingWarning">
2626

2727
<activity
2828
android:name=".ui.activity.SplashActivity"
29+
android:exported="true"
2930
android:label="@string/app_name"
3031
android:screenOrientation="portrait">
3132

@@ -83,14 +84,16 @@
8384
android:screenOrientation="portrait" />
8485

8586
<service
86-
android:name=".fcm.PushListenerService">
87+
android:name=".fcm.PushListenerService"
88+
android:exported="false">
8789
<intent-filter>
8890
<action android:name="com.google.firebase.MESSAGING_EVENT" />
8991
</intent-filter>
9092
</service>
9193

9294
<service
93-
android:name="com.quickblox.messages.services.fcm.QBFcmPushInstanceIDService">
95+
android:name="com.quickblox.messages.services.fcm.QBFcmPushInstanceIDService"
96+
android:exported="false">
9497
<intent-filter>
9598
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
9699
</intent-filter>
@@ -121,8 +124,5 @@
121124
android:name="android.support.FILE_PROVIDER_PATHS"
122125
android:resource="@xml/provider_paths" />
123126
</provider>
124-
<meta-data
125-
android:name="io.fabric.ApiKey"
126-
android:value="4b96a3f33893a42103eae91d2166d0c517b833d3" />
127127
</application>
128128
</manifest>

‎sample-chat-java/app/src/main/java/com/quickblox/sample/chat/java/App.java

+2-11
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22

33
import android.app.Application;
44

5-
import com.crashlytics.android.Crashlytics;
5+
import androidx.lifecycle.ProcessLifecycleOwner;
6+
67
import com.quickblox.auth.session.QBSettings;
78
import com.quickblox.sample.chat.java.managers.BackgroundListener;
89
import com.quickblox.sample.chat.java.utils.ActivityLifecycle;
910

10-
import androidx.lifecycle.ProcessLifecycleOwner;
11-
import io.fabric.sdk.android.Fabric;
12-
1311
public class App extends Application {
1412

1513
//Chat settings
@@ -42,7 +40,6 @@ public void onCreate() {
4240
super.onCreate();
4341
initApplication();
4442
ActivityLifecycle.init(this);
45-
initFabric();
4643
checkAppCredentials();
4744
checkChatSettings();
4845
initCredentials();
@@ -53,12 +50,6 @@ private void initApplication() {
5350
instance = this;
5451
}
5552

56-
private void initFabric() {
57-
if (!BuildConfig.DEBUG) {
58-
Fabric.with(this, new Crashlytics());
59-
}
60-
}
61-
6253
private void checkAppCredentials() {
6354
if (APPLICATION_ID.isEmpty() || AUTH_KEY.isEmpty() || AUTH_SECRET.isEmpty() || ACCOUNT_KEY.isEmpty()) {
6455
throw new AssertionError(getString(R.string.error_qb_credentials_empty));

‎sample-chat-java/app/src/main/java/com/quickblox/sample/chat/java/ui/activity/AttachmentImageActivity.java

+9-14
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import android.content.Context;
44
import android.content.Intent;
55
import android.graphics.Bitmap;
6+
import android.graphics.drawable.BitmapDrawable;
7+
import android.graphics.drawable.Drawable;
68
import android.os.Build;
79
import android.os.Bundle;
810
import android.provider.MediaStore;
@@ -14,13 +16,11 @@
1416
import android.widget.ProgressBar;
1517

1618
import com.bumptech.glide.Glide;
17-
import com.bumptech.glide.load.engine.DiskCacheStrategy;
18-
import com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable;
19-
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
19+
import com.bumptech.glide.load.DataSource;
20+
import com.bumptech.glide.load.engine.GlideException;
2021
import com.bumptech.glide.request.RequestListener;
2122
import com.bumptech.glide.request.target.Target;
2223
import com.quickblox.sample.chat.java.R;
23-
import com.quickblox.sample.chat.java.utils.ImageUtils;
2424
import com.quickblox.sample.chat.java.utils.ToastUtils;
2525

2626
public class AttachmentImageActivity extends BaseActivity {
@@ -83,7 +83,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
8383
private void saveFileToGallery() {
8484
if (imageLoaded) {
8585
try {
86-
Bitmap bitmapToSave = ((GlideBitmapDrawable) imageView.getDrawable().getCurrent()).getBitmap();
86+
Bitmap bitmapToSave = ((BitmapDrawable) imageView.getDrawable().getCurrent()).getBitmap();
8787
MediaStore.Images.Media.insertImage(getContentResolver(), bitmapToSave, "attachment", "");
8888
ToastUtils.shortToast("Image saved to the Gallery");
8989
} catch (Exception e) {
@@ -103,30 +103,25 @@ private void loadImage() {
103103

104104
Glide.with(this)
105105
.load(url)
106-
.diskCacheStrategy(DiskCacheStrategy.ALL)
107106
.listener(new DrawableListener())
108-
.error(R.drawable.ic_error_white)
109-
.dontTransform()
110-
.override(ImageUtils.PREFERRED_IMAGE_SIZE_FULL, ImageUtils.PREFERRED_IMAGE_SIZE_FULL)
111107
.into(imageView);
112108
}
113109

114-
private class DrawableListener implements RequestListener<String, GlideDrawable> {
115-
110+
private class DrawableListener implements RequestListener<Drawable> {
116111
@Override
117-
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
112+
public boolean onLoadFailed(GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
118113
if (e != null && e.getMessage() != null) {
119114
Log.d("Glide Drawable", e.getMessage());
120115
} else {
121-
e = new Exception("Unable to load image");
116+
e = new GlideException("Unable to load image");
122117
}
123118
showErrorSnackbar(R.string.error_load_image, e, null);
124119
progressBar.setVisibility(View.GONE);
125120
return false;
126121
}
127122

128123
@Override
129-
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
124+
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
130125
progressBar.setVisibility(View.GONE);
131126
imageLoaded = true;
132127
return false;

0 commit comments

Comments
 (0)
Please sign in to comment.