tried to make changes to some live data, did not go well so rollback
This commit is contained in:
@@ -3,6 +3,8 @@ package com.odweta.solon
|
|||||||
import androidx.compose.animation.AnimatedContent
|
import androidx.compose.animation.AnimatedContent
|
||||||
import androidx.compose.animation.fadeIn
|
import androidx.compose.animation.fadeIn
|
||||||
import androidx.compose.animation.fadeOut
|
import androidx.compose.animation.fadeOut
|
||||||
|
import androidx.compose.animation.slideInHorizontally
|
||||||
|
import androidx.compose.animation.slideOutHorizontally
|
||||||
import androidx.compose.animation.slideInVertically
|
import androidx.compose.animation.slideInVertically
|
||||||
import androidx.compose.animation.slideOutVertically
|
import androidx.compose.animation.slideOutVertically
|
||||||
import androidx.compose.animation.togetherWith
|
import androidx.compose.animation.togetherWith
|
||||||
@@ -14,15 +16,18 @@ import androidx.compose.foundation.layout.padding
|
|||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.MutableState
|
import androidx.compose.runtime.MutableState
|
||||||
|
import androidx.compose.runtime.RecomposeScope
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
import com.odweta.solon.ui.theme.PastelYellow
|
import com.odweta.solon.ui.theme.PastelYellow
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
import java.util.concurrent.Callable
|
||||||
|
|
||||||
enum class Screen {
|
enum class Screen {
|
||||||
Main,
|
Main,
|
||||||
@@ -98,24 +103,6 @@ data class LectureNote(
|
|||||||
var lectureName: String
|
var lectureName: String
|
||||||
)
|
)
|
||||||
|
|
||||||
class LectureNoteOLD(id: Int, note: MutableState<String>, type: MutableState<LectureNoteType>, number: Int, lectureName: String) {
|
|
||||||
var id: Int = 0
|
|
||||||
var note: MutableState<String> =
|
|
||||||
mutableStateOf("")
|
|
||||||
var type: MutableState<LectureNoteType> =
|
|
||||||
mutableStateOf(LectureNoteType.Normal)
|
|
||||||
var number: Int = 0
|
|
||||||
var lectureName: String = ""
|
|
||||||
|
|
||||||
init {
|
|
||||||
this.id = id
|
|
||||||
this.note = note
|
|
||||||
this.type = type
|
|
||||||
this.number = number
|
|
||||||
this.lectureName = lectureName
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Subject {
|
class Subject {
|
||||||
lateinit var name: String
|
lateinit var name: String
|
||||||
lateinit var place: String
|
lateinit var place: String
|
||||||
@@ -288,7 +275,7 @@ var settings = SettingsData()
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun <T> Animate(targetState: T, content: @Composable (target: T) -> Unit) {
|
fun <T> Animate(targetState: T, content: @Composable (target: T) -> Unit) {
|
||||||
if (settings.useAnimations.checked.value) {
|
if (settings.useAnimations.checked.value == true) {
|
||||||
AnimatedContent(
|
AnimatedContent(
|
||||||
targetState = targetState,
|
targetState = targetState,
|
||||||
transitionSpec = {
|
transitionSpec = {
|
||||||
|
|||||||
@@ -8,11 +8,20 @@ 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
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.currentRecomposeScope
|
||||||
|
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.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.toArgb
|
import androidx.compose.ui.graphics.toArgb
|
||||||
|
import androidx.compose.ui.input.pointer.PointerIcon.Companion.Text
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
import com.odweta.solon.ui.theme.SolonTheme
|
import com.odweta.solon.ui.theme.SolonTheme
|
||||||
|
|
||||||
class MainActivity : ComponentActivity() {
|
class MainActivity : ComponentActivity() {
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ fun MarksAll() {
|
|||||||
.verticalScroll(scrollState)
|
.verticalScroll(scrollState)
|
||||||
) {
|
) {
|
||||||
for ((subject, markList) in global.marks) {
|
for ((subject, markList) in global.marks) {
|
||||||
val amoledModifier = if (settings.useAmoledMode.checked.value) {
|
val amoledModifier = if (settings.useAmoledMode.checked.value == true) {
|
||||||
Modifier
|
Modifier
|
||||||
.width(150.dp)
|
.width(150.dp)
|
||||||
.fillMaxHeight()
|
.fillMaxHeight()
|
||||||
@@ -324,7 +324,7 @@ fun MarksAll() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val amoledModifierBackground = if (settings.useAmoledMode.checked.value) {
|
val amoledModifierBackground = if (settings.useAmoledMode.checked.value == true) {
|
||||||
Modifier
|
Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.height(70.dp)
|
.height(70.dp)
|
||||||
@@ -354,7 +354,7 @@ fun MarksAll() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val amoledSpacerModifier = if (settings.useAmoledMode.checked.value) {
|
val amoledSpacerModifier = if (settings.useAmoledMode.checked.value == true) {
|
||||||
Modifier
|
Modifier
|
||||||
.width(10.dp)
|
.width(10.dp)
|
||||||
.fillMaxHeight()
|
.fillMaxHeight()
|
||||||
@@ -518,7 +518,7 @@ fun MarksSubject() {
|
|||||||
shape = RoundedCornerShape(global.dimens.roundedCorner)
|
shape = RoundedCornerShape(global.dimens.roundedCorner)
|
||||||
)
|
)
|
||||||
.background(
|
.background(
|
||||||
color = if (settings.useAmoledMode.checked.value) {
|
color = if (settings.useAmoledMode.checked.value == true) {
|
||||||
Color.Black
|
Color.Black
|
||||||
} else {
|
} else {
|
||||||
getAvgColor(
|
getAvgColor(
|
||||||
@@ -559,7 +559,7 @@ fun MarksSubject() {
|
|||||||
shape = RoundedCornerShape(global.dimens.roundedCorner)
|
shape = RoundedCornerShape(global.dimens.roundedCorner)
|
||||||
)
|
)
|
||||||
.background(
|
.background(
|
||||||
color = if (settings.useAmoledMode.checked.value) {
|
color = if (settings.useAmoledMode.checked.value == true) {
|
||||||
Color.Black
|
Color.Black
|
||||||
} else {
|
} else {
|
||||||
PastelYellowTransparent
|
PastelYellowTransparent
|
||||||
@@ -586,7 +586,7 @@ fun MarksSubject() {
|
|||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(horizontal = 5.dp)
|
.padding(horizontal = 5.dp)
|
||||||
.background(
|
.background(
|
||||||
color = if (settings.useAmoledMode.checked.value) {
|
color = if (settings.useAmoledMode.checked.value == true) {
|
||||||
Color.Black
|
Color.Black
|
||||||
} else {
|
} else {
|
||||||
getAvgColor(mark.grade)
|
getAvgColor(mark.grade)
|
||||||
@@ -666,7 +666,7 @@ fun MarksDetail() {
|
|||||||
shape = RoundedCornerShape(global.dimens.roundedCorner)
|
shape = RoundedCornerShape(global.dimens.roundedCorner)
|
||||||
)
|
)
|
||||||
.background(
|
.background(
|
||||||
if (settings.useAmoledMode.checked.value) {
|
if (settings.useAmoledMode.checked.value == true) {
|
||||||
Color.Black
|
Color.Black
|
||||||
} else {
|
} else {
|
||||||
getAvgColor(
|
getAvgColor(
|
||||||
@@ -702,7 +702,7 @@ fun MarksDetail() {
|
|||||||
shape = RoundedCornerShape(global.dimens.roundedCorner)
|
shape = RoundedCornerShape(global.dimens.roundedCorner)
|
||||||
)
|
)
|
||||||
.background(
|
.background(
|
||||||
if (settings.useAmoledMode.checked.value) {
|
if (settings.useAmoledMode.checked.value == true) {
|
||||||
Color.Black
|
Color.Black
|
||||||
} else {
|
} else {
|
||||||
PastelYellowTransparent
|
PastelYellowTransparent
|
||||||
@@ -719,7 +719,7 @@ fun MarksDetail() {
|
|||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(horizontal = 5.dp)
|
.padding(horizontal = 5.dp)
|
||||||
.background(
|
.background(
|
||||||
color = if (settings.useAmoledMode.checked.value) {
|
color = if (settings.useAmoledMode.checked.value == true) {
|
||||||
Color.Black
|
Color.Black
|
||||||
} else {
|
} else {
|
||||||
PastelYellowTransparent
|
PastelYellowTransparent
|
||||||
@@ -762,7 +762,7 @@ fun MarksDetail() {
|
|||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(horizontal = 5.dp)
|
.padding(horizontal = 5.dp)
|
||||||
.background(
|
.background(
|
||||||
color = if (settings.useAmoledMode.checked.value) {
|
color = if (settings.useAmoledMode.checked.value == true) {
|
||||||
Color.Black
|
Color.Black
|
||||||
} else {
|
} else {
|
||||||
PastelYellowTransparent
|
PastelYellowTransparent
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ fun NavbarScreen() {
|
|||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
var spacerModifier = 30.dp
|
var spacerModifier = 30.dp
|
||||||
if (settings.showRefreshButton.checked.value) {
|
if (settings.showRefreshButton.checked.value == true) {
|
||||||
spacerModifier = 15.dp
|
spacerModifier = 15.dp
|
||||||
Button(
|
Button(
|
||||||
onClick = {
|
onClick = {
|
||||||
|
|||||||
@@ -18,13 +18,22 @@ import androidx.compose.material3.SwitchColors
|
|||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
|
import androidx.compose.runtime.currentComposer
|
||||||
|
import androidx.compose.runtime.currentRecomposeScope
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
|
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.graphics.Color
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
|
import androidx.lifecycle.liveData
|
||||||
import com.odweta.solon.ui.theme.PastelYellow
|
import com.odweta.solon.ui.theme.PastelYellow
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun SettingsScreen() {
|
fun SettingsScreen() {
|
||||||
@@ -75,15 +84,9 @@ fun SettingsTableRow(setting: Setting) {
|
|||||||
Spacer(modifier = Modifier.weight(1f))
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
|
|
||||||
Switch(
|
Switch(
|
||||||
checked = setting.checked.value,
|
checked = setting.checked.value == true,
|
||||||
onCheckedChange = {
|
onCheckedChange = {
|
||||||
setting.checked.value = it
|
setting.checked.value = it
|
||||||
when (setting.id) {
|
|
||||||
SettingsId.Svoboda -> settings.useSvobodaMode = setting
|
|
||||||
SettingsId.Amoled -> settings.useAmoledMode = setting
|
|
||||||
SettingsId.RefreshButton -> settings.showRefreshButton = setting
|
|
||||||
SettingsId.Animations -> settings.useAnimations = setting
|
|
||||||
}
|
|
||||||
Util.saveStringToFile(global.filePaths.settings, settings.toString())
|
Util.saveStringToFile(global.filePaths.settings, settings.toString())
|
||||||
},
|
},
|
||||||
colors = SwitchColors(
|
colors = SwitchColors(
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ fun subjectModifier(d: Day, s: Subject, lectureNumber: Int): Modifier {
|
|||||||
global.currentLectureNumber = lectureNumber
|
global.currentLectureNumber = lectureNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
val m = if (settings.useAmoledMode.checked.value) {
|
val m = if (settings.useAmoledMode.checked.value == true) {
|
||||||
Modifier
|
Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.height(70.dp)
|
.height(70.dp)
|
||||||
@@ -359,7 +359,7 @@ private fun DayScreen(day: Day) {
|
|||||||
global.lectureNotes[lectureId]?.number = subject.number.toInt()
|
global.lectureNotes[lectureId]?.number = subject.number.toInt()
|
||||||
global.lectureNotes[lectureId]?.lectureName = subject.name
|
global.lectureNotes[lectureId]?.lectureName = subject.name
|
||||||
|
|
||||||
val amoledModifier = if (settings.useAmoledMode.checked.value) {
|
val amoledModifier = if (settings.useAmoledMode.checked.value == true) {
|
||||||
Modifier
|
Modifier
|
||||||
.width(50.dp)
|
.width(50.dp)
|
||||||
.fillMaxHeight()
|
.fillMaxHeight()
|
||||||
@@ -484,7 +484,7 @@ private fun DayScreen(day: Day) {
|
|||||||
.padding(vertical = 5.dp),
|
.padding(vertical = 5.dp),
|
||||||
contentAlignment = Alignment.Center
|
contentAlignment = Alignment.Center
|
||||||
) {
|
) {
|
||||||
if (settings.useSvobodaMode.checked.value) {
|
if (settings.useSvobodaMode.checked.value == true) {
|
||||||
if (
|
if (
|
||||||
subject.teacher == "Jindřich Svoboda" &&
|
subject.teacher == "Jindřich Svoboda" &&
|
||||||
global.studentClass == "5. G"
|
global.studentClass == "5. G"
|
||||||
|
|||||||
@@ -1,10 +1,21 @@
|
|||||||
package com.odweta.solon
|
package com.odweta.solon
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.widget.ImageView
|
||||||
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
|
import androidx.compose.animation.slideInHorizontally
|
||||||
|
import androidx.compose.animation.slideOutHorizontally
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.Upload
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.DisposableEffect
|
import androidx.compose.runtime.DisposableEffect
|
||||||
@@ -12,16 +23,22 @@ import androidx.compose.runtime.getValue
|
|||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
|
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.graphics.Color
|
||||||
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
|
import androidx.compose.ui.viewinterop.AndroidView
|
||||||
|
import com.bumptech.glide.Glide
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
|
||||||
|
private var showLoadingIcon by mutableStateOf(false)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ToolbarScreen() {
|
fun ToolbarScreen() {
|
||||||
// make the font size adaptive relative to the length of the user's name
|
// make the font size adaptive relative to the length of the user's name
|
||||||
@@ -43,12 +60,28 @@ fun ToolbarScreen() {
|
|||||||
toolbarTextSizeAdaptive = 10.sp
|
toolbarTextSizeAdaptive = 10.sp
|
||||||
}
|
}
|
||||||
|
|
||||||
Box(modifier = Modifier.padding(10.dp)) {
|
Animate(global.status) { targetText ->
|
||||||
Text(
|
Row(modifier = Modifier.padding(10.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.Center) {
|
||||||
text = global.status,
|
Text(
|
||||||
fontSize = toolbarTextSizeAdaptive,
|
text = targetText,
|
||||||
color = Color.White
|
fontSize = toolbarTextSizeAdaptive,
|
||||||
)
|
color = Color.White
|
||||||
|
)
|
||||||
|
|
||||||
|
if (settings.useAnimations.checked.value == true) {
|
||||||
|
AnimatedVisibility(showLoadingIcon) {
|
||||||
|
AndroidView(
|
||||||
|
modifier = Modifier.size(50.dp).padding(start = 10.dp),
|
||||||
|
factory = { context: Context -> ImageView(context) },
|
||||||
|
update = { imageView ->
|
||||||
|
Glide.with(imageView.context)
|
||||||
|
.load(R.drawable.loading)
|
||||||
|
.into(imageView)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,20 +113,14 @@ object StatusFactory: StatusFactoryInterface {
|
|||||||
StatusType.Loading -> {
|
StatusType.Loading -> {
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
global.refreshed = false
|
global.refreshed = false
|
||||||
val anim = listOf(
|
showStatus("Načítání nových dat")
|
||||||
"Načítání nových dat",
|
delay(100L)
|
||||||
"Načítání nových dat.",
|
showLoadingIcon = true
|
||||||
"Načítání nových dat..",
|
|
||||||
"Načítání nových dat...",
|
|
||||||
"Načítání nových dat..",
|
|
||||||
"Načítání nových dat."
|
|
||||||
)
|
|
||||||
var i = 0
|
|
||||||
while (!global.refreshed) {
|
while (!global.refreshed) {
|
||||||
if (i == anim.size) i = 0
|
showStatus("Načítání nových dat")
|
||||||
showStatus(anim[i++])
|
|
||||||
delay(300)
|
|
||||||
}
|
}
|
||||||
|
showLoadingIcon = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user