mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 02:39:23 +02:00
Navigation changes
git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@1512 6a642e6f-84f6-412e-ac94-c4a38d5a04b0
This commit is contained in:
parent
c232934e75
commit
063f5f0880
4 changed files with 25 additions and 37 deletions
|
@ -6,6 +6,7 @@
|
|||
<item id="bookmarks"/>
|
||||
<item id="night"/>
|
||||
<item id="day"/>
|
||||
<item id="navigate"/>
|
||||
<item id="search"/>
|
||||
<item id="preferences"/>
|
||||
<item id="preferences-old"/>
|
||||
|
@ -13,5 +14,4 @@
|
|||
<item id="rotate"/>
|
||||
<item id="increaseFont"/>
|
||||
<item id="decreaseFont"/>
|
||||
<item id="navigate"/>
|
||||
</menubar>
|
||||
|
|
|
@ -190,11 +190,8 @@ public final class FBReader extends ZLAndroidActivity {
|
|||
private AlertDialog myNavigateDialog;
|
||||
|
||||
public void navigate() {
|
||||
if (myNavigateDialog == null) {
|
||||
setupNavigation();
|
||||
}
|
||||
myNavigateDialog.show();
|
||||
updateNavigation();
|
||||
}
|
||||
|
||||
public boolean canNavigate() {
|
||||
|
@ -211,24 +208,23 @@ public final class FBReader extends ZLAndroidActivity {
|
|||
final SeekBar slider = (SeekBar) layout.findViewById(R.id.book_position_slider);
|
||||
|
||||
slider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
private boolean myInTouch;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
gotoPage(seekBar.getProgress() + 1);
|
||||
myInTouch = false;
|
||||
}
|
||||
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
myInTouch = true;
|
||||
}
|
||||
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
|
@ -236,32 +232,25 @@ public final class FBReader extends ZLAndroidActivity {
|
|||
final int page = progress + 1;
|
||||
final int pagesNumber = seekBar.getMax() + 1;
|
||||
myNavigateDialog.setTitle(makeNavigationTitle(page, pagesNumber));
|
||||
if (!myInTouch) {
|
||||
gotoPage(page);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
myNavigateDialog = new AlertDialog.Builder(this)
|
||||
.setView(layout)
|
||||
.setTitle("?????") // use Non-empty string to preserve title-bar
|
||||
.setIcon(0)
|
||||
.create();
|
||||
}
|
||||
|
||||
private void updateNavigation() {
|
||||
final org.geometerplus.fbreader.fbreader.FBReader fbreader =
|
||||
(org.geometerplus.fbreader.fbreader.FBReader)ZLApplication.Instance();
|
||||
final ZLTextView textView = (ZLTextView) fbreader.getCurrentView();
|
||||
final int page = textView.computeCurrentPage();
|
||||
final int pagesNumber = textView.computePageNumber();
|
||||
|
||||
final SeekBar slider = (SeekBar) myNavigateDialog.findViewById(R.id.book_position_slider);
|
||||
slider.setMax(pagesNumber - 1);
|
||||
slider.setProgress(page - 1);
|
||||
|
||||
myNavigateDialog.setTitle(makeNavigationTitle(page, pagesNumber));
|
||||
myNavigateDialog = new AlertDialog.Builder(this)
|
||||
.setView(layout)
|
||||
.setTitle(makeNavigationTitle(page, pagesNumber))
|
||||
.setIcon(0)
|
||||
.create();
|
||||
}
|
||||
|
||||
private static String makeNavigationTitle(int page, int pagesNumber) {
|
||||
|
|
|
@ -280,16 +280,6 @@ public final class FBView extends ZLTextView {
|
|||
return myReader.SelectionEnabledOption.getValue();
|
||||
}
|
||||
|
||||
void scrollToHome() {
|
||||
final ZLTextWordCursor cursor = getStartCursor();
|
||||
if (!cursor.isNull() && cursor.isStartOfParagraph() && cursor.getParagraphIndex() == 0) {
|
||||
return;
|
||||
}
|
||||
gotoPosition(0, 0, 0);
|
||||
preparePaintInfo();
|
||||
ZLApplication.Instance().repaintView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scrollbarType() {
|
||||
return myReader.ScrollbarTypeOption.getValue();
|
||||
|
|
|
@ -566,6 +566,15 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
|||
gotoPositionByEnd(paragraphIndex, wordIndex, 0);
|
||||
}
|
||||
|
||||
public void gotoHome() {
|
||||
final ZLTextWordCursor cursor = getStartCursor();
|
||||
if (!cursor.isNull() && cursor.isStartOfParagraph() && cursor.getParagraphIndex() == 0) {
|
||||
return;
|
||||
}
|
||||
gotoPosition(0, 0, 0);
|
||||
preparePaintInfo();
|
||||
}
|
||||
|
||||
private static final char[] SPACE = new char[] { ' ' };
|
||||
private void drawTextLine(ZLTextPage page, ZLTextLineInfo info, int from, int to, int y) {
|
||||
final ZLTextParagraphCursor paragraph = info.ParagraphCursor;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue