added initial course selection

* some minor gui fixes
This commit is contained in:
Jannik 2019-03-17 18:38:31 +01:00
parent f3b7ff066d
commit a6d14044c2
8 changed files with 48 additions and 44 deletions

View File

@ -70,7 +70,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
apply()
}
// TODO show a course selection
SettingsFragment().selectCourse(this)
} else {
Aesthetic.config {
colorPrimary(cColorPrimary)

View File

@ -39,7 +39,7 @@ class PreferencesController {
var mensaCacheTime: Long = 0
var timetableCacheTime: Long = 0
var cColorPrimary: Int = Color.BLACK
var cColorAccent: Int = Color.BLACK
var cColorAccent: Int = Color.parseColor("#3F51B5")
var cCourse = Course("https://www.hs-offenburg.de/index.php?id=6627&class=class&iddV=DA64F6FE-9DDB-429E-A677-05D0D40CB636&week=0", "AI3")
var cShowBuffet = true
@ -121,7 +121,7 @@ class PreferencesController {
), Color.BLACK)
cColorAccent = sharedPref.getInt(context.getString(
R.string.save_key_colorAccent
), Color.parseColor("#FF1744"))
), Color.parseColor("#3F51B5"))
// load showBuffet
cShowBuffet = sharedPref.getBoolean(context.getString(

View File

@ -139,7 +139,7 @@ class HomeFragment : Fragment() {
val lessonTxtView = LessonTextView(context!!)
lessonTxtView.setLesson(lesson)
// TODO why does this exist
// make sure no empty lesson is added
if (lessonTxtView.text.length > 3)
lessonCardView.getLinLayoutLesson().addView(lessonTxtView)
}

View File

@ -22,6 +22,7 @@
package org.mosad.seil0.projectlaogai.fragments
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
@ -95,39 +96,8 @@ class SettingsFragment : Fragment() {
}
linLayoutCourse.setOnClickListener {
// open a new dialog
val courseNameList = ArrayList<String>()
coursesList.forEach { (_, courseName) ->
courseNameList.add(courseName)
}
MaterialDialog(context!!).listItems(items = courseNameList) { _, index, text ->
txtView_Course.text = text // update txtView
val dialog = MaterialDialog(context!!).cancelable(false)
.cancelOnTouchOutside(false)
.customView(R.layout.dialog_loading)
dialog.show()
doAsync {
cCourse = coursesList[index] // set the course
PreferencesController.save(context!!)
// update current & next weeks timetable
TCoRAPIController(context!!).getTimetable(cCourse.courseName, 0)
TCoRAPIController(context!!).getTimetable(cCourse.courseName, 1)
CacheController(context!!).readTimetable(cCourse.courseName, 0)
CacheController(context!!).readTimetable(cCourse.courseName, 1)
uiThread {
dialog.dismiss()
}
}
}
.show()
selectCourse(context!!)
txtView_Course.text = cCourse.courseName // update txtView
}
linLayoutInfo.setOnClickListener {
@ -162,7 +132,6 @@ class SettingsFragment : Fragment() {
MaterialDialog(context!!)
.title(R.string.accent_color)
.colorChooser(DataTypes().accentColors, allowCustomArgb = true, initialSelection = cColorAccent) { _, color ->
//viewAccentColor.setBackgroundColor(color)
view_AccentColor.setBackgroundColor(color)
Aesthetic.config {
colorAccent(color)
@ -184,4 +153,40 @@ class SettingsFragment : Fragment() {
}
fun selectCourse(context: Context) {
val courseNameList = ArrayList<String>()
coursesList.forEach { (_, courseName) ->
courseNameList.add(courseName)
}
// open a new dialog
MaterialDialog(context)
.title(R.string.select_course)
.listItems(items = courseNameList) { _, index, text ->
val dialog = MaterialDialog(context).cancelable(false)
.cancelOnTouchOutside(false)
.customView(R.layout.dialog_loading)
dialog.show()
doAsync {
cCourse = coursesList[index] // set the course
PreferencesController.save(context)
// update current & next weeks timetable
TCoRAPIController(context).getTimetable(cCourse.courseName, 0)
TCoRAPIController(context).getTimetable(cCourse.courseName, 1)
CacheController(context).readTimetable(cCourse.courseName, 0)
CacheController(context).readTimetable(cCourse.courseName, 1)
uiThread {
dialog.dismiss()
}
}
}
.show()
}
}

View File

@ -91,7 +91,7 @@ class TimeTableFragment : Fragment() {
val lessonTxtView = LessonTextView(context!!)
lessonTxtView.setLesson(lesson)
// TODO why does this exist
// make sure no empty lesson is added
if (lessonTxtView.text.length > 3)
lessonCardView.getLinLayoutLesson().addView(lessonTxtView)
}
@ -136,6 +136,7 @@ class TimeTableFragment : Fragment() {
val lessonTxtView = LessonTextView(context!!)
lessonTxtView.setLesson(lesson)
// make sure no empty lesson is added
if (lessonTxtView.text.length > 3)
lessonCardView.getLinLayoutLesson().addView(lessonTxtView)
}

View File

@ -119,12 +119,8 @@ data class Meals(val meals: ArrayList<Meal>)
data class MensaWeek(val days: Array<Meals> = Array(7) { Meals(ArrayList()) })
data class MealWeek(val day: Array<ArrayList<Meal>> = Array(7) { ArrayList<Meal>() }) // TODO remove
data class Lesson(val lessonSubject: String, val lessonTeacher: String, val lessonRoom:String, val lessonRemark: String)
data class TimetableDay( val timeslots: Array<ArrayList<Lesson>> = Array(6) { ArrayList<Lesson>()})
data class TimetableWeek(val days: Array<TimetableDay> = Array(6) { TimetableDay() })
data class TimeTable(val days: Array<TimetableDay> = Array(6) { TimetableDay() }) // TODO remove
data class TimetableWeek(val days: Array<TimetableDay> = Array(6) { TimetableDay() })

View File

@ -29,4 +29,5 @@
<string name="navigation_drawer_close">Navigationsleiste schließen</string>
<string name="navigation_drawer_open">Navigationsleiste öffnen</string>
<string name="show_buffet">Buffet immer anzeigen</string>
<string name="select_course">Wähle deinen Studiengang aus</string>
</resources>

View File

@ -56,5 +56,6 @@
<string name="save_key_coursesCacheTime" translatable="false">org.mosad.seil0.projectlaogai.coursesCacheTime</string>
<string name="save_key_mensaCacheTime" translatable="false">org.mosad.seil0.projectlaogai.mensaCacheTime</string>
<string name="save_key_timetableCacheTime" translatable="false">org.mosad.seil0.projectlaogai.timetableCacheTime</string>
<string name="select_course">Select your course</string>
</resources>