-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmployeeViewActivity.java
More file actions
116 lines (94 loc) · 4.4 KB
/
EmployeeViewActivity.java
File metadata and controls
116 lines (94 loc) · 4.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package com.example.finalproject;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import java.util.ArrayList;
public class EmployeeViewActivity extends AppCompatActivity {
private TextView totalExpensesTextView, approvedExpensesTextView, pendingExpensesTextView;
private Button submitExpenseButton, viewSummaryButton;
private ImageView notificationsIcon, userProfileIcon;
private ListView recentActivityListView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_employee_view);
// Initialize the views
totalExpensesTextView = findViewById(R.id.totalExpensesTextView);
approvedExpensesTextView = findViewById(R.id.approvedExpensesTextView);
pendingExpensesTextView = findViewById(R.id.pendingExpensesTextView);
submitExpenseButton = findViewById(R.id.submitExpenseButton);
viewSummaryButton = findViewById(R.id.viewSummaryButton);
recentActivityListView = findViewById(R.id.recentActivityListView);
// Setting sample text values
totalExpensesTextView.setText("Total Submitted: $500");
approvedExpensesTextView.setText("Approved: $300");
pendingExpensesTextView.setText("Pending: $200");
// Set listeners for buttons and icons
submitExpenseButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openSubmitExpenseScreen();
}
});
viewSummaryButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openViewSummaryScreen();
}
});
if (notificationsIcon != null) {
notificationsIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openNotifications();
}
});
} else {
Toast.makeText(this, "Notifications icon not found!", Toast.LENGTH_SHORT).show();
}
if (userProfileIcon != null) {
userProfileIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openProfileSettings();
}
});
} else {
Toast.makeText(this, "Profile icon not found!", Toast.LENGTH_SHORT).show();
}
loadRecentActivity();
}
private void openSubmitExpenseScreen() {
Toast.makeText(this, "Opening Submit Expense Screen...", Toast.LENGTH_SHORT).show();
}
private void openViewSummaryScreen() {
Toast.makeText(this, "Opening View Summary Screen...", Toast.LENGTH_SHORT).show();
}
private void openNotifications() {
Toast.makeText(this, "Opening Notifications...", Toast.LENGTH_SHORT).show();
}
private void openProfileSettings() {
Toast.makeText(this, "Opening Profile & Settings...", Toast.LENGTH_SHORT).show();
}
private void loadRecentActivity() {
ArrayList<String> recentActivities = new ArrayList<>();
// Retrieve saved expense data from SharedPreferences
SharedPreferences sharedPreferences = getSharedPreferences("ExpenseData", MODE_PRIVATE);
String expenseType = sharedPreferences.getString("expenseType", "No Expense Found");
String expenseAmount = sharedPreferences.getString("expenseAmount", "0");
// Add the retrieved expense to the recent activities list
recentActivities.add("Expense Type: " + expenseType + " - Amount: $" + expenseAmount);
// You can add more items to the list as needed for more expenses
recentActivities.add("Travel Expense - $50 - Approved");
recentActivities.add("Meal Expense - $30 - Pending");
recentActivities.add("Office Supplies - $120 - Approved");
AdapterActivity adapter = new AdapterActivity(this, recentActivities);
recentActivityListView.setAdapter(adapter);
}
}