From cb2d4a905d8d005c1bac68f15bee0a6c29725c69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Thu, 3 May 2018 12:49:33 +0200 Subject: [PATCH] Add option to hide present in attendance (#96) --- .../wulkanowy/data/db/shared/SharedPrefContract.java | 2 ++ .../wulkanowy/data/db/shared/SharedPrefRepository.java | 5 +++++ .../ui/main/attendance/AttendanceTabPresenter.java | 9 +++++++++ .../wulkanowy/ui/main/settings/SettingsFragment.java | 2 ++ app/src/main/res/values-pl/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/preferences.xml | 8 +++++++- 7 files changed, 29 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/github/wulkanowy/data/db/shared/SharedPrefContract.java b/app/src/main/java/io/github/wulkanowy/data/db/shared/SharedPrefContract.java index 48e2b193..b9d3fd14 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/shared/SharedPrefContract.java +++ b/app/src/main/java/io/github/wulkanowy/data/db/shared/SharedPrefContract.java @@ -19,6 +19,8 @@ public interface SharedPrefContract { boolean isShowGradesSummary(); + boolean isShowAttendancePresent(); + int getServicesInterval(); boolean isMobileDisable(); diff --git a/app/src/main/java/io/github/wulkanowy/data/db/shared/SharedPrefRepository.java b/app/src/main/java/io/github/wulkanowy/data/db/shared/SharedPrefRepository.java index 35d30ae6..484af3d1 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/shared/SharedPrefRepository.java +++ b/app/src/main/java/io/github/wulkanowy/data/db/shared/SharedPrefRepository.java @@ -65,6 +65,11 @@ public class SharedPrefRepository implements SharedPrefContract { return settingsSharedPref.getBoolean(SettingsFragment.SHARED_KEY_GRADES_SUMMARY, false); } + @Override + public boolean isShowAttendancePresent() { + return settingsSharedPref.getBoolean(SettingsFragment.SHARED_KEY_ATTENDANCE_PRESENT, false); + } + @Override public int getServicesInterval() { return Integer.parseInt(settingsSharedPref.getString(SettingsFragment.SHARED_KEY_SERVICES_INTERVAL, "60")); diff --git a/app/src/main/java/io/github/wulkanowy/ui/main/attendance/AttendanceTabPresenter.java b/app/src/main/java/io/github/wulkanowy/ui/main/attendance/AttendanceTabPresenter.java index effc38bc..5731cbb3 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/main/attendance/AttendanceTabPresenter.java +++ b/app/src/main/java/io/github/wulkanowy/ui/main/attendance/AttendanceTabPresenter.java @@ -93,6 +93,7 @@ public class AttendanceTabPresenter extends BasePresenter subItems = new ArrayList<>(); for (AttendanceLesson lesson : lessonList) { + if (!isShowPresent && lesson.getPresence()) { + continue; + } + lesson.setDescription(getRepository().getResRepo().getAttendanceLessonDescription(lesson)); subItems.add(new AttendanceSubItem(headerItem, lesson)); } + if (!isShowPresent && subItems.isEmpty()) { + continue; + } + headerItem.setSubItems(subItems); headerItem.setExpanded(false); headerItems.add(headerItem); diff --git a/app/src/main/java/io/github/wulkanowy/ui/main/settings/SettingsFragment.java b/app/src/main/java/io/github/wulkanowy/ui/main/settings/SettingsFragment.java index 0359baca..8b53f077 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/main/settings/SettingsFragment.java +++ b/app/src/main/java/io/github/wulkanowy/ui/main/settings/SettingsFragment.java @@ -14,6 +14,8 @@ public class SettingsFragment extends PreferenceFragmentCompat public static final String SHARED_KEY_GRADES_SUMMARY = "grades_summary"; + public static final String SHARED_KEY_ATTENDANCE_PRESENT = "attendance_present"; + public static final String SHARED_KEY_SERVICES_ENABLE = "services_enable"; public static final String SHARED_KEY_NOTIFY_ENABLE = "notify_enable"; diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 65fc4f4c..0b323629 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -124,6 +124,8 @@ Widok Domyślny widok Pokazuj podsumowanie w ocenach + Pokazuj obecność we frekwencji + Wymagany restart Powiadomienia Pokazuj powiadomienia diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 019601a3..12ad9898 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -119,6 +119,8 @@ View Default view after startup Show summary in grades + Show present in attendance + Required restart Notifications Show the notifications diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index bc4f8130..b620e299 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -11,7 +11,13 @@ + android:title="@string/pref_grades_summary_line_show" + android:summary="@string/required_restart" /> +