Skip to content

Instantly share code, notes, and snippets.

@calliecameron
Last active June 26, 2024 12:54
Show Gist options
  • Save calliecameron/b3c62c601d255630468bd493380e3b7e to your computer and use it in GitHub Desktop.
Save calliecameron/b3c62c601d255630468bd493380e3b7e to your computer and use it in GitHub Desktop.
Onyx Boox handwriting optimisation in any app

Onyx Boox handwriting optimisation in any app

All credit to this thread for figuring out how to do this, I'm just documenting it more thoroughly.

Tested on Nova Air C with firmware 3.5 (2023-11-20).

Handwriting optimisation makes the pen usable in apps installed from the play store. By default it's only available for OneNote, Evernote and WPS -- they have a 'handwriting' tab in the optimisation settings, other apps don't -- but can be enabled for any app by editing the file /onyxconfig/eac_config as root.

Note: whenever you edit eac_config, you have to reboot the device for the changes to take effect. Just restarting the app isn't enough.

Enable handwriting optimisation

  1. Root the device. For the Nova Air C, the instructions are here. For other devices, you'll find instructions on MobileRead.

  2. Open the file /onyxconfig/eac_config (only visible as root), and find the entry for your app.

    • This is a json file with a structure like:

      {
          "appConfigMap": {
              "<app name>": ...
          }
      }
      

      where <app name> is the package name of the app. Take a look at the entries for OneNote (com.microsoft.office.onenote) or Evernote (com.evernote) for examples with handwriting optimisation.

    • If there is no entry for your app, open the app and change one of the optimisation settings -- doesn't matter which one, and you can change it back later, this is just to force creation of an entry in eac_config.

    • All optimisation settings are stored in eac_config, not just handwriting settings.

  3. To enable handwriting optimisation, look for the following settings under your app:

    "noteConfig": {
        ...
        "enable": false,
        "globalStrokeStyle": {
            "enable": false,
            ...
        },
        ...
        "supportNoteConfig": false
        ...
    }
    

    and change them as follows:

    "noteConfig": {
        ...
        "drawViewKey": "<your app's view name>",
        "enable": true,
        "globalStrokeStyle": {
            "enable": true,
            ...
        },
        ...
        "supportNoteConfig": true
        ...
    }
    

    where <your app's view name> is different for different apps. Figuring out what this should be is the hard part, see below.

  4. Reboot the device. Now, when you open the app, the 'handwriting' tab should appear in the optimisation settings.

Finding the view key

Maybe there's a better way to do this, but the way I do it is:

  1. Download the app's apk from the device, as described here.

  2. Open the apk in Android Studio using 'File -> Profile or Debug APK'

  3. Look through the xml files in 'res/layout' until I find a class name that looks drawing-related.

  4. Try that class as the drawViewKey in eac_config, reboot the device, and if that doesn't work, keep trying other classes.

This is very trial-and-error, though.

Customising handwriting optimisation

Once optimisation is enabled, some settings can be changed in the 'handwriting' tab in the optimisation settings. Others can only be changed by editing eac_config.

  • repaintLatency: how quickly the preview line changes to a real line when you stop drawing. 'Refresh time after lifting stylus' in the 'handwriting' tab.
  • globalStrokeStyle
    • strokeWidth: 'Stroke width' in the 'handwriting' tab.

    • strokeStyle: values of 0, 1 and 2 used in the default config? Not sure what the difference is.

      • OneNote uses 1 for pens and 2 for highlighters.
    • strokeColor: two's complement of the ARGB colour, where A is always 255. To generate in python:

      int.from_bytes(((255<<24) + (r<<16) + (g<<8) + b).to_bytes(4, byteorder=sys.byteorder, signed=False), byteorder=sys.byteorder, signed=True)
    • strokeParams and strokeExtraArgs: don't know. OneNote and Evernote don't set these.

  • styleMap: somehow allows different pen styles in the app to appear differently when drawing the preview line. OneNote sets these, and the different pens there draw the preview line in different colours. But I don't know how to find the names to use as the keys, e.g. pen_1 in OneNote.
    • type: 0 appears to be the style -- different for pen and highlighter.
    • type: 2 appears to be the colour.

Known view keys

  • Ibis Paint: jp.ne.ibis.ibispaintx.app.glwtk.IbisPaintView
  • MediBang Paint: com.medibang.android.paint.tablet.ui.widget.CanvasView
  • Squid: com.steadfastinnovation.android.projectpapyrus.ui.widget.PageViewContainer
  • Xodo: com.pdftron.pdf.PDFViewCtrl

If you find the view keys for any other apps, please let me know.

@junrenshi
Copy link

Thanks for very useful information. I would like to add two keys:

  • Xodo
    "drawViewKey":"com.pdftron.pdf.PDFViewCtrl"
  • Squid "drawViewKey":"com.steadfastinnovation.android.projectpapyrus.ui.widget.PageViewContainer"

@calliecameron
Copy link
Author

Thanks, I updated it.

@batman887
Copy link

You are a godsend. Thank you for providing this. I can't believe I found this randomly linked in a Krita forum. Thanks for putting this out there.

I would like to add one key, and hope someone else gets some use out of it:

  • Ibis Paint
  • "drawViewKey":"jp.ne.ibis.ibispaintx.app.glwtk.IbisPaintView"

@calliecameron
Copy link
Author

Glad it's useful! Updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment