Repository navigation
EN Resources
Description of all files in src/main/resources/: what is there, why it is needed, and how to add something new. These resources are packaged into the plugin jar and are available at runtime through ClassLoader.getResourceAsStream(...) (flat paths from the jar root).
src/main/resources/
├── sql/setup/ → plugin DB migrations
│ └── create.sql
├── strings/ → localization
│ ├── strings.properties (EN)
│ └── strings_ru.properties (RU)
└── svg/ → indicator SVG graphics
└── speedometer/
├── background.svg
├── delimiter.svg
├── arrow.svg
└── numeric_40.svg, numeric_80.svg, numeric_160.svg, numeric_320.svg
The plugin owns its own SQLite DB (see getDbVersion() = 1 in Plagin). On the first plugin installation into a project, the SDK executes create.sql; on later version bumps, it executes upgrade-N.sql (from the current version to the new one).
Current schema (v1) - PluginDatabase API smoke test:
-
import_log- the only table. Fields:source_id(PK),source_path,processed_at. Filled inPlagin.onSourceImported: it writes "source X processed at moment Y" when each source is imported. There is no business logic on this data; the goal is to demonstrate how to create a plugin-owned DB and work with it.
The SQL uses the ${table:import_log} placeholder: runtime substitutes the table name with the plugin prefix (plugin_com_velitask_plugin_example_import_log) to avoid collisions with other plugins.
How to add a migration: when changing the schema, bump getDbVersion() (for example 1 -> 2), create sql/setup/upgrade-2.sql with SQL ALTER TABLE / CREATE TABLE. The SDK will run the upgrade automatically on projects with the old version.
How to remove the DB entirely: if a forked plugin does not need its own DB, return getDbVersion() = 0 in Plagin, delete sql/setup/, delete onSourceImported (or leave it empty). Then the SDK will not create a DB file.
Two files, standard Java .properties format:
-
strings.properties- English localization (default). -
strings_ru.properties- Russian localization.
Keys are built using the schema PluginExample.Indicator.<name>.<property>; for example, PluginExample.Indicator.speedometer.title, PluginExample.Indicator.speedometer.tags. The PluginExample prefix is defined as Plagin.KEY; the Plagin.KEY_INDICATOR constant adds .Indicator.
The plugin loads both locales (see defineAdditionLocales(), which returns ["ru"] in addition to the UI locale). This guarantees that Russian strings are available even when the UI is running with the English locale.
The bundle is registered through the manifest: build.gradle specifies the Velitask-Plugin-Localization: strings/strings attribute. The SDK automatically loads both bundle files when initializing the plugin.
Encoding is direct UTF-8. Cyrillic is written as regular text, without \uXXXX escaping (see DOCS_GUIDE.md and the general project rule).
Consistency check: during the build, the Gradle task checkLocalization (see build.gradle) compares keys used in code through localized(...) with both files. Any missing key is a release blocker (see RELEASING.md, Step 1).
The speedometer graphics in this template are implemented with SVG for scalability. SVG is loaded through SvgProperty with .bind(selector, attr, ColorProperty): runtime substitutes the user's current colors into SVG element attributes.
Files (used by SpeedometerIndicator):
-
background.svg- round speedometer background (bind.ring->mBgColor). -
delimiter.svg- scale ticks (bind.tick-majorand.tick-minor->mScaleColor). -
numeric_40.svg,numeric_80.svg,numeric_160.svg,numeric_320.svg- four variants of scale numbers (bind.number->mScaleColor); the indicator chooses one of the four bymSpeedScale. -
arrow.svg- arrow with outline and central hub (binds.arrow-body->mArrowFillColor(fill),mArrowStrokeColor(stroke),mArrowStrokeWidth(stroke-width);.arrow-hub->mArrowStrokeColor).
CSS class naming convention: selectors .ring, .tick-major, .tick-minor, .number, .arrow-body, .arrow-hub are stable; the binds in the indicator depend on them. When editing SVG, do not rename the classes, otherwise .bind(...) will stop finding the elements.
How to add a new SVG:
- Put the file into
svg/(or a subfolder, if there are several resources). - Declare
SvgPropertyin the indicator with this path:new SvgProperty("name", "svg/file.svg"). - Add
.bind(...)for each configurable color; the selector in the SVG must be styled through<style>or be the element'sfill/strokeattribute.
How to replace graphics in the template: when forking, you will most likely want to rewrite arrow.svg for your own style or draw new numeric_*.svg files for other speed ranges. Preserve the CSS selector structure; otherwise the bindings in SpeedometerIndicator will stop working.
- Java ClassLoader.getResourceAsStream - the main way to access these resources at runtime.
- The reference implementation for working with SVG resources is SpeedometerIndicator.