Search in sources :

Example 1 with ObjectiveCName

use of com.google.j2objc.annotations.ObjectiveCName in project actor-platform by actorapp.

the class GroupPermissions method setMembersCanInvite.

@ObjectiveCName("setMembersCanInvite:")
public void setMembersCanInvite(boolean membersCanInvite) {
    SparseArray<Object> unmapped = settings.getUnmappedObjects();
    settings = new ApiAdminSettings(settings.showAdminsToMembers(), membersCanInvite, settings.canMembersEditGroupInfo(), settings.canAdminsEditGroupInfo(), settings.showJoinLeaveMessages());
    settings.setUnmappedObjects(unmapped);
}
Also used : ApiAdminSettings(im.actor.core.api.ApiAdminSettings) ObjectiveCName(com.google.j2objc.annotations.ObjectiveCName)

Example 2 with ObjectiveCName

use of com.google.j2objc.annotations.ObjectiveCName in project actor-platform by actorapp.

the class GroupPermissions method setMembersCanEditInfo.

@ObjectiveCName("setMembersCanEditInfo:")
public void setMembersCanEditInfo(boolean canEditInfo) {
    SparseArray<Object> unmapped = settings.getUnmappedObjects();
    settings = new ApiAdminSettings(settings.showAdminsToMembers(), settings.canMembersInvite(), canEditInfo, settings.canAdminsEditGroupInfo(), settings.showJoinLeaveMessages());
    settings.setUnmappedObjects(unmapped);
}
Also used : ApiAdminSettings(im.actor.core.api.ApiAdminSettings) ObjectiveCName(com.google.j2objc.annotations.ObjectiveCName)

Example 3 with ObjectiveCName

use of com.google.j2objc.annotations.ObjectiveCName in project actor-platform by actorapp.

the class GroupPermissions method setShowAdminsToMembers.

@ObjectiveCName("showAdminsToMembers:")
public void setShowAdminsToMembers(boolean showAdminsToMembers) {
    SparseArray<Object> unmapped = settings.getUnmappedObjects();
    settings = new ApiAdminSettings(showAdminsToMembers, settings.canMembersInvite(), settings.canMembersEditGroupInfo(), settings.canAdminsEditGroupInfo(), settings.showJoinLeaveMessages());
    settings.setUnmappedObjects(unmapped);
}
Also used : ApiAdminSettings(im.actor.core.api.ApiAdminSettings) ObjectiveCName(com.google.j2objc.annotations.ObjectiveCName)

Example 4 with ObjectiveCName

use of com.google.j2objc.annotations.ObjectiveCName in project actor-platform by actorapp.

the class I18nEngine method formatPresence.

// 
// Presence
// 
@ObjectiveCName("formatPresence:withSex:")
public String formatPresence(UserPresence value, Sex sex) {
    if (value == null) {
        return null;
    }
    String[] sexType = DEFAULT;
    if (sex == Sex.MALE) {
        sexType = MALE;
    } else if (sex == Sex.FEMALE) {
        sexType = FEMALE;
    }
    if (value.getState() == UserPresence.State.OFFLINE) {
        long currentTime = im.actor.runtime.Runtime.getCurrentSyncedTime() / 1000L;
        int delta = (int) (currentTime - value.getLastSeen());
        if (delta < 60) {
            return get("presence.now", sexType);
        } else if (delta < 24 * 60 * 60) {
            String time = formatTime(value.getLastSeen() * 1000L);
            if (areSameDays(value.getLastSeen() * 1000L, new Date().getTime())) {
                return get("presence.today", sexType).replace("{time}", time);
            } else {
                return get("presence.yesterday", sexType).replace("{time}", time);
            }
        } else if (delta < 14 * 24 * 60 * 60) {
            String time = formatTime(value.getLastSeen() * 1000L);
            String date = formatDate(value.getLastSeen() * 1000L);
            return get("presence.at_day_time", sexType).replace("{time}", time).replace("{date}", date);
        } else if (delta < 6 * 30 * 24 * 60 * 60) {
            String date = formatDate(value.getLastSeen() * 1000L);
            return get("presence.at_day", sexType).replace("{date}", date);
        } else {
            return get("presence.offline", sexType);
        }
    } else if (value.getState() == UserPresence.State.ONLINE) {
        return get("presence.online", sexType);
    }
    return null;
}
Also used : Date(java.util.Date) ObjectiveCName(com.google.j2objc.annotations.ObjectiveCName)

Example 5 with ObjectiveCName

use of com.google.j2objc.annotations.ObjectiveCName in project actor-platform by actorapp.

the class I18nEngine method formatMessagesExport.

// 
// Exporting messages
// 
/**
 * Formatting messages for exporting
 *
 * @param messages messages to export
 * @return formatted text
 */
@ObjectiveCName("formatMessagesExport:")
public String formatMessagesExport(Message[] messages) {
    String text = "";
    Arrays.sort(messages, new Comparator<Message>() {

        int compare(long lhs, long rhs) {
            return lhs < rhs ? -1 : (lhs == rhs ? 0 : 1);
        }

        @Override
        public int compare(Message lhs, Message rhs) {
            return compare(lhs.getEngineSort(), rhs.getEngineSort());
        }
    });
    if (messages.length == 1) {
        for (Message model : messages) {
            if (!(model.getContent() instanceof TextContent)) {
                continue;
            }
            text += ((TextContent) model.getContent()).getText();
        }
    } else {
        for (Message model : messages) {
            if (!(model.getContent() instanceof TextContent)) {
                continue;
            }
            if (text.length() > 0) {
                text += "\n";
            }
            text += getUser(model.getSenderId()).getName() + ": ";
            text += ((TextContent) model.getContent()).getText();
        }
    }
    return text;
}
Also used : Message(im.actor.core.entity.Message) TextContent(im.actor.core.entity.content.TextContent) ObjectiveCName(com.google.j2objc.annotations.ObjectiveCName)

Aggregations

ObjectiveCName (com.google.j2objc.annotations.ObjectiveCName)12 ApiAdminSettings (im.actor.core.api.ApiAdminSettings)5 Date (java.util.Date)2 List (java.util.List)2 Predicate (com.google.common.base.Predicate)1 Iterables (com.google.common.collect.Iterables)1 Lists (com.google.common.collect.Lists)1 Options (com.google.devtools.j2objc.Options)1 AbstractTypeDeclaration (com.google.devtools.j2objc.ast.AbstractTypeDeclaration)1 Annotation (com.google.devtools.j2objc.ast.Annotation)1 BodyDeclaration (com.google.devtools.j2objc.ast.BodyDeclaration)1 CompilationUnit (com.google.devtools.j2objc.ast.CompilationUnit)1 Expression (com.google.devtools.j2objc.ast.Expression)1 FieldDeclaration (com.google.devtools.j2objc.ast.FieldDeclaration)1 FunctionDeclaration (com.google.devtools.j2objc.ast.FunctionDeclaration)1 MethodDeclaration (com.google.devtools.j2objc.ast.MethodDeclaration)1 NativeDeclaration (com.google.devtools.j2objc.ast.NativeDeclaration)1 SingleMemberAnnotation (com.google.devtools.j2objc.ast.SingleMemberAnnotation)1 SingleVariableDeclaration (com.google.devtools.j2objc.ast.SingleVariableDeclaration)1 TreeNode (com.google.devtools.j2objc.ast.TreeNode)1