-
Notifications
You must be signed in to change notification settings - Fork 588
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
1,610 additions
and
600 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
core/common/src/main/java/com/mifos/core/common/utils/Utils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.mifos.core.common.utils | ||
|
||
import java.text.DateFormat | ||
import java.util.Calendar | ||
import java.util.TimeZone | ||
|
||
object Utils { | ||
|
||
fun getStringOfDate(dateObj: List<Int?>): String { | ||
val calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")) | ||
dateObj.getOrNull(0)?.let { year -> | ||
calendar.set(Calendar.YEAR, year) | ||
} | ||
dateObj.getOrNull(1)?.let { month -> | ||
calendar.set(Calendar.MONTH, month - 1) | ||
} | ||
dateObj.getOrNull(2)?.let { day -> | ||
calendar.set(Calendar.DAY_OF_MONTH, day) | ||
} | ||
val dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM) | ||
return dateFormat.format(calendar.time) | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
core/data/src/main/java/com/mifos/core/data/di/RepositoryModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.mifos.core.data.di | ||
|
||
import com.mifos.core.data.repository.ClientDetailsRepository | ||
import com.mifos.core.data.repository_imp.ClientDetailsRepositoryImp | ||
import com.mifos.core.network.datamanager.DataManagerClient | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object RepositoryModule { | ||
|
||
@Provides | ||
fun providesClientDetailsRepository(dataManagerClient: DataManagerClient): ClientDetailsRepository = | ||
ClientDetailsRepositoryImp(dataManagerClient) | ||
|
||
|
||
} |
22 changes: 22 additions & 0 deletions
22
core/data/src/main/java/com/mifos/core/data/repository/ClientDetailsRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.mifos.core.data.repository | ||
|
||
import com.mifos.core.objects.accounts.ClientAccounts | ||
import com.mifos.core.objects.client.Client | ||
import okhttp3.MultipartBody | ||
import okhttp3.ResponseBody | ||
import rx.Observable | ||
|
||
/** | ||
* Created by Aditya Gupta on 06/08/23. | ||
*/ | ||
interface ClientDetailsRepository { | ||
|
||
fun uploadClientImage(id: Int, file: MultipartBody.Part?): Observable<ResponseBody> | ||
|
||
fun deleteClientImage(clientId: Int): Observable<ResponseBody> | ||
|
||
fun getClientAccounts(clientId: Int): Observable<ClientAccounts> | ||
|
||
fun getClient(clientId: Int): Observable<Client> | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
core/data/src/main/java/com/mifos/core/data/repository_imp/ClientDetailsRepositoryImp.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.mifos.core.data.repository_imp | ||
|
||
import com.mifos.core.data.repository.ClientDetailsRepository | ||
import com.mifos.core.network.datamanager.DataManagerClient | ||
import com.mifos.core.objects.accounts.ClientAccounts | ||
import com.mifos.core.objects.client.Client | ||
import okhttp3.MultipartBody | ||
import okhttp3.ResponseBody | ||
import rx.Observable | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Created by Aditya Gupta on 06/08/23. | ||
*/ | ||
class ClientDetailsRepositoryImp @Inject constructor(private val dataManagerClient: DataManagerClient) : | ||
ClientDetailsRepository { | ||
|
||
override fun uploadClientImage(id: Int, file: MultipartBody.Part?): Observable<ResponseBody> { | ||
return dataManagerClient.uploadClientImage(id, file) | ||
} | ||
|
||
override fun deleteClientImage(clientId: Int): Observable<ResponseBody> { | ||
return dataManagerClient.deleteClientImage(clientId) | ||
} | ||
|
||
override fun getClientAccounts(clientId: Int): Observable<ClientAccounts> { | ||
return dataManagerClient.getClientAccounts(clientId) | ||
} | ||
|
||
override fun getClient(clientId: Int): Observable<Client> { | ||
return dataManagerClient.getClient(clientId) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
core/designsystem/src/main/java/com/mifos/core/designsystem/component/MifosMenuDropdown.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.mifos.core.designsystem.component | ||
|
||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.DropdownMenuItem | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.font.Font | ||
import androidx.compose.ui.text.font.FontFamily | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import com.mifos.core.designsystem.R | ||
|
||
@Composable | ||
fun MifosMenuDropDownItem(option: String, onClick: () -> Unit) { | ||
DropdownMenuItem(text = { | ||
Text( | ||
modifier = Modifier.padding(6.dp), | ||
text = option, style = TextStyle( | ||
fontSize = 17.sp | ||
) | ||
) | ||
}, onClick = { onClick() }) | ||
} |
12 changes: 12 additions & 0 deletions
12
...esignsystem/src/main/java/com/mifos/core/designsystem/component/MifosProgressIndicator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
core/network/src/main/java/com/mifos/core/network/utils/ImageLoaderUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.mifos.core.network.utils | ||
|
||
import android.content.Context | ||
import coil.ImageLoader | ||
import coil.request.ImageRequest | ||
import coil.request.ImageResult | ||
import com.mifos.core.datastore.PrefManager | ||
import com.mifos.core.network.MifosInterceptor | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import javax.inject.Inject | ||
|
||
class ImageLoaderUtils @Inject constructor( | ||
private val prefManager: PrefManager, | ||
private val imageLoader: ImageLoader, | ||
@ApplicationContext private val context: Context | ||
) { | ||
|
||
private fun buildImageUrl(clientId: Int): String { | ||
return (prefManager.getInstanceUrl() | ||
+ "clients/" | ||
+ clientId | ||
+ "/images?maxHeight=120&maxWidth=120") | ||
} | ||
|
||
suspend fun loadImage(clientId: Int): ImageResult { | ||
val request = ImageRequest.Builder(context) | ||
.data(buildImageUrl(clientId)) | ||
.addHeader(MifosInterceptor.HEADER_TENANT, prefManager.getTenant()) | ||
.addHeader(MifosInterceptor.HEADER_AUTH, prefManager.getToken()) | ||
.addHeader("Accept", "application/octet-stream") | ||
.build() | ||
return imageLoader.execute(request) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<uses-permission android:name="android.permission.CAMERA"/> | ||
<uses-feature android:name="android.hardware.camera.any"/> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" | ||
android:maxSdkVersion="28" /> | ||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/> | ||
</manifest> |
44 changes: 44 additions & 0 deletions
44
...in/java/com/mifos/feature/client/clientDetails/domain/usecase/DeleteClientImageUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.mifos.feature.client.clientDetails.domain.usecase | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.mifos.core.data.repository.ClientDetailsRepository | ||
import kotlinx.coroutines.channels.awaitClose | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.callbackFlow | ||
import okhttp3.ResponseBody | ||
import rx.Subscriber | ||
import rx.android.schedulers.AndroidSchedulers | ||
import rx.schedulers.Schedulers | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Created by Aditya Gupta on 18/03/24. | ||
*/ | ||
|
||
class DeleteClientImageUseCase @Inject constructor(private val repository: ClientDetailsRepository) { | ||
|
||
operator fun invoke(clientId: Int): Flow<Resource<ResponseBody>> = callbackFlow { | ||
try { | ||
trySend(Resource.Loading()) | ||
repository.deleteClientImage(clientId) | ||
.observeOn(AndroidSchedulers.mainThread()) | ||
.subscribeOn(Schedulers.io()) | ||
.subscribe(object : Subscriber<ResponseBody>() { | ||
override fun onCompleted() {} | ||
override fun onError(e: Throwable) { | ||
trySend(Resource.Error("Failed to delete image")) | ||
} | ||
|
||
override fun onNext(response: ResponseBody) { | ||
trySend(Resource.Success(response)) | ||
} | ||
}) | ||
|
||
awaitClose { channel.close() } | ||
|
||
} catch (e: Exception) { | ||
trySend(Resource.Error(e.message.toString())) | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.