Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conflicts #16

Merged
merged 5 commits into from
Dec 22, 2024
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
83 changes: 83 additions & 0 deletions .github/workflows/pr-check-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
## Overview
#
# This reusable GitHub Actions workflow provides a comprehensive Continuous Integration (CI) pipeline
# for multi-platform mobile and desktop applications, specifically designed for projects using Gradle and Java/Kotlin.
#
### Key Features
# - Automated code quality checks
# - Dependency management and verification
# - Cross-platform desktop application builds (Windows, Linux, MacOS)
# - Android APK build generation
# - Artifact generation and storage
#
### Workflow Jobs
# 1. **Setup**: Prepares the build environment
# - Checks out repository code
# - Sets up Java 17
# - Configures Gradle
# - Manages dependency caching
#
# 2. **Code Quality Checks**:
# - Build logic verification
# - Code formatting checks (Spotless)
# - Static code analysis (Detekt)
#
# 3. **Dependency Guard**:
# - Verifies dependencies against baseline
# - Prevents unauthorized dependency changes
# - Supports automatic baseline updates
#
# 4. **Android App Build**:
# - Builds debug APK for demo flavor
# - Uploads APK artifacts
#
### Prerequisites
# - Java 17
# - Gradle
# - Configured build scripts for:
# - Android module
# - Desktop module
# - Installed Gradle plugins:
# - Spotless
# - Detekt
# - Dependency Guard
#
### Configuration Parameters
# The workflow requires two input parameters:
#
# | Parameter | Description | Type | Required |
# |------------------------|------------------------------------|--------|----------|
# | `android_package_name` | Name of the Android project module | String | Yes |
#

# https://github.com/openMF/mifos-mobile-github-actions/blob/main/.github/workflows/pr-check-android.yaml

# ##############################################################################
# DON'T EDIT THIS FILE UNLESS NECESSARY #
# ##############################################################################


name: PR Checks

# Trigger conditions for the workflow
on:
push:
branches: [ dev ] # Runs on pushes to dev branch
pull_request: # Runs on all pull requests
workflow_dispatch: # Allows manual triggering of the workflow

# Concurrency settings to prevent multiple simultaneous workflow runs
concurrency:
group: pr-${{ github.ref }}
cancel-in-progress: true # Cancels previous runs if a new one is triggered

permissions:
contents: write

jobs:
pr_checks:
name: PR Checks
uses: openMF/mifos-mobile-github-actions/.github/workflows/pr-check-android.yaml@main
secrets: inherit
with:
android_package_name: 'mifosng-android' # <-- Change Your Android Package Name
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.TaskAction
import org.gradle.internal.extensions.stdlib.capitalized
import org.gradle.configurationcache.extensions.capitalized
import org.gradle.kotlin.dsl.register
import org.gradle.language.base.plugins.LifecycleBasePlugin
import org.gradle.process.ExecOperations
Expand Down
6 changes: 3 additions & 3 deletions core/data/src/main/java/com/mifos/core/data/di/DataModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,15 @@ import com.mifos.core.data.repository.SearchRepository
import com.mifos.core.data.repository.SignatureRepository
import com.mifos.core.data.repository.SurveyListRepository
import com.mifos.core.data.repository.SurveySubmitRepository
import com.mifos.core.data.repositoryImp.ActivateRepositoryImp
import com.mifos.core.data.repositoryImp.CenterDetailsRepositoryImp
import com.mifos.core.data.repositoryImp.CenterListRepositoryImp
import com.mifos.core.data.repositoryImp.ChargeDialogRepositoryImp
import com.mifos.core.data.repositoryImp.CheckerInboxRepositoryImp
import com.mifos.core.data.repositoryImp.CheckerInboxTasksRepositoryImp
import com.mifos.core.data.repositoryImp.ClientChargeRepositoryImp
import com.mifos.core.data.repositoryImp.ClientIdentifierDialogRepositoryImp
import com.mifos.core.data.repositoryImp.ClientIdentifiersRepositoryImp
import com.mifos.core.data.repositoryImp.CreateNewCenterRepositoryImp
import com.mifos.core.data.repositoryImp.CreateNewGroupRepositoryImp
import com.mifos.core.data.repositoryImp.DataTableDataRepositoryImp
import com.mifos.core.data.repositoryImp.DataTableListRepositoryImp
import com.mifos.core.data.repositoryImp.DataTableRepositoryImp
import com.mifos.core.data.repositoryImp.DataTableRowDialogRepositoryImp
Expand Down Expand Up @@ -89,6 +86,9 @@ import com.mifos.core.data.repositoryImp.SearchRepositoryImp
import com.mifos.core.data.repositoryImp.SignatureRepositoryImp
import com.mifos.core.data.repositoryImp.SurveyListRepositoryImp
import com.mifos.core.data.repositoryImp.SurveySubmitRepositoryImp
import com.mifos.core.data.repository_imp.ActivateRepositoryImp
import com.mifos.core.data.repository_imp.ClientIdentifiersRepositoryImp
import com.mifos.core.data.repository_imp.DataTableDataRepositoryImp
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
/*
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.data.pagingSource

import androidx.paging.PagingSource
Expand All @@ -27,7 +18,7 @@ class CenterListPagingSource(private val dataManagerCenter: DataManagerCenter) :
override fun getRefreshKey(state: PagingState<Int, Center>): Int? {
return state.anchorPosition?.let { position ->
state.closestPageToPosition(position)?.prevKey?.plus(10) ?: state.closestPageToPosition(
position,
position
)?.nextKey?.minus(10)
}
}
Expand All @@ -43,43 +34,21 @@ class CenterListPagingSource(private val dataManagerCenter: DataManagerCenter) :
LoadResult.Page(
data = centerListWithSync,
prevKey = if (position <= 0) null else position - 10,
nextKey = if (position >= totalCenters) null else position + 10,
nextKey = if (position >= totalCenters) null else position + 10
)
} catch (e: Exception) {
LoadResult.Error(e)
}
}

private suspend fun getCenterList(position: Int): Pair<List<Center>, Int> =
suspendCoroutine { continuation ->
try {
dataManagerCenter.getCenters(true, position, 10)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(object : Subscriber<Page<Center>>() {
override fun onCompleted() {
}

override fun onError(exception: Throwable) {
continuation.resumeWithException(exception)
}

override fun onNext(center: Page<Center>) {
continuation.resume(
Pair(
center.pageItems,
center.totalFilteredRecords,
),
)
}
})
} catch (exception: Exception) {
continuation.resumeWithException(exception)
}
}
private suspend fun getCenterList(position: Int): Pair<List<Center>, Int> {
val pagedClient = dataManagerCenter.getCenters(true, position, 10)
return Pair(pagedClient.pageItems, pagedClient.totalFilteredRecords)
}

private suspend fun getCenterDbList(): List<Center> = suspendCoroutine { continuation ->
try {

dataManagerCenter.allDatabaseCenters
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
Expand All @@ -100,9 +69,10 @@ class CenterListPagingSource(private val dataManagerCenter: DataManagerCenter) :
}
}


private fun getCenterListWithSync(
centerList: List<Center>,
centerDbList: List<Center>,
centerDbList: List<Center>
): List<Center> {
if (centerDbList.isNotEmpty()) {
centerList.forEach { center ->
Expand All @@ -115,4 +85,4 @@ class CenterListPagingSource(private val dataManagerCenter: DataManagerCenter) :
}
return centerList
}
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
/*
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.data.pagingSource

import androidx.paging.PagingSource
import androidx.paging.PagingState
import com.mifos.core.network.datamanager.DataManagerClient
import com.mifos.core.objects.client.Client
import com.mifos.core.objects.client.Page
import kotlinx.coroutines.suspendCancellableCoroutine
import rx.Subscriber
import rx.android.schedulers.AndroidSchedulers
import rx.schedulers.Schedulers
Expand All @@ -27,13 +17,13 @@ import kotlin.coroutines.suspendCoroutine
*/

class ClientListPagingSource(
private val dataManagerClient: DataManagerClient,
private val dataManagerClient: DataManagerClient
) : PagingSource<Int, Client>() {

override fun getRefreshKey(state: PagingState<Int, Client>): Int? {
return state.anchorPosition?.let { position ->
state.closestPageToPosition(position)?.prevKey?.plus(10) ?: state.closestPageToPosition(
position,
position
)?.nextKey?.minus(10)
}
}
Expand All @@ -49,31 +39,16 @@ class ClientListPagingSource(
LoadResult.Page(
data = clientListWithSync,
prevKey = if (position <= 0) null else position - 10,
nextKey = if (position >= totalClients) null else position + 10,
nextKey = if (position >= totalClients) null else position + 10
)
} catch (e: Exception) {
LoadResult.Error(e)
}
}

private suspend fun getClientList(position: Int): Pair<List<Client>, Int> {
return suspendCancellableCoroutine { continuation ->
dataManagerClient.getAllClients(offset = position, 10)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(object : Subscriber<Page<Client>>() {
override fun onCompleted() {
}

override fun onError(e: Throwable) {
continuation.resumeWithException(e)
}

override fun onNext(t: Page<Client>) {
continuation.resume(Pair(t.pageItems, t.totalFilteredRecords))
}
})
}
val response = dataManagerClient.getAllClients(position, 10)
return Pair(response.pageItems, response.totalFilteredRecords)
}

private suspend fun getClientDbList(): List<Client> {
Expand All @@ -98,7 +73,7 @@ class ClientListPagingSource(

private fun getClientListWithSync(
clientList: List<Client>,
clientDbList: List<Client>,
clientDbList: List<Client>
): List<Client> {
if (clientDbList.isNotEmpty()) {
clientList.forEach { client ->
Expand All @@ -111,4 +86,4 @@ class ClientListPagingSource(
}
return clientList
}
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
/*
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.data.repository

import com.mifos.core.network.GenericResponse
import com.mifos.core.objects.client.ActivatePayload
import org.apache.fineract.client.models.PostCentersCenterIdResponse
import org.apache.fineract.client.models.PostClientsClientIdResponse
import org.openapitools.client.models.PostCentersCenterIdResponse
import org.openapitools.client.models.PostClientsClientIdResponse
import rx.Observable

/**
Expand All @@ -21,18 +12,19 @@ import rx.Observable

interface ActivateRepository {

fun activateClient(
suspend fun activateClient(
clientId: Int,
clientActivate: ActivatePayload?,
): Observable<PostClientsClientIdResponse>
clientActivate: ActivatePayload?
): PostClientsClientIdResponse

fun activateCenter(
suspend fun activateCenter(
centerId: Int,
activatePayload: ActivatePayload?,
): Observable<PostCentersCenterIdResponse>
activatePayload: ActivatePayload?
): PostCentersCenterIdResponse

fun activateGroup(
groupId: Int,
activatePayload: ActivatePayload?,
activatePayload: ActivatePayload?
): Observable<GenericResponse>
}

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
/*
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.data.repository

import com.mifos.core.objects.accounts.ClientAccounts
Expand All @@ -24,7 +15,8 @@ interface ClientDetailsRepository {

fun deleteClientImage(clientId: Int): Observable<ResponseBody>

fun getClientAccounts(clientId: Int): Observable<ClientAccounts>
suspend fun getClientAccounts(clientId: Int): ClientAccounts

suspend fun getClient(clientId: Int): Client

fun getClient(clientId: Int): Observable<Client>
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ package com.mifos.core.data.repository
import com.mifos.core.objects.noncore.IdentifierCreationResponse
import com.mifos.core.objects.noncore.IdentifierPayload
import com.mifos.core.objects.noncore.IdentifierTemplate
import rx.Observable

/**
* Created by Aditya Gupta on 16/08/23.
*/
interface ClientIdentifierDialogRepository {

fun getClientIdentifierTemplate(clientId: Int): Observable<IdentifierTemplate>
suspend fun getClientIdentifierTemplate(clientId: Int): IdentifierTemplate

suspend fun createClientIdentifier(
clientId: Int,
Expand Down
Loading