Skip to the content.

Kaidi

The Kodi remote controller for KaiOS (hence Kai-di)

Goals and project background

I have created this project in 2018 in a mission to create the first Kodi remote controller app for KaiOS. But why? Well, there are a few insprirations:

And with all of that in mind, I set out to create the app, with these goals:

The app was written in two stages, one Alpha and the other Beta. The ‘Beta’ version is a complete rewrite of the original Alpha code with largely the same functionality.

The Alpha version work dated back to 2018, as I had time right after my exams for Year 10. The original code lacked a lot of functionality, was an absolute pain to maintain as I have not applied any true coding styles to it, as I never expected any serious use from it. But as time went by, I got opinions and suggestions from users of the app, and I decided I would attempt a rewrite sometime in the future.

Fast forward to the closing months of 2019, I once again had time to start a rewrite of the app. This time, I tried using SASS and Gulp in order to make the rewrite of the old kaidi.css (the Alpha had all of the app styles in one huge file) easier. Sadly, that particular rewrite did not last long as I quickly had to come back to school and face the harsh reality of having literally NO FREE TIME AT ALL. This was known informally as ‘Kaidi2’.

Later on, while the COVID-19 ravaged around the globe, I suddenly found myself having plenty of free time. And so I began the official second rewrite titled ‘Beta’. The whole rewrite made the app much more modular, the code extremely readable, and the UI infinitely consistent. Moreover, a Gulp build process was created to create app builds that are minified, making for smaller package sizes. In the ‘Implementation’ section below, this version of the app (‘Beta’) would be detailed.

‘Beta’ as of the time of writing is still the latest release of the app. I plan to introduce further features given available time and more test devices.

Implementation

App source code structure

The app source code resides in the src folder within the kaidi GitHub repository (https://github.com/jkelol111/kaidi).

The app is structured like almost every vanilla HTML/CSS/JS KaiOS app would, with a manifest.webapp located in the root of the source code folder that contains the details of the app, relevant permissions and more pertaining to the app.

The HTML files which are the ‘pages’ of the app are also stored at the root of the source code. These define how the app looks in their individual pages and loads the relevant JS and CSS files for operation.

Speaking of CSS, JS and various other files, they are stored in their respective folders css, js, locales and icons, all located alongside the manifest.webapp and HTML files.

Page layout

Behind every ‘page’ in the app, a ‘headerbar’ of sorts is always present, in the app’s theme color. This is for visual recognition that the user is indeed using the Kaidi Remote app. A shade of cyan was chosen as it is relatively light/dark theme agnostic.

Below the headerbar, a secondary headerbar can be added in some pages to display additional contextual information, such as the name of the page. An example of this would be the settings page, where a secondary headerbar is used to tell the user they’re in the right page. These are only used sparingly in the app as KaiOS devices have limited display real estate.

Once the headerbars have been defined, there is a content section. This can be used for the display of any page content.

At the bottom of the page, a softkey bar is displayed for defining which button on the keypad corresponds to which action.

Code behind each page

Besides the settings page, most pages of the app run on JS that contains a class that extends the KodiRPC or KodiMethods class, the former of which handles various communication with the Kodi JSON-RPC APIs, including listening for specific Kodi events and handling the worker’s lifecycle, as well as a providing convenient functions for sending XmlHttpRequests to Kodi and formating them properly, and the latter extends KodiRPC with shared or commonly used functionality, such as displaying the Volume Control HUD in the app. The extended class from KodiRPC or KodiMethods then is used adds the page’s specific functionality in, leveraging the functions and variables provided as part of inheriting the above 2 classes.

All JS embedded in the app are either minified libraries that are untouched from the original publisher, the rest are written following the Standard JS style, which maintains cleanliness of code and consistency.

The stylesheets are separated into individual files, one of which named window.css is imported by all of the pages in app as it provides the elements which all pages will use. For other page specific elements, the HTML can declare addtional CSS files to be loaded, hence reducing memory usage for things that aren’t needed, a flaw of the ‘Alpha’ approach with all of the app’s styles in one stylesheet.

Localization in particular is provided by using the l10n.js library from Mozilla, which while designed for Firefox OS, still works fine on KaiOS. Files stored in locales of the source define key-value pairs for the library to load depending on the selected language. At the time of writing, there is only English and Vietnamese as supported languages.

App building and usage

The app can be downloaded via the KaiStore (pending approval), our community BananaHackers store, or directly from GitHub releases.

If you’re feeling adventurous or want to try all the latest stuff, you could clone the master branch from the repository and use gulp to build the project. More details are in the project’s actual README.md.

Releases that are pushed to KaiStore or BananaHackers/GitHub can be considered ‘stable’.

Project license

This project used to be licensed under the MIT license; however, as of the ‘Beta’ version, the license has been switched to GPLv3.