Stundenplan commit for meeting
Setup most definitely done Display still has some issues
This commit is contained in:
@@ -2,9 +2,11 @@ package com.schoolapp.cleverclass
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.graphics.drawable.Icon
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
@@ -13,6 +15,7 @@ import androidx.compose.foundation.layout.padding
|
|||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.ArrowBack
|
import androidx.compose.material.icons.filled.ArrowBack
|
||||||
|
import androidx.compose.material.icons.outlined.Edit
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
@@ -29,15 +32,17 @@ import androidx.compose.runtime.remember
|
|||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.core.content.ContextCompat.startActivity
|
||||||
import com.schoolapp.cleverclass.LessonStoreManager.getLessons
|
import com.schoolapp.cleverclass.LessonStoreManager.getLessons
|
||||||
import com.schoolapp.cleverclass.ui.theme.CleverClassTheme
|
import com.schoolapp.cleverclass.ui.theme.CleverClassTheme
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
private val listOfDays = listOf("mon", "tue", "wed", "thu", "fri", "sat", "sun")
|
private val listOfDays = listOf("Mo", "Di", "Mi", "Do", "Fr")
|
||||||
private val lessonGrabberIndex = 0
|
private val lessonGrabberIndex = 0
|
||||||
|
|
||||||
class StundenplanActivity : ComponentActivity() {
|
class StundenplanActivity : ComponentActivity() {
|
||||||
@@ -89,6 +94,21 @@ fun StundenplanContent(activity: ComponentActivity){
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
actions ={
|
||||||
|
IconButton(onClick = {
|
||||||
|
val intent = Intent(activity, TimeTableSetupActivity::class.java).apply {
|
||||||
|
putExtra(TimeTableSetupActivity.TYPE_KEY, "TimeSetup")
|
||||||
|
}
|
||||||
|
startActivity(activity, intent, null)
|
||||||
|
}) {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Outlined.Edit,
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier.size(28.dp),
|
||||||
|
tint = MaterialTheme.colorScheme.onPrimaryContainer
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier.fillMaxWidth()
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -101,9 +121,9 @@ fun StundenplanContent(activity: ComponentActivity){
|
|||||||
}
|
}
|
||||||
|
|
||||||
data class LessonData(
|
data class LessonData(
|
||||||
val subject: String,
|
var subject: String,
|
||||||
val teacher: String,
|
var teacher: String,
|
||||||
val room: String
|
var room: String
|
||||||
)
|
)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -116,8 +136,8 @@ fun Day(day: String) {
|
|||||||
lessons = savedLessons.toMutableList()
|
lessons = savedLessons.toMutableList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lessons.forEach() {
|
lessons.forEach() {lessonData ->
|
||||||
Lesson(subject = it.subject, teacher = it.teacher, room = it.room)
|
Lesson(subject = lessonData.subject, teacher = lessonData.teacher, room = lessonData.room)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,7 +148,8 @@ fun Lesson(subject: String, teacher: String, room: String) {
|
|||||||
.size(200.dp, 100.dp)
|
.size(200.dp, 100.dp)
|
||||||
.padding(3.dp)
|
.padding(3.dp)
|
||||||
) {
|
) {
|
||||||
Text(modifier = Modifier.align(Alignment.Center),
|
Text(
|
||||||
|
modifier = Modifier.align(Alignment.Center),
|
||||||
text = "$subject\n@$room\n/w$teacher")
|
text = "$subject\n@$room\n/w$teacher")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,11 +7,8 @@ import android.icu.text.DecimalFormat
|
|||||||
import android.icu.text.DecimalFormatSymbols
|
import android.icu.text.DecimalFormatSymbols
|
||||||
import android.icu.util.Calendar
|
import android.icu.util.Calendar
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.widget.TimePicker
|
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.compose.foundation.Image
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
@@ -47,51 +44,74 @@ import androidx.compose.material3.TextFieldDefaults
|
|||||||
import androidx.compose.material3.TopAppBar
|
import androidx.compose.material3.TopAppBar
|
||||||
import androidx.compose.material3.TopAppBarDefaults
|
import androidx.compose.material3.TopAppBarDefaults
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.currentCompositionLocalContext
|
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.scale
|
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.res.painterResource
|
|
||||||
import androidx.compose.ui.text.input.KeyboardType
|
import androidx.compose.ui.text.input.KeyboardType
|
||||||
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
|
||||||
import androidx.compose.ui.text.input.VisualTransformation
|
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.schoolapp.cleverclass.ui.theme.CleverClassTheme
|
import com.schoolapp.cleverclass.ui.theme.CleverClassTheme
|
||||||
import com.schoolapp.cleverclass.ui.theme.InputPrimaryColor
|
import com.schoolapp.cleverclass.ui.theme.InputPrimaryColor
|
||||||
import com.schoolapp.cleverclass.ui.theme.InputSecondaryColor
|
import com.schoolapp.cleverclass.ui.theme.InputSecondaryColor
|
||||||
import org.intellij.lang.annotations.JdkConstants.CalendarMonth
|
|
||||||
import android.text.format.DateFormat
|
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.material.icons.outlined.Edit
|
import androidx.compose.material.icons.outlined.Edit
|
||||||
|
import androidx.compose.material.ripple.LocalRippleTheme
|
||||||
|
import androidx.compose.material.ripple.RippleAlpha
|
||||||
|
import androidx.compose.material.ripple.RippleTheme
|
||||||
import androidx.compose.material3.FilledTonalButton
|
import androidx.compose.material3.FilledTonalButton
|
||||||
import androidx.compose.material3.OutlinedButton
|
import androidx.compose.material3.OutlinedButton
|
||||||
import androidx.compose.material3.TextButton
|
|
||||||
import androidx.compose.ui.focus.focusModifier
|
|
||||||
import androidx.compose.ui.text.TextStyle
|
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import android.app.Activity
|
|
||||||
import androidx.compose.material3.Checkbox
|
import androidx.compose.material3.Checkbox
|
||||||
import androidx.compose.material3.Tab
|
import androidx.compose.material3.Tab
|
||||||
import androidx.compose.material3.TabRow
|
import androidx.compose.material3.TabRow
|
||||||
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
import androidx.core.content.ContextCompat.startActivity
|
import androidx.core.content.ContextCompat.startActivity
|
||||||
import com.schoolapp.cleverclass.PSEActivity
|
import com.schoolapp.cleverclass.LessonStoreManager.getLessons
|
||||||
import kotlinx.coroutines.selects.select
|
import com.schoolapp.cleverclass.LessonStoreManager.saveLessons
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
private lateinit var activityType : String
|
private lateinit var activityType : String
|
||||||
|
private lateinit var activityState : String
|
||||||
|
private val listOfDays = listOf("Mo", "Di", "Mi", "Do", "Fr")
|
||||||
|
|
||||||
|
private class CustomRippleTheme : RippleTheme {
|
||||||
|
@Composable
|
||||||
|
override fun defaultColor(): Color = Color.Unspecified
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
override fun rippleAlpha(): RippleAlpha = RippleAlpha(
|
||||||
|
draggedAlpha = 0f,
|
||||||
|
focusedAlpha = 0f,
|
||||||
|
hoveredAlpha = 0f,
|
||||||
|
pressedAlpha = 0f
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
class TimeTableSetupActivity : ComponentActivity() {
|
class TimeTableSetupActivity : ComponentActivity() {
|
||||||
companion object{
|
companion object{
|
||||||
const val TYPE_KEY = "type_key"
|
const val TYPE_KEY = "type_key"
|
||||||
|
const val STATE_KEY = "state_key"
|
||||||
}
|
}
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
activityType = intent.getStringExtra(TYPE_KEY).toString()
|
activityType = intent.getStringExtra(TYPE_KEY).toString()
|
||||||
|
activityState = intent.getStringExtra(STATE_KEY).toString()
|
||||||
|
|
||||||
|
var lessons = listOf<LessonData>()
|
||||||
|
|
||||||
|
if (activityType == "DaySetup") {
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
getLessons(this@TimeTableSetupActivity, listOfDays[activityState.toInt()]).collect { savedLessons ->
|
||||||
|
lessons = savedLessons.toList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setContent {
|
setContent {
|
||||||
CleverClassTheme {
|
CleverClassTheme {
|
||||||
@@ -99,7 +119,7 @@ class TimeTableSetupActivity : ComponentActivity() {
|
|||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
color = MaterialTheme.colorScheme.background
|
color = MaterialTheme.colorScheme.background
|
||||||
) {
|
) {
|
||||||
TimeTableSetupContent(activity = this)
|
TimeTableSetupContent(activity = this, lessons)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,7 +130,7 @@ class TimeTableSetupActivity : ComponentActivity() {
|
|||||||
// Content of TimeTableSetup
|
// Content of TimeTableSetup
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun TimeTableSetupContent(activity: ComponentActivity){
|
fun TimeTableSetupContent(activity: ComponentActivity, loadedLessons: List<LessonData>){
|
||||||
val inputFieldColors = TextFieldDefaults.outlinedTextFieldColors(
|
val inputFieldColors = TextFieldDefaults.outlinedTextFieldColors(
|
||||||
textColor = MaterialTheme.colorScheme.onPrimaryContainer,
|
textColor = MaterialTheme.colorScheme.onPrimaryContainer,
|
||||||
containerColor = MaterialTheme.colorScheme.secondaryContainer,
|
containerColor = MaterialTheme.colorScheme.secondaryContainer,
|
||||||
@@ -149,7 +169,10 @@ fun TimeTableSetupContent(activity: ComponentActivity){
|
|||||||
mutableStateOf(false)
|
mutableStateOf(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
val listOfDays = listOf("Mo", "Di", "Mi", "Do", "Fr")
|
var lessons by remember {
|
||||||
|
mutableStateOf(loadedLessons)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
@@ -192,6 +215,13 @@ fun TimeTableSetupContent(activity: ComponentActivity){
|
|||||||
|
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
|
|
||||||
|
IconButton(onClick = { showInfo = !showInfo }) {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Outlined.Info,
|
||||||
|
contentDescription = null,
|
||||||
|
tint = MaterialTheme.colorScheme.onPrimaryContainer
|
||||||
|
)
|
||||||
|
}
|
||||||
if (activityType == "Settings")
|
if (activityType == "Settings")
|
||||||
IconButton(onClick = { showDeleteConfirmation = !showDeleteConfirmation }) {
|
IconButton(onClick = { showDeleteConfirmation = !showDeleteConfirmation }) {
|
||||||
Icon(
|
Icon(
|
||||||
@@ -201,14 +231,6 @@ fun TimeTableSetupContent(activity: ComponentActivity){
|
|||||||
tint = MaterialTheme.colorScheme.onPrimaryContainer
|
tint = MaterialTheme.colorScheme.onPrimaryContainer
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else if (activityType == "TimeSetup")
|
|
||||||
IconButton(onClick = { showInfo = !showInfo }) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Outlined.Info,
|
|
||||||
contentDescription = null,
|
|
||||||
tint = MaterialTheme.colorScheme.onPrimaryContainer
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
@@ -237,7 +259,9 @@ fun TimeTableSetupContent(activity: ComponentActivity){
|
|||||||
symbols.decimalSeparator = ':'
|
symbols.decimalSeparator = ':'
|
||||||
val decimalFormat = DecimalFormat("00.00", symbols)
|
val decimalFormat = DecimalFormat("00.00", symbols)
|
||||||
|
|
||||||
Text(decimalFormat.format(firstLesson) + " Uhr ")
|
Text(
|
||||||
|
text = decimalFormat.format(firstLesson) + " Uhr ",
|
||||||
|
color = MaterialTheme.colorScheme.onPrimaryContainer)
|
||||||
|
|
||||||
Icon(imageVector = Icons.Outlined.Edit, contentDescription = null)
|
Icon(imageVector = Icons.Outlined.Edit, contentDescription = null)
|
||||||
}
|
}
|
||||||
@@ -247,11 +271,7 @@ fun TimeTableSetupContent(activity: ComponentActivity){
|
|||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
value = lessonLength,
|
value = lessonLength,
|
||||||
onValueChange = { lessonLength = it },
|
onValueChange = { lessonLength = it },
|
||||||
label = {
|
label = { Text(text = "Länge einer Schulstunde in min") },
|
||||||
Text(
|
|
||||||
text = "Länge einer Schulstunde in min"
|
|
||||||
)
|
|
||||||
},
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
singleLine = true,
|
singleLine = true,
|
||||||
shape = RoundedCornerShape(20),
|
shape = RoundedCornerShape(20),
|
||||||
@@ -265,11 +285,7 @@ fun TimeTableSetupContent(activity: ComponentActivity){
|
|||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
value = breakAmnt,
|
value = breakAmnt,
|
||||||
onValueChange = { breakAmnt = it},
|
onValueChange = { breakAmnt = it},
|
||||||
label = {
|
label = { Text(text = "Anzahl der Pausen") },
|
||||||
Text(
|
|
||||||
text = "Anzahl der Pausen"
|
|
||||||
)
|
|
||||||
},
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
singleLine = true,
|
singleLine = true,
|
||||||
shape = RoundedCornerShape(20),
|
shape = RoundedCornerShape(20),
|
||||||
@@ -278,7 +294,7 @@ fun TimeTableSetupContent(activity: ComponentActivity){
|
|||||||
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.NumberPassword)
|
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.NumberPassword)
|
||||||
)
|
)
|
||||||
|
|
||||||
if (breakAmnt != "0" && breakAmnt != "") {
|
if (breakAmnt != "") {
|
||||||
for (i in 0 until breakAmnt.toInt()) {
|
for (i in 0 until breakAmnt.toInt()) {
|
||||||
var currentBrakeStartTime by remember{
|
var currentBrakeStartTime by remember{
|
||||||
mutableStateOf(sharedPreferences.getFloat("Brake${i}StartTime", 0.0f))
|
mutableStateOf(sharedPreferences.getFloat("Brake${i}StartTime", 0.0f))
|
||||||
@@ -312,7 +328,11 @@ fun TimeTableSetupContent(activity: ComponentActivity){
|
|||||||
symbols.decimalSeparator = ':'
|
symbols.decimalSeparator = ':'
|
||||||
val decimalFormat = DecimalFormat("00.00", symbols)
|
val decimalFormat = DecimalFormat("00.00", symbols)
|
||||||
|
|
||||||
Text(decimalFormat.format(currentBrakeStartTime) + " Uhr ")
|
Text(
|
||||||
|
text = decimalFormat.format(currentBrakeStartTime) + " Uhr ",
|
||||||
|
color = MaterialTheme.colorScheme.onPrimaryContainer,
|
||||||
|
style = MaterialTheme.typography.labelMedium
|
||||||
|
)
|
||||||
|
|
||||||
Icon(imageVector = Icons.Outlined.Edit, contentDescription = null)
|
Icon(imageVector = Icons.Outlined.Edit, contentDescription = null)
|
||||||
}
|
}
|
||||||
@@ -324,11 +344,7 @@ fun TimeTableSetupContent(activity: ComponentActivity){
|
|||||||
onValueChange = {
|
onValueChange = {
|
||||||
currentBrakeLength = it
|
currentBrakeLength = it
|
||||||
editor.putInt("Brake${i}Length", currentBrakeLength.toInt())},
|
editor.putInt("Brake${i}Length", currentBrakeLength.toInt())},
|
||||||
label = {
|
label = { Text(text = "Länge der ${i + 1}. Pause in min") },
|
||||||
Text(
|
|
||||||
text = "Länge der ${i + 1}. Pause in min"
|
|
||||||
)
|
|
||||||
},
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
singleLine = true,
|
singleLine = true,
|
||||||
shape = RoundedCornerShape(20),
|
shape = RoundedCornerShape(20),
|
||||||
@@ -351,7 +367,7 @@ fun TimeTableSetupContent(activity: ComponentActivity){
|
|||||||
.weight(1f)
|
.weight(1f)
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = "Abbrechen",
|
text = "Zurück",
|
||||||
color = MaterialTheme.colorScheme.secondary,
|
color = MaterialTheme.colorScheme.secondary,
|
||||||
style = MaterialTheme.typography.labelMedium
|
style = MaterialTheme.typography.labelMedium
|
||||||
)
|
)
|
||||||
@@ -364,16 +380,12 @@ fun TimeTableSetupContent(activity: ComponentActivity){
|
|||||||
Button(
|
Button(
|
||||||
onClick = {
|
onClick = {
|
||||||
editor.putInt("lessonLength", lessonLength.toInt())
|
editor.putInt("lessonLength", lessonLength.toInt())
|
||||||
if (breakAmnt == "0") {
|
editor.putInt("breakAmnt", breakAmnt.toInt())
|
||||||
editor.putInt("breakAmnt", -1)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
editor.putInt("breakAmnt", breakAmnt.toInt())
|
|
||||||
}
|
|
||||||
editor.apply()
|
editor.apply()
|
||||||
activity.finish()
|
activity.finish()
|
||||||
val intent = Intent(activity, TimeTableSetupActivity::class.java).apply {
|
val intent = Intent(activity, TimeTableSetupActivity::class.java).apply {
|
||||||
putExtra(TimeTableSetupActivity.TYPE_KEY, "DaySetup")
|
putExtra(TimeTableSetupActivity.TYPE_KEY, "DaySetup")
|
||||||
|
putExtra(TimeTableSetupActivity.STATE_KEY, "0")
|
||||||
}
|
}
|
||||||
startActivity(activity, intent, null)
|
startActivity(activity, intent, null)
|
||||||
},
|
},
|
||||||
@@ -390,59 +402,153 @@ fun TimeTableSetupContent(activity: ComponentActivity){
|
|||||||
}
|
}
|
||||||
else if (activityType == "DaySetup") {
|
else if (activityType == "DaySetup") {
|
||||||
var state by remember {
|
var state by remember {
|
||||||
mutableStateOf(0)
|
mutableStateOf(activityState.toInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
TabRow(selectedTabIndex = state,
|
var currentLessonAmount by remember {
|
||||||
containerColor = MaterialTheme.colorScheme.primaryContainer) {
|
mutableStateOf(sharedPreferences.getInt("lessonAmount${listOfDays[state]}", 0).toString())
|
||||||
for (day in listOfDays) {
|
}
|
||||||
Tab(selected = false,
|
|
||||||
onClick = {
|
CompositionLocalProvider(LocalRippleTheme provides CustomRippleTheme()) {
|
||||||
state = listOfDays.indexOf(day) },
|
TabRow(selectedTabIndex = state,
|
||||||
modifier = Modifier.padding(5.dp),
|
containerColor = MaterialTheme.colorScheme.primaryContainer) {
|
||||||
) {
|
for (day in listOfDays) {
|
||||||
Text(
|
Tab(selected = false,
|
||||||
text = day,
|
onClick = {},
|
||||||
color = MaterialTheme.colorScheme.onPrimaryContainer,
|
modifier = Modifier.padding(5.dp)
|
||||||
style = MaterialTheme.typography.labelMedium
|
) {
|
||||||
)
|
Text(
|
||||||
|
text = day,
|
||||||
|
color = MaterialTheme.colorScheme.onPrimaryContainer,
|
||||||
|
style = MaterialTheme.typography.labelMedium
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sharedPreferences.getInt("AnzahlStunden${day}", 0)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
when (state) {
|
|
||||||
0 -> {
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
Text(text = "Montag")
|
|
||||||
|
OutlinedTextField(
|
||||||
|
value = currentLessonAmount,
|
||||||
|
onValueChange = {
|
||||||
|
currentLessonAmount = it
|
||||||
|
if (currentLessonAmount == "") {
|
||||||
|
editor.putInt("lessonAmount${listOfDays[state]}", 0)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
editor.putInt("lessonAmount${listOfDays[state]}", currentLessonAmount.toInt())
|
||||||
|
}
|
||||||
|
},
|
||||||
|
label = { Text(text = "Anzahl der Schulstunden (${listOfDays[state]})") },
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
singleLine = true,
|
||||||
|
shape = RoundedCornerShape(20),
|
||||||
|
textStyle = MaterialTheme.typography.labelMedium,
|
||||||
|
colors = inputFieldColors,
|
||||||
|
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.NumberPassword)
|
||||||
|
)
|
||||||
|
|
||||||
|
if (currentLessonAmount != "") {
|
||||||
|
for (i in lessons.size until currentLessonAmount.toInt()) {
|
||||||
|
lessons = lessons + LessonData("", "", "")
|
||||||
}
|
}
|
||||||
1 -> {
|
while (currentLessonAmount.toInt() < lessons.size) {
|
||||||
Text(text = "Dienstag")
|
lessons = lessons.drop(1)
|
||||||
}
|
}
|
||||||
2 -> {
|
lessons.forEachIndexed() { index, lessonData ->
|
||||||
Text(text = "Mittwoch")
|
var currentSubject by remember {
|
||||||
}
|
mutableStateOf(lessonData.subject)
|
||||||
3 -> {
|
}
|
||||||
Text(text = "Donnerstag")
|
var currentTeacher by remember {
|
||||||
}
|
mutableStateOf(lessonData.teacher)
|
||||||
4 -> {
|
}
|
||||||
Text(text = "Freitag")
|
var currentRoom by remember {
|
||||||
}
|
mutableStateOf(lessonData.room)
|
||||||
}
|
}
|
||||||
Row () {
|
OutlinedTextField(
|
||||||
Text(
|
value = currentSubject,
|
||||||
text = "Setup beendet? ",
|
onValueChange = {
|
||||||
modifier = Modifier.align(Alignment.CenterVertically),
|
currentSubject = it
|
||||||
style = MaterialTheme.typography.labelMedium
|
lessonData.subject = it
|
||||||
|
saveLessonsUsage(activity, lessons, state)
|
||||||
|
},
|
||||||
|
label = { Text(text = "Fach der ${index + 1}. Stunde") },
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
singleLine = true,
|
||||||
|
shape = RoundedCornerShape(20),
|
||||||
|
textStyle = MaterialTheme.typography.labelMedium,
|
||||||
|
colors = inputFieldColors,
|
||||||
)
|
)
|
||||||
Checkbox(checked = setupDone, onCheckedChange = {setupDone = !setupDone})
|
OutlinedTextField(
|
||||||
|
value = currentTeacher,
|
||||||
|
onValueChange = {
|
||||||
|
currentTeacher = it
|
||||||
|
lessonData.teacher = it
|
||||||
|
saveLessonsUsage(activity, lessons, state)
|
||||||
|
},
|
||||||
|
label = { Text(text = "Lehrer der ${index + 1}. Stunde") },
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
singleLine = true,
|
||||||
|
shape = RoundedCornerShape(20),
|
||||||
|
textStyle = MaterialTheme.typography.labelMedium,
|
||||||
|
colors = inputFieldColors,
|
||||||
|
)
|
||||||
|
OutlinedTextField(
|
||||||
|
value = currentRoom,
|
||||||
|
onValueChange = {
|
||||||
|
currentRoom = it
|
||||||
|
lessonData.room = it
|
||||||
|
saveLessonsUsage(activity, lessons, state)
|
||||||
|
},
|
||||||
|
label = { Text(text = "Raum der ${index + 1}. Stunde") },
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
singleLine = true,
|
||||||
|
shape = RoundedCornerShape(20),
|
||||||
|
textStyle = MaterialTheme.typography.labelMedium,
|
||||||
|
colors = inputFieldColors,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
|
if (state == 4) {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.height(2.dp)
|
||||||
|
.fillMaxWidth()
|
||||||
|
.background(color = MaterialTheme.colorScheme.onPrimaryContainer)
|
||||||
|
)
|
||||||
|
|
||||||
|
Row () {
|
||||||
|
Text(
|
||||||
|
text = "Ertes Setup beendet?",
|
||||||
|
modifier = Modifier.align(Alignment.CenterVertically),
|
||||||
|
style = MaterialTheme.typography.labelMedium
|
||||||
|
)
|
||||||
|
Checkbox(checked = setupDone, onCheckedChange = {setupDone = !setupDone})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
FilledTonalButton(
|
FilledTonalButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
activity.finish()
|
activity.finish()
|
||||||
val intent = Intent(activity, TimeTableSetupActivity::class.java).apply {
|
if (state == 0) {
|
||||||
putExtra(TimeTableSetupActivity.TYPE_KEY, "TimeSetup")
|
val intent = Intent(activity, TimeTableSetupActivity::class.java).apply {
|
||||||
|
putExtra(TimeTableSetupActivity.TYPE_KEY, "TimeSetup")
|
||||||
|
}
|
||||||
|
startActivity(activity, intent, null)
|
||||||
}
|
}
|
||||||
startActivity(activity, intent, null)
|
else {
|
||||||
|
val intent = Intent(activity, TimeTableSetupActivity::class.java).apply {
|
||||||
|
putExtra(TimeTableSetupActivity.TYPE_KEY, "DaySetup")
|
||||||
|
putExtra(TimeTableSetupActivity.STATE_KEY, "${state - 1}")
|
||||||
|
}
|
||||||
|
startActivity(activity, intent, null)
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(5.dp)
|
.padding(5.dp)
|
||||||
@@ -461,16 +567,25 @@ fun TimeTableSetupContent(activity: ComponentActivity){
|
|||||||
|
|
||||||
Button(
|
Button(
|
||||||
onClick = {
|
onClick = {
|
||||||
editor.putBoolean("setupDone", setupDone)
|
|
||||||
editor.apply()
|
|
||||||
activity.finish()
|
activity.finish()
|
||||||
|
if (state != 4) {
|
||||||
|
val intent = Intent(activity, TimeTableSetupActivity::class.java).apply {
|
||||||
|
putExtra(TimeTableSetupActivity.TYPE_KEY, "DaySetup")
|
||||||
|
putExtra(TimeTableSetupActivity.STATE_KEY, "${state + 1}")
|
||||||
|
}
|
||||||
|
startActivity(activity, intent, null)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
editor.putBoolean("setupDone", setupDone)
|
||||||
|
}
|
||||||
|
editor.apply()
|
||||||
},
|
},
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(5.dp)
|
.padding(5.dp)
|
||||||
.weight(1f)
|
.weight(1f)
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = "Speichern",
|
text = "Weiter",
|
||||||
style = MaterialTheme.typography.labelMedium
|
style = MaterialTheme.typography.labelMedium
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -549,3 +664,9 @@ fun TestButton(text: String, onClick: ()-> Unit){
|
|||||||
Text(text = text)
|
Text(text = text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun saveLessonsUsage(context: Context, lessons: List<LessonData>, int: Int) {
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
saveLessons(context, lessons, listOfDays[int])
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user