added initial course selection
* some minor gui fixes
This commit is contained in:
parent
f3b7ff066d
commit
a6d14044c2
@ -70,7 +70,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
|||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO show a course selection
|
SettingsFragment().selectCourse(this)
|
||||||
} else {
|
} else {
|
||||||
Aesthetic.config {
|
Aesthetic.config {
|
||||||
colorPrimary(cColorPrimary)
|
colorPrimary(cColorPrimary)
|
||||||
|
@ -39,7 +39,7 @@ class PreferencesController {
|
|||||||
var mensaCacheTime: Long = 0
|
var mensaCacheTime: Long = 0
|
||||||
var timetableCacheTime: Long = 0
|
var timetableCacheTime: Long = 0
|
||||||
var cColorPrimary: Int = Color.BLACK
|
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 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
|
var cShowBuffet = true
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ class PreferencesController {
|
|||||||
), Color.BLACK)
|
), Color.BLACK)
|
||||||
cColorAccent = sharedPref.getInt(context.getString(
|
cColorAccent = sharedPref.getInt(context.getString(
|
||||||
R.string.save_key_colorAccent
|
R.string.save_key_colorAccent
|
||||||
), Color.parseColor("#FF1744"))
|
), Color.parseColor("#3F51B5"))
|
||||||
|
|
||||||
// load showBuffet
|
// load showBuffet
|
||||||
cShowBuffet = sharedPref.getBoolean(context.getString(
|
cShowBuffet = sharedPref.getBoolean(context.getString(
|
||||||
|
@ -139,7 +139,7 @@ class HomeFragment : Fragment() {
|
|||||||
val lessonTxtView = LessonTextView(context!!)
|
val lessonTxtView = LessonTextView(context!!)
|
||||||
lessonTxtView.setLesson(lesson)
|
lessonTxtView.setLesson(lesson)
|
||||||
|
|
||||||
// TODO why does this exist
|
// make sure no empty lesson is added
|
||||||
if (lessonTxtView.text.length > 3)
|
if (lessonTxtView.text.length > 3)
|
||||||
lessonCardView.getLinLayoutLesson().addView(lessonTxtView)
|
lessonCardView.getLinLayoutLesson().addView(lessonTxtView)
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
package org.mosad.seil0.projectlaogai.fragments
|
package org.mosad.seil0.projectlaogai.fragments
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@ -95,39 +96,8 @@ class SettingsFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
linLayoutCourse.setOnClickListener {
|
linLayoutCourse.setOnClickListener {
|
||||||
// open a new dialog
|
selectCourse(context!!)
|
||||||
val courseNameList = ArrayList<String>()
|
txtView_Course.text = cCourse.courseName // update txtView
|
||||||
|
|
||||||
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()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
linLayoutInfo.setOnClickListener {
|
linLayoutInfo.setOnClickListener {
|
||||||
@ -162,7 +132,6 @@ class SettingsFragment : Fragment() {
|
|||||||
MaterialDialog(context!!)
|
MaterialDialog(context!!)
|
||||||
.title(R.string.accent_color)
|
.title(R.string.accent_color)
|
||||||
.colorChooser(DataTypes().accentColors, allowCustomArgb = true, initialSelection = cColorAccent) { _, color ->
|
.colorChooser(DataTypes().accentColors, allowCustomArgb = true, initialSelection = cColorAccent) { _, color ->
|
||||||
//viewAccentColor.setBackgroundColor(color)
|
|
||||||
view_AccentColor.setBackgroundColor(color)
|
view_AccentColor.setBackgroundColor(color)
|
||||||
Aesthetic.config {
|
Aesthetic.config {
|
||||||
colorAccent(color)
|
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()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ class TimeTableFragment : Fragment() {
|
|||||||
val lessonTxtView = LessonTextView(context!!)
|
val lessonTxtView = LessonTextView(context!!)
|
||||||
lessonTxtView.setLesson(lesson)
|
lessonTxtView.setLesson(lesson)
|
||||||
|
|
||||||
// TODO why does this exist
|
// make sure no empty lesson is added
|
||||||
if (lessonTxtView.text.length > 3)
|
if (lessonTxtView.text.length > 3)
|
||||||
lessonCardView.getLinLayoutLesson().addView(lessonTxtView)
|
lessonCardView.getLinLayoutLesson().addView(lessonTxtView)
|
||||||
}
|
}
|
||||||
@ -136,6 +136,7 @@ class TimeTableFragment : Fragment() {
|
|||||||
val lessonTxtView = LessonTextView(context!!)
|
val lessonTxtView = LessonTextView(context!!)
|
||||||
lessonTxtView.setLesson(lesson)
|
lessonTxtView.setLesson(lesson)
|
||||||
|
|
||||||
|
// make sure no empty lesson is added
|
||||||
if (lessonTxtView.text.length > 3)
|
if (lessonTxtView.text.length > 3)
|
||||||
lessonCardView.getLinLayoutLesson().addView(lessonTxtView)
|
lessonCardView.getLinLayoutLesson().addView(lessonTxtView)
|
||||||
}
|
}
|
||||||
|
@ -119,12 +119,8 @@ data class Meals(val meals: ArrayList<Meal>)
|
|||||||
|
|
||||||
data class MensaWeek(val days: Array<Meals> = Array(7) { Meals(ArrayList()) })
|
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 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 TimetableDay( val timeslots: Array<ArrayList<Lesson>> = Array(6) { ArrayList<Lesson>()})
|
||||||
|
|
||||||
data class TimetableWeek(val days: Array<TimetableDay> = Array(6) { TimetableDay() })
|
data class TimetableWeek(val days: Array<TimetableDay> = Array(6) { TimetableDay() })
|
||||||
|
|
||||||
data class TimeTable(val days: Array<TimetableDay> = Array(6) { TimetableDay() }) // TODO remove
|
|
@ -29,4 +29,5 @@
|
|||||||
<string name="navigation_drawer_close">Navigationsleiste schließen</string>
|
<string name="navigation_drawer_close">Navigationsleiste schließen</string>
|
||||||
<string name="navigation_drawer_open">Navigationsleiste öffnen</string>
|
<string name="navigation_drawer_open">Navigationsleiste öffnen</string>
|
||||||
<string name="show_buffet">Buffet immer anzeigen</string>
|
<string name="show_buffet">Buffet immer anzeigen</string>
|
||||||
|
<string name="select_course">Wähle deinen Studiengang aus</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -56,5 +56,6 @@
|
|||||||
<string name="save_key_coursesCacheTime" translatable="false">org.mosad.seil0.projectlaogai.coursesCacheTime</string>
|
<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_mensaCacheTime" translatable="false">org.mosad.seil0.projectlaogai.mensaCacheTime</string>
|
||||||
<string name="save_key_timetableCacheTime" translatable="false">org.mosad.seil0.projectlaogai.timetableCacheTime</string>
|
<string name="save_key_timetableCacheTime" translatable="false">org.mosad.seil0.projectlaogai.timetableCacheTime</string>
|
||||||
|
<string name="select_course">Select your course</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user