Skip to main content
Samsung Developer Program

Integrating WritingBuddy

WritingBuddy enables your users to:

  • Hand write text with an S-Pen for purposes related to display screen locations (for example, to fill in UI entry fields).
  • Create hand-drawn images via an image editor, which are then converted into a bitmap file and made available to your app via an image user-commit listener.

WritingBuddy does not enter text or images into app UI fields or assign them to any app purpose. Your app sets up WritingBuddy to get and convert handwritten text or to get a hand-drawn image to be used, for example, as a UI field entry or setting a background image. Your app then listens for WritingBuddy to issue a text string or an image file after the end-user commits their image or converted text.

Note: The availability of WritingBuddy features, even when enabled via the Look API, is controlled by device configuration (Settings > (Motion) S Pen > Direct pen input On / Off).

For details about the WritingBuddy API, see the WritingBuddy API Structure section.

User Text Input

WritingBuddy enables your users to quickly input S-Pen handwritten text for purposes related to display screen locations, for example, to fill in UI entry fields or provide input for other purposes, for example, alphanumeric, numeric-only, date, and phone dialer data, via a simple text input panel or an editor panel with text editing features. WritingBuddy text input is quicker than soft keyboard text input. WritingBuddy automatically converts handwritten text and displays it in a stylized cursive handwriting font.

Handwriting Conversion Language

WritingBuddy enables conversion of user handwriting into Unicode alphabet and numeral character codes of any handwriting recognition language selected in device configuration (Language and input > Handwriting recognition Language).

In the text editor panel, the current conversion language is determined by the following:

  • The language the user toggle-selects from all configured recognition languages.  
  • Upon opening the panel, either:
    • The most recently-used conversion language when that language is still configured.
    • When the most recently-used language is not configured, the first language listed in device configuration.​

In the text input panel, only the current conversion language is available.

Samsung Look S-Pen Alphanumeric and Numeric-Only Text Input Panels

Text Input Panel

The WritingBuddy text input panel provides straight-forward conversion of handwritten input:

  • Offers simple, direct handwriting input of either alphabet and/or numeral text, or numeral text only
  • Converts user handwritten input into Unicode characters (displayed in quasi-handwritten font), based on the current conversion language (selectable in the text editor).
  • Upon user commit, generates a Unicode character string, which is processed according to an app-specified user-commit listener (such as assigning it as a UI field entry).
  • User options:
    • Input handwritten text in one line.
    • Input is via cursive writing (continuous pressing) and/or via quickly drawn individual letters / numbers. 
    • Erase all converted text (panel remains active).
    • Commit the displayed converted text, which causes a text string to be generated and processed by the text listener, closes the text input panel, and returns to normal app UI display and app control.
    • Close the input panel (by tapping the S-Pen anywhere outside the panel), which deletes converted text without the committing the text, and returns to normal app UI display and app control.

 

 

 

 

 

 

 

 

 

Samsung Look S-Pen Alphanumeric Text Editor Panel

Text Editor Panel

The WritingBuddy text editor panel provides editing and conversion of handwritten input:

  • Supports handwriting input of alphabet and numeral text.
  • Converts input into Unicode characters based on the current conversion language.
  • While the editor panel is displayed, users can add, edit, and delete text.
  • Upon user commit, generates a Unicode character string, which is either automatically assigned to view(s) in the associated ViewGroup (UI entry fields) or processed according to an app-specified user-commit listener.
  • User options:
    • Select text conversion language from all available handwriting conversions.
    • Enter and edit handwritten text in one or more lines.
    • Space insertion, backspace with deletion, line return insertion.
    • Reposition cursor to change any converted text.
    • Expand / contract panel size (app-specified partial screen or full screen).
    • Handwriting input help.
    • Switch to Image Editor Panel when enabled by your app.
    • Commit the displayed converted text, which causes a text string to be generated and either be assigned to the associated view (no listener) OR processed by the text listener, closes the text editor panel, and returns to normal app UI display and app control. 
    • Close the editor panel by tapping the 'X' close icon or anywhere outside the panel, which ​deletes without the committing the text, and returns to normal app UI display and app control. 

Text Setup, Input, and Processing

After integrating and enabling WritingBuddy, your users can input and convert their handwriting into alphanumeric Unicode of any available handwriting recognition language, and they can generate bitmap files of hand-drawn line drawings, which are then processed as specified by your app.

Samsung Look S-Pen Text Input Process without a Listener

Setting up WritingBuddy to provide for text input and processing via a text input panel or a text editor panel:

  • Your app:
    • Ensures the user's device platform supports WritingBuddy
    • Ensures WritingBuddy features are enabled
    • Instantiates a WritingBuddy object to EITHER:
      • Make available a text input panel:
        • Specifies a ViewGroup to initiate WritingBuddy input
        • Specifies alphanumeric conversion or numeric-only conversion
        • Sets sets a text user-commit listener that specifies how to process user-committed text
          or
      • Make available a text editor panel:
        • Specifies an EditText view to initiate WritingBuddy input
        • Always provides alphanumeric conversion
        • Either:
          • Sets a listener to specify how to process user-committed text
          • Does NOT set a listener to assign user-committed text as the UI entry of the targeted EditText view
  • The user hovers their S-Pen over the display screen location of either the targeted ViewGroup (text input panel) or EditText view (text editor panel).
  • WritingBuddy changes from the S-Pen Pointer Icon  Samsung Look S-Pen Hover Icon  to the S-Pen Tap Icon  Samsung Look S-Pen Tap-to-Input Icon   that the user taps, when enabled in device configuration.
Samsung Look S-Pen Text Input Process with a Listener
  • The user interacts with WritingBuddy:
    • In text input panels:
      • The user hand writes text input.
      • WrittingBuddy converts the input and displays Unicode text in a cursive handwritten font.
      • After the user commits the converted text, WritingBuddy generates a Unicode text string and issues a user-commit call.
    • In text editor panels:
      • The user hand writes text input.
      • WrittingBuddy converts the input and displays Unicode text in a cursive handwritten font.
      • The user can edit and erase converted text, and enter new text input.
      • After the user commits the converted text, WritingBuddy generates a Unicode text string and issues a user-commit call.
  • When your app does not set a user-commit listener WritingBuddy automatically assigns the user-committed text as the UI field entry of the associated EditText view.
  • When your app sets a user-commit listener is set the listener responds and processes the text string to support its use.

User Image Input

WritingBuddy enables your users to create hand-drawn images via an image editor.  After a user commits an image, WritingBuddy converts the image to a bitmap file and makes the file available to your app via an image user-commit listener.

Image Editor PanelSamsung Look S-Pen Image Editor Panel

The WritingBuddy image editor panel provides straight-forward hand-drawn input and image file generation:

  • Supports hand-drawn input of colored line images.
    Note: Also supports generating an image of the user's actual handwriting.
  • While the editor panel is displayed, users can add to the image or delete the entire image and start drawing again.
  • Upon user commit, generates an image bitmap file, which is processed according to an app-specified user-commit listener.
  • User options:
    • Select line color.
    • Enter hand drawn line drawing image.
    • Erase entire line drawing.
    • Switch to Text Editor Panel (when enabled by your app)
    • Commit the drawing, which causes an image bitmap file to be generated and processed by the image listener, closes the image editor panel, and returns to normal app UI display and app control.
    • Close the editor panel by tapping the 'X' icon in the panel, or tapping anywhere outside the panel, which deletes the image without the committing it, hides the image editor panel, and returns to normal app UI display and app control.

Samsung Look S-Pen Image Input Process

Setting up WritingBuddy to provide for image input and processing via an image editor panel:

  • Your app:
    • Ensures the user's device platform supports WritingBuddy.
    • Ensures WritingBuddy features are enabled.
    • Instantiates an editor WritingBuddy object that targets an EditText view.
    • Sets an image user-commit listener to make available an image editor panel and to specify how to process a user-committed image (for example, to prompt the user to save their hand drawn image ).
  • The user hovers the S-Pen over the targeted EditText view's display screen location (for example, a 'Set Background Image' UI button).
  • WritingBuddy changes from the S-Pen pointer icon Samsung Look S-Pen Hover Icon  to the S-Pen tap icon  Samsung Look S-Pen Tap-to-Input Icon   that the user taps (when enabled in device configuration).
  • In the image editor panel, the user hand-draws an image and can erase it and enter a new image.
  • After the user commits the image, WritingBuddy generates and makes available a bitmap image file and issues a user-commit call.
  • Your app's listener responds and processes the image file to support its use.

Integrating WritingBuddy

To provide your users with WritingBuddy features:

  • The user's device must support WritingBuddy features.
  • Your app must:
    • Not disable WritingBuddy features, or enable them after disabling them.
    • Instantiate a WritingBuddy object for a ViewGroup to control the type WritingBuddy panel available to the user (input panel or editor panel).
    • For input panels, specify the type of text conversion (alphanumeric or numeric only).
    • Specify a user-commit listener to process the user's converted text or image file, and/or control the type of editor panel (text or image editor panel).
    • For text editor panels, NOT specify a user-commit listener to automatically assign the user's text entry as the associated view's UI field entry.

Supporting, Enabling, and Disabling WritingBuddy

To provide your users with WritingBuddy input, the user's device platform must support WritingBuddy functionality.

Example Code:  Determining device support of WritingBuddy

public SlookWritingBuddy(ViewGroup parentView)
  {
    if (!isSupport(1))
    {
      Log.e("WritingBuddy", "This is not supported in device");
      return;
    }
    this.mParentView = parentView;
    this.mWritingBuddyImpl = new WritingBuddyImpl(parentView);
  }

Even with WritingBuddy supported by the device platform and integrated into your app, WritingBuddy features MUST be enabled in order for your users to input via WritingBuddy.  
However, the default setting is WritingBuddy enabled, and will only be disabled when setEnabled(false) is specified.

Depending on your app needs, your app may:

  • Enable WritingBuddy, set up one or more WritingBuddy panels for input, wait for and respond to the user committing input, and then disable WritingBuddy during app shutdown.
    OR
  • Enable WritingBuddy, set up one WritingBuddy panel for input, wait for and respond to the user committing input, disable WritingBuddy when appropriate, such as the user navigating to a different UI tab, set up another WritingBuddy panel for input.

Making a Text Input Panel Available

This section describes how to integrate WritingBuddy APIs in order to make a WritingBuddy text input panel available for the user to input, convert, and commit handwriting into a Unicode character string (either alphanumeric or numeric-only) that the app can then use.

A text user-commit listener must be specified to process the user-committed text.

To get and process user text input by setting up a text input panel and user-commit listener:

  • Ensure WritingBuddy is supported and enabled.
  1. Instantiate an input panel WritingBudding object for a specific ViewGroup (SlookWritingBuddy (parentView)).
  2. Optional  Specify the type of text that user input is to be converted to:
    Note: When the text type is not specified, user input is converted into alphabetic and/or numeric Unicode characters.
    1. Alphabetic and/or numeric Unicode characters (specify setEditorType(TYPE_EDITOR_TEXT)).
    2. Numeric-only Unicode characters (specify setEditorType(TYPE_EDITOR_NUMBER)).
  3. Register a text user-commit listener:
    1. Specify the name of the listener (setTextWritingListener).
    2. Specify the listener interface (TextWritingListener).
    3. Assign a variable name to the user-committed Unicode string, and specify how to process it (onTextReceived).

Example Code:  Instantiating an alphanumeric text input panel via default text editor type and setting a text user-commit listener

FrameLayout frame1 = (FrameLayout) findViewById(R.id.frame1);
SlookWritingBuddy mWritingBuddyFrame1 = new SlookWritingBuddy(frame1);

mWritingBuddyFrame2.setTextWritingListener(new TextWritingListener() {

       @Override
       public void onTextReceived(CharSequence arg0) {
                     // TODO Auto-generated method stub
       }
});

Example Code:  Instantiating an alphanumeric text input panel via explicit text editor type

FrameLayout frame2 = (FrameLayout) findViewById(R.id.frame2);
SlookWritingBuddy mWritingBuddyFrame2 = new SlookWritingBuddy(frame2);
mWritingBuddyFrame2.setEditorType(SlookWritingBuddy.TYPE_EDITOR_TEXT);

Example Code:  Instantiating a numeric-only text input panel

FrameLayout frame3 = (FrameLayout) findViewById(R.id.frame3);
SlookWritingBuddy mWritingBuddyFrame3 = new SlookWritingBuddy(frame3);
mWritingBuddyFrame3.setEditorType(SlookWritingBuddy.TYPE_EDITOR_NUMBER);

Making Only a Text Editor Panel Available

This section describes how to integrate WritingBuddy APIs in order to make a WritingBuddy text editor panel (and not an image editor panel) available for the user to input, convert, and commit handwriting into a Unicode chararcter string (either alphanumeric or numeric-only) that the app can then use.

A text user-commit listener is optional:

  • When NO listener is set:
    • Only the text editor panel will be available to the end-user.
      In the text editor panel UI, the image editor icon will not be displayed. 
    • User-committed text strings will be automatically assigned to the specified EditText view.
  • When ONLY a text listener is set:
    • Only the text editor panel will be available to the end-user.
      In the text editor panel UI, the image editor icon will not be displayed.
    • User-committed converted text strings will be processed as specified by the listener. 

To get and process user text input by setting up a text editor panel and user-commit listener:

  • Ensure WritingBuddy is supported and enabled.
  1. Instantiate an editor panel WritingBudding object for a specific EditText view (SlookWritingBuddy (editText)).
  2. Optional  Specify the type of text that user input is to be converted to:
    Note: When the text type is not specified, user input is converted into alphabetic and/or numeric Unicode characters.
    1. Alphabetic and/or numeric Unicode characters (specify setEditorType(TYPE_EDITOR_TEXT)).
    2. Numeric-only Unicode characters (specify setEditorType(TYPE_EDITOR_NUMBER)).
  3. Optional  Register a text user-commit listener:
    Note: When a listener is not registered, the user's converted text string is automatically assigned as the UI entry of the EditText view.
    1. Specify the name of the listener (setTextWritingListener).
    2. Specify the listener interface (TextWritingListener).
    3. Assign a variable name to the user-committed Unicode string, and specify how to process it (onTextReceived).

Example Code:  Instantiating an alphanumeric text editor panel via default editor type and automatically assigning user-committed text to a UI field view 

EditText editText1 = (EditText) findViewById(R.id.editText1);
SlookWritingBuddy mWritingBuddy1 = new SlookWritingBuddy(editText1);

mWritingBuddy1.setTextWritingListener(new TextWritingListener() {

       @Override
       public void onTextReceived(CharSequence arg0) {
                     // TODO Auto-generated method stub
       }
});

Example Code:  Instantiating an alphanumeric text editor panel via default text editor type and setting a user-commit listener 

EditText editText1 = (EditText) findViewById(R.id.editText1);
SlookWritingBuddy mWritingBuddy1 = new SlookWritingBuddy(editText1);

mWritingBuddy1.setTextWritingListener(new TextWritingListener() {

       @Override
       public void onTextReceived(CharSequence arg0) {
                     // TODO Auto-generated method stub
       }
});

Example Code:  Instantiating an alphanumeric text editor panel via explicit text editor type

EditText editText2 = (EditText) findViewById(R.id.editText2);
SlookWritingBuddy mWritingBuddy2 = new SlookWritingBuddy(editText2);
mWritingBuddy2.setEditorType(SlookWritingBuddy.TYPE_EDITOR_TEXT);

Example Code:  Instantiating a numeric-only text editor panel 

EditText editText3 = (EditText) findViewById(R.id.editText3);
SlookWritingBuddy mWritingBuddy3 = new SlookWritingBuddy(editText3);
mWritingBuddy3.setEditorType(SlookWritingBuddy.TYPE_EDITOR_NUMBER);

Making Both Text and Image Editor Panels Available

This section describes how to integrate WritingBuddy APIs in order to make a WritingBuddy text editor panel and image editor panel available for the user to input, convert, and commit handwriting into a Unicode chararcter string (either alphanumeric or numeric-only) that the app can then use. Both editor panels are available to the user via UI buttons in each panel.

A text user-commit listener is optional.  A image user-commit listener must be specified to process the user's image bitmap file, for example, prompt the user where to save the file.

When calling this method, user-commit listeners (via setTextWritingListener and/or setImageWritingListener) can be set to control what editor panels are available to users, and to process user-committed text strings and image files:

  • When ONLY an image listener is set:
    • BOTH image and text editors panel will be available to the end-user.
      The text editor panel will be initially displayed, which will display an image editor icon that displays the image editor panel, which will display a text editor icon that displays the text editor panel.  
    • User-committed image bitmap files will be processed as specified by the image listener.
    • User-committed text strings will be automatically assigned to the specified EditText view.
  • When BOTH text and image listeners are set:
    • Both text and image editor panels will be available to the end-user.
      The text editor panel will be initially displayed, which will display an image editor icon that displays the image editor panel, which will display a text editor icon that displays the text editor panel.  
    • User-committed converted text strings will be processed as specified by the text listener.  
    • User-committed image bitmap files will be processed as specified by the image listener.

To get and process user text and images by setting up text and image editor panels and user-commit listeners to:

  • Ensure WritingBuddy is supported and enabled.
  1. Instantiate an editor panel WritingBudding object for a specific EditText view (SlookWritingBuddy (editText)).  
  2. Optional  Specify the type of text that user input in the text editor panel is to be converted to:
    Note: When the type of text is not specified, user input is converted into alphabetic and/or numeric Unicode characters.
    1. Alphabetic and/or numeric Unicode characters (specify setEditorType(TYPE_EDITOR_TEXT)).
    2. Numeric-only Unicode characters (specify setEditorType(TYPE_EDITOR_NUMBER)).
  3. Register an image user-commit listener to make available an image editor panel and to process user-committed images:
    1. Specify the name of the listener (setImageWritingListener).
    2. Specify the listener interface (ImageWritingListener).
    3. Assign a variable name to the user-committed image bitmap file, and specify how to process it (onImageReceived).
  4. Optional  Register a text user-commit listener to process user-committed converted text:
    Note: When a text listener is not registered, the user-committed text string is automatically assigned as the UI field of the EditText view.
    1. Specify the name of the listener (setTextWritingListener).
    2. Specify the listener interface (TextWritingListener).
    3. Assign a variable name to the user-committed Unicode string, and specify how to process it (onTextReceived).

Example Code:  Instantiating an alphanumeric text editor panel and an image editor panel, and setting an image listener

EditText editText5 = (EditText) findViewById(R.id.editText5);
SlookWritingBuddy mWritingBuddy5 = new SlookWritingBuddy(editText5);
mWritingBuddy5.setEditorType(SlookWritingBuddy.TYPE_EDITOR_TEXT);
             
mWritingBuddy5.setImageWritingListener(new ImageWritingListener() {
                    
@Override
       public void onImageReceived(Bitmap arg0) {
       // TODO Auto-generated method stub
            arg0));                  
       }
});

Example Code:  Instantiating a numeric-only text editor panel  and an image editor panel, and setting image and text listeners

EditText editText6 = (EditText) findViewById(R.id.editText6);
SlookWritingBuddy mWritingBuddy6 = new SlookWritingBuddy(editText6);
mWritingBuddy6.setEditorType(SlookWritingBuddy.TYPE_EDITOR_NUMBER);
             
mWritingBuddy6.setImageWritingListener(new ImageWritingListener() {
       @Override
       public void onImageReceived(Bitmap arg0) {
       // TODO Auto-generated method stub
       }
});

mWritingBuddy6.setTextWritingListener(new TextWritingListener() {

       @Override
       public void onTextReceived(CharSequence arg0) {
                     // TODO Auto-generated method stub
       }
});
  • Was this article helpful?