use of im.actor.sdk.core.AndroidPhoneBook 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();
});
}
use of im.actor.sdk.core.AndroidPhoneBook in project actor-platform by actorapp.
the class InviteFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View res = inflater.inflate(R.layout.fragment_list, container, false);
res.findViewById(R.id.listView).setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor());
emptyText = (TextView) res.findViewById(R.id.emptyView);
emptyText.setTextColor(ActorSDK.sharedActor().style.getTextSecondaryColor());
emptyText.setText(R.string.progress_common);
collection = (RecyclerListView) res.findViewById(R.id.listView);
AndroidPhoneBook phoneBookLoader = new AndroidPhoneBook();
phoneBookLoader.useDelay(false);
res.setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor());
phoneBookLoader.loadPhoneBook(contacts -> {
if (contacts.size() > 0) {
getActivity().runOnUiThread(() -> {
InviteFragment.this.contacts = contacts;
adapter = new InviteAdapter(getActivity(), contacts, new OnItemClickedListener<PhoneBookContact>() {
@Override
public void onClicked(PhoneBookContact item) {
onItemClicked(item);
}
@Override
public boolean onLongClicked(PhoneBookContact item) {
return false;
}
});
collection.setAdapter(adapter);
hideView(emptyText);
showView(collection);
showMenu();
});
}
});
return res;
}
Aggregations