common
This package contains common classes and interfaces that are used by all the extensions of Echo.
Getting Started
Template
To create a new extension, you can use the following template repo:
https://github.com/brahmkshatriya/echo-extension-template
Manual
Add the dependency in your project. build.gradle.kts
implementation("dev.brahmkshatriya.echo:common:1.0.0")Content copied to clipboard
How does it work?
Currently, the common package is JVM only. The app recognizes an App or an apk file as an extension by its AndroidManifest.xml file. To determine what type of extension it is, the app looks for the following feature in the manifest file:
For Music Extension:
<uses-feature android:name="dev.brahmkshatriya.echo.music"/>Content copied to clipboardFor Lyrics Extension:
<uses-feature android:name="dev.brahmkshatriya.echo.lyrics"/>Content copied to clipboardFor Tracker Extension:
<uses-feature android:name="dev.brahmkshatriya.echo.trackers"/>Content copied to clipboardFor Misc Extension:
<uses-feature android:name="dev.brahmkshatriya.echo.misc"/>Content copied to clipboard
There are 2 ways the app can import an extension:
File: The app stores the apk file in the internal storage and loads the class from the dex file.
Installed Package: The app loads the class from the installed apps on the device.
Installed packages have priority over file based, if both extensions have same the id.
The AndroidManifest.xml file of the extension should contain the following metadata:
class: The class path of the
ExtensionClient.
<meta-data
android:name="class"
android:value="com.example.MyExtension" />id: The unique id of the extension.(Avoid using special characters or spaces)
<meta-data
android:name="id"
android:value="my_example" />and others...
Flow of the app:
Load the extensions from the installed packages and internal storage.
Dynamically load the ./src/commonMain/kotlin/dev/brahmkshatriya/echo/common/clients/ExtensionClient.kt instance using the class path from the metadata.
Inject the extension with ./src/commonMain/kotlin/dev/brahmkshatriya/echo/common/settings/Setting.kt
Inject the extension with other ./src/commonMain/kotlin/dev/brahmkshatriya/echo/common/providers
The extension is available to use in the app.