From a4eaea29189597ffc7f074c7088d6b8a8efa6146 Mon Sep 17 00:00:00 2001 From: Seil0 Date: Wed, 20 Mar 2019 21:33:55 +0100 Subject: [PATCH] timetable and mensa gui redesign * the timetable and mensa screen are now the same design as the settings, much cleaner and ready for themes --- app/build.gradle | 7 +- .../projectlaogai/fragments/HomeFragment.kt | 59 ++++---- .../projectlaogai/fragments/MensaFragment.kt | 42 +++--- .../projectlaogai/fragments/MoodleFragment.kt | 4 +- .../fragments/TimeTableFragment.kt | 126 ++++++++---------- .../{MensaDayCardView.kt => DayCardView.kt} | 20 +-- .../uicomponents/LessonLinearLayout.kt | 50 +++++++ .../uicomponents/LessonTextView.kt | 27 ---- ...{LessonCardView.kt => MealLinearLayout.kt} | 36 ++--- .../uicomponents/MenuCardView.kt | 31 ----- app/src/main/res/layout/cardview_day.xml | 19 +++ app/src/main/res/layout/fragment_home.xml | 6 +- app/src/main/res/layout/fragment_mensa.xml | 8 +- .../main/res/layout/fragment_timetable.xml | 3 +- app/src/main/res/layout/lesson_cardview.xml | 23 ---- .../main/res/layout/linearlayout_lesson.xml | 35 +++++ app/src/main/res/layout/linearlayout_meal.xml | 23 ++++ app/src/main/res/layout/mensaday_cardview.xml | 22 --- app/src/main/res/layout/menu_cardview.xml | 42 ------ app/src/main/res/values/colors.xml | 17 ++- 20 files changed, 279 insertions(+), 321 deletions(-) rename app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/{MensaDayCardView.kt => DayCardView.kt} (65%) create mode 100644 app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/LessonLinearLayout.kt delete mode 100644 app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/LessonTextView.kt rename app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/{LessonCardView.kt => MealLinearLayout.kt} (57%) delete mode 100644 app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/MenuCardView.kt create mode 100644 app/src/main/res/layout/cardview_day.xml delete mode 100644 app/src/main/res/layout/lesson_cardview.xml create mode 100644 app/src/main/res/layout/linearlayout_lesson.xml create mode 100644 app/src/main/res/layout/linearlayout_meal.xml delete mode 100644 app/src/main/res/layout/mensaday_cardview.xml delete mode 100644 app/src/main/res/layout/menu_cardview.xml diff --git a/app/build.gradle b/app/build.gradle index 2587225..3439978 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,16 +13,15 @@ android { minSdkVersion 21 targetSdkVersion 28 versionCode 11 - versionName "0.3.96" - versionNameSuffix "-beta" + versionName "0.3.97" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" resValue "string", "build_time", buildTime() } buildTypes { release { - minifyEnabled true - shrinkResources true + minifyEnabled false + shrinkResources false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' versionNameSuffix "-release" } diff --git a/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/HomeFragment.kt b/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/HomeFragment.kt index 329152e..6fdb406 100644 --- a/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/HomeFragment.kt +++ b/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/HomeFragment.kt @@ -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.Meal import org.mosad.seil0.projectlaogai.hsoparser.NotRetardedCalendar -import org.mosad.seil0.projectlaogai.uicomponents.LessonCardView -import org.mosad.seil0.projectlaogai.uicomponents.LessonTextView +import org.mosad.seil0.projectlaogai.uicomponents.DayCardView +import org.mosad.seil0.projectlaogai.uicomponents.LessonLinearLayout import java.util.* import kotlin.collections.ArrayList @@ -127,50 +127,49 @@ class HomeFragment : Fragment() { */ private fun addCurrentTimeTable() { val dayIndex = NotRetardedCalendar().getDayOfWeekIndex() + var helpLesson = LessonLinearLayout(context!!) + val dayCardView = DayCardView(context!!) + dayCardView.setDayHeading("Heute") if (timetables[0].days.isNotEmpty() && dayIndex < 6) { - val timeTableDay = timetables[0].days[dayIndex] - // for all timeslots of the day - for ((i, timeslot) in timeTableDay.timeslots.withIndex()) { - val lessonCardView = LessonCardView(context!!, null) - lessonCardView.getTxtViewTime().text = DataTypes().getTime()[i] + for ((tsIndex, timeslot) in timetables[0].days[dayIndex].timeslots.withIndex()) { - for (lesson in timeslot) { - val lessonTxtView = LessonTextView(context!!) - lessonTxtView.setLesson(lesson) + for(lesson in timeslot) { + if(lesson.lessonSubject.isNotEmpty()) { - // make sure no empty lesson is added - if (lessonTxtView.text.length > 3) - lessonCardView.getLinLayoutLesson().addView(lessonTxtView) + val lessonLayout = LessonLinearLayout(context!!) + lessonLayout.setLesson(lesson, DataTypes().getTime()[tsIndex]) + 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 - if (linLayoutTimeTable.childCount == 0) { + helpLesson.disableDivider() + // 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 - val lessonTxtView = LessonTextView(context!!) - lessonTxtView.setText(resources.getString(R.string.no_lesson_today)) + val noLesson = DayCardView(context!!) + noLesson.setDayHeading(resources.getString(R.string.no_lesson_today)) - val noLessonCardView = LessonCardView(context!!, null) - noLessonCardView.getLinLayoutLesson().addView(lessonTxtView) - - linLayoutTimeTable.addView(noLessonCardView) + linLayoutTimeTable.addView(noLesson) } } else { if (dayIndex == 6) { // if that's the case it's sunday - val lessonTxtView = LessonTextView(context!!) - lessonTxtView.setText(resources.getString(R.string.no_lesson_today)) + val noLesson = DayCardView(context!!) + noLesson.setDayHeading(resources.getString(R.string.no_lesson_today)) - val noLessonCardView = LessonCardView(context!!, null) - noLessonCardView.getLinLayoutLesson().addView(lessonTxtView) - - linLayoutTimeTable.addView(noLessonCardView) + linLayoutTimeTable.addView(noLesson) } else { MaterialDialog(context!!) .title(R.string.error) diff --git a/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/MensaFragment.kt b/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/MensaFragment.kt index c56088f..71a978d 100644 --- a/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/MensaFragment.kt +++ b/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/MensaFragment.kt @@ -28,16 +28,17 @@ import android.view.View import android.view.ViewGroup import android.widget.LinearLayout import androidx.fragment.app.Fragment +import kotlinx.android.synthetic.main.fragment_mensa.* import org.jetbrains.anko.doAsync 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.controller.CacheController.Companion.mensaCurrentWeek 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.NotRetardedCalendar -import org.mosad.seil0.projectlaogai.uicomponents.MensaDayCardView -import org.mosad.seil0.projectlaogai.uicomponents.MenuCardView +import org.mosad.seil0.projectlaogai.uicomponents.DayCardView +import org.mosad.seil0.projectlaogai.uicomponents.MealLinearLayout /** * The mensa controller class @@ -51,7 +52,7 @@ class MensaFragment : Fragment() { 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) val dayCurrent = if(NotRetardedCalendar().getDayOfWeekIndex() == 6) 0 else NotRetardedCalendar().getDayOfWeekIndex() @@ -71,37 +72,34 @@ class MensaFragment : Fragment() { doAsync { uiThread { + // only add the days dayStart to Fri since the mensa is closed on Sat/Sun for (dayIndex in dayStart..4) { - - val cardViewMensaDay = MensaDayCardView(context!!, null) + var helpMeal = MealLinearLayout(context) + val dayCardView = DayCardView(context!!) + dayCardView.setDayHeading(menusWeek.days[dayIndex].meals[0].day) for (meal in menusWeek.days[dayIndex].meals) { - val menuViewMenu = MenuCardView(context!!, null) - menuViewMenu.setMenuHeading(meal.heading) + val mealLayout = MealLinearLayout(context) + mealLayout.setMeal(meal) - meal.parts.forEachIndexed { partIndex, part -> - menuViewMenu.getTxtViewMenu().append(part) - if(partIndex < (meal.parts.size - 1)) - menuViewMenu.getTxtViewMenu().append("\n") + if(meal.heading != "Buffet" || cShowBuffet) { + dayCardView.getLinLayoutDay().addView(mealLayout) + helpMeal = mealLayout } - - cardViewMensaDay.setDayHeading(meal.day) - - if(meal.heading != "Buffet" || cShowBuffet) - cardViewMensaDay.getLinLayoutMensaDay().addView(menuViewMenu) } - if(cardViewMensaDay.getLinLayoutMensaDay().childCount > 1) - linLayoutMensaFragment.addView(cardViewMensaDay) + helpMeal.disableDivider() + if(dayCardView.getLinLayoutDay().childCount > 1) + linLayoutMensaFragment.addView(dayCardView) } // add a card if there are no more meals in this week if(linLayoutMensaFragment.childCount == 0) { - val cardViewNoMoreFood = MensaDayCardView(context!!, null) - cardViewNoMoreFood.setDayHeading(resources.getString(R.string.no_more_food)) - linLayoutMensaFragment.addView(cardViewNoMoreFood) + val noFood = DayCardView(context!!) + noFood.setDayHeading(resources.getString(R.string.no_more_food)) + linLayout_Mensa.addView(noFood) } } } diff --git a/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/MoodleFragment.kt b/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/MoodleFragment.kt index 5ad6696..920c3a1 100644 --- a/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/MoodleFragment.kt +++ b/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/MoodleFragment.kt @@ -48,10 +48,10 @@ class MoodleFragment : Fragment() { webView = view.findViewById(R.id.webView) webView.loadUrl("https://elearning.hs-offenburg.de/moodle/") - webSettings = webView.getSettings() + webSettings = webView.settings //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 } diff --git a/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/TimeTableFragment.kt b/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/TimeTableFragment.kt index 11ccffe..b9b54e5 100644 --- a/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/TimeTableFragment.kt +++ b/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/TimeTableFragment.kt @@ -26,17 +26,15 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.widget.LinearLayout import androidx.fragment.app.Fragment +import kotlinx.android.synthetic.main.fragment_timetable.* import org.jetbrains.anko.doAsync import org.jetbrains.anko.uiThread import org.mosad.seil0.projectlaogai.R import org.mosad.seil0.projectlaogai.controller.CacheController.Companion.timetables import org.mosad.seil0.projectlaogai.hsoparser.DataTypes import org.mosad.seil0.projectlaogai.hsoparser.NotRetardedCalendar -import org.mosad.seil0.projectlaogai.uicomponents.LessonCardView -import org.mosad.seil0.projectlaogai.uicomponents.LessonTextView -import org.mosad.seil0.projectlaogai.uicomponents.MensaDayCardView +import org.mosad.seil0.projectlaogai.uicomponents.* import java.text.SimpleDateFormat import java.util.* @@ -46,16 +44,12 @@ import java.util.* */ class TimeTableFragment : Fragment() { - private lateinit var linLayoutTTFragment: LinearLayout - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { val view: View = inflater.inflate(R.layout.fragment_timetable, container, false) - linLayoutTTFragment = view.findViewById(R.id.linLayout_TTFragment) - - if (timetables[0].days.isNotEmpty()) { - addCurrentWeek() + if (timetables[0].days.isNotEmpty() && timetables[1].days.isNotEmpty()) { + addWeeks() } else { // 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 formatter = SimpleDateFormat("E dd.MM", Locale.GERMANY) // TODO change to android call when min api is 24 val calendar = Calendar.getInstance() @@ -75,91 +69,76 @@ class TimeTableFragment : Fragment() { uiThread { - // add current weeks days + // add the current week for (day in dayIndex..5) { - val cardViewTimeTableDay = MensaDayCardView(context!!, null) - cardViewTimeTableDay.setDayHeading(formatter.format(calendar.time)) + var helpLesson = LessonLinearLayout(context) + val dayCardView = DayCardView(context!!) + dayCardView.setDayHeading(formatter.format(calendar.time)) // for each timeslot of the day - for ((i, timeslot) in timetables[0].days[day].timeslots.withIndex()) { - val lessonCardView = LessonCardView(context!!, null) - lessonCardView.getTxtViewTime().text = DataTypes().getTime()[i] + for ((tsIndex, timeslot) in timetables[0].days[day].timeslots.withIndex()) { - //println(timeslot) + for(lesson in timeslot) { - for (lesson in timeslot) { - val lessonTxtView = LessonTextView(context!!) - lessonTxtView.setLesson(lesson) + if(lesson.lessonSubject.isNotEmpty()) { - // make sure no empty lesson is added - if (lessonTxtView.text.length > 3) - lessonCardView.getLinLayoutLesson().addView(lessonTxtView) + val lessonLayout = LessonLinearLayout(context) + lessonLayout.setLesson(lesson, DataTypes().getTime()[tsIndex]) + 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) - // if the day contains no lessons add a text "No lesson today" - if (cardViewTimeTableDay.getLinLayoutMensaDay().childCount <= 1) { - val lessonTxtView = LessonTextView(context!!) - lessonTxtView.setText(resources.getString(R.string.no_lesson_today)) - - val lessonCardView = LessonCardView(context!!, null) - lessonCardView.getLinLayoutLesson().addView(lessonTxtView) - - cardViewTimeTableDay.getLinLayoutMensaDay().addView(lessonCardView) + // if there are no lessons don't show the dayCardView + if (dayCardView.getLinLayoutDay().childCount > 1) { + linLayout_Timetable.addView(dayCardView) } - - 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) - cardViewTimeTableDay.setDayHeading(formatter.format(calendar.time)) + // add the next week + 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 ((i, timeslot) in timetables[1].days[day].timeslots.withIndex()) { - val lessonCardView = LessonCardView(context!!, null) - lessonCardView.getTxtViewTime().text = DataTypes().getTime()[i] + // for each timeslot of the day + for ((tsIndex, timeslot) in timetables[1].days[day].timeslots.withIndex()) { + for(lesson in timeslot) { - for (lesson in timeslot) { - val lessonTxtView = LessonTextView(context!!) - lessonTxtView.setLesson(lesson) + if(lesson.lessonSubject.isNotEmpty()) { - // make sure no empty lesson is added - if (lessonTxtView.text.length > 3) - lessonCardView.getLinLayoutLesson().addView(lessonTxtView) + val lessonLayout = LessonLinearLayout(context!!) + lessonLayout.setLesson(lesson, DataTypes().getTime()[tsIndex]) + 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 (cardViewTimeTableDay.getLinLayoutMensaDay().childCount <= 1) { - val lessonTxtView = LessonTextView(context!!) - 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) + // if there are no lessons don't show the dayCardView + if (dayCardView.getLinLayoutDay().childCount > 1) { + linLayout_Timetable.addView(dayCardView) } } @@ -168,4 +147,5 @@ class TimeTableFragment : Fragment() { } } + } diff --git a/app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/MensaDayCardView.kt b/app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/DayCardView.kt similarity index 65% rename from app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/MensaDayCardView.kt rename to app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/DayCardView.kt index a39752c..7ab1287 100644 --- a/app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/MensaDayCardView.kt +++ b/app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/DayCardView.kt @@ -24,32 +24,26 @@ package org.mosad.seil0.projectlaogai.uicomponents import android.content.Context import android.graphics.Color -import android.util.AttributeSet 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 -class MensaDayCardView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : androidx.cardview.widget.CardView(context, attrs){ - - private var linLayoutMensaDay: LinearLayout - private var txtViewDayHeading: TextView +class DayCardView(context: Context) : CardView(context) { init { - inflate(context, R.layout.mensaday_cardview,this) - - linLayoutMensaDay = findViewById(R.id.linLayout_MensaDay) - txtViewDayHeading = findViewById(R.id.txtView_DayHeading) + inflate(context, R.layout.cardview_day,this) // workaround to prevent a white border this.setBackgroundColor(Color.TRANSPARENT) } - fun getLinLayoutMensaDay(): LinearLayout { - return linLayoutMensaDay + fun getLinLayoutDay() : LinearLayout { + return linLayout_Day } fun setDayHeading(heading: String) { - txtViewDayHeading.text = heading + txtView_DayHeading.text = heading } } \ No newline at end of file diff --git a/app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/LessonLinearLayout.kt b/app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/LessonLinearLayout.kt new file mode 100644 index 0000000..dd47460 --- /dev/null +++ b/app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/LessonLinearLayout.kt @@ -0,0 +1,50 @@ +/** + * ProjectLaogai + * + * Copyright 2019 + * + * 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 + } + +} \ No newline at end of file diff --git a/app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/LessonTextView.kt b/app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/LessonTextView.kt deleted file mode 100644 index 9f8bb82..0000000 --- a/app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/LessonTextView.kt +++ /dev/null @@ -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 - } -} \ No newline at end of file diff --git a/app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/LessonCardView.kt b/app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/MealLinearLayout.kt similarity index 57% rename from app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/LessonCardView.kt rename to app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/MealLinearLayout.kt index 99e1063..13e7d98 100644 --- a/app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/LessonCardView.kt +++ b/app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/MealLinearLayout.kt @@ -23,32 +23,32 @@ package org.mosad.seil0.projectlaogai.uicomponents import android.content.Context -import android.graphics.Color -import android.util.AttributeSet +import android.view.View 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.hsoparser.Meal -class LessonCardView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : androidx.cardview.widget.CardView(context, attrs){ - - private var linLayoutLesson: LinearLayout - private var txtViewTime: TextView +class MealLinearLayout(context: Context?): LinearLayout(context) { init { - inflate(context, R.layout.lesson_cardview,this) - - linLayoutLesson = findViewById(R.id.linLayout_Lesson) - txtViewTime = findViewById(R.id.txtView_Time) - - // workaround to prevent a white border - this.setBackgroundColor(Color.TRANSPARENT) + CardView.inflate(context, R.layout.linearlayout_meal, this) } - fun getLinLayoutLesson(): LinearLayout { - return linLayoutLesson + fun setMeal(meal: Meal) { + 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 { - return txtViewTime + fun disableDivider() { + divider_meal.visibility = View.GONE } + } \ No newline at end of file diff --git a/app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/MenuCardView.kt b/app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/MenuCardView.kt deleted file mode 100644 index a01302e..0000000 --- a/app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/MenuCardView.kt +++ /dev/null @@ -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 - } -} \ No newline at end of file diff --git a/app/src/main/res/layout/cardview_day.xml b/app/src/main/res/layout/cardview_day.xml new file mode 100644 index 0000000..8c27625 --- /dev/null +++ b/app/src/main/res/layout/cardview_day.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index dc11fb0..37a59df 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -14,9 +14,9 @@ android:id="@+id/cardView" android:layout_width="0dp" android:layout_height="wrap_content" - android:layout_marginStart="5dp" + android:layout_marginStart="3dp" android:layout_marginTop="5dp" - android:layout_marginEnd="5dp" + android:layout_marginEnd="3dp" android:clickable="false" android:maxHeight="125dp" app:cardUseCompatPadding="true" @@ -57,7 +57,7 @@ app:layout_constraintHorizontal_bias="1.0" app:layout_constraintStart_toStartOf="parent" 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"> + android:layout_height="match_parent"> + android:layout_height="wrap_content" android:id="@+id/linLayout_Mensa" + android:background="@color/themePrimary"> diff --git a/app/src/main/res/layout/fragment_timetable.xml b/app/src/main/res/layout/fragment_timetable.xml index 6e21138..b678da5 100644 --- a/app/src/main/res/layout/fragment_timetable.xml +++ b/app/src/main/res/layout/fragment_timetable.xml @@ -15,7 +15,8 @@ + android:layout_height="wrap_content" android:id="@+id/linLayout_Timetable" + android:background="@color/themePrimary"> diff --git a/app/src/main/res/layout/lesson_cardview.xml b/app/src/main/res/layout/lesson_cardview.xml deleted file mode 100644 index bbbd688..0000000 --- a/app/src/main/res/layout/lesson_cardview.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - diff --git a/app/src/main/res/layout/linearlayout_lesson.xml b/app/src/main/res/layout/linearlayout_lesson.xml new file mode 100644 index 0000000..4012441 --- /dev/null +++ b/app/src/main/res/layout/linearlayout_lesson.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/linearlayout_meal.xml b/app/src/main/res/layout/linearlayout_meal.xml new file mode 100644 index 0000000..5a943d7 --- /dev/null +++ b/app/src/main/res/layout/linearlayout_meal.xml @@ -0,0 +1,23 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/mensaday_cardview.xml b/app/src/main/res/layout/mensaday_cardview.xml deleted file mode 100644 index 616ddd7..0000000 --- a/app/src/main/res/layout/mensaday_cardview.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/menu_cardview.xml b/app/src/main/res/layout/menu_cardview.xml deleted file mode 100644 index a8ee9b4..0000000 --- a/app/src/main/res/layout/menu_cardview.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 9b85180..645a465 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -3,22 +3,29 @@ #000000 #000000 #3F51B5 - #ebe8e9 + #EBE8E9 #FFFFFF + #FFFFFF + #FFFFFF + #FAFAFA + + #000000 + #818181 + #FFFFFF - #F5F5F5 + #E0E0E0 #000000 #818181 #000000 - #202020 + #303030 #424242 #FFFFFF - #202020 - #424242 + #FFFFFF + #424242 #424242