Skip to content

Commit

Permalink
Merge branch 'chat-sdk-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
alhazmy13 committed Jan 16, 2019
2 parents 12b2624 + 6c900df commit 8b36609
Show file tree
Hide file tree
Showing 46 changed files with 1,053 additions and 751 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Chat SDK is a fully featured open source instant messaging framework for Android
- **Full control of the data.** You have full and exclusive access to the user's chat data
- **Quick integration.** Chat SDK is fully featured out of the box
<!--- Install the demo **[Firebase](https://i.diawi.com/2JGr4o)** app now by clicking the link on your Android phone! -->
- **Demo Versions.** **[Firebase](https://i.diawi.com/NUcnaL)** or **[XMPP](https://i.diawi.com/ZpPscm)** open this link on your Android phone to install
- **Demo Versions.** **[Firebase](https://i.diawi.com/r6P7of)** or **[XMPP](https://i.diawi.com/boXf6U)** open this link on your Android phone to install
- **Scalable.** Supports millons of daily users [[1](https://firebase.google.com/docs/database/usage/limits), [2](https://blog.process-one.net/ejabberd-massive-scalability-1node-2-million-concurrent-users/)]
- **Backend agnostic.** Chat SDK can be customized to [support any backend](https://github.com/chat-sdk/chat-sdk-android#backend-agnostic-architecture)

Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ android {
dependencies {
// implementation fileTree(include: ['*.jar'], dir: 'libs')
// implementation project(path: ':chat-sdk-core')
implementation 'androidx.multidex:multidex:2.0.0'
implementation "androidx.multidex:multidex:$androidxMultidexVersion"
implementation project(path: ':chat-sdk-ui')
implementation project(path: ':chat-sdk-firebase-adapter')
implementation project(path: ':chat-sdk-firebase-push')
Expand Down
Binary file added app/release.keystore
Binary file not shown.
14 changes: 12 additions & 2 deletions app/src/main/java/co/chatsdk/android/app/AppObj.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
package co.chatsdk.android.app;

import android.content.Context;

import com.google.firebase.auth.EmailAuthProvider;
import com.google.firebase.auth.PhoneAuthProvider;

import androidx.multidex.MultiDex;
import androidx.multidex.MultiDexApplication;

import co.chatsdk.core.dao.User;
import co.chatsdk.core.error.ChatSDKException;
import co.chatsdk.core.session.ChatSDK;
import co.chatsdk.core.session.Configuration;
import co.chatsdk.core.session.NetworkManager;
import co.chatsdk.firebase.FirebaseNetworkAdapter;
import co.chatsdk.firebase.file_storage.FirebaseFileStorageModule;
import co.chatsdk.firebase.push.FirebasePushModule;
import co.chatsdk.firebase.ui.FirebaseUIModule;
import co.chatsdk.ui.manager.BaseInterfaceAdapter;

/**
Expand All @@ -24,22 +31,25 @@ public void onCreate() {
Context context = getApplicationContext();

Configuration.Builder config = new Configuration.Builder(context);

// builder.firebaseRootPath("firebase_v4_web_new_4");
config.firebaseRootPath("18_12_bug");
config.firebaseRootPath("19_01");
config.googleMaps("AIzaSyCwwtZrlY9Rl8paM0R6iDNBEit_iexQ1aE");
config.publicRoomCreationEnabled(false);
config.pushNotificationSound("default");
// config.pushNotificationsForPublicChatRoomsEnabled(true);

try {
ChatSDK.initialize(config.build(), new BaseInterfaceAdapter(context), new FirebaseNetworkAdapter());
ChatSDK.initialize(config.build(), new FirebaseNetworkAdapter(), new BaseInterfaceAdapter(context));
}
catch (ChatSDKException e) {

}

FirebaseFileStorageModule.activate();
FirebasePushModule.activate();


// FirebaseUIModule.activate(context, EmailAuthProvider.PROVIDER_ID, PhoneAuthProvider.PROVIDER_ID);


Expand Down
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.0.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'com.google.gms:google-services:4.2.0'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintrayVersion"
}
}

ext {
bintrayVersion = "1.8.4"
mavenGradleVersion = "2.1"
androidxAppcompatVersion = "1.0.2"
androidxConstraintLayoutVersion = "2.0.0-alpha2"
androidxConstraintLayoutVersion = "2.0.0-alpha3"
androidxLifecycleExtensionsVersion = "2.0.0"
androidxRecyclerViewVersion = "1.0.0"
androidxMultidexVersion = "2.0.1"
materialVersion = "1.0.0"
playAuthVersion = "16.0.1"
playMapsVersion = "16.0.0"
Expand Down
2 changes: 1 addition & 1 deletion chat-sdk-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ dependencies {
api "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
implementation "org.apache.commons:commons-lang3:$apacheCommonsVersion"
api "com.google.android.gms:play-services-maps:$playMapsVersion"

implementation "androidx.recyclerview:recyclerview:$androidxRecyclerViewVersion"

implementation "com.facebook.fresco:fresco:$frescoVersion"
implementation "id.zelory:compressor:$compressorVersion"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package co.chatsdk.core.base;

import android.app.Activity;
import android.view.View;
import android.widget.LinearLayout;

import androidx.recyclerview.widget.RecyclerView;
import co.chatsdk.core.dao.Message;

public abstract class AbstractMessageViewHolder extends RecyclerView.ViewHolder {

protected Activity activity;
protected Message message;

protected View.OnClickListener onClickListener = null;
protected View.OnLongClickListener onLongClickListener = null;

public AbstractMessageViewHolder(View itemView, Activity activity) {
super(itemView);
this.activity = activity;
}

public abstract void showProgressBar();
public abstract void showProgressBar(float progress);
public abstract void hideProgressBar ();

public abstract void setIconSize(int width, int height);
public abstract void setImageSize(int width, int height);
public abstract void setBubbleHidden (boolean hidden);
public abstract void setIconHidden (boolean hidden);
public abstract void setImageHidden (boolean hidden);
public abstract void setTextHidden (boolean hidden);
public abstract View viewForClassType (Class classType);
public abstract void setAlpha (float alpha);
public abstract LinearLayout getExtraLayout();

public void setMessage (Message message) {
this.message = message;
}

public void setOnClickListener (View.OnClickListener listener) {
onClickListener = listener;
}

public void setOnLongClickListener (View.OnLongClickListener listener) {
onLongClickListener = listener;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,21 @@ public Observable<MessageSendProgress> sendMessageWithText(final String text, fi

}

public static Message newMessage (MessageType type, Thread thread) {
public static Message newMessage (int type, Thread thread) {
Message message = StorageManager.shared().createEntity(Message.class);
message.setSender(ChatSDK.currentUser());
message.setMessageStatus(MessageSendStatus.Sending);
message.setDate(new DateTime(System.currentTimeMillis()));
message.setEntityID(UUID.randomUUID().toString());
message.setMessageType(type);
message.setType(type);
thread.addMessage(message);
return message;
}

public static Message newMessage (MessageType type, Thread thread) {
return newMessage(type.ordinal(), thread);
}

/**
/* Convenience method to save the message to the database then pass it to the token network adapter
* send method so it can be sent via the network
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,16 @@

public class BaseHookHandler implements HookHandler {

public static String UserAuthFinished = "UserAuthFinished";
public static String UserAuthFinished_User = "UserAuthFinished_User";
public static String DidAuthenticate = "DidAuthenticate";

public static String UserOn = "UserOn";
public static String UserOn_User = "UserOn_User";

public static String MessageReceived = "MessageReceived";
public static String MessageReceived_Message = "MessageReceived_Message";
public static String MessageIsNew_Bool = "MessageIsNew_Bool";
public static String Message = "Message";
public static String IsNew_Boolean = "IsNew_Boolean";

public static String Logout = "Logout";
public static String Logout_User = "Logout_User";
public static String DidLogout = "DidLogout";
public static String User = "User";

public static String SetUserOnline = "SetUserOnline";
public static String SetUserOffline = "SetUserOffline";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package co.chatsdk.core.base;

import co.chatsdk.core.handlers.AudioMessageHandler;
import java.util.HashMap;

import co.chatsdk.core.handlers.AudioMessageDisplayHandler;
import co.chatsdk.core.handlers.AuthenticationHandler;
import co.chatsdk.core.handlers.BlockingHandler;
import co.chatsdk.core.handlers.ContactHandler;
Expand All @@ -18,12 +20,12 @@
import co.chatsdk.core.handlers.ReadReceiptHandler;
import co.chatsdk.core.handlers.SearchHandler;
import co.chatsdk.core.handlers.SocialLoginHandler;
import co.chatsdk.core.handlers.StickerMessageHandler;
import co.chatsdk.core.handlers.FileMessageHandler;
import co.chatsdk.core.handlers.StickerMessageDisplayHandler;
import co.chatsdk.core.handlers.FileMessageDisplayHandler;
import co.chatsdk.core.handlers.ThreadHandler;
import co.chatsdk.core.handlers.TypingIndicatorHandler;
import co.chatsdk.core.handlers.UploadHandler;
import co.chatsdk.core.handlers.VideoMessageHandler;
import co.chatsdk.core.handlers.VideoMessageDisplayHandler;

/**
* Created by benjaminsmiley-andrews on 02/05/2017.
Expand All @@ -36,8 +38,8 @@ public class BaseNetworkAdapter {
public PushHandler push;
public UploadHandler upload;
public ThreadHandler thread;
public VideoMessageHandler videoMessage;
public AudioMessageHandler audioMessage;
public VideoMessageDisplayHandler videoMessage;
public AudioMessageDisplayHandler audioMessage;
public ImageMessageHandler imageMessage = new BaseImageMessageHandler();
public LocationMessageHandler locationMessage = new BaseLocationMessageHandler();
public ContactHandler contact = new BaseContactHandler();
Expand All @@ -49,11 +51,21 @@ public class BaseNetworkAdapter {
public LastOnlineHandler lastOnline;
public NearbyUsersHandler nearbyUsers;
public ReadReceiptHandler readReceipts;
public StickerMessageHandler stickerMessage;
public FileMessageHandler fileMessage;
public StickerMessageDisplayHandler stickerMessage;
public FileMessageDisplayHandler fileMessage;
public SocialLoginHandler socialLogin;
public EventHandler events;
public HookHandler hook = new BaseHookHandler();
public EncryptionHandler encryption;

private HashMap<String, Object> handlers = new HashMap<>();

public void setHandler(Object handler, String name) {
handlers.put(name, handler);
}

public Object getHandler (String name) {
return handlers.get(name);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public static void createAllTables(Database db, boolean ifNotExists) {
LinkedAccountDao.createTable(db, ifNotExists);
ThreadMetaValueDao.createTable(db, ifNotExists);
FollowerLinkDao.createTable(db, ifNotExists);
MessageMetaValueDao.createTable(db, ifNotExists);
ContactLinkDao.createTable(db, ifNotExists);
ThreadDao.createTable(db, ifNotExists);
UserMetaValueDao.createTable(db, ifNotExists);
ReadReceiptUserLinkDao.createTable(db, ifNotExists);
MessageMetaValueDao.createTable(db, ifNotExists);
}

/** Drops underlying database table using DAOs. */
Expand All @@ -42,11 +42,11 @@ public static void dropAllTables(Database db, boolean ifExists) {
LinkedAccountDao.dropTable(db, ifExists);
ThreadMetaValueDao.dropTable(db, ifExists);
FollowerLinkDao.dropTable(db, ifExists);
MessageMetaValueDao.dropTable(db, ifExists);
ContactLinkDao.dropTable(db, ifExists);
ThreadDao.dropTable(db, ifExists);
UserMetaValueDao.dropTable(db, ifExists);
ReadReceiptUserLinkDao.dropTable(db, ifExists);
MessageMetaValueDao.dropTable(db, ifExists);
}

/**
Expand All @@ -71,11 +71,11 @@ public DaoMaster(Database db) {
registerDaoClass(LinkedAccountDao.class);
registerDaoClass(ThreadMetaValueDao.class);
registerDaoClass(FollowerLinkDao.class);
registerDaoClass(MessageMetaValueDao.class);
registerDaoClass(ContactLinkDao.class);
registerDaoClass(ThreadDao.class);
registerDaoClass(UserMetaValueDao.class);
registerDaoClass(ReadReceiptUserLinkDao.class);
registerDaoClass(MessageMetaValueDao.class);
}

public DaoSession newSession() {
Expand Down
Loading

0 comments on commit 8b36609

Please sign in to comment.