/* * Copyright (c) Kuba SzczodrzyƄski 2019-11-27. */ package pl.szczodrzynski.edziennik.config import pl.szczodrzynski.edziennik.config.utils.get import pl.szczodrzynski.edziennik.config.utils.getFloat import pl.szczodrzynski.edziennik.config.utils.set import pl.szczodrzynski.edziennik.utils.managers.GradesManager.Companion.COLOR_MODE_WEIGHTED import pl.szczodrzynski.edziennik.utils.managers.GradesManager.Companion.YEAR_ALL_GRADES class ProfileConfigGrades(private val config: ProfileConfig) { private var mColorMode: Int? = null var colorMode: Int get() { mColorMode = mColorMode ?: config.values.get("gradesColorMode", COLOR_MODE_WEIGHTED); return mColorMode ?: COLOR_MODE_WEIGHTED } set(value) { config.set("gradesColorMode", value); mColorMode = value } private var mYearAverageMode: Int? = null var yearAverageMode: Int get() { mYearAverageMode = mYearAverageMode ?: config.values.get("yearAverageMode", YEAR_ALL_GRADES); return mYearAverageMode ?: YEAR_ALL_GRADES } set(value) { config.set("yearAverageMode", value); mYearAverageMode = value } private var mHideImproved: Boolean? = null var hideImproved: Boolean get() { mHideImproved = mHideImproved ?: config.values.get("hideImproved", false); return mHideImproved ?: false } set(value) { config.set("hideImproved", value); mHideImproved = value } private var mAverageWithoutWeight: Boolean? = null var averageWithoutWeight: Boolean get() { mAverageWithoutWeight = mAverageWithoutWeight ?: config.values.get("averageWithoutWeight", true); return mAverageWithoutWeight ?: true } set(value) { config.set("averageWithoutWeight", value); mAverageWithoutWeight = value } private var mPlusValue: Float? = null var plusValue: Float? get() { mPlusValue = mPlusValue ?: config.values.getFloat("plusValue"); return mPlusValue } set(value) { config.set("plusValue", value); mPlusValue = value } private var mMinusValue: Float? = null var minusValue: Float? get() { mMinusValue = mMinusValue ?: config.values.getFloat("minusValue"); return mMinusValue } set(value) { config.set("minusValue", value); mMinusValue = value } private var mDontCountEnabled: Boolean? = null var dontCountEnabled: Boolean get() { mDontCountEnabled = mDontCountEnabled ?: config.values.get("dontCountEnabled", false); return mDontCountEnabled ?: false } set(value) { config.set("dontCountEnabled", value); mDontCountEnabled = value } private var mDontCountGrades: List? = null var dontCountGrades: List get() { mDontCountGrades = mDontCountGrades ?: config.values.get("dontCountGrades", listOf()); return mDontCountGrades ?: listOf() } set(value) { config.set("dontCountGrades", value); mDontCountGrades = value } }