mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 17:59:33 +02:00
new methods in API: book info for an arbitrary book
This commit is contained in:
parent
9a3ae79474
commit
938c631afb
5 changed files with 132 additions and 13 deletions
|
@ -17,16 +17,26 @@ public interface Api {
|
||||||
String getOptionValue(String group, String name) throws ApiException;
|
String getOptionValue(String group, String name) throws ApiException;
|
||||||
void setOptionValue(String group, String name, String value) throws ApiException;
|
void setOptionValue(String group, String name, String value) throws ApiException;
|
||||||
|
|
||||||
// book information
|
// book information for current book
|
||||||
String getBookLanguage() throws ApiException;
|
String getBookLanguage() throws ApiException;
|
||||||
String getBookTitle() throws ApiException;
|
String getBookTitle() throws ApiException;
|
||||||
//List<String> getBookAuthors() throws ApiException;
|
//List<String> getBookAuthors() throws ApiException;
|
||||||
List<String> getBookTags() throws ApiException;
|
List<String> getBookTags() throws ApiException;
|
||||||
String getBookFilePath() throws ApiException;
|
String getBookFilePath() throws ApiException;
|
||||||
String getBookHash() throws ApiException;
|
String getBookHash() throws ApiException;
|
||||||
String getBookId() throws ApiException;
|
String getBookUniqueId() throws ApiException;
|
||||||
Date getBookLastTurningTime() throws ApiException;
|
Date getBookLastTurningTime() throws ApiException;
|
||||||
|
|
||||||
|
// book information for book defined by id
|
||||||
|
String getBookLanguage(long id) throws ApiException;
|
||||||
|
String getBookTitle(long id) throws ApiException;
|
||||||
|
//List<String> getBookAuthors(long id) throws ApiException;
|
||||||
|
List<String> getBookTags(long id) throws ApiException;
|
||||||
|
String getBookFilePath(long id) throws ApiException;
|
||||||
|
String getBookHash(long id) throws ApiException;
|
||||||
|
String getBookUniqueId(long id) throws ApiException;
|
||||||
|
Date getBookLastTurningTime(long id) throws ApiException;
|
||||||
|
|
||||||
// text information
|
// text information
|
||||||
int getParagraphsNumber() throws ApiException;
|
int getParagraphsNumber() throws ApiException;
|
||||||
int getElementsNumber(int paragraphIndex) throws ApiException;
|
int getElementsNumber(int paragraphIndex) throws ApiException;
|
||||||
|
|
|
@ -229,14 +229,42 @@ public class ApiClientImplementation implements ServiceConnection, Api, ApiMetho
|
||||||
return requestString(GET_BOOK_HASH, EMPTY_PARAMETERS);
|
return requestString(GET_BOOK_HASH, EMPTY_PARAMETERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBookId() throws ApiException {
|
public String getBookUniqueId() throws ApiException {
|
||||||
return requestString(GET_BOOK_ID, EMPTY_PARAMETERS);
|
return requestString(GET_BOOK_UNIQUE_ID, EMPTY_PARAMETERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getBookLastTurningTime() throws ApiException {
|
public Date getBookLastTurningTime() throws ApiException {
|
||||||
return requestDate(GET_BOOK_LAST_TURNING_TIME, EMPTY_PARAMETERS);
|
return requestDate(GET_BOOK_LAST_TURNING_TIME, EMPTY_PARAMETERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getBookLanguage(long id) throws ApiException {
|
||||||
|
return requestString(GET_BOOK_LANGUAGE, EMPTY_PARAMETERS);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBookTitle(long id) throws ApiException {
|
||||||
|
return requestString(GET_BOOK_TITLE, EMPTY_PARAMETERS);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getBookTags(long id) throws ApiException {
|
||||||
|
return requestStringList(GET_BOOK_TAGS, EMPTY_PARAMETERS);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBookFilePath(long id) throws ApiException {
|
||||||
|
return requestString(GET_BOOK_FILE_PATH, EMPTY_PARAMETERS);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBookHash(long id) throws ApiException {
|
||||||
|
return requestString(GET_BOOK_HASH, EMPTY_PARAMETERS);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBookUniqueId(long id) throws ApiException {
|
||||||
|
return requestString(GET_BOOK_UNIQUE_ID, EMPTY_PARAMETERS);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getBookLastTurningTime(long id) throws ApiException {
|
||||||
|
return requestDate(GET_BOOK_LAST_TURNING_TIME, EMPTY_PARAMETERS);
|
||||||
|
}
|
||||||
|
|
||||||
public TextPosition getPageStart() throws ApiException {
|
public TextPosition getPageStart() throws ApiException {
|
||||||
return requestTextPosition(GET_PAGE_START, EMPTY_PARAMETERS);
|
return requestTextPosition(GET_PAGE_START, EMPTY_PARAMETERS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ interface ApiMethods {
|
||||||
int GET_BOOK_TAGS = 504;
|
int GET_BOOK_TAGS = 504;
|
||||||
int GET_BOOK_FILE_PATH = 505;
|
int GET_BOOK_FILE_PATH = 505;
|
||||||
int GET_BOOK_HASH = 506;
|
int GET_BOOK_HASH = 506;
|
||||||
int GET_BOOK_ID = 507;
|
int GET_BOOK_UNIQUE_ID = 507;
|
||||||
int GET_BOOK_LAST_TURNING_TIME = 508;
|
int GET_BOOK_LAST_TURNING_TIME = 508;
|
||||||
|
|
||||||
// text information
|
// text information
|
||||||
|
|
|
@ -18,6 +18,7 @@ public abstract class ApiObject implements Parcelable {
|
||||||
int STRING = 2;
|
int STRING = 2;
|
||||||
int BOOLEAN = 3;
|
int BOOLEAN = 3;
|
||||||
int DATE = 4;
|
int DATE = 4;
|
||||||
|
int LONG = 5;
|
||||||
int TEXT_POSITION = 10;
|
int TEXT_POSITION = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +53,25 @@ public abstract class ApiObject implements Parcelable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class Long extends ApiObject {
|
||||||
|
final long Value;
|
||||||
|
|
||||||
|
Long(long value) {
|
||||||
|
Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int type() {
|
||||||
|
return Type.LONG;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(Parcel parcel, int flags) {
|
||||||
|
super.writeToParcel(parcel, flags);
|
||||||
|
parcel.writeLong(Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static class Boolean extends ApiObject {
|
static class Boolean extends ApiObject {
|
||||||
final boolean Value;
|
final boolean Value;
|
||||||
|
|
||||||
|
@ -175,6 +195,8 @@ public abstract class ApiObject implements Parcelable {
|
||||||
return Void.Instance;
|
return Void.Instance;
|
||||||
case Type.INT:
|
case Type.INT:
|
||||||
return new Integer(parcel.readInt());
|
return new Integer(parcel.readInt());
|
||||||
|
case Type.LONG:
|
||||||
|
return new Long(parcel.readLong());
|
||||||
case Type.BOOLEAN:
|
case Type.BOOLEAN:
|
||||||
return new Boolean(parcel.readByte() == 1);
|
return new Boolean(parcel.readByte() == 1);
|
||||||
case Type.DATE:
|
case Type.DATE:
|
||||||
|
|
|
@ -67,17 +67,41 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A
|
||||||
);
|
);
|
||||||
return ApiObject.Void.Instance;
|
return ApiObject.Void.Instance;
|
||||||
case GET_BOOK_LANGUAGE:
|
case GET_BOOK_LANGUAGE:
|
||||||
|
if (parameters.length == 0) {
|
||||||
return ApiObject.envelope(getBookLanguage());
|
return ApiObject.envelope(getBookLanguage());
|
||||||
|
} else {
|
||||||
|
return ApiObject.envelope(getBookLanguage(((ApiObject.Long)parameters[0]).Value));
|
||||||
|
}
|
||||||
case GET_BOOK_TITLE:
|
case GET_BOOK_TITLE:
|
||||||
|
if (parameters.length == 0) {
|
||||||
return ApiObject.envelope(getBookTitle());
|
return ApiObject.envelope(getBookTitle());
|
||||||
|
} else {
|
||||||
|
return ApiObject.envelope(getBookTitle(((ApiObject.Long)parameters[0]).Value));
|
||||||
|
}
|
||||||
case GET_BOOK_FILE_PATH:
|
case GET_BOOK_FILE_PATH:
|
||||||
|
if (parameters.length == 0) {
|
||||||
return ApiObject.envelope(getBookFilePath());
|
return ApiObject.envelope(getBookFilePath());
|
||||||
|
} else {
|
||||||
|
return ApiObject.envelope(getBookFilePath(((ApiObject.Long)parameters[0]).Value));
|
||||||
|
}
|
||||||
case GET_BOOK_HASH:
|
case GET_BOOK_HASH:
|
||||||
|
if (parameters.length == 0) {
|
||||||
return ApiObject.envelope(getBookHash());
|
return ApiObject.envelope(getBookHash());
|
||||||
case GET_BOOK_ID:
|
} else {
|
||||||
return ApiObject.envelope(getBookId());
|
return ApiObject.envelope(getBookHash(((ApiObject.Long)parameters[0]).Value));
|
||||||
|
}
|
||||||
|
case GET_BOOK_UNIQUE_ID:
|
||||||
|
if (parameters.length == 0) {
|
||||||
|
return ApiObject.envelope(getBookUniqueId());
|
||||||
|
} else {
|
||||||
|
return ApiObject.envelope(getBookUniqueId(((ApiObject.Long)parameters[0]).Value));
|
||||||
|
}
|
||||||
case GET_BOOK_LAST_TURNING_TIME:
|
case GET_BOOK_LAST_TURNING_TIME:
|
||||||
|
if (parameters.length == 0) {
|
||||||
return ApiObject.envelope(getBookLastTurningTime());
|
return ApiObject.envelope(getBookLastTurningTime());
|
||||||
|
} else {
|
||||||
|
return ApiObject.envelope(getBookLastTurningTime(((ApiObject.Long)parameters[0]).Value));
|
||||||
|
}
|
||||||
case GET_PARAGRAPHS_NUMBER:
|
case GET_PARAGRAPHS_NUMBER:
|
||||||
return ApiObject.envelope(getParagraphsNumber());
|
return ApiObject.envelope(getParagraphsNumber());
|
||||||
case GET_ELEMENTS_NUMBER:
|
case GET_ELEMENTS_NUMBER:
|
||||||
|
@ -192,7 +216,7 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A
|
||||||
return myReader.Model.Book.getContentHashCode();
|
return myReader.Model.Book.getContentHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBookId() {
|
public String getBookUniqueId() {
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -202,6 +226,41 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getBookLanguage(long id) {
|
||||||
|
// TODO: implement
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBookTitle(long id) {
|
||||||
|
// TODO: implement
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getBookTags(long id) {
|
||||||
|
// TODO: implement
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBookFilePath(long id) {
|
||||||
|
// TODO: implement
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBookHash(long id) {
|
||||||
|
// TODO: implement
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBookUniqueId(long id) {
|
||||||
|
// TODO: implement
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getBookLastTurningTime(long id) {
|
||||||
|
// TODO: implement
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// page information
|
// page information
|
||||||
public TextPosition getPageStart() {
|
public TextPosition getPageStart() {
|
||||||
return getTextPosition(myReader.getTextView().getStartCursor());
|
return getTextPosition(myReader.getTextView().getStartCursor());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue