1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-04 18:29:23 +02:00

more API methods

This commit is contained in:
Nikolay Pultsin 2012-05-23 05:48:51 +01:00
parent f366a86441
commit 6175f96a8f
7 changed files with 94 additions and 50 deletions

View file

@ -5,6 +5,7 @@ litres: author photos
1.5.*: 1.5.*:
* Advanced settings plugin does not run
* Autogeneration for ApiMethods & ApiImplementations * Autogeneration for ApiMethods & ApiImplementations
* Footnotes on the same page * Footnotes on the same page
* Chinese books (mail from Eric) * Chinese books (mail from Eric)

View file

@ -63,11 +63,15 @@ public interface Api {
String getKeyAction(int key, boolean longPress) throws ApiException; String getKeyAction(int key, boolean longPress) throws ApiException;
void setKeyAction(int key, boolean longPress, String action) throws ApiException; void setKeyAction(int key, boolean longPress, String action) throws ApiException;
List<String> listTapZones() throws ApiException; List<String> listZoneMaps() throws ApiException;
String getCurrentTapZone() throws ApiException; String getZoneMap() throws ApiException;
int getTapZoneHeight(String name) throws ApiException; void setZoneMap(String name) throws ApiException;
int getTapZoneWidth(String name) throws ApiException; int getZoneMapHeight(String name) throws ApiException;
int getZoneMapWidth(String name) throws ApiException;
void createZoneMap(String name, int width, int height) throws ApiException;
boolean isZoneMapCustom(String name) throws ApiException;
void deleteZoneMap(String name) throws ApiException;
String getTapZoneAction(String name, int h, int v, boolean singleTap) throws ApiException; String getTapZoneAction(String name, int h, int v, boolean singleTap) throws ApiException;
void createTapZone(String name, int width, int height) throws ApiException;
void setTapZoneAction(String name, int h, int v, boolean singleTap, String action) throws ApiException; void setTapZoneAction(String name, int h, int v, boolean singleTap, String action) throws ApiException;
} }

View file

@ -342,20 +342,40 @@ public class ApiClientImplementation implements ServiceConnection, Api, ApiMetho
return requestStringList(LIST_ACTION_NAMES, envelope(actions)); return requestStringList(LIST_ACTION_NAMES, envelope(actions));
} }
public List<String> listTapZones() throws ApiException { public List<String> listZoneMaps() throws ApiException {
return requestStringList(LIST_TAPZONES, EMPTY_PARAMETERS); return requestStringList(LIST_ZONEMAPS, EMPTY_PARAMETERS);
} }
public String getCurrentTapZone() throws ApiException { public String getZoneMap() throws ApiException {
return requestString(GET_CURRENT_TAPZONE, EMPTY_PARAMETERS); return requestString(GET_ZONEMAP, EMPTY_PARAMETERS);
} }
public int getTapZoneHeight(String name) throws ApiException { public void setZoneMap(String name) throws ApiException {
return requestInt(GET_TAPZONE_HEIGHT, envelope(name)); request(SET_ZONEMAP, envelope(name));
} }
public int getTapZoneWidth(String name) throws ApiException { public int getZoneMapHeight(String name) throws ApiException {
return requestInt(GET_TAPZONE_WIDTH, envelope(name)); return requestInt(GET_ZONEMAP_HEIGHT, envelope(name));
}
public int getZoneMapWidth(String name) throws ApiException {
return requestInt(GET_ZONEMAP_WIDTH, envelope(name));
}
public void createZoneMap(String name, int width, int height) throws ApiException {
request(CREATE_ZONEMAP, new ApiObject[] {
ApiObject.envelope(name),
ApiObject.envelope(width),
ApiObject.envelope(height)
});
}
public boolean isZoneMapCustom(String name) throws ApiException {
return requestBoolean(IS_ZONEMAP_CUSTOM, envelope(name));
}
public void deleteZoneMap(String name) throws ApiException {
request(DELETE_ZONEMAP, envelope(name));
} }
public String getTapZoneAction(String name, int h, int v, boolean singleTap) throws ApiException { public String getTapZoneAction(String name, int h, int v, boolean singleTap) throws ApiException {
@ -367,14 +387,6 @@ public class ApiClientImplementation implements ServiceConnection, Api, ApiMetho
}); });
} }
public void createTapZone(String name, int width, int height) throws ApiException {
request(CREATE_TAPZONE, new ApiObject[] {
ApiObject.envelope(name),
ApiObject.envelope(width),
ApiObject.envelope(height)
});
}
public void setTapZoneAction(String name, int h, int v, boolean singleTap, String action) throws ApiException { public void setTapZoneAction(String name, int h, int v, boolean singleTap, String action) throws ApiException {
request(SET_TAPZONE_ACTION, new ApiObject[] { request(SET_TAPZONE_ACTION, new ApiObject[] {
ApiObject.envelope(name), ApiObject.envelope(name),

View file

@ -53,11 +53,15 @@ interface ApiMethods {
int GET_KEY_ACTION = 911; int GET_KEY_ACTION = 911;
int SET_KEY_ACTION = 912; int SET_KEY_ACTION = 912;
int LIST_TAPZONES = 921; int LIST_ZONEMAPS = 921;
int GET_CURRENT_TAPZONE = 922; int GET_ZONEMAP = 922;
int GET_TAPZONE_HEIGHT = 923; int SET_ZONEMAP = 923;
int GET_TAPZONE_WIDTH = 924; int GET_ZONEMAP_HEIGHT = 924;
int GET_TAPZONE_ACTION = 925; int GET_ZONEMAP_WIDTH = 925;
int CREATE_TAPZONE = 926; int CREATE_ZONEMAP = 926;
int SET_TAPZONE_ACTION = 927; int IS_ZONEMAP_CUSTOM = 927;
int DELETE_ZONEMAP = 928;
int GET_TAPZONE_ACTION = 931;
int SET_TAPZONE_ACTION = 932;
} }

View file

@ -143,8 +143,15 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A
((ApiObject.String)parameters[2]).Value ((ApiObject.String)parameters[2]).Value
); );
return ApiObject.Void.Instance; return ApiObject.Void.Instance;
case GET_CURRENT_TAPZONE: case GET_ZONEMAP:
return ApiObject.envelope(getCurrentTapZone()); return ApiObject.envelope(getZoneMap());
case SET_ZONEMAP:
setZoneMap(((ApiObject.String)parameters[0]).Value);
return ApiObject.Void.Instance;
case GET_ZONEMAP_HEIGHT:
return ApiObject.envelope(getZoneMapHeight(((ApiObject.String)parameters[0]).Value));
case GET_ZONEMAP_WIDTH:
return ApiObject.envelope(getZoneMapWidth(((ApiObject.String)parameters[0]).Value));
case GET_TAPZONE_ACTION: case GET_TAPZONE_ACTION:
return ApiObject.envelope(getTapZoneAction( return ApiObject.envelope(getTapZoneAction(
((ApiObject.String)parameters[0]).Value, ((ApiObject.String)parameters[0]).Value,
@ -152,10 +159,6 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A
((ApiObject.Integer)parameters[2]).Value, ((ApiObject.Integer)parameters[2]).Value,
((ApiObject.Boolean)parameters[3]).Value ((ApiObject.Boolean)parameters[3]).Value
)); ));
case GET_TAPZONE_HEIGHT:
return ApiObject.envelope(getTapZoneHeight(((ApiObject.String)parameters[0]).Value));
case GET_TAPZONE_WIDTH:
return ApiObject.envelope(getTapZoneWidth(((ApiObject.String)parameters[0]).Value));
case SET_TAPZONE_ACTION: case SET_TAPZONE_ACTION:
setTapZoneAction( setTapZoneAction(
((ApiObject.String)parameters[0]).Value, ((ApiObject.String)parameters[0]).Value,
@ -165,13 +168,20 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A
((ApiObject.String)parameters[4]).Value ((ApiObject.String)parameters[4]).Value
); );
return ApiObject.Void.Instance; return ApiObject.Void.Instance;
case CREATE_TAPZONE: case CREATE_ZONEMAP:
createTapZone( createZoneMap(
((ApiObject.String)parameters[0]).Value, ((ApiObject.String)parameters[0]).Value,
((ApiObject.Integer)parameters[1]).Value, ((ApiObject.Integer)parameters[1]).Value,
((ApiObject.Integer)parameters[2]).Value ((ApiObject.Integer)parameters[2]).Value
); );
return ApiObject.Void.Instance; return ApiObject.Void.Instance;
case IS_ZONEMAP_CUSTOM:
return ApiObject.envelope(isZoneMapCustom(
((ApiObject.String)parameters[0]).Value
));
case DELETE_ZONEMAP:
deleteZoneMap(((ApiObject.String)parameters[0]).Value);
return ApiObject.Void.Instance;
default: default:
return unsupportedMethodError(method); return unsupportedMethodError(method);
} }
@ -201,8 +211,8 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A
} }
return ApiObject.envelope(listActionNames(actions)); return ApiObject.envelope(listActionNames(actions));
} }
case LIST_TAPZONES: case LIST_ZONEMAPS:
return ApiObject.envelope(listTapZones()); return ApiObject.envelope(listZoneMaps());
default: default:
return Collections.<ApiObject>singletonList(unsupportedMethodError(method)); return Collections.<ApiObject>singletonList(unsupportedMethodError(method));
} }
@ -412,32 +422,45 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A
// TODO: implement // TODO: implement
} }
public List<String> listTapZones() { public List<String> listZoneMaps() {
return TapZoneMap.zoneMapNames(); return TapZoneMap.zoneMapNames();
} }
public String getCurrentTapZone() { public String getZoneMap() {
return ScrollingPreferences.Instance().TapZonesSchemeOption.getValue(); return ScrollingPreferences.Instance().TapZoneMapOption.getValue();
} }
public int getTapZoneHeight(String name) { public void setZoneMap(String name) {
ScrollingPreferences.Instance().TapZoneMapOption.setValue(name);
}
public int getZoneMapHeight(String name) {
return TapZoneMap.zoneMap(name).getHeight(); return TapZoneMap.zoneMap(name).getHeight();
} }
public int getTapZoneWidth(String name) { public int getZoneMapWidth(String name) {
return TapZoneMap.zoneMap(name).getWidth(); return TapZoneMap.zoneMap(name).getWidth();
} }
public void createZoneMap(String name, int width, int height) {
TapZoneMap.createZoneMap(name, width, height);
}
public boolean isZoneMapCustom(String name) throws ApiException {
// TODO: implement
return false;
}
public void deleteZoneMap(String name) throws ApiException {
// TODO: implement
}
public String getTapZoneAction(String name, int h, int v, boolean singleTap) { public String getTapZoneAction(String name, int h, int v, boolean singleTap) {
return TapZoneMap.zoneMap(name).getActionByZone( return TapZoneMap.zoneMap(name).getActionByZone(
h, v, singleTap ? TapZoneMap.Tap.singleNotDoubleTap : TapZoneMap.Tap.doubleTap h, v, singleTap ? TapZoneMap.Tap.singleNotDoubleTap : TapZoneMap.Tap.doubleTap
); );
} }
public void createTapZone(String name, int width, int height) {
TapZoneMap.createZoneMap(name, width, height);
}
public void setTapZoneAction(String name, int h, int v, boolean singleTap, String action) { public void setTapZoneAction(String name, int h, int v, boolean singleTap, String action) {
TapZoneMap.zoneMap(name).setActionForZone(h, v, singleTap, action); TapZoneMap.zoneMap(name).setActionForZone(h, v, singleTap, action);
} }

View file

@ -57,7 +57,7 @@ public final class FBView extends ZLTextView {
private TapZoneMap getZoneMap() { private TapZoneMap getZoneMap() {
final ScrollingPreferences prefs = ScrollingPreferences.Instance(); final ScrollingPreferences prefs = ScrollingPreferences.Instance();
String id = prefs.TapZonesSchemeOption.getValue(); String id = prefs.TapZoneMapOption.getValue();
if ("".equals(id)) { if ("".equals(id)) {
id = ScrollingPreferences.Instance().HorizontalOption.getValue() ? "right_to_left" : "up"; id = ScrollingPreferences.Instance().HorizontalOption.getValue() ? "right_to_left" : "up";
} }

View file

@ -42,8 +42,8 @@ public class ScrollingPreferences {
public final ZLBooleanOption HorizontalOption = public final ZLBooleanOption HorizontalOption =
new ZLBooleanOption("Scrolling", "Horizontal", true); new ZLBooleanOption("Scrolling", "Horizontal", true);
public final ZLStringOption TapZonesSchemeOption = public final ZLStringOption TapZoneMapOption =
new ZLStringOption("Scrolling", "TapZonesScheme", ""); new ZLStringOption("Scrolling", "TapZoneMap", "");
private ScrollingPreferences() { private ScrollingPreferences() {
ourInstance = this; ourInstance = this;