Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Navigation App
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWP Datenverwaltung Navigation 2023
Navigation App
Commits
d986b2ca
Commit
d986b2ca
authored
Mar 30, 2023
by
theiled00
Browse files
Options
Downloads
Patches
Plain Diff
Adjust android setup; setup connection to local running backend
parent
ca0c86a3
No related branches found
No related tags found
1 merge request
!6
final project merge into main
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
android/app/build.gradle
+1
-1
1 addition, 1 deletion
android/app/build.gradle
android/app/src/main/AndroidManifest.xml
+3
-2
3 additions, 2 deletions
android/app/src/main/AndroidManifest.xml
lib/main.dart
+30
-14
30 additions, 14 deletions
lib/main.dart
with
34 additions
and
17 deletions
android/app/build.gradle
+
1
−
1
View file @
d986b2ca
...
...
@@ -47,7 +47,7 @@ android {
applicationId
"com.example.router_app"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion
flutter
.
minSdkVersion
minSdkVersion
20
targetSdkVersion
flutter
.
targetSdkVersion
versionCode
flutterVersionCode
.
toInteger
()
versionName
flutterVersionName
...
...
This diff is collapsed.
Click to expand it.
android/app/src/main/AndroidManifest.xml
+
3
−
2
View file @
d986b2ca
...
...
@@ -32,7 +32,8 @@
android:value=
"2"
/>
<meta-data
android:name=
"com.google.andoid.geo.API_KEY"
android:value=
"AIzaSyAzedQacDEZmyxAOUEEeocvehT8MEdMWys"
/>
</application>
<uses-permission
android:name=
"android.permission.ACCESS_FINE_LOCATION"
/>
<uses-permission
android:name=
"android.permission.ACCESS_COARSE_LOCATION"
/>
</application>
</manifest>
This diff is collapsed.
Click to expand it.
lib/main.dart
+
30
−
14
View file @
d986b2ca
...
...
@@ -214,17 +214,32 @@ class _MyHomePageState extends State<MyHomePage> {
var
destlon
=
_destCoordinates
.
longitude
;
// Get direction data
final
response
=
await
http
.
get
(
Uri
.
parse
(
'https://api.openrouteservice.org/v2/directions/driving-car?api_key=
${config.OSM_API}
&start=
$originlon
,
$originlat
&end=
$destlon
,
$destlat
'
,
// No weather or days included for now
final
response
=
await
http
.
post
(
Uri
.
parse
(
'http://10.0.2.2:8080/route'
),
body:
jsonEncode
(
{
"start_node"
:
{
"lat"
:
originlat
,
"lon"
:
originlon
},
"end_node"
:
{
"lat"
:
destlat
,
"lon"
:
destlon
},
"forbidden"
:
[],
"start_after_today"
:
0
,
"end_after_today"
:
0
}
),
headers:
<
String
,
String
>{
"Content-Type"
:
"application/json"
}
);
_data
=
jsonDecode
(
response
.
body
);
var
coordinates
=
_data
[
'
features'
][
0
][
'geometry'
][
'coordina
te
s
'
];
double
duration
=
_data
[
'features'
][
0
][
'properties'
][
'segments'
][
0
][
'duration
'
];
double
distance
=
_data
[
'features'
][
0
][
'properties'
][
'segments'
][
0
][
'distance
'
];
var
coordinates
=
_data
[
'
rou
te'
];
int
duration
=
_data
[
'duration'
];
int
distance
=
_data
[
'distance
'
];
//TODO include day
int
daysAfterToday
=
_data
[
'days_after_today
'
];
// Format duration and distance
_totalDuration
=
getTotalDuration
(
duration
);
...
...
@@ -260,12 +275,11 @@ class _MyHomePageState extends State<MyHomePage> {
// Draw polyline based on given coordinates
for
(
int
i
=
0
;
i
<
ls
.
lineString
.
length
;
i
++
)
{
_polyline
.
add
(
latlng
.
LatLng
(
ls
.
lineString
[
i
][
1
],
ls
.
lineString
[
i
][
0
]));
_polyline
.
add
(
latlng
.
LatLng
(
ls
.
lineString
[
i
][
0
],
ls
.
lineString
[
i
][
1
]));
}
}
String
getTotalDuration
(
double
duration
)
{
double
durationInMins
=
duration
/
60
;
String
getTotalDuration
(
int
durationInMins
)
{
int
hours
=
(
durationInMins
/
60
)
.
floor
();
int
min
=
(
durationInMins
%
60
)
.
floor
();
if
(
hours
!=
0
)
{
...
...
@@ -274,7 +288,7 @@ class _MyHomePageState extends State<MyHomePage> {
return
'
$min
mins'
;
}
String
getTotalDistance
(
double
distance
)
{
String
getTotalDistance
(
int
distance
)
{
int
distanceInKm
=
(
distance
/
1000
)
.
ceil
();
return
'
$distanceInKm
km'
;
}
...
...
@@ -954,8 +968,9 @@ class _MyHomePageState extends State<MyHomePage> {
itemCount:
1
,
padding:
EdgeInsets
.
all
(
20
),
itemBuilder:
(
BuildContext
context
,
int
index
)
{
return
Expanded
(
child:
Column
(
return
Stack
(
children:
[
Column
(
children:
[
Container
(
margin:
EdgeInsets
.
only
(
bottom:
15
,
top:
5
),
...
...
@@ -1231,6 +1246,7 @@ class _MyHomePageState extends State<MyHomePage> {
),
],
),
],
);
},
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment