parent
a088323fa0
commit
54a5e2da8e
|
@ -11,7 +11,7 @@ android {
|
|||
minSdkVersion 21
|
||||
targetSdkVersion 28
|
||||
versionCode 5
|
||||
versionName "0.1.4"
|
||||
versionName "0.2.0"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildTypes {
|
||||
|
|
|
@ -50,6 +50,8 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
|||
private var courseTTLinkList = ArrayList<CourseTTLink>()
|
||||
private var timeTableWeek = arrayOf<Array<Lesson>>()
|
||||
|
||||
private lateinit var course: CourseTTLink
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
@ -143,13 +145,22 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
|||
}
|
||||
|
||||
/**
|
||||
* update the gui with the data of the new selected course TODO
|
||||
* save selected course and courseTTLink TODO
|
||||
* update the gui with the data of the new selected course
|
||||
* save selected course and courseTTLink
|
||||
*/
|
||||
fun updateCourse(course: CourseTTLink) {
|
||||
println(course.course)
|
||||
println(course.courseTTLink)
|
||||
|
||||
this.course = course
|
||||
// save new selected course
|
||||
val sharedPref = getPreferences(MODE_PRIVATE) ?: return
|
||||
with (sharedPref.edit()) {
|
||||
putString(getString(R.string.save_key_course), course.course)
|
||||
putString(getString(R.string.save_key_courseTTLink), course.courseTTLink.replace("http", "https"))
|
||||
apply()
|
||||
}
|
||||
|
||||
timeTableWeek = timeTableParser.getTimeTable(course.courseTTLink.replace("http", "https"))
|
||||
}
|
||||
|
||||
|
@ -158,6 +169,19 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
|||
* TODO evaluate if we should use a timeout here
|
||||
*/
|
||||
private fun load() {
|
||||
|
||||
// load saved course
|
||||
val sharedPref = getPreferences(MODE_PRIVATE) ?: return
|
||||
course = CourseTTLink(
|
||||
sharedPref.getString(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")!!,
|
||||
sharedPref.getString(getString(R.string.save_key_course), "AI3")!!
|
||||
)
|
||||
|
||||
/**
|
||||
* load mensa, course timetable and courselist from the swfr/hso website
|
||||
* TODO make an API see https://git.mosad.xyz/Seil0/TheCitadelofRicks
|
||||
*/
|
||||
val time = measureTimeMillis {
|
||||
/* getting the course list should be faster than the timetable,
|
||||
* we need have time until the user opens the dialog
|
||||
|
@ -172,7 +196,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
|||
|
||||
val t2 = doAsync {
|
||||
try {
|
||||
timeTableWeek = timeTableParser.getTimeTable("https://www.hs-offenburg.de/index.php?id=6627&class=class&iddV=DA64F6FE-9DDB-429E-A677-05D0D40CB636&week=0")
|
||||
timeTableWeek = timeTableParser.getTimeTable(course.courseTTLink)
|
||||
}catch (e: Exception) {
|
||||
e.stackTrace
|
||||
}
|
||||
|
@ -197,4 +221,8 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
|||
return weekMenus
|
||||
}
|
||||
|
||||
fun getCourse(): CourseTTLink {
|
||||
return course
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -72,6 +72,12 @@ class SettingsFragment : Fragment() {
|
|||
return view
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
txtView_Course.text = mainActivity.getCourse().course
|
||||
}
|
||||
|
||||
/**
|
||||
* initialize some actions for SettingsFragment elements
|
||||
*/
|
||||
|
|
|
@ -48,12 +48,13 @@ class TimeTableParser {
|
|||
fun getTimeTable(courseTTURL: String): Array<Array<Lesson>> {
|
||||
val scheduleHTML = Jsoup.connect(courseTTURL).get()
|
||||
|
||||
// val week = scheduleHTML.select("h1.timetable-caption").text()
|
||||
// println("$week successful!\n")
|
||||
//val week = scheduleHTML.select("h1.timetable-caption").text()
|
||||
//println("$week successful!\n")
|
||||
|
||||
scheduleHTML.select("table.timetable").select("td.lastcol").forEachIndexed { index, element ->
|
||||
timeTableWeek[index % 6][index / 6] = Lesson(element.select("div.lesson-subject").text(), element.select("div.lesson-teacher").text(), element.select("div.lesson-room").text(), element.select("div.lesson-remark").text())
|
||||
}
|
||||
|
||||
return timeTableWeek
|
||||
}
|
||||
|
||||
|
@ -69,6 +70,7 @@ class TimeTableParser {
|
|||
return courseTTLinkList
|
||||
}
|
||||
|
||||
|
||||
fun printTimeTableWeek (timeTableWeek: Array<Array<Lesson>>) {
|
||||
|
||||
for (j in 0..5) print(days[j].padEnd(25 ,' ') + " | ")
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<string name="app_name" translatable="false">Project Laogai</string>
|
||||
<string name="navigation_drawer_open">Open navigation drawer</string>
|
||||
<string name="navigation_drawer_close">Close navigation drawer</string>
|
||||
<string name="nav_header_title" translatable="false">hso App 0.1.4</string>
|
||||
<string name="nav_header_title" translatable="false">hso App 0.2.0</string>
|
||||
<string name="nav_header_subtitle" translatable="false">seil0@mosad.xyz</string>
|
||||
<string name="nav_header_desc" translatable="false">Project Laogai</string>
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
|||
<string name="primary_color">primary color</string>
|
||||
<string name="main_color_desc">The primary color, default is indigo</string>
|
||||
<string name="select">select</string>
|
||||
<string name="version" translatable="false">version 0.1.4</string>
|
||||
<string name="version" translatable="false">version 0.2.0</string>
|
||||
<string name="about">about</string>
|
||||
<string name="about_txtView" translatable="false">hso App by @Seil0</string>
|
||||
<string name="about_text" translatable="false">"This software is made by @Seil0 and is published under the terms and conditions of GPL 3. For further information visit \ngit.mosad.xyz/Seil0/ProjectLaogai \n\n© 2018 seil0@mosad.xyz "</string>
|
||||
|
@ -43,4 +43,7 @@
|
|||
|
||||
<string name="hello_blank_fragment">soon ™</string>
|
||||
<string name="string_new_line" translatable="false">%1$s\n</string>
|
||||
|
||||
<string name="save_key_course" translatable="false">org.mosag.seil0.projectlaogai.couse</string>
|
||||
<string name="save_key_courseTTLink" translatable="false">org.mosag.seil0.projectlaogai.couseTTLink</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue