Skip to content

Commit

Permalink
refactor: final cleanup (#2265)
Browse files Browse the repository at this point in the history
* Remove Unused XML, Resources, and Kotlin Code

deleted themeHelper.kt

deleted unused files

* actions/upload-artifact version update

* remove unused testFiles

* applied spotless and detekt on whole project

* added dependency guard

* fix build failure
  • Loading branch information
itsPronay authored Dec 23, 2024
1 parent fee8541 commit 5f44c46
Show file tree
Hide file tree
Showing 375 changed files with 2,780 additions and 13,838 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

# Upload APK
- name: Upload APK
uses: actions/upload-artifact@v2.2.0
uses: actions/upload-artifact@v4
with:
# Artifact name
name: android-client-app
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,15 +49,18 @@ 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 @@ -86,9 +89,6 @@ 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,3 +1,12 @@
/*
* 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 @@ -18,7 +27,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 @@ -34,7 +43,7 @@ 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)
Expand All @@ -48,7 +57,6 @@ class CenterListPagingSource(private val dataManagerCenter: DataManagerCenter) :

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

dataManagerCenter.allDatabaseCenters
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
Expand All @@ -69,10 +77,9 @@ 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 @@ -85,4 +92,4 @@ class CenterListPagingSource(private val dataManagerCenter: DataManagerCenter) :
}
return centerList
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* 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 @@ -17,13 +26,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 @@ -39,7 +48,7 @@ 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)
Expand Down Expand Up @@ -73,7 +82,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 @@ -86,4 +95,4 @@ class ClientListPagingSource(
}
return clientList
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* 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
Expand All @@ -14,17 +23,16 @@ interface ActivateRepository {

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

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

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

}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* 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 @@ -18,5 +27,4 @@ interface ClientDetailsRepository {
suspend fun getClientAccounts(clientId: Int): ClientAccounts

suspend fun getClient(clientId: Int): Client

}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* 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.noncore.Identifier
Expand All @@ -12,6 +21,6 @@ interface ClientIdentifiersRepository {

suspend fun deleteClientIdentifier(
clientId: Int,
identifierId: Int
identifierId: Int,
): DeleteClientsClientIdIdentifiersIdentifierIdResponse
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* 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.google.gson.JsonArray
Expand All @@ -13,7 +22,6 @@ interface DataTableDataRepository {
suspend fun deleteDataTableEntry(
table: String,
entity: Int,
rowId: Int
rowId: Int,
): DeleteDataTablesDatatableAppTableIdDatatableIdResponse

}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* 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.noncore.DataTable
Expand All @@ -8,5 +17,4 @@ import com.mifos.core.objects.noncore.DataTable
interface DataTableRepository {

suspend fun getDataTable(tableName: String?): List<DataTable>

}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* 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 org.openapitools.client.models.PostAuthenticationResponse
Expand All @@ -9,5 +18,4 @@ import org.openapitools.client.models.PostAuthenticationResponse
interface LoginRepository {

suspend fun login(username: String, password: String): PostAuthenticationResponse

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
package com.mifos.core.data.repository_imp
/*
* 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.repositoryImp

import com.mifos.core.data.repository.ActivateRepository
import com.mifos.core.network.GenericResponse
Expand All @@ -17,27 +26,27 @@ import javax.inject.Inject
class ActivateRepositoryImp @Inject constructor(
private val dataManagerClient: DataManagerClient,
private val dataManagerCenter: DataManagerCenter,
private val dataManagerGroups: DataManagerGroups
private val dataManagerGroups: DataManagerGroups,
) : ActivateRepository {

override suspend fun activateClient(
clientId: Int,
clientActivate: ActivatePayload?
clientActivate: ActivatePayload?,
): PostClientsClientIdResponse {
return dataManagerClient.activateClient(clientId, clientActivate)
}

override suspend fun activateCenter(
centerId: Int,
activatePayload: ActivatePayload?
activatePayload: ActivatePayload?,
): PostCentersCenterIdResponse {
return dataManagerCenter.activateCenter(centerId, activatePayload)
}

override fun activateGroup(
groupId: Int,
activatePayload: ActivatePayload?
activatePayload: ActivatePayload?,
): Observable<GenericResponse> {
return dataManagerGroups.activateGroup(groupId, activatePayload)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
package com.mifos.core.data.repository_imp
/*
* 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.repositoryImp

import com.mifos.core.data.repository.ClientIdentifiersRepository
import com.mifos.core.network.datamanager.DataManagerClient
Expand All @@ -18,9 +27,8 @@ class ClientIdentifiersRepositoryImp @Inject constructor(private val dataManager

override suspend fun deleteClientIdentifier(
clientId: Int,
identifierId: Int
identifierId: Int,
): DeleteClientsClientIdIdentifiersIdentifierIdResponse {
return dataManagerClient.deleteClientIdentifier(clientId, identifierId)
}

}
}
Loading

0 comments on commit 5f44c46

Please sign in to comment.