pcolby / nfc-quick-settings

Android Quick Settings tile for NFC
https://play.google.com/store/apps/details?id=au.id.colby.nfcquicksettings
GNU General Public License v3.0
22 stars 1 forks source link

Long tap to open NFC settings? #38

Closed xt1zer closed 3 weeks ago

xt1zer commented 1 month ago

Hi, first of all, I'd like to share my appreciation for this project. I was awfully unpleased to find out that the firmware on my new Xperia 10 VI is also missing the NFC tile on Quick Settings menu. And now that I can toggle the feature in just one tap, it surely is an option I'd hate missing a lot.

One thing I wish to request: for long tapping the tile to open the system NFC settings instead of the app settings. That'll make the quick setting the most authentic to how it behaves in other firmwares (as far as I know, at least I remember it working like this on Samsung's One UI).

Thanks again for making this feature a reality and making Android great once again!

pcolby commented 1 month ago

Thanks @xt1zer, I 100% agree that it would be great, at least in the Advanced mode, for the long-press to go to the NFC settings page. I spent a couple of hours in June, trying to do exactly that, but failed to find a way.

At first glance, it seems that third-party quick settings tiles cannot customise the long-press behaviour, but I haven't fully groked the Android docs in that area yet. Your request has prompted me to try again soon πŸ˜„ Thanks!

pcolby commented 1 month ago

Just to clarify where I got to (back in June), this Android doc says:

Long-tapping a tile prompts the App Info screen for the user. To override this behavior and instead launch an activity for setting preferences, add an <intent-filter> to one of your activities with ACTION_QS_TILE_PREFERENCES.

The trick, it seems, would be to somehow define an <intent-filter> on, not my activity, but the built-in ACTION_NFC_SETTINGS activity... might be possible via adb, but I can't see any official way to do it on the device/app itself.

Of course, I might be misunderstanding the Android docs here too πŸ€·πŸΌβ€β™‚οΈ

pcolby commented 1 month ago

I have an implementation available now (compare the tile-prefs-intent branch), but it's a little more janky for users that don't use the WRITE_SECURE_SETTINGS permission, so I'm not 100% sold on it just yet πŸ€”

bramborman commented 1 month ago

...but it's a little more janky for users that don't use the WRITE_SECURE_SETTINGS permission...

If you wanna have users without the secure settings permission go to the app details settings page as is the default long-click behavior, you can eventually disable the activity completely by default (android:enabled="false" in manifest I believe), and then when the secure settings permission is detected as granted, enable it at runtime, such as here.

Also, I don't know how it looks like now, but I'd suggest using android:theme="@android:style/Theme.NoDisplay" for the activity. It shouldn't then display anything and you won't have to override the onCreate method as well 😊

Btw, I created basically the same app like two years ago but didn't have time to publish it to Play Store and when I did, I found you did it already with yours πŸ˜… I planned to add the secure settings thing but you again were faster with this and so I'm gonna use yours instead and have unpublished mine already πŸ˜… I'll also create a PR when I have the time as there are a few things I see can be improved here 😁

pcolby commented 1 month ago

Thanks @bramborman, both of those suggestions sounds excellent! I'll explore both of them very soon πŸ˜ƒ

Btw, I created basically the same app like two years ago but didn't have time to publish it to Play Store

Yeah, for my first release, it took more work to publish to the Play store than write the code πŸ˜… But pretty easy now that I've got the hang of it.

I'll also create a PR when I have the time as there are a few things I see can be improved here 😁

I look forward to it! 😁 This was literally my first Android app (not my usual development target) so I'm sure there's lots to improve, and I'm keen to learn 😊

Thanks!

pcolby commented 1 month ago

Using android:theme="@android:style/Theme.NoDisplay" reduces (or eliminates?) the jankiness, programmatically enabled/disabling the preferences activity means it has no impact at all on users that don't grant the WRITE_SECURE_PERMISSIONS, so I'm happy that this is all good to go. Prepping a new release shortly :)

pcolby commented 1 month ago

This is now released as v1.4.3. I've already rolled it out to internal testers on Google Play. Will rollout to open testers next, and then full public rollout once I'm confident the release has not introduced and new ANRs ☺️

xt1zer commented 1 month ago

Hi, I've just tried the latest version from the beta programme on Google Play, and can tell it works as expected! No issues to report too.

7heMech commented 3 weeks ago

Trying the lastest f-droid, when I hold it opens settings for apps, when I tap, but a lil longer it opens nfc settings and when I normally tap nothing happens.

bramborman commented 3 weeks ago

Trying the lastest f-droid, when I hold it opens settings for apps, when I tap, but a lil longer it opens nfc settings and when I normally tap nothing happens.

Android APIs allow to specify only two actions - tap, and eventually also long tap, aka hold. There's no way for the app to differentiate between a tap and a little longer tap, so this, unfortunately, isn't fixable on the app side πŸ˜•

I had similar issues with other app from time to time... I guess the issue is that the app was not yet fully started or something. Does this happen every time, or randomly? It might also be a "feature" of your OS flavor. You can try disabling the battery optimization for the app to allow it to always run and see if it improves anything.

pcolby commented 3 weeks ago

Thanks @7heMech, I'm a little confused - its sounds like you're describing three types of taps, but as far as I know, Android only supports two. Can you please confirm the following:

  1. What phone model you have, and which Android version?
  2. What version of NFC Quick Settings? v1.4.3? (only just made to F-Droid in the last 24 hours or so)
  3. Do you use the basic or advanced mode? (ie have you manually granted the WRITE_SECURE_SETTINGS permission to the app?)
  4. What happens when long-tap the tile?
  5. What happens when you quick tap the tile?
  6. If you swipe the quick panel down twice to show the full tile info (assuming your model supports that), what sub-text is written on the NFC tile? (eg On, Off, or Unavailable, or the equivalent in another language).

Thanks πŸ™‚

7heMech commented 3 weeks ago

Hey,

bramborman commented 3 weeks ago

Hey,

  • Google Pixel 6 Pro - Android 14
  • v1.4.3
  • I've not granted any perms
  • If I hold the tile without letting go in about a second I go to app settings
  • if I quickly tap, it shows tap animation, but nothing changes
  • the text is off and it just stays off forever
  • if I tap in the middle of hold and quick tap so about quarter of a second it opens nfc settings where I can turn on nfc.

That's exactly the same as my experience, and funny enough, I have Pixel 7 Pro, so the same Android flavor πŸ˜… Now that I think about it more, I'm either no longer having such issues, or I got used to them and no longer notice... If it's the first, then it must've been the battery optimization... But looking at it now, I see that I don't have the battery set to unrestricted on the app anymore. Afaik there's some "smart learning" algorithm for optimizing apps based on their usage, i.e., if you use the app often enough, it should get better and Android shouldn't kill it that often and you should no longer notice such hangs.

pcolby commented 3 weeks ago

Thanks @7heMech and @bramborman, very interesting πŸ€”

That's exactly the same as my experience, and funny enough, I have Pixel 7 Pro, so the same Android flavor πŸ˜…

Is that your experience with the NFC Quick Settings tile, other tiles, or both?

pcolby commented 3 weeks ago

Also, @7heMech, do you know if it was the same with any previous version of NFC Quick Settings? or is v1.4.3 the first version you've tried? Thanks

7heMech commented 3 weeks ago

Also, @7heMech, do you know if it was the same with any previous version of NFC Quick Settings? or is v1.4.3 the first version you've tried? Thanks

I think previously versions worked just fine let me try

7heMech commented 3 weeks ago

@pcolby ok, old versions behave the same (at least past two) Also @bramborman I'm experiencing something interesting, if I hit record button (so full screen recording) and I quick tap nfc tile it opens nfc settings in a bit like within a second which doesn't happen while I don't record is it the same for you?

bramborman commented 3 weeks ago

Is that your experience with the NFC Quick Settings tile, other tiles, or both?

It was with my own NFC Quick Tile app which's implementation is pretty similar to this app. It's possible that the hold functionality is somehow responsible for these hangs. My app, however, has the hold functionality from the very beginning, so I cannot really say whether that made any difference. But I am experiencing the same with other apps, even a Microsoft one πŸ˜…

if I hit record button (so full screen recording) and I quick tap nfc tile it opens nfc settings in a bit like within a second which doesn't happen while I don't record is it the same for you?

When I checked without recording I didn't face the issue, so I didn't even check with recording. I found that after I force stop my tile app in system settings the first click on the tile just shows the tapping animation and does nothing. The second tap works fine, however. Can you try the same? Possibly also setting the battery optimization to unrestricted with background running allowed? Might it be because you've already tapped the tile close before the recording so the app was running? Then maybe waited a little longer after the recording so the app was again killed by the system? πŸ€”

bramborman commented 3 weeks ago

Anyways, I believe this has nothing to do with the app itself. It's most likely an issue with the system or too aggressive battery optimizations.

7heMech commented 3 weeks ago

Is that your experience with the NFC Quick Settings tile, other tiles, or both?

Only with this app I have another FOSS app which I use for my flashlight, when I hold it, it opens app itself and when I - click it, it works fine.

bramborman commented 3 weeks ago

I have another FOSS app which I use for my flashlight, when I hold it, it opens app itself and when I - click it, it works fine.

Would be interesting to check its source code, can you provide some link please? 😊

7heMech commented 3 weeks ago

Would be interesting to check its source code, can you provide some link please? 😊

Yeah, sure: https://github.com/cyb3rko/flashdim

bramborman commented 3 weeks ago

https://github.com/cyb3rko/flashdim

Had a quick look at some of its code and found nothing particularly interesting to this issue, except for accessibility service. Do you have the app's accessibility service enabled? If yes, then the app runs always in the background and that could make its tile more responsive.

7heMech commented 3 weeks ago

@bramborman nop, I don't have accessibility service, it just works. πŸ€·πŸ»β€β™‚οΈ

bramborman commented 3 weeks ago

@bramborman nop, I don't have accessibility service, it just works. πŸ€·πŸ»β€β™‚οΈ

Yeah, the service is for some shortcut, an additional feature so not required..

Anyways, then I'd bet on the battery optimization. Have a look at the Pixel support article about this topic. I use the tile where I had issues quite often, so I believe my phone just learned to keep the app running. And I think there's no more that can be done here - either you wait for your system to learn you want the app running, or you force the system to not stop the app by turning off the battery optimizations for this app πŸ˜•

pcolby commented 3 weeks ago

Thanks everyone, the original feature request is now live, so closing this issue. As always, feel free to open a new one for any other issues. Thanks!