Skip to content

Commit afaf616

Browse files
committed
- notifies cook when their suspension is lifted
1 parent 7f5ca62 commit afaf616

File tree

4 files changed

+71
-11
lines changed

4 files changed

+71
-11
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
android:supportsRtl="true"
1313
android:theme="@style/Theme.MealerApp"
1414
tools:targetApi="31">
15+
<activity
16+
android:name=".TemporarilySuspended"
17+
android:exported="false">
18+
<meta-data
19+
android:name="android.app.lib_name"
20+
android:value="" />
21+
</activity>
1522
<activity
1623
android:name=".PermanentlySuspended"
1724
android:exported="false">

app/src/main/java/com/example/mealerapp/MainLogin.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class MainLogin extends AppCompatActivity {
2929
private Button login;
3030
private EditText textInputEmail;
3131
private EditText textInputPassword;
32+
private String susLiftedDate;
3233

3334

3435
// DatabaseReference reference = FirebaseDatabase.getInstance().getReference("Users");
@@ -77,12 +78,6 @@ public void onDataChange(@NonNull DataSnapshot snapshot) {
7778
openCookWelcomePage();
7879
} else if (!suspensionStatus.equals("p")) {
7980

80-
/* String currentDate = java.time.LocalDate.now().toString();
81-
String[] splitCurrentDate = currentDate.split("-");
82-
int currentYear = Integer.parseInt(splitCurrentDate[0]);
83-
int currentMonth = Integer.parseInt(splitCurrentDate[1]);
84-
int currentDay = Integer.parseInt(splitCurrentDate[2]);*/
85-
8681
Date now = new Date();
8782
int currentYear = now.getYear();
8883
int currentMonth = now.getMonth();
@@ -96,8 +91,11 @@ public void onDataChange(@NonNull DataSnapshot snapshot) {
9691
if (susYear > currentYear || (susYear == currentYear && susMonth > currentMonth)
9792
|| susYear == currentYear && susMonth == currentMonth && susDay > currentDay) {
9893

99-
String susLiftedDate = susYear + "/" + susMonth + "/" + susDay;
100-
openTempSusPage(susLiftedDate);
94+
susYear += 1900;
95+
susMonth += 1;
96+
susLiftedDate = susYear + "/" + susMonth + "/" + susDay;
97+
openTempSusPage();
98+
10199

102100
} else {
103101

@@ -162,9 +160,12 @@ public void openPermSusPage() {
162160
startActivity(intent);
163161
}
164162

165-
public void openTempSusPage(String susLiftedDate) {
166-
return;
167-
}
163+
public void openTempSusPage() {
164+
Intent intent = new Intent(this, TemporarilySuspended.class);
165+
intent.putExtra("Date", susLiftedDate);
166+
startActivity(intent);
167+
168168

169+
}
169170

170171
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.example.mealerapp;
2+
3+
import androidx.appcompat.app.AppCompatActivity;
4+
5+
import android.content.Intent;
6+
import android.os.Bundle;
7+
import android.view.View;
8+
import android.widget.TextView;
9+
10+
public class TemporarilySuspended extends AppCompatActivity {
11+
12+
@Override
13+
protected void onCreate(Bundle savedInstanceState) {
14+
15+
super.onCreate(savedInstanceState);
16+
setContentView(R.layout.activity_temporarily_suspended);
17+
TextView dateDisplay = findViewById(R.id.date);
18+
Intent intent = getIntent();
19+
String susLiftedDate = intent.getStringExtra("Date");
20+
dateDisplay.setText(susLiftedDate);
21+
22+
}
23+
24+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
android:background="@color/white"
8+
tools:context=".TemporarilySuspended">
9+
10+
<LinearLayout
11+
android:layout_width="match_parent"
12+
android:layout_height="match_parent"
13+
android:orientation="vertical">
14+
15+
<TextView
16+
android:id="@+id/textView4"
17+
android:layout_width="match_parent"
18+
android:layout_height="wrap_content"
19+
android:text="You are temporarily suspended. Your suspension will be lifted on: "
20+
android:textSize="34sp" />
21+
22+
<TextView
23+
android:id="@+id/date"
24+
android:layout_width="match_parent"
25+
android:layout_height="wrap_content"
26+
android:textSize="34sp" />
27+
</LinearLayout>
28+
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)