Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_android_sdk_maven_plugin
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Panagiotis Triantafyllou
2023-06-28 13:36:07 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8c5dea5fd03c80613e391316a758a2d321295d0d
8c5dea5f
1 parent
6d70ebfb
telematics fixes
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
13 deletions
warply_android_sdk/src/main/AndroidManifest.xml
warply_android_sdk/src/main/java/ly/warp/sdk/activities/TelematicsActivity.java
warply_android_sdk/src/main/AndroidManifest.xml
View file @
8c5dea5
...
...
@@ -65,11 +65,11 @@
android:screenOrientation=
"portrait"
android:theme=
"@style/SDKAppTheme"
/>
<!-- <activity-->
<!-- android:name="ly.warp.sdk.activities.TelematicsActivity"-->
<!-- android:exported="false"-->
<!-- android:screenOrientation="portrait"-->
<!-- android:theme="@style/SDKAppTheme" />--
>
<activity
android:name=
"ly.warp.sdk.activities.TelematicsActivity"
android:exported=
"false"
android:screenOrientation=
"portrait"
android:theme=
"@style/SDKAppTheme"
/
>
<activity
android:name=
"ly.warp.sdk.activities.GiftsForYouActivity"
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/activities/TelematicsActivity.java
View file @
8c5dea5
...
...
@@ -74,7 +74,7 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
private
static
final
int
PERMISSION_REQUEST_ACCESS_FINE_LOCATION
=
4001
;
JSONArray
jsonArray
=
new
JSONArray
();
private
LocationManager
locationManager
;
private
static
final
int
LOCATION_UPDATE_INTERVAL
=
5
000
;
private
static
final
int
LOCATION_UPDATE_INTERVAL
=
1
000
;
double
mLatitude
=
0
;
double
mLongitude
=
0
;
// Radius of the Earth in meters
...
...
@@ -109,7 +109,6 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
@Override
public
void
onResume
()
{
super
.
onResume
();
requestLocationUpdates
();
// WarplyAnalyticsManager.logTrackersEvent(this, "screen", "TelematicsActivity");
}
...
...
@@ -183,6 +182,7 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
mIsTripStarted
=
false
;
mTvTripButton
.
setText
(
R
.
string
.
cos_dlg_start_trip
);
}
else
{
requestLocationUpdates
();
registerStepSensor
();
mIsTripStarted
=
true
;
mTvTripButton
.
setText
(
R
.
string
.
cos_dlg_stop_trip
);
...
...
@@ -197,6 +197,8 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
@Override
public
void
onRequestPermissionsResult
(
int
requestCode
,
@NonNull
String
[]
permissions
,
@NonNull
int
[]
grantResults
)
{
super
.
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
);
if
(
requestCode
==
PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE
)
{
if
(
grantResults
.
length
>
0
&&
grantResults
[
0
]
==
PackageManager
.
PERMISSION_GRANTED
)
{
saveAccelerationDataToExternalStorage
(
jsonArray
);
...
...
@@ -218,10 +220,16 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
public
void
onLocationChanged
(
Location
location
)
{
//TODO: uncomment and remove setText if needs revert to handler implementation
//TODO: LOCATION_UPDATE_INTERVAL = 300 when using location.getSpeed()
// float speedKmph =
(location.getSpeed() * 3600) / 1000
;
// float speedKmph =
location.getSpeed() * 3.6f
;
// mTvAvgVelocity.setText(String.format("%.1f", Math.floor(speedKmph)) + " km/h");
if
(
mLatitude
!=
0
&&
mLongitude
!=
0
)
requestLocationUpdatePeriodically
(
location
);
if
(
mLatitude
!=
0
&&
mLongitude
!=
0
)
{
double
speed
=
calculateSpeed
(
mLatitude
,
mLongitude
,
location
.
getLatitude
(),
location
.
getLongitude
(),
(
LOCATION_UPDATE_INTERVAL
/
1000
));
mTvAvgVelocity
.
setText
(
String
.
format
(
"%.1f"
,
Math
.
floor
(
speed
))
+
" km/h"
);
}
// if (mLatitude != 0 && mLongitude != 0)
// requestLocationUpdatePeriodically(location);
mLatitude
=
location
.
getLatitude
();
mLongitude
=
location
.
getLongitude
();
}
...
...
@@ -251,15 +259,12 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
}
private
void
requestLocationUpdates
()
{
// Check if the ACCESS_FINE_LOCATION permission is granted
if
(
ContextCompat
.
checkSelfPermission
(
this
,
Manifest
.
permission
.
ACCESS_FINE_LOCATION
)
!=
PackageManager
.
PERMISSION_GRANTED
)
{
// Permission is not granted, request it
ActivityCompat
.
requestPermissions
(
this
,
new
String
[]{
Manifest
.
permission
.
ACCESS_FINE_LOCATION
},
PERMISSION_REQUEST_ACCESS_FINE_LOCATION
);
}
else
{
// Permission is granted, start requesting location updates
startLocationUpdates
();
}
}
...
...
Please
register
or
login
to post a comment