0

So I'm making an app that uses Samsung's Pen SDK, the only problem is in their example, ComposerSample7_1_Composer, there is code for creating the context menus,

private void createContextMenu(Menu menu) {
    final boolean editable = mSpenComposerView.getMode() == SpenComposerView.MODE_EDIT;
    final SpenSDoc.CursorInfo begin = mSDoc.getSelectedRegionBegin();
    final SpenSDoc.CursorInfo end = mSDoc.getSelectedRegionEnd();

    Log.d(TAG, "SpenContextMenuListener$createContextMenu : " + begin.index + " - " + end.index);

    menu.add(Menu.NONE, CONTEXT_MENU_ID_CUT, CONTEXT_MENU_ID_CUT, "CUT")
            .setEnabled(editable);
    menu.add(Menu.NONE, CONTEXT_MENU_ID_COPY, CONTEXT_MENU_ID_COPY, "COPY")
            .setEnabled(mSDoc.isSelected());
    menu.add(Menu.NONE, CONTEXT_MENU_ID_PASTE, CONTEXT_MENU_ID_PASTE, "PASTE")
            .setEnabled(editable);
    menu.add(Menu.NONE, CONTEXT_MENU_ID_SELECT_ALL, CONTEXT_MENU_ID_SELECT_ALL, "SELECT ALL")
            .setEnabled(true);

    if (begin.index >= 0 && begin.index == end.index) {
        switch (mSDoc.getContent(begin.index).getType()) {
            case SpenContentBase.TYPE_HANDWRITING:
                break;
            case SpenContentBase.TYPE_DRAWING:
                menu.add(Menu.NONE, CONTEXT_MENU_ID_RESIZE_IMAGE, CONTEXT_MENU_ID_RESIZE_IMAGE, "RESIZE")
                        .setEnabled(editable);
                break;
            case SpenContentBase.TYPE_IMAGE:
                menu.add(Menu.NONE, CONTEXT_MENU_ID_RESIZE_IMAGE, CONTEXT_MENU_ID_RESIZE_IMAGE, "RESIZE")
                        .setEnabled(editable);
                break;
            case SpenContentBase.TYPE_VOICE:
                break;
        }
    }
}

But the there is no actions for what to do when these items are selected, this is what the sample code has:

private boolean executeMenuItem(MenuItem item) {
    final SpenSDoc.CursorInfo begin = mSDoc.getSelectedRegionBegin();
    final SpenSDoc.CursorInfo end = mSDoc.getSelectedRegionEnd();

    Log.d(TAG, "SpenContextMenuListener$executeMenuItem : " + item.getItemId() + " / " + begin.index + " - " + end.index);

    switch (item.getItemId()) {
        case CONTEXT_MENU_ID_CUT:
            //TODO
            break;
        case CONTEXT_MENU_ID_COPY:
            //TODO

            break;
        case CONTEXT_MENU_ID_PASTE:
            //TODO

            break;
        case CONTEXT_MENU_ID_RESIZE_IMAGE: {
            if (!mSDoc.isSelected()) {
                return true;
            }
            final SpenContentBase contentImage = mSDoc.getContent(begin.index);
            if (contentImage != null
                    && (contentImage.getType() == SpenContentBase.TYPE_IMAGE || contentImage.getType() == SpenContentBase.TYPE_DRAWING)) {
                mSpenComposerView.setResizeHandleVisible(true);
                mSDoc.setCursorPosition(begin.pos > 0 ? begin : end);
                mSoftInput.hide((Activity) mContext);
            }
        }
        break;
        case CONTEXT_MENU_ID_SELECT_ALL:
            selectAll();
            break;
    }

    return true;
}

How can I get these actions to work? This is where Samsung's SDK is located, including all the sample code. Thanks for any help, this is my first post, so sorry if I messed something up!

hong4rc
  • 3,999
  • 4
  • 21
  • 40

1 Answers1

0

@WalkingHat Samsung S-Pen SDK wrapper library don't support these kind of features

A Samsung S-Pen library for Android that handles most of the common use cases with a single class only with much reduced complexity compared with Samsung SDK Pen package.

which support: Pen of various styles, colors and adjustable size

Eraser of adjustable size

Undo, redo

Zoom

Scroll automatically when the pen is hovering near an edge of the canvas

Replay of strokes with different speed

Instance thumbnail generation

Multi-page support

Re-order pages

Color background

Image background

Supported events: onTouch, onReplayCompleted, onPageUpdated, onCommit, undo, redo

Draw using S-Pen or finger

you need to your code for these

Adil
  • 812
  • 1
  • 9
  • 29
  • I'm not quite sure what you mean. If this isn't possible using the Pen SDK, how is Samsung doing it in their Samsung Notes app? – WalkingHat Jun 16 '18 at 01:12