{"action":"created","issue":{"url":"https://api.github.com/repos/mauron85/background-geolocation-android/issues/8","repository_url":"https://api.github.com/repos/mauron85/background-geolocation-android","labels_url":"https://api.github.com/repos/mauron85/background-geolocation-android/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/mauron85/background-geolocation-android/issues/8/comments","events_url":"https://api.github.com/repos/mauron85/background-geolocation-android/issues/8/events","html_url":"https://github.com/mauron85/background-geolocation-android/pull/8","id":351067925,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA4NzU0NDA4","number":8,"title":"Allow transforming or rejecting coordinates with a special transform","user":{"login":"danielgindi","id":366926,"node_id":"MDQ6VXNlcjM2NjkyNg==","avatar_url":"https://avatars1.githubusercontent.com/u/366926?v=4","gravatar_id":"","url":"https://api.github.com/users/danielgindi","html_url":"https://github.com/danielgindi","followers_url":"https://api.github.com/users/danielgindi/followers","following_url":"https://api.github.com/users/danielgindi/following{/other_user}","gists_url":"https://api.github.com/users/danielgindi/gists{/gist_id}","starred_url":"https://api.github.com/users/danielgindi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielgindi/subscriptions","organizations_url":"https://api.github.com/users/danielgindi/orgs","repos_url":"https://api.github.com/users/danielgindi/repos","events_url":"https://api.github.com/users/danielgindi/events{/privacy}","received_events_url":"https://api.github.com/users/danielgindi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-08-16T06:10:38Z","updated_at":"2018-08-16T16:08:21Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/mauron85/background-geolocation-android/pulls/8","html_url":"https://github.com/mauron85/background-geolocation-android/pull/8","diff_url":"https://github.com/mauron85/background-geolocation-android/pull/8.diff","patch_url":"https://github.com/mauron85/background-geolocation-android/pull/8.patch"},"body":"## Motivation\r\n\r\nA concern was raised by users, where they do not want coordinates to be transmitted from their home address.  \r\nIt's a common privacy issue.\r\n\r\nOur idea was to let them set a \"reverse fence\" around their home. Where all coordinates transmitted within a certain radius - will be offset by around 1km.\r\n\r\n## Implementation\r\n\r\nIn order to achieve the desired result, we have to intervene even when the app is in the background, or as a service. At this stage some user mode code like React Native's JS will not have been executed yet.\r\n\r\nI came up with a \"transform\", where all coordinates pass through. You can modify them or return a new one. Or you can reject them by returning null.\r\n\r\nDue to the fact that the Facade is in most cases not owned by the developer - for example in RN situation where it is owned by the RCT module, and that module is also owned by RN, we have to access the modules statically.\r\nSo static setters have been written for the Facade.\r\n\r\nAs I believe in separation of concerns, I left the issue of \"how to filter\", or in RN's situation \"how to share settings with the transformer\" to the user, to handle with a separate technique/library.\r\n\r\n## Usage\r\n\r\nWhen the `Application` is initialized (which also happens before services gets started in the background), write some code like this:\r\n\r\n```\r\nBackgroundGeolocationFacade.setLocationTransform(new ILocationTransform() {\r\n            @Nullable\r\n            @Override\r\n            public BackgroundLocation transformLocationBeforeCommit(@NonNull Context context, @NonNull BackgroundLocation location) {\r\n                // `context` is available too if there's a need to use a value from preferences etc.\r\n                location.setLatitude(location.getLatitude() + 0.018);\r\n                return location;\r\n            }\r\n        }\r\n```\r\n\r\nNote: The equivalent iOS PR is here: https://github.com/mauron85/background-geolocation-ios/pull/3"},"comment":{"url":"https://api.github.com/repos/mauron85/background-geolocation-android/issues/comments/413599051","html_url":"https://github.com/mauron85/background-geolocation-android/pull/8#issuecomment-413599051","issue_url":"https://api.github.com/repos/mauron85/background-geolocation-android/issues/8","id":413599051,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMzU5OTA1MQ==","user":{"login":"mauron85","id":359450,"node_id":"MDQ6VXNlcjM1OTQ1MA==","avatar_url":"https://avatars0.githubusercontent.com/u/359450?v=4","gravatar_id":"","url":"https://api.github.com/users/mauron85","html_url":"https://github.com/mauron85","followers_url":"https://api.github.com/users/mauron85/followers","following_url":"https://api.github.com/users/mauron85/following{/other_user}","gists_url":"https://api.github.com/users/mauron85/gists{/gist_id}","starred_url":"https://api.github.com/users/mauron85/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mauron85/subscriptions","organizations_url":"https://api.github.com/users/mauron85/orgs","repos_url":"https://api.github.com/users/mauron85/repos","events_url":"https://api.github.com/users/mauron85/events{/privacy}","received_events_url":"https://api.github.com/users/mauron85/received_events","type":"User","site_admin":false},"created_at":"2018-08-16T16:08:21Z","updated_at":"2018-08-16T16:08:21Z","author_association":"OWNER","body":"I think dedicated section in README.md would be ok."}}
{"actor":{"display_login":"mauron85"}}