Browse Source

minor gui updates

pull/20/head 0.3.3
Jannik 3 years ago
parent
commit
5a1a07cd42
  1. 30
      app/src/main/java/org/mosad/seil0/projectlaogai/fragments/HomeFragment.kt
  2. 1
      app/src/main/java/org/mosad/seil0/projectlaogai/fragments/SettingsFragment.kt
  3. 66
      app/src/main/java/org/mosad/seil0/projectlaogai/fragments/TimeTableFragment.kt
  4. 9
      app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/LessonCardView.kt
  5. 26
      app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/LessonTextView.kt
  6. 15
      app/src/main/res/layout/lesson_cardview.xml

30
app/src/main/java/org/mosad/seil0/projectlaogai/fragments/HomeFragment.kt

@ -37,6 +37,7 @@ import org.mosad.seil0.projectlaogai.PreferencesController.Companion.cWeekMenus
import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.hsoparser.*
import org.mosad.seil0.projectlaogai.uicomponents.LessonCardView
import org.mosad.seil0.projectlaogai.uicomponents.LessonTextView
import java.util.*
/**
@ -128,33 +129,42 @@ class HomeFragment : Fragment() {
// 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 (lesson in timeslot) {
val lessonCardView = LessonCardView(context!!, null)
val lessonTxtView = LessonTextView(context!!)
lessonTxtView.setLesson(lesson)
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)
linLayoutTimeTable.addView(lessonCardView)
// 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
if (linLayoutTimeTable.childCount == 0) {
// 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)
noLessonCardView.getTxtViewLesson().text = resources.getString(R.string.no_lesson_today)
noLessonCardView.getLinLayoutLesson().addView(lessonTxtView)
linLayoutTimeTable.addView(noLessonCardView)
}
} 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 noLessonCardView = LessonCardView(context!!, null)
noLessonCardView.getTxtViewLesson().text = resources.getString(R.string.no_lesson_today)
noLessonCardView.getLinLayoutLesson().addView(lessonTxtView)
linLayoutTimeTable.addView(noLessonCardView)
} else {
MaterialDialog(context!!)

1
app/src/main/java/org/mosad/seil0/projectlaogai/fragments/SettingsFragment.kt

@ -35,7 +35,6 @@ import com.afollestad.materialdialogs.color.colorChooser
import com.afollestad.materialdialogs.customview.customView
import com.afollestad.materialdialogs.list.listItems
import kotlinx.android.synthetic.main.fragment_settings.*
import org.jetbrains.anko.Android
import org.jetbrains.anko.doAsync
import org.jetbrains.anko.uiThread
import org.mosad.seil0.projectlaogai.PreferencesController

66
app/src/main/java/org/mosad/seil0/projectlaogai/fragments/TimeTableFragment.kt

@ -22,7 +22,6 @@
package org.mosad.seil0.projectlaogai.fragments
import android.graphics.Color
import android.os.Bundle
import android.view.LayoutInflater
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.NotRetardedCalendar
import org.mosad.seil0.projectlaogai.uicomponents.LessonCardView
import org.mosad.seil0.projectlaogai.uicomponents.LessonTextView
import org.mosad.seil0.projectlaogai.uicomponents.MensaDayCardView
import java.text.SimpleDateFormat
import java.util.*
@ -83,38 +83,41 @@ class TimeTableFragment : Fragment() {
// for each timeslot of the day
for ((i, timeslot) in cTimeTableCurrentWeek.days[day].timeslots.withIndex()) {
val lessonCardView = LessonCardView(context!!, null)
lessonCardView.getTxtViewTime().text = DataTypes().getTime()[i]
println(timeslot)
//println(timeslot)
for (lesson in timeslot) {
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]
val lessonTxtView = LessonTextView(context!!)
lessonTxtView.setLesson(lesson)
// only add the lesson if it contains data
if (lessonCardView.getTxtViewLesson().text.length > 2)
cardViewTimeTableDay.getLinLayoutMensaDay().addView(lessonCardView)
// 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)
// 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.setBackgroundColor(Color.TRANSPARENT)
lessonCardView.getTxtViewLesson().text = resources.getString(R.string.no_lesson_today)
lessonCardView.getLinLayoutLesson().addView(lessonTxtView)
cardViewTimeTableDay.getLinLayoutMensaDay().addView(lessonCardView)
}
linLayoutTTFragment.addView(cardViewTimeTableDay)
}
// TODO if there is no lesson at one day , show a no lesson card
// add next weeks days, max number = dayIndex, if timetable was loaded
if (cTimeTableNextWeek.days.isNotEmpty()) {
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 ((i, timeslot) in cTimeTableNextWeek.days[day].timeslots.withIndex()) {
val lessonCardView = LessonCardView(context!!, null)
lessonCardView.getTxtViewTime().text = DataTypes().getTime()[i]
for (lesson in timeslot) {
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]
for (lesson in timeslot) {
val lessonTxtView = LessonTextView(context!!)
lessonTxtView.setLesson(lesson)
// only add the lesson if it contains data
if (lessonCardView.getTxtViewLesson().text.length > 2)
cardViewTimeTableDay.getLinLayoutMensaDay().addView(lessonCardView)
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)
// 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)
}
}

9
app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/LessonCardView.kt

@ -25,26 +25,27 @@ 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 org.mosad.seil0.projectlaogai.R
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
init {
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)
// workaround to prevent a white border
this.setBackgroundColor(Color.TRANSPARENT)
}
fun getTxtViewLesson(): TextView {
return txtViewLesson
fun getLinLayoutLesson(): LinearLayout {
return linLayoutLesson
}
fun getTxtViewTime(): TextView {

26
app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/LessonTextView.kt

@ -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
}
}

15
app/src/main/res/layout/lesson_cardview.xml

@ -9,20 +9,9 @@
app:cardUseCompatPadding="true" app:cardPreventCornerOverlap="false" app:contentPadding="5dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
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"/>
android:layout_height="match_parent" android:id="@+id/linLayout_Lesson">
<TextView
android:id="@+id/txtView_Time"
android:layout_width="match_parent"

Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close