forked from github/szkolny
[Settings] Add setting for showing teacher absences
This commit is contained in:
parent
0a578e9a28
commit
46d0459070
1
.gitignore
vendored
1
.gitignore
vendored
@ -42,6 +42,7 @@ captures/
|
||||
.idea/assetWizardSettings.xml
|
||||
.idea/dictionaries
|
||||
.idea/libraries
|
||||
.idea/copyright
|
||||
# Android Studio 3 in .gitignore file.
|
||||
.idea/caches
|
||||
.idea/modules.xml
|
||||
|
@ -181,43 +181,44 @@ public class AgendaFragment extends Fragment {
|
||||
));
|
||||
}
|
||||
|
||||
if (app.profile.getStudentData("showTeacherAbsences", true)) {
|
||||
List<TeacherAbsenceFull> teacherAbsenceList = app.db.teacherAbsenceDao().getAllFull(App.profileId);
|
||||
List<TeacherAbsenceCounter> teacherAbsenceCounters = new ArrayList<>();
|
||||
|
||||
List<TeacherAbsenceFull> teacherAbsenceList = app.db.teacherAbsenceDao().getAllFull(App.profileId);
|
||||
List<TeacherAbsenceCounter> teacherAbsenceCounters = new ArrayList<>();
|
||||
for (TeacherAbsenceFull absence : teacherAbsenceList) {
|
||||
for (Date date = absence.getDateFrom().clone(); date.compareTo(absence.getDateTo()) < 1; date.stepForward(0, 0, 1)) {
|
||||
boolean counterFound = false;
|
||||
for (TeacherAbsenceCounter counter : teacherAbsenceCounters) {
|
||||
if (counter.getTeacherAbsenceDate().compareTo(date) == 0) {
|
||||
counter.setTeacherAbsenceCount(counter.getTeacherAbsenceCount() + 1);
|
||||
counterFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (TeacherAbsenceFull absence : teacherAbsenceList) {
|
||||
for (Date date = absence.getDateFrom().clone(); date.compareTo(absence.getDateTo()) < 1; date.stepForward(0, 0, 1)) {
|
||||
boolean counterFound = false;
|
||||
for (TeacherAbsenceCounter counter : teacherAbsenceCounters) {
|
||||
if (counter.getTeacherAbsenceDate().compareTo(date) == 0) {
|
||||
counter.setTeacherAbsenceCount(counter.getTeacherAbsenceCount() + 1);
|
||||
counterFound = true;
|
||||
break;
|
||||
if (!counterFound) {
|
||||
teacherAbsenceCounters.add(new TeacherAbsenceCounter(date.clone(), 1));
|
||||
}
|
||||
}
|
||||
|
||||
if (!counterFound) {
|
||||
teacherAbsenceCounters.add(new TeacherAbsenceCounter(date.clone(), 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (TeacherAbsenceCounter counter : teacherAbsenceCounters) {
|
||||
Calendar startTime = Calendar.getInstance();
|
||||
Calendar endTime = Calendar.getInstance();
|
||||
Date date = counter.getTeacherAbsenceDate();
|
||||
startTime.set(date.year, date.month - 1, date.day, 10, 0, 0);
|
||||
endTime.setTimeInMillis(startTime.getTimeInMillis() + (1000 * 60 * 45));
|
||||
eventList.add(new TeacherAbsenceEvent(
|
||||
date.getInMillis(),
|
||||
0xffff1744,
|
||||
Colors.legibleTextColor(0xffff1744),
|
||||
startTime,
|
||||
endTime,
|
||||
App.profileId,
|
||||
date,
|
||||
counter.getTeacherAbsenceCount()
|
||||
));
|
||||
for (TeacherAbsenceCounter counter : teacherAbsenceCounters) {
|
||||
Calendar startTime = Calendar.getInstance();
|
||||
Calendar endTime = Calendar.getInstance();
|
||||
Date date = counter.getTeacherAbsenceDate();
|
||||
startTime.set(date.year, date.month - 1, date.day, 10, 0, 0);
|
||||
endTime.setTimeInMillis(startTime.getTimeInMillis() + (1000 * 60 * 45));
|
||||
eventList.add(new TeacherAbsenceEvent(
|
||||
date.getInMillis(),
|
||||
0xffff1744,
|
||||
Colors.legibleTextColor(0xffff1744),
|
||||
startTime,
|
||||
endTime,
|
||||
App.profileId,
|
||||
date,
|
||||
counter.getTeacherAbsenceCount()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,6 +45,7 @@ import pl.szczodrzynski.edziennik.BuildConfig;
|
||||
import pl.szczodrzynski.edziennik.Notifier;
|
||||
import pl.szczodrzynski.edziennik.R;
|
||||
import pl.szczodrzynski.edziennik.MainActivity;
|
||||
import pl.szczodrzynski.edziennik.data.db.modules.login.LoginStore;
|
||||
import pl.szczodrzynski.edziennik.ui.modules.webpush.WebPushConfigActivity;
|
||||
import pl.szczodrzynski.edziennik.ui.dialogs.changelog.ChangelogDialog;
|
||||
import pl.szczodrzynski.edziennik.utils.models.Endpoint;
|
||||
@ -1057,6 +1058,24 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
||||
})
|
||||
);
|
||||
|
||||
if (app.profile.getLoginStoreType() == LoginStore.LOGIN_TYPE_LIBRUS) {
|
||||
items.add(
|
||||
new MaterialAboutSwitchItem(
|
||||
getString(R.string.settings_register_show_teacher_absences_text),
|
||||
null,
|
||||
new IconicsDrawable(activity)
|
||||
.icon(CommunityMaterial.Icon.cmd_account_arrow_right)
|
||||
.size(IconicsSize.dp(iconSizeDp))
|
||||
.color(IconicsColor.colorInt(iconColor))
|
||||
)
|
||||
.setChecked(app.profile.getStudentData("showTeacherAbsences", true))
|
||||
.setOnChangeAction((isChecked, tag) -> {
|
||||
app.profile.putStudentData("showTeacherAbsences", isChecked);
|
||||
return true;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
@ -854,4 +854,5 @@
|
||||
<string name="agenda_teacher_absence">Absent teachers</string>
|
||||
<string name="sync_action_syncing_grade_comments">Getting grade comments</string>
|
||||
<string name="sync_action_syncing_school_free_days">Getting school free days</string>
|
||||
<string name="settings_register_show_teacher_absences_text">Show teacher absences</string>
|
||||
</resources>
|
||||
|
@ -910,4 +910,5 @@
|
||||
<string name="homework_no_data">Brak zadań domowych.</string>
|
||||
<string name="agenda_teacher_absence">Nieobecni nauczyciele</string>
|
||||
<string name="sync_action_syncing_grade_comments">Pobieranie komentarzy ocen</string>
|
||||
<string name="settings_register_show_teacher_absences_text">Pokazuj nieobecności nauczycieli</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user