use of im.actor.core.viewmodel.CommandCallback in project actor-platform by actorapp.
the class SecuritySettingsFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View res = inflater.inflate(R.layout.fr_settings_encryption, container, false);
res.setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor());
res.findViewById(R.id.big_divider).setBackgroundColor(ActorSDK.sharedActor().style.getBackyardBackgroundColor());
((TextView) res.findViewById(R.id.security_settings_title)).setTextColor(ActorSDK.sharedActor().style.getSettingsMainTitleColor());
loading = (TextView) res.findViewById(R.id.loading);
loading.setTextColor(ActorSDK.sharedActor().style.getTextPrimaryColor());
loading.setVisibility(View.GONE);
loading.setOnClickListener(v -> performLoad());
authItems = (LinearLayout) res.findViewById(R.id.authItems);
((TextView) res.findViewById(R.id.settings_last_seen_title)).setTextColor(ActorSDK.sharedActor().style.getTextPrimaryColor());
((TextView) res.findViewById(R.id.settings_last_seen_hint)).setTextColor(ActorSDK.sharedActor().style.getTextSecondaryColor());
res.findViewById(R.id.lastSeen).setOnClickListener(v -> {
String[] itemsValues = new String[] { "always", "contacts", "none" };
String[] items = new String[] { getString(R.string.security_last_seen_everybody), getString(R.string.security_last_seen_contacts), getString(R.string.security_last_seen_nobody) };
int currentLastSeen = Arrays.asList(itemsValues).indexOf(messenger().getPrivacy());
new AlertDialog.Builder(getActivity()).setTitle(R.string.security_last_seen_title).setSingleChoiceItems(items, currentLastSeen, (dialog, which) -> {
messenger().setPrivacy(itemsValues[which]);
dialog.dismiss();
}).setNegativeButton(R.string.dialog_cancel, null).setPositiveButton(R.string.dialog_ok, null).show();
});
res.findViewById(R.id.terminateSessions).setOnClickListener(v -> new AlertDialog.Builder(getActivity()).setMessage(R.string.security_terminate_message).setPositiveButton(R.string.dialog_yes, (dialog, which) -> execute(messenger().terminateAllSessions(), R.string.progress_common, new CommandCallback<Void>() {
@Override
public void onResult(Void res1) {
performLoad();
}
@Override
public void onError(Exception e) {
performLoad();
Toast.makeText(getActivity(), R.string.security_toast_unable_remove_auth, Toast.LENGTH_SHORT).show();
}
})).setNegativeButton(R.string.dialog_no, null).show().setCanceledOnTouchOutside(true));
((TextView) res.findViewById(R.id.settings_terminate_sessions_title)).setTextColor(ActorSDK.sharedActor().style.getTextPrimaryColor());
((TextView) res.findViewById(R.id.settings_terminate_sessions_hint)).setTextColor(ActorSDK.sharedActor().style.getTextSecondaryColor());
performLoad();
return res;
}
use of im.actor.core.viewmodel.CommandCallback in project actor-platform by actorapp.
the class JsFacade method addContact.
@UsedByApp
public JsPromise addContact(final int uid) {
return JsPromise.create(new JsPromiseExecutor() {
@Override
public void execute() {
//noinspection ConstantConditions
messenger.addContact(uid).start(new CommandCallback<Boolean>() {
@Override
public void onResult(Boolean res) {
Log.d(TAG, "addContact:result");
resolve();
}
@Override
public void onError(Exception e) {
Log.d(TAG, "addContact:error");
reject(e.getMessage());
}
});
}
});
}
use of im.actor.core.viewmodel.CommandCallback in project actor-platform by actorapp.
the class JsFacade method getIntegrationToken.
@UsedByApp
public JsPromise getIntegrationToken(final int gid) {
return JsPromise.create(new JsPromiseExecutor() {
@Override
public void execute() {
//noinspection ConstantConditions
messenger.requestIntegrationToken(gid).start(new CommandCallback<String>() {
@Override
public void onResult(String res) {
Log.d(TAG, "getIntegrationToken:result");
resolve(res);
}
@Override
public void onError(Exception e) {
Log.d(TAG, "getIntegrationToken:error");
reject(e.getMessage());
}
});
}
});
}
use of im.actor.core.viewmodel.CommandCallback in project actor-platform by actorapp.
the class JsFacade method findAllDocs.
@UsedByApp
public JsPromise findAllDocs(final JsPeer peer) {
return JsPromise.create(new JsPromiseExecutor() {
@Override
public void execute() {
messenger.findAllDocs(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.viewmodel.CommandCallback in project actor-platform by actorapp.
the class JsFacade method revokeIntegrationToken.
@UsedByApp
public JsPromise revokeIntegrationToken(final int gid) {
return JsPromise.create(new JsPromiseExecutor() {
@Override
public void execute() {
//noinspection ConstantConditions
messenger.revokeIntegrationToken(gid).start(new CommandCallback<String>() {
@Override
public void onResult(String res) {
Log.d(TAG, "revokeIntegrationToken:result");
resolve(res);
}
@Override
public void onError(Exception e) {
Log.d(TAG, "revokeIntegrationToken:error");
reject(e.getMessage());
}
});
}
});
}
Aggregations