package me.teafry.voipmessages; import android.content.ComponentName; import android.content.Context; import android.content.pm.PackageManager; /** * The launcher icon: the dark original or its negative (lighter), like the * desktop's Settings → Appearance → Icon. Each is its own launcher entry * (activity-alias); the choice is which one is enabled, so the launcher * itself remembers it. */ final class Icons { private Icons() {} private static ComponentName dark(Context c) { return new ComponentName(c, "me.teafry.voipmessages.LauncherDark"); } private static ComponentName inverted(Context c) { return new ComponentName(c, "me.teafry.voipmessages.LauncherInverted"); } static boolean isInverted(Context c) { return c.getPackageManager().getComponentEnabledSetting(inverted(c)) == PackageManager.COMPONENT_ENABLED_STATE_ENABLED; } static void setInverted(Context c, boolean on) { PackageManager pm = c.getPackageManager(); // The new entry first, so there's never a moment with no icon at all. pm.setComponentEnabledSetting(on ? inverted(c) : dark(c), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); pm.setComponentEnabledSetting(on ? dark(c) : inverted(c), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); } }