public final class NightDisplayController extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
NightDisplayController.AutoMode |
static interface |
NightDisplayController.Callback
Callback invoked whenever the Night display settings are changed.
|
static class |
NightDisplayController.LocalTime
A time without a time-zone or date.
|
Modifier and Type | Field and Description |
---|---|
static int |
AUTO_MODE_CUSTOM
Auto mode value to automatically activate Night display at a specific start and end time.
|
static int |
AUTO_MODE_DISABLED
Auto mode value to prevent Night display from being automatically activated.
|
static int |
AUTO_MODE_TWILIGHT
Auto mode value to automatically activate Night display from sunset to sunrise.
|
Constructor and Description |
---|
NightDisplayController(Context context) |
NightDisplayController(Context context,
int userId) |
Modifier and Type | Method and Description |
---|---|
int |
getAutoMode()
Returns the current auto mode value controlling when Night display will be automatically
activated.
|
NightDisplayController.LocalTime |
getCustomEndTime()
Returns the local time when Night display will be automatically deactivated when using
AUTO_MODE_CUSTOM . |
NightDisplayController.LocalTime |
getCustomStartTime()
Returns the local time when Night display will be automatically activated when using
AUTO_MODE_CUSTOM . |
boolean |
isActivated()
Returns
true when Night display is activated (the display is tinted red). |
static boolean |
isAvailable(Context context)
Returns
true if Night display is supported by the device. |
boolean |
setActivated(boolean activated)
Sets whether Night display should be activated.
|
boolean |
setAutoMode(int autoMode)
Sets the current auto mode value controlling when Night display will be automatically
activated.
|
boolean |
setCustomEndTime(NightDisplayController.LocalTime endTime)
Sets the local time when Night display will be automatically deactivated when using
AUTO_MODE_CUSTOM . |
boolean |
setCustomStartTime(NightDisplayController.LocalTime startTime)
Sets the local time when Night display will be automatically activated when using
AUTO_MODE_CUSTOM . |
void |
setListener(NightDisplayController.Callback callback)
Register a callback to be invoked whenever the Night display settings are changed.
|
public static final int AUTO_MODE_DISABLED
setActivated(boolean)
.setAutoMode(int)
,
Constant Field Valuespublic static final int AUTO_MODE_CUSTOM
public static final int AUTO_MODE_TWILIGHT
setAutoMode(int)
,
Constant Field Valuespublic NightDisplayController(Context context)
public NightDisplayController(Context context, int userId)
public boolean isActivated()
true
when Night display is activated (the display is tinted red).public boolean setActivated(boolean activated)
activated
- true
if Night display should be activatedtrue
if the activated value was set successfullypublic int getAutoMode()
AUTO_MODE_DISABLED
, AUTO_MODE_CUSTOM
, or
AUTO_MODE_TWILIGHT
.public boolean setAutoMode(int autoMode)
AUTO_MODE_DISABLED
, AUTO_MODE_CUSTOM
, or
AUTO_MODE_TWILIGHT
.autoMode
- the new auto mode to usetrue
if new auto mode was set successfullypublic NightDisplayController.LocalTime getCustomStartTime()
AUTO_MODE_CUSTOM
.public boolean setCustomStartTime(NightDisplayController.LocalTime startTime)
AUTO_MODE_CUSTOM
.startTime
- the local time to automatically activate Night displaytrue
if the new custom start time was set successfullypublic NightDisplayController.LocalTime getCustomEndTime()
AUTO_MODE_CUSTOM
.public boolean setCustomEndTime(NightDisplayController.LocalTime endTime)
AUTO_MODE_CUSTOM
.endTime
- the local time to automatically deactivate Night displaytrue
if the new custom end time was set successfullypublic void setListener(NightDisplayController.Callback callback)
public static boolean isAvailable(Context context)
true
if Night display is supported by the device.