use of com.herewhite.sdk.domain.WindowPrefersColorScheme 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());
}
Aggregations