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

Commit f603da9f authored by Danny Baumann's avatar Danny Baumann
Browse files

Navring: Fix shortcut for uninstalled app

Fix NPE when the user uninstalls an app that was assigned to a navring
shortcut before.

Change-Id: I3f02fca73cb30e2edbb35d089ad127b35d8233c0
parent da062dc6
Loading
Loading
Loading
Loading
+27 −19
Original line number Diff line number Diff line
@@ -134,7 +134,24 @@ public class NavigationRingHelpers {
                PackageManager pm = context.getPackageManager();
                ActivityInfo info = intent.resolveActivityInfo(pm, PackageManager.GET_ACTIVITIES);

                Drawable activityIcon = info.loadIcon(pm);
                if (info != null) {
                    return createDrawableForActivity(res, info.loadIcon(pm));
                }
            } catch (URISyntaxException e) {
                // treat as empty
            }

            resourceId = com.android.internal.R.drawable.ic_navigation_ring_empty;
        }

        TargetDrawable drawable = new TargetDrawable(res, resourceId);
        if (resourceId == com.android.internal.R.drawable.ic_navigation_ring_empty) {
            drawable.setEnabled(false);
        }
        return drawable;
    }

    private static TargetDrawable createDrawableForActivity(Resources res, Drawable activityIcon) {
        Drawable iconBg = res.getDrawable(
                com.android.internal.R.drawable.ic_navigation_ring_blank_normal);
        Drawable iconBgActivated = res.getDrawable(
@@ -151,17 +168,8 @@ public class NavigationRingHelpers {
        selector.addState(TargetDrawable.STATE_INACTIVE, icon);
        selector.addState(TargetDrawable.STATE_ACTIVE, iconActivated);
        selector.addState(TargetDrawable.STATE_FOCUSED, iconActivated);
                return new TargetDrawable(res, selector);
            } catch (URISyntaxException e) {
                resourceId = com.android.internal.R.drawable.ic_navigation_ring_empty;
            }
        }

        TargetDrawable drawable = new TargetDrawable(res, resourceId);
        if (resourceId == com.android.internal.R.drawable.ic_navigation_ring_empty) {
            drawable.setEnabled(false);
        }
        return drawable;
        return new TargetDrawable(res, selector);
    }

    private static int getVibrateDrawableResId(Context context) {