Skip to content

Commit

Permalink
- notifies cook when their suspension is lifted
Browse files Browse the repository at this point in the history
  • Loading branch information
sohpha committed Nov 7, 2022
1 parent 7f5ca62 commit afaf616
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 11 deletions.
7 changes: 7 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
android:supportsRtl="true"
android:theme="@style/Theme.MealerApp"
tools:targetApi="31">
<activity
android:name=".TemporarilySuspended"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".PermanentlySuspended"
android:exported="false">
Expand Down
23 changes: 12 additions & 11 deletions app/src/main/java/com/example/mealerapp/MainLogin.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class MainLogin extends AppCompatActivity {
private Button login;
private EditText textInputEmail;
private EditText textInputPassword;
private String susLiftedDate;


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

/* String currentDate = java.time.LocalDate.now().toString();
String[] splitCurrentDate = currentDate.split("-");
int currentYear = Integer.parseInt(splitCurrentDate[0]);
int currentMonth = Integer.parseInt(splitCurrentDate[1]);
int currentDay = Integer.parseInt(splitCurrentDate[2]);*/

Date now = new Date();
int currentYear = now.getYear();
int currentMonth = now.getMonth();
Expand All @@ -96,8 +91,11 @@ public void onDataChange(@NonNull DataSnapshot snapshot) {
if (susYear > currentYear || (susYear == currentYear && susMonth > currentMonth)
|| susYear == currentYear && susMonth == currentMonth && susDay > currentDay) {

String susLiftedDate = susYear + "/" + susMonth + "/" + susDay;
openTempSusPage(susLiftedDate);
susYear += 1900;
susMonth += 1;
susLiftedDate = susYear + "/" + susMonth + "/" + susDay;
openTempSusPage();


} else {

Expand Down Expand Up @@ -162,9 +160,12 @@ public void openPermSusPage() {
startActivity(intent);
}

public void openTempSusPage(String susLiftedDate) {
return;
}
public void openTempSusPage() {
Intent intent = new Intent(this, TemporarilySuspended.class);
intent.putExtra("Date", susLiftedDate);
startActivity(intent);


}

}
24 changes: 24 additions & 0 deletions app/src/main/java/com/example/mealerapp/TemporarilySuspended.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.mealerapp;

import androidx.appcompat.app.AppCompatActivity;

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

public class TemporarilySuspended extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_temporarily_suspended);
TextView dateDisplay = findViewById(R.id.date);
Intent intent = getIntent();
String susLiftedDate = intent.getStringExtra("Date");
dateDisplay.setText(susLiftedDate);

}

}
28 changes: 28 additions & 0 deletions app/src/main/res/layout/activity_temporarily_suspended.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
tools:context=".TemporarilySuspended">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<TextView
android:id="@+id/textView4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="You are temporarily suspended. Your suspension will be lifted on: "
android:textSize="34sp" />

<TextView
android:id="@+id/date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="34sp" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit afaf616

Please sign in to comment.