mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 09:49:19 +02:00
refactoring: selection bookmark creation code moved from FBReader to FBReaderApp and SelectionBookmarkAction
Conflicts: src/org/geometerplus/android/fbreader/FBReader.java
This commit is contained in:
parent
2e8c494352
commit
3f7b68c96d
4 changed files with 32 additions and 22 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
* re-implement go to bookmark operation
|
||||||
DONE highlight bookmarks
|
DONE highlight bookmarks
|
||||||
DONE show highlights in footnote view
|
DONE show highlights in footnote view
|
||||||
DONE don't draw all bookmarks, filter by position
|
DONE don't draw all bookmarks, filter by position
|
||||||
|
|
|
@ -638,27 +638,6 @@ public final class FBReader extends Activity {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addSelectionBookmark() {
|
|
||||||
final FBView fbView = myFBReaderApp.getTextView();
|
|
||||||
final String text = fbView.getSelectedText();
|
|
||||||
|
|
||||||
final Bookmark bookmark = new Bookmark(
|
|
||||||
myFBReaderApp.Model.Book,
|
|
||||||
fbView.getModel().getId(),
|
|
||||||
fbView.getSelectionStartPosition(),
|
|
||||||
fbView.getSelectionEndPosition(),
|
|
||||||
text,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
myFBReaderApp.Collection.saveBookmark(bookmark);
|
|
||||||
fbView.clearSelection();
|
|
||||||
|
|
||||||
UIUtil.showMessageText(
|
|
||||||
this,
|
|
||||||
ZLResource.resource("selection").getResource("bookmarkCreated").getValue().replace("%s", text)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
return (myMainView != null && myMainView.onKeyDown(keyCode, event)) || super.onKeyDown(keyCode, event);
|
return (myMainView != null && myMainView.onKeyDown(keyCode, event)) || super.onKeyDown(keyCode, event);
|
||||||
|
|
|
@ -19,8 +19,14 @@
|
||||||
|
|
||||||
package org.geometerplus.android.fbreader;
|
package org.geometerplus.android.fbreader;
|
||||||
|
|
||||||
|
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||||
|
|
||||||
|
import org.geometerplus.fbreader.book.Bookmark;
|
||||||
|
import org.geometerplus.fbreader.book.SerializerUtil;
|
||||||
import org.geometerplus.fbreader.fbreader.FBReaderApp;
|
import org.geometerplus.fbreader.fbreader.FBReaderApp;
|
||||||
|
|
||||||
|
import org.geometerplus.android.util.UIUtil;
|
||||||
|
|
||||||
public class SelectionBookmarkAction extends FBAndroidAction {
|
public class SelectionBookmarkAction extends FBAndroidAction {
|
||||||
SelectionBookmarkAction(FBReader baseApplication, FBReaderApp fbreader) {
|
SelectionBookmarkAction(FBReader baseApplication, FBReaderApp fbreader) {
|
||||||
super(baseApplication, fbreader);
|
super(baseApplication, fbreader);
|
||||||
|
@ -28,6 +34,12 @@ public class SelectionBookmarkAction extends FBAndroidAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void run(Object ... params) {
|
protected void run(Object ... params) {
|
||||||
BaseActivity.addSelectionBookmark();
|
final Bookmark bookmark = Reader.addSelectionBookmark();
|
||||||
|
UIUtil.showMessageText(
|
||||||
|
BaseActivity,
|
||||||
|
ZLResource.resource("selection").getResource("bookmarkCreated").getValue()
|
||||||
|
.replace("%s", bookmark.getText())
|
||||||
|
);
|
||||||
|
//final Intent styleIntent = new Intent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,6 +258,24 @@ public final class FBReaderApp extends ZLApplication {
|
||||||
FootnoteView.clearCaches();
|
FootnoteView.clearCaches();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Bookmark addSelectionBookmark() {
|
||||||
|
final FBView fbView = getTextView();
|
||||||
|
final String text = fbView.getSelectedText();
|
||||||
|
|
||||||
|
final Bookmark bookmark = new Bookmark(
|
||||||
|
Model.Book,
|
||||||
|
fbView.getModel().getId(),
|
||||||
|
fbView.getSelectionStartPosition(),
|
||||||
|
fbView.getSelectionEndPosition(),
|
||||||
|
text,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
Collection.saveBookmark(bookmark);
|
||||||
|
fbView.clearSelection();
|
||||||
|
|
||||||
|
return bookmark;
|
||||||
|
}
|
||||||
|
|
||||||
private void setBookmarkHighlightings(ZLTextView view, String modelId) {
|
private void setBookmarkHighlightings(ZLTextView view, String modelId) {
|
||||||
view.removeHighlightings(BookmarkHighlighting.class);
|
view.removeHighlightings(BookmarkHighlighting.class);
|
||||||
for (BookmarkQuery query = new BookmarkQuery(Model.Book, 20); ; query = query.next()) {
|
for (BookmarkQuery query = new BookmarkQuery(Model.Book, 20); ; query = query.next()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue