FileDocCategorySizeDatePackage
BrandingResources.javaAPI DocAndroid 1.5 API5638Wed May 06 22:42:48 BST 2009com.android.providers.im

BrandingResources

public class BrandingResources extends Object
The provider specific branding resources.

Fields Summary
private static final String
TAG
private static final boolean
LOCAL_DEBUG
private Map
mResMapping
private android.content.res.Resources
mPackageRes
private BrandingResources
mDefaultRes
Constructors Summary
public BrandingResources(android.content.Context context, LandingPage.PluginInfo pluginInfo, String provider, BrandingResources defaultRes)
Creates a new BrandingResource of a specific plug-in. The resources will be retrieved from the plug-in package.

param
context The current application context.
param
pluginInfo The info about the plug-in.
param
provider the name of the IM service provider.
param
defaultRes The default branding resources. If the resource is not found in the plug-in, the default resource will be returned.


                                                                                
          
              
        String packageName = null;
        mDefaultRes = defaultRes;

        try {
            mResMapping = pluginInfo.mPlugin.getResourceMapForProvider(provider);
            packageName = pluginInfo.mPlugin.getResourcePackageNameForProvider(provider);
        } catch (RemoteException e) {
            Log.e(TAG, "Failed load the plugin resource map", e);
        }

        if (packageName == null) {
            packageName = pluginInfo.mPackageName;
        }

        PackageManager pm = context.getPackageManager();
        try {
            if (LOCAL_DEBUG) log("load resources from " + packageName);
            mPackageRes = pm.getResourcesForApplication(packageName);
        } catch (NameNotFoundException e) {
            Log.e(TAG, "Can not load resources from " + packageName);
        }
    
public BrandingResources(android.content.Context context, Map resMapping, BrandingResources defaultRes)
Creates a BrandingResource with application context and the resource ID map. The resource will be retrieved from the context directly instead from the plug-in package.

param
context
param
resMapping

        mPackageRes = context.getResources();
        mResMapping = resMapping;
        mDefaultRes = defaultRes;
    
Methods Summary
public android.graphics.drawable.DrawablegetDrawable(int id)
Gets a drawable object associated with a particular resource ID defined in {@link com.android.im.plugin.BrandingResourceIDs}

param
id The ID defined in {@link com.android.im.plugin.BrandingResourceIDs}
return
Drawable An object that can be used to draw this resource.

        int resId = getPackageResourceId(id);
        if (resId != 0) {
            return mPackageRes.getDrawable(resId);
        } else if (mDefaultRes != null){
            return mDefaultRes.getDrawable(id);
        } else {
            return null;
        }
    
private intgetPackageResourceId(int id)

        if (mResMapping == null || mPackageRes == null) {
            return 0;
        }
        Integer resId = mResMapping.get(id);
        return resId == null ? 0 : resId;
    
public java.lang.StringgetString(int id, java.lang.Object formatArgs)
Gets the string value associated with a particular resource ID defined in {@link com.android.im.plugin.BrandingResourceIDs}

param
id The ID of the string resource defined in {@link com.android.im.plugin.BrandingResourceIDs}
param
formatArgs The format arguments that will be used for substitution.
return
The string data associated with the resource

        int resId = getPackageResourceId(id);
        if (resId != 0) {
            return mPackageRes.getString(resId, formatArgs);
        } else if (mDefaultRes != null){
            return  mDefaultRes.getString(id, formatArgs);
        } else {
            return null;
        }
    
public java.lang.String[]getStringArray(int id)
Gets the string array associated with a particular resource ID defined in {@link com.android.im.plugin.BrandingResourceIDs}

param
id The ID of the string resource defined in {@link com.android.im.plugin.BrandingResourceIDs}
return
The string array associated with the resource.

        int resId = getPackageResourceId(id);
        if (resId != 0) {
            return mPackageRes.getStringArray(resId);
        } else if (mDefaultRes != null){
            return mDefaultRes.getStringArray(id);
        } else {
            return null;
        }
    
private voidlog(java.lang.String msg)

        Log.d(TAG, "[BrandingRes] " + msg);