Skip to content

Commit b9322a6

Browse files
committed
Add Firebase configuration, SharedViewModel, and various UI enhancements
- Include google-services.json for Firebase setup. - Introduce SharedViewModel to manage data and state across the app. - Add new vector drawables for enhanced UI elements. - Configure data binding and view binding. - Add dependencies for Retrofit2, OkHttp3, and intuitive SDP/SSP dimensions. - Update MainActivity to integrate with the new SharedViewModel. - Adjust layout files to use new dimension resources. - Tweak theme and colors for better night mode compatibility.
1 parent 463b38b commit b9322a6

26 files changed

+1256
-264
lines changed

app/build.gradle

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ android {
3333
kotlinOptions {
3434
jvmTarget = '1.8'
3535
}
36-
buildFeatures {
37-
viewBinding true
36+
37+
dataBinding {
38+
enable = true
39+
}
40+
viewBinding {
41+
enabled = true
3842
}
3943
}
4044

@@ -52,6 +56,7 @@ dependencies {
5256
implementation libs.androidx.lifecycle.livedata.ktx
5357
implementation libs.androidx.lifecycle.viewmodel.ktx
5458
implementation libs.androidx.fragment.ktx
59+
implementation libs.androidx.databinding.runtime
5560
testImplementation libs.junit
5661
androidTestImplementation libs.androidx.junit
5762
androidTestImplementation libs.androidx.espresso.core
@@ -60,4 +65,14 @@ dependencies {
6065
implementation libs.kotlinx.coroutines.play.services
6166
implementation libs.kotlinx.coroutines.core
6267
implementation libs.kotlinx.coroutines.android
63-
}
68+
implementation libs.sdp.android
69+
implementation libs.ssp.android
70+
71+
// Retrofit2 and OkHttp3
72+
implementation libs.retrofit
73+
implementation libs.converter.gson
74+
implementation libs.okhttp
75+
implementation libs.logging.interceptor
76+
77+
78+
}

app/google-services.json

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{
2+
"project_info": {
3+
"project_number": "371993303456",
4+
"firebase_url": "https://test-firenase.firebaseio.com",
5+
"project_id": "test-firenase",
6+
"storage_bucket": "test-firenase.appspot.com"
7+
},
8+
"client": [
9+
{
10+
"client_info": {
11+
"mobilesdk_app_id": "1:371993303456:android:3d0e404f9f84fa9e612cc5",
12+
"android_client_info": {
13+
"package_name": "com.pigo.areo"
14+
}
15+
},
16+
"oauth_client": [
17+
{
18+
"client_id": "371993303456-oia9vv1nqpq0n2ef4q7kh476u8qh1l04.apps.googleusercontent.com",
19+
"client_type": 3
20+
}
21+
],
22+
"api_key": [
23+
{
24+
"current_key": "AIzaSyD0W5L0eDFjR3uP4LT-GpSL4fjKqc4OXVE"
25+
}
26+
],
27+
"services": {
28+
"appinvite_service": {
29+
"other_platform_oauth_client": [
30+
{
31+
"client_id": "371993303456-oia9vv1nqpq0n2ef4q7kh476u8qh1l04.apps.googleusercontent.com",
32+
"client_type": 3
33+
}
34+
]
35+
}
36+
}
37+
},
38+
{
39+
"client_info": {
40+
"mobilesdk_app_id": "1:371993303456:android:f969232f6d391b3a612cc5",
41+
"android_client_info": {
42+
"package_name": "com.roommate.firebasestore"
43+
}
44+
},
45+
"oauth_client": [
46+
{
47+
"client_id": "371993303456-4ubima8d27p3t366l4stmcsp0bf2hc41.apps.googleusercontent.com",
48+
"client_type": 1,
49+
"android_info": {
50+
"package_name": "com.roommate.firebasestore",
51+
"certificate_hash": "4b247fff97d4e078d4160852c256b98f793824f1"
52+
}
53+
},
54+
{
55+
"client_id": "371993303456-oia9vv1nqpq0n2ef4q7kh476u8qh1l04.apps.googleusercontent.com",
56+
"client_type": 3
57+
}
58+
],
59+
"api_key": [
60+
{
61+
"current_key": "AIzaSyD0W5L0eDFjR3uP4LT-GpSL4fjKqc4OXVE"
62+
}
63+
],
64+
"services": {
65+
"appinvite_service": {
66+
"other_platform_oauth_client": [
67+
{
68+
"client_id": "371993303456-oia9vv1nqpq0n2ef4q7kh476u8qh1l04.apps.googleusercontent.com",
69+
"client_type": 3
70+
}
71+
]
72+
}
73+
}
74+
},
75+
{
76+
"client_info": {
77+
"mobilesdk_app_id": "1:371993303456:android:70d3bc7e4540b9e7612cc5",
78+
"android_client_info": {
79+
"package_name": "com.segx01.demo"
80+
}
81+
},
82+
"oauth_client": [
83+
{
84+
"client_id": "371993303456-oia9vv1nqpq0n2ef4q7kh476u8qh1l04.apps.googleusercontent.com",
85+
"client_type": 3
86+
}
87+
],
88+
"api_key": [
89+
{
90+
"current_key": "AIzaSyD0W5L0eDFjR3uP4LT-GpSL4fjKqc4OXVE"
91+
}
92+
],
93+
"services": {
94+
"appinvite_service": {
95+
"other_platform_oauth_client": [
96+
{
97+
"client_id": "371993303456-oia9vv1nqpq0n2ef4q7kh476u8qh1l04.apps.googleusercontent.com",
98+
"client_type": 3
99+
}
100+
]
101+
}
102+
}
103+
}
104+
],
105+
"configuration_version": "1"
106+
}

app/src/main/java/com/pigo/areo/MainActivity.kt

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.Manifest
44
import android.content.pm.PackageManager
55
import android.location.Location
66
import android.os.Bundle
7+
import android.util.Log
78
import androidx.activity.result.contract.ActivityResultContracts
89
import androidx.activity.viewModels
910
import androidx.appcompat.app.AppCompatActivity
@@ -24,7 +25,10 @@ import com.google.android.gms.maps.SupportMapFragment
2425
import com.google.android.gms.maps.model.LatLng
2526
import com.google.android.gms.maps.model.MapStyleOptions
2627
import com.pigo.areo.databinding.ActivityMainBinding
27-
import com.pigo.areo.ui.current_trip.CurrentTripViewModel
28+
import com.pigo.areo.shared.SharedViewModel
29+
import com.pigo.areo.shared.SharedViewModelFactory
30+
import kotlinx.coroutines.CoroutineScope
31+
import kotlinx.coroutines.Dispatchers
2832
import kotlinx.coroutines.Job
2933
import kotlinx.coroutines.delay
3034
import kotlinx.coroutines.isActive
@@ -37,7 +41,9 @@ class MainActivity : AppCompatActivity(), OnMapReadyCallback {
3741
private lateinit var fusedLocationClient: FusedLocationProviderClient
3842
private lateinit var locationCallback: LocationCallback
3943
private lateinit var appBarConfiguration: AppBarConfiguration
40-
private lateinit var currentTripViewModel: CurrentTripViewModel
44+
private val sharedViewModel: SharedViewModel by viewModels {
45+
SharedViewModelFactory(this.applicationContext)
46+
}
4147

4248
private val requestPermissionLauncher = registerForActivityResult(
4349
ActivityResultContracts.RequestMultiplePermissions()
@@ -59,7 +65,6 @@ class MainActivity : AppCompatActivity(), OnMapReadyCallback {
5965

6066
setupNavigation()
6167

62-
currentTripViewModel = viewModels<CurrentTripViewModel>().value
6368

6469
val mapFragment =
6570
supportFragmentManager.findFragmentById(R.id.map_fragment_container) as SupportMapFragment
@@ -113,8 +118,8 @@ class MainActivity : AppCompatActivity(), OnMapReadyCallback {
113118

114119
// Permissions granted, proceed to request location updates
115120
val locationRequest = LocationRequest.create().apply {
116-
interval = 10000
117-
fastestInterval = 5000
121+
interval = 4000
122+
fastestInterval = 3000
118123
priority = LocationRequest.PRIORITY_HIGH_ACCURACY
119124
}
120125

@@ -123,17 +128,30 @@ class MainActivity : AppCompatActivity(), OnMapReadyCallback {
123128

124129
private var isFirstUpdate = true
125130

131+
126132
private fun updateLocationOnMap(location: Location) {
127133
val currentLatLng = LatLng(location.latitude, location.longitude)
128-
currentTripViewModel.updateCurrentLatLng(currentLatLng)
134+
sharedViewModel.updateCurrentLatLng(currentLatLng)
135+
Log.d("LocationUpdate", "Updated current LatLng: $currentLatLng")
136+
137+
if (::gMap.isInitialized) {
138+
sharedViewModel.updateCurrentMarkerAndAddMarkers(gMap, this.applicationContext)
139+
Log.d("LocationUpdate", "Updated current marker and added markers")
140+
}
129141

130142
if (::gMap.isInitialized && isFirstUpdate) {
131-
val cameraUpdate = CameraUpdateFactory.newLatLngZoom(currentLatLng, 15f)
132-
gMap.animateCamera(cameraUpdate)
143+
animateCameraToLocation(currentLatLng)
133144
isFirstUpdate = false
134145
}
146+
147+
135148
}
136149

150+
private fun animateCameraToLocation(latLng: LatLng) {
151+
val cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, 16f)
152+
gMap.animateCamera(cameraUpdate)
153+
Log.d("LocationUpdate", "Animated camera to new location: $latLng")
154+
}
137155

138156
private fun setupNavigation() {
139157
val navHostFragment =
@@ -184,9 +202,10 @@ class MainActivity : AppCompatActivity(), OnMapReadyCallback {
184202
}
185203

186204
override fun onMapReady(googleMap: GoogleMap) {
205+
sharedViewModel.setGoogleMap(googleMap)
187206
gMap = googleMap
188-
currentTripViewModel.setGoogleMap(googleMap)
189207
changeMapStyle()
208+
Log.e("TestGamp", "onMapReady ${gMap == googleMap}")
190209
// Setup map here (e.g., set markers, move camera)
191210
}
192211

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.pigo.areo.geolink.models
2+
3+
import com.google.gson.annotations.SerializedName
4+
5+
data class TextSearchResponse(
6+
@SerializedName("data") val data: List<SearchResult>,
7+
@SerializedName("success") val success: Boolean
8+
)
9+
10+
data class SearchResult(
11+
@SerializedName("latitude") val latitude: Double,
12+
@SerializedName("longitude") val longitude: Double,
13+
@SerializedName("long_address") val longAddress: String?,
14+
@SerializedName("short_address") val shortAddress: String?
15+
)

0 commit comments

Comments
 (0)