use of com.herewhite.sdk.domain.SDKError in project whiteboard-android by netless-io.
the class WindowRegisterAppActivity method joinRoom.
private void joinRoom(String uuid, String token) {
logRoomInfo("room uuid: " + uuid + "\nroom token: " + token);
WhiteSdkConfiguration configuration = new WhiteSdkConfiguration(demoAPI.getAppId(), true);
configuration.setUserCursor(true);
configuration.setUseMultiViews(true);
mWhiteSdk = new WhiteSdk(mWhiteboardView, this, configuration);
mWhiteSdk.setCommonCallbacks(new CommonCallback() {
@Override
public void onLogger(JSONObject object) {
logAction(object.toString());
}
});
// 如需支持用户头像,请在设置 WhiteSdkConfiguration 后,再调用 setUserPayload 方法,传入符合用户信息
RoomParams roomParams = new RoomParams(uuid, token, DemoAPI.DEFAULT_UID);
roomParams.setWritable(true);
HashMap<String, String> styleMap = new HashMap<>();
styleMap.put("bottom", "12px");
styleMap.put("left", "60px");
styleMap.put("position", "fixed");
WindowParams windowParams = new WindowParams().setContainerSizeRatio(3f / 4).setChessboard(true).setDebug(true).setCollectorStyles(styleMap);
roomParams.setWindowParams(windowParams);
registerMonaco();
registerEmbedPage();
mWhiteSdk.joinRoom(roomParams, new AbstractRoomCallbacks() {
@Override
public void onPhaseChanged(RoomPhase phase) {
logRoomInfo("onPhaseChanged: " + phase.name());
showToast(phase.name());
}
@Override
public void onRoomStateChanged(RoomState roomState) {
if (roomState.getWindowBoxState() != null) {
logRoomInfo("WindowBoxState " + roomState.getWindowBoxState());
}
}
}, new Promise<Room>() {
@Override
public void then(Room room) {
mRoom = room;
}
@Override
public void catchEx(SDKError sdkError) {
}
});
}
use of com.herewhite.sdk.domain.SDKError in project whiteboard-android by netless-io.
the class WindowRestoreActivity method joinRoom.
private void joinRoom(String uuid, String token) {
logRoomInfo("room uuid: " + uuid + "\nroom token: " + token);
WhiteSdkConfiguration configuration = new WhiteSdkConfiguration(DemoAPI.get().getAppId(), true);
configuration.setUserCursor(true);
configuration.setFonts(new MapBuilder<String, String>().put("宋体", "https://your-cdn.com/Songti.ttf").build());
configuration.setUseMultiViews(true);
mWhiteSdk = new WhiteSdk(mWhiteboardView, this, configuration);
mWhiteSdk.setCommonCallbacks(new CommonCallback() {
@Override
public void onLogger(JSONObject object) {
logAction(object.toString());
}
});
RoomParams roomParams = new RoomParams(uuid, token, DemoAPI.DEFAULT_UID);
HashMap<String, String> styleMap = new HashMap<>();
styleMap.put("backgroundColor", "red");
styleMap.put("bottom", "12px");
styleMap.put("left", "60px");
styleMap.put("position", "fixed");
WindowParams windowParams = new WindowParams().setContainerSizeRatio(3f / 4).setChessboard(true).setDebug(true).setCollectorStyles(styleMap);
roomParams.setWindowParams(windowParams);
mWhiteSdk.joinRoom(roomParams, new RoomListener() {
@Override
public void onPhaseChanged(RoomPhase phase) {
logRoomInfo("onPhaseChanged: " + phase.name());
showToast(phase.name());
}
@Override
public void onDisconnectWithError(Exception e) {
}
@Override
public void onKickedWithReason(String s) {
}
@Override
public void onRoomStateChanged(RoomState roomState) {
if (roomState.getWindowBoxState() != null) {
logRoomInfo("WindowBoxState " + roomState.getWindowBoxState());
}
}
@Override
public void onCanUndoStepsUpdate(long l) {
}
@Override
public void onCanRedoStepsUpdate(long l) {
}
@Override
public void onCatchErrorWhenAppendFrame(long l, Exception e) {
}
}, new Promise<Room>() {
@Override
public void then(Room room) {
mRoom = room;
}
@Override
public void catchEx(SDKError sdkError) {
}
});
}
use of com.herewhite.sdk.domain.SDKError in project whiteboard-android by netless-io.
the class WindowTestActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_window_test);
getSupportActionBar().hide();
DWebView.setWebContentsDebuggingEnabled(true);
mWhiteboardView = findViewById(R.id.white);
mWhiteboardView.getSettings().setAllowUniversalAccessFromFileURLs(true);
// 使用 LocalFileWebViewClient 对 动态 ppt 拦截进行替换,先查看本地是否有,如果没有再发出网络请求
LocalFileWebViewClient client = new LocalFileWebViewClient();
client.setPptDirectory(getCacheDir().getAbsolutePath());
mWhiteboardView.setWebViewClient(client);
mWhiteboardParent = findViewById(R.id.whiteParent);
// 窗口比例
findViewById(R.id.radio).setOnClickListener(new View.OnClickListener() {
int index = 0;
final List<Float> ratios = new ArrayList<Float>() {
{
add(1.0f);
add(16f / 9);
add(9f / 16);
}
};
@Override
public void onClick(View v) {
mRoom.setContainerSizeRatio(ratios.get(index++ % ratios.size()));
}
});
// 窗口暗色模式
findViewById(R.id.colorScheme).setOnClickListener(new View.OnClickListener() {
int index = 0;
final List<WindowPrefersColorScheme> colorSchemes = new ArrayList<WindowPrefersColorScheme>() {
{
add(WindowPrefersColorScheme.Dark);
add(WindowPrefersColorScheme.Light);
add(WindowPrefersColorScheme.Auto);
}
};
@Override
public void onClick(View v) {
mRoom.setPrefersColorScheme(colorSchemes.get(index++ % colorSchemes.size()));
}
});
// 插入播放器
findViewById(R.id.insertPlayer).setOnClickListener(v -> {
WindowAppParam appParam = WindowAppParam.createMediaPlayerApp("https://white-pan.oss-cn-shanghai.aliyuncs.com/101/oceans.mp4", "player");
mRoom.addApp(appParam, new Promise<String>() {
@Override
public void then(String appId) {
logRoomInfo("create App id " + appId);
}
@Override
public void catchEx(SDKError t) {
}
});
});
// 插入静态场景
findViewById(R.id.insertStatic).setOnClickListener(v -> {
// 由转换后信息序列化
String ppts = "[{\"name\":\"1\",\"ppt\":{\"height\":1010.0,\"src\":\"https://convertcdn.netless.link/staticConvert/0764816000c411ecbfbbb9230f6dd80f/1.png\",\"width\":714.0}},{\"name\":\"2\",\"ppt\":{\"height\":1010.0,\"src\":\"https://convertcdn.netless.link/staticConvert/0764816000c411ecbfbbb9230f6dd80f/2.png\",\"width\":714.0}},{\"name\":\"3\",\"ppt\":{\"height\":1010.0,\"src\":\"https://convertcdn.netless.link/staticConvert/0764816000c411ecbfbbb9230f6dd80f/3.png\",\"width\":714.0}},{\"name\":\"4\",\"ppt\":{\"height\":1010.0,\"src\":\"https://convertcdn.netless.link/staticConvert/0764816000c411ecbfbbb9230f6dd80f/4.png\",\"width\":714.0}}]";
Scene[] scenes = gson.fromJson(ppts, Scene[].class);
WindowAppParam param = WindowAppParam.createDocsViewerApp("/static", scenes, "static");
mRoom.addApp(param, null);
});
// 插入动态场景
findViewById(R.id.insertDynamic).setOnClickListener(v -> {
// 由转换后信息序列化
String ppts = " [{\"name\":\"1\",\"ppt\":{\"src\":\"pptx://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/1.slide\",\"width\":1280,\"height\":720,\"previewURL\":\"https://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/preview/1.png\"}},{\"name\":\"2\",\"ppt\":{\"src\":\"pptx://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/2.slide\",\"width\":1280,\"height\":720,\"previewURL\":\"https://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/preview/2.png\"}},{\"name\":\"3\",\"ppt\":{\"src\":\"pptx://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/3.slide\",\"width\":1280,\"height\":720,\"previewURL\":\"https://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/preview/3.png\"}},{\"name\":\"4\",\"ppt\":{\"src\":\"pptx://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/4.slide\",\"width\":1280,\"height\":720,\"previewURL\":\"https://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/preview/4.png\"}},{\"name\":\"5\",\"ppt\":{\"src\":\"pptx://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/5.slide\",\"width\":1280,\"height\":720,\"previewURL\":\"https://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/preview/5.png\"}},{\"name\":\"6\",\"ppt\":{\"src\":\"pptx://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/6.slide\",\"width\":1280,\"height\":720,\"previewURL\":\"https://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/preview/6.png\"}},{\"name\":\"7\",\"ppt\":{\"src\":\"pptx://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/7.slide\",\"width\":1280,\"height\":720,\"previewURL\":\"https://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/preview/7.png\"}},{\"name\":\"8\",\"ppt\":{\"src\":\"pptx://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/8.slide\",\"width\":1280,\"height\":720,\"previewURL\":\"https://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/preview/8.png\"}},{\"name\":\"9\",\"ppt\":{\"src\":\"pptx://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/9.slide\",\"width\":1280,\"height\":720,\"previewURL\":\"https://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/preview/9.png\"}},{\"name\":\"10\",\"ppt\":{\"src\":\"pptx://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/10.slide\",\"width\":1280,\"height\":720,\"previewURL\":\"https://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/preview/10.png\"}},{\"name\":\"11\",\"ppt\":{\"src\":\"pptx://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/11.slide\",\"width\":1280,\"height\":720,\"previewURL\":\"https://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/preview/11.png\"}},{\"name\":\"12\",\"ppt\":{\"src\":\"pptx://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/12.slide\",\"width\":1280,\"height\":720,\"previewURL\":\"https://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/preview/12.png\"}},{\"name\":\"13\",\"ppt\":{\"src\":\"pptx://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/13.slide\",\"width\":1280,\"height\":720,\"previewURL\":\"https://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/preview/13.png\"}},{\"name\":\"14\",\"ppt\":{\"src\":\"pptx://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/14.slide\",\"width\":1280,\"height\":720,\"previewURL\":\"https://convertcdn.netless.link/dynamicConvert/369ac28037d011ec99f08bddeae74404/preview/14.png\"}}]";
Scene[] scenes = gson.fromJson(ppts, Scene[].class);
WindowAppParam param = WindowAppParam.createSlideApp("/dynamic", scenes, "dynamic");
mRoom.addApp(param, null);
});
// 插入新的动态PPT
findViewById(R.id.insertNewDynamic).setOnClickListener(v -> {
// prefixUrl
String prefixUrl = "https://convertcdn.netless.link/dynamicConvert";
String taskUuid = "a136d855525a48a9844c678ad5027067";
WindowAppParam param = WindowAppParam.createSlideApp(taskUuid, prefixUrl, "Projector App");
mRoom.addApp(param, null);
});
// 插入本地同步信息
findViewById(R.id.insertLocal).setOnClickListener(v -> {
if (mRoom != null) {
// 插入方初始化状态
state = new UserSyncedState();
state.dragViewState.w = 0.3f;
state.dragViewState.h = 0.2f;
mRoom.safeSetAttributes(state);
}
updateDragView();
dragViewPlugin.startTimer(120_000);
});
// 16:9 限定
findViewById(R.id.lockRatio).setOnClickListener(v -> {
lockRatio();
});
findViewById(R.id.disableOperation).setOnClickListener(v -> {
if (mRoom != null) {
mRoom.disableWindowOperation(true);
}
});
findViewById(R.id.saveAttributes).setOnClickListener(v -> {
if (mRoom != null) {
mRoom.getWindowManagerAttributes(new Promise<String>() {
@Override
public void then(String s) {
File file = new File(getCacheDir(), WindowRestoreActivity.ATTRIBUTES_FILE);
try {
FileUtils.writeStringToFile(file, s);
gotoWindowRestore();
} catch (IOException e) {
showToast("write file error");
}
}
@Override
public void catchEx(SDKError t) {
}
});
}
});
joinRoom(demoAPI.getRoomUUID(), demoAPI.getRoomToken());
}
use of com.herewhite.sdk.domain.SDKError in project whiteboard-android by netless-io.
the class WindowTestActivity method joinRoom.
private void joinRoom(String uuid, String token) {
logRoomInfo("room uuid: " + uuid + "\nroom token: " + token);
WhiteSdkConfiguration configuration = new WhiteSdkConfiguration(demoAPI.getAppId(), true);
/*显示用户头像*/
configuration.setUserCursor(true);
// 动态 ppt 需要的自定义字体,如果没有使用,无需调用
configuration.setFonts(new MapBuilder<String, String>().put("宋体", "https://your-cdn.com/Songti.ttf").build());
// configuration.setEnableSyncedStore(true);
configuration.setUseMultiViews(true);
mWhiteSdk = new WhiteSdk(mWhiteboardView, this, configuration);
mWhiteSdk.setCommonCallbacks(new CommonCallback() {
@Override
public void onLogger(JSONObject object) {
logAction(object.toString());
}
});
/* 设置自定义全局状态,在后续回调中 GlobalState 直接进行类型转换即可 */
WhiteDisplayerState.setCustomGlobalStateClass(GlobalState.class);
// 如需支持用户头像,请在设置 WhiteSdkConfiguration 后,再调用 setUserPayload 方法,传入符合用户信息
RoomParams roomParams = new RoomParams(uuid, token, DemoAPI.DEFAULT_UID);
HashMap<String, String> styleMap = new HashMap<>();
styleMap.put("backgroundColor", "red");
styleMap.put("top", "12px");
styleMap.put("left", "60px");
styleMap.put("position", "fixed");
// String darkMode = darkModeStyle();
WindowParams windowParams = new WindowParams().setContainerSizeRatio(3f / 4).setChessboard(true).setDebug(true).setCollectorStyles(styleMap);
// optional
roomParams.setWindowParams(windowParams);
mWhiteSdk.joinRoom(roomParams, new RoomListener() {
@Override
public void onPhaseChanged(RoomPhase phase) {
logRoomInfo("onPhaseChanged: " + phase.name());
showToast(phase.name());
}
@Override
public void onDisconnectWithError(Exception e) {
}
@Override
public void onKickedWithReason(String s) {
}
@Override
public void onRoomStateChanged(RoomState roomState) {
if (roomState.getWindowBoxState() != null) {
logRoomInfo("WindowBoxState " + roomState.getWindowBoxState());
}
}
@Override
public void onCanUndoStepsUpdate(long l) {
}
@Override
public void onCanRedoStepsUpdate(long l) {
}
@Override
public void onCatchErrorWhenAppendFrame(long l, Exception e) {
}
@Override
public void onAttributesUpdate(String valueOf) {
state = gson.fromJson(valueOf, UserSyncedState.class);
logRoomInfo("onAttributesUpdate:" + state);
updateDragView();
}
}, new Promise<Room>() {
@Override
public void then(Room room) {
mRoom = room;
}
@Override
public void catchEx(SDKError sdkError) {
}
});
}
use of com.herewhite.sdk.domain.SDKError in project whiteboard-android by netless-io.
the class RoomActivityTest method setScenePath.
@Test
public void setScenePath() {
onIdle();
CountingIdlingResource idlingResource = new CountingIdlingResource("getScenePath");
idlingResource.increment();
mActivity.mRoom.getSceneState(new Promise<SceneState>() {
@Override
public void then(SceneState sceneState) {
currentSceneState = sceneState;
idlingResource.decrement();
}
@Override
public void catchEx(SDKError t) {
idlingResource.decrement();
}
});
IdlingRegistry.getInstance().register(idlingResource);
SetScenePathResult result = new SetScenePathResult();
result.register();
onView(isRoot()).perform(new SimpleViewAction() {
@Override
public void perform(UiController uiController, View view) {
IdlingRegistry.getInstance().unregister(idlingResource);
if (currentSceneState == null) {
fail();
}
result.start();
mActivity.mRoom.setScenePath(getNextScenePath(currentSceneState), result);
}
private String getNextScenePath(SceneState currentSceneState) {
String dir = currentSceneState.getScenePath().substring(0, currentSceneState.getScenePath().lastIndexOf('/'));
int index = currentSceneState.getIndex();
Scene[] scenes = currentSceneState.getScenes();
Scene tScene = scenes[(index + 1) % scenes.length];
return dir + '/' + tScene.getName();
}
});
// wait for idling
onIdle();
onView(isRoot()).perform(new SimpleViewAction() {
@Override
public void perform(UiController uiController, View view) {
assertEquals(true, result.success);
result.unregister();
}
});
}
Aggregations