use KAE synthetic binding for layouts in SettingsFragment
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
* closes #7
This commit is contained in:
parent
a3102bc3f2
commit
390728bfb7
|
@ -48,8 +48,6 @@ import org.mosad.seil0.projectlaogai.controller.NFCMensaCard
|
||||||
import org.mosad.seil0.projectlaogai.controller.cache.CacheController
|
import org.mosad.seil0.projectlaogai.controller.cache.CacheController
|
||||||
import org.mosad.seil0.projectlaogai.controller.preferences.EncryptedPreferences
|
import org.mosad.seil0.projectlaogai.controller.preferences.EncryptedPreferences
|
||||||
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences
|
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences
|
||||||
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences.cColorAccent
|
|
||||||
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences.cColorPrimary
|
|
||||||
import org.mosad.seil0.projectlaogai.fragments.*
|
import org.mosad.seil0.projectlaogai.fragments.*
|
||||||
import org.mosad.seil0.projectlaogai.util.NotificationUtils
|
import org.mosad.seil0.projectlaogai.util.NotificationUtils
|
||||||
import kotlin.system.measureTimeMillis
|
import kotlin.system.measureTimeMillis
|
||||||
|
@ -200,9 +198,9 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
||||||
}
|
}
|
||||||
|
|
||||||
Aesthetic.config {
|
Aesthetic.config {
|
||||||
colorPrimary(cColorPrimary)
|
colorPrimary(Preferences.colorPrimary)
|
||||||
colorPrimaryDark(cColorPrimary)
|
colorPrimaryDark(Preferences.colorPrimary)
|
||||||
colorAccent(cColorAccent)
|
colorAccent(Preferences.colorAccent)
|
||||||
navigationViewMode(NavigationViewMode.SELECTED_ACCENT)
|
navigationViewMode(NavigationViewMode.SELECTED_ACCENT)
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ import kotlinx.coroutines.*
|
||||||
import org.mosad.seil0.projectlaogai.controller.QISPOSParser
|
import org.mosad.seil0.projectlaogai.controller.QISPOSParser
|
||||||
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences
|
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences
|
||||||
import org.mosad.seil0.projectlaogai.controller.TCoRAPIController
|
import org.mosad.seil0.projectlaogai.controller.TCoRAPIController
|
||||||
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences.cCourse
|
|
||||||
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences.coursesCacheTime
|
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences.coursesCacheTime
|
||||||
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences.gradesCacheTime
|
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences.gradesCacheTime
|
||||||
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences.mensaCacheTime
|
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences.mensaCacheTime
|
||||||
|
@ -78,8 +77,8 @@ class CacheController(cont: Context) {
|
||||||
|
|
||||||
GlobalScope.launch(Dispatchers.Default) {
|
GlobalScope.launch(Dispatchers.Default) {
|
||||||
val threads = listOf(
|
val threads = listOf(
|
||||||
updateTimetable(cCourse.courseName, 0, context),
|
updateTimetable(Preferences.course.courseName, 0, context),
|
||||||
updateTimetable(cCourse.courseName, 1, context)
|
updateTimetable(Preferences.course.courseName, 1, context)
|
||||||
)
|
)
|
||||||
threads.joinAll()
|
threads.joinAll()
|
||||||
}
|
}
|
||||||
|
@ -87,7 +86,7 @@ class CacheController(cont: Context) {
|
||||||
|
|
||||||
updateCourseList(context)
|
updateCourseList(context)
|
||||||
|
|
||||||
readStartCache(cCourse.courseName) // initially read values from cache
|
readStartCache(Preferences.course.courseName) // initially read values from cache
|
||||||
|
|
||||||
// check if an update is necessary, not blocking
|
// check if an update is necessary, not blocking
|
||||||
if (currentTime - coursesCacheTime > 86400)
|
if (currentTime - coursesCacheTime > 86400)
|
||||||
|
|
|
@ -25,7 +25,7 @@ package org.mosad.seil0.projectlaogai.controller.cache
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import org.mosad.seil0.projectlaogai.controller.TCoRAPIController
|
import org.mosad.seil0.projectlaogai.controller.TCoRAPIController
|
||||||
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences.cCourse
|
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences
|
||||||
import org.mosad.seil0.projectlaogai.util.Lesson
|
import org.mosad.seil0.projectlaogai.util.Lesson
|
||||||
import org.mosad.seil0.projectlaogai.util.TimetableWeek
|
import org.mosad.seil0.projectlaogai.util.TimetableWeek
|
||||||
|
|
||||||
|
@ -49,8 +49,8 @@ object TimetableController {
|
||||||
*/
|
*/
|
||||||
fun update(context: Context): List<Job> {
|
fun update(context: Context): List<Job> {
|
||||||
return listOf(
|
return listOf(
|
||||||
CacheController.updateTimetable(cCourse.courseName, 0, context),
|
CacheController.updateTimetable(Preferences.course.courseName, 0, context),
|
||||||
CacheController.updateTimetable(cCourse.courseName, 1, context),
|
CacheController.updateTimetable(Preferences.course.courseName, 1, context),
|
||||||
CacheController.updateAdditionalLessons(context)
|
CacheController.updateAdditionalLessons(context)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,14 +37,14 @@ object Preferences {
|
||||||
var mensaCacheTime: Long = 0
|
var mensaCacheTime: Long = 0
|
||||||
var timetableCacheTime: Long = 0
|
var timetableCacheTime: Long = 0
|
||||||
var gradesCacheTime: Long = 0
|
var gradesCacheTime: Long = 0
|
||||||
var cColorPrimary: Int = Color.parseColor("#009688")
|
var colorPrimary: Int = Color.parseColor("#009688")
|
||||||
var cColorAccent: Int = Color.parseColor("#0096ff")
|
var colorAccent: Int = Color.parseColor("#0096ff")
|
||||||
var gradesSyncInterval = 0
|
var gradesSyncInterval = 0
|
||||||
var cCourse = Course(
|
var course = Course(
|
||||||
"https://www.hs-offenburg.de/index.php?id=6627&class=class&iddV=DA64F6FE-9DDB-429E-A677-05D0D40CB636&week=0",
|
"https://www.hs-offenburg.de/index.php?id=6627&class=class&iddV=DA64F6FE-9DDB-429E-A677-05D0D40CB636&week=0",
|
||||||
"AI3"
|
"AI3"
|
||||||
)
|
)
|
||||||
var cShowBuffet = true
|
var showBuffet = true
|
||||||
var oGiants = false
|
var oGiants = false
|
||||||
|
|
||||||
// TODO move!
|
// TODO move!
|
||||||
|
@ -92,7 +92,7 @@ object Preferences {
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
cCourse = course
|
this.course = course
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,7 +111,7 @@ object Preferences {
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
cColorPrimary = colorPrimary
|
this.colorPrimary = colorPrimary
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,7 +130,7 @@ object Preferences {
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
cColorAccent = colorAccent
|
this.colorAccent = colorAccent
|
||||||
}
|
}
|
||||||
|
|
||||||
fun saveGradesSync(context: Context, interval: Int) {
|
fun saveGradesSync(context: Context, interval: Int) {
|
||||||
|
@ -165,7 +165,7 @@ object Preferences {
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
cShowBuffet = showBuffet
|
this.showBuffet = showBuffet
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -192,19 +192,17 @@ object Preferences {
|
||||||
)
|
)
|
||||||
|
|
||||||
// load saved course
|
// load saved course
|
||||||
cCourse = Course(
|
course = Course(
|
||||||
sharedPref.getString(context.getString(R.string.save_key_courseTTLink),
|
sharedPref.getString(context.getString(R.string.save_key_courseTTLink),"https://www.hs-offenburg.de/index.php?id=6627&class=class&iddV=DA64F6FE-9DDB-429E-A677-05D0D40CB636&week=0")!!,
|
||||||
"https://www.hs-offenburg.de/index.php?id=6627&class=class&iddV=DA64F6FE-9DDB-429E-A677-05D0D40CB636&week=0"
|
|
||||||
)!!,
|
|
||||||
sharedPref.getString(context.getString(R.string.save_key_course), "AI3")!!
|
sharedPref.getString(context.getString(R.string.save_key_course), "AI3")!!
|
||||||
)
|
)
|
||||||
|
|
||||||
// load saved colors
|
// load saved colors
|
||||||
cColorPrimary = sharedPref.getInt(
|
colorPrimary = sharedPref.getInt(
|
||||||
context.getString(R.string.save_key_colorPrimary), cColorPrimary
|
context.getString(R.string.save_key_colorPrimary), colorPrimary
|
||||||
)
|
)
|
||||||
cColorAccent = sharedPref.getInt(
|
colorAccent = sharedPref.getInt(
|
||||||
context.getString(R.string.save_key_colorAccent), cColorAccent
|
context.getString(R.string.save_key_colorAccent), colorAccent
|
||||||
)
|
)
|
||||||
|
|
||||||
// load grades sync interval
|
// load grades sync interval
|
||||||
|
@ -213,7 +211,7 @@ object Preferences {
|
||||||
)
|
)
|
||||||
|
|
||||||
// load showBuffet
|
// load showBuffet
|
||||||
cShowBuffet = sharedPref.getBoolean(
|
showBuffet = sharedPref.getBoolean(
|
||||||
context.getString(R.string.save_key_showBuffet), true
|
context.getString(R.string.save_key_showBuffet), true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,6 @@ import org.mosad.seil0.projectlaogai.R
|
||||||
import org.mosad.seil0.projectlaogai.controller.cache.CacheController
|
import org.mosad.seil0.projectlaogai.controller.cache.CacheController
|
||||||
import org.mosad.seil0.projectlaogai.controller.cache.CacheController.Companion.mensaMenu
|
import org.mosad.seil0.projectlaogai.controller.cache.CacheController.Companion.mensaMenu
|
||||||
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences
|
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences
|
||||||
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences.cShowBuffet
|
|
||||||
import org.mosad.seil0.projectlaogai.uicomponents.DayCardView
|
import org.mosad.seil0.projectlaogai.uicomponents.DayCardView
|
||||||
import org.mosad.seil0.projectlaogai.uicomponents.MealLinearLayout
|
import org.mosad.seil0.projectlaogai.uicomponents.MealLinearLayout
|
||||||
import org.mosad.seil0.projectlaogai.uicomponents.TextViewInfo
|
import org.mosad.seil0.projectlaogai.uicomponents.TextViewInfo
|
||||||
|
@ -97,7 +96,7 @@ class MensaFragment : Fragment() {
|
||||||
val mealLayout = MealLinearLayout(context)
|
val mealLayout = MealLinearLayout(context)
|
||||||
mealLayout.setMeal(meal)
|
mealLayout.setMeal(meal)
|
||||||
|
|
||||||
if(meal.heading != "Buffet" || cShowBuffet) {
|
if(meal.heading != "Buffet" || Preferences.showBuffet) {
|
||||||
dayCardView.getLinLayoutDay().addView(mealLayout)
|
dayCardView.getLinLayoutDay().addView(mealLayout)
|
||||||
helpMeal = mealLayout
|
helpMeal = mealLayout
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,7 @@ import android.util.TypedValue
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.LinearLayout
|
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.appcompat.widget.SwitchCompat
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import com.afollestad.aesthetic.Aesthetic
|
import com.afollestad.aesthetic.Aesthetic
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
|
@ -53,10 +51,6 @@ import org.mosad.seil0.projectlaogai.controller.cache.CacheController.Companion.
|
||||||
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences
|
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences
|
||||||
import org.mosad.seil0.projectlaogai.controller.cache.TimetableController
|
import org.mosad.seil0.projectlaogai.controller.cache.TimetableController
|
||||||
import org.mosad.seil0.projectlaogai.controller.preferences.EncryptedPreferences
|
import org.mosad.seil0.projectlaogai.controller.preferences.EncryptedPreferences
|
||||||
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences.cColorAccent
|
|
||||||
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences.cColorPrimary
|
|
||||||
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences.cCourse
|
|
||||||
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences.cShowBuffet
|
|
||||||
import org.mosad.seil0.projectlaogai.uicomponents.dialogs.LoginDialog
|
import org.mosad.seil0.projectlaogai.uicomponents.dialogs.LoginDialog
|
||||||
import org.mosad.seil0.projectlaogai.util.DataTypes
|
import org.mosad.seil0.projectlaogai.util.DataTypes
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
@ -67,16 +61,6 @@ import java.util.*
|
||||||
*/
|
*/
|
||||||
class SettingsFragment : Fragment() {
|
class SettingsFragment : Fragment() {
|
||||||
|
|
||||||
private lateinit var linLayoutUser: LinearLayout
|
|
||||||
private lateinit var linLayoutCourse: LinearLayout
|
|
||||||
private lateinit var linLayoutManageLessons: LinearLayout
|
|
||||||
private lateinit var linLayoutAbout: LinearLayout
|
|
||||||
private lateinit var linLayoutLicence: LinearLayout
|
|
||||||
private lateinit var linLayoutTheme: LinearLayout
|
|
||||||
private lateinit var linLayoutPrimaryColor: LinearLayout
|
|
||||||
private lateinit var linLayoutAccentColor: LinearLayout
|
|
||||||
private lateinit var linLayoutGradesSync: LinearLayout
|
|
||||||
private lateinit var switchBuffet: SwitchCompat
|
|
||||||
private lateinit var txtViewCourse: TextView
|
private lateinit var txtViewCourse: TextView
|
||||||
|
|
||||||
private var selectedTheme = DataTypes.Theme.Light
|
private var selectedTheme = DataTypes.Theme.Light
|
||||||
|
@ -91,17 +75,6 @@ class SettingsFragment : Fragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
linLayoutUser = view.findViewById(R.id.linLayout_User)
|
|
||||||
linLayoutCourse = view.findViewById(R.id.linLayout_Course)
|
|
||||||
linLayoutManageLessons = view.findViewById(R.id.linLayout_ManageLessons)
|
|
||||||
linLayoutAbout = view.findViewById(R.id.linLayout_About)
|
|
||||||
linLayoutLicence = view.findViewById(R.id.linLayout_Licence)
|
|
||||||
linLayoutTheme = view.findViewById(R.id.linLayout_Theme)
|
|
||||||
linLayoutPrimaryColor = view.findViewById(R.id.linLayout_PrimaryColor)
|
|
||||||
linLayoutAccentColor = view.findViewById(R.id.linLayout_AccentColor)
|
|
||||||
linLayoutGradesSync = view.findViewById(R.id.linLayout_GradesSync)
|
|
||||||
switchBuffet = view.findViewById(R.id.switch_buffet)
|
|
||||||
|
|
||||||
// if we call txtView_Course via KAE view binding it'll result in a NPE in the onDismissed call
|
// if we call txtView_Course via KAE view binding it'll result in a NPE in the onDismissed call
|
||||||
txtViewCourse = view.findViewById(R.id.txtView_Course)
|
txtViewCourse = view.findViewById(R.id.txtView_Course)
|
||||||
|
|
||||||
|
@ -109,14 +82,14 @@ class SettingsFragment : Fragment() {
|
||||||
|
|
||||||
|
|
||||||
txtView_User.text = EncryptedPreferences.email.ifEmpty { resources.getString(R.string.sample_user) }
|
txtView_User.text = EncryptedPreferences.email.ifEmpty { resources.getString(R.string.sample_user) }
|
||||||
txtView_Course.text = cCourse.courseName
|
txtView_Course.text = Preferences.course.courseName
|
||||||
txtView_AboutDesc.text = resources.getString(R.string.about_version, BuildConfig.VERSION_NAME, getString(R.string.build_time))
|
txtView_AboutDesc.text = resources.getString(R.string.about_version, BuildConfig.VERSION_NAME, getString(R.string.build_time))
|
||||||
txtView_GradesSyncDesc.text = if (Preferences.gradesSyncInterval == 0) {
|
txtView_GradesSyncDesc.text = if (Preferences.gradesSyncInterval == 0) {
|
||||||
resources.getString(R.string.grades_sync_desc_never)
|
resources.getString(R.string.grades_sync_desc_never)
|
||||||
} else {
|
} else {
|
||||||
resources.getString(R.string.grades_sync_desc, Preferences.gradesSyncInterval)
|
resources.getString(R.string.grades_sync_desc, Preferences.gradesSyncInterval)
|
||||||
}
|
}
|
||||||
switch_buffet.isChecked = cShowBuffet // init switch
|
switch_buffet.isChecked = Preferences.showBuffet // init switch
|
||||||
|
|
||||||
val outValue = TypedValue()
|
val outValue = TypedValue()
|
||||||
activity!!.theme.resolveAttribute(R.attr.themeName, outValue, true)
|
activity!!.theme.resolveAttribute(R.attr.themeName, outValue, true)
|
||||||
|
@ -144,7 +117,7 @@ class SettingsFragment : Fragment() {
|
||||||
* initialize some actions for SettingsFragment elements
|
* initialize some actions for SettingsFragment elements
|
||||||
*/
|
*/
|
||||||
private fun initActions() {
|
private fun initActions() {
|
||||||
linLayoutUser.setOnClickListener {
|
linLayout_User.setOnClickListener {
|
||||||
// open a new dialog
|
// open a new dialog
|
||||||
LoginDialog(context!!)
|
LoginDialog(context!!)
|
||||||
.positiveButton {
|
.positiveButton {
|
||||||
|
@ -156,20 +129,20 @@ class SettingsFragment : Fragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
linLayoutUser.setOnLongClickListener {
|
linLayout_User.setOnLongClickListener {
|
||||||
Preferences.oGiants = true // enable easter egg
|
Preferences.oGiants = true // enable easter egg
|
||||||
return@setOnLongClickListener true
|
return@setOnLongClickListener true
|
||||||
}
|
}
|
||||||
|
|
||||||
linLayoutCourse.setOnClickListener {
|
linLayout_Course.setOnClickListener {
|
||||||
selectCourse(context!!).show {
|
selectCourse(context!!).show {
|
||||||
onDismiss {
|
onDismiss {
|
||||||
txtViewCourse.text = cCourse.courseName // update txtView after the dialog is dismissed
|
txtViewCourse.text = Preferences.course.courseName // update txtView after the dialog is dismissed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
linLayoutManageLessons.setOnClickListener {
|
linLayout_ManageLessons.setOnClickListener {
|
||||||
val lessons = ArrayList<String>()
|
val lessons = ArrayList<String>()
|
||||||
TimetableController.subjectMap.forEach { pair ->
|
TimetableController.subjectMap.forEach { pair ->
|
||||||
pair.value.forEach {
|
pair.value.forEach {
|
||||||
|
@ -181,8 +154,8 @@ class SettingsFragment : Fragment() {
|
||||||
title(R.string.manage_lessons)
|
title(R.string.manage_lessons)
|
||||||
positiveButton(R.string.delete)
|
positiveButton(R.string.delete)
|
||||||
negativeButton(R.string.cancel)
|
negativeButton(R.string.cancel)
|
||||||
getActionButton(WhichButton.POSITIVE).updateTextColor(cColorAccent)
|
getActionButton(WhichButton.POSITIVE).updateTextColor(Preferences.colorAccent)
|
||||||
getActionButton(WhichButton.NEGATIVE).updateTextColor(cColorAccent)
|
getActionButton(WhichButton.NEGATIVE).updateTextColor(Preferences.colorAccent)
|
||||||
|
|
||||||
listItemsMultiChoice(items = lessons) { _, _, items ->
|
listItemsMultiChoice(items = lessons) { _, _, items ->
|
||||||
items.forEach {
|
items.forEach {
|
||||||
|
@ -193,7 +166,7 @@ class SettingsFragment : Fragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
linLayoutAbout.setOnClickListener {
|
linLayout_About.setOnClickListener {
|
||||||
// open a new info dialog
|
// open a new info dialog
|
||||||
MaterialDialog(context!!)
|
MaterialDialog(context!!)
|
||||||
.title(R.string.about_dialog_heading)
|
.title(R.string.about_dialog_heading)
|
||||||
|
@ -201,7 +174,7 @@ class SettingsFragment : Fragment() {
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
linLayoutLicence.setOnClickListener {
|
linLayout_Licence.setOnClickListener {
|
||||||
// do the theme magic, as the lib's theme support is broken
|
// do the theme magic, as the lib's theme support is broken
|
||||||
val outValue = TypedValue()
|
val outValue = TypedValue()
|
||||||
context!!.theme.resolveAttribute(R.attr.themeName, outValue, true)
|
context!!.theme.resolveAttribute(R.attr.themeName, outValue, true)
|
||||||
|
@ -227,7 +200,7 @@ class SettingsFragment : Fragment() {
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
linLayoutTheme.setOnClickListener {
|
linLayout_Theme.setOnClickListener {
|
||||||
val themes = listOf(
|
val themes = listOf(
|
||||||
resources.getString(R.string.themeLight),
|
resources.getString(R.string.themeLight),
|
||||||
resources.getString(R.string.themeDark),
|
resources.getString(R.string.themeDark),
|
||||||
|
@ -250,10 +223,10 @@ class SettingsFragment : Fragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
linLayoutPrimaryColor.setOnClickListener {
|
linLayout_PrimaryColor.setOnClickListener {
|
||||||
// open a new color chooser dialog
|
// open a new color chooser dialog
|
||||||
MaterialDialog(context!!)
|
MaterialDialog(context!!)
|
||||||
.colorChooser(DataTypes().primaryColors, allowCustomArgb = true, initialSelection = cColorPrimary) { _, color ->
|
.colorChooser(DataTypes().primaryColors, allowCustomArgb = true, initialSelection = Preferences.colorPrimary) { _, color ->
|
||||||
view_PrimaryColor.setBackgroundColor(color)
|
view_PrimaryColor.setBackgroundColor(color)
|
||||||
Aesthetic.config {
|
Aesthetic.config {
|
||||||
colorPrimary(color)
|
colorPrimary(color)
|
||||||
|
@ -265,15 +238,15 @@ class SettingsFragment : Fragment() {
|
||||||
.show {
|
.show {
|
||||||
title(R.string.primary_color)
|
title(R.string.primary_color)
|
||||||
positiveButton(R.string.select)
|
positiveButton(R.string.select)
|
||||||
getActionButton(WhichButton.POSITIVE).updateTextColor(cColorAccent)
|
getActionButton(WhichButton.POSITIVE).updateTextColor(Preferences.colorAccent)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
linLayoutAccentColor.setOnClickListener {
|
linLayout_AccentColor.setOnClickListener {
|
||||||
// open a new color chooser dialog
|
// open a new color chooser dialog
|
||||||
MaterialDialog(context!!)
|
MaterialDialog(context!!)
|
||||||
.colorChooser(DataTypes().accentColors, allowCustomArgb = true, initialSelection = cColorAccent) { _, color ->
|
.colorChooser(DataTypes().accentColors, allowCustomArgb = true, initialSelection = Preferences.colorAccent) { _, color ->
|
||||||
view_AccentColor.setBackgroundColor(color)
|
view_AccentColor.setBackgroundColor(color)
|
||||||
Aesthetic.config {
|
Aesthetic.config {
|
||||||
colorAccent(color)
|
colorAccent(color)
|
||||||
|
@ -285,11 +258,11 @@ class SettingsFragment : Fragment() {
|
||||||
.show{
|
.show{
|
||||||
title(R.string.accent_color)
|
title(R.string.accent_color)
|
||||||
positiveButton(R.string.select)
|
positiveButton(R.string.select)
|
||||||
getActionButton(WhichButton.POSITIVE).updateTextColor(cColorAccent)
|
getActionButton(WhichButton.POSITIVE).updateTextColor(Preferences.colorAccent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
linLayoutGradesSync.setOnClickListener {
|
linLayout_GradesSync.setOnClickListener {
|
||||||
val items = resources.getStringArray(R.array.syncInterval).toList()
|
val items = resources.getStringArray(R.array.syncInterval).toList()
|
||||||
val initial = when (Preferences.gradesSyncInterval) {
|
val initial = when (Preferences.gradesSyncInterval) {
|
||||||
1 -> 1
|
1 -> 1
|
||||||
|
@ -321,8 +294,8 @@ class SettingsFragment : Fragment() {
|
||||||
}.show()
|
}.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
switchBuffet.setOnClickListener {
|
switch_buffet.setOnClickListener {
|
||||||
Preferences.saveShowBuffet(context!!, switchBuffet.isChecked)
|
Preferences.saveShowBuffet(context!!, switch_buffet.isChecked)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -348,8 +321,8 @@ class SettingsFragment : Fragment() {
|
||||||
|
|
||||||
// update current & next weeks timetable
|
// update current & next weeks timetable
|
||||||
val threads = listOf(
|
val threads = listOf(
|
||||||
CacheController.updateTimetable(cCourse.courseName, 0, context),
|
CacheController.updateTimetable(Preferences.course.courseName, 0, context),
|
||||||
CacheController.updateTimetable(cCourse.courseName, 1, context)
|
CacheController.updateTimetable(Preferences.course.courseName, 1, context)
|
||||||
)
|
)
|
||||||
threads.joinAll() // blocking since we want the new data
|
threads.joinAll() // blocking since we want the new data
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,8 @@ class AddSubjectDialog(val context: Context) {
|
||||||
spinnerSubjects = dialog.getCustomView().findViewById(R.id.spinner_Lessons)
|
spinnerSubjects = dialog.getCustomView().findViewById(R.id.spinner_Lessons)
|
||||||
|
|
||||||
// fix not working accent color
|
// fix not working accent color
|
||||||
dialog.getActionButton(WhichButton.POSITIVE).updateTextColor(Preferences.cColorAccent)
|
dialog.getActionButton(WhichButton.POSITIVE).updateTextColor(Preferences.colorAccent)
|
||||||
dialog.getActionButton(WhichButton.NEGATIVE).updateTextColor(Preferences.cColorAccent)
|
dialog.getActionButton(WhichButton.NEGATIVE).updateTextColor(Preferences.colorAccent)
|
||||||
|
|
||||||
initSpinners()
|
initSpinners()
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,8 +56,8 @@ class LoginDialog(val context: Context) {
|
||||||
editTextPassword = dialog.getCustomView().findViewById(R.id.editText_password)
|
editTextPassword = dialog.getCustomView().findViewById(R.id.editText_password)
|
||||||
|
|
||||||
// fix not working accent color
|
// fix not working accent color
|
||||||
dialog.getActionButton(WhichButton.POSITIVE).updateTextColor(Preferences.cColorAccent)
|
dialog.getActionButton(WhichButton.POSITIVE).updateTextColor(Preferences.colorAccent)
|
||||||
dialog.getActionButton(WhichButton.NEGATIVE).updateTextColor(Preferences.cColorAccent)
|
dialog.getActionButton(WhichButton.NEGATIVE).updateTextColor(Preferences.colorAccent)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun positiveButton(func: LoginDialog.() -> Unit): LoginDialog = apply {
|
fun positiveButton(func: LoginDialog.() -> Unit): LoginDialog = apply {
|
||||||
|
|
Loading…
Reference in New Issue