use of com.orgzly.android.Note in project orgzly-android by orgzly.
the class NotesClient method fromCursor.
public static Note fromCursor(Cursor cursor, boolean withExtras) {
long id = idFromCursor(cursor);
long createdAt = cursor.getLong(cursor.getColumnIndex(DbNoteView.CREATED_AT));
int contentLines = cursor.getInt(cursor.getColumnIndex(DbNoteView.CONTENT_LINE_COUNT));
OrgHead head = headFromCursor(cursor);
NotePosition position = DbNote.positionFromCursor(cursor);
Note note = new Note();
note.setHead(head);
note.setId(id);
note.setCreatedAt(createdAt);
note.setPosition(position);
note.setContentLines(contentLines);
if (withExtras) {
String inheritedTags = cursor.getString(cursor.getColumnIndex(DbNoteView.INHERITED_TAGS));
if (!TextUtils.isEmpty(inheritedTags)) {
note.setInheritedTags(DbNote.dbDeSerializeTags(inheritedTags));
}
}
return note;
}
use of com.orgzly.android.Note in project orgzly-android by orgzly.
the class MainActivity method openNote.
private void openNote(long noteId) {
finishActionMode();
// TODO: Avoid using Shelf from activity directly
Shelf shelf = new Shelf(this);
Note note = shelf.getNote(noteId);
if (note != null) {
long bookId = note.getPosition().getBookId();
Intent intent = new Intent(AppIntent.ACTION_OPEN_NOTE);
intent.putExtra(AppIntent.EXTRA_NOTE_ID, noteId);
intent.putExtra(AppIntent.EXTRA_BOOK_ID, bookId);
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent);
}
}
use of com.orgzly.android.Note in project orgzly-android by orgzly.
the class SyncTest method testOrgRange.
@Test
public void testOrgRange() {
shelfTestUtils.setupRepo("mock://repo-a");
shelfTestUtils.setupRook("mock://repo-a", "mock://repo-a/remote-book-1.org", "* Note\nSCHEDULED: <2015-01-13 уто 13:00-14:14>--<2015-01-14 сре 14:10-15:20>", "0abcdef", 1400067156);
shelf.sync();
Note note = shelf.getNote(2);
/* ID 1 was a root from dummy which was deleted. */
OrgRange range = note.getHead().getScheduled();
assertEquals("<2015-01-13 уто 13:00-14:14>--<2015-01-14 сре 14:10-15:20>", range.toString());
}
use of com.orgzly.android.Note in project orgzly-android by orgzly.
the class NoteFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
if (BuildConfig.LOG_DEBUG)
LogUtils.d(TAG, savedInstanceState);
super.onActivityCreated(savedInstanceState);
if (mBookId != 0) {
// FIXME: ANR reported
mBook = mShelf.getBook(mBookId);
}
if (mIsNew) {
/* Creating new note. */
mNote = new Note();
mNote.getPosition().setBookId(mBookId);
updateNewNoteValues();
mViewFlipper.setDisplayedChild(0);
editSwitch.setChecked(true);
/* Open keyboard for new notes, unless fragment was given
* some initial values (for example from ShareActivity).
*/
if (TextUtils.isEmpty(mInitialTitle) && TextUtils.isEmpty(mInitialContent)) {
ActivityUtils.INSTANCE.openSoftKeyboard(getActivity(), mTitleView);
}
} else {
/* Get existing note from database. */
mNote = mShelf.getNote(mNoteId);
if (mNote != null) {
// TODO: Cleanup: getNote(id, withProperties) or such
mNote.getHead().setProperties(mShelf.getNoteProperties(mNoteId));
mViewFlipper.setDisplayedChild(0);
} else {
mViewFlipper.setDisplayedChild(1);
}
}
if (mNote != null) {
/* Get current values from saved Bundle and populate all views. */
if (savedInstanceState != null) {
updateNoteFromBundle(savedInstanceState);
}
/* Update views from note. */
updateViewsFromNote();
}
/* Store the hash value of original note. */
if (!getArguments().containsKey(ARG_ORIGINAL_NOTE_HASH) && mNote != null) {
getArguments().putLong(ARG_ORIGINAL_NOTE_HASH, noteHash(mNote));
}
/* Refresh action bar items (hide or display, depending on if book is loaded. */
if (getActivity() != null) {
getActivity().invalidateOptionsMenu();
}
}
use of com.orgzly.android.Note in project orgzly-android by orgzly.
the class SettingsTest method testStateChangeAndNotesReparse.
@Test
public void testStateChangeAndNotesReparse() throws IOException {
Note note;
shelfTestUtils.setupBook("booky", "* TODO [#A] Title");
AppPreferences.states(context, "TODO|DONE");
shelf.reParseNotesStateAndTitles();
note = shelf.getNote(1);
assertEquals("TODO", note.getHead().getState());
assertEquals("A", note.getHead().getPriority());
assertEquals("Title", note.getHead().getTitle());
AppPreferences.states(context, "");
shelf.reParseNotesStateAndTitles();
note = shelf.getNote(1);
assertNull(note.getHead().getState());
assertNull(note.getHead().getPriority());
assertEquals("TODO [#A] Title", note.getHead().getTitle());
AppPreferences.states(context, "TODO|DONE");
shelf.reParseNotesStateAndTitles();
note = shelf.getNote(1);
assertEquals("TODO", note.getHead().getState());
assertEquals("A", note.getHead().getPriority());
assertEquals("Title", note.getHead().getTitle());
}
Aggregations