wrongwrongな開発日記

しんまいさんの忘備録

【Android】GitHubの言語ごとの色に対応するXMLを作る【Kotlin】

GitHubでは以下のように言語ごとに色が割り振られています。これをAndroidで利用したかったので、XML形式に変換しました。
f:id:wrongwrongwrongwrong163377:20180813165149p:plain

やりかた

以下に定義が有るので、これをローカルに持ってきて解析します。
https://raw.githubusercontent.com/hiroppy/github-language-color-themes/master/languages.json

結果

[ ,+-#]の5文字は使えないので、'_'で置換しました。
一方この内容はどうやら最新ではないようで、見つけた範囲ではKotlinの色が違ったりVim scriptが含まれていなかったりしました。

<color name="ABAP">#E8274B</color>
<color name="AGS_Script">#B9D9FF</color>
<color name="AMPL">#E6EFBB</color>
<color name="ANTLR">#9DC3FF</color>
<color name="API_Blueprint">#2ACCA8</color>
<color name="APL">#5A8164</color>
<color name="ASP">#6a40fd</color>
<color name="ATS">#1ac620</color>
<color name="ActionScript">#882B0F</color>
<color name="Ada">#02f88c</color>
<color name="Agda">#315665</color>
<color name="Alloy">#cc5c24</color>
<color name="Arc">#aa2afe</color>
<color name="Arduino">#bd79d1</color>
<color name="AspectJ">#a957b0</color>
<color name="Assembly">#6E4C13</color>
<color name="AutoHotkey">#6594b9</color>
<color name="AutoIt">#1C3552</color>
<color name="BlitzMax">#cd6400</color>
<color name="Boo">#d4bec1</color>
<color name="Brainfuck">#2F2530</color>
<color name="C">#555555</color>
<color name="C_">#178600</color>
<color name="C__">#f34b7d</color>
<color name="CSS">#563d7c</color>
<color name="Chapel">#8dc63f</color>
<color name="Cirru">#ccccff</color>
<color name="Clarion">#db901e</color>
<color name="Clean">#3F85AF</color>
<color name="Clojure">#db5855</color>
<color name="CoffeeScript">#244776</color>
<color name="ColdFusion">#ed2cd6</color>
<color name="ColdFusion_CFC">#ed2cd6</color>
<color name="Common_Lisp">#3fb68b</color>
<color name="Component_Pascal">#b0ce4e</color>
<color name="Crystal">#776791</color>
<color name="D">#fcd46d</color>
<color name="DM">#447265</color>
<color name="Dart">#00B4AB</color>
<color name="Diff">#88dddd</color>
<color name="Dogescript">#cca760</color>
<color name="Dylan">#6c616e</color>
<color name="E">#ccce35</color>
<color name="ECL">#8a1267</color>
<color name="Eagle">#814C05</color>
<color name="Eiffel">#946d57</color>
<color name="Elixir">#6e4a7e</color>
<color name="Elm">#60B5CC</color>
<color name="Emacs_Lisp">#c065db</color>
<color name="EmberScript">#FFF4F3</color>
<color name="Erlang">#B83998</color>
<color name="F_">#b845fc</color>
<color name="FLUX">#88ccff</color>
<color name="FORTRAN">#4d41b1</color>
<color name="Factor">#636746</color>
<color name="Fancy">#7b9db4</color>
<color name="Fantom">#dbded5</color>
<color name="Forth">#341708</color>
<color name="Frege">#00cafe</color>
<color name="Game_Maker_Language">#8fb200</color>
<color name="Glyph">#e4cc98</color>
<color name="Gnuplot">#f0a9f0</color>
<color name="Go">#375eab</color>
<color name="Golo">#88562A</color>
<color name="Gosu">#82937f</color>
<color name="Grammatical_Framework">#79aa7a</color>
<color name="Groovy">#e69f56</color>
<color name="HTML">#e44b23</color>
<color name="Handlebars">#01a9d6</color>
<color name="Harbour">#0e60e3</color>
<color name="Haskell">#29b544</color>
<color name="Haxe">#f7941e</color>
<color name="Hy">#7790B2</color>
<color name="IDL">#a3522f</color>
<color name="Io">#a9188d</color>
<color name="Ioke">#078193</color>
<color name="Isabelle">#FEFE00</color>
<color name="J">#9EEDFF</color>
<color name="JFlex">#DBCA00</color>
<color name="Java">#b07219</color>
<color name="JavaScript">#f1e05a</color>
<color name="Julia">#a270ba</color>
<color name="KRL">#28431f</color>
<color name="Kotlin">#EA4DFA</color>
<color name="LFE">#004200</color>
<color name="LOLCODE">#cc9900</color>
<color name="LSL">#3d9970</color>
<color name="Lasso">#999999</color>
<color name="Latte">#A8FF97</color>
<color name="LiveScript">#499886</color>
<color name="LookML">#652B81</color>
<color name="Lua">#000080</color>
<color name="MTML">#b7e1f4</color>
<color name="Makefile">#427819</color>
<color name="Mask">#f97732</color>
<color name="Matlab">#bb92ac</color>
<color name="Max">#c4a79c</color>
<color name="Mercury">#ff2b2b</color>
<color name="Mirah">#c7a938</color>
<color name="Nemerle">#3d3c6e</color>
<color name="NetLinx">#0aa0ff</color>
<color name="NetLinx_ERB">#747faa</color>
<color name="NetLogo">#ff6375</color>
<color name="NewLisp">#87AED7</color>
<color name="Nimrod">#37775b</color>
<color name="Nit">#009917</color>
<color name="Nix">#7e7eff</color>
<color name="Nu">#c9df40</color>
<color name="OCaml">#3be133</color>
<color name="Objective_C">#438eff</color>
<color name="Objective_C__">#6866fb</color>
<color name="Objective_J">#ff0c5a</color>
<color name="Omgrofl">#cabbff</color>
<color name="Opal">#f7ede0</color>
<color name="Oxygene">#cdd0e3</color>
<color name="Oz">#fab738</color>
<color name="PAWN">#dbb284</color>
<color name="PHP">#4F5D95</color>
<color name="Pan">#cc0000</color>
<color name="Papyrus">#6600cc</color>
<color name="Parrot">#f3ca0a</color>
<color name="Pascal">#b0ce4e</color>
<color name="Perl">#0298c3</color>
<color name="Perl6">#0000fb</color>
<color name="PigLatin">#fcd7de</color>
<color name="Pike">#005390</color>
<color name="PogoScript">#d80074</color>
<color name="Processing">#0096D8</color>
<color name="Prolog">#74283c</color>
<color name="Propeller_Spin">#7fa2a7</color>
<color name="Puppet">#332A77</color>
<color name="Pure_Data">#91de79</color>
<color name="PureBasic">#5a6986</color>
<color name="PureScript">#1D222D</color>
<color name="Python">#3572A5</color>
<color name="QML">#44a51c</color>
<color name="R">#198ce7</color>
<color name="RAML">#77d9fb</color>
<color name="Racket">#22228f</color>
<color name="Ragel_in_Ruby_Host">#e17600</color>
<color name="Rebol">#358a5b</color>
<color name="Red">#ee0000</color>
<color name="Rouge">#cc0088</color>
<color name="Ruby">#701516</color>
<color name="Rust">#dea584</color>
<color name="SAS">#B34936</color>
<color name="SQF">#3F3F3F</color>
<color name="SaltStack">#646464</color>
<color name="Scala">#7dd3b0</color>
<color name="Scheme">#1e4aec</color>
<color name="Self">#0579aa</color>
<color name="Shell">#89e051</color>
<color name="Shen">#120F14</color>
<color name="Slash">#007eff</color>
<color name="Slim">#ff8f77</color>
<color name="Smalltalk">#596706</color>
<color name="SourcePawn">#5c7611</color>
<color name="Squirrel">#800000</color>
<color name="Standard_ML">#dc566d</color>
<color name="SuperCollider">#46390b</color>
<color name="Swift">#ffac45</color>
<color name="SystemVerilog">#DAE1C2</color>
<color name="Tcl">#e4cc98</color>
<color name="TeX">#3D6117</color>
<color name="Turing">#45f715</color>
<color name="TypeScript">#2b7489</color>
<color name="Unified_Parallel_C">#4e3617</color>
<color name="UnrealScript">#a54c4d</color>
<color name="VHDL">#adb2cb</color>
<color name="Vala">#fbe5cd</color>
<color name="Verilog">#b2b7f8</color>
<color name="VimL">#199f4b</color>
<color name="Visual_Basic">#945db7</color>
<color name="Volt">#1F1F1F</color>
<color name="Web_Ontology_Language">#9cc9dd</color>
<color name="XC">#99DA07</color>
<color name="XQuery">#5232e7</color>
<color name="Zephir">#118f9e</color>
<color name="eC">#913960</color>
<color name="edn">#db5855</color>
<color name="nesC">#94B0C7</color>
<color name="ooc">#b0b77e</color>
<color name="wisp">#7582D1</color>
<color name="xBase">#403a40</color>