Search in sources :

Example 1 with NoteComment

use of de.westnordost.osmapi.notes.NoteComment in project StreetComplete by westnordost.

the class CreateNoteUploadTest method createNote.

private Note createNote(CreateNote fitsTo) {
    Note note = new Note();
    note.id = 2;
    note.status = Note.Status.OPEN;
    note.dateCreated = new Date();
    note.position = new OsmLatLon(1, 2);
    NoteComment comment = new NoteComment();
    comment.text = "bla bla";
    if (fitsTo != null) {
        comment.text += CreateNoteUpload.getAssociatedElementString(fitsTo);
    }
    comment.action = NoteComment.Action.OPENED;
    comment.date = new Date();
    note.comments.add(0, comment);
    return note;
}
Also used : NoteComment(de.westnordost.osmapi.notes.NoteComment) Note(de.westnordost.osmapi.notes.Note) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) Date(java.util.Date)

Example 2 with NoteComment

use of de.westnordost.osmapi.notes.NoteComment in project StreetComplete by westnordost.

the class NoteDaoTest method createNote.

static Note createNote() {
    Note note = new Note();
    note.position = new OsmLatLon(1, 1);
    note.status = Note.Status.OPEN;
    note.id = 5;
    note.dateCreated = new Date(5000);
    NoteComment comment = new NoteComment();
    comment.text = "hi";
    comment.date = new Date(5000);
    comment.action = NoteComment.Action.OPENED;
    comment.user = new User(5, "PingPong");
    note.comments.add(comment);
    return note;
}
Also used : NoteComment(de.westnordost.osmapi.notes.NoteComment) User(de.westnordost.osmapi.user.User) Note(de.westnordost.osmapi.notes.Note) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) Date(java.util.Date)

Example 3 with NoteComment

use of de.westnordost.osmapi.notes.NoteComment in project StreetComplete by westnordost.

the class NoteDiscussionForm method inflateNoteDiscussion.

private void inflateNoteDiscussion(Note note) {
    for (NoteComment noteComment : note.comments) {
        CharSequence userName;
        if (noteComment.isAnonymous()) {
            userName = getResources().getString(R.string.quest_noteDiscussion_anonymous);
        } else {
            userName = noteComment.user.displayName;
        }
        CharSequence dateDescription = DateUtils.getRelativeTimeSpanString(noteComment.date.getTime(), new Date().getTime(), MINUTE_IN_MILLIS);
        CharSequence commenter = String.format(getResources().getString(getNoteCommentActionResourceId(noteComment.action)), userName, dateDescription);
        if (noteComment == note.comments.get(0)) {
            TextView noteText = getView().findViewById(R.id.noteText);
            noteText.setText(noteComment.text);
            TextView noteAuthor = getView().findViewById(R.id.noteAuthor);
            noteAuthor.setText(commenter);
        } else {
            ViewGroup discussionItem = (ViewGroup) LayoutInflater.from(getActivity()).inflate(R.layout.quest_note_discussion_item, noteDiscussion, false);
            TextView commentInfo = discussionItem.findViewById(R.id.comment_info);
            commentInfo.setText(commenter);
            TextView commentText = discussionItem.findViewById(R.id.comment_text);
            commentText.setText(noteComment.text);
            noteDiscussion.addView(discussionItem);
        }
    }
}
Also used : NoteComment(de.westnordost.osmapi.notes.NoteComment) ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) Date(java.util.Date)

Example 4 with NoteComment

use of de.westnordost.osmapi.notes.NoteComment in project StreetComplete by westnordost.

the class OsmNotesDownload method userProbablyCreatedNoteInApp.

private boolean userProbablyCreatedNoteInApp(Long userId, Note note) {
    if (userId == null)
        return false;
    NoteComment firstComment = note.comments.get(0);
    boolean isViaApp = firstComment.text.contains("via " + ApplicationConstants.NAME);
    return isFromUser(userId, firstComment) && isViaApp;
}
Also used : NoteComment(de.westnordost.osmapi.notes.NoteComment)

Example 5 with NoteComment

use of de.westnordost.osmapi.notes.NoteComment in project StreetComplete by westnordost.

the class OsmNotesDownloadTest method createANote.

private Note createANote() {
    Note note = new Note();
    note.id = 4;
    note.position = new OsmLatLon(6.0, 7.0);
    note.status = Note.Status.OPEN;
    note.dateCreated = new Date();
    NoteComment comment = new NoteComment();
    comment.date = new Date();
    comment.action = NoteComment.Action.OPENED;
    comment.text = "hurp durp";
    note.comments.add(comment);
    return note;
}
Also used : NoteComment(de.westnordost.osmapi.notes.NoteComment) Note(de.westnordost.osmapi.notes.Note) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) Date(java.util.Date)

Aggregations

NoteComment (de.westnordost.osmapi.notes.NoteComment)6 Date (java.util.Date)4 OsmLatLon (de.westnordost.osmapi.map.data.OsmLatLon)3 Note (de.westnordost.osmapi.notes.Note)3 ViewGroup (android.view.ViewGroup)1 TextView (android.widget.TextView)1 User (de.westnordost.osmapi.user.User)1