Compare commits
2 Commits
30ad4bed64
...
50eb19a464
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
50eb19a464 | ||
|
|
4c3de94dd3 |
@@ -7,21 +7,23 @@ 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.border
|
import androidx.compose.foundation.border
|
||||||
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.horizontalScroll
|
import androidx.compose.foundation.horizontalScroll
|
||||||
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.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.defaultMinSize
|
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
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.rememberScrollState
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
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.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.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
@@ -31,6 +33,10 @@ import androidx.compose.material3.Text
|
|||||||
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.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.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.text.style.TextDecoration
|
import androidx.compose.ui.text.style.TextDecoration
|
||||||
@@ -56,7 +62,7 @@ class StundenplanActivity : ComponentActivity() {
|
|||||||
|
|
||||||
//Loading saved lessons when NOT auto-loading the setup
|
//Loading saved lessons when NOT auto-loading the setup
|
||||||
if (setupDone) {
|
if (setupDone) {
|
||||||
listOfDays.forEachIndexed() { index, dayLessons ->
|
listOfDays.forEachIndexed { index, dayLessons ->
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
getLessons(this@StundenplanActivity, dayLessons).collect { savedLessons ->
|
getLessons(this@StundenplanActivity, dayLessons).collect { savedLessons ->
|
||||||
lessons[index] = savedLessons.toMutableList()
|
lessons[index] = savedLessons.toMutableList()
|
||||||
@@ -102,7 +108,11 @@ fun StundenplanContent(activity: ComponentActivity, loadedLessons: List<List<Les
|
|||||||
listOfBreakLengths.add(sharedPreferences.getInt("break${i}Length", 0))
|
listOfBreakLengths.add(sharedPreferences.getInt("break${i}Length", 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
Column() {
|
var showInfo by remember {
|
||||||
|
mutableStateOf(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(MaterialTheme.colorScheme.primaryContainer),
|
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(MaterialTheme.colorScheme.primaryContainer),
|
||||||
title = {
|
title = {
|
||||||
@@ -121,6 +131,16 @@ fun StundenplanContent(activity: ComponentActivity, loadedLessons: List<List<Les
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions ={
|
actions ={
|
||||||
|
//Info button
|
||||||
|
IconButton(
|
||||||
|
onClick = { showInfo = !showInfo }) {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Outlined.Info,
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier.size(28.dp),
|
||||||
|
tint = MaterialTheme.colorScheme.onPrimaryContainer
|
||||||
|
)
|
||||||
|
}
|
||||||
//Edit button
|
//Edit button
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
@@ -157,16 +177,18 @@ fun StundenplanContent(activity: ComponentActivity, loadedLessons: List<List<Les
|
|||||||
)
|
)
|
||||||
|
|
||||||
//Creation of 5 Columns
|
//Creation of 5 Columns
|
||||||
loadedLessons.forEachIndexed() { index, dailyLessons ->
|
loadedLessons.forEachIndexed { index, dailyLessons ->
|
||||||
Column(modifier = Modifier.wrapContentWidth()) {
|
//Width variable for variable Box sizes
|
||||||
|
Column(modifier = Modifier.width(250.dp)) {
|
||||||
//Additional extraIndex to count lessons without breaks getting into the way
|
//Additional extraIndex to count lessons without breaks getting into the way
|
||||||
var extraIndex = 0
|
var extraIndex = 0
|
||||||
|
|
||||||
//Box with the day on top of each Column()
|
//Box with the day on top of each Column()
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(200.dp, 50.dp)
|
.size(250.dp, 50.dp)
|
||||||
.padding(3.dp)
|
.padding(3.dp)
|
||||||
|
.align(Alignment.CenterHorizontally)
|
||||||
.border(
|
.border(
|
||||||
width = 1.dp,
|
width = 1.dp,
|
||||||
color = MaterialTheme.colorScheme.primaryContainer
|
color = MaterialTheme.colorScheme.primaryContainer
|
||||||
@@ -186,8 +208,7 @@ fun StundenplanContent(activity: ComponentActivity, loadedLessons: List<List<Les
|
|||||||
if (listOfBreakIndexes.indexOf(i) != -1) {
|
if (listOfBreakIndexes.indexOf(i) != -1) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(200.dp, 100.dp)
|
.size(250.dp, 100.dp)
|
||||||
.padding(3.dp)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
//Else creation of a Box containing all the information from the LessonData object
|
//Else creation of a Box containing all the information from the LessonData object
|
||||||
@@ -211,6 +232,29 @@ fun StundenplanContent(activity: ComponentActivity, loadedLessons: List<List<Les
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (showInfo) {
|
||||||
|
AlertDialog(
|
||||||
|
onDismissRequest = { showInfo = false },
|
||||||
|
text = {
|
||||||
|
Text(
|
||||||
|
text = "Die Breite der Spalten ist auf eine bestimmte Größe festgelegt.\n\n" +
|
||||||
|
"Zu lange eingaben können horizontal gescrollt werden.",
|
||||||
|
color = MaterialTheme.colorScheme.onPrimaryContainer,
|
||||||
|
style = MaterialTheme.typography.labelMedium)
|
||||||
|
},
|
||||||
|
confirmButton = {
|
||||||
|
Text(
|
||||||
|
text = "Schließen",
|
||||||
|
color = MaterialTheme.colorScheme.secondary,
|
||||||
|
style = MaterialTheme.typography.labelMedium,
|
||||||
|
modifier = Modifier.clickable { showInfo = false }
|
||||||
|
)
|
||||||
|
},
|
||||||
|
containerColor = MaterialTheme.colorScheme.primaryContainer,
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(5.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Data class to save objects via DataShare containing information about lessons
|
//Data class to save objects via DataShare containing information about lessons
|
||||||
@@ -225,21 +269,51 @@ data class LessonData(
|
|||||||
// contains the information from the corresponding LessonData object
|
// contains the information from the corresponding LessonData object
|
||||||
@Composable
|
@Composable
|
||||||
fun LessonBox(subject: String, teacher: String, room: String) {
|
fun LessonBox(subject: String, teacher: String, room: String) {
|
||||||
Box(modifier = Modifier
|
Box(
|
||||||
.defaultMinSize(200.dp, 100.dp)
|
modifier = Modifier
|
||||||
|
.size(250.dp, 100.dp)
|
||||||
.padding(3.dp)
|
.padding(3.dp)
|
||||||
.border(
|
.border(
|
||||||
width = 1.dp,
|
width = 1.dp,
|
||||||
color = MaterialTheme.colorScheme.onPrimaryContainer
|
color = MaterialTheme.colorScheme.onPrimaryContainer
|
||||||
)
|
),
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
) {
|
) {
|
||||||
|
Column {
|
||||||
|
if (subject != "") {
|
||||||
Text(
|
Text(
|
||||||
modifier = Modifier.align(Alignment.Center),
|
modifier = Modifier
|
||||||
text = "$subject\n@$room\n/w$teacher",
|
.horizontalScroll(rememberScrollState())
|
||||||
|
.align(Alignment.CenterHorizontally)
|
||||||
|
.padding(horizontal = 5.dp),
|
||||||
|
text = subject,
|
||||||
|
style = MaterialTheme.typography.labelMedium
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (room != "") {
|
||||||
|
Text(
|
||||||
|
modifier = Modifier
|
||||||
|
.horizontalScroll(rememberScrollState())
|
||||||
|
.align(Alignment.CenterHorizontally)
|
||||||
|
.padding(horizontal = 5.dp),
|
||||||
|
text = room,
|
||||||
|
style = MaterialTheme.typography.labelMedium
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (teacher != "") {
|
||||||
|
Text(
|
||||||
|
modifier = Modifier
|
||||||
|
.horizontalScroll(rememberScrollState())
|
||||||
|
.align(Alignment.CenterHorizontally)
|
||||||
|
.padding(horizontal = 5.dp),
|
||||||
|
text = teacher,
|
||||||
style = MaterialTheme.typography.labelMedium
|
style = MaterialTheme.typography.labelMedium
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//Left-/Right-Handed info Column
|
//Left-/Right-Handed info Column
|
||||||
@Composable
|
@Composable
|
||||||
@@ -314,8 +388,8 @@ fun InfoColumn(loadedLessons: List<List<LessonData>>, breakAmnt: Int, breaksStar
|
|||||||
lessonTimeIncrement += breaksLength[breaksStartTime.indexOf(breakTime)]
|
lessonTimeIncrement += breaksLength[breaksStartTime.indexOf(breakTime)]
|
||||||
//Add info that one moe brake exists to the indexing increment
|
//Add info that one moe brake exists to the indexing increment
|
||||||
lessonNegIncrement++
|
lessonNegIncrement++
|
||||||
//Add the extraIndex (overallIndex) into the listOfBreakIndexes list to include breaks in timetable core
|
//Add the extraIndex (lessonIndex) into the listOfBreakIndexes list to include breaks in timetable core
|
||||||
listOfBreakIndexes.add(extraIndex)
|
listOfBreakIndexes.add(i)
|
||||||
//Prevent double creation of Boxes
|
//Prevent double creation of Boxes
|
||||||
loopDone = true
|
loopDone = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -495,7 +495,7 @@ fun TimeTableSetupContent(activity: ComponentActivity, loadedLessons: List<Lesso
|
|||||||
lessons = lessons.drop(1)
|
lessons = lessons.drop(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
lessons.forEachIndexed() { index, lessonData ->
|
lessons.forEachIndexed { index, lessonData ->
|
||||||
//Input variables
|
//Input variables
|
||||||
var currentSubject by remember {
|
var currentSubject by remember {
|
||||||
mutableStateOf(lessonData.subject)
|
mutableStateOf(lessonData.subject)
|
||||||
@@ -574,7 +574,7 @@ fun TimeTableSetupContent(activity: ComponentActivity, loadedLessons: List<Lesso
|
|||||||
.background(color = MaterialTheme.colorScheme.onPrimaryContainer)
|
.background(color = MaterialTheme.colorScheme.onPrimaryContainer)
|
||||||
)
|
)
|
||||||
|
|
||||||
Row () {
|
Row {
|
||||||
Text(
|
Text(
|
||||||
text = "Ertes Setup beendet?",
|
text = "Ertes Setup beendet?",
|
||||||
modifier = Modifier.align(Alignment.CenterVertically),
|
modifier = Modifier.align(Alignment.CenterVertically),
|
||||||
|
|||||||
Reference in New Issue
Block a user