use of im.actor.core.ConfigurationBuilder in project actor-platform by actorapp.
the class ActorSDK method createActor.
//
// SDK Initialization
//
public void createActor(final Application application) {
this.application = application;
ThreadDispatcher.pushDispatcher(Runtime::postToMainThread);
Runtime.dispatch(() -> {
//
// SDK Tools
//
ImagePipelineConfig config = ImagePipelineConfig.newBuilder(application).setDownsampleEnabled(true).build();
Fresco.initialize(application, config);
SmileProcessor emojiProcessor = new SmileProcessor(application);
ActorSystem.system().addDispatcher("voice_capture_dispatcher", 1);
//
// SDK Configuration
//
ConfigurationBuilder builder = new ConfigurationBuilder();
for (String s : endpoints) {
builder.addEndpoint(s);
}
for (String t : trustedKeys) {
builder.addTrustedKey(t);
}
builder.setPhoneBookProvider(new AndroidPhoneBook());
builder.setVideoCallsEnabled(videoCallsEnabled);
builder.setOnClientPrivacyEnabled(onClientPrivacyEnabled);
builder.setNotificationProvider(new AndroidNotifications(application));
builder.setDeviceCategory(DeviceCategory.MOBILE);
builder.setPlatformType(PlatformType.ANDROID);
builder.setIsEnabledGroupedChatList(false);
builder.setApiConfiguration(new ApiConfiguration(appName, apiAppId, apiAppKey, Devices.getDeviceName(), AndroidContext.getContext().getPackageName() + ":" + Build.SERIAL));
//
// Adding Locales
//
Locale defaultLocale = Locale.getDefault();
Log.d(TAG, "Found Locale: " + defaultLocale.getLanguage() + "-" + defaultLocale.getCountry());
Log.d(TAG, "Found Locale: " + defaultLocale.getLanguage());
builder.addPreferredLanguage(defaultLocale.getLanguage() + "-" + defaultLocale.getCountry());
builder.addPreferredLanguage(defaultLocale.getLanguage());
//
// Adding TimeZone
//
String timeZone = TimeZone.getDefault().getID();
Log.d(TAG, "Found TimeZone: " + timeZone);
builder.setTimeZone(timeZone);
//
if (customApplicationName != null) {
builder.setCustomAppName(customApplicationName);
}
//
// Calls Support
//
builder.setCallsProvider(new AndroidCallProvider());
//
// Handle raw updates
//
builder.setRawUpdatesHandler(getDelegate().getRawUpdatesHandler());
//
for (String s : autoJoinGroups) {
builder.addAutoJoinGroup(s);
}
builder.setAutoJoinType(autoJoinType);
//
// Building Messenger
//
this.messenger = new AndroidMessenger(application, builder.build());
//
if (isKeepAliveEnabled) {
Intent keepAliveService = new Intent(application, KeepAliveService.class);
PendingIntent pendingIntent = PendingIntent.getService(application, 0, keepAliveService, 0);
AlarmManager alarm = (AlarmManager) application.getSystemService(Context.ALARM_SERVICE);
alarm.setRepeating(AlarmManager.RTC, System.currentTimeMillis(), 30 * 1000, pendingIntent);
}
//
if (actorPushEndpoint != null) {
ActorPushRegister.registerForPush(application, actorPushEndpoint, endpoint -> {
Log.d(TAG, "On Actor push registered: " + endpoint);
messenger.registerActorPush(endpoint);
});
}
//
try {
if (pushId != 0) {
final ActorPushManager pushManager = (ActorPushManager) Class.forName("im.actor.push.PushManager").newInstance();
pushManager.registerPush(application);
}
} catch (Exception e) {
e.printStackTrace();
}
synchronized (LOAD_LOCK) {
isLoaded = true;
LOAD_LOCK.notifyAll();
}
//
// Loading Emoji
//
emojiProcessor.loadEmoji();
});
}
Aggregations