Class EventAlarms

java.lang.Object
com.aurelienpierre.sioul.EventAlarms

final class EventAlarms extends Object
Reminders before events while Sioul is not on the screen (docs/android.md, "Events"): Android freezes an app it does not show, so Rust hands the coming reminders of events ahead (crates/sioul-app/src/eventalarms.rs: their own alarms, Sioul's before them, the working day before), and each is given to Android's alarm clock, as the doses are (DoseAlarms). At its time EventReceiver asks Rust what to say: the event read again, sleep or a pause holding it or not, the time left said as it is then. Rust shows it through `show`: Sioul's reminders before an event and the working day before in the "Events" channel, at low importance (no sound, no banner); an alarm the event carries in "An event's alarms", at Android's default importance (its sound, no banner), or, while one of Sioul's modes lets them through, in its twin that passes do-not-disturb (PauseMode); each yours to change in Android's settings. A tap opens the event in Sioul (ReminderOpener). Rust silent, the words given with the list are shown instead: never nothing. Apart from the doses: its own list, alarms, channels and receiver. The list also holds when the end of work's notice and the night's may come (kind "day"): Rust decides those at their alarm and shows them through DayNotes, or nothing; no words are kept for them.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    (package private) static final class 
    An alarm to set: its reminder's key, and when (Unix ms).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final String
    "An event's alarms": the alarms an event carries, with their sound.
    (package private) static final String
    The "Events" channel: Sioul's reminders before an event, and the working day before; quiet.
    (package private) static final String
    Whether a reminder of the list rang and was answered (`done`): kept while Rust lists it, never set again.
    private static final String[][]
     
    (package private) static final String
    The time Rust gave a reminder last (Unix ms), kept apart from its "at", the time its alarm is set for, which `again` moves.
    private static final String
     
    private static final long
    A reminder stays in the shade until an hour after its event began.
    private static final String
     
    (package private) static final String
     
    private static final int
    The question asked again once a day, nothing having rung meanwhile.
    private static final int
    A reminder is known by its key (its tag) and this number.
    private static final String
     
    (package private) static final String
     
    private static final String
     
    private static final String
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) static void
    again(Context context, String key, long at)
    A reminder asked about again at `at`: held now (you sleep), still worth telling then.
    private static void
    alarm(Context context, String key, long at)
    A reminder's alarm, at its time even while the phone sleeps (Doze); without "Alarms & reminders", as close as Android allows: up to an hour late.
    (package private) static JSONArray
    The list with `key` done with (`done`): kept, marked, while Rust lists it, so that it is never set again; gone with the next list without it.
    (package private) static void
    ask(Context context, String why)
    Rust asked for the coming reminders, then given them (EventReceiver, on a thread of its own): after a restart, an update, a change of time or of zone, once a day.
    (package private) static JSONArray
    asked(JSONArray kept, String key, long at)
    The list with `key` asked about again at `at` (`again`), set again, not done.
    private static void
    cancel(Context context, String key)
     
    (package private) static void
    channel(Context context)
    The channels: "Events" at low importance, without sound or banner, for Sioul's reminders before an event and the working day before; "An event's alarms" at Android's default importance (its sound, no banner), for the alarms an event carries.
    private static JSONObject
    copied(JSONObject reminder)
    A copy of `reminder`, or an empty one.
    (package private) static void
    dismiss(Context context, String key)
    A reminder said for nothing (by the fallback) taken away.
    (package private) static void
    done(Context context, String key)
    A reminder done with (told, gone): marked, not to ring again, after a restart neither (`answered`).
    (package private) static void
    fallback(Context context, String key)
    The words given with the list, said when Rust cannot be asked at a reminder's time: never nothing.
    (package private) static boolean
    isAlarm(String kind, String key)
    Whether a reminder is an alarm its event carries: as Rust says it ("kind": "alarm", "before", "event"), else by its key (`alarm:…`, a list given by an older Sioul).
    (package private) static boolean
    isDay(String kind)
    Whether an entry of the list is the end of work's notice or the night's (DayNotes), which have no words kept.
    private static SharedPreferences
    kept(Context context)
     
    (package private) static JSONObject
    kept(Context context, String key)
    The words given with a reminder in the list, shown when Rust cannot be asked; null when not kept.
    (package private) static String
    key(Intent intent)
    The reminder an intent is about; "" when none.
    private static String
    key(JSONObject reminder)
     
    private static JSONArray
    list(Context context)
     
    private static void
    look(Context context, long at)
    The list asked for again at `at` (inexact: nothing hangs on its minute).
    (package private) static JSONArray
    merged(JSONArray kept, JSONArray coming, long now, List<EventAlarms.Arm> armed)
    The list kept once Rust gives `coming` (`set`), and the alarms to set for it, put in `armed`: a reminder new to the list, at its time (one past rings at once: Rust says whether it still makes sense); one kept already, at a time Rust moved into the future, or moved earlier than it said before while it is not done, though that be past (the hours edited so that today's end of work was a few minutes ago; a hold that ended early): it rings at once; never one kept already again in the past at the time Rust said before: it rang already, or rings at the time `again` gave it, and keeps that time and whether it is done.
    (package private) static String
    The coming reminders, in the phone's `zone` (`sioul_event_coming`); "" when Rust failed.
    (package private) static String
    At a reminder's time (eventalarms.rs, `sioul_event_decide`): {"shown"}, {"again_at"}, {}; null when Rust failed.
    (package private) static void
    opened(Context context, String kind, String key)
    A tapped notification's thing, kept until Sioul takes it (ReminderOpener): "event" and its file, "porch".
    private static void
    post(Context context, String key, boolean alarm, String title, String body, String event, long until)
    A reminder in the shade: an alarm the event carries in "An event's alarms", or in its twin that passes do-not-disturb while every one of Sioul's modes on lets an event's alarms through (PauseMode); Sioul's own reminders in the quiet "Events".
    private static void
    put(JSONObject object, String name, Object value)
     
    (package private) static void
    restore(Context context, String why)
    The alarms given again from the list kept: Android forgets them when it restarts.
    private static Intent
    ringIntent(Context context, String key)
     
    private static void
    schedule(Context context, JSONArray coming)
     
    (package private) static void
    set(Context context, String json)
    Rust's coming reminders: JSON {reminders: [{key, at (Unix ms), title, body}], look (Unix ms), words}.
    (package private) static void
    show(Context context, String json)
    Rust's reminder (eventalarms.rs, `show`): JSON {key, kind, title, body, event (its file), until (Unix ms, when the event begins), words}.
    (package private) static String
    What a tapped notification opens, once, as JSON {kind, key}; null when nothing (android/main.cpp, for Rust).
    (package private) static String
    word(Context context, String which)
    The words said here, as Rust gave them with the list (in the person's language, crates/sioul-core/locales); before any list, these, by the phone's language.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • nativeDecide

      static String nativeDecide(String key)
      At a reminder's time (eventalarms.rs, `sioul_event_decide`): {"shown"}, {"again_at"}, {}; null when Rust failed.
    • nativeComing

      static String nativeComing(String zone)
      The coming reminders, in the phone's `zone` (`sioul_event_coming`); "" when Rust failed.
    • set

      static void set(Context context, String json)
      Rust's coming reminders: JSON {reminders: [{key, at (Unix ms), title, body}], look (Unix ms), words}. Their alarms replace those given before, as `merged` says; the list is kept for Android's restarts. Any thread.
    • merged

      static JSONArray merged(JSONArray kept, JSONArray coming, long now, List<EventAlarms.Arm> armed)
      The list kept once Rust gives `coming` (`set`), and the alarms to set for it, put in `armed`: a reminder new to the list, at its time (one past rings at once: Rust says whether it still makes sense); one kept already, at a time Rust moved into the future, or moved earlier than it said before while it is not done, though that be past (the hours edited so that today's end of work was a few minutes ago; a hold that ended early): it rings at once; never one kept already again in the past at the time Rust said before: it rang already, or rings at the time `again` gave it, and keeps that time and whether it is done. So a list given again and again with a past reminder in it (the end of work's, while its ten minutes last) never rings it again and again: Rust's times for it stay put, or only grow ("a second from now"). Pure, checked on a JVM (android/jvm-checks/DayNotesCheck.java).
      Parameters:
      kept - the list kept until now
      coming - the list Rust gives
      now - the time now (Unix ms)
      armed - the alarms to set, added to
      Returns:
      the list to keep
    • asked

      static JSONArray asked(JSONArray kept, String key, long at)
      The list with `key` asked about again at `at` (`again`), set again, not done. Pure (DayNotesCheck).
      Parameters:
      kept - the list kept
      key - the reminder's key
      at - when (Unix ms)
      Returns:
      the list to keep
    • answered

      static JSONArray answered(JSONArray kept, String key)
      The list with `key` done with (`done`): kept, marked, while Rust lists it, so that it is never set again; gone with the next list without it. Pure (DayNotesCheck).
      Parameters:
      kept - the list kept
      key - the reminder's key
      Returns:
      the list to keep
    • copied

      private static JSONObject copied(JSONObject reminder)
      A copy of `reminder`, or an empty one.
    • restore

      static void restore(Context context, String why)
      The alarms given again from the list kept: Android forgets them when it restarts. One whose time went by rings at once: Rust says whether it still makes sense. Those done with stay unset.
    • ask

      static void ask(Context context, String why)
      Rust asked for the coming reminders, then given them (EventReceiver, on a thread of its own): after a restart, an update, a change of time or of zone, once a day. Not before the phone's first unlock: Sioul's files cannot be read then. No answer: the list kept goes on.
    • again

      static void again(Context context, String key, long at)
      A reminder asked about again at `at`: held now (you sleep), still worth telling then.
    • done

      static void done(Context context, String key)
      A reminder done with (told, gone): marked, not to ring again, after a restart neither (`answered`).
    • schedule

      private static void schedule(Context context, JSONArray coming)
    • alarm

      private static void alarm(Context context, String key, long at)
      A reminder's alarm, at its time even while the phone sleeps (Doze); without "Alarms & reminders", as close as Android allows: up to an hour late. Never Android's alarm clock: no alarm icon for an appointment.
    • cancel

      private static void cancel(Context context, String key)
    • look

      private static void look(Context context, long at)
      The list asked for again at `at` (inexact: nothing hangs on its minute).
    • ringIntent

      private static Intent ringIntent(Context context, String key)
    • key

      static String key(Intent intent)
      The reminder an intent is about; "" when none.
    • key

      private static String key(JSONObject reminder)
    • kept

      static JSONObject kept(Context context, String key)
      The words given with a reminder in the list, shown when Rust cannot be asked; null when not kept.
    • put

      private static void put(JSONObject object, String name, Object value)
    • kept

      private static SharedPreferences kept(Context context)
    • list

      private static JSONArray list(Context context)
    • opened

      static void opened(Context context, String kind, String key)
      A tapped notification's thing, kept until Sioul takes it (ReminderOpener): "event" and its file, "porch".
    • takeOpened

      static String takeOpened(Context context)
      What a tapped notification opens, once, as JSON {kind, key}; null when nothing (android/main.cpp, for Rust).
    • channel

      static void channel(Context context)
      The channels: "Events" at low importance, without sound or banner, for Sioul's reminders before an event and the working day before; "An event's alarms" at Android's default importance (its sound, no banner), for the alarms an event carries. Yours to change.
    • isAlarm

      static boolean isAlarm(String kind, String key)
      Whether a reminder is an alarm its event carries: as Rust says it ("kind": "alarm", "before", "event"), else by its key (`alarm:…`, a list given by an older Sioul). Pure, checked on a JVM (android/jvm-checks/ModeCheck.java).
    • show

      static void show(Context context, String json)
      Rust's reminder (eventalarms.rs, `show`): JSON {key, kind, title, body, event (its file), until (Unix ms, when the event begins), words}. A tap, or Open, brings Sioul up on the event. Any thread.
    • fallback

      static void fallback(Context context, String key)
      The words given with the list, said when Rust cannot be asked at a reminder's time: never nothing. Not the end of work's notice nor the night's (kind "day"): said by Rust alone, or not at all, as on a computer (Rust's notice may not come: the day closed, a meeting, the notice told on another device).
    • isDay

      static boolean isDay(String kind)
      Whether an entry of the list is the end of work's notice or the night's (DayNotes), which have no words kept. Pure, checked on a JVM (android/jvm-checks/DayNotesCheck.java).
      Parameters:
      kind - the entry's kind, as Rust gave it
      Returns:
      whether it is one of the day's
    • dismiss

      static void dismiss(Context context, String key)
      A reminder said for nothing (by the fallback) taken away.
    • post

      private static void post(Context context, String key, boolean alarm, String title, String body, String event, long until)
      A reminder in the shade: an alarm the event carries in "An event's alarms", or in its twin that passes do-not-disturb while every one of Sioul's modes on lets an event's alarms through (PauseMode); Sioul's own reminders in the quiet "Events".
    • word

      static String word(Context context, String which)
      The words said here, as Rust gave them with the list (in the person's language, crates/sioul-core/locales); before any list, these, by the phone's language.