digidem / comapeo-mobile

The next version of Mapeo mobile
GNU General Public License v3.0
5 stars 1 forks source link

fix: microphone permission modal has correct text #843

Closed cimigree closed 6 days ago

cimigree commented 1 week ago

closes #831

Description

This PR removes some old console.logs. Also!

  1. it makes sure that the text on the permission modal is correct. It should say allow, not now if someone has not denied permissions.
  2. Once someone has denied permissions, it should say Go to Settings, which now it does. I had to add the useEffect so that when someone returns from settings, the behavior is correct. There were many ways to achieve this! I hope you like the way I landed on. I considered at least 4 other ways that also worked.

As a reminder, adb shell pm reset-permissions will reset the permissions (from "granted") but if they are denied, they will remain "denied"... Not sure why that is.

To test

  1. Start an observation.
  2. Press microphone. Modal should open and say "Allow/ Not Now". Press Not Now. Modal should close.
  3. Press microphone. Modal should say "Allow/ Now Now". Press Allow. Grant permission. You should navigate to the the audio recording screen.
  4. Run adb shell pm reset-permissions
  5. Reopen the app, grant other permissions
  6. Press microphone. Modal should now say Not Now, Go to Settings. Hit Not Now and modal should close.
  7. Press microphone. Modal should now say Not Now, Go to Settings. Hit Go to Settings and you should Go to settings. Don't enable microphone permissions. Modal should still be open. You can hit Not Now and it will close.
  8. Press microphone. Modal should now say Not Now, Go to Settings. Hit Go to Settings and you should Go to settings. Enable Microphone permissions. Use back button to go back to the app. You should navigate to audio now (sorry there is some flashing as the sheet closes).
ErikSin commented 1 week ago

Just to clarify. What was happening before was the user was setting the permissions in setting, but the app was improperly detecting when that permission was being set?

cimigree commented 1 week ago

@ErikSin

Just to clarify. What was happening before was the user was setting the permissions in setting, but the app was improperly detecting when that permission was being set?

There were two things wrong. Problem number one and the one that Ximena noticed, was just that the text in the modal was wrong. If you deny permissions, the next time you press the microphone the modal is supposed to say Go To Settings (see issue https://github.com/digidem/comapeo-mobile/issues/359 ) and it was saying Allow/ Not now instead. So I fixed that so it now says Go To Settings if you had previously denied permission.

Problem number two, once the user navigated back to the app from settings giving permission for the microphone, the behavior wasn't right because the modal was still open saying Allow/ Not now and if you clicked allow, you would go to settings again... You had to press Not Now, the modal would close and then when you pressed the microphone again then you would correctly be navigated to Audio. So I fixed that.