Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPS Passive recording feature #275

Merged
merged 85 commits into from
May 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
60462f3
Merge pull request #21 from onaio/master
eotin Jan 28, 2019
88c93c2
Merge pull request #22 from eotin/master
eotin Jan 28, 2019
1be6529
Merge pull request #23 from onaio/master
eotin Feb 27, 2019
3a6444b
Merge pull request #24 from eotin/master
eotin Feb 27, 2019
01ea0ce
Fix issue in the WMTS layout
eotin Feb 27, 2019
8a588ab
Fix spelling Wmts activity
eotin Mar 4, 2019
6749217
Add TrackingService functionality
eotin Mar 15, 2019
dcbcd1d
Add recording images
eotin Mar 19, 2019
909beb6
Add Unit Tests
eotin Mar 20, 2019
e441be4
Merge pull request #25 from onaio/master
eotin Mar 20, 2019
d789e38
Merge branch 'eo/merge_passive_record_location' into Develop
eotin Mar 20, 2019
2b06ba4
Merge pull request #26 from eotin/Develop
eotin Mar 20, 2019
e8b4a74
Fix import issue after merging from onaio/master
eotin Mar 20, 2019
8c0e4d5
Merge pull request #27 from eotin/eo/merge_passive_record_location
eotin Mar 20, 2019
3875380
Merge pull request #28 from eotin/master
eotin Mar 20, 2019
17c85d6
Fix code regarding Codacy/PR Quality Review
eotin Mar 20, 2019
bca4fd3
Merge pull request #29 from eotin/Develop
eotin Mar 20, 2019
6e098a0
Fix code regarding Codacy/PR Quality Review
eotin Mar 20, 2019
6bf33a3
Merge pull request #30 from eotin/Develop
eotin Mar 20, 2019
2ba6a28
Fix code regarding Codacy/PR Quality Review
eotin Mar 20, 2019
789c88e
Merge pull request #31 from eotin/Develop
eotin Mar 20, 2019
a42d1a0
Fix code regarding Codacy Bot
eotin Mar 21, 2019
c8aa557
Merge pull request #32 from eotin/Develop
eotin Mar 21, 2019
44198b3
Merge pull request #33 from onaio/master
eotin Mar 25, 2019
2174318
Merge pull request #34 from eotin/master
eotin Mar 25, 2019
0b20657
Uncomment developmentKujakuModulesImport to be able to build successf…
eotin Mar 25, 2019
6f1ad3d
Merge pull request #35 from eotin/Develop
eotin Mar 25, 2019
b73985b
Avoid catching generic exceptions such as NullPointerException, Runti…
eotin Mar 25, 2019
914c751
Merge pull request #36 from eotin/Develop
eotin Mar 25, 2019
8965585
Increase unit tests Coverage
eotin Mar 25, 2019
707d494
Merge pull request #37 from eotin/Develop
eotin Mar 25, 2019
ee76564
Fix unused import
eotin Mar 25, 2019
a4021bf
Merge pull request #38 from eotin/Develop
eotin Mar 25, 2019
f4aef1f
Fix crash on activity after updating the mapbox sdk
eotin Mar 25, 2019
19e9efd
Merge pull request #39 from eotin/Develop
eotin Mar 25, 2019
ac68d4d
Add TrackingStorage Tests
eotin Mar 26, 2019
eee880b
Merge pull request #40 from eotin/Develop
eotin Mar 26, 2019
48156ac
Avoid catching generic exceptions such as NullPointerException, Runti…
eotin Mar 26, 2019
27809c0
Merge pull request #41 from eotin/Develop
eotin Mar 26, 2019
02d6f72
Fix test errors after having changed the KujakuMapView.java file
eotin Mar 27, 2019
785bf20
Merge pull request #42 from eotin/Develop
eotin Mar 27, 2019
eaad1d8
Add Test for Class WmtsLayer
eotin Apr 3, 2019
404c5d5
Merge pull request #43 from eotin/Develop
eotin Apr 3, 2019
dd44d9a
Add Test for Class BaseStorage / TrackingStorage
eotin Apr 3, 2019
530f886
Merge pull request #44 from eotin/Develop
eotin Apr 3, 2019
e342a58
Add Tests coverage for TrackingService class
eotin Apr 3, 2019
17251ac
Merge pull request #45 from eotin/Develop
eotin Apr 3, 2019
26d1afe
Fix "Document empty method body" code review
eotin Apr 3, 2019
e628dcb
Merge pull request #46 from eotin/Develop
eotin Apr 3, 2019
c2fa462
Update TrackingServiceTest class
eotin Apr 4, 2019
98eb0ba
Remove unused import
eotin Apr 4, 2019
50f32e2
Merge pull request #47 from eotin/Develop
eotin Apr 4, 2019
32f5cd8
Fix tracking service test class
eotin Apr 4, 2019
d7a4545
Merge pull request #48 from eotin/Develop
eotin Apr 4, 2019
a07f0b7
Refactor string initialization
eotin Apr 4, 2019
a53398c
Refactor accessing to the storage from the TrackingService
eotin Apr 4, 2019
0481e56
Merge pull request #49 from eotin/Develop
eotin Apr 4, 2019
cc9c2a6
Increase Unit test coverage
eotin Apr 5, 2019
a5e259d
Merge pull request #50 from eotin/Develop
eotin Apr 5, 2019
ca63756
Add Check storage permissions
eotin Apr 5, 2019
b882843
Merge pull request #51 from eotin/Develop
eotin Apr 5, 2019
a11c5c0
Use KujakuMapView#updateDroppedPoints instead of modifying accessibil…
eotin Apr 5, 2019
23e155f
Merge pull request #52 from eotin/Develop
eotin Apr 5, 2019
884c8ce
Merge branch 'master' of https://github.com/onaio/kujaku
eotin Apr 8, 2019
f65e473
Merge pull request #54 from eotin/master
eotin Apr 8, 2019
5b4e234
Use MultiplePermissionsListener instead of PermissionListener in Kuja…
eotin Apr 9, 2019
cdaa51e
Merge remote-tracking branch 'origin/Develop' into Develop
eotin Apr 9, 2019
be6ccc9
Merge pull request #55 from eotin/Develop
eotin Apr 9, 2019
c46b690
Check if all permissions are granted too
eotin Apr 10, 2019
adae2d9
Fix TrackingService code after coding review
eotin Apr 10, 2019
7ad91c0
Merge pull request #56 from eotin/Develop
eotin Apr 10, 2019
13f2285
Add Comments in TrackingServiceTest
eotin Apr 11, 2019
bc1274c
Merge pull request #57 from eotin/Develop
eotin Apr 11, 2019
dce1b99
Add Comments in TrackingServiceTest
eotin Apr 11, 2019
e0b890d
Merge pull request #58 from eotin/Develop
eotin Apr 11, 2019
3c6d41f
Merge pull request #59 from onaio/master
eotin Apr 11, 2019
acb57fb
Merge pull request #60 from eotin/master
eotin Apr 11, 2019
32e841d
Make the TrackingService icon configurable
eotin Apr 11, 2019
532bebd
Merge pull request #61 from eotin/Develop
eotin Apr 11, 2019
5bb6db0
Make the TrackingService icon configurable
eotin Apr 12, 2019
3f7a462
Merge pull request #62 from eotin/Develop
eotin Apr 12, 2019
0bc8e75
Update kujaku_permission_reason string
eotin Apr 16, 2019
ce15819
Merge pull request #63 from eotin/Develop
eotin Apr 16, 2019
0a2bf67
Add method to unregister the tracking listener
eotin Apr 18, 2019
7ed98eb
Merge pull request #64 from eotin/Develop
eotin Apr 18, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ android:
# tools required
- tools
# The BuildTools version used by your project
- build-tools-28.0.2
- build-tools-28.0.3
# The SDK version used to compile your projects
- android-27
- android-22
Expand Down
52 changes: 52 additions & 0 deletions SPECIFICATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,58 @@ public void addWmtsLayer(WmtsCapabilities capabilities, String layerIdentifier)
public void addWmtsLayer(WmtsCapabilities capabilities, String layerIdentifier, String styleIdentifier, String tileMatrixSetLinkIdentifier) throws Exception
```

## 2. Using Tracking Service

The Tracking Service is a foreground service providing Locations points regarding some options.
The application needs to register the TrackingService listener to be able to receive notifications when :
- First location as been received
- A new location has been recorded
- A location has been recorded close to the first location recorded

### API available

The `KujakuMapView` has public methods to control the TrackingService :

* This method initialize the Tracking Service and need an instance of TrackingServiceListener and instance of TrackingServiceOptions
```
void initTrackingService(@NonNull TrackingServiceListener trackingServiceListener, TrackingServiceUIConfiguration uiConfiguration, TrackingServiceOptions options);
```

* This method starts the Tracking Service and need the context and the class of the host activity
```
void startTrackingService(@NonNull Context context, @NonNull Class<?> cls) throws TrackingServiceNotInitializedException;
```

* This method stops the Tracking Service et returns a collection of collected Locations
```
public List<Location> stopTrackingService(@NonNull Context context)
```

* This method can bind to an already running instance of the TrackingService
```
public boolean resumeTrackingService(Context context)
```

* This method allows the user to force take a location. The last received pending location is then recorded
```
public void trackingServiceTakeLocation()
```

* This method returns a collection of collected Locations
```
public List<Location> getTrackingServiceRecordedLocations()
```

### TrackingService options

The abstract class `TrackingServiceOptions` provides parameters to the TrackingService instance.
2 classes extending the `TrackingServiceOptions` are available but you can create your own TrackingServiceOptions instance if needed.
All parameters are explained in the `TrackingServiceOptions`class.

### TrackingService UI configuration

The abstract class `TrackingServiceUIConfiguration` provides ui configuration to the TrackingService instance.
1 class extending the `TrackingServiceUIConfiguration` is available but you can create your own TrackingServiceUIConfiguration instance if needed.

## Offline Maps Downloader Service

Expand Down
4 changes: 1 addition & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import groovy.transform.Field

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
Expand Down Expand Up @@ -37,7 +35,7 @@ task clean(type: Delete) {

ext {
supportVersion = '27.1.1'
buildToolsVersion = "28.0.2"
buildToolsVersion = "28.0.3"
compileSdkVersion = 27
volleyVersion = "1.1.0"
targetSdkVersion = 27
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ POM_SETTING_LICENCE_DIST=repo
POM_SETTING_DEVELOPER_ID=opensrp
POM_SETTING_DEVELOPER_NAME=OpenSRP Onadev

# android.debug.obsoleteApi=true

4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Sep 26 19:47:37 EAT 2018
#Thu Feb 28 14:26:07 CET 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ public void enableAddPointShouldHideMarkerLayoutWhenPassedFalse() throws NoSuchF

@Test
public void enableAddPointShouldEnableLocationUpdatesWhenGivenOnLocationChangedAndTrue() throws NoSuchFieldException, IllegalAccessException {
String isMapScrollingVariableName = "isMapScrolled";
insertValueInPrivateField(KujakuMapView.class, kujakuMapView, isMapScrollingVariableName, true);
String updateCameraUserLocationOnMap = "updateCameraUserLocationOnMap";
insertValueInPrivateField(KujakuMapView.class, kujakuMapView, updateCameraUserLocationOnMap, false);

OnLocationChanged onLocationChanged = new OnLocationChanged() {
@Override
Expand All @@ -139,7 +139,7 @@ public void onLocationChanged(Location location) {
};

kujakuMapView.enableAddPoint(true, onLocationChanged);
assertFalse((boolean) getValueInPrivateField(KujakuMapView.class, kujakuMapView, isMapScrollingVariableName));
assertTrue((boolean) getValueInPrivateField(KujakuMapView.class, kujakuMapView, updateCameraUserLocationOnMap));
assertEquals(onLocationChanged, getValueInPrivateField(KujakuMapView.class, kujakuMapView, "onLocationChangedListener"));
assertTrue((boolean) getValueInPrivateField(KujakuMapView.class, kujakuMapView, "updateUserLocationOnMap"));
}
Expand Down Expand Up @@ -251,17 +251,20 @@ public void showCurrentLocationBtnShouldChangeVisibleWhenCalled() {
@Test
public void focusOnUserLocationShouldChangeTargetIconWhenCalled() throws NoSuchFieldException, IllegalAccessException {
String updateUserLocationOnMap = "updateUserLocationOnMap";
String updateCameraUserLocationOnMap = "updateCameraUserLocationOnMap";

kujakuMapView.focusOnUserLocation(true);
assertTrue((boolean) getValueInPrivateField(KujakuMapView.class, kujakuMapView, updateUserLocationOnMap));
assertTrue((boolean) getValueInPrivateField(KujakuMapView.class, kujakuMapView, updateCameraUserLocationOnMap));
ImageButton imageButton = kujakuMapView.findViewById(R.id.ib_mapview_focusOnMyLocationIcon);

int drawableResId = (int) getValueInPrivateField(ImageView.class, imageButton, "mResource");
assertEquals(R.drawable.ic_cross_hair_blue, drawableResId);


kujakuMapView.focusOnUserLocation(false);
assertFalse((boolean) getValueInPrivateField(KujakuMapView.class, kujakuMapView, updateUserLocationOnMap));
assertTrue((boolean) getValueInPrivateField(KujakuMapView.class, kujakuMapView, updateUserLocationOnMap));
assertFalse((boolean) getValueInPrivateField(KujakuMapView.class, kujakuMapView, updateCameraUserLocationOnMap));

drawableResId = (int) getValueInPrivateField(ImageView.class, imageButton, "mResource");
assertEquals(R.drawable.ic_cross_hair, drawableResId);
Expand All @@ -270,17 +273,20 @@ public void focusOnUserLocationShouldChangeTargetIconWhenCalled() throws NoSuchF
@Test
public void focusOnUserLocationWithRadiusShouldChangeTargetIconWhenCalled() throws NoSuchFieldException, IllegalAccessException {
String updateUserLocationOnMap = "updateUserLocationOnMap";
String updateCameraUserLocationOnMap = "updateCameraUserLocationOnMap";

kujakuMapView.focusOnUserLocation(true, 25f);
assertTrue((boolean) getValueInPrivateField(KujakuMapView.class, kujakuMapView, updateUserLocationOnMap));
assertTrue((boolean) getValueInPrivateField(KujakuMapView.class, kujakuMapView, updateCameraUserLocationOnMap));
ImageButton imageButton = kujakuMapView.findViewById(R.id.ib_mapview_focusOnMyLocationIcon);

int drawableResId = (int) getValueInPrivateField(ImageView.class, imageButton, "mResource");
assertEquals(R.drawable.ic_cross_hair_blue, drawableResId);


kujakuMapView.focusOnUserLocation(false);
assertFalse((boolean) getValueInPrivateField(KujakuMapView.class, kujakuMapView, updateUserLocationOnMap));
assertTrue((boolean) getValueInPrivateField(KujakuMapView.class, kujakuMapView, updateUserLocationOnMap));
assertFalse((boolean) getValueInPrivateField(KujakuMapView.class, kujakuMapView, updateCameraUserLocationOnMap));

drawableResId = (int) getValueInPrivateField(ImageView.class, imageButton, "mResource");
assertEquals(R.drawable.ic_cross_hair, drawableResId);
Expand Down
5 changes: 5 additions & 0 deletions library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<application
android:allowBackup="true"
Expand All @@ -17,6 +19,9 @@
android:name=".activities.MapActivity"
android:exported="false" />
<service android:name=".services.MapboxOfflineDownloaderService"/>
<service android:name=".services.TrackingService"
android:label="Tracking Service">
</service>
<receiver android:name=".receivers.KujakuNetworkChangeReceiver">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import io.ona.kujaku.adapters.InfoWindowObject;
import io.ona.kujaku.adapters.holders.InfoWindowViewHolder;
import io.ona.kujaku.domain.Point;
import io.ona.kujaku.helpers.MapBoxStyleStorage;
import io.ona.kujaku.helpers.storage.MapBoxStyleStorage;
import io.ona.kujaku.sorting.Sorter;
import io.ona.kujaku.utils.Constants;
import io.ona.kujaku.utils.Permissions;
Expand Down Expand Up @@ -467,9 +467,9 @@ protected void onPause() {
protected void onDestroy() {
super.onDestroy();

if (currentStylePath != null && currentStylePath.startsWith("file://") && currentStylePath.contains(MapBoxStyleStorage.DIRECTORY)) {
if (currentStylePath != null && currentStylePath.startsWith("file://") && currentStylePath.contains(MapBoxStyleStorage.BASE_DIRECTORY)) {
new MapBoxStyleStorage()
.deleteFile(currentStylePath.replace("file://", ""), true);
.deleteFile(currentStylePath.replace("file://", ""), true, false);
}

if (kujakuMapView != null) kujakuMapView.onDestroy();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.ona.kujaku.exceptions;

/**
* Created by Emmanuel Otin - [email protected] 12/04/19.
*/
public class TrackingServiceNotInitializedException extends Exception {

public TrackingServiceNotInitializedException() {
super("The TackingService has not been initialized");
}

public TrackingServiceNotInitializedException(String message) {
super(message);
}

}
Loading