{"id":37029674,"url":"https://github.com/halfhp/fig","last_synced_at":"2026-01-14T03:34:29.128Z","repository":{"id":46977810,"uuid":"69124541","full_name":"halfhp/fig","owner":"halfhp","description":"Configure any object from XML","archived":false,"fork":false,"pushed_at":"2021-09-19T14:03:28.000Z","size":207,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-08-07T21:45:29.506Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/halfhp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-24T19:59:37.000Z","updated_at":"2022-04-10T06:21:14.000Z","dependencies_parsed_at":"2022-07-25T04:16:52.120Z","dependency_job_id":null,"html_url":"https://github.com/halfhp/fig","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/halfhp/fig","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halfhp%2Ffig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halfhp%2Ffig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halfhp%2Ffig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halfhp%2Ffig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/halfhp","download_url":"https://codeload.github.com/halfhp/fig/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halfhp%2Ffig/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408843,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2026-01-14T03:34:28.505Z","updated_at":"2026-01-14T03:34:29.114Z","avatar_url":"https://github.com/halfhp.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fig\nA utility for Android apps to easily configure any object from XML.\n\n![image](docs/images/fig.png)\n \n## Why Use It?\n\n* Configure anything; instances of Paint, View, your own classes, third party libs, etc.\n* Supports `sp`, `dp`, `pix`, `pt`, `in`, `mm` and `color` params.\n* Keep UI code where it belongs: store configurations by screen size and density using standard \nAndroid resource directory conventions.\n* Easy to use.\n\n# Usage\nFig relies on JavaBean naming conventions to map XML parameters to objects:\n\n```java\n// given:\nButton button = new Button();\n```\n\nthen:\n```java\nbutton.getPaint().setColor(Color.RED);\n```\n\nbecomes:\n\n```xml\nbutton.paint.color=\"@color/red\"\n```\n\n### Gradle Dependency\n\n```groovy\ndependencies {\n    compile \"com.halfhp.fig:figlib:1.0.11\"\n}\n```\n\n###  A Simple Example\nGiven a class:\n\n```java\n// A thingy that has a name and a fill color.\npublic class ColorfulThingy {    \n    private String name;\n    private Paint fillPaint;\n    \n    // JavaBean style setters/getters:\n    public String getName() { return name; }    \n    public void setName(String name) { this.name = name; }\n    public Paint getFillPaint() { return fillPaint; }\n    public void setFillPaint(Paint fillPaint) { this.fillPaint = fillPaint; }\n}\n```\n\nWe can configure any instances:\n\n```java\nColorfulBoxyThingy thingy = new ColorfulBoxyThingy();\nFig.configure(context, thingy, R.xml.thingy_config.xml);\n```\n\nFrom thingyConfig.xml, for any property that has a standard Java Bean setter:\n\n**thingy_config.xml:**\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cconfig name=\"My Thingy\"/\u003e\n```\n\nWe can also configure properties of nested objects as long as the chain of nested objects\nis accessible via Standard Java Bean getter and the target property also has a standard Java Bean setter:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cconfig name=\"My Thingy\"\n        fillPaint.color=\"#FF0000\"/\u003e\n```\n\n### Standard JavaBean Setters/Getters\nIf you use IntelliJ or Android Studio to auto generate your setters and getters, you can safely skip \nthis section.  If you're using another IDE or are just curious, read on.\n\nWhen using Fig, there are two conventions to follow:\n\n* Setters begin with lower-case \"set\" followed by the name of the property being set, eg. `setFoo(...)`.\n* Getters begin with lower-case \"get\" followed by the name of the property being retrieved, `eg. getFoo()`.\n\nThe JavaBean spec has more to say on casing conventions etc, but Fig's matching is case insensitive so\nfeel free to use whatever casing convention you prefer.\n\n# Fig \u0026 Obfuscation\nFig uses runtime reflection to configure object instances and relies on  class method names remaining \nconsistent at runtime. Obfuscation must be disabled for any classes you wish to configure.\nThis is typically a matter of adding a rule to your proguard config to preserve these class' members:\n\n```\n# preserve a single class:\n-keepclassmembers class com.somedomain.somepackage.Foo { *; }\n\n# preserve an entire package:\n-keepclassmembers com.somedomain.somepackage.** { *; }\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalfhp%2Ffig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhalfhp%2Ffig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalfhp%2Ffig/lists"}