use of com.orgzly.org.OrgHead in project orgzly-android by orgzly.
the class NoteFragment method updateNoteFromBundle.
/**
* Bundle -> Note
*/
private void updateNoteFromBundle(Bundle savedInstanceState) {
OrgHead head = mNote.getHead();
head.setState(savedInstanceState.getString(ARG_CURRENT_STATE));
head.setPriority(savedInstanceState.getString(ARG_CURRENT_PRIORITY));
head.setTitle(savedInstanceState.getString(ARG_CURRENT_TITLE));
if (savedInstanceState.getString(ARG_CURRENT_TAGS) != null) {
head.setTags(savedInstanceState.getString(ARG_CURRENT_TAGS).split("\\s+"));
} else {
head.setTags(new String[] {});
}
if (TextUtils.isEmpty(savedInstanceState.getString(ARG_CURRENT_SCHEDULED))) {
head.setScheduled(null);
} else {
head.setScheduled(OrgRange.parse(savedInstanceState.getString(ARG_CURRENT_SCHEDULED)));
}
if (TextUtils.isEmpty(savedInstanceState.getString(ARG_CURRENT_DEADLINE))) {
head.setDeadline(null);
} else {
head.setDeadline(OrgRange.parse(savedInstanceState.getString(ARG_CURRENT_DEADLINE)));
}
if (TextUtils.isEmpty(savedInstanceState.getString(ARG_CURRENT_CLOSED))) {
head.setClosed(null);
} else {
head.setClosed(OrgRange.parse(savedInstanceState.getString(ARG_CURRENT_CLOSED)));
}
head.removeProperties();
if (savedInstanceState.containsKey(ARG_CURRENT_PROPERTIES)) {
ArrayList<String> array = savedInstanceState.getStringArrayList(ARG_CURRENT_PROPERTIES);
if (array != null) {
for (int i = 0; i < array.size(); i += 2) {
head.addProperty(array.get(i), array.get(i + 1));
}
}
}
head.setContent(savedInstanceState.getString(ARG_CURRENT_CONTENT));
}
use of com.orgzly.org.OrgHead in project orgzly-android by orgzly.
the class NoteFragment method onDateTimeSet.
@Override
public /* TimestampDialog */
void onDateTimeSet(int id, TreeSet<Long> noteIds, OrgDateTime time) {
if (mNote == null) {
return;
}
OrgHead head = mNote.getHead();
OrgRange range = new OrgRange(time);
switch(id) {
case R.id.fragment_note_scheduled_button:
updateTimestampView(TimeType.SCHEDULED, mScheduledButton, range);
head.setScheduled(range);
break;
case R.id.fragment_note_deadline_button:
updateTimestampView(TimeType.DEADLINE, mDeadlineButton, range);
head.setDeadline(range);
break;
case R.id.fragment_note_closed_button:
updateTimestampView(TimeType.CLOSED, mClosedButton, range);
head.setClosed(range);
break;
}
}
use of com.orgzly.org.OrgHead in project orgzly-android by orgzly.
the class NoteFragment method updateViewsFromNote.
/**
* Note -> Views
*/
private void updateViewsFromNote() {
OrgHead head = mNote.getHead();
setStateView(head.getState());
setPriorityView(head.getPriority());
/* Title. */
mTitleView.setText(head.getTitle());
/* Tags. */
if (head.hasTags()) {
mTagsView.setText(TextUtils.join(" ", head.getTags()));
} else {
mTagsView.setText(null);
}
/* Times. */
updateTimestampView(TimeType.SCHEDULED, mScheduledButton, head.getScheduled());
updateTimestampView(TimeType.DEADLINE, mDeadlineButton, head.getDeadline());
updateTimestampView(TimeType.CLOSED, mClosedButton, head.getClosed());
/* Properties. */
propertyList.removeAllViews();
if (head.hasProperties()) {
OrgProperties properties = head.getProperties();
for (String name : properties.keySet()) {
String value = properties.get(name);
addPropertyToList(name, value);
}
}
/* Content. */
bodyEdit.setText(head.getContent());
bodyView.setText(OrgFormatter.INSTANCE.parse(head.getContent(), getContext()));
}
use of com.orgzly.org.OrgHead in project orgzly-android by orgzly.
the class ListWidgetViewsFactory method setupNoteRow.
private void setupNoteRow(RemoteViews row, Cursor cursor) {
Note note = NotesClient.fromCursor(cursor);
if (isPartitioned) {
Long originalId = originalNoteIDs.get(note.getId()).getNoteId();
note.setId(originalId);
}
OrgHead head = note.getHead();
row.setTextViewText(R.id.item_list_widget_title, titleGenerator.generateTitle(note, head));
/* Closed time. */
if (head.hasClosed() && AppPreferences.displayPlanning(mContext)) {
row.setTextViewText(R.id.item_list_widget_closed_text, userTimeFormatter.formatAll(head.getClosed()));
row.setViewVisibility(R.id.item_list_widget_closed, View.VISIBLE);
} else {
row.setViewVisibility(R.id.item_list_widget_closed, View.GONE);
}
/* Deadline time. */
if (head.hasDeadline() && AppPreferences.displayPlanning(mContext)) {
row.setTextViewText(R.id.item_list_widget_deadline_text, userTimeFormatter.formatAll(head.getDeadline()));
row.setViewVisibility(R.id.item_list_widget_deadline, View.VISIBLE);
} else {
row.setViewVisibility(R.id.item_list_widget_deadline, View.GONE);
}
/* Scheduled time. */
if (head.hasScheduled() && AppPreferences.displayPlanning(mContext)) {
row.setTextViewText(R.id.item_list_widget_scheduled_text, userTimeFormatter.formatAll(head.getScheduled()));
row.setViewVisibility(R.id.item_list_widget_scheduled, View.VISIBLE);
} else {
row.setViewVisibility(R.id.item_list_widget_scheduled, View.GONE);
}
if (AppPreferences.todoKeywordsSet(mContext).contains(head.getState())) {
row.setViewVisibility(R.id.item_list_widget_done, View.VISIBLE);
} else {
row.setViewVisibility(R.id.item_list_widget_done, View.GONE);
}
final Intent openIntent = new Intent();
openIntent.putExtra(AppIntent.EXTRA_CLICK_TYPE, ListWidgetProvider.OPEN_CLICK_TYPE);
openIntent.putExtra(AppIntent.EXTRA_NOTE_ID, note.getId());
openIntent.putExtra(AppIntent.EXTRA_BOOK_ID, note.getPosition().getBookId());
row.setOnClickFillInIntent(R.id.item_list_widget_layout, openIntent);
final Intent doneIntent = new Intent();
doneIntent.putExtra(AppIntent.EXTRA_CLICK_TYPE, ListWidgetProvider.DONE_CLICK_TYPE);
doneIntent.putExtra(AppIntent.EXTRA_NOTE_ID, note.getId());
row.setOnClickFillInIntent(R.id.item_list_widget_done, doneIntent);
if (BuildConfig.LOG_DEBUG)
LogUtils.d(TAG, row, cursor);
}
use of com.orgzly.org.OrgHead in project orgzly-android by orgzly.
the class HeadsListViewAdapter method bindView.
@Override
public void bindView(final View view, final Context context, Cursor cursor) {
final Note note = NotesClient.fromCursor(cursor, !inBook);
final OrgHead head = note.getHead();
final ViewHolder holder = (ViewHolder) view.getTag();
/* Attach some often used data to the view to avoid having to query for it later. */
view.setTag(R.id.note_view_state, head.getState());
if (inBook) {
if (note.getPosition().getFoldedUnderId() == 0) {
view.setVisibility(View.VISIBLE);
} else {
view.setVisibility(View.GONE);
}
}
setupIndentContainer(context, holder.indentContainer, inBook ? note.getPosition().getLevel() - 1 : // No indentation unless in book
0);
updateBullet(note, holder);
if (updateFoldingButton(context, note, holder)) {
holder.foldButton.setOnClickListener(v -> toggleFoldedState(context, note.getId()));
holder.bullet.setOnClickListener(v -> toggleFoldedState(context, note.getId()));
} else {
holder.foldButton.setOnClickListener(null);
holder.bullet.setOnClickListener(null);
}
/* Book name. */
if (inBook) {
holder.bookNameUnderNote.setVisibility(View.GONE);
holder.bookNameLeftFromNoteText.setVisibility(View.GONE);
} else {
switch(Integer.valueOf(AppPreferences.bookNameInSearchResults(context))) {
case 0:
holder.bookNameLeftFromNoteText.setVisibility(View.GONE);
holder.bookNameUnderNote.setVisibility(View.GONE);
break;
case 1:
holder.bookNameLeftFromNoteText.setText(cursor.getString(cursor.getColumnIndex(DbNoteView.BOOK_NAME)));
holder.bookNameLeftFromNoteText.setVisibility(View.VISIBLE);
holder.bookNameUnderNote.setVisibility(View.GONE);
break;
case 2:
holder.bookNameUnderNoteText.setText(cursor.getString(cursor.getColumnIndex(DbNoteView.BOOK_NAME)));
holder.bookNameLeftFromNoteText.setVisibility(View.GONE);
holder.bookNameUnderNote.setVisibility(View.VISIBLE);
break;
}
}
/* Title. */
holder.title.setText(titleGenerator.generateTitle(note, head));
/* Content. */
if (head.hasContent() && titleGenerator.shouldDisplayContent(note)) {
if (AppPreferences.isFontMonospaced(context)) {
holder.content.setTypeface(Typeface.MONOSPACE);
}
holder.content.setText(OrgFormatter.INSTANCE.parse(head.getContent(), context));
holder.content.setVisibility(View.VISIBLE);
} else {
holder.content.setVisibility(View.GONE);
}
/* Closed time. */
if (head.hasClosed() && AppPreferences.displayPlanning(context)) {
holder.closedText.setText(userTimeFormatter.formatAll(head.getClosed()));
holder.closed.setVisibility(View.VISIBLE);
} else {
holder.closed.setVisibility(View.GONE);
}
/* Deadline time. */
if (head.hasDeadline() && AppPreferences.displayPlanning(context)) {
holder.deadlineText.setText(userTimeFormatter.formatAll(head.getDeadline()));
holder.deadline.setVisibility(View.VISIBLE);
} else {
holder.deadline.setVisibility(View.GONE);
}
/* Scheduled time. */
if (head.hasScheduled() && AppPreferences.displayPlanning(context)) {
holder.scheduledText.setText(userTimeFormatter.formatAll(head.getScheduled()));
holder.scheduled.setVisibility(View.VISIBLE);
} else {
holder.scheduled.setVisibility(View.GONE);
}
/* Set alpha for done items. */
if (head.getState() != null && AppPreferences.doneKeywordsSet(context).contains(head.getState())) {
holder.payload.setAlpha(0.45f);
} else {
holder.payload.setAlpha(1.0f);
}
quickMenu.updateView(view, note.getId(), holder.menuContainer, holder.menuFlipper);
selection.updateView(view, note.getId());
}
Aggregations