Browse Source

added initial course selection

* some minor gui fixes
pull/20/head
Jannik 3 years ago
parent
commit
a6d14044c2
  1. 2
      app/src/main/java/org/mosad/seil0/projectlaogai/MainActivity.kt
  2. 4
      app/src/main/java/org/mosad/seil0/projectlaogai/controller/PreferencesController.kt
  3. 2
      app/src/main/java/org/mosad/seil0/projectlaogai/fragments/HomeFragment.kt
  4. 73
      app/src/main/java/org/mosad/seil0/projectlaogai/fragments/SettingsFragment.kt
  5. 3
      app/src/main/java/org/mosad/seil0/projectlaogai/fragments/TimeTableFragment.kt
  6. 6
      app/src/main/java/org/mosad/seil0/projectlaogai/hsoparser/DataTypes.kt
  7. 1
      app/src/main/res/values-de-rDE/strings.xml
  8. 1
      app/src/main/res/values/strings.xml

2
app/src/main/java/org/mosad/seil0/projectlaogai/MainActivity.kt

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

4
app/src/main/java/org/mosad/seil0/projectlaogai/controller/PreferencesController.kt

@ -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(

2
app/src/main/java/org/mosad/seil0/projectlaogai/fragments/HomeFragment.kt

@ -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)
}

73
app/src/main/java/org/mosad/seil0/projectlaogai/fragments/SettingsFragment.kt

@ -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()
}
}

3
app/src/main/java/org/mosad/seil0/projectlaogai/fragments/TimeTableFragment.kt

@ -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)
}

6
app/src/main/java/org/mosad/seil0/projectlaogai/hsoparser/DataTypes.kt

@ -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() })

1
app/src/main/res/values-de-rDE/strings.xml

@ -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>

1
app/src/main/res/values/strings.xml

@ -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>

Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close