Migration guide

MirrorFly Chat SDK Version 2 has introduced major import changes to streamline the code structure and enhance its scalability.

This guide explains the breaking changes and provices a step by step guide for migrating to Version 2.

Remove old dependencies#

Step 1: Remove the following libraries in app/libs folder in the project.

  • appbase.aar
  • flycommons.aar
  • flynetwork.aar
  • flydatabase.aar
  • videocompression.aar
  • xmpp.aar
  • flywebrtc.aar

Step 2: Remove the following dependencies in the app/build.gradle file.

dependencies {
... // your app dependencies
implementation files('libs/appbase.aar')
implementation files('libs/flycommons.aar')
implementation files('libs/flynetwork.aar')
implementation files('libs/flydatabase.aar')
implementation files('libs/videocompression.aar')
implementation files('libs/xmpp.aar')
implementation files('libs/flywebrtc.aar')
}

Configure maven dependencies#

Step 1: If using Gradle 6.8 or higher, add the following code to your settings.gradle file. If using Gradle 6.7 or lower, add the following code to your root build.gradle file. See this release note to learn more about updates to Gradle.

dependencyResolutionManagement {
repositories {
jcenter()
maven {
url "https://repo.mirrorfly.com/release"
}
}
}

Step 2: Add the following dependencies in the app/build.gradle file.

dependencies {
implementation 'com.mirrorfly.sdk:mirrorflysdk:7.4.0'
}

Step 3: Check in app/build.gradle file below dependencies is used.

dependencies {
implementation 'org.webrtc:google-webrtc:1.0.32006'
}

If it is used then replace it with below dependencies.

dependencies {
implementation 'com.mirrorfly.sdk:webrtc:0.0.11'
}

Migrating to Version 2#

MirrorFly SDK Version 2 will likely prevent your app from compiling until all migration tasks are complete and all errors are fixed. We recommend you allow a generous timeline for the task. Depending on the level of dependency, it may take a few hours to a day.

Replace import names#

It's is mandatory to replace old imports to new imports from Version 2

import com.contus.flycommons.* -> import com.mirrorflysdk.flycommons.*
import com.contus.flynetwork.* -> import com.mirrorflysdk.flynetwork.*
import com.contus.webrtc.* -> import com.mirrorflysdk.flycall.webrtc.*
import com.contus.call.* -> import com.mirrorflysdk.flycall.call.*
import com.contus.call.database.model.CallLog -> import com.mirrorflysdk.flycall.call.database.model.CallLog
import com.contus.call.utils.CallTimeFormatter -> import com.mirrorflysdk.flycall.call.utils.CallTimeFormatter
import com.contus.xmpp.* -> import com.mirrorflysdk.xmpp.*
import com.contusflysdk.api.* -> import com.mirrorflysdk.api.*
import com.contusflysdk.views.* -> import com.mirrorflysdk.views.*
import com.contusflysdk.utils.* -> import com.mirrorflysdk.utils.*
import com.contusflysdk.activities -> import com.mirrorflysdk.activities
import com.contusflysdk.di.* -> import com.mirrorflysdk.di.*
import com.contusflysdk.backup.* -> import com.mirrorflysdk.backup.*
import com.contusflysdk.helpers.* -> import com.mirrorflysdk.helpers.*
import com.contusflysdk.ChatSDK -> import com.mirrorflysdk.ChatSDK
import com.contusflysdk.AppUtils -> import com.mirrorflysdk.AppUtils
import com.contusflysdk.GroupConfig -> import com.mirrorflysdk.GroupConfig
import com.contusflysdk.model.Roster -> import com.mirrorflysdk.flydatabase.model.Roster
import com.contusflysdk.model.Country -> import com.mirrorflysdk.flydatabase.model.Country
import com.contusflysdk.model.WebLogin -> import com.mirrorflysdk.flydatabase.model.WebLogin
import com.contusflysdk.model.Backup -> import com.mirrorflysdk.flydatabase.model.Backup
import com.contusflysdk.media.MediaUploadDownloadManager -> import com.mirrorflysdk.media.MediaUploadDownloadManager
import com.contusflysdk.model.CallLogs -> import com.mirrorflysdk.flydatabase.model.CallLogs
import com.contusflysdk.media.MediaUploadHelper -> import com.mirrorflysdk.media.MediaUploadHelper
import com.contusflysdk.model.ChatTagModel -> import com.mirrorflysdk.flydatabase.model.ChatTagModel
import com.contusflysdk.BuildConfig -> import com.mirrorflysdk.BuildConfig
import com.contusflysdk.model.ContactMessage -> import com.mirrorflysdk.flydatabase.model.ContactMessage
import com.contusfly.videocompression.composer.Mp4Composer -> import com.mirrorflysdk.videocompression.composer.Mp4Composer

Removed files#

Below files were removed from MirrorFly SDK from Version 2.

import com.contusflysdk.utils.ItemClickSupport
import com.mirrorflysdk.utils.LocationFinder
import com.mirrorflysdk.utils.LocationUtils
import com.contus.flycommons.Prefs
import com.contus.flycommons.SharedPreferenceManager

You can find these removed files in sample project here

Removed functions#

Below Kotlin extention functions were removed in MirrorFly SDK Version 2, Add below functions in your applications if you have already used.

fun HashMap<String, Any>.getMessage(): String = if (this.containsKey(FlyConstants.MESSAGE))
this[FlyConstants.MESSAGE].toString()
else
emptyStringFE()
fun HashMap<String, Any>.getData(): Any = if (this.containsKey(FlyConstants.DATA))
this[FlyConstants.DATA]!!
else
emptyStringFE()
fun HashMap<String, Any>.getParams(key: String? = null): Any {
return if (key == null) {
if (this.containsKey(FlyConstants.PARAMS))
this[FlyConstants.PARAMS]!!
else
emptyStringFE()
} else {
if (this.containsKey(key))
this[key]!!
else
emptyStringFE()
}
}
fun HashMap<String, Any>.getHttpStatusCode(): Int = if (this.containsKey(FlyConstants.HTTP_STATUS_CODE))
this[FlyConstants.HTTP_STATUS_CODE]!! as Int
else
500
private object ContextHandler {
val handler = Handler(Looper.getMainLooper())
val mainThread = Looper.getMainLooper().thread
}
fun runOnUiThread(action: () -> Unit) {
if (ContextHandler.mainThread == Thread.currentThread()) action() else ContextHandler.handler.post { action() }
}
fun runOnUiThread(action: Runnable) {
if (ContextHandler.mainThread == Thread.currentThread()) action.run() else ContextHandler.handler.post { action.run() }
}
fun getString(@StringRes id: Int): String {
return ChatManager.applicationContext.getString(id)
}
fun Context.isPermissionAllowed(permission: String): Boolean {
return ContextCompat.checkSelfPermission(this, permission) == PackageManager.PERMISSION_GRANTED
}

Once the migration has been completed you can proceed with V2 documentation.