bryceco / GoMap

OpenStreetMap editor for iPhone/iPad
ISC License
318 stars 41 forks source link

Automatically use users preferred units. #748

Closed ooosssay closed 4 months ago

ooosssay commented 5 months ago

Have tags length, width, height, max speed, charge, and more automatically based on users set preferences in app settings. For example, when a user is putting in the speed limit and when the user finishes and closes the keyboard, it should automatically put in “mph” if the user set it as their preference. Likewise having USD automatically inserted for the charge= tag. A feature that is similar to this is the camera capturing hours and automatically turning it from 12 hour to 24 hours. Also this feature should also be able to be turned off as users who travel can forget to change their units. (Or automatically set it based on location)

verhovsky commented 5 months ago

This could come from chosen unit of the scale ruler (a recent change that's not live on the app store yet)

bryceco commented 5 months ago

I'm not a fan of modifying a person's edits automatically, even if it is something they opted into. I'm also not a fan of adding preferences for things, unless absolutely necessary.

However, it would be nice to automatically set the Speed Limit toggle in Common Tags to the correct position (km/h or mph). And if the user changes it we could remember the change and automatically set it the same way the next time.

If we had units controls for the other keys you mention we could replicate that logic for them too. Unfortunately there is not currently a way to know whether a given key represents a distance or other unit (see https://github.com/ideditor/schema-builder/issues/15), so we have to hard code the table.

ooosssay commented 4 months ago

I see I respect your opinion. Also, how about implementing something like this: IMG_6687

Where when a user starts the app it will show the already default units but later on when a user puts in a unit with a corresponding tag that unit is saved with the key on top of the keyboard. But as I’m writing this there may be a problem of having the app know what part of the tag is the unit so how about let the user put in their own unit. And that unit is connected to the tag. Sorry if you don’t understand this as this just came into mind while writing this.

1ec5 commented 4 months ago

However, it would be nice to automatically set the Speed Limit toggle in Common Tags to the correct position (km/h or mph). And if the user changes it we could remember the change and automatically set it the same way the next time.

For typically signposted quantities, like speed limits, on-the-ground reality matters more than whatever units the user prefers to use their phone in. iD uses country coder to determine the local conventions. If you can similarly determine the country the user is currently mapping, then on iOS 16 and above, get the Locale.measurementSystem of the current country. On older versions of iOS, you might be able to use MeasurementFormatter to suss out the default measurement system for the current country’s locale.

bryceco commented 4 months ago

I implemented this by ensuring that (most) keys with units have an associated toggle to switch between different units. If the user switches the toggle then we remember the position and restore it the next time the same key appears, and if the user enters a numeric value then the appropriate unit is appended to it.

While most keys just have two possible units, there's a snag with weight which has 5, meaning it would be too wide for our toggle switch (although the underlying code supports more than 2 "toggles").