Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 66e28940 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

DateTimeView: Add additional display configuration options.

Right now, DateTimeView has one display configuration option called
"showRelative":
 - showRelative=false: Times will be shown as absolute times, like
   "9:47" or "9/4/24"
 - showRelative=true: Times will be shown as relative from the current
   time. If the time is 7 minutes in the past, "7m" is used. If the time
   is 2 hours in the future, "in 2h" is used.

This CL adds additional dislpay configuration options, used only if
showRelative=true:

 - disambiguationText:
     If "future" is included, times in the future will have an
     additional "in " at the beginning of the string (e.g. "in 7m")

     If "past" is included, times in the past will have an additional "
     ago" at the end of the string (e.g. "7m ago")

 - relativeTimeUnitDisplayLength:
    If "shortest", use a single character to denote the unit. "m" for
    minutes, "h" for hours, etc. (This is how it works today.)

    If "medium", use 2-3 characters to denote the unit. "min" for
    minutes", "hr" for hours, etc.

    This is an enum so that we could easily add a "long" or "full" value
    if needed later.

Why this is needed: Notifications currently use DateTimeView to show the
time the notification was posted. In a future release, we're adding
chips in the status bar for ongoing notifications, and those chips also
need to show the time the notification was posted. There's two
important differences for the time in the status bar chip:

 1) The notifications that will get status bar chips will likely be for
    *upcoming* events, not past ones, so we expect most notification
    times to be in the future. Since there's so little space in the
    status bar, we want to use just "7m" instead of "in 7m" for those
    future times.

 2) Some status bar chips will be displaying *distance* information, not
    *time* information, like in navigation situations where a user needs
    to take a turn. Single-character time units can be confused with
    single-character distances units - specifically "m" could mean either
    minutes or meters. So, we'd like the time unit used in the status
    bar chip to be slightly longer.

Bug: 364653005
Test: Create a DateTimeView with disambiguationText=past and
relativeTimeUnitDisplayLength=medium, verify strings (see screenshots in
bug)
Test: atest DateTimeViewTest
Flag: android.view.flags.date_time_view_relative_time_display_configs

Change-Id: I8266d36b3b61d1f64ba854b6cd09c2e509179be1
parent 0825a072
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment