{"id":13498325,"url":"https://github.com/pranavpandey/dynamic-theme","last_synced_at":"2025-04-22T10:23:03.464Z","repository":{"id":44370180,"uuid":"214565778","full_name":"pranavpandey/dynamic-theme","owner":"pranavpandey","description":"A text (JSON) based theme engine for Android apps.","archived":false,"fork":false,"pushed_at":"2025-03-05T19:21:56.000Z","size":2233,"stargazers_count":33,"open_issues_count":0,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-12T21:23:13.385Z","etag":null,"topics":["android","engine","library","text","theme"],"latest_commit_sha":null,"homepage":"https://theme.pranavpandey.com","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pranavpandey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":"pranavpandey","patreon":"pranavpandey","open_collective":"pranavpandeydev","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["paypal.me/pranavpandeydev"]}},"created_at":"2019-10-12T02:47:42.000Z","updated_at":"2025-03-05T19:22:00.000Z","dependencies_parsed_at":"2023-12-10T15:10:54.566Z","dependency_job_id":null,"html_url":"https://github.com/pranavpandey/dynamic-theme","commit_stats":{"total_commits":142,"total_committers":1,"mean_commits":142.0,"dds":0.0,"last_synced_commit":"8ba877aeebf420579c7cc3f6f840746d7fd6ea23"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranavpandey%2Fdynamic-theme","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranavpandey%2Fdynamic-theme/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranavpandey%2Fdynamic-theme/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranavpandey%2Fdynamic-theme/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pranavpandey","download_url":"https://codeload.github.com/pranavpandey/dynamic-theme/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249195515,"owners_count":21228221,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","engine","library","text","theme"],"created_at":"2024-07-31T21:00:22.167Z","updated_at":"2025-04-16T16:31:35.492Z","avatar_url":"https://github.com/pranavpandey.png","language":"Java","funding_links":["https://github.com/sponsors/pranavpandey","https://patreon.com/pranavpandey","https://opencollective.com/pranavpandeydev","paypal.me/pranavpandeydev","https://paypal.me/pranavpandeydev"],"categories":["Uncategorized","Java"],"sub_categories":["Uncategorized"],"readme":"\u003cimg src=\"./graphics/icon.png\" height=\"160\"\u003e\n\n# Dynamic Theme\n\n[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg?)](https://www.apache.org/licenses/LICENSE-2.0.html)\n[![Build Status](https://travis-ci.org/pranavpandey/dynamic-theme.svg?branch=master)](https://travis-ci.org/pranavpandey/dynamic-theme)\n[![Release](https://img.shields.io/maven-central/v/com.pranavpandey.android/dynamic-theme)](https://search.maven.org/artifact/com.pranavpandey.android/dynamic-theme)\n\n**A text (JSON) based theme engine for Android 4.0 (API 14) and above.**\n\n\u003e [!IMPORTANT]\n\u003e It uses [AndroidX][androidx] so, first [migrate][androidx-migrate] your project to AndroidX.\n\u003cbr/\u003eSince v3.1.0, it is dependent on Java 8 due to the dependency on\n[Dynamic Utils][dynamic-utils].\n\u003cbr/\u003eSince v4.5.1, it is targeting Java 17 to provide maximum compatibility.\n\u003cbr/\u003eSince v4.6.0, the minimum SDK is Android 4.4 (API 19) to comply with the latest policies.\n\n\u003cimg src=\"./graphics/code.png\" width=\"400\"\u003e\u0026nbsp;\u0026nbsp;\u003cimg src=\"./graphics/preview.png\" width=\"400\"\u003e\n\n```\n{\n  \"backgroundColor\": \"#455A64\",\n  \"tintBackgroundColor\": \"auto\",\n  \"surfaceColor\": \"auto\",\n  \"tintSurfaceColor\": \"auto\",\n  \"primaryColor\": \"#FF455A64\",\n  \"tintPrimaryColor\": \"auto\",\n  \"primaryColorDark\": \"auto\",\n  \"tintPrimaryColorDark\": \"auto\",\n  \"accentColor\": \"#FFE6EE9C\",\n  \"tintAccentColor\": \"auto\",\n  \"accentColorDark\": \"auto\",\n  \"tintAccentColorDark\": \"auto\",\n  \"errorColor\": \"auto\",\n  \"tintErrorColor\": \"auto\",\n  \"textPrimaryColor\": \"auto\",\n  \"textPrimaryColorInverse\": \"auto\",\n  \"textSecondaryColor\": \"auto\",\n  \"textSecondaryColorInverse\": \"auto\",\n  \"fontScale\": \"auto\",\n  \"cornerRadius\": \"auto\",\n  \"backgroundAware\": \"auto\",\n  \"contrast\": \"auto\",\n  \"opacity\": \"auto\",\n  \"elevation\": \"auto\",\n  \"style\": \"auto\"\n}\n```\n\n---\n\n## Contents\n\n- [Format](#format)\n- [Installation](#installation)\n- [Usage](#usage)\n    - [Dependency](#dependency)\n    - [Proguard](#proguard)\n- [Palettes](#palettes)\n- [License](#license)\n\n---\n\n## Format\n\nA dynamic theme can be represented as a `JSON`, `URL` or a `File` with `.theme` extension \ncontaining the JSON text. Use the Palettes app for Android to create or share dynamic themes \nin various formats. However, the most suitable way is to share it via a URL that can be imported \neasily on various platforms.\n\n### JSON\n\nA `JSON` is the original format for the dynamic theme that provides cross-app functionality.\n\n```json\n{\n  \"backgroundColor\": \"auto|color\",\n  \"tintBackgroundColor\": \"auto|color\",\n  \"surfaceColor\": \"auto|color\",\n  \"tintSurfaceColor\": \"auto|color\",\n  \"primaryColor\": \"auto|color\",\n  \"tintPrimaryColor\": \"auto|color\",\n  \"primaryColorDark\": \"auto|color\",\n  \"tintPrimaryColorDark\": \"auto|color\",\n  \"accentColor\": \"auto|color\",\n  \"tintAccentColor\": \"auto|color\",\n  \"accentColorDark\": \"auto|color\",\n  \"tintAccentColorDark\": \"auto|color\",\n  \"errorColor\": \"auto|color\",\n  \"tintErrorColor\": \"auto|color\",\n  \"textPrimaryColor\": \"auto|color\",\n  \"textPrimaryColorInverse\": \"auto|color\",\n  \"textSecondaryColor\": \"auto|color\",\n  \"textSecondaryColorInverse\": \"auto|color\",\n  \"fontScale\": \"auto|integer\",\n  \"cornerRadius\": \"auto|system|integer\",\n  \"backgroundAware\": \"auto|disable|enable\",\n  \"contrast\": \"auto|integer\",\n  \"opacity\": \"auto|integer\",\n  \"elevation\": \"auto|disable|enable\",\n  \"style\": \"auto|custom\",\n  \"header\": \"auto|hide|show\"\n}\n```\n\n### URL\n\nA `URL` is the short representation of the theme `JSON` that can be shared on the platforms \nhaving a character limit like Twitter. This is the most suitable way to share a dynamic theme that \ncan be imported easily in various apps or platforms.\n\n#### Mappings\n\n| JSON                 | URL | JSON                      | URL |\n|:---------------------|-----|:--------------------------|-----|\n| {,}                  |     | \"\"                        |     |\n| Split (Key)          | -   | Dark \\| Inverse           | Z   |\n| backgroundColor      | 0   | tintBackgroundColor       | 1   |\n| surfaceColor         | 2   | tintSurfaceColor          | 3   |\n| primaryColor         | 4   | tintPrimaryColor          | 5   |\n| primaryColorDark     | 4Z  | tintPrimaryColorDark      | 7   |\n| accentColor          | 8   | tintAccentColor           | 9   |\n| accentColorDark      | 8Z  | tintAccentColorDark       | 11  |\n| errorColor           | 21  | tintErrorColor            | 22  |\n| textPrimaryColor     | 12  | textPrimaryColorInverse   | 12Z |\n| textSecondaryColor   | 14  | textSecondaryColorInverse | 14Z |\n| fontScale            | 16  | cornerRadius              | 17  |\n| backgroundAware      | 18  | contrast                  | 25  |\n| opacity              | 20  | elevation                 | 26  |\n| style                | 23  | header                    | 19  |\n\n#### Values\n\n| JSON          | URL | JSON   | URL |\n| :-------------| --- | :----- |-----|\n| Split (Value) | v   | #      | X   |\n| auto          | A   | system | M   |\n| disable       | D   | enable | E   |\n| hide          | H   | show   | S   |\n\n### Code\n\nA `QR code` representation of the theme `URL` to easily share themes across various platforms \nand devices.\n\n### File\n\nA `File` with `.theme` extension containing the JSON text. Currently, it is possible to export \nor import a dynamic theme file on the Android (Java) platform.\n\n---\n\n## Installation\n\nIt can be installed by adding the following dependency to your `build.gradle` file:\n\n```groovy\ndependencies {\n    // For AndroidX enabled projects.\n    implementation 'com.pranavpandey.android:dynamic-theme:4.6.0'\n}\n```\n\n---\n\n## Usage\n\nIt can be used in raw JSON format or can be implemented on the Android (Java) platform.\n\n\u003e For a complete reference, please read the [documentation][documentation].\n\n### Android (Java)\n\nJust implement the [AppTheme][app theme] or [AppWidgetTheme][app widget theme] to create a \ndynamic theme. A possible implementation can be found [here][theme implementation].\n\n```java\npublic class DynamicAppTheme implements AppTheme\u003cDynamicAppTheme\u003e {\n    \n    ...\n    \n    @Override\n    public @StyleRes int getThemeRes() {\n        return themeRes;\n    }\n\n    @Override\n    public @NonNull DynamicAppTheme setThemeRes(@StyleRes int themeRes) {\n        this.themeRes = themeRes;\n\n        return this;\n    }\n\n    ...\n\n    @Override\n    public @NonNull String toJsonString() {\n        return new Gson().toJson(new DynamicAppTheme(this));\n    }\n\n    @Override\n    public @NonNull String toDynamicString() {\n        return new GsonBuilder().setExclusionStrategies(new ExcludeStrategy())\n                .registerTypeAdapter(DynamicAppTheme.class, new DynamicThemeTypeAdapter\u003c\u003e())\n                .setPrettyPrinting().create().toJson(new DynamicAppTheme(this));\n    }\n}\n```\n\n### Dependency\n\nIt depends on the [dynamic-utils][dynamic-utils] to perform\nvarious internal operations. So, its functions can also be used to perform other useful operations.\n\n### Proguard\n\nThis library uses [Gson][gson] and has custom strategy to process the theme data. \nIt will automatically apply the appropriate rules if proguard is enabled in the project.\n\nThe following rules will be applied by this library:\n\n```yml\n# Gson uses generic type information stored in a class file when working with fields.\n# Proguard removes such information by default, so configure it to keep all of it.\n-keepattributes Signature\n\n# For using Gson annotation.\n-keepattributes *Annotation*\n\n# Gson specific classes.\n-keep class sun.misc.Unsafe { *; }\n-keep class com.google.gson.** { *; }\n```\n\n---\n\n\u003cimg src=\"./graphics/apps/pranavpandey-palettes.png\" height=\"140\"\u003e\n\n## Palettes\n\n[Palettes][palettes] is a universal manager for apps supporting the dynamic theme on Android. \nIt provides some default configurations that can be extended to create custom ones. \nLet's give it a try to explore its other useful features.\n\n- A collection of theme presets that can be applied in the supported apps.\n- Extend them to create custom ones according to the requirement.\n- Preview them natively in the supported apps and widgets.\n- Experimental option to enable dark mode in devices that don't have a system setting.\n\n---\n\n## Author\n\nPranav Pandey\n\n[![GitHub](https://img.shields.io/github/followers/pranavpandey?label=GitHub\u0026style=social)](https://github.com/pranavpandey)\n[![Follow on Twitter](https://img.shields.io/twitter/follow/pranavpandeydev?label=Follow\u0026style=social)](https://twitter.com/intent/follow?screen_name=pranavpandeydev)\n[![Donate via PayPal](https://img.shields.io/static/v1?label=Donate\u0026message=PayPal\u0026color=blue)](https://paypal.me/pranavpandeydev)\n\n---\n\n## License\n\n    Copyright 2019-2024 Pranav Pandey\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n\n[androidx]: https://developer.android.com/jetpack/androidx\n[androidx core]: https://developer.android.com/jetpack/androidx/releases/core\n[androidx-migrate]: https://developer.android.com/jetpack/androidx/migrate\n[documentation]: https://pranavpandey.github.io/dynamic-theme \n[app theme]: ./dynamic-theme/src/main/java/com/pranavpandey/android/dynamic/theme/AppTheme.java\n[app widget theme]: ./dynamic-theme/src/main/java/com/pranavpandey/android/dynamic/theme/AppWidgetTheme.java\n[theme implementation]: https://github.com/pranavpandey/dynamic-support/blob/master/dynamic-support/src/main/java/com/pranavpandey/android/dynamic/support/model/DynamicAppTheme.java\n[dynamic-utils]: https://github.com/pranavpandey/dynamic-utils\n[gson]: https://github.com/google/gson \n[palettes]: https://play.google.com/store/apps/details?id=com.pranavpandey.theme \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpranavpandey%2Fdynamic-theme","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpranavpandey%2Fdynamic-theme","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpranavpandey%2Fdynamic-theme/lists"}