abrenoch / hyperion-android-grabber

Screen grabber for hyperion
MIT License
194 stars 33 forks source link

Feature/toggle tile #64

Closed abrenoch closed 6 years ago

abrenoch commented 6 years ago

Adds a quick settings tile to toggle the grabber on/off.

Uses the BootActivity, so there is a slight screen flash, but since the settings pane is open it is mostly unnoticeable.

closes #24

ninovanhooff commented 6 years ago

Works fine in a general usage scenario. Also correctly shows a toast if the host / port have not been configured

Unfortunately, when the user has not given permanent screen recording permission, the dialog for it will pop up; but the dialog is covered by the open settings drawer. Ideally, we would close the settings drawer when needed, but we have no way of knowing whether the dialog will appear:

https://stackoverflow.com/questions/46293836/how-to-check-whether-media-projection-api-service-permission-enabled-or-not

Which would mean closing the dialog always; which might bother regular users since this is not expected (try toggling your wifi, the settings panel stays open).

I though long and hard about this, and couldn't think of a solution. To my knowledge there is no way of detecting whether the dialog was shown (the BootActivity gets paused for a millisecond even when it turns out the dialog is not required).

What we can do is check whether the connection settings were configured when a tile is enabled, and start the settings when required. For this I added commits to your PR

abrenoch commented 6 years ago

I also discovered determining if the screen record permission had been granted or not was hard to tell... You would really think that information would be readily available, but I simply couldn't find a way to determine it.

I agree about confirmation dialog... There is the startActivityAndCollapse call that would close the notification pane, but that would only make sense if permission is not granted... And since we have no way of knowing, no sure if that is possible.

You don't happen to have any ideas to making the BootActivity less invasive do you? It only blinks into existence for a split second before closing itself, but it is noticeable. I've tried pretty much every strategy I could find online, but still feel a little underwhelmed by it!

abrenoch commented 6 years ago

Also one other small thing - I noticed sometimes the activity takes a while to respond after punching the tile (usually on the first click, and subsequent clicks run faster). Any thoughts on that?

I'll merge the changes for now, if we find a better way to make BootActivity more stealthy it can just be a separate PR!