Skip to content
Open

a #57

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
769a9b3
Merge pull request #40 from Java-rice/main
Java-rice Feb 12, 2024
8e7491a
phone call
Java-rice Feb 12, 2024
04a0843
Merge pull request #42 from Java-rice/new_jm_branch
Java-rice Feb 12, 2024
31dd5d6
Merge pull request #43 from Java-rice/main
Java-rice Feb 12, 2024
5f370ce
final changes reports and emergency
Java-rice Feb 12, 2024
877ac06
Merge pull request #44 from Java-rice/new_jm_branch
Java-rice Feb 12, 2024
e2000d6
Merge pull request #45 from Java-rice/main
Java-rice Feb 12, 2024
87c469b
Merge pull request #46 from Java-rice/nichole
Java-rice Feb 12, 2024
1a36504
Merge pull request #47 from Java-rice/main
Java-rice Feb 12, 2024
1921944
report a crime date and time
Java-rice Feb 13, 2024
ebb20ec
Merge pull request #51 from Java-rice/new_jm_branch
Java-rice Feb 13, 2024
fc867d6
liked button
Java-rice Feb 13, 2024
3e5a729
Merge pull request #52 from Java-rice/new_jm_branch
Java-rice Feb 13, 2024
d8534ff
Merge pull request #53 from Java-rice/main
Java-rice Feb 13, 2024
a0ab53c
improved post template in item_crime_report.xml
jaypeepeep Feb 13, 2024
5fbf00b
added validation for type of crime and description in activity_create…
jaypeepeep Feb 13, 2024
053cd2f
Merge pull request #54 from Java-rice/jpp
Java-rice Feb 13, 2024
af5eea5
Merge pull request #55 from Java-rice/main
jaypeepeep Feb 13, 2024
2f38fed
Merge pull request #56 from Java-rice/new_jm_branch
Java-rice Feb 13, 2024
ac96ba7
added post feature for loadInYourAreaCrimeReports in HomeFragment.kt
jaypeepeep Feb 13, 2024
3d3b8dd
Merge pull request #58 from Java-rice/jpp
Java-rice Feb 13, 2024
887aabf
added post feature for loadMostRecentCrimeReport in HomeFragment.kt
jaypeepeep Feb 13, 2024
98c6c10
Merge pull request #60 from Java-rice/jpp
Java-rice Feb 13, 2024
bf16f05
added profile picture and username for loadInYourAreaCrimeReport in H…
jaypeepeep Feb 13, 2024
f18bba5
Merge pull request #62 from Java-rice/jpp
Java-rice Feb 13, 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
2 changes: 1 addition & 1 deletion .idea/deploymentTargetDropDown.xml

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

81 changes: 80 additions & 1 deletion app/src/main/java/com/mobile/komyusagip/CreatePost.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.mobile.komyusagip

import android.app.DatePickerDialog
import android.app.TimePickerDialog
import android.content.Intent
import android.os.Bundle
import android.view.View
Expand All @@ -8,6 +10,8 @@ import androidx.appcompat.app.AppCompatActivity
import com.google.android.material.textfield.TextInputEditText
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.firestore.FirebaseFirestore
import java.util.Calendar
import java.util.Locale

class CreatePost : AppCompatActivity() {
private val auth = FirebaseAuth.getInstance()
Expand All @@ -22,6 +26,48 @@ class CreatePost : AppCompatActivity() {
val intent = Intent(this, Home::class.java)
startActivity(intent)
}
val timeTextField = findViewById<EditText>(R.id.timeTextField)
val timePickerButton = findViewById<Button>(R.id.timePickerButton)

val timePickerDialog = TimePickerDialog(
this,
{ _, hourOfDay, minute ->
val selectedTime = formatTime(hourOfDay, minute)
timeTextField.setText(selectedTime)
},
12, // Initial hour (you can set your own default)
0, // Initial minute (you can set your own default)
false // Set to false for 12-hour format
)

timePickerButton.setOnClickListener {
timePickerDialog.show()
}

timePickerButton.setOnClickListener {
timePickerDialog.show()
}
val dateTextField = findViewById<EditText>(R.id.dateTextField)
val datePickerButton = findViewById<Button>(R.id.datePickerButton)
val calendar = Calendar.getInstance()
val initialYear = calendar.get(Calendar.YEAR)
val initialMonth = calendar.get(Calendar.MONTH)
val initialDay = calendar.get(Calendar.DAY_OF_MONTH)

val datePickerDialog = DatePickerDialog(
this,
{ _, year, month, day ->
val selectedDate = formatDate(year, month + 1, day)
dateTextField.setText(selectedDate)
},
initialYear,
initialMonth,
initialDay
)

datePickerButton.setOnClickListener {
datePickerDialog.show()
}

val dropdownTypeOfCrime = findViewById<Spinner>(R.id.spinnerTypeOfCrime)
val spinnerSelectedValueTextView = findViewById<TextView>(R.id.selectedSpinnerTypeOfCrime)
Expand Down Expand Up @@ -52,19 +98,52 @@ class CreatePost : AppCompatActivity() {
validateAndSubmit()
}
}
private fun formatTime(hour: Int, minute: Int): String {
val isAM = hour < 12
val amPm = if (isAM) "AM" else "PM"
val hourFormatted = if (hour % 12 == 0) 12 else hour % 12
return String.format(Locale.getDefault(), "%02d:%02d %s", hourFormatted, minute, amPm)
}

private fun formatDate(year: Int, month: Int, day: Int): String {
return String.format(Locale.getDefault(), "%02d-%02d-%04d", month, day, year)
}
private fun showTimePickerDialog(initialHour: Int, initialMinute: Int) {
val timePicker = TimePickerDialog(
this,
TimePickerDialog.OnTimeSetListener { view: TimePicker?, hourOfDay: Int, minute: Int ->
// Do something with the selected time
val selectedTime = "$hourOfDay:$minute"
// You can update the UI or perform any actions with the selected time
},
initialHour,
initialMinute,
false // Set to true if you want 24-hour format
)

timePicker.show()
}
private fun validateAndSubmit() {
val addDescription = findViewById<TextInputEditText>(R.id.addDesciption)
val spinnerSelectedValueTextView = findViewById<TextView>(R.id.selectedSpinnerTypeOfCrime)

val description = addDescription.text?.toString()?.trim()
val typeOfCrime = spinnerSelectedValueTextView.text.toString()

if (description.isNullOrEmpty()) {
if (typeOfCrime.isNullOrEmpty() && description.isNullOrEmpty()) {
spinnerSelectedValueTextView.error = "Please select the type of crime"
addDescription.error = "Add description"
return
} else if (typeOfCrime.isNullOrEmpty()) {
spinnerSelectedValueTextView.error = "Please select the type of crime"
return
} else if (description.isNullOrEmpty()) {
addDescription.error = "Add description"
return
}



// Get current user ID
val userId = auth.currentUser?.uid
userId?.let { uid ->
Expand Down
50 changes: 41 additions & 9 deletions app/src/main/java/com/mobile/komyusagip/EmergencyContacts.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.mobile.komyusagip
import android.content.Intent

import android.os.Bundle
import android.widget.Button
import android.widget.ImageButton
import android.widget.LinearLayout
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity

class EmergencyContacts : AppCompatActivity() {
class EmergencyContacts : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.page_emergency_contacts)
Expand All @@ -16,7 +16,6 @@ class EmergencyContacts : AppCompatActivity() {
finish()
}


// Reference the LinearLayout where you want to add the contact containers
val contactContainerLayout = findViewById<LinearLayout>(R.id.contactCont)

Expand All @@ -31,18 +30,51 @@ class EmergencyContacts : AppCompatActivity() {
R.layout.contact_components,
R.layout.contact_components,
R.layout.contact_components,
R.layout.contact_components,
R.layout.contact_components,
R.layout.contact_components,
R.layout.contact_components
// Add more layout IDs as needed
)

for (contactContainerId in contactContainerIds) {
val contactNames = arrayOf(
"John Doe",
"Jane Doe",
"Bob Smith",
"Alice Johnson",
"David Lee",
"Ella Martinez",
"Michael Cruz",
"Sophia Reyes",
"William Garcia",
"Olivia Rodriguez"
// Add more contact names as needed
)

val contactNumbers = arrayOf(
"+639123456789",
"+639987654321",
"+639555123456",
"+639876543210",
"+639111223344",
"+639876543210",
"+639222334455",
"+639333445566",
"+639444556677",
"+639555667788"
// Add more valid Philippine phone numbers as needed
)

for (i in contactContainerIds.indices) {
val inflater = layoutInflater
val contactContainer = inflater.inflate(contactContainerId, null)
val contactContainer = inflater.inflate(contactContainerIds[i], null)

// You can customize the contact container programmatically if needed

// Set contact details
val contactName = contactContainer.findViewById<TextView>(R.id.contactName)
contactName.text = contactNames[i]

val contactNumber = contactContainer.findViewById<TextView>(R.id.contactNumber)
contactNumber.text = contactNumbers[i]

// Add the contact container to the LinearLayout
contactContainerLayout.addView(contactContainer)
}
Expand Down
74 changes: 62 additions & 12 deletions app/src/main/java/com/mobile/komyusagip/EmergencyHotline.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.mobile.komyusagip

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.widget.Button
import android.view.View
import android.widget.ImageButton
import android.widget.LinearLayout
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity

class EmergencyHotline : AppCompatActivity() {
class EmergencyHotline : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.page_emergency_hotlines)
Expand All @@ -15,10 +18,11 @@ class EmergencyHotline : AppCompatActivity() {
backToHome.setOnClickListener {
finish()
}
// Reference the LinearLayout where you want to add the contact containers

// Reference the LinearLayout where you want to add the hotline containers
val hotlineContainerLayout = findViewById<LinearLayout>(R.id.hotlineCont)

// Assuming 'contact_container.xml' is the layout file for your contact container
// Assuming 'hotline_components.xml' is the layout file for your hotline container
val hotlineContainerIds = arrayOf(
R.layout.hotline_components,
R.layout.hotline_components,
Expand All @@ -29,20 +33,66 @@ class EmergencyHotline : AppCompatActivity() {
R.layout.hotline_components,
R.layout.hotline_components,
R.layout.hotline_components,
R.layout.hotline_components,
R.layout.hotline_components,
R.layout.hotline_components,
R.layout.hotline_components
// Add more layout IDs as needed
)

val hotlineNames = arrayOf(
"Philippine Coast Guard",
"Philippine National Police",
"Bureau of Fire Protection",
"National Disaster Risk Reduction and Management Council",
"Red Cross Philippines",
"Philippine General Hospital",
"National Poison Management and Control Center",
"National Center for Mental Health",
"Department of Health Hotline",
"Emergency Medical Services"
// Add more hotline names as needed
)

for (contactContainerId in hotlineContainerIds) {
val hotlineNumbers = arrayOf(
"(02) 527-8481",
"117",
"(02) 729-5166",
"(02) 8911-1406",
"(02) 790-2383",
"(02) 554-8400",
"(02) 8403-5673",
"(02) 7989-8727",
"(02) 894-COVID",
"0917-899-8956"
// Add more valid Philippine phone numbers as needed
)

for (i in hotlineContainerIds.indices) {
val inflater = layoutInflater
val contactContainer = inflater.inflate(contactContainerId, null)
val hotlineContainer = inflater.inflate(hotlineContainerIds[i], null)

// You can customize the hotline container programmatically if needed

// Set hotline details
val hotlineName = hotlineContainer.findViewById<TextView>(R.id.contactName)
hotlineName.text = hotlineNames[i]

val hotlineNumber = hotlineContainer.findViewById<TextView>(R.id.contactNumber)
hotlineNumber.text = hotlineNumbers[i]

// You can customize the contact container programmatically if needed
val callButton = hotlineContainer.findViewById<View>(R.id.loginAuth)
callButton.setOnClickListener {
dialPhoneNumber(hotlineNumbers[i])
}

// Add the contact container to the LinearLayout
hotlineContainerLayout.addView(contactContainer)
// Add the hotline container to the LinearLayout
hotlineContainerLayout.addView(hotlineContainer)
}

}
private fun dialPhoneNumber(phoneNumber: String) {
val dialIntent = Intent(Intent.ACTION_DIAL)
dialIntent.data = Uri.parse("tel:$phoneNumber")
if (dialIntent.resolveActivity(packageManager) != null) {
startActivity(dialIntent)
}
}
}
Loading