use of com.orgzly.org.datetime.OrgDateTime in project orgzly-android by orgzly.
the class TitleGenerator method generateTitle.
public CharSequence generateTitle(Note note, OrgHead head) {
SpannableStringBuilder builder = new SpannableStringBuilder();
/* State. */
if (head.getState() != null) {
builder.append(generateState(head));
}
/* Priority. */
if (head.getPriority() != null) {
if (builder.length() > 0) {
builder.append(TITLE_SEPARATOR);
}
builder.append(generatePriority(head));
}
/* Bold everything up until now. */
if (builder.length() > 0) {
builder.setSpan(new StyleSpan(Typeface.BOLD), 0, builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
/* Space before title, unless there's nothing added. */
if (builder.length() > 0) {
builder.append(TITLE_SEPARATOR);
}
/* Title. */
builder.append(OrgFormatter.INSTANCE.parse(head.getTitle(), mContext));
/* Append note ID. */
// builder.append(TITLE_SEPARATOR).append("#").append(String.valueOf(note.getId()));
int mark = builder.length();
boolean hasPostTitleText = false;
/* Tags. */
if (head.hasTags()) {
builder.append(TITLE_SEPARATOR).append(generateTags(head.getTags()));
hasPostTitleText = true;
}
/* Inherited tags in search results. */
if (!inBook && note.hasInheritedTags() && AppPreferences.inheritedTagsInSearchResults(mContext)) {
if (head.hasTags()) {
builder.append(INHERITED_TAGS_SEPARATOR);
} else {
builder.append(TITLE_SEPARATOR);
}
builder.append(generateTags(note.getInheritedTags()));
hasPostTitleText = true;
}
/* Content line number. */
if (head.hasContent() && AppPreferences.contentLineCountDisplayed(mContext)) {
if (!shouldDisplayContent(note)) {
builder.append(TITLE_SEPARATOR).append(String.valueOf(note.getContentLines()));
hasPostTitleText = true;
}
}
if (false) {
String times = note.getCreatedAt() > 0 ? new OrgDateTime(note.getCreatedAt(), false).toString() : "N/A";
builder.append(" ").append(times);
hasPostTitleText = true;
}
/* Change font style of text after title. */
if (hasPostTitleText) {
builder.setSpan(attributes.postTitleTextSize, mark, builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
builder.setSpan(attributes.postTitleTextColor, mark, builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
return builder;
}
Aggregations