minor gui updates
This commit is contained in:
parent
dbfdaffe99
commit
5a1a07cd42
|
@ -37,6 +37,7 @@ import org.mosad.seil0.projectlaogai.PreferencesController.Companion.cWeekMenus
|
||||||
import org.mosad.seil0.projectlaogai.R
|
import org.mosad.seil0.projectlaogai.R
|
||||||
import org.mosad.seil0.projectlaogai.hsoparser.*
|
import org.mosad.seil0.projectlaogai.hsoparser.*
|
||||||
import org.mosad.seil0.projectlaogai.uicomponents.LessonCardView
|
import org.mosad.seil0.projectlaogai.uicomponents.LessonCardView
|
||||||
|
import org.mosad.seil0.projectlaogai.uicomponents.LessonTextView
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -128,33 +129,42 @@ class HomeFragment : Fragment() {
|
||||||
|
|
||||||
// for all timeslots of the day
|
// for all timeslots of the day
|
||||||
for ((i, timeslot) in timeTableDay.timeslots.withIndex()) {
|
for ((i, timeslot) in timeTableDay.timeslots.withIndex()) {
|
||||||
|
|
||||||
for (lesson in timeslot) {
|
|
||||||
val lessonCardView = LessonCardView(context!!, null)
|
val lessonCardView = LessonCardView(context!!, null)
|
||||||
|
|
||||||
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]
|
lessonCardView.getTxtViewTime().text = DataTypes().getTime()[i]
|
||||||
|
|
||||||
if(lessonCardView.getTxtViewLesson().text.length > 2)
|
for (lesson in timeslot) {
|
||||||
linLayoutTimeTable.addView(lessonCardView)
|
val lessonTxtView = LessonTextView(context!!)
|
||||||
|
lessonTxtView.setLesson(lesson)
|
||||||
|
|
||||||
|
// TODO why does this exist
|
||||||
|
if (lessonTxtView.text.length > 3)
|
||||||
|
lessonCardView.getLinLayoutLesson().addView(lessonTxtView)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lessonCardView.getLinLayoutLesson().childCount > 2)
|
||||||
|
linLayoutTimeTable.addView(lessonCardView)
|
||||||
}
|
}
|
||||||
|
|
||||||
// add a card if there is no lesson today
|
// add a card if there is no lesson today
|
||||||
if (linLayoutTimeTable.childCount == 0) {
|
if (linLayoutTimeTable.childCount == 0) {
|
||||||
// TODO we could display the next day with a lecture
|
// TODO we could display the next day with a lecture
|
||||||
|
val lessonTxtView = LessonTextView(context!!)
|
||||||
|
lessonTxtView.setText(resources.getString(R.string.no_lesson_today))
|
||||||
|
|
||||||
val noLessonCardView = LessonCardView(context!!, null)
|
val noLessonCardView = LessonCardView(context!!, null)
|
||||||
noLessonCardView.getTxtViewLesson().text = resources.getString(R.string.no_lesson_today)
|
noLessonCardView.getLinLayoutLesson().addView(lessonTxtView)
|
||||||
|
|
||||||
linLayoutTimeTable.addView(noLessonCardView)
|
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!!)
|
||||||
|
lessonTxtView.setText(resources.getString(R.string.no_lesson_today))
|
||||||
|
|
||||||
val noLessonCardView = LessonCardView(context!!, null)
|
val noLessonCardView = LessonCardView(context!!, null)
|
||||||
noLessonCardView.getTxtViewLesson().text = resources.getString(R.string.no_lesson_today)
|
noLessonCardView.getLinLayoutLesson().addView(lessonTxtView)
|
||||||
|
|
||||||
linLayoutTimeTable.addView(noLessonCardView)
|
linLayoutTimeTable.addView(noLessonCardView)
|
||||||
} else {
|
} else {
|
||||||
MaterialDialog(context!!)
|
MaterialDialog(context!!)
|
||||||
|
|
|
@ -35,7 +35,6 @@ import com.afollestad.materialdialogs.color.colorChooser
|
||||||
import com.afollestad.materialdialogs.customview.customView
|
import com.afollestad.materialdialogs.customview.customView
|
||||||
import com.afollestad.materialdialogs.list.listItems
|
import com.afollestad.materialdialogs.list.listItems
|
||||||
import kotlinx.android.synthetic.main.fragment_settings.*
|
import kotlinx.android.synthetic.main.fragment_settings.*
|
||||||
import org.jetbrains.anko.Android
|
|
||||||
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.PreferencesController
|
import org.mosad.seil0.projectlaogai.PreferencesController
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
|
|
||||||
package org.mosad.seil0.projectlaogai.fragments
|
package org.mosad.seil0.projectlaogai.fragments
|
||||||
|
|
||||||
import android.graphics.Color
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
@ -37,6 +36,7 @@ import org.mosad.seil0.projectlaogai.R
|
||||||
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.LessonCardView
|
||||||
|
import org.mosad.seil0.projectlaogai.uicomponents.LessonTextView
|
||||||
import org.mosad.seil0.projectlaogai.uicomponents.MensaDayCardView
|
import org.mosad.seil0.projectlaogai.uicomponents.MensaDayCardView
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
@ -83,38 +83,41 @@ class TimeTableFragment : Fragment() {
|
||||||
|
|
||||||
// for each timeslot of the day
|
// for each timeslot of the day
|
||||||
for ((i, timeslot) in cTimeTableCurrentWeek.days[day].timeslots.withIndex()) {
|
for ((i, timeslot) in cTimeTableCurrentWeek.days[day].timeslots.withIndex()) {
|
||||||
|
|
||||||
println(timeslot)
|
|
||||||
|
|
||||||
for (lesson in timeslot) {
|
|
||||||
val lessonCardView = LessonCardView(context!!, null)
|
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]
|
lessonCardView.getTxtViewTime().text = DataTypes().getTime()[i]
|
||||||
|
|
||||||
// only add the lesson if it contains data
|
//println(timeslot)
|
||||||
if (lessonCardView.getTxtViewLesson().text.length > 2)
|
|
||||||
cardViewTimeTableDay.getLinLayoutMensaDay().addView(lessonCardView)
|
for (lesson in timeslot) {
|
||||||
|
val lessonTxtView = LessonTextView(context!!)
|
||||||
|
lessonTxtView.setLesson(lesson)
|
||||||
|
|
||||||
|
// TODO why does this exist
|
||||||
|
if (lessonTxtView.text.length > 3)
|
||||||
|
lessonCardView.getLinLayoutLesson().addView(lessonTxtView)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// only add the lesson if it contains data
|
||||||
|
if (lessonCardView.getLinLayoutLesson().childCount > 1)
|
||||||
|
cardViewTimeTableDay.getLinLayoutMensaDay().addView(lessonCardView)
|
||||||
}
|
}
|
||||||
|
|
||||||
calendar.add(Calendar.DATE, 1)
|
calendar.add(Calendar.DATE, 1)
|
||||||
|
|
||||||
// if the day contains no lessons add a text "No lesson today"
|
// if the day contains no lessons add a text "No lesson today"
|
||||||
if (cardViewTimeTableDay.getLinLayoutMensaDay().childCount <= 1) {
|
if (cardViewTimeTableDay.getLinLayoutMensaDay().childCount <= 1) {
|
||||||
|
val lessonTxtView = LessonTextView(context!!)
|
||||||
|
lessonTxtView.setText(resources.getString(R.string.no_lesson_today))
|
||||||
|
|
||||||
val lessonCardView = LessonCardView(context!!, null)
|
val lessonCardView = LessonCardView(context!!, null)
|
||||||
lessonCardView.setBackgroundColor(Color.TRANSPARENT)
|
lessonCardView.getLinLayoutLesson().addView(lessonTxtView)
|
||||||
lessonCardView.getTxtViewLesson().text = resources.getString(R.string.no_lesson_today)
|
|
||||||
cardViewTimeTableDay.getLinLayoutMensaDay().addView(lessonCardView)
|
cardViewTimeTableDay.getLinLayoutMensaDay().addView(lessonCardView)
|
||||||
}
|
}
|
||||||
|
|
||||||
linLayoutTTFragment.addView(cardViewTimeTableDay)
|
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
|
// add next weeks days, max number = dayIndex, if timetable was loaded
|
||||||
if (cTimeTableNextWeek.days.isNotEmpty()) {
|
if (cTimeTableNextWeek.days.isNotEmpty()) {
|
||||||
calendar.add(Calendar.DATE, 1) // before this we are at a sunday (no lecture on sundays!)
|
calendar.add(Calendar.DATE, 1) // before this we are at a sunday (no lecture on sundays!)
|
||||||
|
@ -126,23 +129,36 @@ class TimeTableFragment : Fragment() {
|
||||||
|
|
||||||
// for each timeslot of the day
|
// for each timeslot of the day
|
||||||
for ((i, timeslot) in cTimeTableNextWeek.days[day].timeslots.withIndex()) {
|
for ((i, timeslot) in cTimeTableNextWeek.days[day].timeslots.withIndex()) {
|
||||||
|
|
||||||
for (lesson in timeslot) {
|
|
||||||
val lessonCardView = LessonCardView(context!!, null)
|
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]
|
lessonCardView.getTxtViewTime().text = DataTypes().getTime()[i]
|
||||||
|
|
||||||
// only add the lesson if it contains data
|
|
||||||
if (lessonCardView.getTxtViewLesson().text.length > 2)
|
for (lesson in timeslot) {
|
||||||
cardViewTimeTableDay.getLinLayoutMensaDay().addView(lessonCardView)
|
val lessonTxtView = LessonTextView(context!!)
|
||||||
|
lessonTxtView.setLesson(lesson)
|
||||||
|
|
||||||
|
if (lessonTxtView.text.length > 3)
|
||||||
|
lessonCardView.getLinLayoutLesson().addView(lessonTxtView)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// only add the lesson if it contains data
|
||||||
|
if (lessonCardView.getLinLayoutLesson().childCount > 1)
|
||||||
|
cardViewTimeTableDay.getLinLayoutMensaDay().addView(lessonCardView)
|
||||||
}
|
}
|
||||||
|
|
||||||
calendar.add(Calendar.DATE, 1)
|
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)
|
linLayoutTTFragment.addView(cardViewTimeTableDay)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,26 +25,27 @@ 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.util.AttributeSet
|
||||||
|
import android.widget.LinearLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import org.mosad.seil0.projectlaogai.R
|
import org.mosad.seil0.projectlaogai.R
|
||||||
|
|
||||||
class LessonCardView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : androidx.cardview.widget.CardView(context, attrs){
|
class LessonCardView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : androidx.cardview.widget.CardView(context, attrs){
|
||||||
|
|
||||||
private var txtViewLesson: TextView
|
private var linLayoutLesson: LinearLayout
|
||||||
private var txtViewTime: TextView
|
private var txtViewTime: TextView
|
||||||
|
|
||||||
init {
|
init {
|
||||||
inflate(context, R.layout.lesson_cardview,this)
|
inflate(context, R.layout.lesson_cardview,this)
|
||||||
|
|
||||||
txtViewLesson = findViewById(R.id.txtView_Lesson)
|
linLayoutLesson = findViewById(R.id.linLayout_Lesson)
|
||||||
txtViewTime = findViewById(R.id.txtView_Time)
|
txtViewTime = findViewById(R.id.txtView_Time)
|
||||||
|
|
||||||
// workaround to prevent a white border
|
// workaround to prevent a white border
|
||||||
this.setBackgroundColor(Color.TRANSPARENT)
|
this.setBackgroundColor(Color.TRANSPARENT)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getTxtViewLesson(): TextView {
|
fun getLinLayoutLesson(): LinearLayout {
|
||||||
return txtViewLesson
|
return linLayoutLesson
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getTxtViewTime(): TextView {
|
fun getTxtViewTime(): TextView {
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
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.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(org.mosad.seil0.projectlaogai.R.string.string_new_line, lesson.lessonSubject)
|
||||||
|
this.append(lesson.lessonTeacher + "\n")
|
||||||
|
this.append(lesson.lessonRoom)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setText(text: String) {
|
||||||
|
this.text = text
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,20 +9,9 @@
|
||||||
app:cardUseCompatPadding="true" app:cardPreventCornerOverlap="false" app:contentPadding="5dp">
|
app:cardUseCompatPadding="true" app:cardPreventCornerOverlap="false" app:contentPadding="5dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent" android:id="@+id/linLayout_Lesson">
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/txtView_Lesson"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/a_lesson"
|
|
||||||
android:textColor="@android:color/primary_text_light"
|
|
||||||
android:textSize="14sp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:typeface="sans"/>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/txtView_Time"
|
android:id="@+id/txtView_Time"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
Loading…
Reference in New Issue