@buaa_smat/hometrans 0.1.17 → 0.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) hide show
  1. package/README.md +138 -56
  2. package/agents/code-reviewer.md +321 -65
  3. package/agents/logic-coder.md +113 -88
  4. package/agents/logic-context-builder.md +47 -29
  5. package/agents/scripts/hmos-precheck/backends/arkts.mjs +567 -0
  6. package/agents/scripts/hmos-precheck/backends/arkts_diff.mjs +159 -0
  7. package/agents/scripts/hmos-precheck/backends/arkts_project_rules.mjs +398 -0
  8. package/agents/scripts/hmos-precheck/backends/codelinter.mjs +250 -0
  9. package/agents/scripts/hmos-precheck/backends/project_integrity.mjs +321 -0
  10. package/agents/scripts/hmos-precheck/backends/static_precheck.mjs +247 -0
  11. package/agents/scripts/hmos-precheck/core/config.mjs +184 -0
  12. package/agents/scripts/hmos-precheck/core/diagnostic_scope.mjs +20 -0
  13. package/agents/scripts/hmos-precheck/core/process_adapter.mjs +47 -0
  14. package/agents/scripts/hmos-precheck/core/project_catalog.mjs +50 -0
  15. package/agents/scripts/hmos-precheck/core/result_projection.mjs +147 -0
  16. package/agents/scripts/hmos-precheck/core/scope_plan.mjs +131 -0
  17. package/agents/scripts/hmos-precheck/core/sdk_context.mjs +67 -0
  18. package/agents/scripts/hmos-precheck/docs/architecture.md +37 -0
  19. package/agents/scripts/hmos-precheck/docs/performance-optimization.md +28 -0
  20. package/agents/scripts/hmos-precheck/docs/upstream-reference.json +19 -0
  21. package/agents/scripts/hmos-precheck/docs/validation.md +50 -0
  22. package/agents/scripts/hmos-precheck/index.mjs +17 -0
  23. package/agents/scripts/hmos-precheck/invocation.mjs +231 -0
  24. package/agents/scripts/hmos-precheck/rules/rule_case_matrix.csv +32 -0
  25. package/agents/scripts/hmos-precheck/rules/rule_inventory.csv +64 -0
  26. package/agents/scripts/hmos-precheck/rules/rule_inventory.mjs +59 -0
  27. package/agents/scripts/hmos-precheck/rules/rule_policy.mjs +54 -0
  28. package/agents/scripts/platform_query.mjs +626 -0
  29. package/agents/scripts/platform_query.test.mjs +422 -0
  30. package/agents/self-test-fixer.md +36 -34
  31. package/agents/self-tester.md +35 -376
  32. package/agents/test-case-generation-generator.md +317 -0
  33. package/agents/test-case-generation-validator.md +231 -0
  34. package/dist/cli/config-store.js +19 -146
  35. package/dist/cli/config.js +6 -8
  36. package/dist/cli/env-vars.js +1 -3
  37. package/dist/cli/index.js +0 -11
  38. package/dist/cli/init.js +147 -235
  39. package/dist/cli/uninstall.js +5 -129
  40. package/dist/utils/regex.js +8 -0
  41. package/env-requirements.json +57 -55
  42. package/package.json +6 -8
  43. package/resource/convert_pipeline_process.svg +103 -0
  44. package/resource/project_architecture.svg +122 -0
  45. package/resource/title_dark.png +0 -0
  46. package/skills/hmos-batch-ui-align/SKILL.md +345 -43
  47. package/skills/hmos-batch-ui-align/references/conversion-procedure.md +661 -180
  48. package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
  49. package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
  50. package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
  51. package/skills/hmos-batch-ui-align/references/mvvm/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +648 -648
  52. package/skills/hmos-batch-ui-align/references/mvvm/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md +2088 -2088
  53. package/skills/hmos-batch-ui-align/references/mvvm/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md +1033 -1033
  54. package/skills/hmos-batch-ui-align/references/mvvm/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +1183 -1183
  55. package/skills/hmos-batch-ui-align/references/mvvm/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +576 -576
  56. package/skills/hmos-batch-ui-align/references/mvvm/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +297 -297
  57. package/skills/hmos-batch-ui-align/references/mvvm/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +395 -395
  58. package/skills/hmos-batch-ui-align/references/mvvm/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +902 -902
  59. package/skills/hmos-batch-ui-align/references/mvvm/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md +106 -106
  60. package/skills/hmos-batch-ui-align/references/mvvm/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +1178 -1178
  61. package/skills/hmos-batch-ui-align/references/mvvm/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +911 -911
  62. package/skills/hmos-batch-ui-align/references/mvvm/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +354 -354
  63. package/skills/hmos-batch-ui-align/references/mvvm//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +11 -11
  64. package/skills/hmos-batch-ui-align/references/mvvm-v2/!!/350/257/255/346/263/225/357/274/232/345/217/214/345/220/221/347/273/221/345/256/232.md +206 -0
  65. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Computed/350/243/205/351/245/260/345/231/250/357/274/232/350/256/241/347/256/227/345/261/236/346/200/247.md +373 -0
  66. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Event/350/243/205/351/245/260/345/231/250/357/274/232/350/247/204/350/214/203/347/273/204/344/273/266/350/276/223/345/207/272.md +158 -0
  67. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Local/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/351/203/250/347/212/266/346/200/201.md +750 -0
  68. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Monitor/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/344/277/256/346/224/271/345/274/202/346/255/245/347/233/221/345/220/254.md +1704 -0
  69. package/skills/hmos-batch-ui-align/references/mvvm-v2/@ObservedV2/350/243/205/351/245/260/345/231/250/345/222/214@Trace/350/243/205/351/245/260/345/231/250/357/274/232/347/261/273/345/261/236/346/200/247/345/217/230/345/214/226/350/247/202/346/265/213.md +1012 -0
  70. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Once/350/243/205/351/245/260/345/231/250/357/274/232/345/210/235/345/247/213/345/214/226/345/220/214/346/255/245/344/270/200/346/254/241.md +164 -0
  71. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Param/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/244/226/351/203/250/350/276/223/345/205/245.md +840 -0
  72. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Provider/350/243/205/351/245/260/345/231/250/345/222/214@Consumer/350/243/205/351/245/260/345/231/250/357/274/232/350/267/250/347/273/204/344/273/266/345/261/202/347/272/247/345/217/214/345/220/221/345/220/214/346/255/245.md +856 -0
  73. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Type/350/243/205/351/245/260/345/231/250/357/274/232/346/240/207/350/256/260/347/261/273/345/261/236/346/200/247/347/232/204/347/261/273/345/236/213.md +83 -0
  74. package/skills/hmos-batch-ui-align/references/mvvm-v2/AppStorageV2/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200UI/347/212/266/346/200/201/345/255/230/345/202/250.md +294 -0
  75. package/skills/hmos-batch-ui-align/references/mvvm-v2/MVVM/346/250/241/345/274/217/357/274/210V2/357/274/211.md +1407 -0
  76. package/skills/hmos-batch-ui-align/references/mvvm-v2/PersistenceV2/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +1220 -0
  77. package/skills/hmos-batch-ui-align/references/mvvm-v2/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +47 -0
  78. package/skills/hmos-batch-ui-align/references/mvvm-v2/_/350/243/205/351/245/260/345/231/250/351/200/237/346/237/245.md +133 -0
  79. package/skills/hmos-batch-ui-align/references/mvvm-v2//347/212/266/346/200/201/347/256/241/347/220/206V1/345/220/221V2/350/277/201/347/247/273/344/270/216/346/267/267/347/224/250/346/214/207/345/257/274.md +840 -0
  80. package/skills/hmos-batch-ui-align/scripts/android_parse_fast.ts +1798 -0
  81. package/skills/hmos-batch-ui-align/scripts/arkts_static_check.ts +1592 -0
  82. package/skills/hmos-batch-ui-align/scripts/measure_pack.ts +752 -0
  83. package/skills/hmos-convert-pipeline/SKILL.md +188 -131
  84. package/skills/hmos-fix-build-errors/SKILL.md +87 -67
  85. package/skills/hmos-fix-build-errors/references/arkts-strict-patterns.md +219 -219
  86. package/skills/hmos-fix-build-errors/references/known-patterns.md +157 -157
  87. package/skills/hmos-fix-build-errors/references/rdb-entity-pattern.md +131 -131
  88. package/skills/hmos-incremental-ui-align/README.md +57 -40
  89. package/skills/hmos-incremental-ui-align/SKILL.md +180 -24
  90. package/skills/hmos-incremental-ui-align/diff_analysis.md +52 -52
  91. package/skills/hmos-incremental-ui-align/page_align.md +62 -62
  92. package/skills/hmos-incremental-ui-align/references/Comparison_Template.md +38 -2
  93. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +648 -648
  94. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md +2088 -2088
  95. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md +1033 -1033
  96. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +1183 -1183
  97. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +576 -576
  98. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +297 -297
  99. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +395 -395
  100. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +902 -902
  101. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md +106 -106
  102. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +1178 -1178
  103. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/MVVM/346/250/241/345/274/217V1.md +911 -911
  104. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +354 -354
  105. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +11 -11
  106. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/!!/350/257/255/346/263/225/357/274/232/345/217/214/345/220/221/347/273/221/345/256/232.md +206 -0
  107. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Computed/350/243/205/351/245/260/345/231/250/357/274/232/350/256/241/347/256/227/345/261/236/346/200/247.md +373 -0
  108. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Event/350/243/205/351/245/260/345/231/250/357/274/232/350/247/204/350/214/203/347/273/204/344/273/266/350/276/223/345/207/272.md +158 -0
  109. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Local/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/351/203/250/347/212/266/346/200/201.md +750 -0
  110. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Monitor/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/344/277/256/346/224/271/345/274/202/346/255/245/347/233/221/345/220/254.md +1704 -0
  111. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@ObservedV2/350/243/205/351/245/260/345/231/250/345/222/214@Trace/350/243/205/351/245/260/345/231/250/357/274/232/347/261/273/345/261/236/346/200/247/345/217/230/345/214/226/350/247/202/346/265/213.md +1012 -0
  112. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Once/350/243/205/351/245/260/345/231/250/357/274/232/345/210/235/345/247/213/345/214/226/345/220/214/346/255/245/344/270/200/346/254/241.md +164 -0
  113. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Param/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/244/226/351/203/250/350/276/223/345/205/245.md +840 -0
  114. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Provider/350/243/205/351/245/260/345/231/250/345/222/214@Consumer/350/243/205/351/245/260/345/231/250/357/274/232/350/267/250/347/273/204/344/273/266/345/261/202/347/272/247/345/217/214/345/220/221/345/220/214/346/255/245.md +856 -0
  115. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Type/350/243/205/351/245/260/345/231/250/357/274/232/346/240/207/350/256/260/347/261/273/345/261/236/346/200/247/347/232/204/347/261/273/345/236/213.md +83 -0
  116. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/AppStorageV2/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200UI/347/212/266/346/200/201/345/255/230/345/202/250.md +294 -0
  117. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/MVVM/346/250/241/345/274/217/357/274/210V2/357/274/211.md +1407 -0
  118. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/PersistenceV2/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +1220 -0
  119. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +47 -0
  120. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2//347/212/266/346/200/201/347/256/241/347/220/206V1/345/220/221V2/350/277/201/347/247/273/344/270/216/346/267/267/347/224/250/346/214/207/345/257/274.md +840 -0
  121. package/skills/hmos-incremental-ui-align/references/State_Model_Template.md +74 -0
  122. package/skills/hmos-incremental-ui-align/references/UI_Analysis_Template.md +34 -4
  123. package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
  124. package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
  125. package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
  126. package/skills/hmos-incremental-ui-align/scripts/app_feature_verify.ts +937 -0
  127. package/skills/hmos-incremental-ui-align/scripts/extract_checklist.ts +343 -0
  128. package/skills/hmos-incremental-ui-align/scripts/navigation-capure.md +44 -5
  129. package/skills/hmos-incremental-ui-align/scripts/page_capture.ts +977 -0
  130. package/skills/hmos-incremental-ui-align/scripts/page_capture_burst.ts +188 -0
  131. package/skills/hmos-integration-test/README.md +111 -79
  132. package/skills/hmos-integration-test/SKILL.md +216 -132
  133. package/skills/hmos-integration-test/scripts/report-tool.ts +791 -0
  134. package/skills/hmos-integration-test/scripts/resolve-metadata-tool.ts +125 -0
  135. package/skills/hmos-integration-test/scripts/self-test-runner.ts +756 -0
  136. package/skills/hmos-integration-test/scripts/testcases-tool.ts +239 -0
  137. package/skills/hmos-resources-convert/SKILL.md +334 -66
  138. package/skills/hmos-resources-convert/references/code-vector-icon-rules.md +335 -0
  139. package/skills/hmos-resources-convert/references/conversion-rules.md +676 -663
  140. package/skills/hmos-resources-convert/references/dependency-analysis-rules.md +410 -388
  141. package/skills/hmos-resources-convert/references/lottie-conversion-rules.md +219 -0
  142. package/skills/hmos-resources-convert/references/resource-mapping-rules.md +482 -457
  143. package/skills/hmos-resources-convert/references/xml-drawable-to-svg-rules.md +592 -513
  144. package/skills/hmos-resources-convert/scripts/a2h_resource_convert.ts +2163 -0
  145. package/skills/hmos-resources-convert/scripts/code_vector_icons.ts +591 -0
  146. package/skills/hmos-resources-convert/scripts/svg_fidelity_check.ts +632 -0
  147. package/skills/hmos-spec-generate/SKILL.md +293 -214
  148. package/skills/hmos-spec-generate/scripts/parse_requirements.ts +515 -0
  149. package/skills/hmos-spec-generate/template/REQ.txt +22 -0
  150. package/skills/hmos-spec-generate/template/REQ.xlsx +0 -0
  151. package/skills/hmos-test-case-generation/README.md +241 -0
  152. package/skills/hmos-test-case-generation/SKILL.md +324 -0
  153. package/skills/hmos-test-case-generation/references/contract.md +315 -0
  154. package/skills/hmos-test-case-generation/references/review-notes-template.md +84 -0
  155. package/skills/hmos-test-case-generation/references/ui-elements-schema.md +142 -0
  156. package/skills/hmos-test-case-generation/tools/convert_to_ui_elements.ts +550 -0
  157. package/skills/hmos-test-case-generation/tools/validate.ts +1312 -0
  158. package/tools/bfs-crawl/README.md +73 -0
  159. package/tools/bfs-crawl/android_viewtree_bfs_crawler.ts +1662 -0
  160. package/agents/build-fixer.md +0 -385
  161. package/agents/logic-coder/scripts/platform_context_query.py +0 -568
  162. package/agents/review-fixer.md +0 -405
  163. package/agents/spec-generator.md +0 -541
  164. package/dist/cli/mcp-setup.js +0 -258
  165. package/dist/cli/mcp.js +0 -94
  166. package/dist/context/index.js +0 -694
  167. package/resource/migration_process.svg +0 -94
  168. package/resource/migration_process_transparent.svg +0 -93
  169. package/skills/hmos-batch-ui-align/scripts/android_parse_fast.py +0 -1606
  170. package/skills/hmos-incremental-ui-align/scripts/__pycache__/app_feature_verify.cpython-314.pyc +0 -0
  171. package/skills/hmos-incremental-ui-align/scripts/app_feature_verify.py +0 -542
  172. package/skills/hmos-incremental-ui-align/scripts/page_capture.py +0 -597
  173. package/skills/hmos-resources-convert/evals/evals.json +0 -171
  174. package/skills/hmos-resources-convert/template/AppScope/app.json5 +0 -10
  175. package/skills/hmos-resources-convert/template/AppScope/resources/base/element/string.json +0 -8
  176. package/skills/hmos-resources-convert/template/AppScope/resources/base/media/background.png +0 -0
  177. package/skills/hmos-resources-convert/template/AppScope/resources/base/media/foreground.png +0 -0
  178. package/skills/hmos-resources-convert/template/AppScope/resources/base/media/layered_image.json +0 -7
  179. package/skills/hmos-resources-convert/template/build-profile.json5 +0 -42
  180. package/skills/hmos-resources-convert/template/code-linter.json5 +0 -32
  181. package/skills/hmos-resources-convert/template/entry/build-profile.json5 +0 -33
  182. package/skills/hmos-resources-convert/template/entry/hvigorfile.ts +0 -6
  183. package/skills/hmos-resources-convert/template/entry/obfuscation-rules.txt +0 -23
  184. package/skills/hmos-resources-convert/template/entry/oh-package.json5 +0 -10
  185. package/skills/hmos-resources-convert/template/entry/src/main/ets/entryability/EntryAbility.ets +0 -48
  186. package/skills/hmos-resources-convert/template/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +0 -16
  187. package/skills/hmos-resources-convert/template/entry/src/main/ets/pages/Index.ets +0 -23
  188. package/skills/hmos-resources-convert/template/entry/src/main/module.json5 +0 -55
  189. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/color.json +0 -8
  190. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/float.json +0 -8
  191. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/string.json +0 -16
  192. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/background.png +0 -0
  193. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/foreground.png +0 -0
  194. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/layered_image.json +0 -7
  195. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/startIcon.png +0 -0
  196. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/profile/backup_config.json +0 -3
  197. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/profile/main_pages.json +0 -5
  198. package/skills/hmos-resources-convert/template/entry/src/main/resources/dark/element/color.json +0 -8
  199. package/skills/hmos-resources-convert/template/entry/src/mock/mock-config.json5 +0 -2
  200. package/skills/hmos-resources-convert/template/entry/src/ohosTest/ets/test/Ability.test.ets +0 -35
  201. package/skills/hmos-resources-convert/template/entry/src/ohosTest/ets/test/List.test.ets +0 -5
  202. package/skills/hmos-resources-convert/template/entry/src/ohosTest/module.json5 +0 -16
  203. package/skills/hmos-resources-convert/template/entry/src/test/List.test.ets +0 -5
  204. package/skills/hmos-resources-convert/template/entry/src/test/LocalUnit.test.ets +0 -33
  205. package/skills/hmos-resources-convert/template/hvigor/hvigor-config.json5 +0 -23
  206. package/skills/hmos-resources-convert/template/hvigorfile.ts +0 -6
  207. package/skills/hmos-resources-convert/template/oh-package-lock.json5 +0 -28
  208. package/skills/hmos-resources-convert/template/oh-package.json5 +0 -10
  209. package/skills/hmos-resources-convert/tools/apktool_3.0.1.jar +0 -0
  210. package/skills/hmos-spec-generate/references/android-platform-tokens.md +0 -105
  211. package/skills/hmos-spec-generate/references/spec-sample-1.md +0 -78
  212. package/skills/hmos-spec-generate/references/spec-sample-2.md +0 -58
  213. package/skills/hmos-spec-generate/references/spec-sample-3.md +0 -116
  214. package/skills/hmos-spec-generate/references/step4-report-template.md +0 -33
  215. package/tools/test-tools/autotest/README.md +0 -238
  216. package/tools/test-tools/autotest/pyproject.toml +0 -26
  217. package/tools/test-tools/autotest/report_tool.py +0 -759
  218. package/tools/test-tools/autotest/self_test_runner.py +0 -895
  219. package/tools/test-tools/autotest/testcases_schema.md +0 -143
  220. package/tools/test-tools/autotest/testcases_tool.py +0 -215
  221. package/tools/test-tools/autotest/uv.lock +0 -3156
  222. package/tools/test-tools/harmony_autotest-0.1.0-py3-none-any.whl +0 -0
  223. package/tools/test-tools/hypium-6.1.0.210-py3-none-any.whl +0 -0
  224. package/tools/test-tools/hypium_mcp-0.6.5-py3-none-any.whl +0 -0
  225. package/tools/test-tools/xdevice-6.1.0.210-py3-none-any.whl +0 -0
  226. package/tools/test-tools/xdevice_devicetest-6.1.0.210-py3-none-any.whl +0 -0
  227. package/tools/test-tools/xdevice_ohos-6.1.0.210-py3-none-any.whl +0 -0
@@ -1,513 +1,592 @@
1
- # Android XML Drawable to SVG Conversion Rules
2
-
3
- This document provides complete rules for converting Android XML drawable resources to SVG format for HarmonyOS. HarmonyOS natively supports SVG in `media/` directories, making SVG the ideal target format for XML drawables that would otherwise be lost in migration.
4
-
5
- ## Table of Contents
6
- 1. [General Principles](#general-principles)
7
- 2. [VectorDrawable Conversion](#vectordrawable-conversion)
8
- 3. [ShapeDrawable Conversion](#shapedrawable-conversion)
9
- 4. [LayerList Conversion](#layerlist-conversion)
10
- 5. [Selector / StateList Conversion](#selector--statelist-conversion)
11
- 6. [Gradient Conversion](#gradient-conversion)
12
- 7. [Common Attribute Mapping](#common-attribute-mapping)
13
- 8. [Unconvertible Types](#unconvertible-types)
14
-
15
- ---
16
-
17
- ## General Principles
18
-
19
- - Output files use the original Android filename with `.svg` extension (e.g., `ic_arrow.xml` → `ic_arrow.svg`)
20
- - All SVG output should use the SVG 1.1 namespace: `xmlns="http://www.w3.org/2000/svg"`
21
- - Android uses `dp` units for dimensions; convert to unitless numbers in SVG (1dp = 1 SVG user unit)
22
- - Android colors use `#AARRGGBB` or `#RRGGBB`; SVG uses `#RRGGBB` with a separate `opacity` or `fill-opacity` attribute for alpha
23
- - When a drawable XML references another resource (`@drawable/other`, `@color/primary`), resolve the reference if possible. If not resolvable, use a reasonable default and log it in the report.
24
-
25
- ### Color Conversion (Android → SVG)
26
-
27
- | Android Format | SVG Fill/Stroke | SVG Opacity |
28
- |---|---|---|
29
- | `#RRGGBB` | `#RRGGBB` | (none, fully opaque) |
30
- | `#AARRGGBB` | `#RRGGBB` | `opacity="AA/255"` as decimal (e.g., `#80FF0000` → `fill="#FF0000" fill-opacity="0.502"`) |
31
- | `#RGB` | Expand to `#RRGGBB` | (none) |
32
- | `#ARGB` | Expand to `#RRGGBB` | Extract alpha as decimal |
33
-
34
- ### Dimension Conversion
35
-
36
- - `24dp` → `24` (strip `dp` suffix, use as unitless SVG user units)
37
- - `@dimen/ref` → resolve from dimens.xml if available, otherwise use a default and log
38
-
39
- ---
40
-
41
- ## VectorDrawable Conversion
42
-
43
- Android VectorDrawable (`<vector>`) is structurally very similar to SVG. This is the most straightforward conversion.
44
-
45
- ### Android VectorDrawable Example
46
-
47
- ```xml
48
- <vector xmlns:android="http://schemas.android.com/apk/res/android"
49
- android:width="24dp"
50
- android:height="24dp"
51
- android:viewportWidth="24"
52
- android:viewportHeight="24"
53
- android:tint="#FF000000"
54
- android:alpha="0.8">
55
- <group
56
- android:name="arrow_group"
57
- android:rotation="90"
58
- android:pivotX="12"
59
- android:pivotY="12"
60
- android:scaleX="1.5"
61
- android:scaleY="1.5"
62
- android:translateX="2"
63
- android:translateY="0">
64
- <path
65
- android:name="arrow"
66
- android:pathData="M12,2L4.5,20.29l0.71,0.71L12,18l6.79,3 0.71,-0.71z"
67
- android:fillColor="#FF4081"
68
- android:fillAlpha="0.8"
69
- android:strokeColor="#000000"
70
- android:strokeWidth="1"
71
- android:strokeAlpha="1"
72
- android:strokeLineCap="round"
73
- android:strokeLineJoin="round"
74
- android:fillType="evenOdd"
75
- android:trimPathStart="0"
76
- android:trimPathEnd="1" />
77
- <clip-path
78
- android:name="clip"
79
- android:pathData="M0,0h24v24H0z" />
80
- </group>
81
- </vector>
82
- ```
83
-
84
- ### Converted SVG Output
85
-
86
- ```svg
87
- <svg xmlns="http://www.w3.org/2000/svg"
88
- width="24" height="24"
89
- viewBox="0 0 24 24"
90
- opacity="0.8">
91
- <g transform="translate(2,0) scale(1.5,1.5) rotate(90,12,12)">
92
- <defs>
93
- <clipPath id="clip">
94
- <path d="M0,0h24v24H0z"/>
95
- </clipPath>
96
- </defs>
97
- <path d="M12,2L4.5,20.29l0.71,0.71L12,18l6.79,3 0.71,-0.71z"
98
- fill="#FF4081" fill-opacity="0.8"
99
- stroke="#000000" stroke-width="1"
100
- stroke-linecap="round" stroke-linejoin="round"
101
- fill-rule="evenodd"
102
- clip-path="url(#clip)"/>
103
- </g>
104
- </svg>
105
- ```
106
-
107
- ### Element Mapping: `<vector>` → `<svg>`
108
-
109
- | Android Attribute | SVG Equivalent |
110
- |---|---|
111
- | `android:width` | `width` (strip `dp`) |
112
- | `android:height` | `height` (strip `dp`) |
113
- | `android:viewportWidth` | Part of `viewBox="0 0 W H"` |
114
- | `android:viewportHeight` | Part of `viewBox="0 0 W H"` |
115
- | `android:alpha` | `opacity` on root `<svg>` |
116
- | `android:tint` | Apply as a filter or ignore (SVG has no direct tint; log in report) |
117
-
118
- ### Element Mapping: `<path>` → `<path>`
119
-
120
- | Android Attribute | SVG Attribute |
121
- |---|---|
122
- | `android:pathData` | `d` (path data syntax is identical) |
123
- | `android:fillColor` | `fill` (convert color format) |
124
- | `android:fillAlpha` | `fill-opacity` |
125
- | `android:strokeColor` | `stroke` (convert color format) |
126
- | `android:strokeWidth` | `stroke-width` |
127
- | `android:strokeAlpha` | `stroke-opacity` |
128
- | `android:strokeLineCap` | `stroke-linecap` (`butt`, `round`, `square`) |
129
- | `android:strokeLineJoin` | `stroke-linejoin` (`miter`, `round`, `bevel`) |
130
- | `android:strokeMiterLimit` | `stroke-miterlimit` |
131
- | `android:fillType` | `fill-rule` (`nonZero` → `nonzero`, `evenOdd` → `evenodd`) |
132
- | `android:trimPathStart` | No direct SVG equivalent; if != 0, use `stroke-dasharray` + `stroke-dashoffset` to approximate, or log |
133
- | `android:trimPathEnd` | Same as above |
134
- | `android:trimPathOffset` | Same as above |
135
-
136
- ### Element Mapping: `<group>` → `<g>`
137
-
138
- Build the SVG `transform` attribute from the group's transformation properties. Apply in this order:
139
- 1. `translate(translateX, translateY)`
140
- 2. `scale(scaleX, scaleY)`
141
- 3. `rotate(rotation, pivotX, pivotY)`
142
-
143
- Combined: `transform="translate(tX,tY) scale(sX,sY) rotate(r,pX,pY)"`
144
-
145
- Only include transform components that differ from defaults (translate 0,0; scale 1,1; rotation 0).
146
-
147
- ### Element Mapping: `<clip-path>` → `<clipPath>` + `<path>`
148
-
149
- ```xml
150
- <!-- Android -->
151
- <clip-path android:pathData="M0,0h24v24H0z"/>
152
-
153
- <!-- SVG -->
154
- <defs>
155
- <clipPath id="generated_clip_id">
156
- <path d="M0,0h24v24H0z"/>
157
- </clipPath>
158
- </defs>
159
- <!-- Apply via clip-path="url(#generated_clip_id)" on sibling paths -->
160
- ```
161
-
162
- Generate unique IDs for clip paths (e.g., `clip_1`, `clip_2`, or derive from `android:name`).
163
-
164
- ---
165
-
166
- ## ShapeDrawable Conversion
167
-
168
- Android `<shape>` drawables define geometric shapes with fill, stroke, gradients, corners, and sizing.
169
-
170
- ### Shape Types
171
-
172
- #### Rectangle (default)
173
-
174
- ```xml
175
- <!-- Android -->
176
- <shape xmlns:android="http://schemas.android.com/apk/res/android"
177
- android:shape="rectangle">
178
- <solid android:color="#FF4081"/>
179
- <stroke android:width="2dp" android:color="#000000"
180
- android:dashWidth="4dp" android:dashGap="2dp"/>
181
- <corners android:radius="8dp"/>
182
- <size android:width="100dp" android:height="50dp"/>
183
- <padding android:left="10dp" android:top="5dp"
184
- android:right="10dp" android:bottom="5dp"/>
185
- </shape>
186
- ```
187
-
188
- ```svg
189
- <!-- SVG -->
190
- <svg xmlns="http://www.w3.org/2000/svg" width="100" height="50" viewBox="0 0 100 50">
191
- <rect x="0" y="0" width="100" height="50" rx="8" ry="8"
192
- fill="#FF4081"
193
- stroke="#000000" stroke-width="2"
194
- stroke-dasharray="4,2"/>
195
- </svg>
196
- ```
197
-
198
- **Corner radius variants:**
199
- - `android:radius` → `rx` and `ry` (same value)
200
- - `android:topLeftRadius`, `android:topRightRadius`, `android:bottomRightRadius`, `android:bottomLeftRadius` → When different per corner, use a `<path>` with rounded corner arcs instead of `<rect>`
201
-
202
- **Per-corner radius SVG path formula:**
203
- ```
204
- M {tlr},0
205
- H {w-trr}
206
- Q {w},0 {w},{trr}
207
- V {h-brr}
208
- Q {w},{h} {w-brr},{h}
209
- H {blr}
210
- Q 0,{h} 0,{h-blr}
211
- V {tlr}
212
- Q 0,0 {tlr},0
213
- Z
214
- ```
215
- Where `tlr`=topLeftRadius, `trr`=topRightRadius, `brr`=bottomRightRadius, `blr`=bottomLeftRadius, `w`=width, `h`=height.
216
-
217
- #### Oval
218
-
219
- ```xml
220
- <!-- Android -->
221
- <shape android:shape="oval">
222
- <solid android:color="#2196F3"/>
223
- <size android:width="60dp" android:height="60dp"/>
224
- </shape>
225
- ```
226
-
227
- ```svg
228
- <!-- SVG -->
229
- <svg xmlns="http://www.w3.org/2000/svg" width="60" height="60" viewBox="0 0 60 60">
230
- <ellipse cx="30" cy="30" rx="30" ry="30" fill="#2196F3"/>
231
- </svg>
232
- ```
233
-
234
- - If width == height, use `<circle>` instead: `<circle cx="30" cy="30" r="30"/>`
235
-
236
- #### Line
237
-
238
- ```xml
239
- <!-- Android -->
240
- <shape android:shape="line">
241
- <stroke android:width="2dp" android:color="#000000"/>
242
- <size android:height="2dp" android:width="100dp"/>
243
- </shape>
244
- ```
245
-
246
- ```svg
247
- <!-- SVG -->
248
- <svg xmlns="http://www.w3.org/2000/svg" width="100" height="2" viewBox="0 0 100 2">
249
- <line x1="0" y1="1" x2="100" y2="1" stroke="#000000" stroke-width="2"/>
250
- </svg>
251
- ```
252
-
253
- #### Ring
254
-
255
- ```xml
256
- <!-- Android -->
257
- <shape android:shape="ring"
258
- android:innerRadius="20dp"
259
- android:thickness="5dp">
260
- <solid android:color="#4CAF50"/>
261
- <size android:width="50dp" android:height="50dp"/>
262
- </shape>
263
- ```
264
-
265
- ```svg
266
- <!-- SVG -->
267
- <svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 50 50">
268
- <circle cx="25" cy="25" r="22.5"
269
- fill="none" stroke="#4CAF50" stroke-width="5"/>
270
- </svg>
271
- ```
272
-
273
- - Ring center radius = `innerRadius + thickness/2`
274
- - SVG stroke-width = `thickness`
275
- - If `android:innerRadiusRatio` is used instead of `android:innerRadius`: `innerRadius = width / (2 * innerRadiusRatio)`
276
- - If `android:thicknessRatio` is used: `thickness = width / (2 * thicknessRatio)`
277
-
278
- ### Shape Size Handling
279
-
280
- If `<size>` is not specified, use a sensible default (e.g., `24x24`) and note in the report that the original had no explicit size. The SVG `viewBox` should match the dimensions.
281
-
282
- ---
283
-
284
- ## Gradient Conversion
285
-
286
- Android shapes and vector drawables can use gradients for fill or stroke colors.
287
-
288
- ### Linear Gradient
289
-
290
- ```xml
291
- <!-- Android (in shape) -->
292
- <gradient
293
- android:type="linear"
294
- android:startColor="#FF0000"
295
- android:centerColor="#00FF00"
296
- android:endColor="#0000FF"
297
- android:angle="45"/>
298
- ```
299
-
300
- ```svg
301
- <!-- SVG -->
302
- <defs>
303
- <linearGradient id="grad_1" x1="0%" y1="100%" x2="100%" y2="0%">
304
- <stop offset="0%" stop-color="#FF0000"/>
305
- <stop offset="50%" stop-color="#00FF00"/>
306
- <stop offset="100%" stop-color="#0000FF"/>
307
- </linearGradient>
308
- </defs>
309
- <rect ... fill="url(#grad_1)"/>
310
- ```
311
-
312
- **Angle to coordinates mapping:**
313
-
314
- | Android `angle` | SVG `x1,y1 → x2,y2` |
315
- |---|---|
316
- | 0 (left→right) | `0%,0% → 100%,0%` |
317
- | 45 (bottom-left→top-right) | `0%,100% → 100%,0%` |
318
- | 90 (bottom→top) | `0%,100% → 0%,0%` |
319
- | 135 (bottom-right→top-left) | `100%,100% → 0%,0%` |
320
- | 180 (right→left) | `100%,0% → 0%,0%` |
321
- | 225 (top-right→bottom-left) | `100%,0% → 0%,100%` |
322
- | 270 (top→bottom) | `0%,0% → 0%,100%` |
323
- | 315 (top-left→bottom-right) | `0%,0% → 100%,100%` |
324
-
325
- Android `angle` must be a multiple of 45. For other values, calculate:
326
- - `x1 = 50 + 50*cos(angle+180)`, `y1 = 50 - 50*sin(angle+180)`
327
- - `x2 = 50 + 50*cos(angle)`, `y2 = 50 - 50*sin(angle)`
328
-
329
- ### Radial Gradient
330
-
331
- ```xml
332
- <!-- Android -->
333
- <gradient
334
- android:type="radial"
335
- android:centerX="0.5"
336
- android:centerY="0.5"
337
- android:gradientRadius="50%p"
338
- android:startColor="#FFFFFF"
339
- android:endColor="#000000"/>
340
- ```
341
-
342
- ```svg
343
- <!-- SVG -->
344
- <defs>
345
- <radialGradient id="grad_2" cx="50%" cy="50%" r="50%">
346
- <stop offset="0%" stop-color="#FFFFFF"/>
347
- <stop offset="100%" stop-color="#000000"/>
348
- </radialGradient>
349
- </defs>
350
- ```
351
-
352
- - `centerX`/`centerY` are fractions (0.0–1.0) → convert to percentages
353
- - `gradientRadius` with `%p` suffix → percentage of parent dimension
354
-
355
- ### Sweep Gradient
356
-
357
- ```xml
358
- <!-- Android -->
359
- <gradient
360
- android:type="sweep"
361
- android:centerX="0.5"
362
- android:centerY="0.5"
363
- android:startColor="#FF0000"
364
- android:endColor="#0000FF"/>
365
- ```
366
-
367
- SVG doesn't have a native sweep/conic gradient in SVG 1.1. Options:
368
- 1. Use CSS `conic-gradient` if targeting modern renderers (but not SVG 1.1 compliant)
369
- 2. Approximate with a series of `<path>` segments in a radial pattern
370
- 3. Log as partially converted and note that sweep gradient was approximated
371
-
372
- Recommended: convert to a `<linearGradient>` as an approximation and log in the report that the original was a sweep gradient.
373
-
374
- ### Gradient in VectorDrawable Paths
375
-
376
- Android API 24+ supports `<aapt:attr>` inline gradient in vector drawables:
377
-
378
- ```xml
379
- <path android:pathData="...">
380
- <aapt:attr name="android:fillColor">
381
- <gradient android:type="linear" .../>
382
- </aapt:attr>
383
- </path>
384
- ```
385
-
386
- Convert the gradient to an SVG `<linearGradient>` in `<defs>` and reference via `fill="url(#grad_id)"`.
387
-
388
- ---
389
-
390
- ## LayerList Conversion
391
-
392
- `<layer-list>` stacks multiple drawable items. Each `<item>` can contain a `<shape>`, a `<bitmap>`, or reference another drawable.
393
-
394
- ```xml
395
- <!-- Android -->
396
- <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
397
- <item>
398
- <shape android:shape="rectangle">
399
- <solid android:color="#CCCCCC"/>
400
- <corners android:radius="4dp"/>
401
- </shape>
402
- </item>
403
- <item android:left="2dp" android:top="2dp"
404
- android:right="2dp" android:bottom="2dp">
405
- <shape android:shape="rectangle">
406
- <solid android:color="#FFFFFF"/>
407
- <corners android:radius="2dp"/>
408
- </shape>
409
- </item>
410
- </layer-list>
411
- ```
412
-
413
- ```svg
414
- <!-- SVG -->
415
- <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100">
416
- <!-- Layer 0: background -->
417
- <rect x="0" y="0" width="100" height="100" rx="4" ry="4" fill="#CCCCCC"/>
418
- <!-- Layer 1: foreground with insets -->
419
- <rect x="2" y="2" width="96" height="96" rx="2" ry="2" fill="#FFFFFF"/>
420
- </svg>
421
- ```
422
-
423
- ### Rules
424
-
425
- - Items are rendered in document order (first item = bottom layer)
426
- - `android:left/top/right/bottom` on `<item>` → inset the element's position and reduce its size accordingly
427
- - `android:width/height` on `<item>` → explicit size override
428
- - `android:gravity` on `<item>` → position within the layer bounds
429
- - If an `<item>` references another drawable via `android:drawable="@drawable/other"`, try to resolve and inline it; if not resolvable, log in report
430
- - For layer-lists without explicit `<size>`, use a default canvas of `100x100` and note in report
431
-
432
- ---
433
-
434
- ## Selector / StateList Conversion
435
-
436
- `<selector>` defines different drawables for different UI states (pressed, focused, disabled, etc.). SVG is static, so we extract the most useful representation.
437
-
438
- ```xml
439
- <!-- Android -->
440
- <selector xmlns:android="http://schemas.android.com/apk/res/android">
441
- <item android:state_pressed="true">
442
- <shape android:shape="rectangle">
443
- <solid android:color="#E0E0E0"/>
444
- <corners android:radius="4dp"/>
445
- </shape>
446
- </item>
447
- <item android:state_focused="true">
448
- <shape android:shape="rectangle">
449
- <solid android:color="#F0F0F0"/>
450
- <corners android:radius="4dp"/>
451
- </shape>
452
- </item>
453
- <item>
454
- <shape android:shape="rectangle">
455
- <solid android:color="#FFFFFF"/>
456
- <corners android:radius="4dp"/>
457
- </shape>
458
- </item>
459
- </selector>
460
- ```
461
-
462
- ### Conversion Strategy
463
-
464
- 1. Find the **default item** — the `<item>` with no `android:state_*` attributes (or the last item, which serves as the default in Android)
465
- 2. Convert that single item to SVG using the appropriate rules (shape → SVG, vector → SVG, etc.)
466
- 3. In the conversion report, list all the state variants that were dropped:
467
- - `state_pressed`, `state_focused`, `state_selected`, `state_checked`, `state_enabled`, `state_activated`, `state_hovered`
468
- 4. Note that HarmonyOS state handling should be done in ArkUI component code, not in resource files
469
-
470
- ---
471
-
472
- ## Common Attribute Mapping
473
-
474
- ### Android `android:` namespace to SVG
475
-
476
- | Android Attribute | SVG Equivalent | Notes |
477
- |---|---|---|
478
- | `android:fillColor` | `fill` | Convert color format |
479
- | `android:strokeColor` | `stroke` | Convert color format |
480
- | `android:strokeWidth` | `stroke-width` | Strip `dp` |
481
- | `android:alpha` | `opacity` | 0.0-1.0 range |
482
- | `android:fillAlpha` | `fill-opacity` | 0.0-1.0 range |
483
- | `android:strokeAlpha` | `stroke-opacity` | 0.0-1.0 range |
484
- | `android:rotation` | `transform="rotate(deg)"` | In `<group>` |
485
- | `android:scaleX/Y` | `transform="scale(x,y)"` | In `<group>` |
486
- | `android:translateX/Y` | `transform="translate(x,y)"` | In `<group>` |
487
-
488
- ### Default Values
489
-
490
- If an Android drawable doesn't specify certain attributes, use these defaults:
491
- - `fillColor`: `#000000` (black) for paths in `<vector>`, transparent for shapes without `<solid>`
492
- - `strokeWidth`: `0` (no stroke)
493
- - `alpha`: `1.0`
494
- - `fillType`: `nonZero`
495
-
496
- ---
497
-
498
- ## Unconvertible Types
499
-
500
- These XML drawable types cannot be meaningfully converted to SVG and should be logged as unmappable in the conversion report:
501
-
502
- | Type | Root Element | Reason |
503
- |---|---|---|
504
- | Ripple | `<ripple>` | Runtime touch feedback animation |
505
- | Animated Vector | `<animated-vector>` | Requires animation timing/interpolation |
506
- | Animated Selector | `<animated-selector>` | State transitions with animations |
507
- | Transition Drawable | `<transition>` | Cross-fade between two drawables |
508
- | Inset Drawable | `<inset>` | Simple wrapper; if inner drawable is convertible, convert that instead |
509
- | Scale Drawable | `<scale>` | Runtime scaling behavior |
510
- | Rotate Drawable | `<rotate>` | Runtime rotation; could be converted as static rotation if angle is fixed |
511
- | Level List | `<level-list>` | Runtime level-based selection |
512
-
513
- For `<inset>` and `<rotate>` with fixed values, attempt conversion by applying the inset/rotation statically and convert the inner drawable. Log in the report either way.
1
+ # Android XML Drawable to SVG Conversion Rules
2
+
3
+ This document provides complete rules for converting Android XML drawable resources to SVG format for HarmonyOS. HarmonyOS natively supports SVG in `media/` directories, making SVG the ideal target format for XML drawables that would otherwise be lost in migration.
4
+
5
+ ## Table of Contents
6
+ 1. [General Principles](#general-principles)
7
+ 2. [VectorDrawable Conversion](#vectordrawable-conversion)
8
+ 3. [ShapeDrawable Conversion](#shapedrawable-conversion)
9
+ 4. [LayerList Conversion](#layerlist-conversion)
10
+ 5. [Selector / StateList Conversion](#selector--statelist-conversion)
11
+ 6. [Gradient Conversion](#gradient-conversion)
12
+ 7. [Common Attribute Mapping](#common-attribute-mapping)
13
+ 8. [Unconvertible Types](#unconvertible-types)
14
+
15
+ ---
16
+
17
+ ## General Principles
18
+
19
+ - Output files use the original Android filename with `.svg` extension (e.g., `ic_arrow.xml` → `ic_arrow.svg`)
20
+ - All SVG output should use the SVG 1.1 namespace: `xmlns="http://www.w3.org/2000/svg"`
21
+ - Android uses `dp` units for dimensions; convert to unitless numbers in SVG (1dp = 1 SVG user unit)
22
+ - Android colors use `#AARRGGBB` or `#RRGGBB`; SVG uses `#RRGGBB` with a separate `opacity` or `fill-opacity` attribute for alpha
23
+ - When a drawable XML references another resource (`@drawable/other`, `@color/primary`), resolve the reference if possible. If not resolvable, use a reasonable default and log it in the report.
24
+
25
+ ### Color Conversion (Android → SVG)
26
+
27
+ | Android Format | SVG Fill/Stroke | SVG Opacity |
28
+ |---|---|---|
29
+ | `#RRGGBB` | `#RRGGBB` | (none, fully opaque) |
30
+ | `#AARRGGBB` | `#RRGGBB` | `opacity="AA/255"` as decimal (e.g., `#80FF0000` → `fill="#FF0000" fill-opacity="0.502"`) |
31
+ | `#RGB` | Expand to `#RRGGBB` | (none) |
32
+ | `#ARGB` | Expand to `#RRGGBB` | Extract alpha as decimal |
33
+
34
+ ### Dimension Conversion
35
+
36
+ - `24dp` → `24` (strip `dp` suffix, use as unitless SVG user units)
37
+ - `@dimen/ref` → resolve from dimens.xml if available, otherwise use a default and log
38
+
39
+ ---
40
+
41
+ ## VectorDrawable Conversion
42
+
43
+ Android VectorDrawable (`<vector>`) is structurally very similar to SVG. This is the most straightforward conversion.
44
+
45
+ ### Android VectorDrawable Example
46
+
47
+ ```xml
48
+ <vector xmlns:android="http://schemas.android.com/apk/res/android"
49
+ android:width="24dp"
50
+ android:height="24dp"
51
+ android:viewportWidth="24"
52
+ android:viewportHeight="24"
53
+ android:tint="#FF000000"
54
+ android:alpha="0.8">
55
+ <group
56
+ android:name="arrow_group"
57
+ android:rotation="90"
58
+ android:pivotX="12"
59
+ android:pivotY="12"
60
+ android:scaleX="1.5"
61
+ android:scaleY="1.5"
62
+ android:translateX="2"
63
+ android:translateY="0">
64
+ <path
65
+ android:name="arrow"
66
+ android:pathData="M12,2L4.5,20.29l0.71,0.71L12,18l6.79,3 0.71,-0.71z"
67
+ android:fillColor="#FF4081"
68
+ android:fillAlpha="0.8"
69
+ android:strokeColor="#000000"
70
+ android:strokeWidth="1"
71
+ android:strokeAlpha="1"
72
+ android:strokeLineCap="round"
73
+ android:strokeLineJoin="round"
74
+ android:fillType="evenOdd"
75
+ android:trimPathStart="0"
76
+ android:trimPathEnd="1" />
77
+ <clip-path
78
+ android:name="clip"
79
+ android:pathData="M0,0h24v24H0z" />
80
+ </group>
81
+ </vector>
82
+ ```
83
+
84
+ ### Converted SVG Output
85
+
86
+ ```svg
87
+ <svg xmlns="http://www.w3.org/2000/svg"
88
+ width="24" height="24"
89
+ viewBox="0 0 24 24"
90
+ opacity="0.8">
91
+ <g transform="translate(2,0) scale(1.5,1.5) rotate(90,12,12)">
92
+ <defs>
93
+ <clipPath id="clip">
94
+ <path d="M0,0h24v24H0z"/>
95
+ </clipPath>
96
+ </defs>
97
+ <path d="M12,2L4.5,20.29l0.71,0.71L12,18l6.79,3 0.71,-0.71z"
98
+ fill="#FF4081" fill-opacity="0.8"
99
+ stroke="#000000" stroke-width="1"
100
+ stroke-linecap="round" stroke-linejoin="round"
101
+ fill-rule="evenodd"
102
+ clip-path="url(#clip)"/>
103
+ </g>
104
+ </svg>
105
+ ```
106
+
107
+ ### Element Mapping: `<vector>` → `<svg>`
108
+
109
+ | Android Attribute | SVG Equivalent |
110
+ |---|---|
111
+ | `android:width` | `width` (strip `dp`) |
112
+ | `android:height` | `height` (strip `dp`) |
113
+ | `android:viewportWidth` | Part of `viewBox="0 0 W H"` |
114
+ | `android:viewportHeight` | Part of `viewBox="0 0 W H"` |
115
+ | `android:alpha` | `opacity` on root `<svg>` |
116
+ | `android:tint` | Apply as a filter or ignore (SVG has no direct tint; log in report) |
117
+
118
+ ### Element Mapping: `<path>` → `<path>`
119
+
120
+ | Android Attribute | SVG Attribute |
121
+ |---|---|
122
+ | `android:pathData` | `d` (path data syntax is identical) |
123
+ | `android:fillColor` | `fill` (convert color format) |
124
+ | `android:fillAlpha` | `fill-opacity` |
125
+ | `android:strokeColor` | `stroke` (convert color format) |
126
+ | `android:strokeWidth` | `stroke-width` |
127
+ | `android:strokeAlpha` | `stroke-opacity` |
128
+ | `android:strokeLineCap` | `stroke-linecap` (`butt`, `round`, `square`) |
129
+ | `android:strokeLineJoin` | `stroke-linejoin` (`miter`, `round`, `bevel`) |
130
+ | `android:strokeMiterLimit` | `stroke-miterlimit` |
131
+ | `android:fillType` | `fill-rule` (`nonZero` → `nonzero`, `evenOdd` → `evenodd`) |
132
+ | `android:trimPathStart` | No direct SVG equivalent; if != 0, use `stroke-dasharray` + `stroke-dashoffset` to approximate, or log |
133
+ | `android:trimPathEnd` | Same as above |
134
+ | `android:trimPathOffset` | Same as above |
135
+
136
+ ### Element Mapping: `<group>` → `<g>`
137
+
138
+ Build the SVG `transform` attribute from the group's transformation properties. Apply in this order:
139
+ 1. `translate(translateX, translateY)`
140
+ 2. `scale(scaleX, scaleY)`
141
+ 3. `rotate(rotation, pivotX, pivotY)`
142
+
143
+ Combined: `transform="translate(tX,tY) scale(sX,sY) rotate(r,pX,pY)"`
144
+
145
+ Only include transform components that differ from defaults (translate 0,0; scale 1,1; rotation 0).
146
+
147
+ ### Element Mapping: `<clip-path>` → `<clipPath>` + `<path>`
148
+
149
+ ```xml
150
+ <!-- Android -->
151
+ <clip-path android:pathData="M0,0h24v24H0z"/>
152
+
153
+ <!-- SVG -->
154
+ <defs>
155
+ <clipPath id="generated_clip_id">
156
+ <path d="M0,0h24v24H0z"/>
157
+ </clipPath>
158
+ </defs>
159
+ <!-- Apply via clip-path="url(#generated_clip_id)" on sibling paths -->
160
+ ```
161
+
162
+ Generate unique IDs for clip paths (e.g., `clip_1`, `clip_2`, or derive from `android:name`).
163
+
164
+ #### `clip-path` is geometry, not decoration — it is mandatory
165
+
166
+ A `<clip-path>` changes the **position, size, and visible extent** of every sibling path in its
167
+ group. Dropping it does not degrade the icon slightly; it renders a different shape. Two forms
168
+ both occur in real icon sets and **both must be preserved**:
169
+
170
+ | Form | Example | Effect if dropped |
171
+ |---|---|---|
172
+ | Full-viewport clip | `M0 0hWvHz` where `W`/`H` equal `viewportWidth`/`viewportHeight` | Visually equivalent, but do not use "it looks full-size" as licence to skip clips in general — verify the numbers first |
173
+ | **Sub-region clip** | clip origin or extent differs from the viewport | Geometry breaks. Two sub-cases are especially damaging: (a) the artwork occupies only part of the viewport, so the icon lands at the wrong offset and scale; (b) the path deliberately **floods the whole viewport** and relies on the clip to cut the visible figure out of it — dropping the clip yields a solid filled rectangle |
174
+
175
+ Case (b) is worth calling out because the path data alone looks like a plain background
176
+ rectangle; nothing about the `<path>` element hints that a clip is load-bearing. Never decide a
177
+ clip is redundant by reading the path — compare the clip's bounds against the viewport.
178
+
179
+ **Self-check after emitting each `<vector>`-derived SVG** (do not defer this to a later step):
180
+
181
+ 1. count of `<clip-path>` in the Android source == count of `<clipPath>` in the SVG
182
+ 2. every path that sat inside a clipped `<group>` carries `clip-path="url(#…)"`
183
+ 3. each `clipPath` `id` referenced actually exists in `<defs>`
184
+
185
+ If any check fails, fix the SVG before moving to the next file.
186
+
187
+ ---
188
+
189
+ ## Vector Fidelity Checklist
190
+
191
+ Run this per `<vector>`-derived SVG before considering the file converted. It is the `<vector>`
192
+ counterpart to the ShapeDrawable rules below, and it exists because **a file that exists and
193
+ parses can still be visually wrong** — existence checks cannot catch any of the items here.
194
+
195
+ | # | Check | Failure signature |
196
+ |---|---|---|
197
+ | 1 | `clip-path` count preserved; clipped paths reference their `clipPath` | Icon offset/scaled wrong, or a solid rectangle where a figure was expected |
198
+ | 2 | `fill` follows the three-branch rule (`fill="none"` for stroke-only paths) | Outline icon renders as a solid blob |
199
+ | 3 | All `stroke*` attributes carried over (`stroke`, `stroke-width`, `-linecap`, `-linejoin`, `-miterlimit`, `-opacity`) | Outline too thin/thick, or corners/caps visibly wrong |
200
+ | 4 | `viewportWidth`/`viewportHeight` == `viewBox="0 0 W H"`; `width`/`height` carried from `android:width/height` | Whole icon scaled or cropped |
201
+ | 5 | `<group>` transforms emitted in order translate → scale → rotate, with pivot preserved | Artwork rotated about the wrong point or displaced |
202
+ | 6 | `fillType="evenOdd"` → `fill-rule="evenodd"` | Holes in the shape fill in (donuts become discs) |
203
+ | 7 | `#AARRGGBB` split into color + `fill-opacity`/`stroke-opacity` | Opaque where it should be translucent |
204
+ | 8 | Inline `<aapt:attr name="android:fillColor"><gradient>` → `<defs><linearGradient\|radialGradient>` + `fill="url(#id)"` | Gradient collapses to a flat color — and because the `<path>` carries no `fillColor` *attribute*, a converter that ignores `aapt:attr` typically falls back to the black default, so the shape turns solid black |
205
+
206
+ Item 8 deserves attention because the gradient lives in a **child element**, not an attribute. Any
207
+ converter that only reads `<path>` attributes sees a path with no `fillColor` and takes the default
208
+ branch. Treat `<aapt:attr>` children as a fill source on equal footing with the attribute form.
209
+
210
+ Item 8 has a second form that only shows up in a **compiled** APK, which is exactly what this skill
211
+ converts. At build time aapt hoists the inline `<gradient>` out into its own drawable resource and
212
+ leaves behind an ordinary attribute: `android:fillColor="@drawable/$icon__0"`, decoding to a file
213
+ `res/drawable*/_icon__0.xml` whose root is `<gradient>` (`$` is written as `_`). Here the attribute
214
+ *is* present, so the `aapt:attr` branch never fires; the reference simply fails to resolve as a color
215
+ and the path falls back to black. Follow the reference into the drawable and build the gradient from
216
+ it — search the unqualified `drawable/` first, then any `drawable-*` directory. When the hoisted
217
+ gradient's own stops are unresolvable (framework dynamic colors such as `@android:0106xxxx`), the
218
+ black fallback is correct, but it must still be recorded as an unresolved paint.
219
+
220
+ Record any file that fails a check in the conversion report rather than silently re-emitting it,
221
+ so the same defect is not reintroduced on the next run.
222
+
223
+ ---
224
+
225
+ ## ShapeDrawable Conversion
226
+
227
+ Android `<shape>` drawables define geometric shapes with fill, stroke, gradients, corners, and sizing.
228
+
229
+ ### Shape Types
230
+
231
+ #### Rectangle (default)
232
+
233
+ ```xml
234
+ <!-- Android -->
235
+ <shape xmlns:android="http://schemas.android.com/apk/res/android"
236
+ android:shape="rectangle">
237
+ <solid android:color="#FF4081"/>
238
+ <stroke android:width="2dp" android:color="#000000"
239
+ android:dashWidth="4dp" android:dashGap="2dp"/>
240
+ <corners android:radius="8dp"/>
241
+ <size android:width="100dp" android:height="50dp"/>
242
+ <padding android:left="10dp" android:top="5dp"
243
+ android:right="10dp" android:bottom="5dp"/>
244
+ </shape>
245
+ ```
246
+
247
+ ```svg
248
+ <!-- SVG -->
249
+ <svg xmlns="http://www.w3.org/2000/svg" width="100" height="50" viewBox="0 0 100 50">
250
+ <rect x="0" y="0" width="100" height="50" rx="8" ry="8"
251
+ fill="#FF4081"
252
+ stroke="#000000" stroke-width="2"
253
+ stroke-dasharray="4,2"/>
254
+ </svg>
255
+ ```
256
+
257
+ **Corner radius variants:**
258
+ - `android:radius` → `rx` and `ry` (same value)
259
+ - `android:topLeftRadius`, `android:topRightRadius`, `android:bottomRightRadius`, `android:bottomLeftRadius` → When different per corner, use a `<path>` with rounded corner arcs instead of `<rect>`
260
+
261
+ **Per-corner radius SVG path formula:**
262
+ ```
263
+ M {tlr},0
264
+ H {w-trr}
265
+ Q {w},0 {w},{trr}
266
+ V {h-brr}
267
+ Q {w},{h} {w-brr},{h}
268
+ H {blr}
269
+ Q 0,{h} 0,{h-blr}
270
+ V {tlr}
271
+ Q 0,0 {tlr},0
272
+ Z
273
+ ```
274
+ Where `tlr`=topLeftRadius, `trr`=topRightRadius, `brr`=bottomRightRadius, `blr`=bottomLeftRadius, `w`=width, `h`=height.
275
+
276
+ #### Oval
277
+
278
+ ```xml
279
+ <!-- Android -->
280
+ <shape android:shape="oval">
281
+ <solid android:color="#2196F3"/>
282
+ <size android:width="60dp" android:height="60dp"/>
283
+ </shape>
284
+ ```
285
+
286
+ ```svg
287
+ <!-- SVG -->
288
+ <svg xmlns="http://www.w3.org/2000/svg" width="60" height="60" viewBox="0 0 60 60">
289
+ <ellipse cx="30" cy="30" rx="30" ry="30" fill="#2196F3"/>
290
+ </svg>
291
+ ```
292
+
293
+ - If width == height, use `<circle>` instead: `<circle cx="30" cy="30" r="30"/>`
294
+
295
+ #### Line
296
+
297
+ ```xml
298
+ <!-- Android -->
299
+ <shape android:shape="line">
300
+ <stroke android:width="2dp" android:color="#000000"/>
301
+ <size android:height="2dp" android:width="100dp"/>
302
+ </shape>
303
+ ```
304
+
305
+ ```svg
306
+ <!-- SVG -->
307
+ <svg xmlns="http://www.w3.org/2000/svg" width="100" height="2" viewBox="0 0 100 2">
308
+ <line x1="0" y1="1" x2="100" y2="1" stroke="#000000" stroke-width="2"/>
309
+ </svg>
310
+ ```
311
+
312
+ #### Ring
313
+
314
+ ```xml
315
+ <!-- Android -->
316
+ <shape android:shape="ring"
317
+ android:innerRadius="20dp"
318
+ android:thickness="5dp">
319
+ <solid android:color="#4CAF50"/>
320
+ <size android:width="50dp" android:height="50dp"/>
321
+ </shape>
322
+ ```
323
+
324
+ ```svg
325
+ <!-- SVG -->
326
+ <svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 50 50">
327
+ <circle cx="25" cy="25" r="22.5"
328
+ fill="none" stroke="#4CAF50" stroke-width="5"/>
329
+ </svg>
330
+ ```
331
+
332
+ - Ring center radius = `innerRadius + thickness/2`
333
+ - SVG stroke-width = `thickness`
334
+ - If `android:innerRadiusRatio` is used instead of `android:innerRadius`: `innerRadius = width / (2 * innerRadiusRatio)`
335
+ - If `android:thicknessRatio` is used: `thickness = width / (2 * thicknessRatio)`
336
+
337
+ ### Shape Size Handling
338
+
339
+ If `<size>` is not specified, use a sensible default (e.g., `24x24`) and note in the report that the original had no explicit size. The SVG `viewBox` should match the dimensions.
340
+
341
+ ---
342
+
343
+ ## Gradient Conversion
344
+
345
+ Android shapes and vector drawables can use gradients for fill or stroke colors.
346
+
347
+ ### Linear Gradient
348
+
349
+ ```xml
350
+ <!-- Android (in shape) -->
351
+ <gradient
352
+ android:type="linear"
353
+ android:startColor="#FF0000"
354
+ android:centerColor="#00FF00"
355
+ android:endColor="#0000FF"
356
+ android:angle="45"/>
357
+ ```
358
+
359
+ ```svg
360
+ <!-- SVG -->
361
+ <defs>
362
+ <linearGradient id="grad_1" x1="0%" y1="100%" x2="100%" y2="0%">
363
+ <stop offset="0%" stop-color="#FF0000"/>
364
+ <stop offset="50%" stop-color="#00FF00"/>
365
+ <stop offset="100%" stop-color="#0000FF"/>
366
+ </linearGradient>
367
+ </defs>
368
+ <rect ... fill="url(#grad_1)"/>
369
+ ```
370
+
371
+ **Angle to coordinates mapping:**
372
+
373
+ | Android `angle` | SVG `x1,y1 → x2,y2` |
374
+ |---|---|
375
+ | 0 (left→right) | `0%,0% → 100%,0%` |
376
+ | 45 (bottom-left→top-right) | `0%,100% → 100%,0%` |
377
+ | 90 (bottom→top) | `0%,100% → 0%,0%` |
378
+ | 135 (bottom-right→top-left) | `100%,100% → 0%,0%` |
379
+ | 180 (right→left) | `100%,0% → 0%,0%` |
380
+ | 225 (top-right→bottom-left) | `100%,0% → 0%,100%` |
381
+ | 270 (top→bottom) | `0%,0% → 0%,100%` |
382
+ | 315 (top-left→bottom-right) | `0%,0% → 100%,100%` |
383
+
384
+ Android `angle` must be a multiple of 45. For other values, calculate:
385
+ - `x1 = 50 + 50*cos(angle+180)`, `y1 = 50 - 50*sin(angle+180)`
386
+ - `x2 = 50 + 50*cos(angle)`, `y2 = 50 - 50*sin(angle)`
387
+
388
+ ### Radial Gradient
389
+
390
+ ```xml
391
+ <!-- Android -->
392
+ <gradient
393
+ android:type="radial"
394
+ android:centerX="0.5"
395
+ android:centerY="0.5"
396
+ android:gradientRadius="50%p"
397
+ android:startColor="#FFFFFF"
398
+ android:endColor="#000000"/>
399
+ ```
400
+
401
+ ```svg
402
+ <!-- SVG -->
403
+ <defs>
404
+ <radialGradient id="grad_2" cx="50%" cy="50%" r="50%">
405
+ <stop offset="0%" stop-color="#FFFFFF"/>
406
+ <stop offset="100%" stop-color="#000000"/>
407
+ </radialGradient>
408
+ </defs>
409
+ ```
410
+
411
+ - `centerX`/`centerY` are fractions (0.0–1.0) → convert to percentages
412
+ - `gradientRadius` with `%p` suffix → percentage of parent dimension
413
+
414
+ ### Sweep Gradient
415
+
416
+ ```xml
417
+ <!-- Android -->
418
+ <gradient
419
+ android:type="sweep"
420
+ android:centerX="0.5"
421
+ android:centerY="0.5"
422
+ android:startColor="#FF0000"
423
+ android:endColor="#0000FF"/>
424
+ ```
425
+
426
+ SVG doesn't have a native sweep/conic gradient in SVG 1.1. Options:
427
+ 1. Use CSS `conic-gradient` if targeting modern renderers (but not SVG 1.1 compliant)
428
+ 2. Approximate with a series of `<path>` segments in a radial pattern
429
+ 3. Log as partially converted and note that sweep gradient was approximated
430
+
431
+ Recommended: convert to a `<linearGradient>` as an approximation and log in the report that the original was a sweep gradient.
432
+
433
+ ### Gradient in VectorDrawable Paths
434
+
435
+ Android API 24+ supports `<aapt:attr>` inline gradient in vector drawables:
436
+
437
+ ```xml
438
+ <path android:pathData="...">
439
+ <aapt:attr name="android:fillColor">
440
+ <gradient android:type="linear" .../>
441
+ </aapt:attr>
442
+ </path>
443
+ ```
444
+
445
+ Convert the gradient to an SVG `<linearGradient>` in `<defs>` and reference via `fill="url(#grad_id)"`.
446
+
447
+ ---
448
+
449
+ ## LayerList Conversion
450
+
451
+ `<layer-list>` stacks multiple drawable items. Each `<item>` can contain a `<shape>`, a `<bitmap>`, or reference another drawable.
452
+
453
+ ```xml
454
+ <!-- Android -->
455
+ <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
456
+ <item>
457
+ <shape android:shape="rectangle">
458
+ <solid android:color="#CCCCCC"/>
459
+ <corners android:radius="4dp"/>
460
+ </shape>
461
+ </item>
462
+ <item android:left="2dp" android:top="2dp"
463
+ android:right="2dp" android:bottom="2dp">
464
+ <shape android:shape="rectangle">
465
+ <solid android:color="#FFFFFF"/>
466
+ <corners android:radius="2dp"/>
467
+ </shape>
468
+ </item>
469
+ </layer-list>
470
+ ```
471
+
472
+ ```svg
473
+ <!-- SVG -->
474
+ <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100">
475
+ <!-- Layer 0: background -->
476
+ <rect x="0" y="0" width="100" height="100" rx="4" ry="4" fill="#CCCCCC"/>
477
+ <!-- Layer 1: foreground with insets -->
478
+ <rect x="2" y="2" width="96" height="96" rx="2" ry="2" fill="#FFFFFF"/>
479
+ </svg>
480
+ ```
481
+
482
+ ### Rules
483
+
484
+ - Items are rendered in document order (first item = bottom layer)
485
+ - `android:left/top/right/bottom` on `<item>` → inset the element's position and reduce its size accordingly
486
+ - `android:width/height` on `<item>` → explicit size override
487
+ - `android:gravity` on `<item>` → position within the layer bounds
488
+ - If an `<item>` references another drawable via `android:drawable="@drawable/other"`, try to resolve and inline it; if not resolvable, log in report
489
+ - For layer-lists without explicit `<size>`, use a default canvas of `100x100` and note in report
490
+
491
+ ---
492
+
493
+ ## Selector / StateList Conversion
494
+
495
+ `<selector>` defines different drawables for different UI states (pressed, focused, disabled, etc.). SVG is static, so we extract the most useful representation.
496
+
497
+ ```xml
498
+ <!-- Android -->
499
+ <selector xmlns:android="http://schemas.android.com/apk/res/android">
500
+ <item android:state_pressed="true">
501
+ <shape android:shape="rectangle">
502
+ <solid android:color="#E0E0E0"/>
503
+ <corners android:radius="4dp"/>
504
+ </shape>
505
+ </item>
506
+ <item android:state_focused="true">
507
+ <shape android:shape="rectangle">
508
+ <solid android:color="#F0F0F0"/>
509
+ <corners android:radius="4dp"/>
510
+ </shape>
511
+ </item>
512
+ <item>
513
+ <shape android:shape="rectangle">
514
+ <solid android:color="#FFFFFF"/>
515
+ <corners android:radius="4dp"/>
516
+ </shape>
517
+ </item>
518
+ </selector>
519
+ ```
520
+
521
+ ### Conversion Strategy
522
+
523
+ 1. Find the **default item** — the `<item>` with no `android:state_*` attributes (or the last item, which serves as the default in Android)
524
+ 2. Convert that single item to SVG using the appropriate rules (shape → SVG, vector → SVG, etc.)
525
+ 3. In the conversion report, list all the state variants that were dropped:
526
+ - `state_pressed`, `state_focused`, `state_selected`, `state_checked`, `state_enabled`, `state_activated`, `state_hovered`
527
+ 4. Note that HarmonyOS state handling should be done in ArkUI component code, not in resource files
528
+
529
+ ---
530
+
531
+ ## Common Attribute Mapping
532
+
533
+ ### Android `android:` namespace to SVG
534
+
535
+ | Android Attribute | SVG Equivalent | Notes |
536
+ |---|---|---|
537
+ | `android:fillColor` | `fill` | Convert color format |
538
+ | `android:strokeColor` | `stroke` | Convert color format |
539
+ | `android:strokeWidth` | `stroke-width` | Strip `dp` |
540
+ | `android:alpha` | `opacity` | 0.0-1.0 range |
541
+ | `android:fillAlpha` | `fill-opacity` | 0.0-1.0 range |
542
+ | `android:strokeAlpha` | `stroke-opacity` | 0.0-1.0 range |
543
+ | `android:rotation` | `transform="rotate(deg)"` | In `<group>` |
544
+ | `android:scaleX/Y` | `transform="scale(x,y)"` | In `<group>` |
545
+ | `android:translateX/Y` | `transform="translate(x,y)"` | In `<group>` |
546
+
547
+ ### Default Values
548
+
549
+ If an Android drawable doesn't specify certain attributes, use these defaults:
550
+ - `strokeWidth`: `0` (no stroke)
551
+ - `alpha`: `1.0`
552
+ - `fillType`: `nonZero`
553
+ - `fillColor`: see the three-branch rule below — **never blanket-default it to black**
554
+
555
+ #### `fill` on `<path>`: three branches, decided per path
556
+
557
+ An omitted `android:fillColor` does **not** always mean black. Because SVG's own `fill`
558
+ default *is* black, writing `fill="#000000"` where Android meant "no fill" silently turns a
559
+ stroke-only outline into a solid black blob. Decide per `<path>`:
560
+
561
+ | Android `<path>` has | Emit | Why |
562
+ |---|---|---|
563
+ | `fillColor` (with or without `strokeColor`) | `fill="<converted color>"` | Explicit fill; convert per the color-format table |
564
+ | **no `fillColor`, but has `strokeColor`** | **`fill="none"`** (required, explicit) | Stroke-only geometry. Omitting `fill` — or worse, emitting `fill="#000000"` — fills the outline solid |
565
+ | neither `fillColor` nor `strokeColor` | `fill="#000000"` | Matches the Android platform default for an otherwise unpainted path |
566
+
567
+ Rule of thumb: in SVG, *omitting* `fill` and *writing black* are equivalent, so `fill="none"`
568
+ must be emitted **explicitly** for stroke-only paths. This applies per path, not per file — one
569
+ `<vector>` may legitimately mix filled and stroke-only paths.
570
+
571
+ Icons built as "white/colored outline on transparent background" are the common case that this
572
+ branch protects; they are widespread in Material-style icon sets, so a blanket black default
573
+ tends to corrupt many files at once rather than just one.
574
+
575
+ ---
576
+
577
+ ## Unconvertible Types
578
+
579
+ These XML drawable types cannot be meaningfully converted to SVG and should be logged as unmappable in the conversion report:
580
+
581
+ | Type | Root Element | Reason |
582
+ |---|---|---|
583
+ | Ripple | `<ripple>` | Runtime touch feedback animation |
584
+ | Animated Vector | `<animated-vector>` | Requires animation timing/interpolation |
585
+ | Animated Selector | `<animated-selector>` | State transitions with animations |
586
+ | Transition Drawable | `<transition>` | Cross-fade between two drawables |
587
+ | Inset Drawable | `<inset>` | Simple wrapper; if inner drawable is convertible, convert that instead |
588
+ | Scale Drawable | `<scale>` | Runtime scaling behavior |
589
+ | Rotate Drawable | `<rotate>` | Runtime rotation; could be converted as static rotation if angle is fixed |
590
+ | Level List | `<level-list>` | Runtime level-based selection |
591
+
592
+ For `<inset>` and `<rotate>` with fixed values, attempt conversion by applying the inset/rotation statically and convert the inner drawable. Log in the report either way.