Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation and Profile Page Integrated #13

Merged
merged 34 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
60f537d
Branch Push
AnKiTk203 Jan 11, 2024
46773f7
Branch Push
AnKiTk203 Jan 11, 2024
361530f
Hello
AnKiTk203 Jan 11, 2024
bb1c615
Branch Push
AnKiTk203 Jan 15, 2024
cad3d9e
Branch Push
AnKiTk203 Jan 15, 2024
9658f5d
Updating
AnKiTk203 Jan 23, 2024
f8b14dd
Updating
AnKiTk203 Jan 23, 2024
436d58f
Updating
AnKiTk203 Jan 31, 2024
dc956af
Updating
AnKiTk203 Jan 31, 2024
eedc905
Updating
AnKiTk203 Jan 31, 2024
b33901d
Updating
AnKiTk203 Feb 15, 2024
8be69fb
Updating
AnKiTk203 Feb 15, 2024
f9664c1
access location button is enabled anduser address fragment is done be…
bishalpb2004 Feb 17, 2024
061e242
setting up
Gaurav-822 Mar 3, 2024
ef2ba92
Dev Branch Push
AnKiTk203 Mar 28, 2024
0d07e36
updating dev with main to integrate further pages
Gaurav-822 Mar 29, 2024
f89905b
updating dev with main to integrate further pages
Gaurav-822 Mar 29, 2024
f513cbe
updating dev with main to integrate further pages
Gaurav-822 Mar 29, 2024
f229544
updating dev with main to integrate further pages
Gaurav-822 Mar 29, 2024
3d83663
Unique Auth ID is successfully generated along with signup of the user
bishalpb2004 Mar 29, 2024
9ff8965
merge conflict resolved
bishalpb2004 Mar 29, 2024
947d942
merge conflict fixed
bishalpb2004 Mar 29, 2024
2cf5779
fixing merge conflicts
bishalpb2004 Mar 29, 2024
68f6d22
Merged authentication and resolved merge conflicts
bishalpb2004 Mar 29, 2024
b012208
navigation inculcated
Gaurav-822 Mar 30, 2024
f0f1262
minor ui fix
Gaurav-822 Mar 30, 2024
2a30371
LogOut Added
AnKiTk203 Jun 5, 2024
3381a34
LogOut Added
AnKiTk203 Jun 5, 2024
56d6a72
LogOut Added
AnKiTk203 Jun 5, 2024
ebdac71
LogOut Added
AnKiTk203 Jun 5, 2024
0bd54f9
push notification in delivery app
jahanavi08 Jun 11, 2024
d9c029c
push notification in delivery app
jahanavi08 Jun 11, 2024
2bed6f7
fixed notifications
bishalpb2004 Jun 11, 2024
0731e9d
dialog box added for asking notifications permissions
bishalpb2004 Jun 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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