Onyx Android SDK

repository·master·Indexed 42 days ago

https://github.com/onyx-intl/onyxandroiddemo

Demonstration project and documentation for Onyx-Intl SDKs, including onyxsdk-device (v1.1.11), onyxsdk-pen (v1.2.1), and onyxsdk-base (v1.4.3.7). Provides implementation examples for E-Paper Display (EPD) control, screen refreshing, front light adjustment, pen/scribble inking, storage management, and DictionaryUtils API. Includes UI/UX adaptation guidelines for BOOX Eink devices and ADB command references for launching system applications.

Tokens
10.9K
Snippets
35
Records
54
Agent score
53%

What's inside Onyx SDK

  1. Overview of Onyx Data SDK features

    master

    The onyxsdk-data module (version 1.0.1) provides managed implementations for several common device tasks, including:

    • WechatManager: WeChat integration.
    • OssManager: Aliyun OSS (Object Storage Service) management.
    • FileDownloader: File downloading capabilities.
    • OTAManager: Over-the-air update management.
    • part Request: Handling partial requests.
  2. Control E-Paper Display (EPD) features

    master

    The SDK provides several controllers to manage the E-Paper Display characteristics:

    • Screen Refreshing: Use EpdController to manage how the EPD screen refreshes.
    • Front Light: Use FrontLightController to adjust screen brightness on devices equipped with a front light.
    • Refresh Modes: Change the app's refresh mode (e.g., for different visual characteristics) using the provided refresh mode APIs.
    • Full Screen: Use DeviceUtils.setFullScreenOnResume(this, fullscreen) to manage full-screen switching on all supported devices.
  3. Calculate sw-dp for device resolutions

    master

    To determine the appropriate sw-dp (smallest width in density-independent pixels) for a specific device, use the following formula based on the device's resolution and DPI:

    sw-dp = (resolution_width * 160) / dpi

    After calculating the real value, you should select the closest sw-dp value that is smaller than or equal to the calculated result. This ensures the UI layout scales correctly for the device's physical characteristics.

    // Example calculation for a 1024x758 device with 212 DPI:
    // 758 * 160 / 212 = 572
    // Closest sw-dp used: 480
  4. Implement Inking and Scribble functionality

    master

    The onyxsdk-pen SDK allows you to apply ink to various view types (e.g., SurfaceView, WebView).

    Key capabilities include:

    • Touch-enabled Drawing: Use TouchHelper (a simplified drawing API) to allow users to draw with their fingers on touch-enabled devices.
    • WebView Inking: Apply ink strokes directly onto a WebView containing web content.
    • Eraser Tools: Implement a move eraser for stroke correction.
    • Multi-view Inking: Support inking across multiple views simultaneously.
    • Stroke Management: Save and manage ink strokes.
  5. Use EpdDeviceManager for uniform EPD screen updates

    master

    The EpdDeviceManager acts as a wrapper for EpdController, providing a simplified and uniform interface for EPD (Electronic Paper Display) screen updates across different hardware platforms (RK3026 and IMX6). It automatically handles device-specific logic to choose between normal and regal partial screen updates.

    To perform updates, you can set a Global Controller (GC) interval and then apply the update to a specific view.

    // Set the interval for partial and full screen updates
    EpdDeviceManager.setGcInterval(THE_INTERVAL_YOU_WANT_TO_SET);
    
    // Update the screen using the set interval
    EpdDeviceManager.applyWithGCInterval(textView, isTextPage);
  6. Enter and leave scribble mode

    master

    To use the scribble feature, you must first request the framework to switch to scribble mode by calling enterScribbleMode(view). Once the user has finished scribbling, call leaveScribbleMode(view) to return to normal operation.

    Note: While in scribble mode, all other screen update requests from the application will be ignored by the framework.

    Device.currentDevice().enterScribbleMode(view);
    // ... scribbling occurs ...
    Device.currentDevice().leaveScribbleMode(view);
  7. Add Onyx SDK dependencies to your project

    master

    To use the Onyx SDKs, include the following dependencies in your build.gradle file. This project utilizes onyxsdk-device and onyxsdk-pen.

        implementation('com.onyx.android.sdk:onyxsdk-device:1.1.11')
        implementation('com.onyx.android.sdk:onyxsdk-pen:1.2.1')
  8. Initialize and use TouchHelper for scribbling

    master

    The TouchHelper class in onyxsdk-scribble 1.0.8 provides a simplified interface for implementing stylus scribbling on an Android View.

    To use it, call setup(view) on a target View and configure your drawing parameters. You can define a specific region for scribbling using setLimitRect and optionally exclude certain areas using a list of Rect objects.

    To control the scribbling state:

    1. Call openRawDrawing() to initialize resources.
    2. Use setRawDrawingEnabled(true) to enter scribble mode (the screen will stop refreshing).
    3. Use setRawDrawingEnabled(false) to pause scribbling.
    4. Call closeRawDrawing() to fully stop the service, release resources, and unlock the screen for normal refreshing.
    touchHelper.setup(view)
               .setStrokeWidth(3.0f)
               .setUseRawInput(true)
               .setLimitRect(limit, exclude)
               .openRawDrawing();
    
    // To start scribbling
    touchHelper.setRawDrawingEnabled(true);
    
    // To pause scribbling
    touchHelper.setRawDrawingEnabled(false);
    
    // To fully stop and release resources
    touchHelper.closeRawDrawing();