Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework start/stop controls #137

Open
7 tasks
gavv opened this issue Feb 23, 2025 · 1 comment
Open
7 tasks

Rework start/stop controls #137

gavv opened this issue Feb 23, 2025 · 1 comment
Labels
category: android Task related to Android development category: user interface Task for developing UI

Comments

@gavv
Copy link
Member

gavv commented Feb 23, 2025

Problem

In new android we have to request media projection before starting foreground service, which unconditionally involves interaction with user (it's not granted permanently like with permissions).

It complicates starting sender/receiver from notification and tile: if the app is closed, we don't have an activity, and can't just request projection. We'd need to create an activity first, either temporary or our main activity, then tell it to do the job. But that would contradict the purpose of notification and tile to be able to control streaming without opening the app.

Another problem is architectural rather than technical. If we want to start streaming from kotlin, we either need to replicate android_backend.dart in kotlin (and have a mirror of config in kotlin, and to handle races, and to maintain two copies of the big chunk of code, etc. etc.), or we need communicate from headless android service with dart code (and have multiple dart entry points and multiple root apps). Both approaches are feasible but are rather complicated and tricky. It would be nice to stick with something simpler.

Suggested solution

To deal with this new requirements, we can switch from 2 states (STARTED and STOPPED) to 3 states:

  • STARTED - projection acquired, streaming active
  • PAUSED - projection acquired, streaming inactive
  • STOPPED - projection released, streaming inactive

If you pause streaming instead of stopping it, you can start it again without any permission dialogs. It means that if streaming is paused, we can resume it from notification and tile.

We'll need to rework UI for these new approach:

  • In app, instead of START/STOP buttons, we'll have:

    • Three buttons shared between sender and receiver: START, PAUSE, STOP. (We can combine the first two into one button).

    • ON/OFF switch in sender and in receiver. It's not a button that starts sender or receiver, it's a flag that control whether sender or receiver should be started when START is pressed.

  • In notification, we'll have:

    • One or two buttons, depending on current state:

      • If streaming is STARTED, then "Pause streaming" and "Stop streaming" buttons.
      • If streaming is PAUSED, then "Start streaming" and "Stop streaming" buttons.
      • If streaming is STOPPED, then "Open app" button. This button will appear only if user did a full stop instead of a pause.
    • On tapping notification, the app is opened.

    • On swiping away notification, streaming is STOPPED.

  • In tile:

    • When switched on:
      • If streaming is PAUSED, START streaming.
      • If streaming is STOPPED, open the app. This will happen only if user did a full stop instead of a pause.
    • When switched off:
      • PAUSE streaming.

The app UI could be updated like follows:

|--------------------------|
|   SENDER   |   RECEIVER  |    <-- tab bar
|--------------------------|
|  [x] ON/OFF              |
|  ....                    |
|                          |
|                          |
|--------------------------|
|    START  PAUSE  STOP    |    <-- tool bar
|--------------------------|

i.e.:

  • move tab bar to top
  • add tool bar with buttons to bottom (buttons don't belong to the tabs)
  • inside each tab, add ON/OFF toggle switch, the rest can be the same

Steps

  • add 3 states to StreamingService.kt
  • update android bridge
  • add 3 states to android_backend.dart
  • add 3 states to model
  • update flutter UI
  • update notification handling in StreamingService.kt
  • update tile handling in QuicktileService.kt
@gavv gavv added the category: user interface Task for developing UI label Feb 23, 2025
@gavv
Copy link
Member Author

gavv commented Feb 23, 2025

I think if we decide to do it, it should be out of scope of #94, but before proceeding with roc cast. (Actually I think roc cast should use same approach, so this can be the first step towards it).

@Izchomatik What do you think?

@gavv gavv added the category: android Task related to Android development label Feb 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: android Task related to Android development category: user interface Task for developing UI
Projects
None yet
Development

No branches or pull requests

1 participant