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
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
2 years ago
by
theiled00
Browse files
Options
Downloads
Patches
Plain Diff
Adjust android setup; setup connection to local running backend
parent
ca0c86a3
Branches
Branches containing commit
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 {
...
@@ -47,7 +47,7 @@ android {
applicationId
"com.example.router_app"
applicationId
"com.example.router_app"
// You can update the following values to match your application needs.
// 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.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion
flutter
.
minSdkVersion
minSdkVersion
20
targetSdkVersion
flutter
.
targetSdkVersion
targetSdkVersion
flutter
.
targetSdkVersion
versionCode
flutterVersionCode
.
toInteger
()
versionCode
flutterVersionCode
.
toInteger
()
versionName
flutterVersionName
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 @@
...
@@ -32,7 +32,8 @@
android:value=
"2"
/>
android:value=
"2"
/>
<meta-data
android:name=
"com.google.andoid.geo.API_KEY"
<meta-data
android:name=
"com.google.andoid.geo.API_KEY"
android:value=
"AIzaSyAzedQacDEZmyxAOUEEeocvehT8MEdMWys"
/>
android:value=
"AIzaSyAzedQacDEZmyxAOUEEeocvehT8MEdMWys"
/>
</application>
<uses-permission
android:name=
"android.permission.ACCESS_FINE_LOCATION"
/>
<uses-permission
android:name=
"android.permission.ACCESS_FINE_LOCATION"
/>
<uses-permission
android:name=
"android.permission.ACCESS_COARSE_LOCATION"
/>
<uses-permission
android:name=
"android.permission.ACCESS_COARSE_LOCATION"
/>
</application>
</manifest>
</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> {
...
@@ -214,17 +214,32 @@ class _MyHomePageState extends State<MyHomePage> {
var
destlon
=
_destCoordinates
.
longitude
;
var
destlon
=
_destCoordinates
.
longitude
;
// Get direction data
// Get direction data
final
response
=
await
http
.
get
(
// No weather or days included for now
Uri
.
parse
(
final
response
=
await
http
.
post
(
'https://api.openrouteservice.org/v2/directions/driving-car?api_key=
${config.OSM_API}
&start=
$originlon
,
$originlat
&end=
$destlon
,
$destlat
'
,
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
);
_data
=
jsonDecode
(
response
.
body
);
var
coordinates
=
_data
[
'
features'
][
0
][
'geometry'
][
'coordina
te
s
'
];
var
coordinates
=
_data
[
'
rou
te'
];
double
duration
=
int
duration
=
_data
[
'duration'
];
_data
[
'features'
][
0
][
'properties'
][
'segments'
][
0
][
'duration
'
];
int
distance
=
_data
[
'distance
'
];
double
distance
=
//TODO include day
_data
[
'features'
][
0
][
'properties'
][
'segments'
][
0
][
'distance
'
];
int
daysAfterToday
=
_data
[
'days_after_today
'
];
// Format duration and distance
// Format duration and distance
_totalDuration
=
getTotalDuration
(
duration
);
_totalDuration
=
getTotalDuration
(
duration
);
...
@@ -260,12 +275,11 @@ class _MyHomePageState extends State<MyHomePage> {
...
@@ -260,12 +275,11 @@ class _MyHomePageState extends State<MyHomePage> {
// Draw polyline based on given coordinates
// Draw polyline based on given coordinates
for
(
int
i
=
0
;
i
<
ls
.
lineString
.
length
;
i
++
)
{
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
)
{
String
getTotalDuration
(
int
durationInMins
)
{
double
durationInMins
=
duration
/
60
;
int
hours
=
(
durationInMins
/
60
)
.
floor
();
int
hours
=
(
durationInMins
/
60
)
.
floor
();
int
min
=
(
durationInMins
%
60
)
.
floor
();
int
min
=
(
durationInMins
%
60
)
.
floor
();
if
(
hours
!=
0
)
{
if
(
hours
!=
0
)
{
...
@@ -274,7 +288,7 @@ class _MyHomePageState extends State<MyHomePage> {
...
@@ -274,7 +288,7 @@ class _MyHomePageState extends State<MyHomePage> {
return
'
$min
mins'
;
return
'
$min
mins'
;
}
}
String
getTotalDistance
(
double
distance
)
{
String
getTotalDistance
(
int
distance
)
{
int
distanceInKm
=
(
distance
/
1000
)
.
ceil
();
int
distanceInKm
=
(
distance
/
1000
)
.
ceil
();
return
'
$distanceInKm
km'
;
return
'
$distanceInKm
km'
;
}
}
...
@@ -954,8 +968,9 @@ class _MyHomePageState extends State<MyHomePage> {
...
@@ -954,8 +968,9 @@ class _MyHomePageState extends State<MyHomePage> {
itemCount:
1
,
itemCount:
1
,
padding:
EdgeInsets
.
all
(
20
),
padding:
EdgeInsets
.
all
(
20
),
itemBuilder:
(
BuildContext
context
,
int
index
)
{
itemBuilder:
(
BuildContext
context
,
int
index
)
{
return
Expanded
(
return
Stack
(
child:
Column
(
children:
[
Column
(
children:
[
children:
[
Container
(
Container
(
margin:
EdgeInsets
.
only
(
bottom:
15
,
top:
5
),
margin:
EdgeInsets
.
only
(
bottom:
15
,
top:
5
),
...
@@ -1231,6 +1246,7 @@ class _MyHomePageState extends State<MyHomePage> {
...
@@ -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