Skip to content

Commit

Permalink
New
Browse files Browse the repository at this point in the history
  • Loading branch information
W4W1R3 committed Nov 20, 2023
1 parent d74d5e3 commit b702776
Show file tree
Hide file tree
Showing 53 changed files with 792 additions and 430 deletions.
5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml
100755 → 100644

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

22 changes: 14 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ plugins {
}

android {
compileSdkVersion 33
compileSdkVersion 34

defaultConfig {
applicationId "com.example.intellimills"
minSdkVersion 19
targetSdkVersion 33
targetSdkVersion 34
versionCode 1
versionName "1.0"

Expand All @@ -32,15 +32,19 @@ android {
}

dependencies {

implementation 'com.google.firebase:firebase-core:21.1.1'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'com.google.firebase:firebase-database:20.2.2' // Replace with the latest version
implementation 'com.google.firebase:firebase-auth:22.3.0' // Include if you're using Firebase Authentication
implementation 'com.firebaseui:firebase-ui-database:8.0.0'
implementation 'com.google.android.material:material:1.10.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.firebase:firebase-auth:22.1.1'
implementation 'com.google.firebase:firebase-database:20.2.2'
testImplementation 'junit:junit:4.13.2'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'

// Add the Firebase SDK dependencies
// Import the Firebase BoM
Expand All @@ -51,10 +55,12 @@ dependencies {
// When using the BoM, don't specify versions in Firebase dependencies
// https://firebase.google.com/docs/android/setup#available-libraries
implementation platform('com.google.firebase:firebase-bom:32.2.2')
implementation 'com.google.firebase:firebase-analytics:21.3.0'
implementation 'com.google.firebase:firebase-analytics:21.5.0'

// other dependencies may be listed here
testImplementation 'junit:junit:4.13.2' // For JUnit 4
// or
testImplementation 'junit:junit:4.13.2' // For JUnit 5
}

}
apply plugin: 'com.google.gms.google-services'
7 changes: 6 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Design.Light">
<activity
android:name=".PermitApprovalActivity"
android:exported="false"
android:theme="@style/Theme.Design.Light.NoActionBar" />
<activity
android:name=".DriverLeaveFormActivity"
android:exported="false" />
android:exported="false"
android:theme="@style/Theme.Design.Light.NoActionBar" />
<activity
android:name=".DriverPickFarmActivity"
android:exported="false"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
package com.example.intellimills;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class AdminDashboardActivity extends AppCompatActivity {

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

// Get a reference to the btnPermitApproval button
Button btnPermitApproval = findViewById(R.id.btnPermitApproval);

// Set an OnClickListener for the btnPermitApproval button
btnPermitApproval.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Open the PermitApprovalActivity when the button is clicked
Intent permitApprovalIntent = new Intent(AdminDashboardActivity.this, PermitApprovalActivity.class);
startActivity(permitApprovalIntent);
}
});

// Add similar code for other buttons to open their respective activities
// For example, if you have a button for Extraction Approval, add code here to open ExtractionApprovalActivity.
}
}
}
68 changes: 41 additions & 27 deletions app/src/main/java/com/example/intellimills/AdminLogin.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.example.intellimills;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
Expand All @@ -9,53 +11,65 @@
import android.widget.Toast;
import android.content.Intent;

public class AdminLogin extends AppCompatActivity {
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.AuthResult;

// Define hardcoded admin credentials
private static final String ADMIN_USERNAME = "adminintel";
private static final String ADMIN_PASSWORD = "001122";
public class AdminLogin extends AppCompatActivity {

EditText editemail;
EditText editpasswrd;
Button button2;

// Initialize Firebase Authentication
private FirebaseAuth mAuth;

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

// Initialize Firebase Authentication
mAuth = FirebaseAuth.getInstance();

editemail = findViewById(R.id.editTextTextEmailAddress2);
editpasswrd = findViewById(R.id.editTextTextPassword2);
button2 = findViewById(R.id.button2login);

Button button2 = findViewById(R.id.button2login);
button2.setOnClickListener(view -> loginUser());
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
loginUser();
}
});
}

private void loginUser() {
String email = editemail.getText().toString();
String password = editpasswrd.getText().toString();

if (TextUtils.isEmpty(email)) {
editemail.setError("Email cannot be empty");
editemail.requestFocus();
Toast.makeText(getApplicationContext(), "Please Enter Your Email", Toast.LENGTH_LONG).show();
} else if (TextUtils.isEmpty(password)) {
editpasswrd.setError("Password cannot be empty");
editpasswrd.requestFocus();
Toast.makeText(getApplicationContext(), "Please enter Password.", Toast.LENGTH_LONG).show();
if (TextUtils.isEmpty(email) || TextUtils.isEmpty(password)) {
Toast.makeText(getApplicationContext(), "Please enter email and password.", Toast.LENGTH_LONG).show();
} else {
// Check if the provided credentials match the hardcoded admin credentials
if (email.equals(ADMIN_USERNAME) && password.equals(ADMIN_PASSWORD)) {
// Admin login successful
Toast.makeText(AdminLogin.this, "Admin login successful", Toast.LENGTH_LONG).show();

// Start the AdminDashboardActivity
Intent adminDashboardIntent = new Intent(AdminLogin.this, AdminDashboardActivity.class);
startActivity(adminDashboardIntent);
// Optional: Finish the AdminLoginActivity to prevent going back to it
} else {
// Admin login failed
Toast.makeText(AdminLogin.this, "Admin login failed. Incorrect credentials.", Toast.LENGTH_LONG).show();
}
mAuth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// Admin login successful
Toast.makeText(AdminLogin.this, "Admin login successful", Toast.LENGTH_LONG).show();

// Start the AdminDashboardActivity
Intent adminDashboardIntent = new Intent(AdminLogin.this, AdminDashboardActivity.class);
startActivity(adminDashboardIntent);
// Optional: Finish the AdminLoginActivity to prevent going back to it
} else {
// Admin login failed
Toast.makeText(AdminLogin.this, "Admin login failed. Incorrect credentials.", Toast.LENGTH_LONG).show();
}
}
});
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,89 @@
package com.example.intellimills;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import java.util.HashMap;
import java.util.Map;

public class DriverLeaveFormActivity extends AppCompatActivity {

private EditText nameEditText;
private EditText idEditText;
private EditText reasonEditText;

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

nameEditText = findViewById(R.id.name3);
idEditText = findViewById(R.id.Id);
reasonEditText = findViewById(R.id.editTextText4);

Button clearButton = findViewById(R.id.button11);
clearButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Clear all EditText fields
nameEditText.setText("");
idEditText.setText("");
reasonEditText.setText("");
}
});

Button submitButton = findViewById(R.id.button7);
submitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Get the user's input
String name = nameEditText.getText().toString();
String id = idEditText.getText().toString();
String reason = reasonEditText.getText().toString();

// Validate the input and submit to Firebase
if (!name.isEmpty() && !id.isEmpty() && !reason.isEmpty()) {
submitLeaveToFirebase(name, id, reason);
} else {
Toast.makeText(DriverLeaveFormActivity.this, "Please fill in all fields.", Toast.LENGTH_SHORT).show();
}
}
});
}

private void submitLeaveToFirebase(String name, String id, String reason) {
// Replace this with your Firebase database reference
DatabaseReference leaveRef = FirebaseDatabase.getInstance().getReference("leave_requests");

// Create a unique key for the leave request
String leaveId = leaveRef.push().getKey();

// Create a map to store the leave data
Map<String, Object> leaveData = new HashMap<>();
leaveData.put("name", name);
leaveData.put("id", id);
leaveData.put("reason", reason);

// Push the data to Firebase
leaveRef.child(leaveId).updateChildren(leaveData)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Toast.makeText(DriverLeaveFormActivity.this, "Submission successful.", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(DriverLeaveFormActivity.this, "Submission failed. Please try again.", Toast.LENGTH_SHORT).show();
}
}
});
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.example.intellimills;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TableRow;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;

public class PermitApprovalActivity extends AppCompatActivity {

private DatabaseReference databaseReference;
private static final String TAG = "PermitApprovalActivity";

private Button updateButton;
private TableRow secondRow;

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

// Replace "your_project_name" with your actual Firebase project name
databaseReference = FirebaseDatabase.getInstance().getReference().child("Harvest Applications");

updateButton = findViewById(R.id.btnUpdate);
secondRow = findViewById(R.id.secondRow); // Assuming you have a TableRow with this ID in your XML layout

updateButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
fetchDataFromFirebaseForSecondRow();
}
});

fetchDataFromFirebaseForSecondRow();
}

private void fetchDataFromFirebaseForSecondRow() {
databaseReference.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
// Assuming "Harvest Applications" is a direct child of the root
DataSnapshot harvestApplicationsSnapshot = dataSnapshot.child("Harvest Applications");

// Assuming the second row data is stored under a specific child (e.g., "record1")
DataSnapshot secondRowDataSnapshot = harvestApplicationsSnapshot.child("record1");

// Assuming you have TextViews in the second row with IDs userarea, usercounty, etc.
updateTextView(secondRow, R.id.userarea, secondRowDataSnapshot.child("userarea").getValue(String.class));
updateTextView(secondRow, R.id.usercounty, secondRowDataSnapshot.child("usercounty").getValue(String.class));
// Add similar lines for other fields

// Update the UI for other fields as needed
}

@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
Log.w(TAG, "fetchDataFromFirebaseForSecondRow:onCancelled", databaseError.toException());
}
});
}

private void updateTextView(TableRow row, int textViewId, String value) {
TextView textView = row.findViewById(textViewId);
if (textView != null) {
textView.setText(value);
}
}
}
Loading

0 comments on commit b702776

Please sign in to comment.