styles: add support for more dark overlays
Change-Id: If9e08ba8ff28cff7a4061a6b6cea10d5fe38a541 Signed-off-by: Joey <joey@lineageos.org>
This commit is contained in:
@@ -526,6 +526,18 @@ public final class LineageSettings {
|
||||
return getStringForUser(resolver, name, UserHandle.myUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up a name in the database.
|
||||
* @param resolver to access the database with
|
||||
* @param name to look up in the table
|
||||
* @param def Value to return if the setting is not defined.
|
||||
* @return the corresponding value, or null if not present
|
||||
*/
|
||||
public static String getString(ContentResolver resolver, String name, String def) {
|
||||
String str = getStringForUser(resolver, name, UserHandle.myUserId());
|
||||
return str == null ? def : str;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public static String getStringForUser(ContentResolver resolver, String name,
|
||||
int userId) {
|
||||
@@ -1343,6 +1355,15 @@ public final class LineageSettings {
|
||||
public static final Validator BERRY_CURRENT_ACCENT_VALIDATOR =
|
||||
sNonNullStringValidator;
|
||||
|
||||
/**
|
||||
* Current dark overlay package name
|
||||
*/
|
||||
public static final String BERRY_DARK_OVERLAY = "berry_dark_overlay";
|
||||
|
||||
/** @hide */
|
||||
public static final Validator BERRY_DARK_OVERLAY_VALIDATOR =
|
||||
sNonNullStringValidator;
|
||||
|
||||
/**
|
||||
* Current application managing the style
|
||||
*/
|
||||
@@ -2242,6 +2263,7 @@ public final class LineageSettings {
|
||||
VALIDATORS.put(PROXIMITY_ON_WAKE, PROXIMITY_ON_WAKE_VALIDATOR);
|
||||
VALIDATORS.put(BERRY_GLOBAL_STYLE, BERRY_GLOBAL_STYLE_VALIDATOR);
|
||||
VALIDATORS.put(BERRY_CURRENT_ACCENT, BERRY_CURRENT_ACCENT_VALIDATOR);
|
||||
VALIDATORS.put(BERRY_DARK_OVERLAY, BERRY_DARK_OVERLAY_VALIDATOR);
|
||||
VALIDATORS.put(BERRY_MANAGED_BY_APP, BERRY_MANAGED_BY_APP_VALIDATOR);
|
||||
VALIDATORS.put(ENABLE_FORWARD_LOOKUP, ENABLE_FORWARD_LOOKUP_VALIDATOR);
|
||||
VALIDATORS.put(ENABLE_PEOPLE_LOOKUP, ENABLE_PEOPLE_LOOKUP_VALIDATOR);
|
||||
@@ -2420,6 +2442,18 @@ public final class LineageSettings {
|
||||
return getStringForUser(resolver, name, UserHandle.myUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up a name in the database.
|
||||
* @param resolver to access the database with
|
||||
* @param name to look up in the table
|
||||
* @param def Value to return if the setting is not defined.
|
||||
* @return the corresponding value, or null if not present
|
||||
*/
|
||||
public static String getString(ContentResolver resolver, String name, String def) {
|
||||
String str = getStringForUser(resolver, name, UserHandle.myUserId());
|
||||
return str == null ? def : str;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public static String getStringForUser(ContentResolver resolver, String name,
|
||||
int userId) {
|
||||
@@ -3284,6 +3318,18 @@ public final class LineageSettings {
|
||||
return getStringForUser(resolver, name, UserHandle.myUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up a name in the database.
|
||||
* @param resolver to access the database with
|
||||
* @param name to look up in the table
|
||||
* @param def Value to return if the setting is not defined.
|
||||
* @return the corresponding value, or null if not present
|
||||
*/
|
||||
public static String getString(ContentResolver resolver, String name, String def) {
|
||||
String str = getStringForUser(resolver, name, UserHandle.myUserId());
|
||||
return str == null ? def : str;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public static String getStringForUser(ContentResolver resolver, String name,
|
||||
int userId) {
|
||||
|
||||
@@ -30,4 +30,7 @@ interface IStyleInterface {
|
||||
String getAccent();
|
||||
Suggestion getSuggestion(in Bitmap source, in int[] colors);
|
||||
List<String> getTrustedAccents();
|
||||
boolean isDarkNow();
|
||||
boolean setDarkOverlay(String overlayName);
|
||||
String getDarkOverlay();
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2015, The CyanogenMod Project
|
||||
* Copyright (c) 2018, The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -71,6 +71,22 @@ public class StyleInterface {
|
||||
*/
|
||||
public static final String ACCENT_DEFAULT = "lineageos";
|
||||
|
||||
/**
|
||||
* Dark style: default
|
||||
*
|
||||
* @see #setDarkOverlay
|
||||
* @hide
|
||||
*/
|
||||
public static final String OVERLAY_DARK_DEFAULT = "org.lineageos.overlay.dark";
|
||||
|
||||
/**
|
||||
* Dark style: black
|
||||
*
|
||||
* @see #setDarkOverlay
|
||||
* @hide
|
||||
*/
|
||||
public static final String OVERLAY_DARK_BLACK = "org.lineageos.overlay.black";
|
||||
|
||||
/**
|
||||
* Allows an application to change system style.
|
||||
* This is a dangerous permission, your app must request
|
||||
@@ -268,4 +284,69 @@ public class StyleInterface {
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the dark style is being used right now,
|
||||
* regardless of the current global style mode.
|
||||
*
|
||||
* @return Returns true if dark style is enabled
|
||||
*/
|
||||
public boolean isDarkNow() {
|
||||
if (sService == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
return sService.isDarkNow();
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, e.getLocalizedMessage(), e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set dark overlay package.
|
||||
*
|
||||
* You will need {@link #CHANGE_STYLE_SETTINGS_PERMISSION}
|
||||
* to utilize this functionality.
|
||||
*
|
||||
* @see #OVERLAY_DARK_DEFAULT
|
||||
* @see #OVERLAY_DARK_BLACK
|
||||
* @param overlayName The package name of the overlay.
|
||||
* One of {@link #OVERLAY_DARK_DEFAULT} or
|
||||
* {@link #OVERLAY_DARK_BLACK},
|
||||
*
|
||||
* @return Whether the process failed
|
||||
* @hide
|
||||
*/
|
||||
public boolean setDarkOverlay(String overlayName) {
|
||||
if (sService == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
return sService.setDarkOverlay(overlayName);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, e.getLocalizedMessage(), e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current dark overlay package name.
|
||||
*
|
||||
* @see #OVERLAY_DARK_DEFAULT
|
||||
* @see #OVERLAY_DARK_BLACK
|
||||
* @@return {@link #OVERLAY_DARK_DEFAULT} or {@link #OVERLAY_DARK_BLACK}
|
||||
* @hide
|
||||
*/
|
||||
public String getDarkOverlay() {
|
||||
if (sService == null) {
|
||||
return OVERLAY_DARK_DEFAULT;
|
||||
}
|
||||
try {
|
||||
return sService.getDarkOverlay();
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, e.getLocalizedMessage(), e);
|
||||
}
|
||||
return OVERLAY_DARK_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user