Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/src/main/java/kg/oshsu/myedu/BackgroundSyncWorker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class BackgroundSyncWorker(appContext: Context, workerParams: WorkerParameters)
private fun getLocalizedContext(context: Context, prefs: PrefsManager): Context {
// Updated to use "app_language" key from your PrefsManager
val lang = prefs.getAppLanguage()
val locale = Locale(lang)
val locale = Locale.forLanguageTag(lang) // Replaced deprecated constructor
Locale.setDefault(locale)
val config = Configuration(context.resources.configuration)
config.setLocale(locale)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/kg/oshsu/myedu/LocaleHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import java.util.Locale

object LocaleHelper {
fun setLocale(context: Context, languageCode: String): ContextWrapper {
val locale = Locale(languageCode)
val locale = Locale.forLanguageTag(languageCode) // Replaced deprecated constructor
Locale.setDefault(locale)
val config = context.resources.configuration
config.setLocale(locale)
Expand Down
8 changes: 3 additions & 5 deletions app/src/main/java/kg/oshsu/myedu/MainViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -515,10 +515,8 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
try { val news = NetworkClient.api.getNews(); withContext(Dispatchers.Main) { newsList = news; prefs?.saveList("news_list", news) } } catch (_: Exception) {}
try { val pay = NetworkClient.api.getPayStatus(); withContext(Dispatchers.Main) { payStatus = pay; prefs?.saveData("pay_status", pay) } } catch (_: Exception) {}

if (profile != null) {
loadScheduleNetwork(profile)
fetchSessionSuspend(profile)
}
loadScheduleNetwork(profile)
fetchSessionSuspend(profile)
}

private suspend fun loadScheduleNetwork(profile: StudentInfoResponse) {
Expand Down Expand Up @@ -876,4 +874,4 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {

data class Quadruple(val info: String, val transcript: String, val linkId: Long, val qr: String)
data class QuintuplePlusOne(val info: String, val license: String, val univ: String, val linkId: Long, val qr: String, val key: String)
}
}
67 changes: 48 additions & 19 deletions app/src/main/java/kg/oshsu/myedu/ui/screens/DocumentsScreens.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kg.oshsu.myedu.ui.screens

import android.content.ClipData
import androidx.compose.animation.*
import androidx.compose.animation.core.*
import androidx.compose.foundation.BorderStroke
Expand All @@ -16,10 +17,10 @@ import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.platform.ClipEntry
import androidx.compose.ui.platform.LocalClipboard
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
Expand All @@ -32,6 +33,7 @@ import kg.oshsu.myedu.TranscriptSubject
import kg.oshsu.myedu.MarkList
import kg.oshsu.myedu.ExamRule
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
Expand All @@ -49,18 +51,26 @@ fun ReferenceView(
animatedVisibilityScope: AnimatedVisibilityScope
) {
val context = LocalContext.current
val clipboardManager = LocalClipboardManager.current
val clipboard = LocalClipboard.current // Updated to LocalClipboard
val scope = rememberCoroutineScope() // Needed for suspend clipboard calls
val user = vm.userData
val profile = vm.profileData
val mov = profile?.studentMovement

// Get current language for data localization
val currentLang = vm.language

DisposableEffect(Unit) {
onDispose { vm.resetDocumentState() }
}

val activeSemester = profile?.active_semester ?: 1
val course = (activeSemester + 1) / 2
val facultyName = mov?.faculty?.let { it.name_en ?: it.name_ru } ?: mov?.speciality?.faculty?.let { it.name_en ?: it.name_ru } ?: "-"

val facultyName = mov?.faculty?.getName(currentLang)
?: mov?.speciality?.faculty?.getName(currentLang)
?: "-"

val datePattern = stringResource(R.string.config_date_format)

val progressAnim = remember { Animatable(0f) }
Expand Down Expand Up @@ -163,40 +173,49 @@ fun ReferenceView(
) {
Icon(Icons.Default.PictureAsPdf, null)
Spacer(Modifier.width(8.dp))
Text("Open PDF")
Text(stringResource(R.string.open_pdf))
}
Spacer(Modifier.height(4.dp))
Text(
text = "Saved to Downloads as ${vm.savedPdfName}",
text = stringResource(R.string.saved_to_downloads, vm.savedPdfName ?: ""),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.outline,
textAlign = TextAlign.Center
)
}
PdfUiState.ERROR -> {
Text(
text = vm.pdfStatusMessage ?: "Unknown Error",
text = vm.pdfStatusMessage ?: stringResource(R.string.error_unknown),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.error,
textAlign = TextAlign.Center,
modifier = Modifier.padding(bottom = 12.dp)
)
Row(horizontalArrangement = Arrangement.spacedBy(16.dp)) {
// FIX: Pre-fetch string resource outside the lambda
val noErrorMsg = stringResource(R.string.no_error_msg)
val errorMessage = vm.pdfStatusMessage ?: noErrorMsg

OutlinedButton(
onClick = { clipboardManager.setText(AnnotatedString(vm.pdfStatusMessage ?: "No Error Msg")) },
onClick = {
scope.launch {
val clipData = ClipData.newPlainText("Error Logs", errorMessage)
clipboard.setClipEntry(ClipEntry(clipData))
}
},
modifier = Modifier.weight(1f)
) {
Icon(Icons.Default.ContentCopy, null)
Spacer(Modifier.width(8.dp))
Text("Copy Logs")
Text(stringResource(R.string.copy_logs))
}
Button(
onClick = { vm.resetDocumentState() },
modifier = Modifier.weight(1f)
) {
Icon(Icons.Default.Refresh, null)
Spacer(Modifier.width(8.dp))
Text("Retry")
Text(stringResource(R.string.retry))
}
}
}
Expand Down Expand Up @@ -227,9 +246,9 @@ fun ReferenceView(

RefDetailRow(stringResource(R.string.student_id), "${user?.id}")
RefDetailRow(stringResource(R.string.faculty), facultyName)
RefDetailRow(stringResource(R.string.speciality), mov?.speciality?.name_en ?: "-")
RefDetailRow(stringResource(R.string.speciality), mov?.speciality?.getName(currentLang) ?: "-")
RefDetailRow(stringResource(R.string.year_of_study), "$course ($activeSemester ${stringResource(R.string.semester)})")
RefDetailRow(stringResource(R.string.edu_form), mov?.edu_form?.name_en ?: "-")
RefDetailRow(stringResource(R.string.edu_form), mov?.edu_form?.getName(currentLang) ?: "-")

val contractLabel = stringResource(R.string.contract)
val budgetLabel = stringResource(R.string.budget)
Expand Down Expand Up @@ -263,7 +282,8 @@ fun TranscriptView(
animatedVisibilityScope: AnimatedVisibilityScope
) {
val context = LocalContext.current
val clipboardManager = LocalClipboardManager.current
val clipboard = LocalClipboard.current // Updated
val scope = rememberCoroutineScope() // Added
val isTransitionComplete = remember { mutableStateOf(false) }

LaunchedEffect(Unit) {
Expand Down Expand Up @@ -353,19 +373,28 @@ fun TranscriptView(
}
PdfUiState.SUCCESS -> {
Button(onClick = { vm.openPdf(context, vm.savedPdfUri!!) }, modifier = Modifier.fillMaxWidth()) {
Icon(Icons.Default.PictureAsPdf, null); Spacer(Modifier.width(8.dp)); Text("Open PDF")
Icon(Icons.Default.PictureAsPdf, null); Spacer(Modifier.width(8.dp)); Text(stringResource(R.string.open_pdf))
}
Spacer(Modifier.height(4.dp))
Text(text = "Saved to Downloads as ${vm.savedPdfName}", style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.outline, textAlign = TextAlign.Center)
Text(text = stringResource(R.string.saved_to_downloads, vm.savedPdfName ?: ""), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.outline, textAlign = TextAlign.Center)
}
PdfUiState.ERROR -> {
Text(text = vm.pdfStatusMessage ?: "Error", style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.error, textAlign = TextAlign.Center, modifier = Modifier.padding(bottom = 12.dp))
Text(text = vm.pdfStatusMessage ?: stringResource(R.string.error_unknown), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.error, textAlign = TextAlign.Center, modifier = Modifier.padding(bottom = 12.dp))
Row(horizontalArrangement = Arrangement.spacedBy(16.dp)) {
OutlinedButton(onClick = { clipboardManager.setText(AnnotatedString(vm.pdfStatusMessage ?: "")) }, modifier = Modifier.weight(1f)) {
Icon(Icons.Default.ContentCopy, null); Spacer(Modifier.width(8.dp)); Text("Copy Logs")
// FIX: Pre-fetch string resource outside the lambda
val noErrorMsg = stringResource(R.string.no_error_msg)
val errorMessage = vm.pdfStatusMessage ?: noErrorMsg

OutlinedButton(onClick = {
scope.launch {
val clipData = ClipData.newPlainText("Error Logs", errorMessage)
clipboard.setClipEntry(ClipEntry(clipData))
}
}, modifier = Modifier.weight(1f)) {
Icon(Icons.Default.ContentCopy, null); Spacer(Modifier.width(8.dp)); Text(stringResource(R.string.copy_logs))
}
Button(onClick = { vm.resetDocumentState() }, modifier = Modifier.weight(1f)) {
Icon(Icons.Default.Refresh, null); Spacer(Modifier.width(8.dp)); Text("Retry")
Icon(Icons.Default.Refresh, null); Spacer(Modifier.width(8.dp)); Text(stringResource(R.string.retry))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.automirrored.rounded.ArrowForward
import androidx.compose.material.icons.filled.Check
import androidx.compose.material.icons.filled.DarkMode
import androidx.compose.material.icons.filled.Edit
import androidx.compose.material.icons.filled.LightMode
import androidx.compose.material.icons.filled.Notifications
import androidx.compose.material.icons.filled.Restore
import androidx.compose.material.icons.filled.SettingsSystemDaydream
import androidx.compose.material.icons.rounded.ArrowForward
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
Expand Down Expand Up @@ -277,7 +277,7 @@ fun OnboardingScreen(
) {
Text(stringResource(R.string.onboard_btn_finish), style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.Bold)
Spacer(Modifier.width(8.dp))
Icon(Icons.Rounded.ArrowForward, null)
Icon(Icons.AutoMirrored.Rounded.ArrowForward, null) // Updated Icon
}

Spacer(Modifier.height(32.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.automirrored.filled.ArrowForward
import androidx.compose.material.icons.automirrored.filled.List
import androidx.compose.material.icons.filled.*
import androidx.compose.material.icons.outlined.*
import androidx.compose.material3.*
Expand Down Expand Up @@ -418,7 +420,7 @@ fun PersonalInfoScreen(
SectionHeader(stringResource(R.string.personal_movement_finance), Icons.Outlined.History)
ExpandableCard {
Text(stringResource(R.string.personal_movement), style = MaterialTheme.typography.titleSmall, color = MaterialTheme.colorScheme.primary)
DataRow(Icons.Default.ArrowForward, stringResource(R.string.personal_type), movTypeObj?.getName(currentLang))
DataRow(Icons.AutoMirrored.Filled.ArrowForward, stringResource(R.string.personal_type), movTypeObj?.getName(currentLang))
DataRow(Icons.Default.CheckCircle, stringResource(R.string.personal_is_student), movTypeObj?.is_student?.toString())
DataRow(Icons.Default.Description, stringResource(R.string.personal_desc), mov?.info_description)
DataRow(Icons.Default.DateRange, stringResource(R.string.personal_period), periodName)
Expand All @@ -441,9 +443,9 @@ fun PersonalInfoScreen(
DataRow(Icons.Default.Book, stringResource(R.string.personal_library), libStatus)
DataRow(Icons.Default.Money, stringResource(R.string.personal_debt_credits), profile?.access_debt_credit_count?.toString())

DataRow(Icons.Default.List, stringResource(R.string.personal_lib_items), "${profile?.studentlibrary?.size ?: 0}")
DataRow(Icons.Default.List, stringResource(R.string.personal_debt_trans), "${profile?.student_debt_transcript?.size ?: 0}")
DataRow(Icons.Default.List, stringResource(R.string.personal_total_price), "${profile?.total_price?.size ?: 0}")
DataRow(Icons.AutoMirrored.Filled.List, stringResource(R.string.personal_lib_items), "${profile?.studentlibrary?.size ?: 0}")
DataRow(Icons.AutoMirrored.Filled.List, stringResource(R.string.personal_debt_trans), "${profile?.student_debt_transcript?.size ?: 0}")
DataRow(Icons.AutoMirrored.Filled.List, stringResource(R.string.personal_total_price), "${profile?.total_price?.size ?: 0}")
}
Spacer(Modifier.height(24.dp))
}
Expand Down
Loading
Loading