Search in sources :

Example 1 with Scene

use of com.herewhite.sdk.domain.Scene in project whiteboard-android by netless-io.

the class RoomActivity method insertNewScene.

public void insertNewScene(MenuItem item) {
    logAction();
    mRoom.putScenes(SCENE_DIR, new Scene[] { new Scene("page1") }, 0);
    mRoom.setScenePath(SCENE_DIR + "/page1");
}
Also used : Scene(com.herewhite.sdk.domain.Scene)

Example 2 with Scene

use of com.herewhite.sdk.domain.Scene in project whiteboard-android by netless-io.

the class PptResourceCacheActivity method insertPPT.

public void insertPPT(MenuItem item) {
    logAction();
    mRoom.putScenes(SCENE_DIR, new Scene[] { new Scene("page2", new PptPage("https://white-pan.oss-cn-shanghai.aliyuncs.com/101/image/alin-rusu-1239275-unsplash_opt.jpg", 600d, 600d)) }, 0);
    mRoom.setScenePath(SCENE_DIR + "/page2");
}
Also used : PptPage(com.herewhite.sdk.domain.PptPage) Scene(com.herewhite.sdk.domain.Scene)

Example 3 with Scene

use of com.herewhite.sdk.domain.Scene 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());
}
Also used : WindowPrefersColorScheme(com.herewhite.sdk.domain.WindowPrefersColorScheme) ArrayList(java.util.ArrayList) SDKError(com.herewhite.sdk.domain.SDKError) IOException(java.io.IOException) Scene(com.herewhite.sdk.domain.Scene) WhiteboardView(com.herewhite.sdk.WhiteboardView) DWebView(wendu.dsbridge.DWebView) View(android.view.View) LocalFileWebViewClient(com.herewhite.demo.LocalFileWebViewClient) WindowAppParam(com.herewhite.sdk.domain.WindowAppParam) File(java.io.File)

Example 4 with Scene

use of com.herewhite.sdk.domain.Scene 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();
        }
    });
}
Also used : CountingIdlingResource(androidx.test.espresso.idling.CountingIdlingResource) SDKError(com.herewhite.sdk.domain.SDKError) SimpleViewAction(com.herewhite.demo.utils.SimpleViewAction) SceneState(com.herewhite.sdk.domain.SceneState) UiController(androidx.test.espresso.UiController) Scene(com.herewhite.sdk.domain.Scene) View(android.view.View) Espresso.onView(androidx.test.espresso.Espresso.onView) Test(org.junit.Test)

Example 5 with Scene

use of com.herewhite.sdk.domain.Scene in project whiteboard-android by netless-io.

the class RoomActivityTest method putScenes.

@Test
public void putScenes() {
    onIdle();
    SceneStateRecover recover = new SceneStateRecover(mActivity.mRoom.getSceneState());
    CountDownLatch latch = new CountDownLatch(2);
    onIdle((Callable<Void>) () -> {
        mActivity.mRoom.putScenes(PUT_TEST_DIR, new Scene[] { new Scene(PUT_TEST_PAGE) }, 0);
        mActivity.mRoom.setScenePath(PUT_TEST_PATH, new SimpleLatchDownPromise<>(latch));
        mActivity.mRoom.getSceneState(new SimpleLatchDownPromise<>(latch));
        return null;
    });
    try {
        latch.await();
    } catch (InterruptedException e) {
        fail();
    }
    onIdle((Callable<Void>) () -> {
        assertEquals(PUT_TEST_PATH, mActivity.mRoom.getSceneState().getScenePath());
        mActivity.mRoom.removeScenes(PUT_TEST_DIR);
        return null;
    });
    recover.restore();
}
Also used : CountDownLatch(java.util.concurrent.CountDownLatch) Scene(com.herewhite.sdk.domain.Scene) Test(org.junit.Test)

Aggregations

Scene (com.herewhite.sdk.domain.Scene)11 PptPage (com.herewhite.sdk.domain.PptPage)4 SDKError (com.herewhite.sdk.domain.SDKError)3 Test (org.junit.Test)3 View (android.view.View)2 ConvertedFiles (com.herewhite.sdk.domain.ConvertedFiles)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 Espresso.onView (androidx.test.espresso.Espresso.onView)1 UiController (androidx.test.espresso.UiController)1 CountingIdlingResource (androidx.test.espresso.idling.CountingIdlingResource)1 JsonObject (com.google.gson.JsonObject)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 LocalFileWebViewClient (com.herewhite.demo.LocalFileWebViewClient)1 SimpleViewAction (com.herewhite.demo.utils.SimpleViewAction)1 WhiteboardView (com.herewhite.sdk.WhiteboardView)1 SceneState (com.herewhite.sdk.domain.SceneState)1 WindowAppParam (com.herewhite.sdk.domain.WindowAppParam)1 WindowPrefersColorScheme (com.herewhite.sdk.domain.WindowPrefersColorScheme)1 File (java.io.File)1 IOException (java.io.IOException)1