Android smali color codes quick reference

Discussion in 'Android Themes' started by raidzero, Sep 8, 2010.

  1. raidzero

    raidzero n00b.
    Theme Developer Premium Member Developer

    Joined:
    Apr 15, 2010
    Messages:
    1,054
    Likes Received:
    3
    Trophy Points:
    38
    Ratings:
    +3
    I found these in HtmlToSpannedConverter.smali:

    Code:
    aqua      = const 0xffffff
    black     = const/16 0x0
    blue      =    const 0xff
    fuschia    =const 0xff00ff
    green     = const 0x8000
    grey    = const 0x808080
    lime     = const 0xff00
    maroon     = const/high16 0x80
    navy     =  const 0x80
    olive     =const 0x808000
    purple     = const 0x800080
    red     = const/high16 0xff
    silver     = const 0xc0c0c0
    teal    = const 0x8080
    white     = const 0xffffff
    yellow     = const 0xffff00
    
    figured it might help some people who are trying to do smali color changes..

    ORIGINAL SMALI:
    Code:
    .line 826
        .local v0, map:Ljava/util/HashMap;,"Ljava/util/HashMap<Ljava/lang/String;Ljava/lang/Integer;>;"
        const-string v1, "aqua"
    
        const v2, 0xffff
    
        invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
    
        move-result-object v2
    
        invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    
        .line 827
        const-string v1, "black"
    
        const/4 v2, 0x0
    
        invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
    
        move-result-object v2
    
        invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    
        .line 828
        const-string v1, "blue"
    
        const/16 v2, 0xff
    
        invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
    
        move-result-object v2
    
        invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    
        .line 829
        const-string v1, "fuchsia"
    
        const v2, 0xff00ff
    
        invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
    
        move-result-object v2
    
        invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    
        .line 830
        const-string v1, "green"
    
        const v2, 0x8000
    
        invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
    
        move-result-object v2
    
        invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    
        .line 831
        const-string v1, "grey"
    
        const v2, 0x808080
    
        invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
    
        move-result-object v2
    
        invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    
        .line 832
        const-string v1, "lime"
    
        const v2, 0xff00
    
        invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
    
        move-result-object v2
    
        invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    
        .line 833
        const-string v1, "maroon"
    
        const/high16 v2, 0x80
    
        invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
    
        move-result-object v2
    
        invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    
        .line 834
        const-string v1, "navy"
    
        const/16 v2, 0x80
    
        invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
    
        move-result-object v2
    
        invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    
        .line 835
        const-string v1, "olive"
    
        const v2, 0x808000
    
        invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
    
        move-result-object v2
    
        invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    
        .line 836
        const-string v1, "purple"
    
        const v2, 0x800080
    
        invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
    
        move-result-object v2
    
        invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    
        .line 837
        const-string v1, "red"
    
        const/high16 v2, 0xff
    
        invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
    
        move-result-object v2
    
        invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    
        .line 838
        const-string v1, "silver"
    
        const v2, 0xc0c0c0
    
        invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
    
        move-result-object v2
    
        invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    
        .line 839
        const-string v1, "teal"
    
        const v2, 0x8080
    
        invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
    
        move-result-object v2
    
        invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    
        .line 840
        const-string v1, "white"
    
        const v2, 0xffffff
    
        invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
    
        move-result-object v2
    
        invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    
        .line 841
        const-string v1, "yellow"
    
        const v2, 0xffff00
    
        invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
    
        move-result-object v2
    
        invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    
    there are of course other ways to define a color using smali (changing high16 or /16 for example), but here are a few that are guaranteed to work.. you have to of course define the variable "register" (the v0, or v1, or v2, etc..)

    I confirmed these to be correct by comparing to Html.java:
    Code:
        private static HashMap<String,Integer> buildColorMap() {
            HashMap<String,Integer> map = new HashMap<String,Integer>();
            map.put("aqua", 0x00FFFF);
            map.put("black", 0x000000);
            map.put("blue", 0x0000FF);
            map.put("fuchsia", 0xFF00FF);
            map.put("green", 0x008000);
            map.put("grey", 0x808080);
            map.put("lime", 0x00FF00);
            map.put("maroon", 0x800000);
            map.put("navy", 0x000080);
            map.put("olive", 0x808000);
            map.put("purple", 0x800080);
            map.put("red", 0xFF0000);
            map.put("silver", 0xC0C0C0);
            map.put("teal", 0x008080);
            map.put("white", 0xFFFFFF);
            map.put("yellow", 0xFFFF00);
      return map;
    
    They are different because in smali they are written in 1's complement, which basically just inverts each digit:
    0 becomes f
    1 becomes e
    2 becomes d
    3 becomes c
    4 becomes b, and so on
     
    #1 raidzero, Sep 8, 2010
    Last edited: Sep 8, 2010
Search tags for this page
alchemy color codes
,

android color codes

,
android colour codes
,
android grey color code
,
kode hex smali
,
kode hex warna smali
,
kode warna smali
,
smali color
,
smali color code
,
smali color codes