[Lab] Add archiver enabled checkbox.

This commit is contained in:
Kuba Szczodrzyński 2021-02-22 16:37:53 +01:00
parent 9b48041cd9
commit f8456fb087
4 changed files with 20 additions and 1 deletions

View File

@ -105,6 +105,11 @@ class Config(val db: AppDb) : CoroutineScope, AbstractConfig {
get() { mWidgetConfigs = mWidgetConfigs ?: values.get("widgetConfigs", JsonObject()); return mWidgetConfigs ?: JsonObject() } get() { mWidgetConfigs = mWidgetConfigs ?: values.get("widgetConfigs", JsonObject()); return mWidgetConfigs ?: JsonObject() }
set(value) { set("widgetConfigs", value); mWidgetConfigs = value } set(value) { set("widgetConfigs", value); mWidgetConfigs = value }
private var mArchiverEnabled: Boolean? = null
var archiverEnabled: Boolean
get() { mArchiverEnabled = mArchiverEnabled ?: values.get("archiverEnabled", true); return mArchiverEnabled ?: true }
set(value) { set("archiverEnabled", value); mArchiverEnabled = value }
private var rawEntries: List<ConfigEntry> = db.configDao().getAllNow() private var rawEntries: List<ConfigEntry> = db.configDao().getAllNow()
private val profileConfigs: HashMap<Int, ProfileConfig> = hashMapOf() private val profileConfigs: HashMap<Int, ProfileConfig> = hashMapOf()
init { init {

View File

@ -103,7 +103,9 @@ open class Profile(
dateSemester2Start.year -= diff dateSemester2Start.year -= diff
dateYearEnd.year -= diff dateYearEnd.year -= diff
} }
return Date.getToday() >= dateYearEnd && Date.getToday().year > studentSchoolYearStart return App.config.archiverEnabled
&& Date.getToday() >= dateYearEnd
&& Date.getToday().year > studentSchoolYearStart
} }
fun isBeforeYear() = false && Date.getToday() < dateSemester1Start fun isBeforeYear() = false && Date.getToday() < dateSemester1Start

View File

@ -45,6 +45,8 @@ class LabPageFragment : LazyFragment(), CoroutineScope {
} }
override fun onPageCreated(): Boolean { override fun onPageCreated(): Boolean {
b.app = app
b.last10unseen.onClick { b.last10unseen.onClick {
launch(Dispatchers.Default) { launch(Dispatchers.Default) {
val events = app.db.eventDao().getAllNow(App.profileId) val events = app.db.eventDao().getAllNow(App.profileId)

View File

@ -7,6 +7,10 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
tools:ignore="HardcodedText"> tools:ignore="HardcodedText">
<data>
<variable name="app" type="pl.szczodrzynski.edziennik.App"/>
</data>
<ScrollView <ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@ -74,6 +78,12 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" /> style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" />
<com.google.android.material.checkbox.MaterialCheckBox
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="@={app.config.archiverEnabled}"
android:text="Archiver enabled" />
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
</layout> </layout>