Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fcf4d02caf | ||
|
|
6166a2f249 | ||
|
|
6213bbf30f |
No files matched your search
@@ -46,3 +46,30 @@ jobs:
|
|||||||
files: app/build/outputs/apk/release/MonthlyPaymentApp-${{ github.ref_name }}.apk
|
files: app/build/outputs/apk/release/MonthlyPaymentApp-${{ github.ref_name }}.apk
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Update update.json after release
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
TAG_NAME="${{ github.ref_name }}"
|
||||||
|
VERSION_NAME="${TAG_NAME#v}"
|
||||||
|
VERSION_CODE=$(grep 'versionCode' app/build.gradle.kts | head -n 1 | awk '{print $3}')
|
||||||
|
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
|
git fetch origin main
|
||||||
|
git checkout main
|
||||||
|
|
||||||
|
cat <<EOF > update.json
|
||||||
|
{
|
||||||
|
"versionCode": ${VERSION_CODE},
|
||||||
|
"versionName": "${VERSION_NAME}",
|
||||||
|
"url": "https://github.com/oqba26/MonthlyPaymentApp/releases/download/${TAG_NAME}/MonthlyPaymentApp-${TAG_NAME}.apk",
|
||||||
|
"releaseNotes": "بهبودهای پایداری و عملکرد همگامسازی",
|
||||||
|
"isForceUpdate": false
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
git add update.json
|
||||||
|
git commit -m "auto-update update.json for release ${TAG_NAME}" || true
|
||||||
|
git push origin main
|
||||||
@@ -30,8 +30,8 @@ android {
|
|||||||
applicationId = "com.oqba26.monthlypaymentapp"
|
applicationId = "com.oqba26.monthlypaymentapp"
|
||||||
minSdk = 25
|
minSdk = 25
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = 11
|
versionCode = 13
|
||||||
versionName = "1.1.0"
|
versionName = "1.1.2"
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
vectorDrawables { useSupportLibrary = true }
|
vectorDrawables { useSupportLibrary = true }
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,13 @@ android {
|
|||||||
targetCompatibility = JavaVersion.VERSION_21
|
targetCompatibility = JavaVersion.VERSION_21
|
||||||
isCoreLibraryDesugaringEnabled = true
|
isCoreLibraryDesugaringEnabled = true
|
||||||
}
|
}
|
||||||
kotlinOptions { jvmTarget = "21" }
|
kotlinOptions {
|
||||||
|
jvmTarget = "21"
|
||||||
|
freeCompilerArgs += listOf(
|
||||||
|
"-opt-in=kotlinx.serialization.InternalSerializationApi",
|
||||||
|
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi"
|
||||||
|
)
|
||||||
|
}
|
||||||
kotlin { jvmToolchain(21) }
|
kotlin { jvmToolchain(21) }
|
||||||
|
|
||||||
packaging {
|
packaging {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
@file:OptIn(InternalSerializationApi::class)
|
||||||
|
|
||||||
package com.oqba26.monthlypaymentapp.data.remote
|
package com.oqba26.monthlypaymentapp.data.remote
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
@@ -5,6 +7,7 @@ import io.ktor.client.HttpClient
|
|||||||
import io.ktor.client.engine.okhttp.OkHttp
|
import io.ktor.client.engine.okhttp.OkHttp
|
||||||
import io.ktor.client.plugins.HttpTimeout
|
import io.ktor.client.plugins.HttpTimeout
|
||||||
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
|
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
|
||||||
|
import io.ktor.client.plugins.timeout
|
||||||
import io.ktor.client.request.delete
|
import io.ktor.client.request.delete
|
||||||
import io.ktor.client.request.get
|
import io.ktor.client.request.get
|
||||||
import io.ktor.client.request.header
|
import io.ktor.client.request.header
|
||||||
@@ -25,6 +28,7 @@ import io.ktor.utils.io.readUTF8Line
|
|||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.flow
|
import kotlinx.coroutines.flow.flow
|
||||||
|
import kotlinx.serialization.InternalSerializationApi
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import kotlinx.serialization.json.JsonObject
|
import kotlinx.serialization.json.JsonObject
|
||||||
@@ -347,6 +351,10 @@ class PocketBaseClient(
|
|||||||
authToken?.let { token ->
|
authToken?.let { token ->
|
||||||
header(HttpHeaders.Authorization, "Bearer $token")
|
header(HttpHeaders.Authorization, "Bearer $token")
|
||||||
}
|
}
|
||||||
|
timeout {
|
||||||
|
requestTimeoutMillis = HttpTimeout.INFINITE_TIMEOUT_MS
|
||||||
|
socketTimeoutMillis = HttpTimeout.INFINITE_TIMEOUT_MS
|
||||||
|
}
|
||||||
}.execute { response ->
|
}.execute { response ->
|
||||||
val channel: ByteReadChannel = response.bodyAsChannel()
|
val channel: ByteReadChannel = response.bodyAsChannel()
|
||||||
var currentEvent = ""
|
var currentEvent = ""
|
||||||
@@ -362,6 +370,7 @@ class PocketBaseClient(
|
|||||||
val connectObj = json.decodeFromString<PocketBaseConnectEvent>(dataJson)
|
val connectObj = json.decodeFromString<PocketBaseConnectEvent>(dataJson)
|
||||||
subscribeRealtime(cleanBaseUrl, connectObj.clientId, subscriptions)
|
subscribeRealtime(cleanBaseUrl, connectObj.clientId, subscriptions)
|
||||||
Log.d(TAG, "اتصال ریلتایم برقرار شد. ClientId: ${connectObj.clientId}")
|
Log.d(TAG, "اتصال ریلتایم برقرار شد. ClientId: ${connectObj.clientId}")
|
||||||
|
emit("PB_CONNECT")
|
||||||
} else if (currentEvent.isNotEmpty()) {
|
} else if (currentEvent.isNotEmpty()) {
|
||||||
emit(currentEvent)
|
emit(currentEvent)
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-37
@@ -14,9 +14,10 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
|||||||
import kotlinx.coroutines.flow.asStateFlow
|
import kotlinx.coroutines.flow.asStateFlow
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
import kotlin.time.Duration.Companion.milliseconds
|
||||||
|
|
||||||
class NetworkRepository(
|
class NetworkRepository(
|
||||||
private val settingsRepository: SettingsRepository? = null
|
settingsRepository: SettingsRepository? = null
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private val pocketBase = ApiClient.pocketBase
|
private val pocketBase = ApiClient.pocketBase
|
||||||
@@ -43,13 +44,16 @@ class NetworkRepository(
|
|||||||
// --- Realtime Operations ---
|
// --- Realtime Operations ---
|
||||||
fun observeRealtimeChanges() {
|
fun observeRealtimeChanges() {
|
||||||
repositoryScope.launch {
|
repositoryScope.launch {
|
||||||
try {
|
while (true) {
|
||||||
pocketBase.listenRealtime(listOf("persons", "payments")).collect { event ->
|
try {
|
||||||
Log.d("PocketBase-Realtime", "Change detected in PocketBase: $event")
|
pocketBase.listenRealtime(listOf("persons", "payments")).collect { event ->
|
||||||
refresh()
|
Log.d("PocketBase-Realtime", "Change detected in PocketBase: $event")
|
||||||
|
refresh()
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("PocketBase-Realtime", "Realtime connection error, retrying...", e)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
delay(3000.milliseconds)
|
||||||
Log.e("PocketBase-Realtime", "Realtime connection error, retrying...", e)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,31 +156,7 @@ class NetworkRepository(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun updatePersonArchivedStatus(personId: String, isArchived: Boolean): Boolean {
|
|
||||||
return try {
|
|
||||||
val currentPerson = _personsFlow.value.find { it.id == personId }
|
|
||||||
if (currentPerson != null) {
|
|
||||||
pocketBase.upsertRecord("persons", "id='$personId'", currentPerson.copy(isArchived = isArchived))
|
|
||||||
}
|
|
||||||
true
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.e("PocketBase", "updateArchived error", e)
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun updatePersonDisplayOrder(personId: String, displayOrder: Long): Boolean {
|
|
||||||
return try {
|
|
||||||
val currentPerson = _personsFlow.value.find { it.id == personId }
|
|
||||||
if (currentPerson != null) {
|
|
||||||
pocketBase.upsertRecord("persons", "id='$personId'", currentPerson.copy(displayOrder = displayOrder))
|
|
||||||
}
|
|
||||||
true
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.e("PocketBase", "updateOrder error", e)
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getPersonsFlow(): Flow<List<Person>> = _personsFlow.asStateFlow()
|
fun getPersonsFlow(): Flow<List<Person>> = _personsFlow.asStateFlow()
|
||||||
|
|
||||||
@@ -192,19 +172,17 @@ class NetworkRepository(
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun deletePayment(paymentId: String): Boolean {
|
suspend fun deletePayment(paymentId: String): Boolean {
|
||||||
var retries = 0
|
|
||||||
val maxRetries = 2
|
val maxRetries = 2
|
||||||
|
for (retries in 1..maxRetries) {
|
||||||
while (retries <= maxRetries) {
|
|
||||||
try {
|
try {
|
||||||
pocketBase.deleteRecordByFilter("payments", "id='$paymentId'")
|
pocketBase.deleteRecordByFilter("payments", "id='$paymentId'")
|
||||||
Log.d("PocketBase", "deletePayment Success: $paymentId")
|
Log.d("PocketBase", "deletePayment Success: $paymentId")
|
||||||
return true
|
return true
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
retries++
|
|
||||||
Log.e("PocketBase", "deletePayment error (Attempt $retries): ${e.message}", e)
|
Log.e("PocketBase", "deletePayment error (Attempt $retries): ${e.message}", e)
|
||||||
if (retries > maxRetries) return false
|
if (retries < maxRetries) {
|
||||||
delay(1000L * retries)
|
delay((1000L * retries).milliseconds)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import androidx.compose.material.ExperimentalMaterialApi
|
|||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.filled.Message
|
import androidx.compose.material.icons.automirrored.filled.Message
|
||||||
import androidx.compose.material.icons.filled.Archive
|
import androidx.compose.material.icons.filled.Archive
|
||||||
import androidx.compose.material.icons.filled.Assessment
|
|
||||||
import androidx.compose.material.icons.filled.Check
|
import androidx.compose.material.icons.filled.Check
|
||||||
import androidx.compose.material.icons.filled.Close
|
import androidx.compose.material.icons.filled.Close
|
||||||
import androidx.compose.material.icons.filled.Sync
|
import androidx.compose.material.icons.filled.Sync
|
||||||
@@ -117,7 +116,6 @@ fun PersonScreen(
|
|||||||
val dashboardData by viewModel.dashboardData.collectAsState()
|
val dashboardData by viewModel.dashboardData.collectAsState()
|
||||||
val financialReportData by viewModel.financialReportData.collectAsState()
|
val financialReportData by viewModel.financialReportData.collectAsState()
|
||||||
val showFinancialReportDialog by viewModel.showFinancialReportDialog.collectAsState()
|
val showFinancialReportDialog by viewModel.showFinancialReportDialog.collectAsState()
|
||||||
val isOperatorMode by viewModel.isOperatorMode.collectAsState()
|
|
||||||
val defaultPaymentAmount by viewModel.defaultPaymentAmountFlow.collectAsState(initial = 0.0)
|
val defaultPaymentAmount by viewModel.defaultPaymentAmountFlow.collectAsState(initial = 0.0)
|
||||||
val cardNumbers by viewModel.cardNumbersFlow.collectAsState(initial = emptyList())
|
val cardNumbers by viewModel.cardNumbersFlow.collectAsState(initial = emptyList())
|
||||||
val personForPaymentDialog by viewModel.personForPaymentDialog.collectAsState()
|
val personForPaymentDialog by viewModel.personForPaymentDialog.collectAsState()
|
||||||
@@ -188,8 +186,7 @@ fun PersonScreen(
|
|||||||
DashboardCard(
|
DashboardCard(
|
||||||
data = dashboardData,
|
data = dashboardData,
|
||||||
financialReportData = financialReportData,
|
financialReportData = financialReportData,
|
||||||
isOperatorMode = isOperatorMode,
|
isMosqueCategory = (currentCategory == "mosque")
|
||||||
onOpenReportClick = { viewModel.onShowFinancialReport() }
|
|
||||||
)
|
)
|
||||||
|
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
@@ -582,7 +579,7 @@ fun AddNewPersonDialog(
|
|||||||
val currentShamsiYear = getCurrentShamsiYear()
|
val currentShamsiYear = getCurrentShamsiYear()
|
||||||
val currentShamsiMonth = getCurrentShamsiMonth()
|
val currentShamsiMonth = getCurrentShamsiMonth()
|
||||||
|
|
||||||
var startMonth by remember { mutableIntStateOf(currentShamsiMonth) }
|
var startMonth by remember { mutableIntStateOf(if (isMosqueCategory) currentShamsiMonth else 1) }
|
||||||
var startYear by remember { mutableIntStateOf(currentShamsiYear) }
|
var startYear by remember { mutableIntStateOf(currentShamsiYear) }
|
||||||
|
|
||||||
var similarContacts by remember { mutableStateOf<List<ContactMatch>>(emptyList()) }
|
var similarContacts by remember { mutableStateOf<List<ContactMatch>>(emptyList()) }
|
||||||
@@ -1072,8 +1069,7 @@ fun SelectCardDialog(
|
|||||||
fun DashboardCard(
|
fun DashboardCard(
|
||||||
data: DashboardUiModel,
|
data: DashboardUiModel,
|
||||||
financialReportData: FinancialReportData,
|
financialReportData: FinancialReportData,
|
||||||
isOperatorMode: Boolean = false,
|
isMosqueCategory: Boolean = false
|
||||||
onOpenReportClick: () -> Unit
|
|
||||||
) {
|
) {
|
||||||
val animatedProgress by animateFloatAsState(
|
val animatedProgress by animateFloatAsState(
|
||||||
targetValue = data.progress,
|
targetValue = data.progress,
|
||||||
@@ -1110,7 +1106,11 @@ fun DashboardCard(
|
|||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
Text("مجموع درآمد ماه جاری", style = MaterialTheme.typography.titleSmall, fontWeight = FontWeight.Bold)
|
Text(
|
||||||
|
text = if (isMosqueCategory) "کمکهای جمعآوری شده ماه جاری" else "حقوق جمعآوری شده ماه جاری",
|
||||||
|
style = MaterialTheme.typography.titleSmall,
|
||||||
|
fontWeight = FontWeight.Bold
|
||||||
|
)
|
||||||
Text("${formatNumberAsPersian(data.totalIncome)} تومان", style = MaterialTheme.typography.bodyMedium, fontWeight = FontWeight.Bold)
|
Text("${formatNumberAsPersian(data.totalIncome)} تومان", style = MaterialTheme.typography.bodyMedium, fontWeight = FontWeight.Bold)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1136,24 +1136,6 @@ fun DashboardCard(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isOperatorMode) {
|
|
||||||
OutlinedButton(
|
|
||||||
onClick = onOpenReportClick,
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.padding(top = 2.dp),
|
|
||||||
shape = MaterialTheme.shapes.medium
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Default.Assessment,
|
|
||||||
contentDescription = null,
|
|
||||||
modifier = Modifier.size(18.dp)
|
|
||||||
)
|
|
||||||
Spacer(modifier = Modifier.width(6.dp))
|
|
||||||
Text("مشاهده گزارش کامل مالی و درآمدهای گذشته", style = MaterialTheme.typography.labelLarge)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"versionCode": 11,
|
"versionCode": 13,
|
||||||
"versionName": "1.1.0",
|
"versionName": "1.1.2",
|
||||||
"url": "https://github.com/oqba26/MonthlyPaymentApp/releases/download/v1.1.0/MonthlyPaymentApp-v1.1.0.apk",
|
"url": "https://github.com/oqba26/MonthlyPaymentApp/releases/download/v1.1.2/MonthlyPaymentApp-v1.1.2.apk",
|
||||||
"releaseNotes": "اصلاح اسکرول یکپارچه دیالوگ گزارش مالی و نمایش کامل تفکیک ماههای گذشته",
|
"releaseNotes": "بهبودهای پایداری و عملکرد همگامسازی",
|
||||||
"isForceUpdate": false
|
"isForceUpdate": false
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user