also looking at this
feat(android): the location-recording controls in Zig — ratchet 65 → 61
#181
7 files
+568
-22
| @@ -1772,6 +1772,10 @@ class CraftBridge( | ||
| 1772 | 1772 | |
| 1773 | 1773 | @JavascriptInterface |
| 1774 | 1774 | fun startLocationRecording(optionsJson: String): String { |
| 1775 | // Null is "Zig declined". A permission-denied answer is not null — it | |
| 1776 | // is a state object saying so, and returning it here is the answer. | |
| 1777 | CraftNative.startLocationRecording(activity)?.let { return it } | |
| 1778 | ||
| 1775 | 1779 | if (ContextCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { |
| 1776 | 1780 | return JSONObject().apply { |
| 1777 | 1781 | put("id", JSONObject.NULL) |
| @@ -1792,12 +1796,16 @@ class CraftBridge( | ||
| 1792 | 1796 | |
| 1793 | 1797 | @JavascriptInterface |
| 1794 | 1798 | fun pauseLocationRecording(): String { |
| 1799 | CraftNative.pauseLocationRecording(activity)?.let { return it } | |
| 1800 | ||
| 1795 | 1801 | CraftLocationRecordingStore.setPaused(activity, true) |
| 1796 | 1802 | return CraftLocationRecordingStore.state(activity).toString() |
| 1797 | 1803 | } |
| 1798 | 1804 | |
| 1799 | 1805 | @JavascriptInterface |
| 1800 | 1806 | fun resumeLocationRecording(): String { |
| 1807 | CraftNative.resumeLocationRecording(activity)?.let { return it } | |
| 1808 | ||
| 1801 | 1809 | CraftLocationRecordingStore.setPaused(activity, false) |
| 1802 | 1810 | if (CraftLocationRecordingStore.isActive(activity)) { |
| 1803 | 1811 | ContextCompat.startForegroundService( |
| @@ -1810,6 +1818,8 @@ class CraftBridge( | ||
| 1810 | 1818 | |
| 1811 | 1819 | @JavascriptInterface |
| 1812 | 1820 | fun stopLocationRecording(): String { |
| 1821 | CraftNative.stopLocationRecording(activity)?.let { return it } | |
| 1822 | ||
| 1813 | 1823 | CraftLocationRecordingStore.stop(activity) |
| 1814 | 1824 | val result = CraftLocationRecordingStore.state(activity, includeLocations = true).toString() |
| 1815 | 1825 | activity.stopService(Intent(activity, LocationRecordingService::class.java).setAction(LocationRecordingService.ACTION_STOP)) |