Skip to content

Commit

Permalink
Merge pull request #786 from QuickBlox/sample-chat-kotlin
Browse files Browse the repository at this point in the history
4.2.8-chat-kotlin
  • Loading branch information
kirillTolmachev authored Apr 4, 2022
2 parents 4006cf6 + 26fa7b1 commit 48d2bdb
Show file tree
Hide file tree
Showing 19 changed files with 253 additions and 281 deletions.
34 changes: 14 additions & 20 deletions sample-chat-kotlin/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,41 @@ buildscript {
repositories {
google()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$rootProject.kotlinGradlePluginVersion"
classpath "io.fabric.tools:gradle:$rootProject.fabricToolsVersion"
}
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'

androidExtensions {
experimental = true
}

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 28
buildToolsVersion "28.0.3"
compileSdkVersion 31
buildToolsVersion "31.0.0"
flavorDimensions dimensionDefault

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

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

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

implementation "com.google.firebase:firebase-core:$rootProject.firebaseCoreVersion"
implementation "com.google.android.material:material:$rootProject.materialVersion"
implementation "androidx.fragment:fragment:$rootProject.fragmentAndroidXVersion"
implementation "androidx.lifecycle:lifecycle-viewmodel:$rootProject.lifecycleViewmodelAndroidXVersion"
implementation "androidx.fragment:fragment-ktx:$rootProject.fragmentAndroidXVersion"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$rootProject.lifecycleViewmodelAndroidXVersion"
implementation "androidx.core:core-ktx:$rootProject.coreKtxVersion"

implementation "com.github.johnkil.android-robototextview:robototextview:$rootProject.robotoTextViewVersion"
Expand All @@ -112,11 +109,8 @@ 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-kotlin/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.** { *; }
13 changes: 7 additions & 6 deletions sample-chat-kotlin/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

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

Expand Down Expand Up @@ -80,13 +81,17 @@
android:name=".ui.activity.AttachmentVideoActivity"
android:screenOrientation="portrait" />

<service android:name=".fcm.PushListenerService">
<service
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">
<service
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 @@ -117,9 +122,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,11 +2,9 @@ package com.quickblox.sample.chat.kotlin

import android.app.Application
import androidx.lifecycle.ProcessLifecycleOwner
import com.crashlytics.android.Crashlytics
import com.quickblox.auth.session.QBSettings
import com.quickblox.sample.chat.kotlin.managers.BackgroundListener
import com.quickblox.sample.chat.kotlin.utils.ActivityLifecycle
import io.fabric.sdk.android.Fabric

//Chat settings
const val USER_DEFAULT_PASSWORD = "quickblox"
Expand Down Expand Up @@ -43,7 +41,6 @@ class App : Application() {
super.onCreate()
instance = this
registerActivityLifecycleCallbacks(ActivityLifecycle)
initFabric()
checkAppCredentials()
checkChatSettings()
initCredentials()
Expand All @@ -58,7 +55,8 @@ class App : Application() {

private fun checkChatSettings() {
if (USER_DEFAULT_PASSWORD.isEmpty() || CHAT_PORT !in MIN_PORT_VALUE..MAX_PORT_VALUE
|| SOCKET_TIMEOUT !in MIN_SOCKET_TIMEOUT..MAX_SOCKET_TIMEOUT) {
|| SOCKET_TIMEOUT !in MIN_SOCKET_TIMEOUT..MAX_SOCKET_TIMEOUT
) {
throw AssertionError(getString(R.string.error_chat_credentails_empty))
}
}
Expand All @@ -73,10 +71,4 @@ class App : Application() {
// QBSettings.getInstance().setEndpoints("https://your_api_endpoint.com", "your_chat_endpoint", ServiceZone.PRODUCTION);
// QBSettings.getInstance().zone = ServiceZone.PRODUCTION
}

private fun initFabric() {
if (!BuildConfig.DEBUG) {
Fabric.with(this, Crashlytics())
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.quickblox.sample.chat.kotlin.ui.activity

import android.content.Context
import android.content.Intent
import android.graphics.drawable.Drawable
import android.os.Build
import android.os.Bundle
import android.provider.MediaStore
Expand All @@ -13,12 +14,11 @@ import android.widget.ImageView
import android.widget.ProgressBar
import androidx.core.graphics.drawable.toBitmap
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
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.kotlin.R
import com.quickblox.sample.chat.kotlin.utils.PREFERRED_IMAGE_SIZE_FULL
import com.quickblox.sample.chat.kotlin.utils.shortToast


Expand Down Expand Up @@ -96,35 +96,28 @@ class AttachmentImageActivity : BaseActivity() {
progressBar.visibility = View.VISIBLE
Glide.with(this)
.load(url)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.listener(DrawableListener(progressBar))
.error(R.drawable.ic_error_white)
.dontTransform()
.override(PREFERRED_IMAGE_SIZE_FULL, PREFERRED_IMAGE_SIZE_FULL)
.into(imageView)
}

private inner class DrawableListener(private val progressBar: ProgressBar) : RequestListener<String, GlideDrawable> {
private inner class DrawableListener(private val progressBar: ProgressBar) : RequestListener<Drawable> {
override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
progressBar.visibility = View.GONE
imageLoaded = true
return false
}

override fun onException(e: Exception?, model: String, target: Target<GlideDrawable>,
isFirstResource: Boolean): Boolean {
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
var ex = e
ex?.printStackTrace()
if (ex?.message != null) {
Log.d("Glide Drawable", ex.message)
Log.d("Glide Drawable", ex.message!!)
} else {
ex = java.lang.Exception("Unable to load image")
ex = GlideException("Unable to load image")
}
showErrorSnackbar(R.string.error_load_image, ex, null)
progressBar.visibility = View.GONE
return false
}

override fun onResourceReady(resource: GlideDrawable, model: String, target: Target<GlideDrawable>,
isFromMemoryCache: Boolean, isFirstResource: Boolean): Boolean {
progressBar.visibility = View.GONE
imageLoaded = true
return false
}
}
}
Loading

0 comments on commit 48d2bdb

Please sign in to comment.