timetable and mensa gui redesign

* the timetable and mensa screen are now the same design as the settings, much cleaner and ready for themes
This commit is contained in:
Jannik 2019-03-20 21:33:55 +01:00
parent cd3136715f
commit a4eaea2918
20 changed files with 279 additions and 321 deletions

View File

@ -13,16 +13,15 @@ android {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 28 targetSdkVersion 28
versionCode 11 versionCode 11
versionName "0.3.96" versionName "0.3.97"
versionNameSuffix "-beta"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resValue "string", "build_time", buildTime() resValue "string", "build_time", buildTime()
} }
buildTypes { buildTypes {
release { release {
minifyEnabled true minifyEnabled false
shrinkResources true shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
versionNameSuffix "-release" versionNameSuffix "-release"
} }

View File

@ -38,8 +38,8 @@ import org.mosad.seil0.projectlaogai.controller.CacheController.Companion.timeta
import org.mosad.seil0.projectlaogai.hsoparser.DataTypes import org.mosad.seil0.projectlaogai.hsoparser.DataTypes
import org.mosad.seil0.projectlaogai.hsoparser.Meal import org.mosad.seil0.projectlaogai.hsoparser.Meal
import org.mosad.seil0.projectlaogai.hsoparser.NotRetardedCalendar import org.mosad.seil0.projectlaogai.hsoparser.NotRetardedCalendar
import org.mosad.seil0.projectlaogai.uicomponents.LessonCardView import org.mosad.seil0.projectlaogai.uicomponents.DayCardView
import org.mosad.seil0.projectlaogai.uicomponents.LessonTextView import org.mosad.seil0.projectlaogai.uicomponents.LessonLinearLayout
import java.util.* import java.util.*
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
@ -127,50 +127,49 @@ class HomeFragment : Fragment() {
*/ */
private fun addCurrentTimeTable() { private fun addCurrentTimeTable() {
val dayIndex = NotRetardedCalendar().getDayOfWeekIndex() val dayIndex = NotRetardedCalendar().getDayOfWeekIndex()
var helpLesson = LessonLinearLayout(context!!)
val dayCardView = DayCardView(context!!)
dayCardView.setDayHeading("Heute")
if (timetables[0].days.isNotEmpty() && dayIndex < 6) { if (timetables[0].days.isNotEmpty() && dayIndex < 6) {
val timeTableDay = timetables[0].days[dayIndex]
// for all timeslots of the day // for all timeslots of the day
for ((i, timeslot) in timeTableDay.timeslots.withIndex()) { for ((tsIndex, timeslot) in timetables[0].days[dayIndex].timeslots.withIndex()) {
val lessonCardView = LessonCardView(context!!, null)
lessonCardView.getTxtViewTime().text = DataTypes().getTime()[i]
for (lesson in timeslot) { for(lesson in timeslot) {
val lessonTxtView = LessonTextView(context!!) if(lesson.lessonSubject.isNotEmpty()) {
lessonTxtView.setLesson(lesson)
// make sure no empty lesson is added val lessonLayout = LessonLinearLayout(context!!)
if (lessonTxtView.text.length > 3) lessonLayout.setLesson(lesson, DataTypes().getTime()[tsIndex])
lessonCardView.getLinLayoutLesson().addView(lessonTxtView) dayCardView.getLinLayoutDay().addView(lessonLayout)
if (lesson != timeslot.last()) {
lessonLayout.disableDivider()
}
helpLesson = lessonLayout
}
} }
if (lessonCardView.getLinLayoutLesson().childCount > 1)
linLayoutTimeTable.addView(lessonCardView)
} }
// add a card if there is no lesson today helpLesson.disableDivider()
if (linLayoutTimeTable.childCount == 0) { // if there are no lessons don't show the dayCardView
if (dayCardView.getLinLayoutDay().childCount > 1) {
linLayoutTimeTable.addView(dayCardView)
} else {
// TODO we could display the next day with a lecture // TODO we could display the next day with a lecture
val lessonTxtView = LessonTextView(context!!) val noLesson = DayCardView(context!!)
lessonTxtView.setText(resources.getString(R.string.no_lesson_today)) noLesson.setDayHeading(resources.getString(R.string.no_lesson_today))
val noLessonCardView = LessonCardView(context!!, null) linLayoutTimeTable.addView(noLesson)
noLessonCardView.getLinLayoutLesson().addView(lessonTxtView)
linLayoutTimeTable.addView(noLessonCardView)
} }
} else { } else {
if (dayIndex == 6) { if (dayIndex == 6) {
// if that's the case it's sunday // if that's the case it's sunday
val lessonTxtView = LessonTextView(context!!) val noLesson = DayCardView(context!!)
lessonTxtView.setText(resources.getString(R.string.no_lesson_today)) noLesson.setDayHeading(resources.getString(R.string.no_lesson_today))
val noLessonCardView = LessonCardView(context!!, null) linLayoutTimeTable.addView(noLesson)
noLessonCardView.getLinLayoutLesson().addView(lessonTxtView)
linLayoutTimeTable.addView(noLessonCardView)
} else { } else {
MaterialDialog(context!!) MaterialDialog(context!!)
.title(R.string.error) .title(R.string.error)

View File

@ -28,16 +28,17 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import kotlinx.android.synthetic.main.fragment_mensa.*
import org.jetbrains.anko.doAsync import org.jetbrains.anko.doAsync
import org.jetbrains.anko.uiThread import org.jetbrains.anko.uiThread
import org.mosad.seil0.projectlaogai.controller.PreferencesController.Companion.cShowBuffet
import org.mosad.seil0.projectlaogai.R import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.controller.CacheController.Companion.mensaCurrentWeek import org.mosad.seil0.projectlaogai.controller.CacheController.Companion.mensaCurrentWeek
import org.mosad.seil0.projectlaogai.controller.CacheController.Companion.mensaNextWeek import org.mosad.seil0.projectlaogai.controller.CacheController.Companion.mensaNextWeek
import org.mosad.seil0.projectlaogai.controller.PreferencesController.Companion.cShowBuffet
import org.mosad.seil0.projectlaogai.hsoparser.MensaWeek import org.mosad.seil0.projectlaogai.hsoparser.MensaWeek
import org.mosad.seil0.projectlaogai.hsoparser.NotRetardedCalendar import org.mosad.seil0.projectlaogai.hsoparser.NotRetardedCalendar
import org.mosad.seil0.projectlaogai.uicomponents.MensaDayCardView import org.mosad.seil0.projectlaogai.uicomponents.DayCardView
import org.mosad.seil0.projectlaogai.uicomponents.MenuCardView import org.mosad.seil0.projectlaogai.uicomponents.MealLinearLayout
/** /**
* The mensa controller class * The mensa controller class
@ -51,7 +52,7 @@ class MensaFragment : Fragment() {
val view: View = inflater.inflate(R.layout.fragment_mensa, container, false) val view: View = inflater.inflate(R.layout.fragment_mensa, container, false)
linLayoutMensaFragment = view.findViewById(R.id.linLayout_MensaFragment) linLayoutMensaFragment = view.findViewById(R.id.linLayout_Mensa)
// add the current week (week starts on sunday) // add the current week (week starts on sunday)
val dayCurrent = if(NotRetardedCalendar().getDayOfWeekIndex() == 6) 0 else NotRetardedCalendar().getDayOfWeekIndex() val dayCurrent = if(NotRetardedCalendar().getDayOfWeekIndex() == 6) 0 else NotRetardedCalendar().getDayOfWeekIndex()
@ -71,37 +72,34 @@ class MensaFragment : Fragment() {
doAsync { doAsync {
uiThread { uiThread {
// only add the days dayStart to Fri since the mensa is closed on Sat/Sun // only add the days dayStart to Fri since the mensa is closed on Sat/Sun
for (dayIndex in dayStart..4) { for (dayIndex in dayStart..4) {
var helpMeal = MealLinearLayout(context)
val cardViewMensaDay = MensaDayCardView(context!!, null) val dayCardView = DayCardView(context!!)
dayCardView.setDayHeading(menusWeek.days[dayIndex].meals[0].day)
for (meal in menusWeek.days[dayIndex].meals) { for (meal in menusWeek.days[dayIndex].meals) {
val menuViewMenu = MenuCardView(context!!, null) val mealLayout = MealLinearLayout(context)
menuViewMenu.setMenuHeading(meal.heading) mealLayout.setMeal(meal)
meal.parts.forEachIndexed { partIndex, part -> if(meal.heading != "Buffet" || cShowBuffet) {
menuViewMenu.getTxtViewMenu().append(part) dayCardView.getLinLayoutDay().addView(mealLayout)
if(partIndex < (meal.parts.size - 1)) helpMeal = mealLayout
menuViewMenu.getTxtViewMenu().append("\n")
} }
cardViewMensaDay.setDayHeading(meal.day)
if(meal.heading != "Buffet" || cShowBuffet)
cardViewMensaDay.getLinLayoutMensaDay().addView(menuViewMenu)
} }
if(cardViewMensaDay.getLinLayoutMensaDay().childCount > 1) helpMeal.disableDivider()
linLayoutMensaFragment.addView(cardViewMensaDay)
if(dayCardView.getLinLayoutDay().childCount > 1)
linLayoutMensaFragment.addView(dayCardView)
} }
// add a card if there are no more meals in this week // add a card if there are no more meals in this week
if(linLayoutMensaFragment.childCount == 0) { if(linLayoutMensaFragment.childCount == 0) {
val cardViewNoMoreFood = MensaDayCardView(context!!, null) val noFood = DayCardView(context!!)
cardViewNoMoreFood.setDayHeading(resources.getString(R.string.no_more_food)) noFood.setDayHeading(resources.getString(R.string.no_more_food))
linLayoutMensaFragment.addView(cardViewNoMoreFood) linLayout_Mensa.addView(noFood)
} }
} }
} }

View File

@ -48,10 +48,10 @@ class MoodleFragment : Fragment() {
webView = view.findViewById(R.id.webView) webView = view.findViewById(R.id.webView)
webView.loadUrl("https://elearning.hs-offenburg.de/moodle/") webView.loadUrl("https://elearning.hs-offenburg.de/moodle/")
webSettings = webView.getSettings() webSettings = webView.settings
//webSettings.setJavaScriptEnabled(true) // Enable Javascript //webSettings.setJavaScriptEnabled(true) // Enable Javascript
webView.setWebViewClient(WebViewClient()) // Force links and redirects to open in the WebView instead of in a browser webView.webViewClient = WebViewClient() // Force links and redirects to open in the WebView instead of in a browser
return view return view
} }

View File

@ -26,17 +26,15 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.LinearLayout
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import kotlinx.android.synthetic.main.fragment_timetable.*
import org.jetbrains.anko.doAsync import org.jetbrains.anko.doAsync
import org.jetbrains.anko.uiThread import org.jetbrains.anko.uiThread
import org.mosad.seil0.projectlaogai.R import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.controller.CacheController.Companion.timetables import org.mosad.seil0.projectlaogai.controller.CacheController.Companion.timetables
import org.mosad.seil0.projectlaogai.hsoparser.DataTypes import org.mosad.seil0.projectlaogai.hsoparser.DataTypes
import org.mosad.seil0.projectlaogai.hsoparser.NotRetardedCalendar import org.mosad.seil0.projectlaogai.hsoparser.NotRetardedCalendar
import org.mosad.seil0.projectlaogai.uicomponents.LessonCardView import org.mosad.seil0.projectlaogai.uicomponents.*
import org.mosad.seil0.projectlaogai.uicomponents.LessonTextView
import org.mosad.seil0.projectlaogai.uicomponents.MensaDayCardView
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
@ -46,16 +44,12 @@ import java.util.*
*/ */
class TimeTableFragment : Fragment() { class TimeTableFragment : Fragment() {
private lateinit var linLayoutTTFragment: LinearLayout
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view: View = inflater.inflate(R.layout.fragment_timetable, container, false) val view: View = inflater.inflate(R.layout.fragment_timetable, container, false)
linLayoutTTFragment = view.findViewById(R.id.linLayout_TTFragment) if (timetables[0].days.isNotEmpty() && timetables[1].days.isNotEmpty()) {
addWeeks()
if (timetables[0].days.isNotEmpty()) {
addCurrentWeek()
} else { } else {
// TODO show card with error msg // TODO show card with error msg
} }
@ -64,9 +58,9 @@ class TimeTableFragment : Fragment() {
} }
/** /**
* add the remaining days of the current week to the timetable screen * add the all days with at least one lesson to the timetable screen
*/ */
private fun addCurrentWeek() { private fun addWeeks() {
val dayIndex = NotRetardedCalendar().getDayOfWeekIndex() val dayIndex = NotRetardedCalendar().getDayOfWeekIndex()
val formatter = SimpleDateFormat("E dd.MM", Locale.GERMANY) // TODO change to android call when min api is 24 val formatter = SimpleDateFormat("E dd.MM", Locale.GERMANY) // TODO change to android call when min api is 24
val calendar = Calendar.getInstance() val calendar = Calendar.getInstance()
@ -75,91 +69,76 @@ class TimeTableFragment : Fragment() {
uiThread { uiThread {
// add current weeks days // add the current week
for (day in dayIndex..5) { for (day in dayIndex..5) {
val cardViewTimeTableDay = MensaDayCardView(context!!, null) var helpLesson = LessonLinearLayout(context)
cardViewTimeTableDay.setDayHeading(formatter.format(calendar.time)) val dayCardView = DayCardView(context!!)
dayCardView.setDayHeading(formatter.format(calendar.time))
// for each timeslot of the day // for each timeslot of the day
for ((i, timeslot) in timetables[0].days[day].timeslots.withIndex()) { for ((tsIndex, timeslot) in timetables[0].days[day].timeslots.withIndex()) {
val lessonCardView = LessonCardView(context!!, null)
lessonCardView.getTxtViewTime().text = DataTypes().getTime()[i]
//println(timeslot) for(lesson in timeslot) {
for (lesson in timeslot) { if(lesson.lessonSubject.isNotEmpty()) {
val lessonTxtView = LessonTextView(context!!)
lessonTxtView.setLesson(lesson)
// make sure no empty lesson is added val lessonLayout = LessonLinearLayout(context)
if (lessonTxtView.text.length > 3) lessonLayout.setLesson(lesson, DataTypes().getTime()[tsIndex])
lessonCardView.getLinLayoutLesson().addView(lessonTxtView) dayCardView.getLinLayoutDay().addView(lessonLayout)
if (lesson != timeslot.last()) {
lessonLayout.disableDivider()
}
helpLesson = lessonLayout
}
} }
// only add the lesson if it contains data
if (lessonCardView.getLinLayoutLesson().childCount > 1)
cardViewTimeTableDay.getLinLayoutMensaDay().addView(lessonCardView)
} }
helpLesson.disableDivider()
calendar.add(Calendar.DATE, 1) calendar.add(Calendar.DATE, 1)
// if the day contains no lessons add a text "No lesson today" // if there are no lessons don't show the dayCardView
if (cardViewTimeTableDay.getLinLayoutMensaDay().childCount <= 1) { if (dayCardView.getLinLayoutDay().childCount > 1) {
val lessonTxtView = LessonTextView(context!!) linLayout_Timetable.addView(dayCardView)
lessonTxtView.setText(resources.getString(R.string.no_lesson_today))
val lessonCardView = LessonCardView(context!!, null)
lessonCardView.getLinLayoutLesson().addView(lessonTxtView)
cardViewTimeTableDay.getLinLayoutMensaDay().addView(lessonCardView)
} }
linLayoutTTFragment.addView(cardViewTimeTableDay)
} }
// add next weeks days, max number = dayIndex, if timetable was loaded
if (timetables[1].days.isNotEmpty()) {
calendar.add(Calendar.DATE, 1) // before this we are at a sunday (no lecture on sundays!)
for (day in 0..(dayIndex - 1)) { calendar.add(Calendar.DATE, 1) // before this we are at a sunday (no lecture on sundays!)
val cardViewTimeTableDay = MensaDayCardView(context!!, null) // add the next week
cardViewTimeTableDay.setDayHeading(formatter.format(calendar.time)) for (day in 0..(dayIndex - 1)) {
var helpLesson = LessonLinearLayout(context!!)
val dayCardView = DayCardView(context!!)
dayCardView.setDayHeading(formatter.format(calendar.time))
// for each timeslot of the day // for each timeslot of the day
for ((i, timeslot) in timetables[1].days[day].timeslots.withIndex()) { for ((tsIndex, timeslot) in timetables[1].days[day].timeslots.withIndex()) {
val lessonCardView = LessonCardView(context!!, null)
lessonCardView.getTxtViewTime().text = DataTypes().getTime()[i]
for(lesson in timeslot) {
for (lesson in timeslot) { if(lesson.lessonSubject.isNotEmpty()) {
val lessonTxtView = LessonTextView(context!!)
lessonTxtView.setLesson(lesson)
// make sure no empty lesson is added val lessonLayout = LessonLinearLayout(context!!)
if (lessonTxtView.text.length > 3) lessonLayout.setLesson(lesson, DataTypes().getTime()[tsIndex])
lessonCardView.getLinLayoutLesson().addView(lessonTxtView) dayCardView.getLinLayoutDay().addView(lessonLayout)
if (lesson != timeslot.last()) {
lessonLayout.disableDivider()
}
helpLesson = lessonLayout
} }
// only add the lesson if it contains data
if (lessonCardView.getLinLayoutLesson().childCount > 1)
cardViewTimeTableDay.getLinLayoutMensaDay().addView(lessonCardView)
} }
}
calendar.add(Calendar.DATE, 1) helpLesson.disableDivider()
calendar.add(Calendar.DATE, 1)
// if the day contains no lessons add a text "No lesson today" // if there are no lessons don't show the dayCardView
if (cardViewTimeTableDay.getLinLayoutMensaDay().childCount <= 1) { if (dayCardView.getLinLayoutDay().childCount > 1) {
val lessonTxtView = LessonTextView(context!!) linLayout_Timetable.addView(dayCardView)
lessonTxtView.setText(resources.getString(R.string.no_lesson_today))
val lessonCardView = LessonCardView(context!!, null)
lessonCardView.getLinLayoutLesson().addView(lessonTxtView)
cardViewTimeTableDay.getLinLayoutMensaDay().addView(lessonCardView)
}
linLayoutTTFragment.addView(cardViewTimeTableDay)
} }
} }
@ -168,4 +147,5 @@ class TimeTableFragment : Fragment() {
} }
} }
} }

View File

@ -24,32 +24,26 @@ package org.mosad.seil0.projectlaogai.uicomponents
import android.content.Context import android.content.Context
import android.graphics.Color import android.graphics.Color
import android.util.AttributeSet
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.TextView import androidx.cardview.widget.CardView
import kotlinx.android.synthetic.main.cardview_day.view.*
import org.mosad.seil0.projectlaogai.R import org.mosad.seil0.projectlaogai.R
class MensaDayCardView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : androidx.cardview.widget.CardView(context, attrs){ class DayCardView(context: Context) : CardView(context) {
private var linLayoutMensaDay: LinearLayout
private var txtViewDayHeading: TextView
init { init {
inflate(context, R.layout.mensaday_cardview,this) inflate(context, R.layout.cardview_day,this)
linLayoutMensaDay = findViewById(R.id.linLayout_MensaDay)
txtViewDayHeading = findViewById(R.id.txtView_DayHeading)
// workaround to prevent a white border // workaround to prevent a white border
this.setBackgroundColor(Color.TRANSPARENT) this.setBackgroundColor(Color.TRANSPARENT)
} }
fun getLinLayoutMensaDay(): LinearLayout { fun getLinLayoutDay() : LinearLayout {
return linLayoutMensaDay return linLayout_Day
} }
fun setDayHeading(heading: String) { fun setDayHeading(heading: String) {
txtViewDayHeading.text = heading txtView_DayHeading.text = heading
} }
} }

View File

@ -0,0 +1,50 @@
/**
* ProjectLaogai
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*/
package org.mosad.seil0.projectlaogai.uicomponents
import android.content.Context
import android.view.View
import android.widget.LinearLayout
import androidx.cardview.widget.CardView
import kotlinx.android.synthetic.main.linearlayout_lesson.view.*
import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.hsoparser.Lesson
class LessonLinearLayout(context: Context?) : LinearLayout(context) {
init {
CardView.inflate(context, R.layout.linearlayout_lesson, this)
}
fun setLesson(lesson: Lesson, time: String) {
txtView_lessonTime.text = time
txtView_lessonSubject.text = lesson.lessonSubject
txtView_lessonTeacher.text = lesson.lessonTeacher
txtView_lessonRoom.text = lesson.lessonRoom
}
fun disableDivider() {
divider_lesson.visibility = View.GONE
}
}

View File

@ -1,27 +0,0 @@
package org.mosad.seil0.projectlaogai.uicomponents
import android.content.Context
import android.graphics.Color
import android.util.AttributeSet
import android.widget.TextView
import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.hsoparser.Lesson
class LessonTextView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : TextView(context, attrs) {
init {
this.setTextColor(Color.BLACK)
this.textSize = 16F
this.setPadding(0,6,0,0)
}
fun setLesson(lesson: Lesson) {
this.text = resources.getString(R.string.string_new_line, lesson.lessonSubject)
this.append(lesson.lessonTeacher + "\n")
this.append(lesson.lessonRoom)
}
fun setText(text: String) {
this.text = text
}
}

View File

@ -23,32 +23,32 @@
package org.mosad.seil0.projectlaogai.uicomponents package org.mosad.seil0.projectlaogai.uicomponents
import android.content.Context import android.content.Context
import android.graphics.Color import android.view.View
import android.util.AttributeSet
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.TextView import androidx.cardview.widget.CardView
import kotlinx.android.synthetic.main.linearlayout_lesson.view.*
import kotlinx.android.synthetic.main.linearlayout_meal.view.*
import org.mosad.seil0.projectlaogai.R import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.hsoparser.Meal
class LessonCardView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : androidx.cardview.widget.CardView(context, attrs){ class MealLinearLayout(context: Context?): LinearLayout(context) {
private var linLayoutLesson: LinearLayout
private var txtViewTime: TextView
init { init {
inflate(context, R.layout.lesson_cardview,this) CardView.inflate(context, R.layout.linearlayout_meal, this)
linLayoutLesson = findViewById(R.id.linLayout_Lesson)
txtViewTime = findViewById(R.id.txtView_Time)
// workaround to prevent a white border
this.setBackgroundColor(Color.TRANSPARENT)
} }
fun getLinLayoutLesson(): LinearLayout { fun setMeal(meal: Meal) {
return linLayoutLesson txtView_MealHeading.text = meal.heading
meal.parts.forEachIndexed { partIndex, part ->
txtView_Meal.append(part)
if(partIndex < (meal.parts.size - 1))
txtView_Meal.append("\n")
}
} }
fun getTxtViewTime(): TextView { fun disableDivider() {
return txtViewTime divider_meal.visibility = View.GONE
} }
} }

View File

@ -1,31 +0,0 @@
package org.mosad.seil0.projectlaogai.uicomponents
import android.content.Context
import android.graphics.Color
import android.util.AttributeSet
import android.widget.TextView
import org.mosad.seil0.projectlaogai.R
class MenuCardView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : androidx.cardview.widget.CardView(context, attrs){
private var txtViewMenuHeading: TextView
private var txtViewMenu: TextView
init {
inflate(context, R.layout.menu_cardview,this)
txtViewMenuHeading = findViewById(R.id.txtView_MenuHeading)
txtViewMenu = findViewById(R.id.txtView_Menu)
// workaround to prevent a white border
this.setBackgroundColor(Color.TRANSPARENT)
}
fun setMenuHeading(heading: String) {
txtViewMenuHeading.text = heading
}
fun getTxtViewMenu(): TextView {
return txtViewMenu
}
}

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content" app:cardUseCompatPadding="true"
app:cardElevation="5dp" app:cardBackgroundColor="@color/themeSecondary"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/linLayout_Day">
<TextView
android:text="@string/sample_date"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/txtView_DayHeading" android:textSize="18sp"
android:textAlignment="center" android:textStyle="bold" android:textColor="?colorAccent"/>
</LinearLayout>
</androidx.cardview.widget.CardView>

View File

@ -14,9 +14,9 @@
android:id="@+id/cardView" android:id="@+id/cardView"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="5dp" android:layout_marginStart="3dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginEnd="5dp" android:layout_marginEnd="3dp"
android:clickable="false" android:clickable="false"
android:maxHeight="125dp" android:maxHeight="125dp"
app:cardUseCompatPadding="true" app:cardUseCompatPadding="true"
@ -57,7 +57,7 @@
app:layout_constraintHorizontal_bias="1.0" app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cardView" android:elevation="5dp" app:layout_constraintTop_toBottomOf="@+id/cardView" android:elevation="5dp"
android:layout_marginEnd="5dp" android:layout_marginStart="5dp"> android:layout_marginEnd="3dp" android:layout_marginStart="3dp">
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"

View File

@ -11,14 +11,12 @@
<ScrollView <ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:background="@android:color/background_light"> android:layout_height="match_parent">
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/linLayout_MensaFragment" android:layout_height="wrap_content" android:id="@+id/linLayout_Mensa"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" android:background="@color/themePrimary">
app:layout_constraintTop_toTopOf="parent"
>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -15,7 +15,8 @@
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/linLayout_TTFragment"> android:layout_height="wrap_content" android:id="@+id/linLayout_Timetable"
android:background="@color/themePrimary">
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="@android:color/background_light"
app:cardElevation="5dp"
app:cardUseCompatPadding="true" app:cardPreventCornerOverlap="false" app:contentPadding="5dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/linLayout_Lesson">
<TextView
android:id="@+id/txtView_Time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:text="@string/a_time"/>
</LinearLayout>
</androidx.cardview.widget.CardView>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/linLayout_lesson" android:padding="7dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/txtView_lessonSubject" android:layout_weight="1"
android:textSize="15sp" android:textColor="@color/textPrimary"/>
<TextView
android:text="@string/a_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/txtView_lessonTime" android:layout_weight="1"
android:textColor="@color/textSecondary" android:gravity="end"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/txtView_lessonTeacher" android:textSize="15sp"
android:textColor="@color/textPrimary"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/txtView_lessonRoom"
android:textColor="@color/textPrimary"/>
<View
android:id="@+id/divider_lesson"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider"
/>
</LinearLayout>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/linLayout_Meal" android:padding="7dp">
<TextView
android:text="@string/meal_1"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/txtView_MealHeading" android:textSize="18sp"
android:textColor="@color/textPrimary" android:textAlignment="center" android:paddingBottom="5dp"
android:textStyle="bold"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/txtView_Meal" android:textSize="15sp"
android:textColor="@color/textPrimary" android:textAlignment="center"/>
<View
android:id="@+id/divider_meal"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider"
/>
</LinearLayout>

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="9dp"
app:cardElevation="5dp"
app:cardBackgroundColor="@color/colorMensaDay"
app:cardUseCompatPadding="true">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/linLayout_MensaDay" android:paddingBottom="5dp">
<TextView
android:text="@string/sample_date"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/txtView_DayHeading" android:textAlignment="center"
android:textSize="20sp" android:textStyle="bold" android:typeface="sans" android:paddingBottom="5dp"/>
</LinearLayout>
</androidx.cardview.widget.CardView>

View File

@ -1,42 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:clickable="false"
android:maxHeight="125dp"
app:cardUseCompatPadding="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="@string/meal_1"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/txtView_MenuHeading"
android:textStyle="bold" android:textAlignment="center" android:textSize="16sp"
android:typeface="sans" android:fontFamily="sans-serif" android:paddingBottom="5dp"/>
<TextView
android:id="@+id/txtView_Menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:textAlignment="center"
android:textSize="16sp"
android:textStyle="bold"
android:typeface="sans"
android:textIsSelectable="true"/>
</LinearLayout>
</androidx.cardview.widget.CardView>

View File

@ -3,22 +3,29 @@
<color name="colorPrimary">#000000</color> <color name="colorPrimary">#000000</color>
<color name="colorPrimaryDark">#000000</color> <color name="colorPrimaryDark">#000000</color>
<color name="colorAccent">#3F51B5</color> <color name="colorAccent">#3F51B5</color>
<color name="colorMensaDay">#ebe8e9</color> <color name="colorMensaDay">#EBE8E9</color>
<color name="ic_launcher_background">#FFFFFF</color> <color name="ic_launcher_background">#FFFFFF</color>
<color name="themePrimary">#FFFFFF</color>
<color name="themeSecondary">#FFFFFF</color>
<color name="themeTertiary">#FAFAFA</color> <!-- TODO find a better color -->
<color name="textPrimary">#000000</color>
<color name="textSecondary">#818181</color>
<!--theme color section, not the working colors--> <!--theme color section, not the working colors-->
<color name="textPrimaryDark">#FFFFFF</color> <color name="textPrimaryDark">#FFFFFF</color>
<color name="textSecondaryDark">#F5F5F5</color> <color name="textSecondaryDark">#E0E0E0</color>
<color name="textPrimaryLight">#000000</color> <color name="textPrimaryLight">#000000</color>
<color name="textSecondaryLight">#818181</color> <color name="textSecondaryLight">#818181</color>
<color name="themePrimaryDark">#000000</color> <color name="themePrimaryDark">#000000</color>
<color name="themeSecondaryDark">#202020</color> <color name="themeSecondaryDark">#303030</color>
<color name="themeTertiaryDark">#424242</color> <color name="themeTertiaryDark">#424242</color>
<color name="themePrimaryLight">#FFFFFF</color> <color name="themePrimaryLight">#FFFFFF</color>
<color name="themeSecondaryLight">#202020</color> <color name="themeSecondaryLight">#FFFFFF</color>
<color name="themeTertiaryLight">#424242</color> <color name="themeTertiaryLight">#424242</color> <!-- TODO find a better color -->
<color name="test">#424242</color> <color name="test">#424242</color>