Skip to content

Commit

Permalink
Update project
Browse files Browse the repository at this point in the history
- Updated AGP to 8.4.1.
- Updated dependencies to latest to fix issues about Account feature.
- Rework UI for Basic Account Information.
- News filter settings will now only shown when enabled (this mean it will hidden at default).
  • Loading branch information
ZoeMeow1027 committed May 27, 2024
1 parent b355e17 commit e6972e0
Show file tree
Hide file tree
Showing 13 changed files with 177 additions and 130 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ dependencies {

implementation 'org.jetbrains.kotlinx:kotlinx-datetime:0.5.0'

implementation 'com.github.dutwrapper:dutwrapper-java:v1.9.0'
implementation 'com.github.dutwrapper:dutwrapper-java:484d2f6f4a'

implementation 'com.google.android.material:material:1.12.0'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.AccountCircle
import androidx.compose.material.icons.outlined.AccountCircle
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
Expand All @@ -18,17 +23,20 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import io.zoemeow.dutschedule.R
import io.zoemeow.dutschedule.ui.component.base.OutlinedTextBox
import io.zoemeow.dutschedule.utils.capitalized

@Composable
fun AccountInfoBanner(
context: Context,
padding: PaddingValues,
isLoading: Boolean = false,
name: String? = null,
username: String? = null,
schoolClass: String? = null,
trainingProgramPlan: String? = null,
specialization: String? = null,
opacity: Float = 1.0f
) {
Surface(
Expand All @@ -42,7 +50,7 @@ fun AccountInfoBanner(
.fillMaxWidth()
.wrapContentHeight()
.padding(10.dp),
horizontalAlignment = Alignment.Start,
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Top,
content = {
if (isLoading) {
Expand Down Expand Up @@ -74,20 +82,25 @@ fun AccountInfoBanner(
)
}
)
OutlinedTextBox(
title = "Username",
value = username ?: context.getString(R.string.data_unknown),
modifier = Modifier.fillMaxWidth().padding(bottom = 5.dp)
Icon(
Icons.Outlined.AccountCircle,
"Account Icon",
modifier = Modifier.size(64.dp)
)
OutlinedTextBox(
title = "Class",
value = schoolClass ?: context.getString(R.string.data_unknown),
modifier = Modifier.fillMaxWidth().padding(bottom = 5.dp)
Text(
name?.capitalized() ?: "(unknown name)",
fontSize = 20.sp,
modifier = Modifier.padding(top = 7.dp)
)
OutlinedTextBox(
title = "Training program plan",
value = trainingProgramPlan ?: context.getString(R.string.data_unknown),
modifier = Modifier.fillMaxWidth().padding(bottom = 5.dp)
Text(
"${username ?: "(unknown student ID)"} - ${schoolClass ?: "(unknown class)"}",
fontSize = 17.sp,
modifier = Modifier.padding(top = 5.dp)
)
Text(
specialization ?: "(unknown specialization)",
fontSize = 17.sp,
modifier = Modifier.padding(top = 5.dp)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,53 +54,57 @@ fun AccountSubjectMoreInformation(
// Subject study
Spacer(modifier = Modifier.size(15.dp))
ContentInBoxWithBorder(
title = "Schedule Study",
title = context.getString(R.string.account_subjectinfo_data_schedulestudy_title),
content = {
var schList = ""
item?.let {
schList = it.subjectStudy.scheduleList.joinToString(
separator = "; ",
transform = { item1 ->
"${CustomDateUtil.dayOfWeekInString(item1.dayOfWeek + 1)},${item1.lesson.start}-${item1.lesson.end},${item1.room}"
}
)
}
CustomText("Day of week: $schList")
var schWeek = ""
item?.let {
schWeek = it.subjectStudy.weekList.joinToString(
separator = "; ",
transform = { item1 ->
"${item1.start}-${item1.end}"
}
)
}
CustomText("Week range: $schWeek")
CustomText(context.getString(
R.string.account_subjectinfo_data_schedulestudy_dayofweek,
item?.let {
it.subjectStudy.scheduleList.joinToString(
separator = "; ",
transform = { item1 ->
"${CustomDateUtil.dayOfWeekInString(item1.dayOfWeek + 1)},${item1.lesson.start}-${item1.lesson.end},${item1.room}"
}
)
} ?: ""
))
CustomText(context.getString(
R.string.account_subjectinfo_data_schedulestudy_weekrange,
item?.let {
it.subjectStudy.weekList.joinToString(
separator = "; ",
transform = { item1 ->
"${item1.start}-${item1.end}"
}
)
} ?: ""
))
},
)
// Subject examination
Spacer(modifier = Modifier.size(15.dp))
ContentInBoxWithBorder(
title = "Schedule Examination",
title = context.getString(R.string.account_subjectinfo_data_scheduleexam_title),
content = {
if (item != null) {
CustomText(
"Group: ${item.subjectExam.group}" +
if (item.subjectExam.isGlobal) " (global exam)" else ""
)
CustomText(
"Date: ${
CustomDateUtil.dateUnixToString(
item.subjectExam.date,
"dd/MM/yyyy HH:mm",
"GMT+7"
)
}"
)
CustomText("Room: ${item.subjectExam.room}")

CustomText(context.getString(
R.string.account_subjectinfo_data_scheduleexam_group,
item.subjectExam.group,
if (item.subjectExam.isGlobal) context.getString(R.string.account_subjectinfo_data_scheduleexam_groupglobal) else ""
))
CustomText(context.getString(
R.string.account_subjectinfo_data_scheduleexam_date,
CustomDateUtil.dateUnixToString(
item.subjectExam.date,
"dd/MM/yyyy HH:mm",
"GMT+7"
)
))
CustomText(context.getString(
R.string.account_subjectinfo_data_scheduleexam_room,
item.subjectExam.room
))
} else {
CustomText("Currently no examination schedule yet for this subject.")
CustomText(context.getString(R.string.account_subjectinfo_data_scheduleexam_noexamdate))
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,10 @@ fun AccountMainView(
opacity = componentBackgroundAlpha,
padding = PaddingValues(10.dp),
isLoading = accInfo.processState.value == ProcessState.Running,
name = accInfo.data.value?.name,
username = accInfo.data.value?.studentId,
schoolClass = accInfo.data.value?.schoolClass,
trainingProgramPlan = accInfo.data.value?.trainingProgramPlan
specialization = accInfo.data.value?.specialization
)
}
ButtonBase(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fun AccountActivity.SubjectFee(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 15.dp)
.padding(vertical = 3.dp),
.padding(vertical = 2.dp),
horizontalAlignment = Alignment.CenterHorizontally,
content = {
Text(getMainViewModel().appSettings.value.currentSchoolYear.toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ fun AccountActivity.SubjectInformation(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 15.dp)
.padding(vertical = 3.dp),
.padding(vertical = 2.dp),
horizontalAlignment = Alignment.CenterHorizontally,
content = {
Text(getMainViewModel().appSettings.value.currentSchoolYear.toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fun AccountActivity.TrainingResult(
contentAlignment = Alignment.BottomCenter,
content = {
TopAppBar(
title = { Text("Account Training Result") },
title = { Text(context.getString(R.string.account_trainingstatus_title)) },
colors = TopAppBarDefaults.topAppBarColors(containerColor = Color.Transparent),
navigationIcon = {
IconButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fun AccountActivity.TrainingSubjectResult(

fun subjectResultToMap(item: SubjectResult): Map<String, String?> {
return mapOf(
"Subject Year" to (item.schoolYear ?: "(unknown)"),
"Subject Year" to "${item.schoolYear ?: "(unknown)"}${ if (item.isExtendedSemester) "in summer" else "" }",
"Subject Code" to (item.id ?: "(unknown)"),
"Credit" to item.credit.toString(),
"Point formula" to (item.pointFormula ?: "(unknown)"),
Expand Down Expand Up @@ -291,21 +291,21 @@ fun AccountActivity.TrainingSubjectResult(
backgroundColor = MaterialTheme.colorScheme.background.copy(alpha = getControlBackgroundAlpha()),
text = "Index",
textAlign = TextAlign.Center,
weight = 0.2f
weight = 0.17f
)
TableCell(
modifier = Modifier.fillMaxHeight(),
backgroundColor = MaterialTheme.colorScheme.background.copy(alpha = getControlBackgroundAlpha()),
text = "Subject name",
textAlign = TextAlign.Center,
weight = 0.6f
weight = 0.58f
)
TableCell(
modifier = Modifier.fillMaxHeight(),
backgroundColor = MaterialTheme.colorScheme.background.copy(alpha = getControlBackgroundAlpha()),
text = "Result (T4/C)",
text = "Result T10(T4)",
textAlign = TextAlign.Center,
weight = 0.2f
weight = 0.25f
)
}
)
Expand Down Expand Up @@ -337,26 +337,26 @@ fun AccountActivity.TrainingSubjectResult(
backgroundColor = MaterialTheme.colorScheme.background.copy(alpha = getControlBackgroundAlpha()),
text = "${subjectItem.index}",
textAlign = TextAlign.Center,
weight = 0.2f
weight = 0.17f
)
TableCell(
modifier = Modifier.fillMaxHeight(),
backgroundColor = MaterialTheme.colorScheme.background.copy(alpha = getControlBackgroundAlpha()),
text = subjectItem.name,
contentAlign = Alignment.CenterStart,
textAlign = TextAlign.Start,
weight = 0.6f
weight = 0.58f
)
TableCell(
modifier = Modifier.fillMaxHeight(),
backgroundColor = MaterialTheme.colorScheme.background.copy(alpha = getControlBackgroundAlpha()),
text = String.format(
"%s (%s)",
if (subjectItem.resultT4 != null) "${subjectItem.resultT4}" else "---",
if (subjectItem.resultByCharacter != null) "${subjectItem.resultByCharacter}" else "-"
subjectItem.resultT10?.toString() ?: "---",
subjectItem.resultT4?.toString() ?: "---"
),
textAlign = TextAlign.Center,
weight = 0.2f
weight = 0.25f
)
}
)
Expand Down
Loading

0 comments on commit e6972e0

Please sign in to comment.