Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
robinsrk committed Feb 22, 2023
1 parent a1c9780 commit 28af523
Show file tree
Hide file tree
Showing 27 changed files with 1,312 additions and 129 deletions.
30 changes: 24 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
id 'com.google.gms.google-services'
id 'kotlin-kapt'
id 'com.google.dagger.hilt.android' version '2.44.2' apply true
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
}

android {
Expand Down Expand Up @@ -41,6 +42,7 @@ android {
}
buildFeatures {
compose true
viewBinding true
}
composeOptions {
kotlinCompilerExtensionVersion '1.4.0-alpha02'
Expand All @@ -58,7 +60,7 @@ dependencies {
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
implementation 'androidx.activity:activity-compose:1.6.1'
implementation platform('androidx.compose:compose-bom:2022.12.00')
implementation platform('androidx.compose:compose-bom:2023.01.00')
implementation 'androidx.compose.ui:ui'
implementation 'androidx.compose.ui:ui-graphics'
implementation 'androidx.compose.ui:ui-tooling-preview'
Expand All @@ -71,22 +73,28 @@ dependencies {
implementation 'com.google.android.datatransport:transport-runtime:3.1.8'
implementation 'androidx.test:monitor:1.6.1'
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'com.google.android.gms:play-services-maps:18.1.0'
implementation 'androidx.compose.material:material:1.3.1'
// implementation 'com.google.android.libraries.maps:maps:3.1.0-beta'
// implementation 'com.android.volley:volley:1.2.1'
// implementation 'com.google.firebase:protolite-well-known-types:18.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation platform('androidx.compose:compose-bom:2022.12.00')
androidTestImplementation platform('androidx.compose:compose-bom:2023.01.00')
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
debugImplementation 'androidx.compose.ui:ui-tooling'
debugImplementation 'androidx.compose.ui:ui-test-manifest'
implementation("io.coil-kt:coil-compose:2.2.2")

// Firebase
implementation 'com.google.firebase:firebase-auth-ktx:21.1.0'
implementation 'com.google.firebase:firebase-firestore-ktx:24.4.3'
implementation 'com.google.firebase:firebase-bom:31.2.1'
// implementation 'com.google.firebase:firebase-firestore-ktx:24.4.3'
implementation 'com.google.firebase:firebase-bom:31.2.2'
implementation 'com.google.firebase:firebase-analytics-ktx:21.2.0'
implementation 'com.google.firebase:firebase-database-ktx:20.1.0'
implementation 'com.google.firebase:firebase-database:20.1.0'
// implementation 'com.google.firebase:protolite-well-known-types:18.0.0'

// Room
implementation 'androidx.room:room-ktx:2.5.0'
Expand All @@ -95,6 +103,7 @@ dependencies {

// Location
implementation 'com.google.android.gms:play-services-location:21.0.1'
implementation 'com.google.maps.android:android-maps-utils:3.4.0'

// CameraX for QR Code scanning
implementation "androidx.camera:camera-camera2:1.2.1"
Expand All @@ -111,9 +120,9 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'

// Hilt
implementation 'com.google.dagger:hilt-android:2.44.2'
implementation 'com.google.dagger:hilt-android:2.45'
implementation 'androidx.hilt:hilt-navigation-compose:1.0.0'
kapt 'com.google.dagger:hilt-compiler:2.44.2'
kapt 'com.google.dagger:hilt-compiler:2.45'
implementation 'androidx.hilt:hilt-navigation-fragment:1.0.0'

// Kotlin coroutines
Expand All @@ -127,4 +136,13 @@ dependencies {

// Navigation animation
implementation 'com.google.accompanist:accompanist-navigation-animation:0.29.1-alpha'

// Stripe payment gateway
implementation 'com.stripe:stripe-android:20.19.3'

// Api call
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'

implementation 'com.google.maps.android:maps-compose:2.11.0'
}
32 changes: 27 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<application
android:name="com.example.buspayment.BaseApplication"
android:name=".BaseApplication"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
Expand All @@ -22,10 +23,31 @@
android:supportsRtl="true"
android:theme="@style/Theme.BusPayment"
android:usesCleartextTraffic="true"
tools:remove="android:appComponentFactory"
tools:targetApi="31">
<!-- <activity-->
<!-- android:name=".LoginActivity"-->
<!-- android:exported="false" />-->

<!--
TODO: Before you run your application, you need a Google Maps API key.
To get one, follow the directions here:
https://developers.google.com/maps/documentation/android-sdk/get-api-key
Once you have your API key (it starts with "AIza"), define a new property in your
project's local.properties file (e.g. MAPS_API_KEY=Aiza...), and replace the
"YOUR_API_KEY" string in this file with "${MAPS_API_KEY}".
-->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="YOUR_API_KEY" />

<activity
android:name=".screens.admin.MapsActivity"
android:exported="false"
android:label="@string/title_activity_maps" />
<!-- <activity -->
<!-- android:name=".LoginActivity" -->
<!-- android:exported="false" /> -->
<activity
android:name=".MainActivity"
android:exported="true"
Expand Down
12 changes: 9 additions & 3 deletions app/src/main/java/com/example/buspayment/MainScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

package com.example.buspayment

import android.net.ConnectivityManager
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
Expand All @@ -10,9 +11,9 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.ui.Modifier
import com.example.buspayment.funtions.NotificationService
import com.example.buspayment.funtions.ToastService
import com.example.buspayment.navigations.SetupNavGraph
import com.example.buspayment.realtimeDB.repository.DBRepository
import com.example.buspayment.ui.theme.BusPaymentTheme
Expand All @@ -27,8 +28,9 @@ class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
DBRepository.setContext(this)
ToastService.setContext(this)
NotificationService(applicationContext).createNotificationChannel()
val connectivityManager = getSystemService(CONNECTIVITY_SERVICE) as ConnectivityManager
val activeNetworkInfo = connectivityManager.activeNetworkInfo
setContent {
BusPaymentTheme {
val navController = rememberAnimatedNavController()
Expand All @@ -39,7 +41,11 @@ class MainActivity : ComponentActivity() {
Column(
modifier = Modifier.fillMaxSize(),
) {
SetupNavGraph(navController)
if (activeNetworkInfo != null) {
SetupNavGraph(navController)
} else {
Text("Connection error")
}
}
}
}
Expand Down
19 changes: 0 additions & 19 deletions app/src/main/java/com/example/buspayment/funtions/ToastService.kt

This file was deleted.

30 changes: 27 additions & 3 deletions app/src/main/java/com/example/buspayment/navigations/NavGraph.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.runtime.Composable
import androidx.navigation.NavHostController
import com.example.buspayment.screens.admin.AddBusScreen
import com.example.buspayment.screens.admin.AddLocationByMap
import com.example.buspayment.screens.admin.AddLocationScreen
import com.example.buspayment.screens.admin.AdminHomeScreen
import com.example.buspayment.screens.admin.LocationsScreen
import com.example.buspayment.screens.admin.ManageAccountsScreen
import com.example.buspayment.screens.admin.ManageBusScreen
import com.example.buspayment.screens.common.LoginScreen
import com.example.buspayment.screens.common.RegisterScreen
import com.example.buspayment.screens.common.SplashScreen
import com.example.buspayment.screens.common.UserRegistrationScreen
import com.example.buspayment.screens.conductor.ConductorHomeScreen
import com.example.buspayment.screens.conductor.ConductorQRCode
import com.example.buspayment.screens.conductor.PaymentListScreen
import com.example.buspayment.screens.user.ProfileScreen
import com.example.buspayment.screens.user.RechargeScreen
Expand All @@ -34,9 +38,9 @@ fun SetupNavGraph(navController: NavHostController) {
LoginScreen(navController)
}
composable(
route = Screens.Register.route
route = Screens.regUser.route
) {
RegisterScreen(navController)
UserRegistrationScreen(navController)
}
composable(
route = Screens.UHome.route
Expand Down Expand Up @@ -99,5 +103,25 @@ fun SetupNavGraph(navController: NavHostController) {
) {
AddBusScreen(navController)
}
composable(
route = Screens.MQR.route
) {
ConductorQRCode(navController)
}
composable(
route = Screens.MDist.route
) {
LocationsScreen(navController)
}
composable(
route = Screens.ADist.route
) {
AddLocationScreen(navController)
}
composable(
route = Screens.map.route
) {
AddLocationByMap(navController)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ sealed class Screens(val route: String) {
object Recharge : Screens(route = "Recharge_screen")
object UHistory : Screens(route = "user_history_screen")
object Login : Screens(route = "login_screen")
object Register : Screens(route = "register_screen")
object regUser : Screens(route = "register_user_screen")
object regCon : Screens(route = "register_conductor_screen")
object map : Screens(route = "map_screen")
object AHome : Screens(route = "admin_home_screen")
object MBus : Screens(route = "mbus_screen")
object ABus : Screens(route = "abus_screen")

object ADist : Screens(route = "add_distance_screen")
object MDist : Screens(route = "manage_distance_screen")
object MQR : Screens(route = "qr_screen")
object MAccount : Screens(route = "admin_manage_account_screen")
object CHome : Screens(route = "conductor_home_screen")
object PList : Screens(route = "payment_list_screen")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,6 @@ class DBRepository @Inject constructor(
.addOnFailureListener {
trySend(ResultState.Failure(it))
}
db.child("conductorPaymentList").child(to).push().setValue(
payment
).addOnCompleteListener {
if (it.isSuccessful)
trySend(ResultState.Success("Payment successful"))
}
.addOnFailureListener {
trySend(ResultState.Failure(it))
}
awaitClose {
close()
}
Expand All @@ -281,6 +272,22 @@ class DBRepository @Inject constructor(
}
}

override fun addDistance(dist: RealtimeDistanceResponse.DistanceResponse): Flow<ResultState<String>> =
callbackFlow {
trySend(ResultState.Loading)
db.child("distance").push().setValue(
dist
).addOnCompleteListener {
if (it.isSuccessful)
trySend(ResultState.Success("Data inserted successfully"))
}.addOnFailureListener {
trySend(ResultState.Failure(it))
}
awaitClose {
close()
}
}

override fun getDistance(): Flow<ResultState<List<RealtimeDistanceResponse>>> = callbackFlow {
trySend(ResultState.Loading)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface Repository {
fun getUser(email: String = ""): Flow<ResultState<List<RealtimeUserResponse>>>
fun getBus(): Flow<ResultState<List<RealtimeBusResponse>>>
fun getDistance(): Flow<ResultState<List<RealtimeDistanceResponse>>>
fun addDistance(dist: RealtimeDistanceResponse.DistanceResponse): Flow<ResultState<String>>
fun updateBalance(pay: Double, from: String, to: String): Flow<ResultState<String>>
fun submitPayment(
payment: RealtimePaymentResponse.PaymentResponse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,13 @@ data class RealtimeDistanceResponse(
data class DistanceResponse(
val name: String = "",
val value: Double = 0.0,
val lat1: Double = 0.0,
val lng1: Double = 0.0,
val lat2: Double = 0.0,
val lng2: Double = 0.0,
val lat3: Double = 0.0,
val lng3: Double = 0.0,
val lat4: Double = 0.0,
val lng4: Double = 0.0,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class RealtimeViewModel @Inject constructor(
private val _userHisRes: MutableState<PaymentState> = mutableStateOf(PaymentState())
val userHisRes: State<PaymentState> = _userHisRes
fun addUser(users: RealtimeUserResponse.UserResponse) = repo.addUser(users)
fun addDistance(dist: RealtimeDistanceResponse.DistanceResponse) = repo.addDistance(dist)
fun submitPayment(
payment: RealtimePaymentResponse.PaymentResponse,
from: String,
Expand Down Expand Up @@ -98,13 +99,13 @@ class RealtimeViewModel @Inject constructor(
}

is ResultState.Failure -> {
_busRes.value = BusState(
_distRes.value = DistState(
error = it.msg.toString()
)
}

is ResultState.Loading -> {
_busRes.value = BusState(
_distRes.value = DistState(
isLoading = true
)
}
Expand Down
Loading

0 comments on commit 28af523

Please sign in to comment.