From 4c3de94dd35bece4d0dd928733f15e569286df5e Mon Sep 17 00:00:00 2001 From: matthias Date: Sat, 8 Jun 2024 14:15:43 +0200 Subject: [PATCH] Stundenplan bugfixes fixed indexing with wrong variable for breaks in core added compatibility for lessons without subject, room or teacher added horizontal scroll for too long user input added info icon with alert dialog for scroll explanation --- .../cleverclass/StundenplanActivity.kt | 120 ++++++++++++++---- 1 file changed, 97 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/com/schoolapp/cleverclass/StundenplanActivity.kt b/app/src/main/java/com/schoolapp/cleverclass/StundenplanActivity.kt index 18504e5..2b78efe 100644 --- a/app/src/main/java/com/schoolapp/cleverclass/StundenplanActivity.kt +++ b/app/src/main/java/com/schoolapp/cleverclass/StundenplanActivity.kt @@ -7,21 +7,23 @@ import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.foundation.border +import androidx.compose.foundation.clickable import androidx.compose.foundation.horizontalScroll import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.defaultMinSize import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.wrapContentWidth +import androidx.compose.foundation.layout.width import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ArrowBack import androidx.compose.material.icons.outlined.Edit +import androidx.compose.material.icons.outlined.Info +import androidx.compose.material3.AlertDialog import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.IconButton @@ -31,6 +33,10 @@ import androidx.compose.material3.Text import androidx.compose.material3.TopAppBar import androidx.compose.material3.TopAppBarDefaults import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.text.style.TextDecoration @@ -56,7 +62,7 @@ class StundenplanActivity : ComponentActivity() { //Loading saved lessons when NOT auto-loading the setup if (setupDone) { - listOfDays.forEachIndexed() { index, dayLessons -> + listOfDays.forEachIndexed { index, dayLessons -> CoroutineScope(Dispatchers.IO).launch { getLessons(this@StundenplanActivity, dayLessons).collect { savedLessons -> lessons[index] = savedLessons.toMutableList() @@ -102,7 +108,11 @@ fun StundenplanContent(activity: ComponentActivity, loadedLessons: List - Column(modifier = Modifier.wrapContentWidth()) { + loadedLessons.forEachIndexed { index, dailyLessons -> + //Width variable for variable Box sizes + Column(modifier = Modifier.width(250.dp)) { //Additional extraIndex to count lessons without breaks getting into the way var extraIndex = 0 //Box with the day on top of each Column() Box( modifier = Modifier - .size(200.dp, 50.dp) + .size(250.dp, 50.dp) .padding(3.dp) + .align(Alignment.CenterHorizontally) .border( width = 1.dp, color = MaterialTheme.colorScheme.primaryContainer @@ -186,8 +208,7 @@ fun StundenplanContent(activity: ComponentActivity, loadedLessons: List>, breakAmnt: Int, breaksStartTime: List, firstLesson: String, lessonLength: Int, breaksLength: List) { @@ -314,8 +388,8 @@ fun InfoColumn(loadedLessons: List>, breakAmnt: Int, breaksStar lessonTimeIncrement += breaksLength[breaksStartTime.indexOf(breakTime)] //Add info that one moe brake exists to the indexing increment lessonNegIncrement++ - //Add the extraIndex (overallIndex) into the listOfBreakIndexes list to include breaks in timetable core - listOfBreakIndexes.add(extraIndex) + //Add the extraIndex (lessonIndex) into the listOfBreakIndexes list to include breaks in timetable core + listOfBreakIndexes.add(i) //Prevent double creation of Boxes loopDone = true }