mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 02:39:23 +02:00
cancel menu (done)
This commit is contained in:
parent
43c22be00d
commit
49adf8f9dc
4 changed files with 40 additions and 24 deletions
|
@ -35,8 +35,7 @@ import org.geometerplus.zlibrary.core.filesystem.ZLFile;
|
|||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
import org.geometerplus.zlibrary.core.view.ZLView;
|
||||
|
||||
import org.geometerplus.zlibrary.text.view.ZLTextFixedPosition;
|
||||
import org.geometerplus.zlibrary.text.view.ZLTextPosition;
|
||||
import org.geometerplus.zlibrary.text.view.ZLTextWordCursor;
|
||||
import org.geometerplus.zlibrary.text.view.ZLTextView;
|
||||
import org.geometerplus.zlibrary.text.hyphenation.ZLTextHyphenator;
|
||||
|
||||
|
@ -64,7 +63,7 @@ public final class FBReader extends ZLAndroidActivity {
|
|||
|
||||
private class NavigationButtonPanel extends ControlButtonPanel {
|
||||
public volatile boolean NavigateDragging;
|
||||
public ZLTextPosition StartPosition;
|
||||
public ZLTextWordCursor StartPosition;
|
||||
|
||||
@Override
|
||||
public void onShow() {
|
||||
|
@ -283,27 +282,25 @@ public final class FBReader extends ZLAndroidActivity {
|
|||
}
|
||||
final ZLTextView textView = (ZLTextView)ZLApplication.Instance().getCurrentView();
|
||||
myNavigatePanel.NavigateDragging = false;
|
||||
myNavigatePanel.StartPosition = new ZLTextFixedPosition(textView.getStartCursor());
|
||||
myNavigatePanel.StartPosition = new ZLTextWordCursor(textView.getStartCursor());
|
||||
myNavigatePanel.show(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
private final void createNavigation(View layout) {
|
||||
final FBReaderApp fbreader = (FBReaderApp)ZLApplication.Instance();
|
||||
final SeekBar slider = (SeekBar)layout.findViewById(R.id.book_position_slider);
|
||||
final TextView text = (TextView)layout.findViewById(R.id.book_position_text);
|
||||
|
||||
slider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
private void gotoPage(int page) {
|
||||
final ZLView view = ZLApplication.Instance().getCurrentView();
|
||||
if (view instanceof ZLTextView) {
|
||||
ZLTextView textView = (ZLTextView)view;
|
||||
if (page == 1) {
|
||||
textView.gotoHome();
|
||||
} else {
|
||||
textView.gotoPage(page);
|
||||
}
|
||||
ZLApplication.Instance().repaintView();
|
||||
final ZLTextView view = fbreader.getTextView();
|
||||
if (page == 1) {
|
||||
view.gotoHome();
|
||||
} else {
|
||||
view.gotoPage(page);
|
||||
}
|
||||
fbreader.repaintView();
|
||||
}
|
||||
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
|
@ -328,10 +325,12 @@ public final class FBReader extends ZLAndroidActivity {
|
|||
final Button btnCancel = (Button)layout.findViewById(android.R.id.button3);
|
||||
View.OnClickListener listener = new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
final ZLTextPosition position = myNavigatePanel.StartPosition;
|
||||
final ZLTextWordCursor position = myNavigatePanel.StartPosition;
|
||||
myNavigatePanel.StartPosition = null;
|
||||
if (v == btnCancel && position != null) {
|
||||
((ZLTextView)ZLApplication.Instance().getCurrentView()).gotoPosition(position);
|
||||
fbreader.getTextView().gotoPosition(position);
|
||||
} else if (v == btnOk) {
|
||||
fbreader.addInvisibleBookmark(position);
|
||||
}
|
||||
myNavigatePanel.hide(true);
|
||||
}
|
||||
|
|
|
@ -121,6 +121,7 @@ public class TOCActivity extends ListActivity {
|
|||
if (reference != null) {
|
||||
finish();
|
||||
final FBReaderApp fbreader = (FBReaderApp)ZLApplication.Instance();
|
||||
fbreader.addInvisibleBookmark();
|
||||
fbreader.BookTextView.gotoPosition(reference.ParagraphIndex, 0, 0);
|
||||
fbreader.showBookTextView();
|
||||
}
|
||||
|
|
|
@ -364,19 +364,34 @@ public final class FBReaderApp extends ZLApplication {
|
|||
}
|
||||
}
|
||||
|
||||
public void addInvisibleBookmark() {
|
||||
if (Model.Book != null) {
|
||||
final Bookmark b = addBookmark(6, false);
|
||||
if (b != null) {
|
||||
b.save();
|
||||
final List<Bookmark> bookmarks = Bookmark.invisibleBookmarks(Model.Book);
|
||||
for (int i = 3; i < bookmarks.size(); ++i) {
|
||||
bookmarks.get(i).delete();
|
||||
}
|
||||
private void updateInvisibleBookmarksList(Bookmark b) {
|
||||
if (Model.Book != null && b != null) {
|
||||
b.save();
|
||||
final List<Bookmark> bookmarks = Bookmark.invisibleBookmarks(Model.Book);
|
||||
for (int i = 3; i < bookmarks.size(); ++i) {
|
||||
bookmarks.get(i).delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addInvisibleBookmark(ZLTextWordCursor cursor) {
|
||||
if (Model.Book != null && getTextView() == BookTextView) {
|
||||
updateInvisibleBookmarksList(new Bookmark(
|
||||
Model.Book,
|
||||
getTextView().getModel().getId(),
|
||||
cursor,
|
||||
6,
|
||||
false
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
public void addInvisibleBookmark() {
|
||||
if (Model.Book != null && getTextView() == BookTextView) {
|
||||
updateInvisibleBookmarksList(addBookmark(6, false));
|
||||
}
|
||||
}
|
||||
|
||||
public Bookmark addBookmark(int maxLength, boolean visible) {
|
||||
final FBView view = getTextView();
|
||||
final ZLTextWordCursor cursor = view.getStartCursor();
|
||||
|
|
|
@ -175,6 +175,7 @@ public final class FBView extends ZLTextView {
|
|||
if (myReader.FooterIsSensitiveOption.getValue()) {
|
||||
Footer footer = getFooterArea();
|
||||
if (footer != null && y > myContext.getHeight() - footer.getTapHeight()) {
|
||||
myReader.addInvisibleBookmark();
|
||||
footer.setProgress(x);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue