Skip to content

Wahaj branch #2

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions .idea/misc.xml

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

2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ dependencies {
implementation("com.google.firebase:firebase-analytics")
implementation ("com.google.firebase:firebase-firestore:24.11.1")
implementation("com.google.firebase:firebase-auth")

implementation ("com.google.android.material:material:1.4.0")
}
73 changes: 60 additions & 13 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,83 @@
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MyApplication"
tools:targetApi="31">
<activity
android:name=".Signup"
android:name=".AdminProfile"
android:exported="false" />
<activity
android:name=".SignUp"
android:name=".EditDoctorProfile"
android:exported="false" />
<activity
android:name=".Login"
android:exported="true">
android:name=".DoctorProfile"
android:exported="false" />
<activity
android:name=".CancelAppointmentsActivity"
android:exported="false" />
<activity
android:name=".AppointmentDetailActivity"
android:exported="false" />
<activity
android:name=".EditPatientProfile"
android:exported="false" />
<activity
android:name=".PatientProfile"
android:exported="false" />
<activity
android:name=".UpcomingAppointmentsActivity"
android:exported="false" />
<activity
android:name=".ApproveAppointmentActivity"
android:exported="false" />
<activity
android:name=".ScheduleAppointment"
android:exported="false" />
<activity
android:name=".SearchDoctor"
android:exported="false" />
<activity
android:name=".Login_Admin"
android:exported="false" />
<activity
android:name=".SignupDoctor"
android:exported="false" />
<activity
android:name=".Login_Doctor"
android:exported="true" />
<activity
android:name=".Login_Patient"
android:exported="true" /> <!-- Launchpage Activity as the main launcher activity -->
<activity
android:name=".Launchpage"
android:exported="true"> <!-- It must be exported to be accessible to the launcher -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</activity> <!-- Other activities without MAIN and LAUNCHER intent filters -->
<activity
android:name=".Feedback"
android:exported="true" /> <!-- Change to true if this activity is accessed from outside the app -->
<activity
android:name=".AddDoctor"
android:exported="true" /> <!-- Change to true if this activity is accessed from outside the app -->
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
android:exported="true" />
<activity
android:name=".SignupPatient"
android:exported="true" />
<activity
android:name=".GenerateInvoice"
android:exported="true" />
<activity
android:name=".GeneratePrescription"
android:exported="true" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
83 changes: 83 additions & 0 deletions app/src/main/java/com/example/myapplication/AddDoctor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package com.example.myapplication;

import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.firestore.FirebaseFirestore;

import java.util.Objects;

public class AddDoctor extends AppCompatActivity {
private EditText etDoctorName, etDoctorEmail, etDoctorPhone, etDoctorQualification,
etDoctorExperience, etDoctorCategory, etDoctorPassword, etDoctorConfirmPassword,doctorFeeEditText;
private FirebaseFirestore db;
private FirebaseAuth auth;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_doctor);

db = FirebaseFirestore.getInstance();
auth = FirebaseAuth.getInstance();

etDoctorName = findViewById(R.id.et_doctor_name);
etDoctorEmail = findViewById(R.id.et_doctor_email);
etDoctorPhone = findViewById(R.id.et_doctor_phone);
etDoctorQualification = findViewById(R.id.et_doctor_qualification);
etDoctorExperience = findViewById(R.id.et_doctor_experience);
etDoctorCategory = findViewById(R.id.et_doctor_category);
etDoctorPassword = findViewById(R.id.et_doctor_password);
etDoctorConfirmPassword = findViewById(R.id.et_doctor_confirm_password);
doctorFeeEditText = findViewById(R.id.doctorFeeEditText);

Button btnAddDoctor = findViewById(R.id.btn_add_doctor);

btnAddDoctor.setOnClickListener(v -> {
String Name = etDoctorName.getText().toString().trim();
String Email = etDoctorEmail.getText().toString().trim();
String Phone = etDoctorPhone.getText().toString().trim();
String Qualification = etDoctorQualification.getText().toString().trim();
String Experience = etDoctorExperience.getText().toString().trim();
String Category = etDoctorCategory.getText().toString().trim();
String Password = etDoctorPassword.getText().toString().trim();
String ConfirmPassword = etDoctorConfirmPassword.getText().toString().trim();
String fee = doctorFeeEditText.getText().toString().trim();
if (Name.isEmpty() || Email.isEmpty() || Phone.isEmpty() || Qualification.isEmpty() ||
Experience.isEmpty() || Category.isEmpty() || Password.isEmpty() || !Password.equals(ConfirmPassword) || Password.length() < 6) {
Toast.makeText(AddDoctor.this, "Please ensure all fields are filled correctly and passwords match.", Toast.LENGTH_SHORT).show();
return;
}

auth.createUserWithEmailAndPassword(Email, Password)
.addOnCompleteListener(task -> {
if (task.isSuccessful()) {
Doctor doctor = new Doctor(Name, Email, Phone, Qualification, Experience, Category,Password,ConfirmPassword,fee);
addDoctorToFirestore(doctor);
} else {
Toast.makeText(AddDoctor.this, "Authentication failed: " + Objects.requireNonNull(task.getException()).getMessage(), Toast.LENGTH_SHORT).show();
}
});
});
}

private void addDoctorToFirestore(Doctor doctor) {
db.collection("doctors").add(doctor)
.addOnSuccessListener(documentReference -> {
Toast.makeText(AddDoctor.this, "Doctor added successfully", Toast.LENGTH_SHORT).show();
finish(); // Optional: Close the activity on success
})
.addOnFailureListener(e -> {
Log.e("AddDoctor", "Error adding doctor to Firestore", e);
Toast.makeText(AddDoctor.this, "Error adding doctor to Firestore: " + e.getMessage(), Toast.LENGTH_SHORT).show();
});
}
}
60 changes: 60 additions & 0 deletions app/src/main/java/com/example/myapplication/AdminProfile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.example.myapplication;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;

import java.util.ResourceBundle;

public class AdminProfile extends AppCompatActivity {

private TextView txtAdminName;
private Button btnGenerateInvoice, btnViewReports, btnSettings;

private String adminEmail;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_admin_profile);

// Initialize views
txtAdminName = findViewById(R.id.txtAdminName);

btnGenerateInvoice = findViewById(R.id.btnGenerateInvoice);
btnViewReports = findViewById(R.id.btnViewReports);
btnSettings = findViewById(R.id.btnSettings);

// Get data from intent
Bundle extras = getIntent().getExtras();
if (extras != null) {
txtAdminName.setText("Name: " + extras.getString("name", "N/A"));
adminEmail = extras.getString("email");
}

// Set up button listeners
btnGenerateInvoice.setOnClickListener(v -> openGenerateInvoiceActivity());
btnViewReports.setOnClickListener(v -> openViewReportsActivity());
btnSettings.setOnClickListener(v -> openAddDoctor());
}

private void openGenerateInvoiceActivity() {
Intent intent = new Intent(AdminProfile.this, GenerateInvoice.class);
startActivity(intent);
finish();
}


private void openViewReportsActivity()
{

}

private void openAddDoctor() {
Intent intent = new Intent(AdminProfile.this, AddDoctor.class);
startActivity(intent);
finish();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.example.myapplication;

import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;

public class AppointmentDetailActivity extends AppCompatActivity {

private TextView txtDate, txtDoctor, txtDescription;
private EditText feedbackInput;
private Button btnSubmitFeedback;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_appointment_detail);

// Initialize views
txtDate = findViewById(R.id.txtDate);
txtDoctor = findViewById(R.id.txtDoctor);
txtDescription = findViewById(R.id.txtDescription);
feedbackInput = findViewById(R.id.feedbackInput);
btnSubmitFeedback = findViewById(R.id.btnSubmitFeedback);

// Get data from intent
Bundle extras = getIntent().getExtras();
if (extras != null) {
String date = extras.getString("date", "No date provided");
String doctor = extras.getString("doctor", "No doctor specified");
String description = extras.getString("description", "No description provided");

// Set data to views
txtDate.setText("Date: " + date);
txtDoctor.setText("Doctor: " + doctor);
txtDescription.setText("Description: " + description);
}

// Handle feedback submission
btnSubmitFeedback.setOnClickListener(v -> submitFeedback());
}

private void submitFeedback() {
String feedback = feedbackInput.getText().toString();
if (!feedback.isEmpty()) {
// Handle the feedback submission logic here
// For example, sending feedback to a server or database
Toast.makeText(this, "Feedback submitted. Thank you!", Toast.LENGTH_LONG).show();

// Clear the input field after submission
feedbackInput.setText("");
} else {
Toast.makeText(this, "Please enter some feedback before submitting.", Toast.LENGTH_LONG).show();
}
}
}
Loading