1fbb876392608a36ec1d23704f29d8b46d5d23991Daniel Lehmann/* 2fbb876392608a36ec1d23704f29d8b46d5d23991Daniel Lehmann * Copyright (C) 2011 The Android Open Source Project 3fbb876392608a36ec1d23704f29d8b46d5d23991Daniel Lehmann * 4fbb876392608a36ec1d23704f29d8b46d5d23991Daniel Lehmann * Licensed under the Apache License, Version 2.0 (the "License"); 5fbb876392608a36ec1d23704f29d8b46d5d23991Daniel Lehmann * you may not use this file except in compliance with the License. 6fbb876392608a36ec1d23704f29d8b46d5d23991Daniel Lehmann * You may obtain a copy of the License at 7fbb876392608a36ec1d23704f29d8b46d5d23991Daniel Lehmann * 8fbb876392608a36ec1d23704f29d8b46d5d23991Daniel Lehmann * http://www.apache.org/licenses/LICENSE-2.0 9fbb876392608a36ec1d23704f29d8b46d5d23991Daniel Lehmann * 10fbb876392608a36ec1d23704f29d8b46d5d23991Daniel Lehmann * Unless required by applicable law or agreed to in writing, software 11fbb876392608a36ec1d23704f29d8b46d5d23991Daniel Lehmann * distributed under the License is distributed on an "AS IS" BASIS, 12fbb876392608a36ec1d23704f29d8b46d5d23991Daniel Lehmann * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13fbb876392608a36ec1d23704f29d8b46d5d23991Daniel Lehmann * See the License for the specific language governing permissions and 14fbb876392608a36ec1d23704f29d8b46d5d23991Daniel Lehmann * limitations under the License. 15fbb876392608a36ec1d23704f29d8b46d5d23991Daniel Lehmann */ 16fbb876392608a36ec1d23704f29d8b46d5d23991Daniel Lehmann 1779c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmannpackage com.android.contacts.util; 1879c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann 1979c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmannimport android.content.res.Resources.Theme; 2079c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmannimport android.util.TypedValue; 2179c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann 2279c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann/** 2379c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann * Provides static functions to more easily resolve attributes of the current theme 2479c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann */ 2579c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmannpublic class ThemeUtils { 2679c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann /** 2791d8e892d549bbeba721cb434163a83bc99330a9Dmitri Plotnikov * Resolves the given attribute id of the theme to a resource id 2879c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann */ 2979c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann public static int getAttribute(Theme theme, int attrId) { 3079c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann final TypedValue outValue = new TypedValue(); 3179c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann theme.resolveAttribute(attrId, outValue, true); 3279c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann return outValue.resourceId; 3379c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann } 3479c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann 3579c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann /** 3691d8e892d549bbeba721cb434163a83bc99330a9Dmitri Plotnikov * Returns the resource id of the background used for buttons to show pressed and focused state 3779c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann */ 3879c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann public static int getSelectableItemBackground(Theme theme) { 3979c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann return getAttribute(theme, android.R.attr.selectableItemBackground); 4079c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann } 4168d8da77cd7b71516cd6a32bdfb491bbdc9929fcDmitri Plotnikov 4268d8da77cd7b71516cd6a32bdfb491bbdc9929fcDmitri Plotnikov /** 4368d8da77cd7b71516cd6a32bdfb491bbdc9929fcDmitri Plotnikov * Returns the resource id of the background used for list items that show activated background 4468d8da77cd7b71516cd6a32bdfb491bbdc9929fcDmitri Plotnikov */ 4568d8da77cd7b71516cd6a32bdfb491bbdc9929fcDmitri Plotnikov public static int getActivatedBackground(Theme theme) { 4668d8da77cd7b71516cd6a32bdfb491bbdc9929fcDmitri Plotnikov return getAttribute(theme, android.R.attr.activatedBackgroundIndicator); 4768d8da77cd7b71516cd6a32bdfb491bbdc9929fcDmitri Plotnikov } 4879c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann} 49