public class

StyleInterface

extends Object
java.lang.Object
   ↳ lineageos.style.StyleInterface

Class Overview

Interface used to customize the System colors. It's capable of setting a global light and dark mode and custom color accents.

Summary

Constants
String ACCENT_DEFAULT Default accent name.
String CHANGE_STYLE_SETTINGS_PERMISSION Allows an application to change system style.
int STYLE_GLOBAL_AUTO_DAYTIME Global style: automatic (based on day time) mode
int STYLE_GLOBAL_AUTO_WALLPAPER Global style: automatic (based on wallpaper) mode
int STYLE_GLOBAL_DARK Global style: dark
int STYLE_GLOBAL_LIGHT Global style: light
Public Methods
String getAccent()
Get the current accent package.
int getGlobalStyle()
Get the current global style.
static StyleInterface getInstance(Context context)
Get or create an instance of the StyleInterface
Suggestion getSuggestion(Bitmap source, int[] colors)
Get the best color that suites a bitmap object and the appropriate global style
List<String> getTrustedAccents()
Get a list of trusted accents that are included in the build.
boolean setAccent(String pkgName)
Set color accent package.
boolean setGlobalStyle(int style, String pkgName)
Set global style.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String ACCENT_DEFAULT

added in API level 9

Default accent name. It can also be used to remove any active accent

See also:

Constant Value: "lineageos"

public static final String CHANGE_STYLE_SETTINGS_PERMISSION

added in API level 9

Allows an application to change system style. This is a dangerous permission, your app must request it at runtime as any other dangerous permission

Constant Value: "lineageos.permission.CHANGE_STYLE"

public static final int STYLE_GLOBAL_AUTO_DAYTIME

added in API level 9

Global style: automatic (based on day time) mode

Constant Value: 1 (0x00000001)

public static final int STYLE_GLOBAL_AUTO_WALLPAPER

added in API level 9

Global style: automatic (based on wallpaper) mode

Constant Value: 0 (0x00000000)

public static final int STYLE_GLOBAL_DARK

added in API level 9

Global style: dark

Constant Value: 3 (0x00000003)

public static final int STYLE_GLOBAL_LIGHT

added in API level 9

Global style: light

Constant Value: 2 (0x00000002)

Public Methods

public String getAccent ()

added in API level 9

Get the current accent package.

Returns
String The current accent package name. Defaults to {#ACCENT_DEFAULT}

public int getGlobalStyle ()

added in API level 9

Get the current global style.

Returns
int One of STYLE_GLOBAL_AUTO_WALLPAPER, STYLE_GLOBAL_AUTO_DAYTIME, STYLE_GLOBAL_LIGHT or STYLE_GLOBAL_DARK

public static StyleInterface getInstance (Context context)

added in API level 9

Get or create an instance of the StyleInterface

Parameters
context Context: Used to get the service
Returns
StyleInterface StyleInterface

public Suggestion getSuggestion (Bitmap source, int[] colors)

added in API level 9

Get the best color that suites a bitmap object and the appropriate global style

Parameters
source Bitmap: The object you want the suggested color to be matched with
colors int: A list of colors that the selection will be made from
Returns
Suggestion A Suggestion which holds the best style + accent combination

public List<String> getTrustedAccents ()

added in API level 9

Get a list of trusted accents that are included in the build. The first element (if any) is the default accent.

Returns
List<String> A list of accents package names that can be used with {#setAccent}.

See also:

public boolean setAccent (String pkgName)

added in API level 9

Set color accent package. You will need CHANGE_STYLE_SETTINGS_PERMISSION to utilize this functionality.

Parameters
pkgName String: The package name of the accent
Returns
boolean Whether the process failed

public boolean setGlobalStyle (int style, String pkgName)

added in API level 9

Set global style. You will need CHANGE_STYLE_SETTINGS_PERMISSION to utilize this functionality.

Parameters
style int: The style mode to set the device to. One of STYLE_GLOBAL_AUTO_WALLPAPER, STYLE_GLOBAL_AUTO_DAYTIME, STYLE_GLOBAL_LIGHT or STYLE_GLOBAL_DARK
pkgName String: The package name of the calling application
Returns
boolean Whether the process failed