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

Commit d6bec452 authored by Nicole Huang's avatar Nicole Huang
Browse files

Support the icon on suggestion card to be changed during run-time.

Setupwizard will try to override the icon on setting suggetion card
runtime. Suport to read the icon from overlaydata bundle.

bug: 110588815
Test: Manually tested and verified
Change-Id: I3e3c7b00113a34649b4c103b7da1aaf79ec2f57e
parent 0b229f87
Loading
Loading
Loading
Loading
+19 −8
Original line number Diff line number Diff line
@@ -182,6 +182,8 @@ public class CandidateSuggestion {
                // First get override data
                final Bundle overrideData = getOverrideData(metaData);
                // Get icon
                icon = getIconFromBundle(overrideData, META_DATA_PREFERENCE_ICON);
                if (icon == null) {
                    if (metaData.containsKey(META_DATA_PREFERENCE_ICON)) {
                        iconRes = metaData.getInt(META_DATA_PREFERENCE_ICON);
                    } else {
@@ -191,6 +193,7 @@ public class CandidateSuggestion {
                        icon = Icon.createWithResource(
                                mResolveInfo.activityInfo.packageName, iconRes);
                    }
                }
                // Get title
                title = getStringFromBundle(overrideData, META_DATA_PREFERENCE_TITLE);
                if (TextUtils.isEmpty(title) && metaData.containsKey(META_DATA_PREFERENCE_TITLE)) {
@@ -241,6 +244,14 @@ public class CandidateSuggestion {
        return bundle.getString(key);
    }

    /** Extracts an Icon object from bundle. */
    private Icon getIconFromBundle(Bundle bundle, String key) {
        if (bundle == null || TextUtils.isEmpty(key)) {
            return null;
        }
        return bundle.getParcelable(key);
    }

    private Bundle getOverrideData(Bundle metadata) {
        if (metadata == null || !metadata.containsKey(META_DATA_PREFERENCE_SUMMARY_URI)) {
            Log.d(TAG, "Metadata null or has no info about summary_uri");