major bug fixes & version 0.3.2
* fixed a issue that prevented the app from showing the second weeks schedule, until now the app showed always the current week as next week * minor color chooser improvements * minor code clean up
This commit is contained in:
parent
87bf614d28
commit
75a457312d
|
@ -39,9 +39,6 @@ dependencies {
|
|||
implementation 'com.afollestad.material-dialogs:core:2.0.0-rc5'
|
||||
implementation 'com.afollestad.material-dialogs:color:2.0.0-rc5'
|
||||
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.0'
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.0'
|
||||
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test:runner:1.1.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* ProjectLaogai
|
||||
*
|
||||
* Copyright 2018 <seil0@mosad.xyz>
|
||||
* Copyright 2019 <seil0@mosad.xyz>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -35,9 +35,6 @@ import com.afollestad.materialdialogs.MaterialDialog
|
|||
import com.google.android.material.navigation.NavigationView
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import kotlinx.android.synthetic.main.app_bar_main.*
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.jetbrains.anko.doAsync
|
||||
import org.jetbrains.anko.uiThread
|
||||
import org.mosad.seil0.projectlaogai.fragments.*
|
||||
|
@ -51,16 +48,12 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
|||
|
||||
private var weekMenus = ArrayList<Meal>()
|
||||
private var courseTTLinkList = ArrayList<CourseTTLink>()
|
||||
//private var timeTableCurrentWeek = arrayOf<Array<Lesson>>()
|
||||
//private var timeTableNextWeek = arrayOf<Array<Lesson>>()
|
||||
private lateinit var timeTableCurrentWeek : Array<Array<Lesson>>
|
||||
private lateinit var timeTableNextWeek: Array<Array<Lesson>>
|
||||
private var timeTableCurrentWeek = arrayOf<Array<Lesson>>()
|
||||
private var timeTableNextWeek = arrayOf<Array<Lesson>>()
|
||||
|
||||
private lateinit var course: CourseTTLink
|
||||
private var color: Int = Color.BLACK
|
||||
|
||||
private var ls = Lesson("","","", "")
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
Aesthetic.attach(this)
|
||||
super.onCreate(savedInstanceState)
|
||||
|
@ -75,6 +68,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
|||
// this is executed on the first app start, use this to show tutorial etc.
|
||||
Aesthetic.config {
|
||||
colorPrimary(Color.BLACK)
|
||||
colorPrimaryDark(Color.BLACK)
|
||||
apply()
|
||||
}
|
||||
} else {
|
||||
|
@ -85,9 +79,6 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//init home fragment TODO make a abstract fragment class
|
||||
val homeFragment = HomeFragment()
|
||||
homeFragment.setMainActivity(this)
|
||||
|
@ -236,44 +227,6 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
|||
*/
|
||||
val time = measureTimeMillis {
|
||||
|
||||
runBlocking {
|
||||
/* getting the course list should be faster than the timetable,
|
||||
* we need have time until the user opens the dialog
|
||||
*/
|
||||
val jobTTLinkList = GlobalScope.launch {
|
||||
courseTTLinkList = timeTableParser.getCourseTTLinks()
|
||||
}
|
||||
|
||||
val jobTTNextWeek = GlobalScope.launch {
|
||||
timeTableNextWeek = timeTableParser.getTimeTable(course.courseTTLink.replace("week=0","week=1"))
|
||||
println("next: " + timeTableNextWeek.size)
|
||||
println(timeTableNextWeek)
|
||||
println(ls.lessonSubject)
|
||||
timeTableParser.printTimeTableWeek(timeTableNextWeek) // Wieso sind die daten hier noch im array
|
||||
}
|
||||
|
||||
val jobTTCurrentWeek = GlobalScope.launch {
|
||||
timeTableCurrentWeek = timeTableParser.getTimeTable(course.courseTTLink)
|
||||
}
|
||||
|
||||
val jobMenus = GlobalScope.launch {
|
||||
weekMenus = mensaParser.getMensaMenu()
|
||||
}
|
||||
|
||||
|
||||
|
||||
jobTTLinkList.join() // wait until child coroutine completes
|
||||
jobTTNextWeek.join()
|
||||
jobTTCurrentWeek.join()
|
||||
jobMenus.join()
|
||||
|
||||
println("next end:" + timeTableNextWeek.size)
|
||||
println(timeTableNextWeek)
|
||||
timeTableParser.printTimeTableWeek(timeTableNextWeek) // und hier nicht mehr
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
/* getting the course list should be faster than the timetable,
|
||||
* we need have time until the user opens the dialog
|
||||
*/
|
||||
|
@ -281,28 +234,13 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
|||
courseTTLinkList = timeTableParser.getCourseTTLinks()
|
||||
}
|
||||
|
||||
val t0 = doAsync {
|
||||
try {
|
||||
timeTableNextWeek = timeTableParser.getTimeTable(course.courseTTLink.replace("week=0","week=1"))
|
||||
ls = timeTableNextWeek[0][0]
|
||||
println("next: " + timeTableNextWeek.size)
|
||||
println(timeTableNextWeek)
|
||||
println(ls.lessonSubject)
|
||||
timeTableParser.printTimeTableWeek(timeTableNextWeek)
|
||||
} catch (e: Exception) {
|
||||
e.stackTrace
|
||||
}
|
||||
}
|
||||
|
||||
val t1 = doAsync {
|
||||
val jobMenus = doAsync {
|
||||
weekMenus = mensaParser.getMensaMenu()
|
||||
}
|
||||
|
||||
val t2 = doAsync {
|
||||
val jobTTCurrentWeek = doAsync {
|
||||
try {
|
||||
timeTableCurrentWeek = timeTableParser.getTimeTable(course.courseTTLink)
|
||||
println("current: " + timeTableCurrentWeek.size)
|
||||
timeTableParser.printTimeTableWeek(timeTableCurrentWeek)
|
||||
} catch (e: Exception) {
|
||||
|
||||
uiThread {
|
||||
|
@ -316,17 +254,19 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
|||
}
|
||||
}
|
||||
|
||||
t0.get()
|
||||
t1.get()
|
||||
t2.get()
|
||||
val jobTTNextWeek = doAsync {
|
||||
try {
|
||||
timeTableNextWeek = timeTableParser.getTimeTable(course.courseTTLink.replace("week=0","week=1"))
|
||||
} catch (e: Exception) {
|
||||
e.stackTrace
|
||||
}
|
||||
}
|
||||
|
||||
println("next end:" + timeTableNextWeek.size)
|
||||
println(timeTableNextWeek)
|
||||
timeTableParser.printTimeTableWeek(timeTableNextWeek)
|
||||
println(ls.lessonSubject)
|
||||
jobMenus.get()
|
||||
jobTTCurrentWeek.get()
|
||||
jobTTNextWeek.get()
|
||||
}
|
||||
println("Completed in $time ms")
|
||||
println(ls.lessonSubject)
|
||||
}
|
||||
|
||||
fun getCourseTTLinkList(): ArrayList<CourseTTLink>{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* ProjectLaogai
|
||||
*
|
||||
* Copyright 2018 <seil0@mosad.xyz>
|
||||
* Copyright 2019 <seil0@mosad.xyz>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* ProjectLaogai
|
||||
*
|
||||
* Copyright 2018 <seil0@mosad.xyz>
|
||||
* Copyright 2019 <seil0@mosad.xyz>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* ProjectLaogai
|
||||
*
|
||||
* Copyright 2018 <seil0@mosad.xyz>
|
||||
* Copyright 2019 <seil0@mosad.xyz>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* ProjectLaogai
|
||||
*
|
||||
* Copyright 2018 <seil0@mosad.xyz>
|
||||
* Copyright 2019 <seil0@mosad.xyz>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -126,11 +126,11 @@ class SettingsFragment : Fragment() {
|
|||
|
||||
linLayoutMainColor.setOnClickListener {
|
||||
// open a new color chooser dialog
|
||||
val colors = intArrayOf(Color.BLACK, Color.CYAN, Color.MAGENTA, Color.YELLOW)
|
||||
val colors = intArrayOf(Color.BLACK, Color.DKGRAY, Color.RED, Color.GREEN, Color.YELLOW)
|
||||
|
||||
MaterialDialog(context!!)
|
||||
.title(R.string.primary_color)
|
||||
.colorChooser(colors, initialSelection = mainActivity.getColorPrimary()) { _, color ->
|
||||
.colorChooser(colors, allowCustomArgb = true,initialSelection = mainActivity.getColorPrimary()) { _, color ->
|
||||
viewPrimaryColor.setBackgroundColor(color)
|
||||
Aesthetic.config {
|
||||
colorPrimary(color)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* ProjectLaogai
|
||||
*
|
||||
* Copyright 2018 <seil0@mosad.xyz>
|
||||
* Copyright 2019 <seil0@mosad.xyz>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -35,7 +35,6 @@ import org.mosad.seil0.projectlaogai.MainActivity
|
|||
import org.mosad.seil0.projectlaogai.R
|
||||
import org.mosad.seil0.projectlaogai.hsoparser.DataTypes
|
||||
import org.mosad.seil0.projectlaogai.hsoparser.NotRetardedCalendar
|
||||
import org.mosad.seil0.projectlaogai.hsoparser.TimeTableParser
|
||||
import org.mosad.seil0.projectlaogai.uicomponents.LessonCardView
|
||||
import org.mosad.seil0.projectlaogai.uicomponents.MensaDayCardView
|
||||
import java.text.SimpleDateFormat
|
||||
|
@ -73,9 +72,6 @@ class TimeTableFragment : Fragment() {
|
|||
val formatter = SimpleDateFormat("E dd.MM", Locale.GERMANY) // TODO change to android call when min api is 24
|
||||
val calendar = Calendar.getInstance()
|
||||
|
||||
println(mainActivity.getTimeTableCurrentWeek().size)
|
||||
println(mainActivity.getTimeTableNextWeek().size)
|
||||
|
||||
doAsync {
|
||||
|
||||
uiThread {
|
||||
|
@ -113,6 +109,7 @@ class TimeTableFragment : Fragment() {
|
|||
linLayoutTTFragment.addView(cardViewTimeTableDay)
|
||||
}
|
||||
|
||||
// TODO if there is no lesson at one day , show a no lesson card
|
||||
// add next weeks days, max number = dayIndex, if timetable was loaded
|
||||
if (mainActivity.getTimeTableNextWeek().isNotEmpty()) {
|
||||
calendar.add(Calendar.DATE,1) // before this we are at a sunday (no lecture on sundays!)
|
||||
|
@ -122,9 +119,6 @@ class TimeTableFragment : Fragment() {
|
|||
val cardViewTimeTableDay = MensaDayCardView(context!!, null)
|
||||
cardViewTimeTableDay.setDayHeading(formatter.format(calendar.time))
|
||||
|
||||
//val ttp = TimeTableParser()
|
||||
//ttp.printTimeTableWeek(mainActivity.getTimeTableNextWeek())
|
||||
|
||||
// for each lessen of the day
|
||||
for((i, lesson) in mainActivity.getTimeTableNextWeek()[day].withIndex()) {
|
||||
val lessonCardView = LessonCardView(context!!, null)
|
||||
|
@ -144,7 +138,6 @@ class TimeTableFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO if there is no lesson at one day , show a no lesson card
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* ProjectLaogai
|
||||
*
|
||||
* Copyright 2018 <seil0@mosad.xyz>
|
||||
* Copyright 2019 <seil0@mosad.xyz>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* ProjectLaogai
|
||||
*
|
||||
* Copyright 2018 <seil0@mosad.xyz>
|
||||
* Copyright 2019 <seil0@mosad.xyz>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* ProjectLaogai
|
||||
*
|
||||
* Copyright 2018 <seil0@mosad.xyz>
|
||||
* Copyright 2019 <seil0@mosad.xyz>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -27,9 +27,16 @@ import org.jsoup.Jsoup
|
|||
class TimeTableParser {
|
||||
private val days = arrayOf("Monday", "Tuesday" ,"Wednesday", "Thursday", "Friday", "Saturday")
|
||||
private var courseTTLinkList = ArrayList<CourseTTLink>()
|
||||
private var timeTableWeek = arrayOf<Array<Lesson>>()
|
||||
|
||||
init {
|
||||
/**
|
||||
* get the timetable from the given url
|
||||
* the timetable is organised per row not per column;
|
||||
* Mon 1, Tue 1, Wed 1, Thur 1, Fri 1, Sat 1, Mon 2 and so on
|
||||
*/
|
||||
fun getTimeTable(courseTTURL: String): Array<Array<Lesson>> {
|
||||
var timeTableWeek = arrayOf<Array<Lesson>>()
|
||||
val scheduleHTML = Jsoup.connect(courseTTURL).get()
|
||||
|
||||
// create the timetable array
|
||||
for (i in 0..5) {
|
||||
var timeTableDay = arrayOf<Lesson>()
|
||||
|
@ -38,15 +45,6 @@ class TimeTableParser {
|
|||
}
|
||||
timeTableWeek += timeTableDay
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the timetable from the given url
|
||||
* the timetable is organised per row not per column;
|
||||
* Mon 1, Tue 1, Wed 1, Thur 1, Fri 1, Sat 1, Mon 2 and so on
|
||||
*/
|
||||
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")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* ProjectLaogai
|
||||
*
|
||||
* Copyright 2018 <seil0@mosad.xyz>
|
||||
* Copyright 2019 <seil0@mosad.xyz>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* ProjectLaogai
|
||||
*
|
||||
* Copyright 2018 <seil0@mosad.xyz>
|
||||
* Copyright 2019 <seil0@mosad.xyz>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -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.3.1</string>
|
||||
<string name="nav_header_title" translatable="false">hso App 0.3.2</string>
|
||||
<string name="nav_header_subtitle" translatable="false">seil0@mosad.xyz</string>
|
||||
<string name="nav_header_desc" translatable="false">Project Laogai</string>
|
||||
|
||||
|
@ -37,11 +37,11 @@
|
|||
<string name="primary_color">primary color</string>
|
||||
<string name="main_color_desc">The primary color, default is black</string>
|
||||
<string name="select">select</string>
|
||||
<string name="version" translatable="false">version 0.3.1</string>
|
||||
<string name="version" translatable="false">version 0.3.2</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
|
||||
conditions of GPL 3. For further information visit \ngit.mosad.xyz/Seil0/ProjectLaogai \n\n© 2018-2019
|
||||
seil0@mosad.xyz "
|
||||
</string>
|
||||
<string name="loading_timetable">loading timetable …</string>
|
||||
|
|
Loading…
Reference in New Issue