v0.4.0: bubble for Android 0.4.0 — an inverted (lighter) icon, chosen in Settings on both
The original icon is a little dark: resources/icon-inverted.png and ic_launcher_inverted.png are its negative (alpha kept). - Desktop: Settings → Appearance → Icon (Dark / Inverted), saved on click; sets the window icon and rewrites the launcher's installed copy - Android: Settings → Icon; two launcher activity-aliases, one enabled
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user