Browse Source

change default accent color, code clean up

pull/46/head
Jannik 2 years ago
parent
commit
7779296345
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
  1. 6
      app/src/main/java/org/mosad/seil0/projectlaogai/controller/CacheController.kt
  2. 14
      app/src/main/java/org/mosad/seil0/projectlaogai/controller/PreferencesController.kt
  3. 8
      app/src/main/java/org/mosad/seil0/projectlaogai/controller/TCoRAPIController.kt
  4. 6
      app/src/main/java/org/mosad/seil0/projectlaogai/fragments/HomeFragment.kt
  5. 4
      app/src/main/java/org/mosad/seil0/projectlaogai/fragments/MensaFragment.kt
  6. 2
      app/src/main/java/org/mosad/seil0/projectlaogai/fragments/SettingsFragment.kt
  7. 2
      app/src/main/java/org/mosad/seil0/projectlaogai/fragments/TimeTableFragment.kt
  8. 2
      app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/AddLessonDialog.kt
  9. 6
      app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/DayCardView.kt
  10. 2
      app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/LessonLinearLayout.kt
  11. 2
      app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/MealLinearLayout.kt
  12. 54
      app/src/main/java/org/mosad/seil0/projectlaogai/util/DataTypes.kt
  13. 64
      app/src/main/java/org/mosad/seil0/projectlaogai/util/NotRetardedCalendar.kt
  14. 2
      app/src/main/res/values-de-rDE/strings.xml
  15. 2
      app/src/main/res/values/colors.xml
  16. 2
      app/src/main/res/values/strings.xml

6
app/src/main/java/org/mosad/seil0/projectlaogai/controller/CacheController.kt

@ -30,9 +30,9 @@ import com.google.gson.JsonParser
import com.google.gson.reflect.TypeToken
import kotlinx.coroutines.*
import org.mosad.seil0.projectlaogai.controller.PreferencesController.Companion.cCourse
import org.mosad.seil0.projectlaogai.hsoparser.Course
import org.mosad.seil0.projectlaogai.hsoparser.MensaMenu
import org.mosad.seil0.projectlaogai.hsoparser.TimetableCourseWeek
import org.mosad.seil0.projectlaogai.util.Course
import org.mosad.seil0.projectlaogai.util.MensaMenu
import org.mosad.seil0.projectlaogai.util.TimetableCourseWeek
import java.io.BufferedReader
import java.io.File
import java.io.FileReader

14
app/src/main/java/org/mosad/seil0/projectlaogai/controller/PreferencesController.kt

@ -25,7 +25,7 @@ package org.mosad.seil0.projectlaogai.controller
import android.content.Context
import android.graphics.Color
import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.hsoparser.Course
import org.mosad.seil0.projectlaogai.util.Course
/**
* The PreferencesController class
@ -38,8 +38,11 @@ class PreferencesController {
var mensaCacheTime: Long = 0
var timetableCacheTime: Long = 0
var cColorPrimary: Int = Color.parseColor("#009688")
var cColorAccent: Int = Color.parseColor("#3F51B5")
var cCourse = Course("https://www.hs-offenburg.de/index.php?id=6627&class=class&iddV=DA64F6FE-9DDB-429E-A677-05D0D40CB636&week=0", "AI3")
var cColorAccent: Int = Color.parseColor("#0096ff")
var cCourse = Course(
"https://www.hs-offenburg.de/index.php?id=6627&class=class&iddV=DA64F6FE-9DDB-429E-A677-05D0D40CB636&week=0",
"AI3"
)
var cShowBuffet = true
var oGiants = false
@ -161,7 +164,10 @@ class PreferencesController {
// load saved course
cCourse = Course(
sharedPref.getString(context.getString(R.string.save_key_courseTTLink), "https://www.hs-offenburg.de/index.php?id=6627&class=class&iddV=DA64F6FE-9DDB-429E-A677-05D0D40CB636&week=0")!!,
sharedPref.getString(
context.getString(R.string.save_key_courseTTLink),
"https://www.hs-offenburg.de/index.php?id=6627&class=class&iddV=DA64F6FE-9DDB-429E-A677-05D0D40CB636&week=0"
)!!,
sharedPref.getString(context.getString(R.string.save_key_course), "AI3")!!
)

8
app/src/main/java/org/mosad/seil0/projectlaogai/controller/TCoRAPIController.kt

@ -31,10 +31,10 @@ import org.json.JSONObject
import org.mosad.seil0.projectlaogai.controller.PreferencesController.Companion.coursesCacheTime
import org.mosad.seil0.projectlaogai.controller.PreferencesController.Companion.mensaCacheTime
import org.mosad.seil0.projectlaogai.controller.PreferencesController.Companion.timetableCacheTime
import org.mosad.seil0.projectlaogai.hsoparser.CoursesList
import org.mosad.seil0.projectlaogai.hsoparser.Lesson
import org.mosad.seil0.projectlaogai.hsoparser.MensaMenu
import org.mosad.seil0.projectlaogai.hsoparser.TimetableCourseWeek
import org.mosad.seil0.projectlaogai.util.CoursesList
import org.mosad.seil0.projectlaogai.util.Lesson
import org.mosad.seil0.projectlaogai.util.MensaMenu
import org.mosad.seil0.projectlaogai.util.TimetableCourseWeek
import java.io.BufferedWriter
import java.io.File
import java.io.FileWriter

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

@ -35,11 +35,11 @@ import kotlinx.coroutines.*
import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.controller.CacheController.Companion.mensaMenu
import org.mosad.seil0.projectlaogai.controller.CacheController.Companion.timetables
import org.mosad.seil0.projectlaogai.hsoparser.Meal
import org.mosad.seil0.projectlaogai.hsoparser.NotRetardedCalendar
import org.mosad.seil0.projectlaogai.hsoparser.TimetableDay
import org.mosad.seil0.projectlaogai.util.Meal
import org.mosad.seil0.projectlaogai.util.TimetableDay
import org.mosad.seil0.projectlaogai.uicomponents.DayCardView
import org.mosad.seil0.projectlaogai.uicomponents.MealLinearLayout
import org.mosad.seil0.projectlaogai.util.NotRetardedCalendar
import java.text.SimpleDateFormat
import java.util.*

4
app/src/main/java/org/mosad/seil0/projectlaogai/fragments/MensaFragment.kt

@ -37,10 +37,10 @@ import org.mosad.seil0.projectlaogai.controller.CacheController
import org.mosad.seil0.projectlaogai.controller.CacheController.Companion.mensaMenu
import org.mosad.seil0.projectlaogai.controller.PreferencesController.Companion.cShowBuffet
import org.mosad.seil0.projectlaogai.controller.TCoRAPIController
import org.mosad.seil0.projectlaogai.hsoparser.MensaWeek
import org.mosad.seil0.projectlaogai.hsoparser.NotRetardedCalendar
import org.mosad.seil0.projectlaogai.util.MensaWeek
import org.mosad.seil0.projectlaogai.uicomponents.DayCardView
import org.mosad.seil0.projectlaogai.uicomponents.MealLinearLayout
import org.mosad.seil0.projectlaogai.util.NotRetardedCalendar
/**
* The mensa controller class

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

@ -55,7 +55,7 @@ import org.mosad.seil0.projectlaogai.controller.PreferencesController.Companion.
import org.mosad.seil0.projectlaogai.controller.PreferencesController.Companion.cCourse
import org.mosad.seil0.projectlaogai.controller.PreferencesController.Companion.cShowBuffet
import org.mosad.seil0.projectlaogai.controller.TCoRAPIController
import org.mosad.seil0.projectlaogai.hsoparser.DataTypes
import org.mosad.seil0.projectlaogai.util.DataTypes
import java.util.*
/**

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

@ -40,9 +40,9 @@ import org.mosad.seil0.projectlaogai.controller.CacheController.Companion.timeta
import org.mosad.seil0.projectlaogai.controller.PreferencesController
import org.mosad.seil0.projectlaogai.controller.PreferencesController.Companion.cCourse
import org.mosad.seil0.projectlaogai.controller.TCoRAPIController
import org.mosad.seil0.projectlaogai.hsoparser.NotRetardedCalendar
import org.mosad.seil0.projectlaogai.uicomponents.AddLessonDialog
import org.mosad.seil0.projectlaogai.uicomponents.DayCardView
import org.mosad.seil0.projectlaogai.util.NotRetardedCalendar
/**
* The timetable controller class

2
app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/AddLessonDialog.kt

@ -37,7 +37,7 @@ import kotlinx.coroutines.runBlocking
import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.controller.CacheController
import org.mosad.seil0.projectlaogai.controller.TCoRAPIController
import org.mosad.seil0.projectlaogai.hsoparser.Course
import org.mosad.seil0.projectlaogai.util.Course
import java.util.stream.Collectors
/**

6
app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/DayCardView.kt

@ -28,8 +28,8 @@ import android.widget.LinearLayout
import androidx.cardview.widget.CardView
import kotlinx.android.synthetic.main.cardview_day.view.*
import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.hsoparser.DataTypes
import org.mosad.seil0.projectlaogai.hsoparser.TimetableDay
import org.mosad.seil0.projectlaogai.util.DataTypes
import org.mosad.seil0.projectlaogai.util.TimetableDay
import java.text.SimpleDateFormat
import java.util.*
@ -71,7 +71,7 @@ class DayCardView(context: Context) : CardView(context) {
if (lesson.lessonSubject.isNotEmpty()) {
val lessonLayout = LessonLinearLayout(context)
lessonLayout.setLesson(lesson, DataTypes().getTime()[tsIndex])
lessonLayout.setLesson(lesson, DataTypes().times[tsIndex])
linLayout_Day.addView(lessonLayout)
if (lesson != timeslot.last()) {

2
app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/LessonLinearLayout.kt

@ -28,7 +28,7 @@ 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
import org.mosad.seil0.projectlaogai.util.Lesson
class LessonLinearLayout(context: Context?) : LinearLayout(context) {

2
app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/MealLinearLayout.kt

@ -28,7 +28,7 @@ import android.widget.LinearLayout
import androidx.cardview.widget.CardView
import kotlinx.android.synthetic.main.linearlayout_meal.view.*
import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.hsoparser.Meal
import org.mosad.seil0.projectlaogai.util.Meal
class MealLinearLayout(context: Context?): LinearLayout(context) {

54
app/src/main/java/org/mosad/seil0/projectlaogai/hsoparser/DataTypes.kt → app/src/main/java/org/mosad/seil0/projectlaogai/util/DataTypes.kt

@ -20,11 +20,9 @@
*
*/
package org.mosad.seil0.projectlaogai.hsoparser
package org.mosad.seil0.projectlaogai.util
import android.graphics.Color
import org.mosad.seil0.projectlaogai.R
import java.util.*
import kotlin.collections.ArrayList
class DataTypes {
@ -60,7 +58,7 @@ class DataTypes {
Color.parseColor("#3F51B5"),
Color.parseColor("#3D5AFE"),
Color.parseColor("#2979FF"),
Color.parseColor("#00B0FF"),
Color.parseColor("#0096FF"),
Color.parseColor("#00E5FF"),
Color.parseColor("#1DE9B6"),
Color.parseColor("#00E676"),
@ -77,54 +75,6 @@ class DataTypes {
Dark("Dark"),
Black("Black")
}
init {
// do something
}
fun getTime(): Array<String> {
return times
}
}
class NotRetardedCalendar {
companion object {
private val calendar = Calendar.getInstance()
fun getDayOfWeekIndex(): Int {
return when (calendar.get(Calendar.DAY_OF_WEEK)) {
Calendar.MONDAY -> 0
Calendar.TUESDAY -> 1
Calendar.WEDNESDAY -> 2
Calendar.THURSDAY -> 3
Calendar.FRIDAY -> 4
Calendar.SATURDAY -> 5
Calendar.SUNDAY -> 6
else -> 7
}
}
fun getTomorrowWeekIndex(): Int {
return when (calendar.get(Calendar.DAY_OF_WEEK)) {
Calendar.MONDAY -> 1
Calendar.TUESDAY -> 2
Calendar.WEDNESDAY -> 3
Calendar.THURSDAY -> 4
Calendar.FRIDAY -> 5
Calendar.SATURDAY -> 6
Calendar.SUNDAY -> 0
else -> 7
}
}
fun getWeekOfYear(): Int {
return when (calendar.get(Calendar.DAY_OF_WEEK)) {
Calendar.SUNDAY -> Calendar.getInstance().get(Calendar.WEEK_OF_YEAR) - 1
else -> Calendar.getInstance().get(Calendar.WEEK_OF_YEAR)
}
}
}
}
// data classes for the course part

64
app/src/main/java/org/mosad/seil0/projectlaogai/util/NotRetardedCalendar.kt

@ -0,0 +1,64 @@
/**
* 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.util
import java.util.*
class NotRetardedCalendar {
companion object {
private val calendar = Calendar.getInstance()
fun getDayOfWeekIndex(): Int {
return when (calendar.get(Calendar.DAY_OF_WEEK)) {
Calendar.MONDAY -> 0
Calendar.TUESDAY -> 1
Calendar.WEDNESDAY -> 2
Calendar.THURSDAY -> 3
Calendar.FRIDAY -> 4
Calendar.SATURDAY -> 5
Calendar.SUNDAY -> 6
else -> 7
}
}
fun getTomorrowWeekIndex(): Int {
return when (calendar.get(Calendar.DAY_OF_WEEK)) {
Calendar.MONDAY -> 1
Calendar.TUESDAY -> 2
Calendar.WEDNESDAY -> 3
Calendar.THURSDAY -> 4
Calendar.FRIDAY -> 5
Calendar.SATURDAY -> 6
Calendar.SUNDAY -> 0
else -> 7
}
}
fun getWeekOfYear(): Int {
return when (calendar.get(Calendar.DAY_OF_WEEK)) {
Calendar.SUNDAY -> Calendar.getInstance().get(Calendar.WEEK_OF_YEAR) - 1
else -> Calendar.getInstance().get(Calendar.WEEK_OF_YEAR)
}
}
}
}

2
app/src/main/res/values-de-rDE/strings.xml

@ -53,7 +53,7 @@
<string name="primary_color">Primärfarbe</string>
<string name="primary_color_desc">Zum Ändern tippen, Standard ist Blaugrün.</string>
<string name="accent_color">Akzentfarbe</string>
<string name="accent_color_desc">Zum Ändern tippen, Standard ist Indigo.</string>
<string name="accent_color_desc">Zum Ändern tippen, Standard ist Hellblau.</string>
<string name="show_buffet">Buffet immer anzeigen</string>
<!-- dialogs -->

2
app/src/main/res/values/colors.xml

@ -2,7 +2,7 @@
<resources>
<color name="colorPrimary">#009688</color>
<color name="colorPrimaryDark">#009688</color>
<color name="colorAccent">#3f51b5</color>
<color name="colorAccent">#0096ff</color>
<color name="ic_launcher_background">#ffffff</color>
<!--theme color section, not the working colors-->

2
app/src/main/res/values/strings.xml

@ -58,7 +58,7 @@
<string name="primary_color">Primary color</string>
<string name="primary_color_desc">Tap to change, default is teal blue.</string>
<string name="accent_color">Accent color</string>
<string name="accent_color_desc">Tap to change, default is indigo.</string>
<string name="accent_color_desc">Tap to change, default is light blue.</string>
<string name="show_buffet">Always show buffet</string>
<!-- dialogs -->

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