Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-020
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
O.V.B Sewmina
2022-020
Commits
73d8fd25
Commit
73d8fd25
authored
Oct 08, 2022
by
A.P.R.C. Abeyrathna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Destination location selector added
Bus live tracker added V1
parent
acd7e607
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
162 additions
and
15 deletions
+162
-15
.idea/vcs.xml
.idea/vcs.xml
+6
-0
app/build.gradle
app/build.gradle
+2
-0
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
+14
-9
app/src/main/java/com/app/travelle/InitialMap.java
app/src/main/java/com/app/travelle/InitialMap.java
+25
-1
app/src/main/java/com/app/travelle/RetrieveBusMap.java
app/src/main/java/com/app/travelle/RetrieveBusMap.java
+78
-0
app/src/main/res/layout/activity_initial_map.xml
app/src/main/res/layout/activity_initial_map.xml
+21
-3
app/src/main/res/layout/activity_retrieve_bus_map.xml
app/src/main/res/layout/activity_retrieve_bus_map.xml
+9
-0
app/src/main/res/layout/activity_welcome.xml
app/src/main/res/layout/activity_welcome.xml
+1
-1
app/src/main/res/values/strings.xml
app/src/main/res/values/strings.xml
+1
-0
build.gradle
build.gradle
+5
-1
No files found.
.idea/vcs.xml
0 → 100644
View file @
73d8fd25
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"VcsDirectoryMappings"
>
<mapping
directory=
""
vcs=
"Git"
/>
</component>
</project>
\ No newline at end of file
app/build.gradle
View file @
73d8fd25
plugins
{
id
'com.android.application'
id
'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
id
'com.google.gms.google-services'
}
android
{
...
...
@@ -42,6 +43,7 @@ dependencies {
implementation
'com.google.android.gms:play-services-maps:18.1.0'
implementation
'com.google.android.gms:play-services-maps:18.1.0'
implementation
'com.google.android.gms:play-services-location:20.0.0'
implementation
'com.google.firebase:firebase-database:20.0.4'
testImplementation
'junit:junit:4.13.2'
androidTestImplementation
'androidx.test.ext:junit:1.1.3'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.4.0'
...
...
app/src/main/AndroidManifest.xml
View file @
73d8fd25
...
...
@@ -14,17 +14,11 @@
android:icon=
"@mipmap/ic_launcher"
android:label=
"@string/app_name"
android:roundIcon=
"@mipmap/ic_launcher_round"
android:screenOrientation=
"sensorPortrait"
android:supportsRtl=
"true"
android:theme=
"@style/Theme.Travelle"
android:screenOrientation=
"sensorPortrait"
tools:targetApi=
"31"
>
<activity
android:name=
".InitialMap"
android:exported=
"false"
>
<meta-data
android:name=
"android.app.lib_name"
android:value=
""
/>
</activity>
<!--
TODO: Before you run your application, you need a Google Maps API key.
...
...
@@ -38,8 +32,19 @@
-->
<meta-data
android:name=
"com.google.android.geo.API_KEY"
android:value=
"
AIzaSyD7LBGU3enFRU4u2is65UDT5jRGeIcx4_Q
"
/>
android:value=
"
YOUR_API_KEY
"
/>
<activity
android:name=
".RetrieveBusMap"
android:exported=
"false"
android:label=
"@string/title_activity_retrieve_bus_map"
/>
<activity
android:name=
".InitialMap"
android:exported=
"false"
>
<meta-data
android:name=
"android.app.lib_name"
android:value=
""
/>
</activity>
<activity
android:name=
".HomeMap"
android:exported=
"false"
...
...
app/src/main/java/com/app/travelle/InitialMap.java
View file @
73d8fd25
...
...
@@ -6,13 +6,17 @@ import androidx.core.app.ActivityCompat;
import
android.Manifest
;
import
android.annotation.SuppressLint
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.content.res.Resources
;
import
android.graphics.Color
;
import
android.location.Location
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.View
;
import
android.view.WindowManager
;
import
android.widget.ArrayAdapter
;
import
android.widget.AutoCompleteTextView
;
import
com.google.android.gms.location.FusedLocationProviderClient
;
import
com.google.android.gms.location.LocationServices
;
...
...
@@ -28,10 +32,18 @@ import com.google.android.gms.maps.model.Polyline;
import
com.google.android.gms.maps.model.PolylineOptions
;
import
com.google.android.gms.tasks.OnSuccessListener
;
import
com.google.android.gms.tasks.Task
;
import
android.view.View
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
InitialMap
extends
AppCompatActivity
{
//Initialize variable
private
static
final
String
[]
CITIES
=
new
String
[]{
"Viharamahadevi Park"
,
"House Of Fashion"
,
"Castle Street"
,
"Rajagiriya"
,
"HSBC Rajagiriya"
,
"Ethulkotte New"
,
"Parliament Junction"
,
"Battaramulla Junction"
,
"Ganahena"
,
"Koswatta"
,
"Kotte-Bope"
,
"Thalahena Junction"
,
"Malabe"
,
"Fort_TR"
,
"Kompannavidiya_TR"
,
"Kollupitiya_TR"
,
"Bambalapitiya_TR"
,
"Wellawatte_TR"
,
"Dehiwala_TR"
};
//Initialize variable
SupportMapFragment
supportMapFragment
;
FusedLocationProviderClient
client
;
GoogleMap
map
;
...
...
@@ -44,6 +56,12 @@ public class InitialMap extends AppCompatActivity {
getSupportActionBar
().
hide
();
setContentView
(
R
.
layout
.
activity_initial_map
);
//Where to declaration
AutoCompleteTextView
editText
=
findViewById
(
R
.
id
.
where_to
);
ArrayAdapter
<
String
>
adapter
=
new
ArrayAdapter
<
String
>(
this
,
android
.
R
.
layout
.
simple_list_item_1
,
CITIES
);
editText
.
setAdapter
(
adapter
);
//Assign variable
...
...
@@ -67,6 +85,12 @@ public class InitialMap extends AppCompatActivity {
}
}
public
void
btnRetrieveLocation
(
View
view
)
{
startActivity
(
new
Intent
(
getApplicationContext
(),
RetrieveBusMap
.
class
));
}
private
void
getCurrentLocation
()
{
//Initialize task location
if
(
ActivityCompat
.
checkSelfPermission
(
this
,
Manifest
.
permission
.
ACCESS_FINE_LOCATION
)
!=
PackageManager
.
PERMISSION_GRANTED
&&
ActivityCompat
.
checkSelfPermission
(
this
,
Manifest
.
permission
.
ACCESS_COARSE_LOCATION
)
!=
PackageManager
.
PERMISSION_GRANTED
)
{
...
...
app/src/main/java/com/app/travelle/RetrieveBusMap.java
0 → 100644
View file @
73d8fd25
package
com.app.travelle
;
import
androidx.annotation.NonNull
;
import
androidx.fragment.app.FragmentActivity
;
import
android.os.Bundle
;
import
com.google.android.gms.maps.CameraUpdateFactory
;
import
com.google.android.gms.maps.GoogleMap
;
import
com.google.android.gms.maps.OnMapReadyCallback
;
import
com.google.android.gms.maps.SupportMapFragment
;
import
com.google.android.gms.maps.model.LatLng
;
import
com.google.android.gms.maps.model.MarkerOptions
;
import
com.app.travelle.databinding.ActivityRetrieveBusMapBinding
;
import
com.google.firebase.database.DataSnapshot
;
import
com.google.firebase.database.DatabaseError
;
import
com.google.firebase.database.DatabaseReference
;
import
com.google.firebase.database.FirebaseDatabase
;
import
com.google.firebase.database.ValueEventListener
;
public
class
RetrieveBusMap
extends
FragmentActivity
implements
OnMapReadyCallback
{
private
GoogleMap
mMap
;
private
ActivityRetrieveBusMapBinding
binding
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
binding
=
ActivityRetrieveBusMapBinding
.
inflate
(
getLayoutInflater
());
setContentView
(
binding
.
getRoot
());
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment
mapFragment
=
(
SupportMapFragment
)
getSupportFragmentManager
()
.
findFragmentById
(
R
.
id
.
map
);
mapFragment
.
getMapAsync
(
this
);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public
void
onMapReady
(
GoogleMap
googleMap
)
{
mMap
=
googleMap
;
DatabaseReference
databaseReference
=
FirebaseDatabase
.
getInstance
().
getReference
(
"/"
);
ValueEventListener
listener
=
databaseReference
.
addValueEventListener
(
new
ValueEventListener
()
{
@Override
public
void
onDataChange
(
@NonNull
DataSnapshot
dataSnapshot
)
{
Double
latitude
=
dataSnapshot
.
child
(
"latitude"
).
getValue
(
Double
.
class
);
Double
longitude
=
dataSnapshot
.
child
(
"longitude"
).
getValue
(
Double
.
class
);
LatLng
location
=
new
LatLng
(
latitude
,
longitude
);
mMap
.
addMarker
(
new
MarkerOptions
().
position
(
location
).
title
(
"117"
));
mMap
.
moveCamera
(
CameraUpdateFactory
.
newLatLngZoom
(
location
,
14
F
));
}
@Override
public
void
onCancelled
(
@NonNull
DatabaseError
databaseError
)
{
}
});
}
}
\ No newline at end of file
app/src/main/res/layout/activity_initial_map.xml
View file @
73d8fd25
...
...
@@ -23,7 +23,7 @@
app:layout_constraintStart_toStartOf=
"parent"
app:srcCompat=
"@drawable/rectangle_16"
/>
<com.google.android.material.textfield.TextInputLayout
<!--
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/search_destination"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="340dp"
...
...
@@ -54,15 +54,16 @@
android:layout_height="wrap_content"
android:fontFamily="@font/sans_bold"
android:hint="Where to?" />
</com.google.android.material.textfield.TextInputLayout>
</com.google.android.material.textfield.TextInputLayout>
-->
<Button
android:id=
"@+id/
button2
"
android:id=
"@+id/
findbus
"
android:layout_width=
"124dp"
android:layout_height=
"58dp"
android:layout_marginStart=
"140dp"
android:layout_marginBottom=
"16dp"
android:backgroundTint=
"#262730"
android:onClick=
"btnRetrieveLocation"
android:text=
"FIND "
app:cornerRadius=
"60px"
android:textSize=
"60px"
...
...
@@ -94,4 +95,21 @@
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<AutoCompleteTextView
android:id=
"@+id/where_to"
android:layout_width=
"340dp"
android:layout_height=
"59dp"
android:layout_marginStart=
"32dp"
android:layout_marginBottom=
"156dp"
android:hint=
"Where to"
android:textAlignment=
"center"
android:completionThreshold=
"1"
android:completionHint=
"Select a city"
android:background=
"#FFFFFF"
app:layout_constraintBottom_toTopOf=
"@+id/button2"
app:layout_constraintStart_toStartOf=
"parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/activity_retrieve_bus_map.xml
0 → 100644
View file @
73d8fd25
<?xml version="1.0" encoding="utf-8"?>
<fragment
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:map=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/map"
android:name=
"com.google.android.gms.maps.SupportMapFragment"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
".RetrieveBusMap"
/>
\ No newline at end of file
app/src/main/res/layout/activity_welcome.xml
View file @
73d8fd25
...
...
@@ -79,7 +79,7 @@
android:text=
"Where to"
android:textAlignment=
"center"
android:completionThreshold=
"3"
android:popupTheme=
"#FFFFFF"
android:background=
"#FFFFFF"
app:layout_constraintBottom_toTopOf=
"@+id/button2"
...
...
app/src/main/res/values/strings.xml
View file @
73d8fd25
...
...
@@ -11,4 +11,5 @@
<string
name=
"hello_second_fragment"
>
Hello second fragment. Arg: %1$s
</string>
<string
name=
"title_activity_homemap"
>
homemap
</string>
<string
name=
"title_activity_home_map"
>
HomeMap
</string>
<string
name=
"title_activity_retrieve_bus_map"
>
RetrieveBusMap
</string>
</resources>
\ No newline at end of file
build.gradle
View file @
73d8fd25
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript
{
dependencies
{
classpath
'com.google.gms:google-services:4.3.10'
}
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins
{
id
'com.android.application'
version
'7.3.0'
apply
false
id
'com.android.library'
version
'7.3.0'
apply
false
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment