init fragment in onViewCreated()
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
* closes #42 * show a info text if no mensa menus where found * the refresh spinner respects the selecte theme now
This commit is contained in:
parent
953b4825a9
commit
99ba87c3f6
|
@ -31,6 +31,7 @@ import android.nfc.NfcManager
|
||||||
import android.nfc.tech.NfcA
|
import android.nfc.tech.NfcA
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.util.TypedValue
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import androidx.appcompat.app.ActionBarDrawerToggle
|
import androidx.appcompat.app.ActionBarDrawerToggle
|
||||||
|
@ -203,6 +204,13 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set theme color values
|
||||||
|
val out = TypedValue()
|
||||||
|
this.theme.resolveAttribute(R.attr.themePrimary, out, true)
|
||||||
|
Preferences.themePrimary = out.data
|
||||||
|
|
||||||
|
this.theme.resolveAttribute(R.attr.themeSecondary, out, true)
|
||||||
|
Preferences.themeSecondary = out.data
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initForegroundDispatch() {
|
private fun initForegroundDispatch() {
|
||||||
|
|
|
@ -45,6 +45,10 @@ object Preferences {
|
||||||
var cShowBuffet = true
|
var cShowBuffet = true
|
||||||
var oGiants = false
|
var oGiants = false
|
||||||
|
|
||||||
|
// TODO move!
|
||||||
|
var themePrimary = 0
|
||||||
|
var themeSecondary = 0
|
||||||
|
|
||||||
// the save function
|
// the save function
|
||||||
fun save(context: Context) {
|
fun save(context: Context) {
|
||||||
val sharedPref = context.getSharedPreferences(
|
val sharedPref = context.getSharedPreferences(
|
||||||
|
|
|
@ -36,6 +36,7 @@ import kotlinx.coroutines.*
|
||||||
import org.mosad.seil0.projectlaogai.R
|
import org.mosad.seil0.projectlaogai.R
|
||||||
import org.mosad.seil0.projectlaogai.controller.QISPOSParser
|
import org.mosad.seil0.projectlaogai.controller.QISPOSParser
|
||||||
import org.mosad.seil0.projectlaogai.controller.preferences.EncryptedPreferences
|
import org.mosad.seil0.projectlaogai.controller.preferences.EncryptedPreferences
|
||||||
|
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences
|
||||||
import org.mosad.seil0.projectlaogai.uicomponents.DayCardView
|
import org.mosad.seil0.projectlaogai.uicomponents.DayCardView
|
||||||
import org.mosad.seil0.projectlaogai.uicomponents.GradeLinearLayout
|
import org.mosad.seil0.projectlaogai.uicomponents.GradeLinearLayout
|
||||||
import org.mosad.seil0.projectlaogai.uicomponents.dialogs.LoginDialog
|
import org.mosad.seil0.projectlaogai.uicomponents.dialogs.LoginDialog
|
||||||
|
@ -51,19 +52,18 @@ class GradesFragment : Fragment() {
|
||||||
private lateinit var parser: QISPOSParser
|
private lateinit var parser: QISPOSParser
|
||||||
|
|
||||||
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_grades, container, false)
|
return inflater.inflate(R.layout.fragment_grades, container, false)
|
||||||
|
|
||||||
refreshLayoutGrades = view.findViewById(R.id.refreshLayout_Grades)
|
|
||||||
refreshLayoutGrades.isEnabled = false // disable swipe
|
|
||||||
|
|
||||||
parser = QISPOSParser(context!!)// init the parser
|
|
||||||
|
|
||||||
return view
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
refreshLayoutGrades = view.findViewById(R.id.refreshLayout_Grades)
|
||||||
|
refreshLayoutGrades.isEnabled = false // disable swipe
|
||||||
|
refreshLayoutGrades.setProgressBackgroundColorSchemeColor(Preferences.themeSecondary)
|
||||||
|
|
||||||
|
parser = QISPOSParser(context!!)// init the parser
|
||||||
|
|
||||||
if (checkCredentials() && checkQisposStatus()) {
|
if (checkCredentials() && checkQisposStatus()) {
|
||||||
GlobalScope.launch(Dispatchers.Default) {
|
GlobalScope.launch(Dispatchers.Default) {
|
||||||
addGrades()
|
addGrades()
|
||||||
|
@ -105,18 +105,21 @@ class GradesFragment : Fragment() {
|
||||||
private fun checkQisposStatus(): Boolean {
|
private fun checkQisposStatus(): Boolean {
|
||||||
val statusCode = parser.checkQISPOSStatus()
|
val statusCode = parser.checkQISPOSStatus()
|
||||||
|
|
||||||
val infoText = resources.getString(when(statusCode) {
|
// show error if the status code is not 200
|
||||||
503 -> R.string.qispos_unavailable
|
if (statusCode != 200) {
|
||||||
else -> R.string.qispos_generic_error
|
val infoText = resources.getString(when(statusCode) {
|
||||||
})
|
503 -> R.string.qispos_unavailable
|
||||||
|
else -> R.string.qispos_generic_error
|
||||||
|
})
|
||||||
|
|
||||||
val img = ResourcesCompat.getDrawable(resources, R.drawable.ic_error_outline_black_24dp, null)?.apply {
|
val img = ResourcesCompat.getDrawable(resources, R.drawable.ic_error_outline_black_24dp, null)?.apply {
|
||||||
bounds = Rect(0, 0, 75, 75)
|
bounds = Rect(0, 0, 75, 75)
|
||||||
}
|
}
|
||||||
|
|
||||||
txtView_Loading?.apply {
|
txtView_Loading?.apply {
|
||||||
text = infoText
|
text = infoText
|
||||||
setCompoundDrawables(null, null, null, img)
|
setCompoundDrawables(null, null, null, img)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return statusCode == 200
|
return statusCode == 200
|
||||||
|
|
|
@ -53,13 +53,14 @@ class HomeFragment : Fragment() {
|
||||||
private val formatter = SimpleDateFormat("E dd.MM", Locale.getDefault())
|
private val formatter = SimpleDateFormat("E dd.MM", Locale.getDefault())
|
||||||
|
|
||||||
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_home, container, false)
|
return inflater.inflate(R.layout.fragment_home, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
addMensaMenu()
|
addMensaMenu()
|
||||||
addTimeTable()
|
addTimeTable()
|
||||||
|
|
||||||
// Inflate the layout for this fragment
|
|
||||||
return view
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
package org.mosad.seil0.projectlaogai.fragments
|
package org.mosad.seil0.projectlaogai.fragments
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.TypedValue
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
@ -32,13 +33,16 @@ import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
|
import org.mosad.seil0.projectlaogai.MainActivity
|
||||||
import org.mosad.seil0.projectlaogai.R
|
import org.mosad.seil0.projectlaogai.R
|
||||||
import org.mosad.seil0.projectlaogai.controller.cache.CacheController
|
import org.mosad.seil0.projectlaogai.controller.cache.CacheController
|
||||||
import org.mosad.seil0.projectlaogai.controller.cache.CacheController.Companion.mensaMenu
|
import org.mosad.seil0.projectlaogai.controller.cache.CacheController.Companion.mensaMenu
|
||||||
|
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences
|
||||||
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences.cShowBuffet
|
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences.cShowBuffet
|
||||||
import org.mosad.seil0.projectlaogai.util.MensaWeek
|
|
||||||
import org.mosad.seil0.projectlaogai.uicomponents.DayCardView
|
import org.mosad.seil0.projectlaogai.uicomponents.DayCardView
|
||||||
import org.mosad.seil0.projectlaogai.uicomponents.MealLinearLayout
|
import org.mosad.seil0.projectlaogai.uicomponents.MealLinearLayout
|
||||||
|
import org.mosad.seil0.projectlaogai.uicomponents.TextViewInfo
|
||||||
|
import org.mosad.seil0.projectlaogai.util.MensaWeek
|
||||||
import org.mosad.seil0.projectlaogai.util.NotRetardedCalendar
|
import org.mosad.seil0.projectlaogai.util.NotRetardedCalendar
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,11 +52,15 @@ import org.mosad.seil0.projectlaogai.util.NotRetardedCalendar
|
||||||
class MensaFragment : Fragment() {
|
class MensaFragment : Fragment() {
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
|
return inflater.inflate(R.layout.fragment_mensa, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
val view: View = inflater.inflate(R.layout.fragment_mensa, container, false)
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
// init actions
|
refreshLayout_Mensa.setProgressBackgroundColorSchemeColor(Preferences.themeSecondary)
|
||||||
refreshAction()
|
|
||||||
|
refreshAction() // init actions
|
||||||
|
|
||||||
GlobalScope.launch(Dispatchers.Default) {
|
GlobalScope.launch(Dispatchers.Default) {
|
||||||
val dayCurrent = if(NotRetardedCalendar.getDayOfWeekIndex() == 6) 0 else NotRetardedCalendar.getDayOfWeekIndex()
|
val dayCurrent = if(NotRetardedCalendar.getDayOfWeekIndex() == 6) 0 else NotRetardedCalendar.getDayOfWeekIndex()
|
||||||
|
@ -62,10 +70,13 @@ class MensaFragment : Fragment() {
|
||||||
addWeek(mensaMenu.nextWeek, 0)
|
addWeek(mensaMenu.nextWeek, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// show a info if there are no more menus
|
||||||
// TODO should we show a info if there is no more food this & next week?
|
if (linLayout_Mensa.childCount == 0) {
|
||||||
|
val txtViewInfo = TextViewInfo(context!!).set {
|
||||||
return view
|
txt = resources.getString(R.string.no_more_meals)
|
||||||
|
}
|
||||||
|
linLayout_Mensa.addView(txtViewInfo)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,7 +87,6 @@ class MensaFragment : Fragment() {
|
||||||
private fun addWeek(menusWeek: MensaWeek, dayStart: Int) = GlobalScope.launch(Dispatchers.Default) {
|
private fun addWeek(menusWeek: MensaWeek, dayStart: Int) = GlobalScope.launch(Dispatchers.Default) {
|
||||||
|
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
|
|
||||||
// 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)
|
var helpMeal = MealLinearLayout(context)
|
||||||
|
@ -100,7 +110,6 @@ class MensaFragment : Fragment() {
|
||||||
if(dayCardView.getLinLayoutDay().childCount > 2)
|
if(dayCardView.getLinLayoutDay().childCount > 2)
|
||||||
linLayout_Mensa.addView(dayCardView)
|
linLayout_Mensa.addView(dayCardView)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -136,6 +145,14 @@ class MensaFragment : Fragment() {
|
||||||
addWeek(mensaMenu.nextWeek, 0)
|
addWeek(mensaMenu.nextWeek, 0)
|
||||||
|
|
||||||
refreshLayout_Mensa.isRefreshing = false
|
refreshLayout_Mensa.isRefreshing = false
|
||||||
|
|
||||||
|
// show a info if there are no more menus
|
||||||
|
if (linLayout_Mensa.childCount == 0) {
|
||||||
|
val txtViewInfo = TextViewInfo(context!!).set {
|
||||||
|
txt = resources.getString(R.string.no_more_meals)
|
||||||
|
}
|
||||||
|
linLayout_Mensa.addView(txtViewInfo)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,11 @@ class MoodleFragment : Fragment() {
|
||||||
private lateinit var webSettings: WebSettings
|
private lateinit var webSettings: WebSettings
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
|
return inflater.inflate(R.layout.fragment_moodle, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
val view: View = inflater.inflate(R.layout.fragment_moodle, container, false)
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
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/")
|
||||||
|
@ -52,7 +55,5 @@ class MoodleFragment : Fragment() {
|
||||||
//webSettings.setJavaScriptEnabled(true) // Enable Javascript
|
//webSettings.setJavaScriptEnabled(true) // Enable Javascript
|
||||||
|
|
||||||
webView.webViewClient = 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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,8 +80,14 @@ class SettingsFragment : Fragment() {
|
||||||
private var selectedTheme = DataTypes.Theme.Light
|
private var selectedTheme = DataTypes.Theme.Light
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
|
return inflater.inflate(R.layout.fragment_settings, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
val view: View = inflater.inflate(R.layout.fragment_settings, container, false)
|
/**
|
||||||
|
* initialize the settings gui
|
||||||
|
*/
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
linLayoutUser = view.findViewById(R.id.linLayout_User)
|
linLayoutUser = view.findViewById(R.id.linLayout_User)
|
||||||
linLayoutCourse = view.findViewById(R.id.linLayout_Course)
|
linLayoutCourse = view.findViewById(R.id.linLayout_Course)
|
||||||
|
@ -92,19 +98,13 @@ class SettingsFragment : Fragment() {
|
||||||
linLayoutPrimaryColor = view.findViewById(R.id.linLayout_PrimaryColor)
|
linLayoutPrimaryColor = view.findViewById(R.id.linLayout_PrimaryColor)
|
||||||
linLayoutAccentColor = view.findViewById(R.id.linLayout_AccentColor)
|
linLayoutAccentColor = view.findViewById(R.id.linLayout_AccentColor)
|
||||||
switchBuffet = view.findViewById(R.id.switch_buffet)
|
switchBuffet = view.findViewById(R.id.switch_buffet)
|
||||||
|
|
||||||
// if we call txtView_Course via KAE view binding it'll result in a NPE in the onDismissed call
|
// if we call txtView_Course via KAE view binding it'll result in a NPE in the onDismissed call
|
||||||
txtViewCourse = view.findViewById(R.id.txtView_Course)
|
txtViewCourse = view.findViewById(R.id.txtView_Course)
|
||||||
|
|
||||||
initActions()
|
initActions()
|
||||||
|
|
||||||
// Inflate the layout for this fragment
|
|
||||||
return view
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
|
|
||||||
// initialize the settings gui
|
|
||||||
txtView_User.text = EncryptedPreferences.email.ifEmpty { resources.getString(R.string.sample_user) }
|
txtView_User.text = EncryptedPreferences.email.ifEmpty { resources.getString(R.string.sample_user) }
|
||||||
txtView_Course.text = cCourse.courseName
|
txtView_Course.text = cCourse.courseName
|
||||||
txtView_AboutDesc.text = resources.getString(R.string.about_version, BuildConfig.VERSION_NAME, getString(R.string.build_time))
|
txtView_AboutDesc.text = resources.getString(R.string.about_version, BuildConfig.VERSION_NAME, getString(R.string.build_time))
|
||||||
|
|
|
@ -28,15 +28,16 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.ScrollView
|
import android.widget.ScrollView
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
import kotlinx.android.synthetic.main.fragment_timetable.*
|
import kotlinx.android.synthetic.main.fragment_timetable.*
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import org.mosad.seil0.projectlaogai.R
|
import org.mosad.seil0.projectlaogai.R
|
||||||
import org.mosad.seil0.projectlaogai.controller.cache.TimetableController
|
import org.mosad.seil0.projectlaogai.controller.cache.TimetableController
|
||||||
import org.mosad.seil0.projectlaogai.controller.cache.TimetableController.Companion.timetable
|
import org.mosad.seil0.projectlaogai.controller.cache.TimetableController.Companion.timetable
|
||||||
|
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences
|
||||||
import org.mosad.seil0.projectlaogai.uicomponents.dialogs.AddSubjectDialog
|
import org.mosad.seil0.projectlaogai.uicomponents.dialogs.AddSubjectDialog
|
||||||
import org.mosad.seil0.projectlaogai.uicomponents.DayCardView
|
import org.mosad.seil0.projectlaogai.uicomponents.DayCardView
|
||||||
|
import org.mosad.seil0.projectlaogai.uicomponents.TextViewInfo
|
||||||
import org.mosad.seil0.projectlaogai.util.NotRetardedCalendar
|
import org.mosad.seil0.projectlaogai.util.NotRetardedCalendar
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,26 +50,26 @@ class TimeTableFragment : Fragment() {
|
||||||
private lateinit var faBtnAddSubject: FloatingActionButton
|
private lateinit var faBtnAddSubject: FloatingActionButton
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
|
return inflater.inflate(R.layout.fragment_timetable, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
val view: View = inflater.inflate(R.layout.fragment_timetable, container, false)
|
|
||||||
scrollViewTimetable = view.findViewById(R.id.scrollView_Timetable)
|
scrollViewTimetable = view.findViewById(R.id.scrollView_Timetable)
|
||||||
faBtnAddSubject = view.findViewById(R.id.faBtnAddSubject)
|
faBtnAddSubject = view.findViewById(R.id.faBtnAddSubject)
|
||||||
|
refreshLayout_Timetable.setProgressBackgroundColorSchemeColor(Preferences.themeSecondary)
|
||||||
|
|
||||||
// init actions
|
initActions() // init actions
|
||||||
initActions()
|
|
||||||
|
|
||||||
if (timetable.size > 1 && timetable[0].days.isNotEmpty() && timetable[1].days.isNotEmpty()) {
|
if (timetable.size > 1 && timetable[0].days.isNotEmpty() && timetable[1].days.isNotEmpty()) {
|
||||||
initTimetable()
|
initTimetable()
|
||||||
|
|
||||||
//println(timetable)
|
|
||||||
} else {
|
} else {
|
||||||
MaterialDialog(context!!)
|
val txtViewInfo = TextViewInfo(context!!).set {
|
||||||
.title(R.string.error)
|
txt = resources.getString(R.string.timetable_generic_error)
|
||||||
.message(R.string.timetable_error)
|
}.showImage()
|
||||||
.show()
|
linLayout_Timetable.addView(txtViewInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
return view
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -65,9 +65,8 @@ class DayCardView(context: Context) : CardView(context) {
|
||||||
txtView_DayHeading.text = formatter.format(cal.time)
|
txtView_DayHeading.text = formatter.format(cal.time)
|
||||||
|
|
||||||
// for every timeslot of that timetable
|
// for every timeslot of that timetable
|
||||||
for ((tsIndex, timeslot) in timetable.timeslots.withIndex()) {
|
timetable.timeslots.forEachIndexed { tsIndex, timeslot ->
|
||||||
|
timeslot.forEach { lesson ->
|
||||||
for (lesson in timeslot) {
|
|
||||||
if (lesson.lessonSubject.isNotEmpty()) {
|
if (lesson.lessonSubject.isNotEmpty()) {
|
||||||
|
|
||||||
val lessonLayout = LessonLinearLayout(context)
|
val lessonLayout = LessonLinearLayout(context)
|
||||||
|
@ -81,6 +80,7 @@ class DayCardView(context: Context) : CardView(context) {
|
||||||
lastLesson = lessonLayout
|
lastLesson = lessonLayout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lastLesson.disableDivider() // disable the divider for the last lesson of the day
|
lastLesson.disableDivider() // disable the divider for the last lesson of the day
|
||||||
|
|
|
@ -25,7 +25,6 @@ package org.mosad.seil0.projectlaogai.uicomponents
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.cardview.widget.CardView
|
|
||||||
import kotlinx.android.synthetic.main.linearlayout_grade.view.*
|
import kotlinx.android.synthetic.main.linearlayout_grade.view.*
|
||||||
import org.mosad.seil0.projectlaogai.R
|
import org.mosad.seil0.projectlaogai.R
|
||||||
|
|
||||||
|
@ -37,7 +36,7 @@ class GradeLinearLayout(context: Context?): LinearLayout(context) {
|
||||||
var subGrade = ""
|
var subGrade = ""
|
||||||
|
|
||||||
init {
|
init {
|
||||||
CardView.inflate(context, R.layout.linearlayout_grade, this)
|
inflate(context, R.layout.linearlayout_grade, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun set(func: GradeLinearLayout.() -> Unit): GradeLinearLayout = apply {
|
fun set(func: GradeLinearLayout.() -> Unit): GradeLinearLayout = apply {
|
||||||
|
|
|
@ -25,7 +25,6 @@ package org.mosad.seil0.projectlaogai.uicomponents
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.cardview.widget.CardView
|
|
||||||
import kotlinx.android.synthetic.main.linearlayout_lesson.view.*
|
import kotlinx.android.synthetic.main.linearlayout_lesson.view.*
|
||||||
import org.mosad.seil0.projectlaogai.R
|
import org.mosad.seil0.projectlaogai.R
|
||||||
import org.mosad.seil0.projectlaogai.util.Lesson
|
import org.mosad.seil0.projectlaogai.util.Lesson
|
||||||
|
@ -33,7 +32,7 @@ import org.mosad.seil0.projectlaogai.util.Lesson
|
||||||
class LessonLinearLayout(context: Context?) : LinearLayout(context) {
|
class LessonLinearLayout(context: Context?) : LinearLayout(context) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
CardView.inflate(context, R.layout.linearlayout_lesson, this)
|
inflate(context, R.layout.linearlayout_lesson, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setLesson(lesson: Lesson, time: String) {
|
fun setLesson(lesson: Lesson, time: String) {
|
||||||
|
|
|
@ -25,7 +25,6 @@ package org.mosad.seil0.projectlaogai.uicomponents
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.cardview.widget.CardView
|
|
||||||
import kotlinx.android.synthetic.main.linearlayout_meal.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.util.Meal
|
import org.mosad.seil0.projectlaogai.util.Meal
|
||||||
|
@ -33,7 +32,7 @@ import org.mosad.seil0.projectlaogai.util.Meal
|
||||||
class MealLinearLayout(context: Context?): LinearLayout(context) {
|
class MealLinearLayout(context: Context?): LinearLayout(context) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
CardView.inflate(context, R.layout.linearlayout_meal, this)
|
inflate(context, R.layout.linearlayout_meal, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setMeal(meal: Meal) {
|
fun setMeal(meal: Meal) {
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
/**
|
||||||
|
* ProjectLaogai
|
||||||
|
*
|
||||||
|
* Copyright 2019-2020 <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.graphics.Rect
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import androidx.appcompat.widget.AppCompatTextView
|
||||||
|
import androidx.core.content.res.ResourcesCompat
|
||||||
|
import org.mosad.seil0.projectlaogai.R
|
||||||
|
|
||||||
|
|
||||||
|
class TextViewInfo(context: Context?): AppCompatTextView(context!!) {
|
||||||
|
|
||||||
|
var txt = ""
|
||||||
|
var txtSize = 15F
|
||||||
|
var txtAlignment = View.TEXT_ALIGNMENT_CENTER
|
||||||
|
var drawable = R.drawable.ic_error_outline_black_24dp
|
||||||
|
var params = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)
|
||||||
|
|
||||||
|
init {
|
||||||
|
params.setMargins(0,200,0,0)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun set(func: TextViewInfo.() -> Unit): TextViewInfo = apply {
|
||||||
|
func()
|
||||||
|
|
||||||
|
text = txt
|
||||||
|
layoutParams = params
|
||||||
|
textSize = txtSize
|
||||||
|
textAlignment = txtAlignment
|
||||||
|
}
|
||||||
|
|
||||||
|
fun showImage(): TextViewInfo = apply {
|
||||||
|
val img = ResourcesCompat.getDrawable(resources, drawable, context.theme)?.apply {
|
||||||
|
bounds = Rect(0, 0, 75, 75)
|
||||||
|
}
|
||||||
|
setCompoundDrawables(null, null, null, img)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,26 +1,28 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".fragments.MensaFragment"
|
tools:context=".fragments.MensaFragment"
|
||||||
android:background="?themePrimary">
|
android:background="?themePrimary">
|
||||||
|
|
||||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/refreshLayout_Mensa"
|
||||||
android:layout_height="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:id="@+id/refreshLayout_Mensa">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/scrollView_Mensa"
|
||||||
android:layout_height="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:id="@+id/scrollView_Mensa">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="vertical"
|
android:id="@+id/linLayout_Mensa"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:animateLayoutChanges="false"
|
android:animateLayoutChanges="false"
|
||||||
android:id="@+id/linLayout_Mensa"/>
|
android:orientation="vertical" />
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
|
|
|
@ -33,11 +33,15 @@
|
||||||
<string name="no_more_food">Diese Woche keine weitere Essensausgabe</string>
|
<string name="no_more_food">Diese Woche keine weitere Essensausgabe</string>
|
||||||
<string name="no_lesson_today">heute keine Vorlesung!</string>
|
<string name="no_lesson_today">heute keine Vorlesung!</string>
|
||||||
|
|
||||||
|
<!-- fragment_mensa -->
|
||||||
|
<string name="no_more_meals">Für diese und nächste Woche ist der Speiseplan leer.</string>
|
||||||
|
|
||||||
<!-- fragment_timetable -->
|
<!-- fragment_timetable -->
|
||||||
<string name="add_lesson">Eine Vorlesung hinzufügen</string>
|
<string name="add_lesson">Eine Vorlesung hinzufügen</string>
|
||||||
<string name="add_lesson_desc">Füge eine Vorlesung eines anderen Studiengangs zu deinem Stundenplan hinzu.</string>
|
<string name="add_lesson_desc">Füge eine Vorlesung eines anderen Studiengangs zu deinem Stundenplan hinzu.</string>
|
||||||
<string name="courses">Studiengänge:</string>
|
<string name="courses">Studiengänge:</string>
|
||||||
<string name="lessons">Vorlesungen:</string>
|
<string name="lessons">Vorlesungen:</string>
|
||||||
|
<string name="timetable_generic_error">Beim laden des Stundenplans ist ein Fehler aufgetreten.\n</string>
|
||||||
|
|
||||||
<!-- fragment_grades -->
|
<!-- fragment_grades -->
|
||||||
<string name="loading_from_hs">Lade Daten von den Hochschul Servern.\nDas kann eine Weile dauern.</string>
|
<string name="loading_from_hs">Lade Daten von den Hochschul Servern.\nDas kann eine Weile dauern.</string>
|
||||||
|
@ -78,7 +82,7 @@
|
||||||
|
|
||||||
<!-- errors -->
|
<!-- errors -->
|
||||||
<string name="error">Fehler</string>
|
<string name="error">Fehler</string>
|
||||||
<string name="timetable_error">Stundenplan konnte nicht geladen werden!</string>
|
<string name="timetable_error">Der Stundenplan konnte nicht geladen werden.</string>
|
||||||
|
|
||||||
<!-- shortcuts -->
|
<!-- shortcuts -->
|
||||||
<string name="shortcut_mensa_short">Mensa</string>
|
<string name="shortcut_mensa_short">Mensa</string>
|
||||||
|
|
|
@ -35,11 +35,15 @@
|
||||||
<string name="no_more_food">No more Food this week</string>
|
<string name="no_more_food">No more Food this week</string>
|
||||||
<string name="no_lesson_today">"No lecture today!"</string>
|
<string name="no_lesson_today">"No lecture today!"</string>
|
||||||
|
|
||||||
|
<!-- fragment_mensa -->
|
||||||
|
<string name="no_more_meals">The menu is empty for this and the next week.</string>
|
||||||
|
|
||||||
<!-- fragment_timetable -->
|
<!-- fragment_timetable -->
|
||||||
<string name="add_lesson">Add a lesson</string>
|
<string name="add_lesson">Add a lesson</string>
|
||||||
<string name="add_lesson_desc">Add a lesson from another course to your timetable.</string>
|
<string name="add_lesson_desc">Add a lesson from another course to your timetable.</string>
|
||||||
<string name="courses">Courses:</string>
|
<string name="courses">Courses:</string>
|
||||||
<string name="lessons">Lessons:</string>
|
<string name="lessons">Lessons:</string>
|
||||||
|
<string name="timetable_generic_error">An error occurred while loading the timetable.\n</string>
|
||||||
|
|
||||||
<!-- fragment_grades -->
|
<!-- fragment_grades -->
|
||||||
<string name="loading_from_hs">Loading data from the university servers.\nThis may take a while.</string>
|
<string name="loading_from_hs">Loading data from the university servers.\nThis may take a while.</string>
|
||||||
|
@ -93,7 +97,7 @@
|
||||||
|
|
||||||
<!-- errors -->
|
<!-- errors -->
|
||||||
<string name="error">Error</string>
|
<string name="error">Error</string>
|
||||||
<string name="timetable_error">Could not load timetable!"</string>
|
<string name="timetable_error">Could not load the timetable!"</string>
|
||||||
|
|
||||||
<!-- shortcuts -->
|
<!-- shortcuts -->
|
||||||
<string name="shortcut_mensa_short">Mensa</string>
|
<string name="shortcut_mensa_short">Mensa</string>
|
||||||
|
|
Loading…
Reference in New Issue