public static String getMapImageURL (LatLng location, int width, int height) { String googleMapsAPIKey = ChatSDK.config().googleMapsApiKey; String api = "https://maps.googleapis.com/maps/api/staticmap"; String markers = "markers="+location.latitude+","+location.longitude; String size = "zoom=18&size="+width+"x"+ height; String key = "key=" + googleMapsAPIKey; return api + "?" + markers + "&" + size + "&" + key; }
@Override public boolean allowThreadCreation () { return ChatSDK.config().publicRoomCreationEnabled; }
@Override public boolean showLocalNotifications(Thread thread) { if (localNotificationHandler != null) { return localNotificationHandler.showLocalNotification(thread); } else { return ChatSDK.config().showLocalNotifications; } }
public Single<Thread> createThread(String name, List<User> users, int type, String entityID) { return createThread(name, users, type, entityID, ChatSDK.config().reuseDeleted1to1Threads); }
public Observable<User> usersForIndex(final String value) { return usersForIndex(value, ChatSDK.config().contactsToLoadPerBatch); }
public Observable<User> usersForIndex(final String value, final String index) { return usersForIndex(value, ChatSDK.config().contactsToLoadPerBatch, index); }
public List<Thread> getThreads(int type, boolean allowDeleted) { return getThreads(type, allowDeleted, ChatSDK.config().showEmptyChats); }
public Observable<User> usersForIndexes(final String value, final String... indexes) { return usersForIndexes(value, ChatSDK.config().contactsToLoadPerBatch, indexes); }
public static File createEmptyFileInCacheDirectory(Context context, String name, String ext) { File imageDir = getDiskCacheDir(context, ChatSDK.config().imageDirectoryName); return createEmptyFileInCacheDirectory(imageDir, name, ext); }
@OnLifecycleEvent(Lifecycle.Event.ON_STOP) public void onAppBackground () { inBackground = true; if (ChatSDK.config().disconnectFromFirebaseWhenInBackground) { ChatSDK.core().goOffline(); } }
public void handleImageFile (Activity activity, String path) { // Scanning the messageImageView so it would be visible in the gallery images. if (ChatSDK.config().saveImagesToDirectory) { ImageUtils.scanFilePathForGallery(activity, path); } if (resultHandler != null) { resultHandler.result(path); clear(); } }
public Boolean accountTypeEnabled(AccountDetails.Type type) { if (type == AccountDetails.Type.Anonymous) { return ChatSDK.config().anonymousLoginEnabled; } else if (type == AccountDetails.Type.Username || type == AccountDetails.Type.Register) { return true; } else if (ChatSDK.socialLogin() != null) { return ChatSDK.socialLogin().accountTypeEnabled(type); } else { return false; } }
public Single<List<Message>> loadMoreMessagesForThread(final Message fromMessage, final Thread thread) { return super.loadMoreMessagesForThread(fromMessage, thread).flatMap(messages -> { if (messages.isEmpty()) { return new ThreadWrapper(thread).loadMoreMessages(fromMessage, ChatSDK.config().messagesToLoadPerBatch); } return Single.just(messages); }); }
public FirebaseSocialLoginHandler (Context context) { if(accountTypeEnabled(AccountDetails.Type.Google)) { gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(ChatSDK.config().googleWebClientKey) .requestEmail() .build(); } if(accountTypeEnabled(AccountDetails.Type.Twitter)) { TwitterAuthConfig authConfig = new TwitterAuthConfig(ChatSDK.config().twitterKey, ChatSDK.config().twitterSecret); TwitterConfig config = new TwitterConfig.Builder(context).twitterAuthConfig(authConfig).build(); Twitter.initialize(config); } }
/** @return The main databse ref.*/ public static DatabaseReference firebaseRawRef() { String url = ChatSDK.config().firebaseDatabaseUrl; if (url != null) return FirebaseDatabase.getInstance(url).getReference(); else return FirebaseDatabase.getInstance().getReference(); }
@Override public boolean onCreateOptionsMenu(Menu menu) { if (!inflateMenuItems) return super.onCreateOptionsMenu(menu); // Adding the add user option only if group chat is enabled. if (ChatSDK.config().groupsEnabled && thread.typeIs(ThreadType.Private)) { MenuItem item = menu.add(Menu.NONE, R.id.action_chat_sdk_add, 10, getString(R.string.chat_activity_show_users_item_text)); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); item.setIcon(R.drawable.ic_plus); } return super.onCreateOptionsMenu(menu); }
@OnLifecycleEvent(Lifecycle.Event.ON_START) public void onAppForeground () { inBackground = false; if(ChatSDK.auth().userAuthenticated() && ChatSDK.config().disconnectFromFirebaseWhenInBackground) { ChatSDK.core().goOnline(); } }
public Single<List<Message>> loadMoreMessagesForThread(final Message fromMessage, final Thread thread) { return Single.create((SingleOnSubscribe<List<Message>>) e -> { // Date messageDate = fromMessage != null ? fromMessage.getDate().toDate() : null; // First try to load the messages from the database List<Message> list = StorageManager.shared().fetchMessagesForThreadWithID(thread.getId(), ChatSDK.config().messagesToLoadPerBatch + 1, messageDate); e.onSuccess(list); }).subscribeOn(Schedulers.single()); }