syncthing-android icon indicating copy to clipboard operation
syncthing-android copied to clipboard

Feature Suggestion: [Force Start] [Normal Operation] [Force Stop] buttons in notification

Open Mrnofish opened this issue 3 years ago • 16 comments

Would it be feasible to include three buttons in its notification, in a similar fashion to media players?

The three buttons would correspond to Normal Operation (e.g. [>] Play Button), Force Start (e.g. [>>] Fast Forward], and Force Stop (e.g. [#] Stop button)

This would allow for quickly switching the various run states, so Syncthing could be stopped manually for saving battery, or started for as long as necessary for large transfers.

Mrnofish avatar May 15 '21 05:05 Mrnofish

Hi,

I think this is easy. Maybe @Helium314 could be asked if he has time and motivation to go on this?

Noted for enhancement :) thanks!

Catfriend1 avatar May 15 '21 06:05 Catfriend1

I actually thought about adding buttons to the notification, but decided to do QS tiles only because the feature request already existed.

Text-only action buttons should be pretty easy to implement. No idea though about buttons with graphics like they are typically used in media players.

Helium314 avatar May 15 '21 10:05 Helium314

Tiles would be great in theory, however, on Lineage the icon density is very low (only 9 icons per page), so there's fierce competition for the first page.

Graphical buttons would be cool, however text ones are plenty fine, too.

Thanks for taking this into consideration.

Mrnofish avatar May 15 '21 18:05 Mrnofish

BTW I've been trying to use the tile, however I have to admit it's unexpectedly clunky, might as well open the app.

Any progress on text buttons?

Mrnofish avatar Aug 26 '21 12:08 Mrnofish

@Mrnofish No plans from my side.

Catfriend1 avatar Aug 26 '21 13:08 Catfriend1

It was said that it'd be an easy change to make, any particular reason against its inclusion?

Mrnofish avatar Aug 26 '21 20:08 Mrnofish

No, nothing against it - but I myself won't do it because a lack of time . My family has priority.

Catfriend1 avatar Aug 26 '21 21:08 Catfriend1

I had tried to implement this after my comment that it should be easy, but then encontered some difficulties so that it would be more work than expected. Can't remember details though...

Helium314 avatar Sep 04 '21 06:09 Helium314

I'd love to help, I have some coding experience, but none specific to Android, currently do not have the time to set aside to get my paws in that particular pie.

Any chance to get someone, who might be in a better position to contribute, started?

Mrnofish avatar Sep 04 '21 17:09 Mrnofish

Well from my side every contribution "from someone who knows what he does" is welcome. or it is easy and simple so I can welcome it by reviewing myself :-).

Catfriend1 avatar Sep 04 '21 17:09 Catfriend1

Sure, but the point is, how do you make that contribution happen in the first place.

I know asking the question might seem easy, however as the project maintainer, don't you have tools to your disposal, like creating a preferential path to incentivize and help someone to submit a patch?

Asking honestly, because I've read about this stuff in discussions on how to attract developers and make FOSS projects more successful, but I was never in your shoes.

Mrnofish avatar Sep 04 '21 18:09 Mrnofish

I'm not sure I understood the question correctly... the preferred path is to open a GitHub pull request with code changes, Githubdesktop may help with this, it's a free tool I use, too. All other build tools etc. are available at no cost like e.g. Python, Android Studio and Go.

Catfriend1 avatar Sep 04 '21 19:09 Catfriend1

The questions boils down to attracting developers who might be interested in contributing patches, by making it more easy for them to do so.

This is just an example I grabbed off a quick web search, only meant to give you a rough idea what I'm talking about:

https://opensource.com/business/16/9/how-to-get-programmers

And in particular, the paragraph titled "Easy and well-defined initial contributions".

Mrnofish avatar Sep 04 '21 20:09 Mrnofish

Ok, understood. Issued are tagged easy / pr welcome a possible new contributor can try to start with. We already have these tags. The other thing: I still do easy and important things myself when I have the time for a dev session.

Catfriend1 avatar Sep 05 '21 09:09 Catfriend1

The other thing: I still do easy and important things myself when I have the time for a dev session.

For that and the app, I am very thankful!

This feature, on the other hand, really affects my quality of life, and since I am not in a position to provide a solution myself, I would really like for someone to take care of it sooner rather than later.

Thanks again for the great app.

Mrnofish avatar Sep 05 '21 13:09 Mrnofish

This feature, on the other hand, really affects my quality of life, and since I am not in a position to provide a solution myself, I would really like for someone to take care of it sooner rather than later.

This is almost exactly the reason why I started messing with Android apps, so I can recommed trying it yourself.

I had a look at what should be necessary to implement the buttons:

  • show the buttons
    • see https://developer.android.com/training/notify-user/build-notification#Actions: you need to create a pending intent for each button and add the button using addAction approximately here: https://github.com/Catfriend1/syncthing-android/blob/main/app/src/main/java/com/nutomic/syncthingandroid/service/NotificationHandler.java#L20
    • which buttons to show depends on the current force state, which you can get from shared preferences
  • for the actual action you need to provide an intent (to be put into the pending intent mentioned above, see the link)
    • I think there is no action (required for the intent) for changing the force state, only for starting a 5 min run and for updating the run decision
    • so you need to create some way to change the force state using an intent (via action or using extras)
    • this could be by adding new actions or by providing extras to an intent with ACTION_UPDATE_SHOULD_RUN_DECISION
    • there needs to be some receiver / filter for the intent that changes the force setting appropriately and updates the should-run decision (to be put in RunConditionMonitor)

I think I got stuck in the second part, which is not straightforward (mostly because I don't really understand this (pending) intent stuff enough)

Helium314 avatar Sep 16 '21 06:09 Helium314