Skip to content

Commit

Permalink
Merge pull request #13 from gdsc-nits-org/dev
Browse files Browse the repository at this point in the history
Navigation and Profile Page Integrated
  • Loading branch information
navneet-raj-karn authored Jun 13, 2024
2 parents e310296 + 0731e9d commit 28ee85a
Show file tree
Hide file tree
Showing 62 changed files with 1,959 additions and 107 deletions.
3 changes: 3 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 12 additions & 6 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ android {
}

// View Binding
buildFeatures {
viewBinding = true
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -51,8 +48,10 @@ dependencies {
implementation("com.google.android.material:material:1.11.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("com.google.firebase:firebase-auth:22.3.1")
implementation("com.google.firebase:firebase-database:20.3.0")
implementation("com.google.firebase:firebase-database:20.3.1")
implementation("com.google.firebase:firebase-auth-ktx:22.3.1")
implementation("com.google.firebase:firebase-messaging:24.0.0")
implementation("com.google.firebase:firebase-messaging-ktx:24.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")
Expand All @@ -61,13 +60,20 @@ dependencies {

// Card View
implementation("androidx.cardview:cardview:1.0.0")

// Glide
implementation ("com.github.bumptech.glide:glide:4.16.0")
implementation("com.github.bumptech.glide:glide:4.16.0")
annotationProcessor("com.github.bumptech.glide:compiler:4.11.0")

// Coil
implementation("io.coil-kt:coil:2.5.0")
implementation("com.airbnb.android:lottie:6.0.0")


//Navigation dependency
val nav_version = "2.7.6"
//noinspection GradleDependency
implementation("androidx.navigation:navigation-fragment-ktx:$nav_version")
//noinspection GradleDependency
implementation("androidx.navigation:navigation-ui-ktx:$nav_version")

}
20 changes: 19 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>

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

<application
android:allowBackup="true"
Expand All @@ -22,6 +22,15 @@
android:supportsRtl="true"
android:theme="@style/Theme.DeliveryApp"
tools:targetApi="31">

<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/logo__1_" />
<!-- Set color used with incoming notification messages. This is used when no color is set for the incoming
notification message. See README(https://goo.gl/6BKBk7) for more. -->
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/ButtonColour" />
<activity
android:name=".EmptyActivity"
android:exported="false" />
Expand All @@ -37,6 +46,15 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<service
android:name=".MyFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,50 +1,105 @@
package com.example.deliveryapp.Fragments

import android.Manifest
import android.app.AlertDialog
import android.content.pm.PackageManager
import android.os.Build
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.activity.OnBackPressedCallback
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.navigation.NavController
import androidx.navigation.Navigation
import com.example.deliveryapp.R
import com.example.deliveryapp.databinding.FragmentAccessLocationBinding


class AccessLocation : Fragment() {


private lateinit var binding: FragmentAccessLocationBinding
private lateinit var navController: NavController

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
): View {
binding = FragmentAccessLocationBinding.inflate(inflater, container, false)
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

navController= Navigation.findNavController(view)

navController = Navigation.findNavController(view)
binding.btnAccessLocation.setOnClickListener {
navController.navigate(R.id.action_accessLocation_to_animatedScreen)

if (checkLocationPermission()) {
// Permission granted, navigate to the next screen
navController.navigate(R.id.animatedScreen)
}
}

val callback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
// Log.d("TAG", "Pressed...")
// Do nothing or handle as needed
}
}

requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback)

// Check for permission on fragment start
}

private fun checkLocationPermission(): Boolean {
val context = requireContext()
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
// Runtime permissions not required below Android M
return true
}
if (ContextCompat.checkSelfPermission(
context,
Manifest.permission.ACCESS_FINE_LOCATION
) != PackageManager.PERMISSION_GRANTED
) {
// Permission not granted, request it
if (ActivityCompat.shouldShowRequestPermissionRationale(
requireActivity(),
Manifest.permission.ACCESS_FINE_LOCATION
)
) {
// Show an explanation to the user if they have denied permission previously
AlertDialog.Builder(context)
.setTitle("Location Permission Needed")
.setMessage("This app needs the Location permission to function properly. Please allow.")
.setPositiveButton("OK") { _, _ ->
requestLocationPermission()
}
.setNegativeButton("Cancel") { dialog, _ ->
dialog.dismiss()
}
.create()
.show()
} else {
// No explanation needed, request the permission
requestLocationPermission()
}
return false
}
// Permission already granted
return true
}

private fun requestLocationPermission() {
ActivityCompat.requestPermissions(
requireActivity(),
arrayOf(Manifest.permission.ACCESS_FINE_LOCATION),
LOCATION_PERMISSION_REQUEST_CODE
)
}

}
companion object {
private const val LOCATION_PERMISSION_REQUEST_CODE = 1001
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.example.deliveryapp.Fragments

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.activity.OnBackPressedCallback
import androidx.navigation.NavController
import androidx.navigation.Navigation
import com.example.deliveryapp.R
import com.example.deliveryapp.databinding.FragmentLocationBinding

class LocationFragment : Fragment() {

private lateinit var navController: NavController
private lateinit var binding:FragmentLocationBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
binding=FragmentLocationBinding.inflate(inflater,container,false)
return binding.root

}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
navController=Navigation.findNavController(view)



binding.btnAddLocation.setOnClickListener {
navController.navigate(R.id.action_locationFragment_to_addressFragment)
}

val callback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
// Log.d("TAG", "Pressed...")
}
}

requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback)

}
}
22 changes: 18 additions & 4 deletions app/src/main/java/com/example/deliveryapp/Fragments/LoginPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ import com.example.deliveryapp.R
import com.example.deliveryapp.databinding.FragmentLoginPageBinding
import com.google.android.gms.tasks.OnCompleteListener
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.database.DatabaseReference
import com.google.firebase.database.FirebaseDatabase


class LoginPage : Fragment() {

private lateinit var auth: FirebaseAuth
private lateinit var binding: FragmentLoginPageBinding
private lateinit var navController: NavController
private lateinit var databaseRef: DatabaseReference

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
Expand Down Expand Up @@ -51,6 +54,10 @@ class LoginPage : Fragment() {

navController=Navigation.findNavController(view)
auth=FirebaseAuth.getInstance()
databaseRef=FirebaseDatabase.getInstance()
.reference.child("Users")
.child(auth.currentUser?.uid.toString())

}

private fun registerEvents() {
Expand All @@ -68,20 +75,27 @@ class LoginPage : Fragment() {
val pattern=Regex("nits.ac.in")
val check=pattern.containsMatchIn(email)

if ( email.isNotEmpty() && pass.isNotEmpty() && check==true){
if (email.isNotEmpty() && pass.isNotEmpty() && check){

auth.signInWithEmailAndPassword(email,pass)
.addOnCompleteListener(

auth.signInWithEmailAndPassword(email,pass).addOnCompleteListener(
OnCompleteListener {
if (it.isSuccessful){
Toast.makeText(context,"Login Successfully", Toast.LENGTH_SHORT).show()
navController.navigate(R.id.action_loginPage_to_emptyActivity)
navController.navigate(R.id.action_loginPage_to_locationFragment)

}else{
Toast.makeText(context,it.exception?.message, Toast.LENGTH_SHORT).show()
Toast.makeText(context,"Kindly Sign Up By Clicking SignUp button", Toast.LENGTH_SHORT).show()
}
}

)

}else{

Toast.makeText(context,"Please fill up all the necessary details",Toast.LENGTH_SHORT).show()

}

}
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/example/deliveryapp/Fragments/SignIn.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.example.deliveryapp.Fragments

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand Down Expand Up @@ -34,15 +34,15 @@ class SignIn : Fragment() {
binding.btnSignUp.setOnClickListener {
navController.navigate(R.id.action_signIn_to_signUpPage)
}


val callback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
// Log.d("TAG", "Pressed...")
}
}

requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback)


}


Expand Down
Loading

0 comments on commit 28ee85a

Please sign in to comment.