mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 02:39:23 +02:00
bookmark style (in progress)
This commit is contained in:
parent
e8d28b6d87
commit
4bdf7a0a71
5 changed files with 39 additions and 9 deletions
|
@ -840,8 +840,10 @@ final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
.append(" bm.bookmark_id,bm.book_id,b.title,bm.bookmark_text,")
|
.append(" bm.bookmark_id,bm.book_id,b.title,bm.bookmark_text,")
|
||||||
.append("bm.creation_time,bm.modification_time,bm.access_time,bm.access_counter,")
|
.append("bm.creation_time,bm.modification_time,bm.access_time,bm.access_counter,")
|
||||||
.append("bm.model_id,bm.paragraph,bm.word,bm.char,")
|
.append("bm.model_id,bm.paragraph,bm.word,bm.char,")
|
||||||
.append("bm.end_paragraph,bm.end_word,bm.end_character")
|
.append("bm.end_paragraph,bm.end_word,bm.end_character,")
|
||||||
.append(" FROM Bookmarks AS bm INNER JOIN Books AS b ON b.book_id = bm.book_id")
|
.append("bm.style_id")
|
||||||
|
.append(" FROM Bookmarks AS bm")
|
||||||
|
.append(" INNER JOIN Books AS b ON b.book_id = bm.book_id")
|
||||||
.append(" WHERE");
|
.append(" WHERE");
|
||||||
if (query.Book != null) {
|
if (query.Book != null) {
|
||||||
sql.append(" b.book_id = " + query.Book.getId() +" AND");
|
sql.append(" b.book_id = " + query.Book.getId() +" AND");
|
||||||
|
@ -868,7 +870,8 @@ final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
(int)cursor.getLong(12),
|
(int)cursor.getLong(12),
|
||||||
cursor.isNull(13) ? -1 : (int)cursor.getLong(13),
|
cursor.isNull(13) ? -1 : (int)cursor.getLong(13),
|
||||||
cursor.isNull(14) ? -1 : (int)cursor.getLong(14),
|
cursor.isNull(14) ? -1 : (int)cursor.getLong(14),
|
||||||
query.Visible
|
query.Visible,
|
||||||
|
(int)cursor.getLong(15)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
@ -1392,8 +1395,11 @@ final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
myDatabase.execSQL(
|
myDatabase.execSQL(
|
||||||
"CREATE TABLE IF NOT EXISTS HighlightingStyle(" +
|
"CREATE TABLE IF NOT EXISTS HighlightingStyle(" +
|
||||||
"style_id INTEGER PRIMARY KEY," +
|
"style_id INTEGER PRIMARY KEY," +
|
||||||
|
"name TEXT," +
|
||||||
"bg_color INTEGER NOT NULL)");
|
"bg_color INTEGER NOT NULL)");
|
||||||
myDatabase.execSQL("INSERT INTO HighlightingStyle (style_id, bg_color) VALUES (1, 127*256*256 + 127*256 + 127)");
|
myDatabase.execSQL("INSERT INTO HighlightingStyle (style_id, name, bg_color) VALUES (1, 'default', 136*256*256 + 138*256 + 133)"); // #888a85
|
||||||
|
myDatabase.execSQL("INSERT INTO HighlightingStyle (style_id, name, bg_color) VALUES (2, 'orange', 245*256*256 + 121*256 + 0)"); // #f57900
|
||||||
|
myDatabase.execSQL("INSERT INTO HighlightingStyle (style_id, name, bg_color) VALUES (3, 'blue', 114*160*256 + 159*256 + 207)"); // #729fcf
|
||||||
myDatabase.execSQL("ALTER TABLE Bookmarks ADD COLUMN style_id INTEGER NOT NULL REFERENCES HighlightingStyle(style_id) DEFAULT 1");
|
myDatabase.execSQL("ALTER TABLE Bookmarks ADD COLUMN style_id INTEGER NOT NULL REFERENCES HighlightingStyle(style_id) DEFAULT 1");
|
||||||
myDatabase.execSQL("UPDATE Bookmarks SET end_paragraph = LENGTH(bookmark_text)");
|
myDatabase.execSQL("UPDATE Bookmarks SET end_paragraph = LENGTH(bookmark_text)");
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ public final class Bookmark extends ZLTextFixedPosition {
|
||||||
private Date myLatestDate;
|
private Date myLatestDate;
|
||||||
private ZLTextFixedPosition myEnd;
|
private ZLTextFixedPosition myEnd;
|
||||||
private int myLength;
|
private int myLength;
|
||||||
|
private int myStyleId;
|
||||||
|
|
||||||
public final String ModelId;
|
public final String ModelId;
|
||||||
public final boolean IsVisible;
|
public final boolean IsVisible;
|
||||||
|
@ -52,7 +53,8 @@ public final class Bookmark extends ZLTextFixedPosition {
|
||||||
String modelId,
|
String modelId,
|
||||||
int start_paragraphIndex, int start_elementIndex, int start_charIndex,
|
int start_paragraphIndex, int start_elementIndex, int start_charIndex,
|
||||||
int end_paragraphIndex, int end_elementIndex, int end_charIndex,
|
int end_paragraphIndex, int end_elementIndex, int end_charIndex,
|
||||||
boolean isVisible
|
boolean isVisible,
|
||||||
|
int styleId
|
||||||
) {
|
) {
|
||||||
super(start_paragraphIndex, start_elementIndex, start_charIndex);
|
super(start_paragraphIndex, start_elementIndex, start_charIndex);
|
||||||
|
|
||||||
|
@ -78,6 +80,8 @@ public final class Bookmark extends ZLTextFixedPosition {
|
||||||
} else {
|
} else {
|
||||||
myLength = end_paragraphIndex;
|
myLength = end_paragraphIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
myStyleId = styleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Buffer {
|
private static class Buffer {
|
||||||
|
@ -197,6 +201,7 @@ mainLoop:
|
||||||
ModelId = modelId;
|
ModelId = modelId;
|
||||||
IsVisible = isVisible;
|
IsVisible = isVisible;
|
||||||
myEnd = new ZLTextFixedPosition(end);
|
myEnd = new ZLTextFixedPosition(end);
|
||||||
|
myStyleId = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
|
@ -207,6 +212,10 @@ mainLoop:
|
||||||
return myBookId;
|
return myBookId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getStyleId() {
|
||||||
|
return myStyleId;
|
||||||
|
}
|
||||||
|
|
||||||
public String getText() {
|
public String getText() {
|
||||||
return myText;
|
return myText;
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,8 @@ public abstract class BooksDatabase {
|
||||||
String modelId,
|
String modelId,
|
||||||
int start_paragraphIndex, int start_wordIndex, int start_charIndex,
|
int start_paragraphIndex, int start_wordIndex, int start_charIndex,
|
||||||
int end_paragraphIndex, int end_wordIndex, int end_charIndex,
|
int end_paragraphIndex, int end_wordIndex, int end_charIndex,
|
||||||
boolean isVisible
|
boolean isVisible,
|
||||||
|
int styleId
|
||||||
) {
|
) {
|
||||||
return new Bookmark(
|
return new Bookmark(
|
||||||
id, bookId, bookTitle, text,
|
id, bookId, bookTitle, text,
|
||||||
|
@ -100,7 +101,8 @@ public abstract class BooksDatabase {
|
||||||
modelId,
|
modelId,
|
||||||
start_paragraphIndex, start_wordIndex, start_charIndex,
|
start_paragraphIndex, start_wordIndex, start_charIndex,
|
||||||
end_paragraphIndex, end_wordIndex, end_charIndex,
|
end_paragraphIndex, end_wordIndex, end_charIndex,
|
||||||
isVisible
|
isVisible,
|
||||||
|
styleId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -284,6 +284,10 @@ class XMLSerializer extends AbstractSerializer {
|
||||||
"length", String.valueOf(bookmark.getLength())
|
"length", String.valueOf(bookmark.getLength())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
appendTag(
|
||||||
|
buffer, "style", true,
|
||||||
|
"id", String.valueOf(bookmark.getStyleId())
|
||||||
|
);
|
||||||
closeTag(buffer, "bookmark");
|
closeTag(buffer, "bookmark");
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
@ -784,6 +788,7 @@ class XMLSerializer extends AbstractSerializer {
|
||||||
private int myEndElementIndex;
|
private int myEndElementIndex;
|
||||||
private int myEndCharIndex;
|
private int myEndCharIndex;
|
||||||
private boolean myIsVisible;
|
private boolean myIsVisible;
|
||||||
|
private int myStyle;
|
||||||
|
|
||||||
public Bookmark getBookmark() {
|
public Bookmark getBookmark() {
|
||||||
return myState == State.READ_NOTHING ? myBookmark : null;
|
return myState == State.READ_NOTHING ? myBookmark : null;
|
||||||
|
@ -809,6 +814,7 @@ class XMLSerializer extends AbstractSerializer {
|
||||||
myEndElementIndex = -1;
|
myEndElementIndex = -1;
|
||||||
myEndCharIndex = -1;
|
myEndCharIndex = -1;
|
||||||
myIsVisible = false;
|
myIsVisible = false;
|
||||||
|
myStyle = 1;
|
||||||
|
|
||||||
myState = State.READ_NOTHING;
|
myState = State.READ_NOTHING;
|
||||||
}
|
}
|
||||||
|
@ -824,7 +830,8 @@ class XMLSerializer extends AbstractSerializer {
|
||||||
myModelId,
|
myModelId,
|
||||||
myStartParagraphIndex, myStartElementIndex, myStartCharIndex,
|
myStartParagraphIndex, myStartElementIndex, myStartCharIndex,
|
||||||
myEndParagraphIndex, myEndElementIndex, myEndCharIndex,
|
myEndParagraphIndex, myEndElementIndex, myEndCharIndex,
|
||||||
myIsVisible
|
myIsVisible,
|
||||||
|
myStyle
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -886,6 +893,12 @@ class XMLSerializer extends AbstractSerializer {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new SAXException("XML parsing error", e);
|
throw new SAXException("XML parsing error", e);
|
||||||
}
|
}
|
||||||
|
} else if ("style".equals(localName)) {
|
||||||
|
try {
|
||||||
|
myStyle = Integer.parseInt(attributes.getValue("id"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new SAXException("XML parsing error", e);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new SAXException("Unexpected tag " + localName);
|
throw new SAXException("Unexpected tag " + localName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,6 @@ public final class BookmarkHighlighting extends ZLTextSimpleHighlighting {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ZLColor getBackgroundColor() {
|
public ZLColor getBackgroundColor() {
|
||||||
return new ZLColor(127, 127, 127);
|
return new ZLColor(0x888A85);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue