mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 10:19:33 +02:00
introduces FBReaderApp.getCurrentBook()
This commit is contained in:
parent
25e219186d
commit
78158354e7
9 changed files with 28 additions and 14 deletions
|
@ -61,7 +61,7 @@ class ProcessHyperlinkAction extends FBAndroidAction {
|
||||||
openInBrowser(hyperlink.Id);
|
openInBrowser(hyperlink.Id);
|
||||||
break;
|
break;
|
||||||
case FBHyperlinkType.INTERNAL:
|
case FBHyperlinkType.INTERNAL:
|
||||||
Reader.Collection.markHyperlinkAsVisited(Reader.Model.Book, hyperlink.Id);
|
Reader.Collection.markHyperlinkAsVisited(Reader.getCurrentBook(), hyperlink.Id);
|
||||||
Reader.tryOpenFootnote(hyperlink.Id);
|
Reader.tryOpenFootnote(hyperlink.Id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class SelectionShareAction extends FBAndroidAction {
|
||||||
@Override
|
@Override
|
||||||
protected void run(Object ... params) {
|
protected void run(Object ... params) {
|
||||||
final String text = Reader.getTextView().getSelectedText();
|
final String text = Reader.getTextView().getSelectedText();
|
||||||
final String title = Reader.Model.Book.getTitle();
|
final String title = Reader.getCurrentBook().getTitle();
|
||||||
Reader.getTextView().clearSelection();
|
Reader.getTextView().clearSelection();
|
||||||
|
|
||||||
final Intent intent = new Intent(android.content.Intent.ACTION_SEND);
|
final Intent intent = new Intent(android.content.Intent.ACTION_SEND);
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package org.geometerplus.android.fbreader;
|
package org.geometerplus.android.fbreader;
|
||||||
|
|
||||||
|
import org.geometerplus.fbreader.book.Book;
|
||||||
import org.geometerplus.fbreader.fbreader.FBReaderApp;
|
import org.geometerplus.fbreader.fbreader.FBReaderApp;
|
||||||
|
|
||||||
public class ShareBookAction extends FBAndroidAction {
|
public class ShareBookAction extends FBAndroidAction {
|
||||||
|
@ -28,11 +29,12 @@ public class ShareBookAction extends FBAndroidAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVisible() {
|
public boolean isVisible() {
|
||||||
return Reader.Model != null && Reader.Model.Book.File.getPhysicalFile() != null;
|
final Book book = Reader.getCurrentBook();
|
||||||
|
return book != null && book.File.getPhysicalFile() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void run(Object ... params) {
|
protected void run(Object ... params) {
|
||||||
FBUtil.shareBook(BaseActivity, Reader.Model.Book);
|
FBUtil.shareBook(BaseActivity, Reader.getCurrentBook());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ class ShowBookInfoAction extends FBAndroidAction {
|
||||||
final Intent intent =
|
final Intent intent =
|
||||||
new Intent(BaseActivity.getApplicationContext(), BookInfoActivity.class)
|
new Intent(BaseActivity.getApplicationContext(), BookInfoActivity.class)
|
||||||
.putExtra(BookInfoActivity.FROM_READING_MODE_KEY, true);
|
.putExtra(BookInfoActivity.FROM_READING_MODE_KEY, true);
|
||||||
FBReaderIntents.putBookExtra(intent, Reader.Model.Book);
|
FBReaderIntents.putBookExtra(intent, Reader.getCurrentBook());
|
||||||
OrientationUtil.startActivity(BaseActivity, intent);
|
OrientationUtil.startActivity(BaseActivity, intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ class ShowBookmarksAction extends FBAndroidAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startBookmarksActivity(Intent intent) {
|
private void startBookmarksActivity(Intent intent) {
|
||||||
FBReaderIntents.putBookExtra(intent, Reader.Model.Book);
|
FBReaderIntents.putBookExtra(intent, Reader.getCurrentBook());
|
||||||
FBReaderIntents.putBookmarkExtra(intent, Reader.createBookmark(20, true));
|
FBReaderIntents.putBookmarkExtra(intent, Reader.createBookmark(20, true));
|
||||||
OrientationUtil.startActivity(BaseActivity, intent);
|
OrientationUtil.startActivity(BaseActivity, intent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ class ShowLibraryAction extends FBAndroidAction {
|
||||||
|
|
||||||
private void startLibraryActivity(Intent intent) {
|
private void startLibraryActivity(Intent intent) {
|
||||||
if (Reader.Model != null) {
|
if (Reader.Model != null) {
|
||||||
FBReaderIntents.putBookExtra(intent, Reader.Model.Book);
|
FBReaderIntents.putBookExtra(intent, Reader.getCurrentBook());
|
||||||
}
|
}
|
||||||
OrientationUtil.startActivity(BaseActivity, intent);
|
OrientationUtil.startActivity(BaseActivity, intent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -328,11 +328,13 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBookLanguage() {
|
public String getBookLanguage() {
|
||||||
return getReader().Model.Book.getLanguage();
|
final Book book = getReader().getCurrentBook();
|
||||||
|
return book != null ? book.getLanguage() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBookTitle() {
|
public String getBookTitle() {
|
||||||
return getReader().Model.Book.getTitle();
|
final Book book = getReader().getCurrentBook();
|
||||||
|
return book != null ? book.getTitle() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getBookTags() {
|
public List<String> getBookTags() {
|
||||||
|
@ -341,11 +343,16 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBookFilePath() {
|
public String getBookFilePath() {
|
||||||
return getReader().Model.Book.File.getPath();
|
final Book book = getReader().getCurrentBook();
|
||||||
|
return book != null ? book.File.getPath() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBookHash() {
|
public String getBookHash() {
|
||||||
final UID uid = BookUtil.createUid(getReader().Model.Book.File, "SHA-256");
|
final Book book = getReader().getCurrentBook();
|
||||||
|
if (book == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final UID uid = BookUtil.createUid(book.File, "SHA-256");
|
||||||
return uid != null ? uid.Id : null;
|
return uid != null ? uid.Id : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,10 @@ public final class FBReaderApp extends ZLApplication {
|
||||||
setView(BookTextView);
|
setView(BookTextView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Book getCurrentBook() {
|
||||||
|
return Model != null ? Model.Book : ExternalBook;
|
||||||
|
}
|
||||||
|
|
||||||
public void openBook(final Book book, final Bookmark bookmark, final Runnable postAction) {
|
public void openBook(final Book book, final Bookmark bookmark, final Runnable postAction) {
|
||||||
if (book != null || Model == null) {
|
if (book != null || Model == null) {
|
||||||
final SynchronousExecutor executor = createExecutor("loadingBook");
|
final SynchronousExecutor executor = createExecutor("loadingBook");
|
||||||
|
@ -133,11 +137,12 @@ public final class FBReaderApp extends ZLApplication {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadBook() {
|
public void reloadBook() {
|
||||||
if (Model != null && Model.Book != null) {
|
final Book book = getCurrentBook();
|
||||||
|
if (book != null) {
|
||||||
final SynchronousExecutor executor = createExecutor("loadingBook");
|
final SynchronousExecutor executor = createExecutor("loadingBook");
|
||||||
executor.execute(new Runnable() {
|
executor.execute(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
openBookInternal(Model.Book, null, true);
|
openBookInternal(book, null, true);
|
||||||
}
|
}
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -434,7 +434,7 @@ public final class FBView extends ZLTextView {
|
||||||
case FBHyperlinkType.NONE:
|
case FBHyperlinkType.NONE:
|
||||||
return profile.RegularTextOption.getValue();
|
return profile.RegularTextOption.getValue();
|
||||||
case FBHyperlinkType.INTERNAL:
|
case FBHyperlinkType.INTERNAL:
|
||||||
return myReader.Collection.isHyperlinkVisited(myReader.Model.Book, hyperlink.Id)
|
return myReader.Collection.isHyperlinkVisited(myReader.getCurrentBook(), hyperlink.Id)
|
||||||
? profile.VisitedHyperlinkTextOption.getValue()
|
? profile.VisitedHyperlinkTextOption.getValue()
|
||||||
: profile.HyperlinkTextOption.getValue();
|
: profile.HyperlinkTextOption.getValue();
|
||||||
case FBHyperlinkType.EXTERNAL:
|
case FBHyperlinkType.EXTERNAL:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue