Skip to content

Commit 9a601e2

Browse files
committed
1.3
1 parent 1cb4710 commit 9a601e2

File tree

7 files changed

+154
-35
lines changed

7 files changed

+154
-35
lines changed

app/src/main/java/com/spr/selfcheck/FirebaseAccess.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class FirebaseAccess {
2929
final private DatabaseReference shopReference;
3030
final private DatabaseReference eventReference;
3131
final private DatabaseReference pinReference;
32+
final private DatabaseReference todoReference;
3233
final private String shop = "b4b8bb4ceeaa2aee";
3334

3435
public String eName;
@@ -50,6 +51,7 @@ public FirebaseAccess() {
5051
eventReference = dbInstance.getReference().child("shop_events/" + shop + "/authorised_id/");
5152
shopReference = dbInstance.getReference().child("shop_data/" + shop + "/employee_data/");
5253
pinReference = dbInstance.getReference().child("shop_data/" + shop + "/pin/");
54+
todoReference = dbInstance.getReference().child("shop_events/" + shop + "/todo_data/");
5355
employeeID = "";
5456
}
5557

@@ -86,6 +88,12 @@ public void add_record(String id, String documentStamp, String timeStamp, int da
8688
eventReference.child(id + "/log_events/" + documentStamp).setValue(record);
8789
}
8890

91+
public void add_todo(String text, boolean check, String recipient, String documentStamp, String dateStamp, String dateS) {
92+
// Add record
93+
TodoRecord todoRecord = new TodoRecord(dateS, dateStamp, recipient, check, text);
94+
todoReference.child(documentStamp + "Todo").setValue(todoRecord);
95+
}
96+
8997
public void self_check(String id, String documentStamp, String timeStamp, int dateStamp, String realtime, Context context) {
9098
TextView txtPlaceholderTwo = ((Activity) context).findViewById(R.id.txtPlaceholderTwo);
9199
eventReference.child(id + "/actual_state").get().addOnCompleteListener(task -> {
@@ -123,12 +131,6 @@ public void output_name(String id, Context context) {
123131
});
124132
}
125133

126-
public void get_info(String id, Context context) {
127-
get_name(id, context, name -> {
128-
129-
});
130-
}
131-
132134
public void get_name(String id, Context context, final String_Callback callback) {
133135
Log.e("id", id);
134136
shopReference.addListenerForSingleValueEvent(new ValueEventListener() {
@@ -147,8 +149,7 @@ public void onDataChange(@NonNull DataSnapshot snapshot) {
147149
eName = employeeName[0];
148150
employeeID = id;
149151
callback.onSuccess(eName);
150-
}
151-
Toast.makeText(context, R.string.no_tag_on_database, Toast.LENGTH_SHORT).show();
152+
} else Toast.makeText(context, R.string.no_tag_on_database, Toast.LENGTH_SHORT).show();
152153
}
153154

154155
@Override
@@ -245,16 +246,19 @@ public void onDataChange(@NonNull DataSnapshot snapshot) {
245246
String timeStamp = new SimpleDateFormat("yyyyMMddHHmm").format(date);
246247
String documentStamp = new SimpleDateFormat("yyyyMMddHHmmss").format(date);
247248
String dateStamp = new SimpleDateFormat("yyyyMMdd").format(date);
249+
String dateTodo = new SimpleDateFormat("dd-MM-yyyy").format(date);
248250
int dateS = Integer.parseInt(dateStamp);
249251

250252
for (DataSnapshot snap : snapshot.getChildren()) {
251253
update_state(snap.getKey(), "out");
252254
add_record(snap.getKey(), documentStamp, timeStamp, dateS,"out");
253255
listNotLoggedOut.append(snap.getKey()).append(" ");
254256
}
255-
NotificationMaker notify = new NotificationMaker();
256-
notify.alertInEmployee(context, context.getString(R.string.logout_report), context.getString(R.string.alert_not_logout, listNotLoggedOut.toString()), new Intent(context, FirebaseAccess.class), 1);
257257

258+
NotificationMaker notify = new NotificationMaker();
259+
String alert = context.getString(R.string.alert_not_logout, listNotLoggedOut.toString());
260+
notify.alertInEmployee(context, context.getString(R.string.logout_report), alert, new Intent(context, FirebaseAccess.class), 1);
261+
add_todo(alert, false, "Opastajat", documentStamp, dateStamp, dateTodo);
258262
}
259263
}
260264

app/src/main/java/com/spr/selfcheck/NfcWriteActivity.java

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import android.nfc.Tag;
1313
import android.nfc.tech.Ndef;
1414
import android.nfc.tech.NdefFormatable;
15+
import android.os.Build;
1516
import android.os.Bundle;
1617
import android.os.Parcelable;
1718
import android.util.Log;
@@ -64,9 +65,9 @@ public void onCreate(Bundle savedInstanceState) {
6465
isAuthorized = false;
6566
access = new FirebaseAccess();
6667
access.get_store_passcode(this);
67-
txtInputGuide.setText("Input password, then press Next, then input the new tagID and press next again, then insert the card to write the ID to the tag.");
68+
txtInputGuide.setText(R.string.txt_guide);
6869
currentLocale = getIntent().getExtras().getString("locale");
69-
editInput.setHint("Manger's password");
70+
editInput.setHint(R.string.manager_pass);
7071
Intent backToMain = new Intent(this, MainActivity.class);
7172

7273
// NFC Init
@@ -83,7 +84,7 @@ public void onCreate(Bundle savedInstanceState) {
8384
btnBack.setOnClickListener(v -> startActivity(backToMain));
8485
btnSbm.setOnClickListener(v -> {
8586
if (editInput.getText().toString().equals(""))
86-
txtInputGuide.setText("Do not leave this field blank");
87+
txtInputGuide.setText(R.string.no_blank);
8788
else {
8889
if (!isAuthorized) {
8990
String password = access.storePasscode();
@@ -92,20 +93,15 @@ public void onCreate(Bundle savedInstanceState) {
9293
if (!editInput.getText().toString().equals(password)) {
9394
txtInputGuide.setText(R.string.wrong_password);
9495
} else {
95-
txtInputGuide.setText("Input the tagID you want to write.");
96+
txtInputGuide.setText(R.string.txt_guide_input_id);
9697
editInput.setText("");
97-
editInput.setHint("Tag ID.");
98+
editInput.setHint("ID");
9899
isAuthorized = true;
99100
}
100101
}
101102
} else {
102103
tagRecord = editInput.getText().toString();
103-
if (empID == null) {
104-
txtInputGuide.setText("Please insert card.");
105-
} else {
106-
txtInputGuide.setText("Insert the card behind the phone to start writing.");
107-
Log.e("Write", editInput.getText().toString());
108-
}
104+
txtInputGuide.setText(R.string.txt_guide_insert_card);
109105
}
110106
}
111107
});
@@ -143,14 +139,14 @@ private void handleIntent(Intent intent) {
143139
NdefMessage ndfMsg = (NdefMessage) rawMessages[0];
144140
String message = new String(ndfMsg.getRecords()[0].getPayload());
145141
empID = message.substring(3);
146-
Toast.makeText(this, "Old ID: " + empID + ". New ID: " + tagRecord + ".", Toast.LENGTH_LONG).show();
142+
Toast.makeText(this, this.getString(R.string.txt_guide_popup_replace, empID, tagRecord), Toast.LENGTH_LONG).show();
147143
} else {
148144
// Write new tag
149-
Toast.makeText(this, "New NFC tag: " + tagRecord + ".", Toast.LENGTH_LONG).show();
145+
Toast.makeText(this, this.getString(R.string.txt_guide_popup_newid, tagRecord), Toast.LENGTH_LONG).show();
150146
}
151147
writeTag(tag, createTextMessage(tagRecord));
152148
refresh();
153-
} else txtInputGuide.setText("You have to type the password or the tagID and press Next before inserting the card!");
149+
} else txtInputGuide.setText(R.string.txt_guide_card_wrong);
154150

155151
}
156152
}
@@ -182,7 +178,7 @@ public static void stopForegroundDispatch(final Activity activity, NfcAdapter ad
182178
adapter.disableForegroundDispatch(activity);
183179
}
184180

185-
public NdefMessage createTextMessage (String id) {
181+
public NdefMessage createTextMessage(String id) {
186182
try {
187183
byte[] lang = Locale.getDefault().getLanguage().getBytes(StandardCharsets.UTF_8);
188184
byte[] text = id.getBytes(StandardCharsets.UTF_8); // Content in UTF-8
@@ -224,11 +220,10 @@ public void writeTag(Tag tag, NdefMessage id) {
224220
}
225221
}
226222

227-
@SuppressLint("SetTextI18n")
228-
public void refresh(){
229-
txtInputGuide.setText("You can go back to the login screen, or press the new tag ID in the input field, press next, then insert the new card to continue writing.");
223+
public void refresh() {
224+
txtInputGuide.setText(R.string.txt_guide_after);
230225
editInput.setText("");
231-
editInput.setHint("123456");
226+
editInput.setHint(R.string.placeholder_id);
232227
editInput.clearFocus();
233228
empID = null;
234229
tagRecord = null;
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package com.spr.selfcheck;
2+
3+
import java.util.Date;
4+
5+
public class TodoRecord {
6+
private String date;
7+
private String dateStamp;
8+
private boolean from_employee;
9+
private String name;
10+
private String recipient;
11+
private boolean check;
12+
private String message;
13+
14+
15+
public TodoRecord(String date, String dateStamp, String recipient, boolean check, String message) {
16+
this.date = date;
17+
this.dateStamp = dateStamp;
18+
this.recipient = recipient;
19+
this.check = check;
20+
this.message = message;
21+
from_employee = false;
22+
name = "SPR-Kirppis Android App";
23+
}
24+
25+
public String getDate() {
26+
return date;
27+
}
28+
29+
public void setDate(String date) {
30+
this.date = date;
31+
}
32+
33+
public String getDateStamp() {
34+
return dateStamp;
35+
}
36+
37+
public void setDateStamp(String dateStamp) {
38+
this.dateStamp = dateStamp;
39+
}
40+
41+
public boolean isFrom_employee() {
42+
return from_employee;
43+
}
44+
45+
public void setFrom_employee(boolean from_employee) {
46+
this.from_employee = from_employee;
47+
}
48+
49+
public String getName() {
50+
return name;
51+
}
52+
53+
public void setName(String name) {
54+
this.name = name;
55+
}
56+
57+
public String getRecipient() {
58+
return recipient;
59+
}
60+
61+
public void setRecipient(String recipient) {
62+
this.recipient = recipient;
63+
}
64+
65+
public boolean isCheck() {
66+
return check;
67+
}
68+
69+
public void setCheck(boolean check) {
70+
this.check = check;
71+
}
72+
73+
public String getMessage() {
74+
return message;
75+
}
76+
77+
public void setMessage(String message) {
78+
this.message = message;
79+
}
80+
}

app/src/main/res/values-en/strings.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,14 @@
3232
<string name="write_nfc_tags">Write NFC Tags</string>
3333
<string name="sbm">Next</string>
3434
<string name="wrong_password">Wrong password.</string>
35+
<string name="txt_guide">Input password, then press Next, then input the new tagID and press next again, then insert the card to write the ID to the tag.</string>
36+
<string name="txt_guide_after">You can go back to the login screen, or press the new tag ID in the input field, press next, then insert the new card to continue writing.</string>
37+
<string name="placeholder_id">ID</string>
38+
<string name="txt_guide_card_wrong">You have to type the password or the tagID and press Next before inserting the card!</string>
39+
<string name="txt_guide_insert_card">Please insert card.</string>
40+
<string name="txt_guide_input_id">Input the tagID you want to write.</string>
41+
<string name="manager_pass">Manger\'s password</string>
42+
<string name="no_blank">Do not leave this field blank</string>
43+
<string name="txt_guide_popup_replace">Old ID: %1$s. New ID: %2$s.</string>
44+
<string name="txt_guide_popup_newid">New NFC tag: %1$s.</string>
3545
</resources>

app/src/main/res/values-fi-rFI/strings.xml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,20 @@
2626
<string name="error_file_inout">VIRHE: tiedostoon ei voi kirjoittaa.</string>
2727
<string name="reminder_logout">Muista kirjautua ulos lähtiessäsi.</string>
2828
<string name="logout_report">Automaattinen uloskirjautumisraportti</string>
29-
<string name="store_s_password">Store\'s Password</string>
30-
<string name="go_back">Go Back</string>
31-
<string name="next">Next</string>
32-
<string name="write_nfc_tags">Write NFC Tags</string>
33-
<string name="sbm">Next</string>
34-
<string name="wrong_password">Wrong password.</string>
29+
<string name="store_s_password">Myymälän Salasana</string>
30+
<string name="next">Seuraava</string>
31+
<string name="write_nfc_tags">Kirjoita Tägejä</string>
32+
<string name="sbm">Seuraava</string>
33+
<string name="wrong_password">Väärä salasana.</string>
34+
<string name="txt_guide">Syötä salasana ja paina seuraava näppäintä. Tämän jälkeen syöty uuden tägin numero, pistä tägi puhelimen taakse ja paina uudelleen seuraava näppäintä.</string>
35+
<string name="txt_guide_after">Voit mennä takaisin alkuun takaisin näppäimellä tai jatkaa uusien tägien kirjoittamista syöttämällä uuden tägin numeron ja painamalla seuraava näppäintä.</string>
36+
<string name="placeholder_id">ID</string>
37+
<string name="txt_guide_card_wrong">Syötä myymälä salasana ja pain seuraav näppäintä ja sitten syöty uuden tägin numero ja laita nimikortti puhelimen taakse.</string>
38+
<string name="txt_guide_insert_card">Syötä kortti.</string>
39+
<string name="txt_guide_input_id">Syötä haluamasi tägi numero.</string>
40+
<string name="manager_pass">Ohjaajan salasana</string>
41+
<string name="no_blank">Älä jätä syöttö ruutua tyhjäksi.</string>
42+
<string name="txt_guide_popup_replace">Vanha ID: %1$s. Uusi ID: %2$s.</string>
43+
<string name="txt_guide_popup_newid">Uusi NFC tägi: %1$s.</string>
44+
<string name="go_back">Takaisin</string>
3545
</resources>

app/src/main/res/values-sv-rSE/strings.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,14 @@
3232
<string name="write_nfc_tags">Write NFC Tags</string>
3333
<string name="sbm">Next</string>
3434
<string name="wrong_password">Wrong password.</string>
35+
<string name="txt_guide">Input password, then press Next, then input the new tagID and press next again, then insert the card to write the ID to the tag.</string>
36+
<string name="txt_guide_after">You can go back to the login screen, or press the new tag ID in the input field, press next, then insert the new card to continue writing.</string>
37+
<string name="placeholder_id">ID</string>
38+
<string name="txt_guide_card_wrong">You have to type the password or the tagID and press Next before inserting the card!</string>
39+
<string name="txt_guide_insert_card">Please insert card.</string>
40+
<string name="txt_guide_input_id">Input the tagID you want to write.</string>
41+
<string name="manager_pass">Manger\'s password</string>
42+
<string name="no_blank">Do not leave this field blank</string>
43+
<string name="txt_guide_popup_newid">New NFC tag: %1$s.</string>
44+
<string name="txt_guide_popup_replace">Old ID: %1$s. New ID: %2$s.</string>
3545
</resources>

app/src/main/res/values/strings.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@
3131
<string name="write_nfc_tags">Write NFC Tags</string>
3232
<string name="sbm">Next</string>
3333
<string name="wrong_password">Wrong password.</string>
34+
<string name="txt_guide">Input password, then press Next, then input the new tagID and press next again, then insert the card to write the ID to the tag.</string>
35+
<string name="txt_guide_after">You can go back to the login screen, or press the new tag ID in the input field, press next, then insert the new card to continue writing.</string>
36+
<string name="placeholder_id">123456</string>
37+
<string name="txt_guide_card_wrong">You have to type the password or the tagID and press Next before inserting the card!</string>
38+
<string name="txt_guide_insert_card">Please insert card.</string>
39+
<string name="txt_guide_input_id">Input the tagID you want to write.</string>
40+
<string name="manager_pass">Manger\'s password</string>
41+
<string name="no_blank">Do not leave this field blank</string>
42+
<string name="txt_guide_popup_replace">Old ID: %1$s. New ID: %2$s.</string>
43+
<string name="txt_guide_popup_newid">New NFC tag: %1$s.</string>
3444

3545

3646
</resources>

0 commit comments

Comments
 (0)