Search in sources :

Example 1 with Note

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

the class NoteDiscussionForm method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);
    View contentView = setContentView(R.layout.quest_note_discussion);
    View buttonPanel = setButtonsView(R.layout.quest_notediscussion_buttonbar);
    Button buttonOk = buttonPanel.findViewById(R.id.buttonOk);
    buttonOk.setOnClickListener(v -> onClickOk());
    Button buttonNo = buttonPanel.findViewById(R.id.buttonNo);
    buttonNo.setOnClickListener(v -> skipQuest());
    noteInput = contentView.findViewById(R.id.noteInput);
    noteDiscussion = contentView.findViewById(R.id.noteDiscussion);
    buttonOtherAnswers.setVisibility(View.GONE);
    new InlineAsyncTask<Note>() {

        @Override
        protected Note doInBackground() throws Exception {
            return noteDb.get(getQuestId()).getNote();
        }

        @Override
        public void onSuccess(Note result) {
            if (getActivity() != null && result != null) {
                inflateNoteDiscussion(result);
            }
        }

        @Override
        public void onError(Exception e) {
            Log.e(TAG, "Error fetching note quest " + getQuestId() + " from DB.", e);
        }
    }.execute();
    return view;
}
Also used : Button(android.widget.Button) Note(de.westnordost.osmapi.notes.Note) TextView(android.widget.TextView) View(android.view.View)

Example 2 with Note

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

the class CreateNoteUploadTest method testCreateNoteOnExistingNoteWillCommentOnExistingNote.

public void testCreateNoteOnExistingNoteWillCommentOnExistingNote() {
    CreateNote createNote = createACreateNote();
    createNote.elementType = Element.Type.WAY;
    createNote.elementId = 5L;
    Note note = createNote(createNote);
    setUpThereIsANoteFor(createNote, note);
    when(notesDao.comment(anyLong(), anyString())).thenReturn(note);
    assertNotNull(createNoteUpload.uploadCreateNote(createNote));
    verify(notesDao).comment(note.id, createNote.text);
    verifyNoteInsertedIntoDb(createNote.id, note);
}
Also used : Note(de.westnordost.osmapi.notes.Note)

Example 3 with Note

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

the class CreateNoteUploadTest method testCreateNoteWithNoAssociatedElement.

public void testCreateNoteWithNoAssociatedElement() {
    CreateNote createNote = createACreateNote();
    Note note = createNote(null);
    when(notesDao.create(any(LatLon.class), anyString())).thenReturn(note);
    assertNotNull(createNoteUpload.uploadCreateNote(createNote));
    verify(notesDao).create(createNote.position, createNote.text);
    verifyNoteInsertedIntoDb(createNote.id, note);
}
Also used : LatLon(de.westnordost.osmapi.map.data.LatLon) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) Note(de.westnordost.osmapi.notes.Note)

Example 4 with Note

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

the class CreateNoteUploadTest method testCreateNoteWithNoQuestTitleButAssociatedElement.

public void testCreateNoteWithNoQuestTitleButAssociatedElement() {
    CreateNote createNote = createACreateNote();
    createNote.elementType = Element.Type.WAY;
    createNote.elementId = 5L;
    when(mapDataDao.getWay(createNote.elementId)).thenReturn(mock(Way.class));
    Note note = createNote(null);
    when(notesDao.create(any(LatLon.class), anyString())).thenReturn(note);
    assertNotNull(createNoteUpload.uploadCreateNote(createNote));
    verify(notesDao).create(createNote.position, "for https://www.openstreetmap.org/way/5 via " + ApplicationConstants.USER_AGENT + ":\n\njo ho");
    verifyNoteInsertedIntoDb(createNote.id, note);
}
Also used : LatLon(de.westnordost.osmapi.map.data.LatLon) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) Note(de.westnordost.osmapi.notes.Note) Way(de.westnordost.osmapi.map.data.Way)

Example 5 with Note

use of de.westnordost.osmapi.notes.Note 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)

Aggregations

Note (de.westnordost.osmapi.notes.Note)32 OsmLatLon (de.westnordost.osmapi.map.data.OsmLatLon)10 Date (java.util.Date)8 LatLon (de.westnordost.osmapi.map.data.LatLon)5 ArrayList (java.util.ArrayList)5 BoundingBox (de.westnordost.osmapi.map.data.BoundingBox)4 NoteComment (de.westnordost.osmapi.notes.NoteComment)3 Way (de.westnordost.osmapi.map.data.Way)2 QuestStatus (de.westnordost.streetcomplete.data.QuestStatus)2 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 View (android.view.View)1 Button (android.widget.Button)1 TextView (android.widget.TextView)1 Handler (de.westnordost.osmapi.common.Handler)1 SingleElementHandler (de.westnordost.osmapi.common.SingleElementHandler)1 OsmConflictException (de.westnordost.osmapi.common.errors.OsmConflictException)1 NotesDao (de.westnordost.osmapi.notes.NotesDao)1 User (de.westnordost.osmapi.user.User)1 QuestGroup (de.westnordost.streetcomplete.data.QuestGroup)1 VisibleQuestListener (de.westnordost.streetcomplete.data.VisibleQuestListener)1