use of im.actor.core.js.annotations.UsedByApp in project actor-platform by actorapp.
the class JsFacade method init.
@UsedByApp
public void init(JsConfig config) {
provider = (JsFileSystemProvider) Storage.getFileSystemRuntime();
String clientName = IdentityUtils.getClientName();
String uniqueId = IdentityUtils.getUniqueId();
ConfigurationBuilder configuration = new ConfigurationBuilder();
configuration.setApiConfiguration(new ApiConfiguration(APP_NAME, APP_ID, APP_KEY, clientName, uniqueId));
configuration.setPhoneBookProvider(new JsPhoneBookProvider());
configuration.setNotificationProvider(new JsNotificationsProvider());
configuration.setCallsProvider(new JsCallsProvider());
// Setting locale
String locale = LocaleInfo.getCurrentLocale().getLocaleName();
if (locale.equals("default")) {
Log.d(TAG, "Default locale found");
configuration.addPreferredLanguage("en");
} else {
Log.d(TAG, "Locale found:" + locale);
configuration.addPreferredLanguage(locale.toLowerCase());
}
// Setting timezone
int offset = new Date().getTimezoneOffset();
String timeZone = TimeZone.createTimeZone(offset).getID();
Log.d(TAG, "TimeZone found:" + timeZone + " for delta " + offset);
configuration.setTimeZone(timeZone);
// LocaleInfo.getCurrentLocale().getLocaleName()
// Is Web application
configuration.setPlatformType(PlatformType.WEB);
// Device Category
// Only Desktop is supported for JS library
configuration.setDeviceCategory(DeviceCategory.DESKTOP);
// Adding endpoints
for (String endpoint : config.getEndpoints()) {
configuration.addEndpoint(endpoint);
}
if (config.getLogHandler() != null) {
final JsLogCallback callback = config.getLogHandler();
JsLogProvider.setLogCallback(new JsLogProvider.LogCallback() {
@Override
public void log(String tag, String level, String message) {
callback.log(tag, level, message);
}
});
}
messenger = new JsMessenger(configuration.build());
Log.d(TAG, "JsMessenger created");
}
use of im.actor.core.js.annotations.UsedByApp in project actor-platform by actorapp.
the class JsFacade method doCall.
// Calls
@UsedByApp
public JsPromise doCall(final int uid) {
return JsPromise.create(new JsPromiseExecutor() {
@Override
public void execute() {
messenger.doCall(uid).start(new CommandCallback<Long>() {
@Override
public void onResult(Long res) {
Log.d(TAG, "doCall:result");
resolve();
}
@Override
public void onError(Exception e) {
Log.d(TAG, "doCall:error");
reject(e.getMessage());
}
});
}
});
}
use of im.actor.core.js.annotations.UsedByApp in project actor-platform by actorapp.
the class JsFacade method findAllPhotos.
@UsedByApp
public JsPromise findAllPhotos(final JsPeer peer) {
return JsPromise.create(new JsPromiseExecutor() {
@Override
public void execute() {
messenger.findAllPhotos(peer.convert()).start(new CommandCallback<List<MessageSearchEntity>>() {
@Override
public void onResult(List<MessageSearchEntity> res) {
resolve(convertSearchRes(res));
}
@Override
public void onError(Exception e) {
Log.d(TAG, "findAllText:error");
reject(e.getMessage());
}
});
}
});
}
use of im.actor.core.js.annotations.UsedByApp in project actor-platform by actorapp.
the class JsFacade method findAllText.
@UsedByApp
public JsPromise findAllText(final JsPeer peer, final String query) {
return JsPromise.create(new JsPromiseExecutor() {
@Override
public void execute() {
messenger.findTextMessages(peer.convert(), query).start(new CommandCallback<List<MessageSearchEntity>>() {
@Override
public void onResult(List<MessageSearchEntity> res) {
resolve(convertSearchRes(res));
}
@Override
public void onError(Exception e) {
Log.d(TAG, "findAllText:error");
reject(e.getMessage());
}
});
}
});
}
use of im.actor.core.js.annotations.UsedByApp in project actor-platform by actorapp.
the class JsFacade method deleteChat.
@UsedByApp
public JsPromise deleteChat(final JsPeer peer) {
return JsPromise.create(new JsPromiseExecutor() {
@Override
public void execute() {
messenger.deleteChat(peer.convert()).start(new CommandCallback<Void>() {
@Override
public void onResult(Void res) {
Log.d(TAG, "deleteChat:result");
resolve();
}
@Override
public void onError(Exception e) {
Log.d(TAG, "deleteChat:error");
reject(e.getMessage());
}
});
}
});
}
Aggregations