ThemeUtils.java revision 68d8da77cd7b71516cd6a32bdfb491bbdc9929fc
179c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmannpackage com.android.contacts.util; 279c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann 379c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmannimport android.content.res.Resources.Theme; 479c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmannimport android.util.TypedValue; 579c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann 679c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann/** 779c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann * Provides static functions to more easily resolve attributes of the current theme 879c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann */ 979c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmannpublic class ThemeUtils { 1079c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann /** 1191d8e892d549bbeba721cb434163a83bc99330a9Dmitri Plotnikov * Resolves the given attribute id of the theme to a resource id 1279c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann */ 1379c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann public static int getAttribute(Theme theme, int attrId) { 1479c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann final TypedValue outValue = new TypedValue(); 1579c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann theme.resolveAttribute(attrId, outValue, true); 1679c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann return outValue.resourceId; 1779c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann } 1879c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann 1979c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann /** 2091d8e892d549bbeba721cb434163a83bc99330a9Dmitri Plotnikov * Returns the resource id of the background used for buttons to show pressed and focused state 2179c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann */ 2279c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann public static int getSelectableItemBackground(Theme theme) { 2379c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann return getAttribute(theme, android.R.attr.selectableItemBackground); 2479c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann } 2568d8da77cd7b71516cd6a32bdfb491bbdc9929fcDmitri Plotnikov 2668d8da77cd7b71516cd6a32bdfb491bbdc9929fcDmitri Plotnikov /** 2768d8da77cd7b71516cd6a32bdfb491bbdc9929fcDmitri Plotnikov * Returns the resource id of the background used for list items that show activated background 2868d8da77cd7b71516cd6a32bdfb491bbdc9929fcDmitri Plotnikov */ 2968d8da77cd7b71516cd6a32bdfb491bbdc9929fcDmitri Plotnikov public static int getActivatedBackground(Theme theme) { 3068d8da77cd7b71516cd6a32bdfb491bbdc9929fcDmitri Plotnikov return getAttribute(theme, android.R.attr.activatedBackgroundIndicator); 3168d8da77cd7b71516cd6a32bdfb491bbdc9929fcDmitri Plotnikov } 3279c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann} 33