Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 81cd2e90 authored by Adam Powell's avatar Adam Powell
Browse files

Logo attribute for manifest and PackageManager methods to fetch it

Change-Id: I2c5ac44a4e2af982a616b2012901d7395013b19f
parent 1bdbb072
Loading
Loading
Loading
Loading
+150 −11
Original line number Diff line number Diff line
@@ -5938,17 +5938,6 @@
 visibility="public"
>
</field>
<field name="kraken_resource_pad67"
 type="int"
 transient="false"
 volatile="false"
 value="16843454"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="kraken_resource_pad7"
 type="int"
 transient="false"
@@ -6532,6 +6521,17 @@
 visibility="public"
>
</field>
<field name="logo"
 type="int"
 transient="false"
 volatile="false"
 value="16843454"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="longClickable"
 type="int"
 transient="false"
@@ -47502,6 +47502,19 @@
<parameter name="pm" type="android.content.pm.PackageManager">
</parameter>
</method>
<method name="loadLogo"
 return="android.graphics.drawable.Drawable"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="pm" type="android.content.pm.PackageManager">
</parameter>
</method>
<method name="loadXmlMetaData"
 return="android.content.res.XmlResourceParser"
 abstract="false"
@@ -47552,6 +47565,16 @@
 visibility="public"
>
</field>
<field name="logo"
 type="int"
 transient="false"
 volatile="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="metaData"
 type="android.os.Bundle"
 transient="false"
@@ -47834,6 +47857,36 @@
<exception name="PackageManager.NameNotFoundException" type="android.content.pm.PackageManager.NameNotFoundException">
</exception>
</method>
<method name="getActivityLogo"
 return="android.graphics.drawable.Drawable"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="activityName" type="android.content.ComponentName">
</parameter>
<exception name="PackageManager.NameNotFoundException" type="android.content.pm.PackageManager.NameNotFoundException">
</exception>
</method>
<method name="getActivityLogo"
 return="android.graphics.drawable.Drawable"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="intent" type="android.content.Intent">
</parameter>
<exception name="PackageManager.NameNotFoundException" type="android.content.pm.PackageManager.NameNotFoundException">
</exception>
</method>
<method name="getAllPermissionGroups"
 return="java.util.List&lt;android.content.pm.PermissionGroupInfo&gt;"
 abstract="true"
@@ -47918,6 +47971,34 @@
<parameter name="info" type="android.content.pm.ApplicationInfo">
</parameter>
</method>
<method name="getApplicationLogo"
 return="android.graphics.drawable.Drawable"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="info" type="android.content.pm.ApplicationInfo">
</parameter>
</method>
<method name="getApplicationLogo"
 return="android.graphics.drawable.Drawable"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="packageName" type="java.lang.String">
</parameter>
<exception name="PackageManager.NameNotFoundException" type="android.content.pm.PackageManager.NameNotFoundException">
</exception>
</method>
<method name="getComponentEnabledSetting"
 return="int"
 abstract="true"
@@ -152223,6 +152304,36 @@
<exception name="PackageManager.NameNotFoundException" type="android.content.pm.PackageManager.NameNotFoundException">
</exception>
</method>
<method name="getActivityLogo"
 return="android.graphics.drawable.Drawable"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="activityName" type="android.content.ComponentName">
</parameter>
<exception name="PackageManager.NameNotFoundException" type="android.content.pm.PackageManager.NameNotFoundException">
</exception>
</method>
<method name="getActivityLogo"
 return="android.graphics.drawable.Drawable"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="intent" type="android.content.Intent">
</parameter>
<exception name="PackageManager.NameNotFoundException" type="android.content.pm.PackageManager.NameNotFoundException">
</exception>
</method>
<method name="getAllPermissionGroups"
 return="java.util.List&lt;android.content.pm.PermissionGroupInfo&gt;"
 abstract="false"
@@ -152307,6 +152418,34 @@
<parameter name="info" type="android.content.pm.ApplicationInfo">
</parameter>
</method>
<method name="getApplicationLogo"
 return="android.graphics.drawable.Drawable"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="info" type="android.content.pm.ApplicationInfo">
</parameter>
</method>
<method name="getApplicationLogo"
 return="android.graphics.drawable.Drawable"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="packageName" type="java.lang.String">
</parameter>
<exception name="PackageManager.NameNotFoundException" type="android.content.pm.PackageManager.NameNotFoundException">
</exception>
</method>
<method name="getComponentEnabledSetting"
 return="int"
 abstract="false"
+33 −0
Original line number Diff line number Diff line
@@ -2174,6 +2174,39 @@ class ContextImpl extends Context {
            return getApplicationIcon(getApplicationInfo(packageName, 0));
        }
        
        @Override 
        public Drawable getActivityLogo(ComponentName activityName)
                throws NameNotFoundException {
            return getActivityInfo(activityName, 0).loadLogo(this);
        }

        @Override
        public Drawable getActivityLogo(Intent intent)
                throws NameNotFoundException {
            if (intent.getComponent() != null) {
                return getActivityLogo(intent.getComponent());
            }

            ResolveInfo info = resolveActivity(
                    intent, PackageManager.MATCH_DEFAULT_ONLY);
            if (info != null) {
                return info.activityInfo.loadLogo(this);
            }

            throw new NameNotFoundException(intent.toUri(0));
        }

        @Override
        public Drawable getApplicationLogo(ApplicationInfo info) {
            return info.loadLogo(this);
        }

        @Override
        public Drawable getApplicationLogo(String packageName)
                throws NameNotFoundException {
            return getApplicationLogo(getApplicationInfo(packageName, 0));
        }

        @Override public Resources getResourcesForActivity(
                ComponentName activityName) throws NameNotFoundException {
            return getResourcesForApplication(
+8 −0
Original line number Diff line number Diff line
@@ -154,6 +154,14 @@ public class ComponentInfo extends PackageItemInfo {
        return applicationInfo.loadIcon(pm);
    }
    
    /**
     * @hide
     */
    @Override
    protected Drawable loadDefaultLogo(PackageManager pm) {
        return applicationInfo.loadLogo(pm);
    }
    
    /**
     * @hide
     */
+47 −0
Original line number Diff line number Diff line
@@ -66,6 +66,14 @@ public class PackageItemInfo {
     */
    public int icon;
    
    /**
     * A drawable resource identifier (in the package's resources) of this
     * component's logo. Logos may be larger/wider than icons and are
     * displayed by certain UI elements in place of a name or name/icon
     * combination. From the "logo" attribute or, if not set, 0. 
     */
    public int logo;
    
    /**
     * Additional meta-data associated with this component.  This field
     * will only be filled in if you set the
@@ -84,6 +92,7 @@ public class PackageItemInfo {
        nonLocalizedLabel = orig.nonLocalizedLabel;
        if (nonLocalizedLabel != null) nonLocalizedLabel = nonLocalizedLabel.toString().trim();
        icon = orig.icon;
        logo = orig.logo;
        metaData = orig.metaData;
    }

@@ -151,6 +160,42 @@ public class PackageItemInfo {
        return pm.getDefaultActivityIcon();
    }
    
    /**
     * Retrieve the current graphical logo associated with this item. This
     * will call back on the given PackageManager to load the logo from
     * the application.
     * 
     * @param pm A PackageManager from which the logo can be loaded; usually
     * the PackageManager from which you originally retrieved this item.
     * 
     * @return Returns a Drawable containing the item's logo. If the item
     * does not have a logo, this method will return null.
     */
    public Drawable loadLogo(PackageManager pm) {
        if (logo != 0) {
            Drawable d = pm.getDrawable(packageName, logo, getApplicationInfo());
            if (d != null) {
                return d;
            }
        }
        return loadDefaultLogo(pm);
    }
    
    /**
     * Retrieve the default graphical logo associated with this item.
     * 
     * @param pm A PackageManager from which the logo can be loaded; usually
     * the PackageManager from which you originally retrieved this item.
     * 
     * @return Returns a Drawable containing the item's default logo
     * or null if no default logo is available.
     * 
     * @hide
     */
    protected Drawable loadDefaultLogo(PackageManager pm) {
        return null;
    }
    
    /**
     * Load an XML resource attached to the meta-data of this item.  This will
     * retrieved the name meta-data entry, and if defined call back on the
@@ -196,6 +241,7 @@ public class PackageItemInfo {
        dest.writeInt(labelRes);
        TextUtils.writeToParcel(nonLocalizedLabel, dest, parcelableFlags);
        dest.writeInt(icon);
        dest.writeInt(logo);
        dest.writeBundle(metaData);
    }
    
@@ -206,6 +252,7 @@ public class PackageItemInfo {
        nonLocalizedLabel
                = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
        icon = source.readInt();
        logo = source.readInt();
        metaData = source.readBundle();
    }

+73 −0
Original line number Diff line number Diff line
@@ -1596,6 +1596,79 @@ public abstract class PackageManager {
    public abstract Drawable getApplicationIcon(String packageName)
            throws NameNotFoundException;

    /**
     * Retrieve the logo associated with an activity.  Given the full name of
     * an activity, retrieves the information about it and calls
     * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its logo.
     * If the activity can not be found, NameNotFoundException is thrown.
     *
     * @param activityName Name of the activity whose logo is to be retrieved.
     *
     * @return Returns the image of the logo or null if the activity has no
     * logo specified.
     * 
     * @throws NameNotFoundException Thrown if the resources for the given
     * activity could not be loaded.
     *
     * @see #getActivityLogo(Intent)
     */
    public abstract Drawable getActivityLogo(ComponentName activityName)
            throws NameNotFoundException;

    /**
     * Retrieve the logo associated with an Intent.  If intent.getClassName() is
     * set, this simply returns the result of
     * getActivityLogo(intent.getClassName()).  Otherwise it resolves the intent's
     * component and returns the logo associated with the resolved component.
     * If intent.getClassName() can not be found or the Intent can not be resolved
     * to a component, NameNotFoundException is thrown.
     *
     * @param intent The intent for which you would like to retrieve a logo.
     *
     * @return Returns the image of the logo, or null if the activity has no
     * logo specified.
     * 
     * @throws NameNotFoundException Thrown if the resources for application
     * matching the given intent could not be loaded.
     *
     * @see #getActivityLogo(ComponentName)
     */
    public abstract Drawable getActivityLogo(Intent intent)
            throws NameNotFoundException;

    /**
     * Retrieve the logo associated with an application.  If it has not specified
     * a logo, this method returns null.
     *
     * @param info Information about application being queried.
     *
     * @return Returns the image of the logo, or null if no logo is specified
     * by the application.
     *
     * @see #getApplicationLogo(String)
     */
    public abstract Drawable getApplicationLogo(ApplicationInfo info);

    /**
     * Retrieve the logo associated with an application.  Given the name of the
     * application's package, retrieves the information about it and calls
     * getApplicationLogo() to return its logo. If the application can not be
     * found, NameNotFoundException is thrown.
     *
     * @param packageName Name of the package whose application logo is to be
     *                    retrieved.
     *
     * @return Returns the image of the logo, or null if no application logo
     * has been specified.
     * 
     * @throws NameNotFoundException Thrown if the resources for the given
     * application could not be loaded.
     *
     * @see #getApplicationLogo(ApplicationInfo)
     */
    public abstract Drawable getApplicationLogo(String packageName)
            throws NameNotFoundException;

    /**
     * Retrieve text from a package.  This is a low-level API used by
     * the various package manager info structures (such as
Loading