IconShapeOverride源码
时间: 2023-11-25 17:08:36 浏览: 42
IconShapeOverride是一个可以修改应用图标形状的库,它通过使用自定义的图形路径来替换应用默认的圆形图标。以下是IconShapeOverride的源码:
```java
public class IconShapeOverride {
private static final String TAG = IconShapeOverride.class.getSimpleName();
private static final String KEY_PREFERENCE = "icon_shape_override";
private static final String KEY_SHAPE = "shape";
private static final String SHAPE_CIRCLE = "circle";
private static final String SHAPE_SQUARE = "square";
private static final String SHAPE_ROUNDED_SQUARE = "rounded_square";
private static final String PACKAGE_SYSTEMUI = "com.android.systemui";
private static final String CLASS_ICON_CONTROLLER = "com.android.systemui.statusbar.phone.StatusBarIconController";
private static final String METHOD_GET_ICON = "getIcon";
private static final String METHOD_SET_ICON = "setIcon";
private static final String PACKAGE_NOVA_LAUNCHER = "com.teslacoilsw.launcher";
private static final String CLASS_LAUNCHER = "com.teslacoilsw.launcher.Launcher";
private static final String FIELD_ICON_CACHE = "mIconCache";
private static final String METHOD_CREATE_ICON = "createIcon";
public enum Shape {
CIRCLE,
SQUARE,
ROUNDED_SQUARE
}
private static Shape sCurrentShape = Shape.CIRCLE;
/**
* Sets the shape of all icons in the system.
*
* @param context Application context.
* @param shape The new shape to use.
*/
public static void setIconShape(Context context, Shape shape) {
if (sCurrentShape == shape