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-11-16 19:27:25 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
58e30650f1e47f8c66b4b8a5f31eba772de5a810
58e30650
1 parent
95c66a57
telematics fixes
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
warply_android_sdk/src/main/java/ly/warp/sdk/activities/TelematicsActivity.java
warply_android_sdk/src/main/java/ly/warp/sdk/activities/TelematicsActivity.java
View file @
58e3065
...
...
@@ -83,9 +83,10 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
private
float
velocity
=
0
;
private
ArrayList
<
JSONObject
>
mAccelerationTimestamps
=
new
ArrayList
<>();
private
float
mAcceleration
=
0
;
private
final
float
ALPHA
=
0.8f
;
// Filter factor
private
final
float
STOP_THRESHOLD
=
8.0f
;
// Stop threshold in m/s²
private
final
int
PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE
=
4000
;
private
final
float
ALPHA
=
0.5f
;
// Filter factor 0.8f
private
final
float
STOP_THRESHOLD
=
10.0f
;
// Stop threshold in m/s² 8.0f
private
final
int
PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE
=
4003
;
private
final
int
PERMISSION_REQUEST_LOCATION_SETTINGS
=
4000
;
private
final
int
PERMISSION_REQUEST_ACCESS_FINE_LOCATION
=
4001
;
private
JSONArray
jsonArray
=
new
JSONArray
();
private
LocationManager
locationManager
;
...
...
@@ -94,7 +95,6 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
private
double
mLongitude
=
0
;
// Radius of the Earth in meters
private
final
double
EARTH_RADIUS
=
6371000.0
;
private
Location
previousLocation
;
private
double
mSpeed
=
0
;
private
int
orientationCount
=
0
,
touchCount
=
0
;
final
long
REFRESH_TIME
=
100
;
// miliseconds
...
...
@@ -102,7 +102,6 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
private
final
int
RECORDS_INTERVAL
=
5000
;
private
EditText
mEtLimit
,
mEtSampleTime
;
private
RelativeLayout
mRlMainScroll
;
private
int
REQUEST_LOCATION_SETTINGS
=
4000
;
// ===========================================================
...
...
@@ -136,7 +135,6 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
mLlTelematicsHistory
.
setOnClickListener
(
this
);
locationManager
=
(
LocationManager
)
getSystemService
(
Context
.
LOCATION_SERVICE
);
previousLocation
=
null
;
initViews
();
}
...
...
@@ -308,7 +306,7 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
@Override
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
if
(
requestCode
==
REQUEST_LOCATION_SETTINGS
)
{
if
(
requestCode
==
PERMISSION_
REQUEST_LOCATION_SETTINGS
)
{
switch
(
resultCode
)
{
case
Activity
.
RESULT_OK
:
mIsTripStarted
=
true
;
...
...
@@ -423,7 +421,7 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
jobjData
.
putOpt
(
"latitude"
,
mLatitude
);
jobjData
.
putOpt
(
"longitude"
,
mLongitude
);
jobjData
.
putOpt
(
"limit"
,
getCutOffLimit
());
jobjData
.
putOpt
(
"samples"
,
TextUtils
.
isEmpty
(
mEtSampleTime
.
getText
())
?
RECORDS_INTERVAL
:
Integer
.
valueOf
(
mEtSampleTime
.
getText
().
toString
()));
jobjData
.
putOpt
(
"samples"
,
TextUtils
.
isEmpty
(
mEtSampleTime
.
getText
())
?
RECORDS_INTERVAL
:
Integer
.
parseInt
(
mEtSampleTime
.
getText
().
toString
()));
jobj
.
putOpt
(
timestamp
,
jobjData
);
mAccelerationTimestamps
.
add
(
jobj
);
recordsCount
[
0
]++;
...
...
@@ -431,11 +429,14 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
Snackbar
.
make
(
mLlTelematicsMain
,
"Runnable Failed"
,
Snackbar
.
LENGTH_SHORT
).
show
();
}
finally
{
mHandler
.
removeCallbacks
(
mRunnable
);
mHandler
=
new
Handler
();
mHandler
.
postDelayed
(
this
,
TextUtils
.
isEmpty
(
mEtSampleTime
.
getText
())
?
RECORDS_INTERVAL
:
Integer
.
parseInt
(
mEtSampleTime
.
getText
().
toString
()));
}
mHandler
.
postDelayed
(
this
,
TextUtils
.
isEmpty
(
mEtSampleTime
.
getText
())
?
RECORDS_INTERVAL
:
Integer
.
valueOf
(
mEtSampleTime
.
getText
().
toString
()));
}
};
mHandler
.
post
Delayed
(
mRunnable
,
TextUtils
.
isEmpty
(
mEtSampleTime
.
getText
())
?
RECORDS_INTERVAL
:
Integer
.
valueOf
(
mEtSampleTime
.
getText
().
toString
())
);
mHandler
.
post
(
mRunnable
);
}
private
void
unregisterSensor
()
{
...
...
@@ -551,7 +552,7 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
ResolvableApiException
resolvable
=
(
ResolvableApiException
)
exception
;
// Show the dialog by calling startResolutionForResult(),
// and check the result in onActivityResult().
resolvable
.
startResolutionForResult
(
TelematicsActivity
.
this
,
REQUEST_LOCATION_SETTINGS
);
resolvable
.
startResolutionForResult
(
TelematicsActivity
.
this
,
PERMISSION_
REQUEST_LOCATION_SETTINGS
);
}
catch
(
IntentSender
.
SendIntentException
e
)
{
// Ignore the error.
Log
.
v
(
"SendIntentException"
,
e
.
getMessage
());
...
...
Please
register
or
login
to post a comment