merge version 0.5.1 #38
@ -64,37 +64,81 @@ class PreferencesController {
 | 
			
		||||
                apply()
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // save the course
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * save the course locally
 | 
			
		||||
         */
 | 
			
		||||
        fun saveCourse(context: Context, course: Course) {
 | 
			
		||||
            val sharedPref = context.getSharedPreferences(
 | 
			
		||||
                context.getString(R.string.preference_file_key),
 | 
			
		||||
                Context.MODE_PRIVATE
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
            with (sharedPref.edit()) {
 | 
			
		||||
                putString(context.getString(R.string.save_key_course), cCourse.courseName)
 | 
			
		||||
                putString(context.getString(R.string.save_key_courseTTLink), cCourse.courseLink)
 | 
			
		||||
                putString(context.getString(R.string.save_key_course), course.courseName)
 | 
			
		||||
                putString(context.getString(R.string.save_key_courseTTLink), course.courseLink)
 | 
			
		||||
                apply()
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // save the primary color
 | 
			
		||||
            cCourse = course
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * save the primary color
 | 
			
		||||
         */
 | 
			
		||||
        fun saveColorPrimary(context: Context, colorPrimary: Int) {
 | 
			
		||||
            val sharedPref = context.getSharedPreferences(
 | 
			
		||||
                context.getString(R.string.preference_file_key),
 | 
			
		||||
                Context.MODE_PRIVATE
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
            with (sharedPref.edit()) {
 | 
			
		||||
                putInt(context.getString(R.string.save_key_colorPrimary),
 | 
			
		||||
                    cColorPrimary
 | 
			
		||||
                    colorPrimary
 | 
			
		||||
                )
 | 
			
		||||
                apply()
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // save the accent color
 | 
			
		||||
            cColorPrimary = colorPrimary
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * save the accent color
 | 
			
		||||
         */
 | 
			
		||||
        fun saveColorAccent(context: Context, colorAccent: Int) {
 | 
			
		||||
            val sharedPref = context.getSharedPreferences(
 | 
			
		||||
                context.getString(R.string.preference_file_key),
 | 
			
		||||
                Context.MODE_PRIVATE
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
            with (sharedPref.edit()) {
 | 
			
		||||
                putInt(context.getString(R.string.save_key_colorAccent),
 | 
			
		||||
                    cColorAccent
 | 
			
		||||
                    colorAccent
 | 
			
		||||
                )
 | 
			
		||||
                apply()
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // save showBuffet
 | 
			
		||||
            cColorAccent = colorAccent
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * save showBuffet
 | 
			
		||||
         */
 | 
			
		||||
        fun saveShowBuffet(context: Context, showBuffet: Boolean) {
 | 
			
		||||
            val sharedPref = context.getSharedPreferences(
 | 
			
		||||
                context.getString(R.string.preference_file_key),
 | 
			
		||||
                Context.MODE_PRIVATE
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
            with (sharedPref.edit()) {
 | 
			
		||||
                putBoolean(context.getString(R.string.save_key_showBuffet),
 | 
			
		||||
                    cShowBuffet
 | 
			
		||||
                    showBuffet
 | 
			
		||||
                )
 | 
			
		||||
                apply()
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            cShowBuffet = showBuffet
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // the load function
 | 
			
		||||
 | 
			
		||||
@ -182,6 +182,7 @@ class SettingsFragment : Fragment() {
 | 
			
		||||
                            2 -> activityTheme(R.style.AppTheme_Black)
 | 
			
		||||
                            else -> activityTheme(R.style.AppTheme_Light)
 | 
			
		||||
                        }
 | 
			
		||||
                        apply()
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
@ -199,8 +200,7 @@ class SettingsFragment : Fragment() {
 | 
			
		||||
                        apply()
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    cColorPrimary = color
 | 
			
		||||
                    PreferencesController.save(context!!)
 | 
			
		||||
                    PreferencesController.saveColorPrimary(context!!, color)
 | 
			
		||||
                }
 | 
			
		||||
                .positiveButton(R.string.select)
 | 
			
		||||
                .show()
 | 
			
		||||
@ -217,17 +217,14 @@ class SettingsFragment : Fragment() {
 | 
			
		||||
                        apply()
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    cColorAccent = color
 | 
			
		||||
                    PreferencesController.save(context!!)
 | 
			
		||||
                    PreferencesController.saveColorAccent(context!!, color)
 | 
			
		||||
                }
 | 
			
		||||
                .positiveButton(R.string.select)
 | 
			
		||||
                .show()
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        switchBuffet.setOnClickListener {
 | 
			
		||||
            cShowBuffet = switchBuffet.isChecked
 | 
			
		||||
            PreferencesController.save(context!!)
 | 
			
		||||
            println(switchBuffet.isChecked)
 | 
			
		||||
            PreferencesController.saveShowBuffet(context!!, switchBuffet.isChecked)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
@ -249,8 +246,7 @@ class SettingsFragment : Fragment() {
 | 
			
		||||
                dialog.show()
 | 
			
		||||
 | 
			
		||||
                doAsync {
 | 
			
		||||
                    cCourse = coursesList[index] // set the course
 | 
			
		||||
                    PreferencesController.save(context)
 | 
			
		||||
                    PreferencesController.saveCourse(context, coursesList[index]) // save the course
 | 
			
		||||
 | 
			
		||||
                    // update current & next weeks timetable
 | 
			
		||||
                    TCoRAPIController.getTimetable(cCourse.courseName, 0, context).get() // blocking since we want the new data
 | 
			
		||||
 | 
			
		||||
@ -7,7 +7,7 @@ buildscript {
 | 
			
		||||
        jcenter()
 | 
			
		||||
    }
 | 
			
		||||
    dependencies {
 | 
			
		||||
        classpath 'com.android.tools.build:gradle:3.5.2'
 | 
			
		||||
        classpath 'com.android.tools.build:gradle:3.5.3'
 | 
			
		||||
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
 | 
			
		||||
 | 
			
		||||
        // NOTE: Do not place your application dependencies here; they belong
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user