Search in sources :

Example 6 with OrgHead

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));
}
Also used : OrgHead(com.orgzly.org.OrgHead)

Example 7 with OrgHead

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;
    }
}
Also used : OrgHead(com.orgzly.org.OrgHead) OrgRange(com.orgzly.org.datetime.OrgRange)

Example 8 with OrgHead

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()));
}
Also used : OrgHead(com.orgzly.org.OrgHead) OrgProperties(com.orgzly.org.OrgProperties)

Example 9 with OrgHead

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);
}
Also used : OrgHead(com.orgzly.org.OrgHead) Note(com.orgzly.android.Note) Intent(android.content.Intent) AppIntent(com.orgzly.android.AppIntent)

Example 10 with OrgHead

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());
}
Also used : OrgHead(com.orgzly.org.OrgHead) Note(com.orgzly.android.Note)

Aggregations

OrgHead (com.orgzly.org.OrgHead)14 Note (com.orgzly.android.Note)4 Cursor (android.database.Cursor)2 DbNote (com.orgzly.android.provider.models.DbNote)2 OrgRange (com.orgzly.org.datetime.OrgRange)2 OrgParserWriter (com.orgzly.org.parser.OrgParserWriter)2 ContentProviderOperation (android.content.ContentProviderOperation)1 ContentValues (android.content.ContentValues)1 Intent (android.content.Intent)1 OperationApplicationException (android.content.OperationApplicationException)1 RemoteException (android.os.RemoteException)1 View (android.view.View)1 MultiAutoCompleteTextView (android.widget.MultiAutoCompleteTextView)1 ScrollView (android.widget.ScrollView)1 TextView (android.widget.TextView)1 AppIntent (com.orgzly.android.AppIntent)1 Book (com.orgzly.android.Book)1 NotePosition (com.orgzly.android.NotePosition)1 OrgzlyTest (com.orgzly.android.OrgzlyTest)1 CircularArrayList (com.orgzly.android.util.CircularArrayList)1