Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
f6f652ffb6 | |||
8fa0d496c6 | |||
0607d58760 | |||
3cd831e72c |
@ -5,13 +5,15 @@ apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
|
||||
android {
|
||||
signingConfigs {
|
||||
}
|
||||
compileSdkVersion 28
|
||||
defaultConfig {
|
||||
applicationId "org.mosad.seil0.projectlaogai"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 28
|
||||
versionCode 6
|
||||
versionName "0.2.1"
|
||||
versionCode 7
|
||||
versionName "0.2.3"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildTypes {
|
||||
@ -27,15 +29,14 @@ android {
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
implementation 'androidx.appcompat:appcompat:1.0.1'
|
||||
implementation 'androidx.appcompat:appcompat:1.0.2'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'com.google.android.material:material:1.0.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
|
||||
implementation 'org.jsoup:jsoup:1.11.3'
|
||||
implementation 'org.jetbrains.anko:anko-commons:0.10.7'
|
||||
implementation 'com.afollestad.material-dialogs:core:2.0.0-beta4'
|
||||
implementation 'com.afollestad.material-dialogs:color:2.0.0-beta4'
|
||||
|
||||
implementation 'com.afollestad.material-dialogs:core:2.0.0-beta5'
|
||||
implementation 'com.afollestad.material-dialogs:color:2.0.0-beta5'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test:runner:1.1.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
|
||||
|
@ -50,7 +50,8 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
||||
|
||||
private var weekMenus = ArrayList<Meal>()
|
||||
private var courseTTLinkList = ArrayList<CourseTTLink>()
|
||||
private var timeTableWeek = arrayOf<Array<Lesson>>()
|
||||
private var timeTableCurrentWeek = arrayOf<Array<Lesson>>()
|
||||
private var timeTableNextWeek = arrayOf<Array<Lesson>>()
|
||||
|
||||
private lateinit var course: CourseTTLink
|
||||
|
||||
@ -163,7 +164,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
||||
apply()
|
||||
}
|
||||
|
||||
timeTableWeek = timeTableParser.getTimeTable(course.courseTTLink.replace("http", "https"))
|
||||
timeTableCurrentWeek = timeTableParser.getTimeTable(course.courseTTLink.replace("http", "https"))
|
||||
}
|
||||
|
||||
/**
|
||||
@ -192,13 +193,21 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
||||
courseTTLinkList = timeTableParser.getCourseTTLinks()
|
||||
}
|
||||
|
||||
doAsync {
|
||||
try {
|
||||
timeTableNextWeek = timeTableParser.getTimeTable(course.courseTTLink.replace("week=0","week=1"))
|
||||
} catch (e: Exception) {
|
||||
e.stackTrace
|
||||
}
|
||||
}
|
||||
|
||||
val t1 = doAsync {
|
||||
weekMenus = mensaParser.getMensaMenu()
|
||||
}
|
||||
|
||||
val t2 = doAsync {
|
||||
try {
|
||||
timeTableWeek = timeTableParser.getTimeTable(course.courseTTLink)
|
||||
timeTableCurrentWeek = timeTableParser.getTimeTable(course.courseTTLink)
|
||||
} catch (e: Exception) {
|
||||
|
||||
uiThread {
|
||||
@ -223,8 +232,12 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
||||
return courseTTLinkList
|
||||
}
|
||||
|
||||
fun getCurrentTimeTableWeek(): Array<Array<Lesson>> {
|
||||
return timeTableWeek
|
||||
fun getTimeTableCurrentWeek(): Array<Array<Lesson>> {
|
||||
return timeTableCurrentWeek
|
||||
}
|
||||
|
||||
fun getTimeTableNextWeek(): Array<Array<Lesson>> {
|
||||
return timeTableNextWeek
|
||||
}
|
||||
|
||||
fun getWeekMenu(): ArrayList<Meal>{
|
||||
|
@ -64,22 +64,42 @@ class HomeFragment : Fragment() {
|
||||
|
||||
/**
|
||||
* add the current mensa meal to the home screens
|
||||
* TODO show meals of the next day if its later than 1500
|
||||
*/
|
||||
private fun addCurrentMensaMenu() {
|
||||
doAsync {
|
||||
val dayMenus: ArrayList<Meal> = MensaParser().getMensaMenuDay(mainActivity.getWeekMenu(), Calendar.getInstance().get(Calendar.DAY_OF_WEEK))
|
||||
val dayMenus: ArrayList<Meal>
|
||||
val cal = Calendar.getInstance()
|
||||
|
||||
// TODO needs testing
|
||||
if (cal.get(Calendar.HOUR_OF_DAY) < 15) {
|
||||
dayMenus = MensaParser().getMensaMenuDay(mainActivity.getWeekMenu(), cal.get(Calendar.DAY_OF_WEEK))
|
||||
} else {
|
||||
dayMenus = MensaParser().getMensaMenuDay(mainActivity.getWeekMenu(), cal.get(Calendar.DAY_OF_WEEK) + 1)
|
||||
uiThread {
|
||||
// TODO Mensa closed today is showing
|
||||
txtView_Menu1Heading.text = resources.getString(R.string.meal_1_tomorrow)
|
||||
txtView_Menu2Heading.text = resources.getString(R.string.meal_2_tomorrow)
|
||||
}
|
||||
}
|
||||
|
||||
uiThread {
|
||||
|
||||
if (dayMenus.size >= 2) {
|
||||
for (part in dayMenus[0].parts) {
|
||||
txtViewMenu1.append(part)
|
||||
// get the index of the first meal, not a "Schneller Teller"
|
||||
loop@ for ((i, meal) in dayMenus.withIndex()) {
|
||||
if(meal.heading.contains("Essen")) {
|
||||
for (part in dayMenus[i].parts) {
|
||||
txtViewMenu1.append(part)
|
||||
}
|
||||
|
||||
for (part in dayMenus[i + 1].parts) {
|
||||
txtViewMenu2.append(part)
|
||||
}
|
||||
|
||||
break@loop
|
||||
}
|
||||
}
|
||||
|
||||
for (part in dayMenus[1].parts) {
|
||||
txtViewMenu2.append(part)
|
||||
}
|
||||
} else {
|
||||
txtViewMenu1.text = resources.getString(R.string.no_meal_today)
|
||||
txtViewMenu2.text = resources.getString(R.string.no_meal_today)
|
||||
@ -95,9 +115,9 @@ class HomeFragment : Fragment() {
|
||||
private fun addCurrentTimeTable() {
|
||||
val dayIndex = NotRetardedCalendar().getDayOfWeekIndex()
|
||||
|
||||
if (mainActivity.getCurrentTimeTableWeek().isNotEmpty() && dayIndex < 6) {
|
||||
if (mainActivity.getTimeTableCurrentWeek().isNotEmpty() && dayIndex < 6) {
|
||||
|
||||
val timeTableDay = mainActivity.getCurrentTimeTableWeek()[dayIndex]
|
||||
val timeTableDay = mainActivity.getTimeTableCurrentWeek()[dayIndex]
|
||||
|
||||
for (i in 0..5) {
|
||||
val lessonCardView = LessonCardView(context!!, null)
|
||||
|
@ -71,7 +71,7 @@ class MensaFragment : Fragment() {
|
||||
Calendar.THURSDAY -> "Don"
|
||||
Calendar.FRIDAY -> "Fre"
|
||||
Calendar.SATURDAY -> "Sam"
|
||||
else -> "TODAY" //TODO
|
||||
else -> "TODAY" // the app will likely crash here
|
||||
}
|
||||
|
||||
val cardViewMensaDay = MensaDayCardView(context!!, null)
|
||||
|
@ -62,28 +62,23 @@ class TimeTableFragment : Fragment() {
|
||||
|
||||
/**
|
||||
* add the remaining days of the current week to the timetable screen
|
||||
* TODO show the current day and the following 5 days
|
||||
*/
|
||||
private fun addCurrentWeek() {
|
||||
val dayIndex = NotRetardedCalendar().getDayOfWeekIndex()
|
||||
val formatter = SimpleDateFormat("E dd.MM", Locale.GERMANY) // TODO change to android call when min api is 24
|
||||
val calendar = Calendar.getInstance()
|
||||
|
||||
doAsync {
|
||||
|
||||
uiThread {
|
||||
|
||||
println(dayIndex)
|
||||
// add current weeks days
|
||||
for(day in dayIndex..5) {
|
||||
|
||||
val formatter = SimpleDateFormat("E dd.MM", Locale.GERMANY) // TODO change to android call when min api is 24
|
||||
val calendar = Calendar.getInstance()
|
||||
calendar.firstDayOfWeek = Calendar.MONDAY
|
||||
calendar.add(Calendar.DATE,day - Calendar.getInstance().get(Calendar.DAY_OF_WEEK))
|
||||
|
||||
val cardViewTimeTableDay = MensaDayCardView(context!!, null)
|
||||
cardViewTimeTableDay.setDayHeading(formatter.format(calendar.time))
|
||||
|
||||
// for each lessen of the day
|
||||
for((i, lesson) in mainActivity.getCurrentTimeTableWeek()[dayIndex].withIndex()) {
|
||||
for((i, lesson) in mainActivity.getTimeTableCurrentWeek()[day].withIndex()) {
|
||||
val lessonCardView = LessonCardView(context!!, null)
|
||||
lessonCardView.setBackgroundColor(Color.TRANSPARENT)
|
||||
|
||||
@ -96,11 +91,39 @@ class TimeTableFragment : Fragment() {
|
||||
cardViewTimeTableDay.getLinLayoutMensaDay().addView(lessonCardView)
|
||||
}
|
||||
|
||||
// TODO if there is no lesson at one day , show a no lesson card
|
||||
|
||||
calendar.add(Calendar.DATE,1)
|
||||
linLayoutTTFragment.addView(cardViewTimeTableDay)
|
||||
}
|
||||
|
||||
// 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!)
|
||||
|
||||
for(day in 0..(dayIndex - 1)) {
|
||||
|
||||
val cardViewTimeTableDay = MensaDayCardView(context!!, null)
|
||||
cardViewTimeTableDay.setDayHeading(formatter.format(calendar.time))
|
||||
|
||||
// for each lessen of the day
|
||||
for((i, lesson) in mainActivity.getTimeTableNextWeek()[day].withIndex()) {
|
||||
val lessonCardView = LessonCardView(context!!, null)
|
||||
lessonCardView.setBackgroundColor(Color.TRANSPARENT)
|
||||
|
||||
lessonCardView.getTxtViewLesson().text = resources.getString(R.string.string_new_line, lesson.lessonSubject)
|
||||
lessonCardView.getTxtViewLesson().append(lesson.lessonTeacher + "\n")
|
||||
lessonCardView.getTxtViewLesson().append(lesson.lessonRoom)
|
||||
lessonCardView.getTxtViewTime().text = DataTypes().getTime()[i]
|
||||
|
||||
if(lessonCardView.getTxtViewLesson().text.length > 2)
|
||||
cardViewTimeTableDay.getLinLayoutMensaDay().addView(lessonCardView)
|
||||
}
|
||||
|
||||
calendar.add(Calendar.DATE,1)
|
||||
linLayoutTTFragment.addView(cardViewTimeTableDay)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO if there is no lesson at one day , show a no lesson card
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,8 @@
|
||||
<string name="settings">Einstellungen</string>
|
||||
<string name="meal_1">Essen 1</string>
|
||||
<string name="meal_2">Essen 2</string>
|
||||
<string name="meal_1_tomorrow">Essen 1, Morgen</string>
|
||||
<string name="meal_2_tomorrow">Essen 1, Morgen</string>
|
||||
<string name="no_meal_today">heute keine Essensausgabe</string>
|
||||
<string name="no_more_food">Diese Woche keine weitere Essensausgabe</string>
|
||||
<string name="no_lesson_today">heute keine Vorlesung</string>
|
||||
|
@ -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.2.1</string>
|
||||
<string name="nav_header_title" translatable="false">hso App 0.2.2</string>
|
||||
<string name="nav_header_subtitle" translatable="false">seil0@mosad.xyz</string>
|
||||
<string name="nav_header_desc" translatable="false">Project Laogai</string>
|
||||
|
||||
@ -15,6 +15,8 @@
|
||||
|
||||
<string name="meal_1">Meal 1</string>
|
||||
<string name="meal_2">Meal 2</string>
|
||||
<string name="meal_1_tomorrow">Meal 1, tomorrow</string>
|
||||
<string name="meal_2_tomorrow">Meal 2, tomorrow</string>
|
||||
<string name="no_meal_today">Mensa closed today</string>
|
||||
<string name="no_more_food">No more Food this week</string>
|
||||
|
||||
@ -35,7 +37,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.2.1</string>
|
||||
<string name="version" translatable="false">version 0.2.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 seil0@mosad.xyz "</string>
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.3.0'
|
||||
ext.kotlin_version = '1.3.10'
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
|
Reference in New Issue
Block a user