Use Android Chat SDK - magnetsystems/message-samples-android GitHub Wiki
- Create a new project with Android Studio (or use a existing Android Studio Project)
- In the root of the project, run command
git clone https://github.com/jimxj/mmxchatsdk.git
Alternatively, you can add it as a git submodule (assume it's under source control with git)
git submodule add https://github.com/jimxj/mmxchatsdk.git
- In Android Studio, add mmxchatsdk as a module.
- Add following repositories in the root build.gradle
jcenter()
maven {
url "https://repo.magnet.com/artifactory/public"
}
maven {
url "http://dev-repo.magnet.com:8081/artifactory/everything"
credentials {
username = "pritesh.shah"
password = "aardvark"
}
}
maven {
url "https://repo.commonsware.com.s3.amazonaws.com"
}
maven {
url "https://jitpack.io"
}
5.Enable dataBinding in your app build.gradle
android {
...
dataBinding {
enabled = true
}
...
}
In your Application subclass, init the Max and ChatSDK
public class ChatSampleApplication extends MultiDexApplication {
...
@Override
public void onCreate() {
super.onCreate();
//Initialization of the MagnetMax
Max.init(this, new MaxAndroidPropertiesConfig(this, com.magnet.chatsdk.sample.R.raw.magnetmax));
//Initialization of Chat SDK
ChatSDK.init(this);
User.login(email, password, remember, new ApiCallback<Boolean>() {
@Override
public void success(Boolean aBoolean) {
...
// Start MMX to enable incoming message
MMX.start();
...
}
@Override
public void failure(ApiError apiError) {
Logger.error("login", apiError);
}
});
This activity shows the list of chat current user. Click on one item will go to ChatActivity Click on the Floating Action Bar will go to ChooseUserActivity to start a new Chat
This activity is the actual chat window where user sends and receives message with other user/users. Click on "Details" menu will go to
This activity shows the users in the app (be default) who you can choose to start a new chat or add to existing chat.
This activity shows all the members in the chat. If current user is the creator of the chat, click on the "+" menu item will go to ChooseUserActivity to add more user(s) to the chat
Following are the colors you can customize
<color name="primary">#2196F3</color>
<color name="primary_dark">#1976D2</color>
<color name="primary_light">#BBDEFB</color>
<color name="accent">#517daa</color>
<color name="primary_text">#212121</color>
<color name="secondary_text">#727272</color>
<color name="buttonsTextColor">#517daa</color>
<color name="itemSelected">#c3c3c3</color>
<color name="itemNotSelected">#fff</color>
<color name="colorHintText">#51517daa</color>
<color name="colorLightGray">#cccccc</color>
<color name="colorDarkTransparent">#88000000</color>
<color name="messageBackgroundFromMe">#517daa</color>
<color name="messageBackgroundToMe">#e6e6e6</color>
<color name="FABBackground">#00c0ff</color>
The SDK has a theme MagnetChatSDKTheme, to customize it, you need to add tools:replace="android:theme" in the application tag of application Manifest