22 Android tips and tricks
hugleo edited this page 3 months ago

Customize keys

KOReader supports keymappings. While most phones and tablets use common keycodes defined by AOSP, some "closed-android" e-ink vendors use their own scheme.

NOTE: it is impossible for a non-launcher app to override the behaviour of the home key. The rest of physical/virtual keys can be mapped.

example: add support for the custom keys used on the Nook Glowlight 3 (top keys as page back and bottom keys as page forward)

return {
   [139] = "LPgBack", -- Nook Left Page Back (left lower button)
   [140] = "LPgFwd",  -- Nook Left Page Forward (left upper button)
   [141] = "LPgFwd",  -- Nook Right Page Forward (right upper button)
   [142] = "LPgBack", -- Nook Right Page Back (right lower button)
}

To know which keycodes are being emmited by your device please follow this link

Customize dictionary list

Since v2019.11.69 you can customize your third party dictionary list by creating koreader/dictionaries.lua

Check the default list and create your own based on your preferences.

You can also configure an action without a specific package. In that case the application picker will be shown with all the available options.

example 1: a simple list with 2 dicts, the first one will show the app picker with all the apps that can manage the "send" action. The second one will open the query in Colordict if the app is installed.

return {
    { "Generic", "App picker", true, nil, "send" },
    { "ColorDict", "ColorDict", false, "com.socialnmobile.colordict", "colordict" },
}

example 2: like example 1 but without checking if Colordict is available each time the app runs

return {
    { "Generic", "App picker", true, nil, "send" },
    { "ColorDict", "ColorDict", true, "com.socialnmobile.colordict", "colordict" },
}

example 3: open the app picker for each kind of generic intent

return {
    { "Send", "App picker (send)", true, nil, "send" },
    { "Search", "App picker (search)", true, nil, "search" },
    { "TextProcessing", "App picker (text processing)", true, nil, "text" },
}

ADB Stuff

Android Debug Bridge (ADB) stands as a multifaceted command-line utility, facilitating seamless communication with your Android device.

USB Driver Setup

To enable the USB driver on your device, follow these general steps:

  1. Connect your Android device to your computer using a USB cable.
  2. Access the device's settings and navigate to the "Developer Options" section. If "Developer Options" are not visible, go to "About Phone" and tap on the "Build Number" multiple times until you unlock developer access.
  3. Within "Developer Options," locate and enable the "USB Debugging" feature.
  4. A prompt may appear on your device asking for permission to enable USB debugging. Allow this access.
  5. Once USB debugging is enabled, your Android device is ready to communicate with ADB.

Note: The exact steps may vary slightly depending on your device model and Android version.

Onyx Devices

Light drivers, permissions

For Onyx devices running Android version 11 and above, enabling the Lights driver requires specific steps due to restrictions on non-SDK interfaces:

  1. Check if the variable is set:

    adb shell settings get global hidden_api_policy
    
  2. Set the permission to use non-SDK hidden API:

    adb shell settings put global hidden_api_policy 1
    
  3. Execute only if the test fails or if you want to remove the permission:

    adb shell settings delete global hidden_api_policy
    

Note: After applying the permission changes in step 2, it is important to close and reopen KOReader for the changes to take effect.

Other settings

Enable USB debugging: Apps > top right hamburger icon > App Management > USB Debug Mode: enable

Enable orientation change within KOReader: Apps > top right hamburger icon > App Management > Force to follow system orientation > KOReader: disable