Skip to content

Commit

Permalink
Merge pull request #787 from QuickBlox/sample-chat-java
Browse files Browse the repository at this point in the history
4.2.8-chat-java
  • Loading branch information
kirillTolmachev authored Apr 4, 2022
2 parents 686ea42 + ae87d09 commit 4006cf6
Show file tree
Hide file tree
Showing 16 changed files with 229 additions and 268 deletions.
34 changes: 13 additions & 21 deletions sample-chat-java/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,32 @@ buildscript {
repositories {
google()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}

dependencies {
classpath "io.fabric.tools:gradle:$rootProject.fabricToolsVersion"
}
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
google()
jcenter()
mavenCentral()
maven {
url "https://github.com/QuickBlox/quickblox-android-sdk-releases/raw/master/"
}
maven { url 'https://maven.fabric.io/public' }
flatDir { dirs 'libs' }
}

android {
def versionQACode = 1

compileSdkVersion 29
buildToolsVersion "29.0.3"
compileSdkVersion 31
buildToolsVersion "31.0.0"
flavorDimensions dimensionDefault

defaultConfig {
applicationId "com.quickblox.sample.chat.java"
minSdkVersion 16
targetSdkVersion 29
versionCode 427000
versionName '4.2.7-java'
minSdkVersion 21
targetSdkVersion 31
versionCode 428000
versionName '4.2.8-java'
multiDexEnabled true
}

Expand All @@ -59,12 +51,14 @@ android {
minifyEnabled false
shrinkResources false
proguardFile 'proguard-rules.pro'
zipAlignEnabled false
resValue "string", "versionName", "QuickBlox Chat Java\nBuild version " + defaultConfig.getVersionName()
}

release {
signingConfig signingConfigs.debug
minifyEnabled true
shrinkResources true
proguardFile 'proguard-rules.pro'
resValue "string", "versionName", "QuickBlox Chat Java\nBuild version " + defaultConfig.getVersionName()
}
}
Expand Down Expand Up @@ -101,11 +95,9 @@ dependencies {

implementation "com.timehop.stickyheadersrecyclerview:library:$rootProject.stickylistheadersVersion@aar"
implementation "com.github.orangegangsters:swipy:$rootProject.swipyVersion@aar"
implementation("com.crashlytics.sdk.android:crashlytics:$rootProject.crashlyticsVersion@aar") {
transitive = true
}
implementation "android.arch.lifecycle:extensions:1.1.1"
annotationProcessor "android.arch.lifecycle:compiler:1.1.1"

implementation "android.arch.lifecycle:extensions:$rootProject.lifecircleExtensionVersion"
annotationProcessor "androidx.lifecycle:lifecycle-common-java8:$rootProject.lifecircleCommonVersion"
}

apply from: "../artifacts.gradle"
Expand Down
46 changes: 11 additions & 35 deletions sample-chat-java/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -23,48 +23,24 @@
##---------------Begin: proguard configuration for Gson ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes EnclosingMethod
-keepattributes InnerClasses
-keepattributes Signature
-keepattributes Exceptions

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-keep class sun.misc.Unsafe { *; }
#-keep class com.google.gson.stream.** { *; }

# Application classes that will be serialized/deserialized over Gson
-keep class com.quickblox.core.account.model.** { *; }


##---------------End: proguard configuration for Gson ----------
#quickblox sample chat

-keep class com.quickblox.auth.parsers.** { *; }
-keep class com.quickblox.auth.model.** { *; }
-keep class com.quickblox.core.parser.** { *; }
-keep class com.quickblox.core.model.** { *; }
-keep class com.quickblox.core.server.** { *; }
-keep class com.quickblox.core.rest.** { *; }
-keep class com.quickblox.core.error.** { *; }
-keep class com.quickblox.core.Query { *; }

-keep class com.quickblox.users.parsers.** { *; }
-keep class com.quickblox.users.model.** { *; }

-keep class com.quickblox.chat.parser.** { *; }
-keep class com.quickblox.chat.model.** { *; }

-keep class com.quickblox.messages.parsers.** { *; }
-keep class com.quickblox.messages.model.** { *; }

-keep class com.quickblox.content.parsers.** { *; }
-keep class com.quickblox.content.model.** { *; }
#quickblox sdk
-keep class com.quickblox.** { *; }

#smack xmpp library
-keep class org.jxmpp.** { *; }
-keep class org.jivesoftware.** { *; }
-dontwarn org.jivesoftware.**

#sample chat
-keep class android.support.v7.** { *; }
#glide
-keep class com.bumptech.** { *; }

-dontwarn org.jivesoftware.smackx.**
-dontwarn android.support.v4.app.**
#google gms
-keep class com.google.android.gms.** { *; }
14 changes: 7 additions & 7 deletions sample-chat-java/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
android:allowBackup="false"
android:icon="@mipmap/ic_launcher_new"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning"
android:requestLegacyExternalStorage="true">
tools:ignore="GoogleAppIndexingWarning">

<activity
android:name=".ui.activity.SplashActivity"
android:exported="true"
android:label="@string/app_name"
android:screenOrientation="portrait">

Expand Down Expand Up @@ -83,14 +84,16 @@
android:screenOrientation="portrait" />

<service
android:name=".fcm.PushListenerService">
android:name=".fcm.PushListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>

<service
android:name="com.quickblox.messages.services.fcm.QBFcmPushInstanceIDService">
android:name="com.quickblox.messages.services.fcm.QBFcmPushInstanceIDService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
Expand Down Expand Up @@ -121,8 +124,5 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
<meta-data
android:name="io.fabric.ApiKey"
android:value="4b96a3f33893a42103eae91d2166d0c517b833d3" />
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

import android.app.Application;

import com.crashlytics.android.Crashlytics;
import androidx.lifecycle.ProcessLifecycleOwner;

import com.quickblox.auth.session.QBSettings;
import com.quickblox.sample.chat.java.managers.BackgroundListener;
import com.quickblox.sample.chat.java.utils.ActivityLifecycle;

import androidx.lifecycle.ProcessLifecycleOwner;
import io.fabric.sdk.android.Fabric;

public class App extends Application {

//Chat settings
Expand Down Expand Up @@ -42,7 +40,6 @@ public void onCreate() {
super.onCreate();
initApplication();
ActivityLifecycle.init(this);
initFabric();
checkAppCredentials();
checkChatSettings();
initCredentials();
Expand All @@ -53,12 +50,6 @@ private void initApplication() {
instance = this;
}

private void initFabric() {
if (!BuildConfig.DEBUG) {
Fabric.with(this, new Crashlytics());
}
}

private void checkAppCredentials() {
if (APPLICATION_ID.isEmpty() || AUTH_KEY.isEmpty() || AUTH_SECRET.isEmpty() || ACCOUNT_KEY.isEmpty()) {
throw new AssertionError(getString(R.string.error_qb_credentials_empty));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
Expand All @@ -14,13 +16,11 @@
import android.widget.ProgressBar;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.Target;
import com.quickblox.sample.chat.java.R;
import com.quickblox.sample.chat.java.utils.ImageUtils;
import com.quickblox.sample.chat.java.utils.ToastUtils;

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

Glide.with(this)
.load(url)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.listener(new DrawableListener())
.error(R.drawable.ic_error_white)
.dontTransform()
.override(ImageUtils.PREFERRED_IMAGE_SIZE_FULL, ImageUtils.PREFERRED_IMAGE_SIZE_FULL)
.into(imageView);
}

private class DrawableListener implements RequestListener<String, GlideDrawable> {

private class DrawableListener implements RequestListener<Drawable> {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
public boolean onLoadFailed(GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
if (e != null && e.getMessage() != null) {
Log.d("Glide Drawable", e.getMessage());
} else {
e = new Exception("Unable to load image");
e = new GlideException("Unable to load image");
}
showErrorSnackbar(R.string.error_load_image, e, null);
progressBar.setVisibility(View.GONE);
return false;
}

@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
progressBar.setVisibility(View.GONE);
imageLoaded = true;
return false;
Expand Down
Loading

0 comments on commit 4006cf6

Please sign in to comment.