ComplicationText
public
class
ComplicationText
extends Object
implements
Parcelable,
Parcelable
java.lang.Object | |
↳ | android.support.wearable.complications.ComplicationText |
This class is deprecated.
use the Jetpack Wear
Watch Face libraries instead.
Represents a piece of text to be shown in a complication.
ComplicationText can be a plain string or it can contain a time-dependent value, for which the value varies depending on the current date/time.
Instances of this class should be obtained either by calling plainText(CharSequence)
, or by using
one of the provided builders: ComplicationText.TimeDifferenceBuilder
or ComplicationText.TimeFormatBuilder
.
Summary
Nested classes | |
---|---|
class |
ComplicationText.TimeDifferenceBuilder
This class is deprecated. use the Jetpack Wear Watch Face libraries instead. |
@interface |
ComplicationText.TimeDifferenceStyle
This @interface is deprecated. use the Jetpack Wear Watch Face libraries instead. |
class |
ComplicationText.TimeFormatBuilder
This class is deprecated. use the Jetpack Wear Watch Face libraries instead. |
@interface |
ComplicationText.TimeFormatStyle
This @interface is deprecated. use the Jetpack Wear Watch Face libraries instead. |
Constants | |
---|---|
int |
DIFFERENCE_STYLE_SHORT_DUAL_UNIT
Style for time differences shown in a short alpha-numeric style, with up to two significant units included. |
int |
DIFFERENCE_STYLE_SHORT_SINGLE_UNIT
Style for time differences shown in a short alpha-numeric style, with only the most significant unit included. |
int |
DIFFERENCE_STYLE_SHORT_WORDS_SINGLE_UNIT
Style for time differences shown using (possibly abbreviated) words, with only the most significant unit included, that should fit within the character limit for a short text field. |
int |
DIFFERENCE_STYLE_STOPWATCH
Style for time differences shown in a numeric fashion like a timer. |
int |
DIFFERENCE_STYLE_WORDS_SINGLE_UNIT
Style for time differences shown using (possibly abbreviated) words, with only the most significant unit included. |
int |
FORMAT_STYLE_DEFAULT
Style where the formatted date/time should be shown unchanged. |
int |
FORMAT_STYLE_LOWER_CASE
Style where the formatted date/time should be shown in lower case. |
int |
FORMAT_STYLE_UPPER_CASE
Style where the formatted date/time should be capitalized. |
Inherited constants |
---|
Fields | |
---|---|
public
static
final
Creator<ComplicationText> |
CREATOR
|
Public methods | |
---|---|
int
|
describeContents()
|
CharSequence
|
getText(Context context, long dateTimeMillis)
|
static
CharSequence
|
getText(Context context, ComplicationText complicationText, long dateTimeMillis)
Returns |
boolean
|
isAlwaysEmpty()
Returns true if |
static
ComplicationText
|
plainText(CharSequence text)
Returns a ComplicationText object that will display the given |
boolean
|
returnsSameText(long firstDateTimeMillis, long secondDateTimeMillis)
|
void
|
writeToParcel(Parcel out, int flags)
|
Inherited methods | |
---|---|
Constants
DIFFERENCE_STYLE_SHORT_DUAL_UNIT
public static final int DIFFERENCE_STYLE_SHORT_DUAL_UNIT
Style for time differences shown in a short alpha-numeric style, with up to two significant units included.
For time difference t
:
If t < 1 hour
, the value will be shown as a number of minutes, such as 2m
for 2 minutes. Seconds are not displayed.
If 1 hour <= t < 1 day
, the value will be shown as hours and minutes, such as 4h 2m
for 4 hours and 2 minutes.
If 1 day <= t < 10 days
, the value will be shown as days and hours, such as 3d 4h
for 3 days 4 hours.
If 10 days <= t
, the value will be shown as a number of days, such as 13d
for 13 days.
The characters used will be localised to match the default locale. If the representation of the time difference with two units would be too long in the default locale, just a single unit may be shown instead.
Constant Value: 3 (0x00000003)
DIFFERENCE_STYLE_SHORT_SINGLE_UNIT
public static final int DIFFERENCE_STYLE_SHORT_SINGLE_UNIT
Style for time differences shown in a short alpha-numeric style, with only the most significant unit included.
For time difference t
:
If t < 1 hour
, the value will be shown as a number of minutes, such as 2m
for 2 minutes. Seconds are not displayed.
If 1 hour <= t < 1 day
, the value will be shown as a number of hours, such as 4h
for 4 hours.
If 1 days <= t
, the value will be shown as a number of days, such as 13d
for
13 days.
The characters used will be localised to match the default locale.
Constant Value: 2 (0x00000002)
DIFFERENCE_STYLE_SHORT_WORDS_SINGLE_UNIT
public static final int DIFFERENCE_STYLE_SHORT_WORDS_SINGLE_UNIT
Style for time differences shown using (possibly abbreviated) words, with only the most significant unit included, that should fit within the character limit for a short text field.
The output will be the same as for DIFFERENCE_STYLE_WORDS_SINGLE_UNIT
, except that
if the text does not fit into the seven character limit then a shorter form will be used
instead, e.g. "1356d" instead of "1356 days".
Constant Value: 5 (0x00000005)
DIFFERENCE_STYLE_STOPWATCH
public static final int DIFFERENCE_STYLE_STOPWATCH
Style for time differences shown in a numeric fashion like a timer.
For time difference t
:
If t < 1 hour
, the value will be shown as minutes and seconds, such as 02:35
for 2 minutes and 35 seconds.
If 1 hour <= t < 1 day
, the value will be shown as hours and minutes, such as 4:02
for 4 hours and 2 minutes, or as 12:02
for 12 hours and 2 minutes.
If 1 day <= t < 10 days
, the value will be shown as days and hours, such as 3d 4h
for 3 days 4 hours.
If 10 days <= t
, the value will be shown as just days, such as 13d
for 13
days.
The characters used will be localised to match the default locale.
Constant Value: 1 (0x00000001)
DIFFERENCE_STYLE_WORDS_SINGLE_UNIT
public static final int DIFFERENCE_STYLE_WORDS_SINGLE_UNIT
Style for time differences shown using (possibly abbreviated) words, with only the most significant unit included.
For time difference t
:
If t < 1 hour
, the value will be shown as a number of minutes, such as 1 min
for 1 minute or 2 mins
for 2 minutes. Seconds are not displayed.
If 1 hour <= t < 1 day
, the value will be shown as a number of hours, such as 1 hour
for 1 hour or 4 hours
for 4 hours.
If 1 days <= t
, the value will be shown as a number of days, such as 1 day
for 1 day or 13 days
for 13 days.
The words used will be localised to match the default locale.
Constant Value: 4 (0x00000004)
FORMAT_STYLE_DEFAULT
public static final int FORMAT_STYLE_DEFAULT
Style where the formatted date/time should be shown unchanged.
Constant Value: 1 (0x00000001)
FORMAT_STYLE_LOWER_CASE
public static final int FORMAT_STYLE_LOWER_CASE
Style where the formatted date/time should be shown in lower case.
Constant Value: 3 (0x00000003)
FORMAT_STYLE_UPPER_CASE
public static final int FORMAT_STYLE_UPPER_CASE
Style where the formatted date/time should be capitalized.
Constant Value: 2 (0x00000002)
Fields
Public methods
describeContents
public int describeContents ()
Returns | |
---|---|
int |
getText
public CharSequence getText (Context context, long dateTimeMillis)
Parameters | |
---|---|
context |
Context |
dateTimeMillis |
long |
Returns | |
---|---|
CharSequence |
getText
public static CharSequence getText (Context context, ComplicationText complicationText, long dateTimeMillis)
Returns complicationText.getText(dateTimeMillis, res)
if complicationText
is
not null, or null otherwise.
Parameters | |
---|---|
context |
Context |
complicationText |
ComplicationText |
dateTimeMillis |
long |
Returns | |
---|---|
CharSequence |
isAlwaysEmpty
public boolean isAlwaysEmpty ()
Returns true if getText(Context, long)
will return the empty string for any input.
Returns | |
---|---|
boolean |
plainText
public static ComplicationText plainText (CharSequence text)
Returns a ComplicationText object that will display the given text
for any input time.
Parameters | |
---|---|
text |
CharSequence : the text to be displayed
|
Returns | |
---|---|
ComplicationText |
returnsSameText
public boolean returnsSameText (long firstDateTimeMillis, long secondDateTimeMillis)
Parameters | |
---|---|
firstDateTimeMillis |
long |
secondDateTimeMillis |
long |
Returns | |
---|---|
boolean |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-04-11 UTC.