Class ShareActivity

All Implemented Interfaces:
ComponentCallbacks, ComponentCallbacks2, KeyEvent.Callback, LayoutInflater.Factory, LayoutInflater.Factory2, View.OnCreateContextMenuListener, Window.Callback

public final class ShareActivity extends Activity
What other apps hand Sioul to write (docs/android.md, "Sharing"): files and text shared to it, or to one of your addresses straight from the share sheet (MailShortcuts), and mailto: links. Each becomes a request in Sioul's data folder (handed/incoming/<id>.json), which Rust makes a draft of as its window comes up (crates/sioul-app/src/outside.rs); Sioul's window is brought up at once. Shared files come as content:// addresses that Sioul may read only while this activity lives. They are opened on a thread of their own (a cloud's app may fetch a file before it opens), then this activity ends, and the copy goes on from the open files into handed/files/<id>/, under their own names, while you write. When all are copied, handed/incoming/<id>.done.json says where, and Rust is told (nativeHanded) to attach them. Never shown itself. Not taken: a file named by its place (file://), and Sioul's own files, which any app could otherwise ask Sioul to attach. Nothing is sent until you press Send.
  • Field Details

  • Constructor Details

  • Method Details

    • nativeHanded

      static void nativeHanded()
      Rust told that something was handed (android/main.cpp, outside.rs).
    • onCreate

      protected void onCreate(Bundle state)
      Overrides:
      onCreate in class Activity
    • handed

      static File handed(Context context)
      Where Rust takes what is handed (sioul_core::handed): XDG_DATA_HOME/sioul/handed (android/main.cpp). Not the drafts' folder: the sharing carries that one to your other devices, and a request is this phone's.
    • failed

      private static String failed(Exception e)
      "Sioul could not take what you shared: …", in the phone's language, as DoseAlarms.words(int) picks it: Rust's words are not loaded yet.
    • open

      private void open()
      Sioul's window brought up, as by its icon.
    • tell

      private static void tell()
      Rust told, when Sioul's library is loaded (its window up); else it takes the request as the window comes up.
    • used

      private static void used(Context app, Intent intent)
      An address of yours chosen in the share sheet: Android ranks it higher next time.
    • request

      private static JSONObject request(Intent intent, String id, int files, JSONArray refused) throws JSONException
      What Rust reads (sioul_core::handed::Handed).
      Throws:
      JSONException
    • account

      private static String account(Intent intent)
      The account chosen: an address of yours in the share sheet, or a launcher's shortcut; "" for Sioul's usual one.
    • strings

      private static JSONArray strings(Bundle extras, String key)
      Addresses, however the app gave them: one, an array, a list.
    • text

      private static String text(Bundle extras, String key)
      A text, however the app gave it: a string, styled text, a list of them (one per paragraph).
    • streams

      private static List<Uri> streams(Intent intent)
      The files shared: EXTRA_STREAM, one or a list, each once. Not the clip's addresses: beside a text, an app may put there the picture the share sheet shows, which is no attachment.
    • taken

      private boolean taken(Uri uri)
      Whether a shared address is taken: a content:// one, of another app's provider. Not a file:// one, nor one of Sioul's own providers: any app could name Sioul's private files that way, to have them attached.
    • lastPart

      private static String lastPart(Uri uri)
    • copy

      private void copy(Context app, File handed, String id, List<Uri> uris)
      On a thread of its own: each file opened, then this activity let go (its permission with it: the files stay open), then each copied, then Rust told.
    • store

      private static void store(AssetFileDescriptor file, File folder, File copy) throws IOException
      A file copied whole, or not at all: under ".part" until it is. The open file closed after.
      Throws:
      IOException
    • name

      private static String name(ContentResolver resolver, Uri uri)
      A file's name as its app gives it, else the end of its address.
    • cleaned

      static String cleaned(String name, String type)
      A name a file can have in Sioul's folder, as close to the app's as can be: no "/" nor hidden dot, not too long, and an extension from its type when it has none (Sioul tells the recipient a file's type by it).
    • unique

      static String unique(Set<String> taken, String name)
      "photo.jpg", then "photo (2).jpg" for a second of the same name.
    • why

      private static String why(Exception e)
      Why it failed, in the system's words, without Java's class names.
    • write

      static void write(File file, String text) throws IOException
      A text written whole: under another name, then renamed.
      Throws:
      IOException