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

API methods for action controls (server side is not implemented yet)

This commit is contained in:
Nikolay Pultsin 2012-05-23 03:24:02 +01:00
parent 35f1cc6064
commit 45dfb63382
4 changed files with 149 additions and 0 deletions

View file

@ -55,4 +55,18 @@ public interface Api {
void setPageStart(TextPosition position) throws ApiException; void setPageStart(TextPosition position) throws ApiException;
void highlightArea(TextPosition start, TextPosition end) throws ApiException; void highlightArea(TextPosition start, TextPosition end) throws ApiException;
void clearHighlighting() throws ApiException; void clearHighlighting() throws ApiException;
// action control
List<String> listActions() throws ApiException;
List<String> listActionNames(List<String> actions) throws ApiException;
String getKeyAction(int key, boolean longPress) throws ApiException;
void setKeyAction(int key, boolean longPress, String action) throws ApiException;
List<String> listTapZones() throws ApiException;
int getTapZoneHeight(String name) throws ApiException;
int getTapZoneWidth(String name) throws ApiException;
String getTapZoneAction(String name, int v, int h, boolean longPress) throws ApiException;
boolean createTapZone(String name, int height, int width) throws ApiException;
void setTapZoneAction(String name, int v, int h, boolean longPress, String action) throws ApiException;
} }

View file

@ -181,6 +181,15 @@ public class ApiClientImplementation implements ServiceConnection, Api, ApiMetho
return new ApiObject[] { ApiObject.envelope(value) }; return new ApiObject[] { ApiObject.envelope(value) };
} }
private static ApiObject[] envelope(List<String> value) {
final ApiObject[] objects = new ApiObject[value.size()];
int index = 0;
for (String s : value) {
objects[index++] = ApiObject.envelope(s);
}
return objects;
}
// information about fbreader // information about fbreader
public String getFBReaderVersion() throws ApiException { public String getFBReaderVersion() throws ApiException {
return requestString(GET_FBREADER_VERSION, EMPTY_PARAMETERS); return requestString(GET_FBREADER_VERSION, EMPTY_PARAMETERS);
@ -304,4 +313,67 @@ public class ApiClientImplementation implements ServiceConnection, Api, ApiMetho
public void clearHighlighting() throws ApiException { public void clearHighlighting() throws ApiException {
request(CLEAR_HIGHLIGHTING, EMPTY_PARAMETERS); request(CLEAR_HIGHLIGHTING, EMPTY_PARAMETERS);
} }
// action control
public String getKeyAction(int key, boolean longPress) throws ApiException {
return requestString(GET_KEY_ACTION, new ApiObject[] {
ApiObject.envelope(key),
ApiObject.envelope(longPress)
});
}
public void setKeyAction(int key, boolean longPress, String action) throws ApiException {
request(SET_KEY_ACTION, new ApiObject[] {
ApiObject.envelope(key),
ApiObject.envelope(longPress),
ApiObject.envelope(action)
});
}
public List<String> listActions() throws ApiException {
return requestStringList(LIST_ACTIONS, EMPTY_PARAMETERS);
}
public List<String> listActionNames(List<String> actions) throws ApiException {
return requestStringList(LIST_ACTION_NAMES, envelope(actions));
}
public List<String> listTapZones() throws ApiException {
return requestStringList(LIST_TAPZONES, EMPTY_PARAMETERS);
}
public int getTapZoneHeight(String name) throws ApiException {
return requestInt(GET_TAPZONE_HEIGHT, envelope(name));
}
public int getTapZoneWidth(String name) throws ApiException {
return requestInt(GET_TAPZONE_WIDTH, envelope(name));
}
public String getTapZoneAction(String name, int v, int h, boolean longPress) throws ApiException {
return requestString(GET_TAPZONE_ACTION, new ApiObject[] {
ApiObject.envelope(name),
ApiObject.envelope(v),
ApiObject.envelope(h),
ApiObject.envelope(longPress)
});
}
public boolean createTapZone(String name, int height, int width) throws ApiException {
return requestBoolean(CREATE_TAPZONE, new ApiObject[] {
ApiObject.envelope(name),
ApiObject.envelope(height),
ApiObject.envelope(width)
});
}
public void setTapZoneAction(String name, int v, int h, boolean longPress, String action) throws ApiException {
request(SET_TAPZONE_ACTION, new ApiObject[] {
ApiObject.envelope(name),
ApiObject.envelope(v),
ApiObject.envelope(h),
ApiObject.envelope(longPress),
ApiObject.envelope(action)
});
}
} }

View file

@ -45,4 +45,18 @@ interface ApiMethods {
int SET_PAGE_START = 801; int SET_PAGE_START = 801;
int HIGHLIGHT_AREA = 802; int HIGHLIGHT_AREA = 802;
int CLEAR_HIGHLIGHTING = 803; int CLEAR_HIGHLIGHTING = 803;
// action control
int LIST_ACTIONS = 901;
int LIST_ACTION_NAMES = 902;
int GET_KEY_ACTION = 911;
int SET_KEY_ACTION = 912;
int LIST_TAPZONES = 921;
int GET_TAPZONE_HEIGHT = 922;
int GET_TAPZONE_WIDTH = 923;
int GET_TAPZONE_ACTION = 924;
int CREATE_TAPZONE = 925;
int SET_TAPZONE_ACTION = 926;
} }

View file

@ -338,4 +338,53 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A
} }
return sb.toString(); return sb.toString();
} }
// action control
public List<String> listActions() throws ApiException {
// TODO: implement
return Collections.emptyList();
}
public List<String> listActionNames(List<String> actions) throws ApiException {
// TODO: implement
return Collections.emptyList();
}
public String getKeyAction(int key, boolean longPress) throws ApiException {
// TODO: implement
return null;
}
public void setKeyAction(int key, boolean longPress, String action) throws ApiException {
// TODO: implement
}
public List<String> listTapZones() throws ApiException {
// TODO: implement
return Collections.emptyList();
}
public int getTapZoneHeight(String name) throws ApiException {
// TODO: implement
return -1;
}
public int getTapZoneWidth(String name) throws ApiException {
// TODO: implement
return -1;
}
public String getTapZoneAction(String name, int v, int h, boolean longPress) throws ApiException {
// TODO: implement
return null;
}
public boolean createTapZone(String name, int height, int width) throws ApiException {
// TODO: implement
return false;
}
public void setTapZoneAction(String name, int v, int h, boolean longPress, String action) throws ApiException {
// TODO: implement
}
} }