moved the refresh button to the navbar
This commit is contained in:
@@ -12,8 +12,8 @@ android {
|
||||
applicationId = "com.odweta.solon"
|
||||
minSdk = 28
|
||||
targetSdk = 34
|
||||
versionCode = 204
|
||||
versionName = "2.1"
|
||||
versionCode = 205
|
||||
versionName = "2.1.1"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
@@ -22,7 +22,7 @@ android {
|
||||
this.outputs
|
||||
.map { it as com.android.build.gradle.internal.api.ApkVariantOutputImpl }
|
||||
.forEach { output ->
|
||||
var apkName = "com.odweta.solon_" + this.versionName + ".apk"
|
||||
val apkName = "com.odweta.solon_" + this.versionName + ".apk"
|
||||
output.outputFileName = apkName
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ class SettingsData {
|
||||
override fun toString() = "$useSvobodaMode\n$useAmoledMode\n$showRefreshButton"
|
||||
}
|
||||
|
||||
var settingsData: SettingsData = SettingsData()
|
||||
var settings : SettingsData = SettingsData()
|
||||
|
||||
var done: Boolean = false
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.odweta.solon
|
||||
|
||||
import android.content.Context
|
||||
import android.widget.Toast
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.delay
|
||||
@@ -167,7 +168,7 @@ private suspend fun launchPhase1(ctx: Context) {
|
||||
|
||||
// set the settings
|
||||
if (Util.fileExists(settingsDataFilePath) && !Util.fileIsEmpty(settingsDataFilePath)) {
|
||||
settingsData = Util.stringToSettingsData(Util.fileToString(settingsDataFilePath))
|
||||
settings = Util.stringToSettingsData(Util.fileToString(settingsDataFilePath))
|
||||
} // else load the default settigns
|
||||
|
||||
// continue to launch phase 2
|
||||
@@ -290,4 +291,8 @@ private fun launchPhase2(ctx: Context) {
|
||||
|
||||
// set the main content view
|
||||
screenToShow.value = Screen.Main
|
||||
|
||||
if (settings.showRefreshButton.checked.value) {
|
||||
refreshButtonContentColor.value = Color.White
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.odweta.solon
|
||||
|
||||
import android.util.Log
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
@@ -46,7 +45,6 @@ import com.odweta.solon.ui.theme.PastelRed
|
||||
import com.odweta.solon.ui.theme.PastelRedTransparent
|
||||
import com.odweta.solon.ui.theme.PastelYellow
|
||||
import com.odweta.solon.ui.theme.PastelYellowTransparent
|
||||
import kotlin.math.round
|
||||
|
||||
enum class MarksShow {
|
||||
All,
|
||||
@@ -115,7 +113,7 @@ fun MarksAll() {
|
||||
.verticalScroll(scrollState)
|
||||
) {
|
||||
for ((subject, markList) in marks) {
|
||||
val amoledModifier = if (settingsData.useAmoledMode.checked.value) {
|
||||
val amoledModifier = if (settings.useAmoledMode.checked.value) {
|
||||
Modifier
|
||||
.width(150.dp)
|
||||
.fillMaxHeight()
|
||||
@@ -134,7 +132,7 @@ fun MarksAll() {
|
||||
)
|
||||
}
|
||||
|
||||
val amoledModifierBackground = if (settingsData.useAmoledMode.checked.value) {
|
||||
val amoledModifierBackground = if (settings.useAmoledMode.checked.value) {
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.height(70.dp)
|
||||
@@ -161,7 +159,7 @@ fun MarksAll() {
|
||||
}
|
||||
}
|
||||
|
||||
val amoledSpacerModifier = if (settingsData.useAmoledMode.checked.value) {
|
||||
val amoledSpacerModifier = if (settings.useAmoledMode.checked.value) {
|
||||
Modifier
|
||||
.width(10.dp)
|
||||
.fillMaxHeight()
|
||||
@@ -297,7 +295,7 @@ fun MarksSubject() {
|
||||
),
|
||||
shape = RoundedCornerShape(roundedCornerDimen)
|
||||
)
|
||||
.background(color = if (settingsData.useAmoledMode.checked.value) {
|
||||
.background(color = if (settings.useAmoledMode.checked.value) {
|
||||
Color.Black
|
||||
} else {
|
||||
getAvgColor(
|
||||
@@ -337,7 +335,7 @@ fun MarksSubject() {
|
||||
color = PastelYellow,
|
||||
shape = RoundedCornerShape(roundedCornerDimen)
|
||||
)
|
||||
.background(color = if (settingsData.useAmoledMode.checked.value) {
|
||||
.background(color = if (settings.useAmoledMode.checked.value) {
|
||||
Color.Black
|
||||
} else {
|
||||
PastelYellowTransparent
|
||||
@@ -359,7 +357,7 @@ fun MarksSubject() {
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 5.dp)
|
||||
.background(color = if (settingsData.useAmoledMode.checked.value) {
|
||||
.background(color = if (settings.useAmoledMode.checked.value) {
|
||||
Color.Black
|
||||
} else {
|
||||
getAvgColor(
|
||||
@@ -465,7 +463,7 @@ fun MarksDetail() {
|
||||
shape = RoundedCornerShape(roundedCornerDimen)
|
||||
)
|
||||
.background(
|
||||
if (settingsData.useAmoledMode.checked.value) {
|
||||
if (settings.useAmoledMode.checked.value) {
|
||||
Color.Black
|
||||
} else {
|
||||
getAvgColor(
|
||||
@@ -501,7 +499,7 @@ fun MarksDetail() {
|
||||
color = PastelYellow,
|
||||
shape = RoundedCornerShape(roundedCornerDimen)
|
||||
)
|
||||
.background(if (settingsData.useAmoledMode.checked.value) {
|
||||
.background(if (settings.useAmoledMode.checked.value) {
|
||||
Color.Black
|
||||
} else {
|
||||
PastelYellowTransparent
|
||||
@@ -519,7 +517,7 @@ fun MarksDetail() {
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 5.dp)
|
||||
.background(
|
||||
color = if (settingsData.useAmoledMode.checked.value) {
|
||||
color = if (settings.useAmoledMode.checked.value) {
|
||||
Color.Black
|
||||
} else {
|
||||
PastelYellowTransparent
|
||||
@@ -562,7 +560,7 @@ fun MarksDetail() {
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 5.dp)
|
||||
.background(
|
||||
color = if (settingsData.useAmoledMode.checked.value) {
|
||||
color = if (settings.useAmoledMode.checked.value) {
|
||||
Color.Black
|
||||
} else {
|
||||
PastelYellowTransparent
|
||||
|
||||
@@ -9,6 +9,7 @@ import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Menu
|
||||
import androidx.compose.material.icons.filled.Refresh
|
||||
import androidx.compose.material.icons.filled.Schedule
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
@@ -16,24 +17,54 @@ import androidx.compose.material3.Icon
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.odweta.solon.ui.theme.PastelYellow
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
||||
private var timetableColor: MutableState<Color> = mutableStateOf(PastelYellow)
|
||||
private var marksColor: MutableState<Color> = mutableStateOf(Color.White)
|
||||
private var menuColor: MutableState<Color> = mutableStateOf(Color.White)
|
||||
var refreshButtonContentColor: MutableState<Color> = mutableStateOf(Color.White)
|
||||
|
||||
@Composable
|
||||
fun NavbarScreen(modifier: Modifier = Modifier) {
|
||||
val ctx = LocalContext.current
|
||||
val coscope = rememberCoroutineScope()
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.Center,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
var spacerModifier = 30.dp
|
||||
if (settings.showRefreshButton.checked.value) {
|
||||
spacerModifier = 15.dp
|
||||
Button(
|
||||
onClick = {
|
||||
fetchNewData(ctx, coscope)
|
||||
refreshButtonContentColor.value = PastelYellow
|
||||
},
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
contentColor = refreshButtonContentColor.value,
|
||||
containerColor = Color.Black
|
||||
)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Refresh,
|
||||
contentDescription = "Refresh Button",
|
||||
modifier = Modifier.size(25.dp)
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.width(spacerModifier))
|
||||
}
|
||||
|
||||
Button(
|
||||
onClick = {
|
||||
isShowing.value = IsShowing.Timetable
|
||||
@@ -53,7 +84,7 @@ fun NavbarScreen(modifier: Modifier = Modifier) {
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.width(30.dp))
|
||||
Spacer(modifier = Modifier.width(spacerModifier))
|
||||
|
||||
Button(
|
||||
onClick = {
|
||||
@@ -75,7 +106,7 @@ fun NavbarScreen(modifier: Modifier = Modifier) {
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.width(30.dp))
|
||||
Spacer(modifier = Modifier.width(spacerModifier))
|
||||
|
||||
Button(
|
||||
onClick = {
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
package com.odweta.solon
|
||||
|
||||
import android.util.Log
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.gestures.scrollable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
@@ -28,13 +25,10 @@ import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.SwitchColors
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalUriHandler
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextDecoration
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.odweta.solon.ui.theme.PastelYellow
|
||||
@@ -85,15 +79,15 @@ fun SettingsScreen(modifier: Modifier = Modifier) {
|
||||
|
||||
Spacer(Modifier.height(10.dp))
|
||||
|
||||
SettingsTableRow(settingsData.useSvobodaMode)
|
||||
SettingsTableRow(settings.useSvobodaMode)
|
||||
|
||||
Spacer(Modifier.height(10.dp))
|
||||
|
||||
SettingsTableRow(settingsData.useAmoledMode)
|
||||
SettingsTableRow(settings.useAmoledMode)
|
||||
|
||||
Spacer(Modifier.height(10.dp))
|
||||
|
||||
SettingsTableRow(settingsData.showRefreshButton)
|
||||
SettingsTableRow(settings.showRefreshButton)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,11 +114,11 @@ fun SettingsTableRow(setting: Setting) {
|
||||
onCheckedChange = {
|
||||
setting.checked.value = it
|
||||
when (setting.id) {
|
||||
SettingsId.Svoboda -> settingsData.useSvobodaMode = setting
|
||||
SettingsId.Amoled -> settingsData.useAmoledMode = setting
|
||||
SettingsId.RefreshButton -> settingsData.showRefreshButton = setting
|
||||
SettingsId.Svoboda -> settings.useSvobodaMode = setting
|
||||
SettingsId.Amoled -> settings.useAmoledMode = setting
|
||||
SettingsId.RefreshButton -> settings.showRefreshButton = setting
|
||||
}
|
||||
Util.saveStringToFile(settingsDataFilePath, settingsData.toString())
|
||||
Util.saveStringToFile(settingsDataFilePath, settings.toString())
|
||||
},
|
||||
colors = SwitchColors(
|
||||
uncheckedThumbColor = Color.Black,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.odweta.solon
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.graphics.drawable.Drawable
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
@@ -28,19 +27,16 @@ import androidx.compose.material.icons.filled.Refresh
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Shapes
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.RectangleShape
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.font.FontStyle
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.odweta.solon.ui.theme.PastelGreen
|
||||
@@ -62,9 +58,9 @@ fun TimetableScreen() {
|
||||
contentAlignment = Alignment.BottomCenter
|
||||
) {
|
||||
DayPager()
|
||||
if (settingsData.showRefreshButton.checked.value) {
|
||||
RefreshButton()
|
||||
}
|
||||
//if (settings.showRefreshButton.checked.value) {
|
||||
// RefreshButton()
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,8 +76,8 @@ fun DayPager(modifier: Modifier = Modifier) {
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun RefreshButton(modifier: Modifier = Modifier) {
|
||||
//@Composable
|
||||
/*fun RefreshButton(modifier: Modifier = Modifier) {
|
||||
val coscope = rememberCoroutineScope()
|
||||
val ctx = LocalContext.current
|
||||
|
||||
@@ -94,6 +90,7 @@ fun RefreshButton(modifier: Modifier = Modifier) {
|
||||
onClick = {
|
||||
coscope.launch {
|
||||
fetchNewData(ctx, coscope)
|
||||
|
||||
}
|
||||
},
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
@@ -116,6 +113,7 @@ fun RefreshButton(modifier: Modifier = Modifier) {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
private fun getSubjectColor(s: Subject, transparent: Boolean): Color {
|
||||
return if (s.free) {
|
||||
@@ -170,7 +168,7 @@ fun subjectModifier(d: Day, s: Subject, lectureNumber: Int): Modifier {
|
||||
currentLectureNumber = lectureNumber
|
||||
}
|
||||
|
||||
val m = if (settingsData.useAmoledMode.checked.value) {
|
||||
val m = if (settings.useAmoledMode.checked.value) {
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.height(70.dp)
|
||||
@@ -231,7 +229,7 @@ private fun DayScreen(day: Day) {
|
||||
.verticalScroll(scrollState)
|
||||
) {
|
||||
for (subject in day.subjects) {
|
||||
val amoledModifier = if (settingsData.useAmoledMode.checked.value) {
|
||||
val amoledModifier = if (settings.useAmoledMode.checked.value) {
|
||||
Modifier
|
||||
.width(50.dp)
|
||||
.fillMaxHeight()
|
||||
@@ -354,7 +352,7 @@ private fun DayScreen(day: Day) {
|
||||
.padding(vertical = 5.dp),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
if (settingsData.useSvobodaMode.checked.value) {
|
||||
if (settings.useSvobodaMode.checked.value) {
|
||||
if (
|
||||
subject.teacher == "Jindřich Svoboda" &&
|
||||
studentClass == "5. G"
|
||||
@@ -400,10 +398,9 @@ private fun DayScreen(day: Day) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: remove when added settings to turn the refresh button on/off
|
||||
if (settingsData.showRefreshButton.checked.value) {
|
||||
Spacer(modifier = Modifier.height(90.dp))
|
||||
}
|
||||
//if (settings.showRefreshButton.checked.value) {
|
||||
// Spacer(modifier = Modifier.height(90.dp))
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user