Commit 54d1d26c authored by O.V.B Sewmina's avatar O.V.B Sewmina

Merge branch 'IT19179568' into 'master'

It19179568

See merge request 2022-020/2022-020!22
parents ed91952e 689ae5f7
Travelle
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="MavenRepo" />
<option name="name" value="MavenRepo" />
<option name="url" value="https://repo.maven.apache.org/maven2/" />
</remote-repository>
<remote-repository>
<option name="id" value="Google" />
<option name="name" value="Google" />
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
</remote-repository>
</component>
</project>
\ No newline at end of file
<?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
plugins {
id 'com.android.application'
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
id 'com.google.gms.google-services'
}
android {
......@@ -42,7 +43,23 @@ 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.6'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
\ No newline at end of file
// Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:30.5.0')
// Add the dependency for the Realtime Database library
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-database'
// Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:30.5.0')
// Declare the dependencies for the desired Firebase products without specifying versions
// For example, declare the dependencies for Firebase Authentication and Cloud Firestore
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-firestore'
}
{
"project_info": {
"project_number": "764544025792",
"firebase_url": "https://gps-b123c-default-rtdb.firebaseio.com",
"project_id": "gps-b123c",
"storage_bucket": "gps-b123c.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:764544025792:android:af682706740c3b93dd1925",
"android_client_info": {
"package_name": "com.app.travelle"
}
},
"oauth_client": [
{
"client_id": "764544025792-4d40sjiq3sj6rdag8v3gdobdf1ee2kb7.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyAQdPBb4ktGFcpFqC9Fi1oDUiA0DaeIgaU"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "764544025792-4d40sjiq3sj6rdag8v3gdobdf1ee2kb7.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}
\ No newline at end of file
......@@ -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"
......
......@@ -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) {
......
package com.app.travelle;
import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentActivity;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;
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.MapStyleOptions;
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) {
System.out.println("Started");
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
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("/");
System.out.println("================================================") ;
System.out.println(databaseReference);
//Styling
try {
// Customise the styling of the base map using a JSON object defined
// in a raw resource file.
boolean success = googleMap.setMapStyle(
MapStyleOptions.loadRawResourceStyle(
this, R.raw.map_style));
if (!success) {
Log.e("HomeMap", "Style parsing failed.");
}
} catch (Resources.NotFoundException e) {
Log.e("HomeMap", "Can't find style. Error: ", e);
}
ValueEventListener listener = databaseReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
System.out.println("changing-----------------------------");
String latitude = dataSnapshot.child("latitude").getValue(String.class);
String longitude = dataSnapshot.child("longitude").getValue(String.class);
System.out.println(latitude+longitude);
LatLng location = new LatLng(Double.parseDouble(latitude),Double.parseDouble(longitude));
mMap.addMarker(new MarkerOptions().position(location).title("117"));
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(location,17));
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
}
\ No newline at end of file
......@@ -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/findbus"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?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
......@@ -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"
......
......@@ -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
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
// Make sure that you have the following two repositories
}
dependencies {
classpath 'com.google.gms:google-services:4.3.14'
}
}// 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
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' version '2.0.1' apply false
}
\ No newline at end of file
}
allprojects {
repositories {
// Make sure that you have the following two repositories
}}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment