From 3fe7174f911e9added7a4e56236b22eed44e9e34 Mon Sep 17 00:00:00 2001 From: Darkeye14 Date: Fri, 10 Jan 2025 19:49:23 +0530 Subject: [PATCH 1/5] Lint issues MM-110 --- androidApp/src/main/res/values/strings.xml | 23 +++ config/detekt/detekt.yml | 2 +- core/common/build.gradle.kts | 6 + .../org/mifos/mobile/core/common/Network.kt | 146 ++++++------------ .../mobile/core/common/utils/DateHelper.kt | 20 +-- .../core/common/utils/LanguageHelper.kt | 2 +- .../utils/ParcelableAndSerializableUtils.kt | 3 + .../mifos/mobile/core/common/utils/Utils.kt | 1 + .../designsystem/components/MifosTabPager.kt | 9 +- core/model/build.gradle.kts | 1 + .../model/entity/accounts/loan/LoanAccount.kt | 12 +- .../model/entity/accounts/loan/Timeline.kt | 75 +-------- .../model/entity/accounts/savings/TimeLine.kt | 63 +------- .../entity/guarantor/GuarantorPayload.kt | 3 +- .../screens/ClientAccountsScreen.kt | 2 +- gradle/libs.versions.toml | 4 + .../PullRefreshIndicatorTransform.kt | 14 +- shared/build.gradle.kts | 8 +- 18 files changed, 128 insertions(+), 266 deletions(-) diff --git a/androidApp/src/main/res/values/strings.xml b/androidApp/src/main/res/values/strings.xml index 76b091c42..fc89c6f00 100644 --- a/androidApp/src/main/res/values/strings.xml +++ b/androidApp/src/main/res/values/strings.xml @@ -9,6 +9,9 @@ See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md --> + Change Account Password + New Password + Current Password Mifos Mobile Login Welcome %1$s @@ -609,6 +612,26 @@ فارسی + + How to apply for a new account? + Where can I view my profile information? + Where can I see my savings account transactions? + What is the use of a QR code? + How to create a beneficiary using a QR code? + How to make a payment for a loan account? + + + + To apply for a loan account, click on "Report loan application" on the home screen. + You can view your profile information by clicking on the profile picture on the main page of the application. + To view transactions in your savings account, go to the Accounts section, click on the required savings account, click on the + three dots present in the upper right corner and select the Transaction option. + The QR code of all loan or savings accounts can be shared with other users which will allow them to create a beneficiary. + To create a beneficiary, go to the beneficiary on the main page of the application, then click on the button in the lower right corner, select the scan option which will open the camera + of the device, scan the QR code of the person for whom you want to create a beneficiary, after filling in the required data, create beneficiaries using the QR code. + To make a payment for a loan account, go to the Accounts section, select the LOAN option, open the target loan account and click on the Make a payment option. + + System_Language en diff --git a/config/detekt/detekt.yml b/config/detekt/detekt.yml index f486f8184..497082145 100644 --- a/config/detekt/detekt.yml +++ b/config/detekt/detekt.yml @@ -828,7 +828,7 @@ style: active: false ReturnCount: active: true - max: 2 + max: 4 excludedFunctions: - "equals" excludeLabeled: false diff --git a/core/common/build.gradle.kts b/core/common/build.gradle.kts index fb4ec9a35..1442d9990 100644 --- a/core/common/build.gradle.kts +++ b/core/common/build.gradle.kts @@ -14,8 +14,14 @@ plugins { android { namespace = "org.mifos.mobile.core.common" + + lint { + disable.add( "NullSafeMutableLiveData" ) + } + } dependencies { + implementation(libs.androidx.preference.ktx) } \ No newline at end of file diff --git a/core/common/src/main/java/org/mifos/mobile/core/common/Network.kt b/core/common/src/main/java/org/mifos/mobile/core/common/Network.kt index 5f5f941b0..c70b79340 100644 --- a/core/common/src/main/java/org/mifos/mobile/core/common/Network.kt +++ b/core/common/src/main/java/org/mifos/mobile/core/common/Network.kt @@ -12,21 +12,9 @@ package org.mifos.mobile.core.common import android.annotation.SuppressLint import android.content.Context import android.net.ConnectivityManager -import android.net.NetworkInfo -import android.telephony.TelephonyManager +import android.net.NetworkCapabilities object Network { - /** - * Get the network info - * - * @param context - * @return - */ - @SuppressLint("MissingPermission") - private fun getNetworkInfo(context: Context): NetworkInfo? { - val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager - return cm.activeNetworkInfo - } /** * Check if there is any connectivity @@ -34,98 +22,56 @@ object Network { * @param context * @return */ + @SuppressLint("MissingPermission") @JvmStatic fun isConnected(context: Context?): Boolean { - val info = getNetworkInfo(context!!) - if (info != null) { - return info.isConnected - } - return false - } - - /** - * Check if there is any connectivity to a Wifi network - * - * @param context - * @param type - * @return - */ - fun isConnectedWifi(context: Context): Boolean { - val info = getNetworkInfo(context) - if (info != null) { - return info.isConnected && info.type == ConnectivityManager.TYPE_WIFI - } - return false - } - - /** - * Check if there is any connectivity to a mobile network - * - * @param context - * @param type - * @return - */ - fun isConnectedMobile(context: Context): Boolean { - val info = getNetworkInfo(context) - if (info != null) { - return info.isConnected && info.type == ConnectivityManager.TYPE_MOBILE + if (context == null) { + return false } - return false - } - - /** - * Check if there is fast connectivity - * - * @param context - * @return - */ - fun isConnectedFast(context: Context): Boolean { - val info = getNetworkInfo(context) - if (info != null) { - return info.isConnected && isConnectionFast(info.type, info.subtype) + val connectivityManager = + context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager + val networkCapabilities = connectivityManager.activeNetwork ?: return false + val actNw = + connectivityManager.getNetworkCapabilities(networkCapabilities) ?: return false + return when { + actNw.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> true + actNw.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> true + actNw.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> true + else -> false } - return false } +} - /** - * Check if the connection is fast - * - * @param type - * @param subType - * @return - */ - @Suppress("CyclomaticComplexMethod") - private fun isConnectionFast(type: Int, subType: Int): Boolean { - return when (type) { - ConnectivityManager.TYPE_WIFI -> { - true - } - - ConnectivityManager.TYPE_MOBILE -> { - when (subType) { - TelephonyManager.NETWORK_TYPE_1xRTT -> false // ~ 50-100 kbps - TelephonyManager.NETWORK_TYPE_CDMA -> false // ~ 14-64 kbps - TelephonyManager.NETWORK_TYPE_EDGE -> false // ~ 50-100 kbps - TelephonyManager.NETWORK_TYPE_EVDO_0 -> true // ~ 400-1000 kbps - TelephonyManager.NETWORK_TYPE_EVDO_A -> true // ~ 600-1400 kbps - TelephonyManager.NETWORK_TYPE_GPRS -> false // ~ 100 kbps - TelephonyManager.NETWORK_TYPE_HSDPA -> true // ~ 2-14 Mbps - TelephonyManager.NETWORK_TYPE_HSPA -> true // ~ 700-1700 kbps - TelephonyManager.NETWORK_TYPE_HSUPA -> true // ~ 1-23 Mbps - TelephonyManager.NETWORK_TYPE_UMTS -> true // ~ 400-7000 kbps - TelephonyManager.NETWORK_TYPE_EHRPD -> true // ~ 1-2 Mbps - TelephonyManager.NETWORK_TYPE_EVDO_B -> true // ~ 5 Mbps - TelephonyManager.NETWORK_TYPE_HSPAP -> true // ~ 10-20 Mbps - TelephonyManager.NETWORK_TYPE_IDEN -> false // ~25 kbps - TelephonyManager.NETWORK_TYPE_LTE -> true // ~ 10+ Mbps - TelephonyManager.NETWORK_TYPE_UNKNOWN -> false - else -> false - } - } +/** + * Check if there is any connectivity to a Wifi network + * + * @param context + * @param type + * @return + */ +@SuppressLint("MissingPermission") +fun isConnectedWifi(context: Context): Boolean { + val connectivityManager = + context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager + val networkCapabilities = connectivityManager.activeNetwork ?: return false + val actNw = + connectivityManager.getNetworkCapabilities(networkCapabilities) ?: return false + return actNw.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) +} - else -> { - false - } - } - } +/** + * Check if there is any connectivity to a mobile network + * + * @param context + * @param type + * @return + */ +@SuppressLint("MissingPermission") +fun isConnectedMobile(context: Context): Boolean { + val connectivityManager = + context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager + val networkCapabilities = connectivityManager.activeNetwork ?: return false + val actNw = + connectivityManager.getNetworkCapabilities(networkCapabilities) ?: return false + return actNw.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) } diff --git a/core/common/src/main/java/org/mifos/mobile/core/common/utils/DateHelper.kt b/core/common/src/main/java/org/mifos/mobile/core/common/utils/DateHelper.kt index 2895dac1c..242425fba 100755 --- a/core/common/src/main/java/org/mifos/mobile/core/common/utils/DateHelper.kt +++ b/core/common/src/main/java/org/mifos/mobile/core/common/utils/DateHelper.kt @@ -68,18 +68,18 @@ object DateHelper { val finalFormat = SimpleDateFormat(format, Locale.ENGLISH) var date: Date? = null try { - date = pickerFormat.parse(dateString) + date = dateString?.let { pickerFormat.parse(it) } } catch (e: ParseException) { - Log.d(LOG_TAG, e.localizedMessage) + e.localizedMessage?.let { Log.d(LOG_TAG, it) } } - return finalFormat.format(date) + return finalFormat.format(date!!) } fun getSpecificFormat(format: String?, dateLong: Long?): String? { try { return SimpleDateFormat(format, Locale.getDefault()).format(dateLong) } catch (e: ParseException) { - Log.d(LOG_TAG, e.localizedMessage) + e.localizedMessage?.let { Log.d(LOG_TAG, it) } return null } } @@ -93,11 +93,11 @@ object DateHelper { val finalFormat = SimpleDateFormat(requiredFormat, Locale.ENGLISH) var date: Date? = null try { - date = pickerFormat.parse(dateString) + date = dateString?.let { pickerFormat.parse(it) } } catch (e: ParseException) { - Log.d(LOG_TAG, e.localizedMessage) + e.localizedMessage?.let { Log.d(LOG_TAG, it) } } - return finalFormat.format(date) + return finalFormat.format(date!!) } /** @@ -127,7 +127,7 @@ object DateHelper { val sdf = SimpleDateFormat(pattern, Locale.getDefault()) var date: Date? = null try { - date = sdf.parse(dateStr) + date = dateStr?.let { sdf.parse(it) } } catch (e: ParseException) { Log.d("TAG", e.message ?: "") } @@ -154,13 +154,13 @@ object DateHelper { fun getDateAsStringFromLong(timeInMillis: Long?): String { val sdf = SimpleDateFormat("dd MMM yyyy", Locale.getDefault()) - return sdf.format(timeInMillis?.let { Date(it) }) + return sdf.format(Date(timeInMillis!!)) } @JvmStatic fun getDateAndTimeAsStringFromLong(timeInMillis: Long?): String { val sdf = SimpleDateFormat("HH:mm a dd MMM yyyy", Locale.getDefault()) - return sdf.format(timeInMillis?.let { Date(it) }) + return sdf.format(Date(timeInMillis!!)) } } diff --git a/core/common/src/main/java/org/mifos/mobile/core/common/utils/LanguageHelper.kt b/core/common/src/main/java/org/mifos/mobile/core/common/utils/LanguageHelper.kt index 20ae98cf5..1f21fa97a 100644 --- a/core/common/src/main/java/org/mifos/mobile/core/common/utils/LanguageHelper.kt +++ b/core/common/src/main/java/org/mifos/mobile/core/common/utils/LanguageHelper.kt @@ -10,7 +10,7 @@ package org.mifos.mobile.core.common.utils import android.content.Context -import android.preference.PreferenceManager +import androidx.preference.PreferenceManager import org.mifos.mobile.core.common.R import java.util.Locale diff --git a/core/common/src/main/java/org/mifos/mobile/core/common/utils/ParcelableAndSerializableUtils.kt b/core/common/src/main/java/org/mifos/mobile/core/common/utils/ParcelableAndSerializableUtils.kt index 9def51789..f588a471e 100644 --- a/core/common/src/main/java/org/mifos/mobile/core/common/utils/ParcelableAndSerializableUtils.kt +++ b/core/common/src/main/java/org/mifos/mobile/core/common/utils/ParcelableAndSerializableUtils.kt @@ -19,6 +19,7 @@ object ParcelableAndSerializableUtils { return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { this.getParcelableArrayList(key, classType) } else { + @Suppress("DEPRECATION") this.getParcelableArrayList(key) } } @@ -27,6 +28,7 @@ object ParcelableAndSerializableUtils { return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { this.getParcelable(key, classType) } else { + @Suppress("DEPRECATION") this.getParcelable(key) } } @@ -35,6 +37,7 @@ object ParcelableAndSerializableUtils { return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { this.getSerializable(key, classType) } else { + @Suppress("DEPRECATION") this.getSerializable(key) } } diff --git a/core/common/src/main/java/org/mifos/mobile/core/common/utils/Utils.kt b/core/common/src/main/java/org/mifos/mobile/core/common/utils/Utils.kt index 20586025f..440aec9e9 100644 --- a/core/common/src/main/java/org/mifos/mobile/core/common/utils/Utils.kt +++ b/core/common/src/main/java/org/mifos/mobile/core/common/utils/Utils.kt @@ -37,6 +37,7 @@ object Utils { val drawable = menu.getItem(i).icon if (drawable != null) { drawable.mutate() + @Suppress("DEPRECATION") drawable.setColorFilter( ContextCompat.getColor(context!!, color), PorterDuff.Mode.SRC_IN, diff --git a/core/designsystem/src/main/kotlin/org/mifos/mobile/core/designsystem/components/MifosTabPager.kt b/core/designsystem/src/main/kotlin/org/mifos/mobile/core/designsystem/components/MifosTabPager.kt index f7d16f63e..f0e8056b8 100644 --- a/core/designsystem/src/main/kotlin/org/mifos/mobile/core/designsystem/components/MifosTabPager.kt +++ b/core/designsystem/src/main/kotlin/org/mifos/mobile/core/designsystem/components/MifosTabPager.kt @@ -13,6 +13,8 @@ import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.pager.HorizontalPager +import androidx.compose.foundation.pager.PagerState import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Tab import androidx.compose.material3.TabRow @@ -23,10 +25,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp -import com.google.accompanist.pager.HorizontalPager -import com.google.accompanist.pager.PagerState -@Suppress("DEPRECATION") @Composable fun MifosTabPager( pagerState: PagerState, @@ -66,11 +65,11 @@ fun MifosTabPager( HorizontalPager( state = pagerState, - count = tabs.size, modifier = Modifier.fillMaxWidth(), - content = { page -> + pageContent = { page -> content(page) }, + beyondViewportPageCount = tabs.size, ) } } diff --git a/core/model/build.gradle.kts b/core/model/build.gradle.kts index 2a7083558..0aab29000 100644 --- a/core/model/build.gradle.kts +++ b/core/model/build.gradle.kts @@ -30,6 +30,7 @@ dependencies { // For Serialized name implementation(libs.squareup.retrofit.converter.gson) + implementation(libs.androidx.annotation.jvm) testImplementation(libs.junit) androidTestImplementation(libs.androidx.test.ext.junit) diff --git a/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/loan/LoanAccount.kt b/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/loan/LoanAccount.kt index 432c21cfa..409c7a160 100644 --- a/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/loan/LoanAccount.kt +++ b/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/loan/LoanAccount.kt @@ -9,6 +9,7 @@ */ package org.mifos.mobile.core.model.entity.accounts.loan +import android.os.Build import android.os.Parcel import android.os.Parcelable import org.mifos.mobile.core.model.entity.accounts.Account @@ -57,6 +58,7 @@ data class LoanAccount( var timeline: Timeline?, ) : Account(), Parcelable { + @androidx.annotation.RequiresApi(Build.VERSION_CODES.TIRAMISU) constructor(parcel: Parcel) : this( parcel.readLong(), parcel.readString(), @@ -69,16 +71,16 @@ data class LoanAccount( parcel.readString(), parcel.readDouble(), parcel.readDouble(), - parcel.readParcelable(Status::class.java.classLoader), - parcel.readParcelable(LoanType::class.java.classLoader), + parcel.readParcelable(Status::class.java.classLoader, Status::class.java), + parcel.readParcelable(LoanType::class.java.classLoader, LoanType::class.java), parcel.readValue(Int::class.java.classLoader) as? Int, parcel.readDouble(), parcel.readDouble(), - parcel.readParcelable(Currency::class.java.classLoader), + parcel.readParcelable(Currency::class.java.classLoader, Currency::class.java), parcel.readValue(Boolean::class.java.classLoader) as? Boolean, - parcel.readParcelable(Summary::class.java.classLoader), + parcel.readParcelable(Summary::class.java.classLoader, Summary::class.java), parcel.readString(), - parcel.readParcelable(Timeline::class.java.classLoader), + parcel.readParcelable(Timeline::class.java.classLoader, Timeline::class.java), ) override fun writeToParcel(parcel: Parcel, flags: Int) { diff --git a/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/loan/Timeline.kt b/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/loan/Timeline.kt index 49d780426..84588efe9 100644 --- a/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/loan/Timeline.kt +++ b/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/loan/Timeline.kt @@ -9,9 +9,10 @@ */ package org.mifos.mobile.core.model.entity.accounts.loan -import android.os.Parcel import android.os.Parcelable +import kotlinx.parcelize.Parcelize +@Parcelize @Suppress("ktlint:standard:property-naming") data class Timeline( var submittedOnDate: List? = null, @@ -46,74 +47,4 @@ data class Timeline( var withdrawnOnDate: List, -) : Parcelable { - constructor(parcel: Parcel) : this( - arrayListOf().apply { - parcel.readArrayList(Int::class.java.classLoader) - }, - parcel.readString(), - parcel.readString(), - parcel.readString(), - arrayListOf().apply { - parcel.readArrayList(Int::class.java.classLoader) - }, - parcel.readString(), - parcel.readString(), - parcel.readString(), - arrayListOf().apply { - parcel.readArrayList(Int::class.java.classLoader) - }, - arrayListOf().apply { - parcel.readArrayList(Int::class.java.classLoader) - }, - parcel.readString(), - parcel.readString(), - parcel.readString(), - arrayListOf().apply { - parcel.readArrayList(Int::class.java.classLoader) - }, - arrayListOf().apply { - parcel.readArrayList(Int::class.java.classLoader) - }, - arrayListOf().apply { - parcel.readArrayList(Int::class.java.classLoader) - }, - ) - - override fun writeToParcel(parcel: Parcel, flags: Int) { - parcel.writeList(submittedOnDate) - parcel.writeString(submittedByUsername) - parcel.writeString(submittedByFirstname) - parcel.writeString(submittedByLastname) - parcel.writeList(approvedOnDate) - parcel.writeString(approvedByUsername) - parcel.writeString(approvedByFirstname) - parcel.writeString(approvedByLastname) - parcel.writeList(expectedDisbursementDate) - parcel.writeList(actualDisbursementDate) - parcel.writeString(disbursedByUsername) - parcel.writeString(disbursedByFirstname) - parcel.writeString(disbursedByLastname) - parcel.writeList(closedOnDate) - parcel.writeList(expectedMaturityDate) - parcel.writeList(withdrawnOnDate) - } - - override fun describeContents(): Int { - return 0 - } - - companion object { - - @JvmField - var CREATOR: Parcelable.Creator = object : Parcelable.Creator { - override fun createFromParcel(parcel: Parcel): Timeline { - return Timeline(parcel) - } - - override fun newArray(size: Int): Array { - return arrayOfNulls(size) - } - } - } -} +) : Parcelable diff --git a/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/savings/TimeLine.kt b/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/savings/TimeLine.kt index 12d87fd29..cf226bb9c 100644 --- a/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/savings/TimeLine.kt +++ b/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/savings/TimeLine.kt @@ -9,9 +9,10 @@ */ package org.mifos.mobile.core.model.entity.accounts.savings -import android.os.Parcel import android.os.Parcelable +import kotlinx.parcelize.Parcelize +@Parcelize data class TimeLine( var submittedOnDate: List = ArrayList(), @@ -39,62 +40,4 @@ data class TimeLine( var closedOnDate: List, -) : Parcelable { - constructor(parcel: Parcel) : this( - arrayListOf().apply { - parcel.readArrayList(Int::class.java.classLoader) - }, - parcel.readString(), - parcel.readString(), - parcel.readString(), - arrayListOf().apply { - parcel.readArrayList(Int::class.java.classLoader) - }, - parcel.readString(), - parcel.readString(), - parcel.readString(), - arrayListOf().apply { - parcel.readArrayList(Int::class.java.classLoader) - }, - parcel.readString(), - parcel.readString(), - parcel.readString(), - arrayListOf().apply { - parcel.readArrayList(Int::class.java.classLoader) - }, - ) - - override fun writeToParcel(parcel: Parcel, flags: Int) { - parcel.writeList(submittedOnDate) - parcel.writeString(submittedByUsername) - parcel.writeString(submittedByFirstname) - parcel.writeString(submittedByLastname) - parcel.writeList(approvedOnDate) - parcel.writeString(approvedByUsername) - parcel.writeString(approvedByFirstname) - parcel.writeString(approvedByLastname) - parcel.writeList(activatedOnDate) - parcel.writeString(activatedByUsername) - parcel.writeString(activatedByFirstname) - parcel.writeString(activatedByLastname) - parcel.writeList(closedOnDate) - } - - override fun describeContents(): Int { - return 0 - } - - companion object { - - @JvmField - val CREATOR: Parcelable.Creator = object : Parcelable.Creator { - override fun createFromParcel(parcel: Parcel): TimeLine { - return TimeLine(parcel) - } - - override fun newArray(size: Int): Array { - return arrayOfNulls(size) - } - } - } -} +) : Parcelable diff --git a/core/model/src/main/java/org/mifos/mobile/core/model/entity/guarantor/GuarantorPayload.kt b/core/model/src/main/java/org/mifos/mobile/core/model/entity/guarantor/GuarantorPayload.kt index 9cf9ebd3b..c827b565e 100644 --- a/core/model/src/main/java/org/mifos/mobile/core/model/entity/guarantor/GuarantorPayload.kt +++ b/core/model/src/main/java/org/mifos/mobile/core/model/entity/guarantor/GuarantorPayload.kt @@ -14,7 +14,6 @@ package org.mifos.mobile.core.model.entity.guarantor */ import android.os.Parcelable -import kotlinx.android.parcel.RawValue import kotlinx.parcelize.Parcelize @Parcelize @@ -26,7 +25,7 @@ data class GuarantorPayload( var lastname: String? = null, - var guarantorType: @RawValue GuarantorType? = null, + var guarantorType: GuarantorType? = null, var firstname: String? = null, diff --git a/feature/account/src/main/java/org/mifos/mobile/feature/account/clientAccount/screens/ClientAccountsScreen.kt b/feature/account/src/main/java/org/mifos/mobile/feature/account/clientAccount/screens/ClientAccountsScreen.kt index e465435c6..3a029669f 100644 --- a/feature/account/src/main/java/org/mifos/mobile/feature/account/clientAccount/screens/ClientAccountsScreen.kt +++ b/feature/account/src/main/java/org/mifos/mobile/feature/account/clientAccount/screens/ClientAccountsScreen.kt @@ -181,7 +181,7 @@ private fun ClientAccountsTabRow( modifier: Modifier = Modifier, ) { var page by remember { mutableIntStateOf(currentPage) } - val pagerState = rememberPagerState() + val pagerState = androidx.compose.foundation.pager.rememberPagerState { page } val tabs = listOf( stringResource(id = R.string.feature_account_savings), diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8804ad1ea..958e7817d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -114,6 +114,8 @@ jbSavedState = "1.2.2" packageName = "MifosWallet" packageNamespace = "org.mifos.desktop" packageVersion = "1.0.0" +preferenceKtxVersion = "1.2.1" +annotationJvmVersion = "1.9.1" [libraries] accompanist-pager = { group = "com.google.accompanist", name = "accompanist-pager", version.ref = "accompanistVersion" } @@ -312,6 +314,8 @@ moko-permission = { group = "dev.icerock.moko", name = "permissions", version.re moko-permission-compose = { group = "dev.icerock.moko", name = "permissions-compose", version.ref = "mokoPermission" } window-size = { group = "dev.chrisbanes.material3", name = "material3-window-size-class-multiplatform", version.ref = "windowsSizeClass" } +androidx-preference-ktx = { group = "androidx.preference", name = "preference-ktx", version.ref = "preferenceKtxVersion" } +androidx-annotation-jvm = { group = "androidx.annotation", name = "annotation-jvm", version.ref = "annotationJvmVersion" } [bundles] androidx-compose-ui-test = [ diff --git a/libs/pullrefresh/src/main/kotlin/com.mifos.library.pullrefresh/PullRefreshIndicatorTransform.kt b/libs/pullrefresh/src/main/kotlin/com.mifos.library.pullrefresh/PullRefreshIndicatorTransform.kt index 08b24bcf0..94aa52145 100644 --- a/libs/pullrefresh/src/main/kotlin/com.mifos.library.pullrefresh/PullRefreshIndicatorTransform.kt +++ b/libs/pullrefresh/src/main/kotlin/com.mifos.library.pullrefresh/PullRefreshIndicatorTransform.kt @@ -13,11 +13,11 @@ package com.mifos.library.pullrefresh import androidx.compose.animation.core.LinearOutSlowInEasing import androidx.compose.ui.Modifier +import androidx.compose.ui.composed import androidx.compose.ui.draw.drawWithContent import androidx.compose.ui.graphics.drawscope.clipRect import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.platform.debugInspectorInfo -import androidx.compose.ui.platform.inspectable /** * A modifier for translating the position and scaling the size of a pull-to-refresh indicator @@ -28,7 +28,11 @@ import androidx.compose.ui.platform.inspectable * @param state The [PullRefreshState] which determines the position of the indicator. * @param scale A boolean controlling whether the indicator's size scales with pull progress or not. */ -fun Modifier.pullRefreshIndicatorTransform(state: PullRefreshState, scale: Boolean = false) = inspectable( + +fun Modifier.pullRefreshIndicatorTransform( + state: PullRefreshState, + scale: Boolean = false, +): Modifier = composed( inspectorInfo = debugInspectorInfo { name = "pullRefreshIndicatorTransform" properties["state"] = state @@ -36,12 +40,6 @@ fun Modifier.pullRefreshIndicatorTransform(state: PullRefreshState, scale: Boole }, ) { Modifier - // Essentially we only want to clip the at the top, so the indicator will not appear when - // the position is 0. It is preferable to clip the indicator as opposed to the layout that - // contains the indicator, as this would also end up clipping shadows drawn by items in a - // list for example - so we leave the clipping to the scrolling container. We use MAX_VALUE - // for the other dimensions to allow for more room for elevation / arbitrary indicators - we - // only ever really want to clip at the top edge. .drawWithContent { clipRect( top = 0f, diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts index a7ba5874b..1d9b951c2 100644 --- a/shared/build.gradle.kts +++ b/shared/build.gradle.kts @@ -6,7 +6,13 @@ plugins { } kotlin { - androidTarget() + androidTarget { + compilations.all { + kotlinOptions{ + jvmTarget = "17" + } + } + } listOf( iosX64(), From c578efe162a6d39af86b99a7ea28c7c6336b604f Mon Sep 17 00:00:00 2001 From: Darkeye14 Date: Fri, 10 Jan 2025 23:26:04 +0530 Subject: [PATCH 2/5] fixing errors --- androidApp/src/main/res/values-ar/strings.xml | 2 + androidApp/src/main/res/values-bn/strings.xml | 2 + androidApp/src/main/res/values-es/strings.xml | 2 + androidApp/src/main/res/values-fr/strings.xml | 2 + androidApp/src/main/res/values-in/strings.xml | 2 + androidApp/src/main/res/values-km/strings.xml | 2 + androidApp/src/main/res/values-kn/strings.xml | 2 + androidApp/src/main/res/values-my/strings.xml | 2 + androidApp/src/main/res/values-pl/strings.xml | 2 + androidApp/src/main/res/values-pt/strings.xml | 2 + androidApp/src/main/res/values-ru/strings.xml | 2 + androidApp/src/main/res/values-sw/strings.xml | 2 + androidApp/src/main/res/values-te/strings.xml | 2 + androidApp/src/main/res/values-ur/strings.xml | 2 + .../org/mifos/mobile/core/common/Network.kt | 146 ++++++++++++------ .../mobile/core/common/utils/DateHelper.kt | 20 +-- .../core/common/utils/LanguageHelper.kt | 2 +- .../designsystem/components/MifosTabPager.kt | 9 +- .../model/entity/accounts/loan/LoanAccount.kt | 14 +- .../model/entity/accounts/loan/Timeline.kt | 75 ++++++++- .../model/entity/accounts/savings/TimeLine.kt | 63 +++++++- .../entity/guarantor/GuarantorPayload.kt | 3 +- .../screens/ClientAccountsScreen.kt | 2 +- .../PullRefreshIndicatorTransform.kt | 14 +- 24 files changed, 293 insertions(+), 83 deletions(-) diff --git a/androidApp/src/main/res/values-ar/strings.xml b/androidApp/src/main/res/values-ar/strings.xml index fc9dfe802..9db4473a2 100644 --- a/androidApp/src/main/res/values-ar/strings.xml +++ b/androidApp/src/main/res/values-ar/strings.xml @@ -10,6 +10,8 @@ --> ميفوس موبايل + كلمة مرور جديدة + غيير كلمة مرور الحساب تسجيل الدخول %1$s أهلا بك غير متصل بالإنترنت diff --git a/androidApp/src/main/res/values-bn/strings.xml b/androidApp/src/main/res/values-bn/strings.xml index 3b469b8fc..d5e08baab 100644 --- a/androidApp/src/main/res/values-bn/strings.xml +++ b/androidApp/src/main/res/values-bn/strings.xml @@ -10,6 +10,8 @@ --> লগ ইন করুন + নতুন পাসওয়ার্ড + অ্যাকাউন্ট পাসওয়ার্ড পরিবর্তন করুন হ্যালো, %1$s। কোন ইন্টারনেট সংযোগ নেই প্রাথমিক diff --git a/androidApp/src/main/res/values-es/strings.xml b/androidApp/src/main/res/values-es/strings.xml index 10af9cd67..e0ce66a67 100644 --- a/androidApp/src/main/res/values-es/strings.xml +++ b/androidApp/src/main/res/values-es/strings.xml @@ -10,6 +10,8 @@ --> Iniciar sesión + Nueva contraseña + Cambiar la contraseña de la cuenta Hola, %1$s. Falta conexión internet Primario diff --git a/androidApp/src/main/res/values-fr/strings.xml b/androidApp/src/main/res/values-fr/strings.xml index eb067a45d..86b867705 100644 --- a/androidApp/src/main/res/values-fr/strings.xml +++ b/androidApp/src/main/res/values-fr/strings.xml @@ -10,6 +10,8 @@ --> Se connecter + Nouveau mot de passe + Changer le mot de passe du compte Bonjour, %1$s. Pas de connexion internet Primaire diff --git a/androidApp/src/main/res/values-in/strings.xml b/androidApp/src/main/res/values-in/strings.xml index 95b39ad04..91f1e974e 100644 --- a/androidApp/src/main/res/values-in/strings.xml +++ b/androidApp/src/main/res/values-in/strings.xml @@ -10,6 +10,8 @@ --> Masuk + Kata sandi baru + Ubah kata sandi akun Halo, %1$s. Tidak ada koneksi internet Primer diff --git a/androidApp/src/main/res/values-km/strings.xml b/androidApp/src/main/res/values-km/strings.xml index 839a28e33..98a1fc7b6 100644 --- a/androidApp/src/main/res/values-km/strings.xml +++ b/androidApp/src/main/res/values-km/strings.xml @@ -9,6 +9,8 @@ See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md --> + ពាក្យសម្ងាត់ថ្មី + ប្តូរពាក្យសម្ងាត់គណនី ចូល សួស្តី, %1$s ។ គ្មានការតភ្ជាប់អ៊ីនធឺណិត diff --git a/androidApp/src/main/res/values-kn/strings.xml b/androidApp/src/main/res/values-kn/strings.xml index 47c9e6fb7..e2e5f1c09 100644 --- a/androidApp/src/main/res/values-kn/strings.xml +++ b/androidApp/src/main/res/values-kn/strings.xml @@ -10,6 +10,8 @@ --> ಲಾಗ್ ಇನ್ ಮಾಡಿ + ಹೊಸ ಪಾಸ್‌ವರ್ಡ್ + ಖಾತೆ ಪಾಸ್‌ವರ್ಡ್ ಬದಲಾಯಿಸಿ ಹಲೋ, %1$s. ಇಂಟರ್ನೆಟ್ ಸಂಪರ್ಕವಿಲ್ಲ ಪ್ರಾಥಮಿಕ diff --git a/androidApp/src/main/res/values-my/strings.xml b/androidApp/src/main/res/values-my/strings.xml index ac34907d1..54f3dca07 100644 --- a/androidApp/src/main/res/values-my/strings.xml +++ b/androidApp/src/main/res/values-my/strings.xml @@ -10,7 +10,9 @@ --> Mifos မိုဘိုင်း + စကားဝှက်အသစ် လော့ဂ်အင် + အကောင့်စကားဝှက်ပြောင် း ပါ %1$s ကိုမှလှိုက်လှဲစွာကြိုဆိုပါသည် အင်တာနက်ချိတ်ဆက်မ အခြေခံပညာ diff --git a/androidApp/src/main/res/values-pl/strings.xml b/androidApp/src/main/res/values-pl/strings.xml index d2dd4bbbb..a34492ed5 100644 --- a/androidApp/src/main/res/values-pl/strings.xml +++ b/androidApp/src/main/res/values-pl/strings.xml @@ -10,6 +10,8 @@ --> Zaloguj Się + Nowe hasło + Zmień hasło do konta Witaj, %1$s. Brak połączenia z Internetem Podstawowy diff --git a/androidApp/src/main/res/values-pt/strings.xml b/androidApp/src/main/res/values-pt/strings.xml index 80ec682fd..3f6b4d8db 100644 --- a/androidApp/src/main/res/values-pt/strings.xml +++ b/androidApp/src/main/res/values-pt/strings.xml @@ -10,6 +10,8 @@ --> Mifos Mobile + Nova senha + Alterar senha da conta Entrar Bem-vindo %1$s Não conectado à internet diff --git a/androidApp/src/main/res/values-ru/strings.xml b/androidApp/src/main/res/values-ru/strings.xml index 655eba2f7..d6158e522 100644 --- a/androidApp/src/main/res/values-ru/strings.xml +++ b/androidApp/src/main/res/values-ru/strings.xml @@ -10,6 +10,8 @@ --> Вход + Новый пароль + Изменить пароль учетной записи Здравствуйте, %1$s. Нет подключения к интернету Первичный diff --git a/androidApp/src/main/res/values-sw/strings.xml b/androidApp/src/main/res/values-sw/strings.xml index 075d11734..73674432e 100644 --- a/androidApp/src/main/res/values-sw/strings.xml +++ b/androidApp/src/main/res/values-sw/strings.xml @@ -10,6 +10,8 @@ --> Ingia + Nenosiri la akaunti + Badilisha nenosiri la akaunti Sawadi, %1$s. Hakuna uhusiano wa internet Msingi diff --git a/androidApp/src/main/res/values-te/strings.xml b/androidApp/src/main/res/values-te/strings.xml index 979e447fc..770abcfab 100644 --- a/androidApp/src/main/res/values-te/strings.xml +++ b/androidApp/src/main/res/values-te/strings.xml @@ -11,6 +11,8 @@ Mifos Mobile లాగిన్ + కొత్త పాస్‌వర్డ్ + ాతా పాస్‌వర్డ్ మార్చండి స్వాగతం %1$s మా గురించి ఇంటర్నెట్కి కనెక్ట్ చేయబడలేదు diff --git a/androidApp/src/main/res/values-ur/strings.xml b/androidApp/src/main/res/values-ur/strings.xml index 0ddd267dd..48f36eca9 100644 --- a/androidApp/src/main/res/values-ur/strings.xml +++ b/androidApp/src/main/res/values-ur/strings.xml @@ -11,6 +11,8 @@ Mifos موبائل لاگ ان کریں + نیا پاس ورڈ + اکاؤنٹ پاس ورڈ تبدیل کریں خوش آمدید %1$s انٹرنیٹ سے منسلک نہیں بنیادی diff --git a/core/common/src/main/java/org/mifos/mobile/core/common/Network.kt b/core/common/src/main/java/org/mifos/mobile/core/common/Network.kt index c70b79340..5f5f941b0 100644 --- a/core/common/src/main/java/org/mifos/mobile/core/common/Network.kt +++ b/core/common/src/main/java/org/mifos/mobile/core/common/Network.kt @@ -12,9 +12,21 @@ package org.mifos.mobile.core.common import android.annotation.SuppressLint import android.content.Context import android.net.ConnectivityManager -import android.net.NetworkCapabilities +import android.net.NetworkInfo +import android.telephony.TelephonyManager object Network { + /** + * Get the network info + * + * @param context + * @return + */ + @SuppressLint("MissingPermission") + private fun getNetworkInfo(context: Context): NetworkInfo? { + val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager + return cm.activeNetworkInfo + } /** * Check if there is any connectivity @@ -22,56 +34,98 @@ object Network { * @param context * @return */ - @SuppressLint("MissingPermission") @JvmStatic fun isConnected(context: Context?): Boolean { - if (context == null) { - return false + val info = getNetworkInfo(context!!) + if (info != null) { + return info.isConnected } - val connectivityManager = - context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager - val networkCapabilities = connectivityManager.activeNetwork ?: return false - val actNw = - connectivityManager.getNetworkCapabilities(networkCapabilities) ?: return false - return when { - actNw.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> true - actNw.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> true - actNw.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> true - else -> false + return false + } + + /** + * Check if there is any connectivity to a Wifi network + * + * @param context + * @param type + * @return + */ + fun isConnectedWifi(context: Context): Boolean { + val info = getNetworkInfo(context) + if (info != null) { + return info.isConnected && info.type == ConnectivityManager.TYPE_WIFI } + return false } -} -/** - * Check if there is any connectivity to a Wifi network - * - * @param context - * @param type - * @return - */ -@SuppressLint("MissingPermission") -fun isConnectedWifi(context: Context): Boolean { - val connectivityManager = - context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager - val networkCapabilities = connectivityManager.activeNetwork ?: return false - val actNw = - connectivityManager.getNetworkCapabilities(networkCapabilities) ?: return false - return actNw.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -} + /** + * Check if there is any connectivity to a mobile network + * + * @param context + * @param type + * @return + */ + fun isConnectedMobile(context: Context): Boolean { + val info = getNetworkInfo(context) + if (info != null) { + return info.isConnected && info.type == ConnectivityManager.TYPE_MOBILE + } + return false + } -/** - * Check if there is any connectivity to a mobile network - * - * @param context - * @param type - * @return - */ -@SuppressLint("MissingPermission") -fun isConnectedMobile(context: Context): Boolean { - val connectivityManager = - context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager - val networkCapabilities = connectivityManager.activeNetwork ?: return false - val actNw = - connectivityManager.getNetworkCapabilities(networkCapabilities) ?: return false - return actNw.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) + /** + * Check if there is fast connectivity + * + * @param context + * @return + */ + fun isConnectedFast(context: Context): Boolean { + val info = getNetworkInfo(context) + if (info != null) { + return info.isConnected && isConnectionFast(info.type, info.subtype) + } + return false + } + + /** + * Check if the connection is fast + * + * @param type + * @param subType + * @return + */ + @Suppress("CyclomaticComplexMethod") + private fun isConnectionFast(type: Int, subType: Int): Boolean { + return when (type) { + ConnectivityManager.TYPE_WIFI -> { + true + } + + ConnectivityManager.TYPE_MOBILE -> { + when (subType) { + TelephonyManager.NETWORK_TYPE_1xRTT -> false // ~ 50-100 kbps + TelephonyManager.NETWORK_TYPE_CDMA -> false // ~ 14-64 kbps + TelephonyManager.NETWORK_TYPE_EDGE -> false // ~ 50-100 kbps + TelephonyManager.NETWORK_TYPE_EVDO_0 -> true // ~ 400-1000 kbps + TelephonyManager.NETWORK_TYPE_EVDO_A -> true // ~ 600-1400 kbps + TelephonyManager.NETWORK_TYPE_GPRS -> false // ~ 100 kbps + TelephonyManager.NETWORK_TYPE_HSDPA -> true // ~ 2-14 Mbps + TelephonyManager.NETWORK_TYPE_HSPA -> true // ~ 700-1700 kbps + TelephonyManager.NETWORK_TYPE_HSUPA -> true // ~ 1-23 Mbps + TelephonyManager.NETWORK_TYPE_UMTS -> true // ~ 400-7000 kbps + TelephonyManager.NETWORK_TYPE_EHRPD -> true // ~ 1-2 Mbps + TelephonyManager.NETWORK_TYPE_EVDO_B -> true // ~ 5 Mbps + TelephonyManager.NETWORK_TYPE_HSPAP -> true // ~ 10-20 Mbps + TelephonyManager.NETWORK_TYPE_IDEN -> false // ~25 kbps + TelephonyManager.NETWORK_TYPE_LTE -> true // ~ 10+ Mbps + TelephonyManager.NETWORK_TYPE_UNKNOWN -> false + else -> false + } + } + + else -> { + false + } + } + } } diff --git a/core/common/src/main/java/org/mifos/mobile/core/common/utils/DateHelper.kt b/core/common/src/main/java/org/mifos/mobile/core/common/utils/DateHelper.kt index 242425fba..2895dac1c 100755 --- a/core/common/src/main/java/org/mifos/mobile/core/common/utils/DateHelper.kt +++ b/core/common/src/main/java/org/mifos/mobile/core/common/utils/DateHelper.kt @@ -68,18 +68,18 @@ object DateHelper { val finalFormat = SimpleDateFormat(format, Locale.ENGLISH) var date: Date? = null try { - date = dateString?.let { pickerFormat.parse(it) } + date = pickerFormat.parse(dateString) } catch (e: ParseException) { - e.localizedMessage?.let { Log.d(LOG_TAG, it) } + Log.d(LOG_TAG, e.localizedMessage) } - return finalFormat.format(date!!) + return finalFormat.format(date) } fun getSpecificFormat(format: String?, dateLong: Long?): String? { try { return SimpleDateFormat(format, Locale.getDefault()).format(dateLong) } catch (e: ParseException) { - e.localizedMessage?.let { Log.d(LOG_TAG, it) } + Log.d(LOG_TAG, e.localizedMessage) return null } } @@ -93,11 +93,11 @@ object DateHelper { val finalFormat = SimpleDateFormat(requiredFormat, Locale.ENGLISH) var date: Date? = null try { - date = dateString?.let { pickerFormat.parse(it) } + date = pickerFormat.parse(dateString) } catch (e: ParseException) { - e.localizedMessage?.let { Log.d(LOG_TAG, it) } + Log.d(LOG_TAG, e.localizedMessage) } - return finalFormat.format(date!!) + return finalFormat.format(date) } /** @@ -127,7 +127,7 @@ object DateHelper { val sdf = SimpleDateFormat(pattern, Locale.getDefault()) var date: Date? = null try { - date = dateStr?.let { sdf.parse(it) } + date = sdf.parse(dateStr) } catch (e: ParseException) { Log.d("TAG", e.message ?: "") } @@ -154,13 +154,13 @@ object DateHelper { fun getDateAsStringFromLong(timeInMillis: Long?): String { val sdf = SimpleDateFormat("dd MMM yyyy", Locale.getDefault()) - return sdf.format(Date(timeInMillis!!)) + return sdf.format(timeInMillis?.let { Date(it) }) } @JvmStatic fun getDateAndTimeAsStringFromLong(timeInMillis: Long?): String { val sdf = SimpleDateFormat("HH:mm a dd MMM yyyy", Locale.getDefault()) - return sdf.format(Date(timeInMillis!!)) + return sdf.format(timeInMillis?.let { Date(it) }) } } diff --git a/core/common/src/main/java/org/mifos/mobile/core/common/utils/LanguageHelper.kt b/core/common/src/main/java/org/mifos/mobile/core/common/utils/LanguageHelper.kt index 1f21fa97a..20ae98cf5 100644 --- a/core/common/src/main/java/org/mifos/mobile/core/common/utils/LanguageHelper.kt +++ b/core/common/src/main/java/org/mifos/mobile/core/common/utils/LanguageHelper.kt @@ -10,7 +10,7 @@ package org.mifos.mobile.core.common.utils import android.content.Context -import androidx.preference.PreferenceManager +import android.preference.PreferenceManager import org.mifos.mobile.core.common.R import java.util.Locale diff --git a/core/designsystem/src/main/kotlin/org/mifos/mobile/core/designsystem/components/MifosTabPager.kt b/core/designsystem/src/main/kotlin/org/mifos/mobile/core/designsystem/components/MifosTabPager.kt index f0e8056b8..f7d16f63e 100644 --- a/core/designsystem/src/main/kotlin/org/mifos/mobile/core/designsystem/components/MifosTabPager.kt +++ b/core/designsystem/src/main/kotlin/org/mifos/mobile/core/designsystem/components/MifosTabPager.kt @@ -13,8 +13,6 @@ import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.pager.HorizontalPager -import androidx.compose.foundation.pager.PagerState import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Tab import androidx.compose.material3.TabRow @@ -25,7 +23,10 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp +import com.google.accompanist.pager.HorizontalPager +import com.google.accompanist.pager.PagerState +@Suppress("DEPRECATION") @Composable fun MifosTabPager( pagerState: PagerState, @@ -65,11 +66,11 @@ fun MifosTabPager( HorizontalPager( state = pagerState, + count = tabs.size, modifier = Modifier.fillMaxWidth(), - pageContent = { page -> + content = { page -> content(page) }, - beyondViewportPageCount = tabs.size, ) } } diff --git a/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/loan/LoanAccount.kt b/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/loan/LoanAccount.kt index 409c7a160..6a8e7baee 100644 --- a/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/loan/LoanAccount.kt +++ b/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/loan/LoanAccount.kt @@ -9,7 +9,6 @@ */ package org.mifos.mobile.core.model.entity.accounts.loan -import android.os.Build import android.os.Parcel import android.os.Parcelable import org.mifos.mobile.core.model.entity.accounts.Account @@ -57,8 +56,7 @@ data class LoanAccount( var timeline: Timeline?, -) : Account(), Parcelable { - @androidx.annotation.RequiresApi(Build.VERSION_CODES.TIRAMISU) + ) : Account(), Parcelable { constructor(parcel: Parcel) : this( parcel.readLong(), parcel.readString(), @@ -71,16 +69,16 @@ data class LoanAccount( parcel.readString(), parcel.readDouble(), parcel.readDouble(), - parcel.readParcelable(Status::class.java.classLoader, Status::class.java), - parcel.readParcelable(LoanType::class.java.classLoader, LoanType::class.java), + parcel.readParcelable(Status::class.java.classLoader), + parcel.readParcelable(LoanType::class.java.classLoader), parcel.readValue(Int::class.java.classLoader) as? Int, parcel.readDouble(), parcel.readDouble(), - parcel.readParcelable(Currency::class.java.classLoader, Currency::class.java), + parcel.readParcelable(Currency::class.java.classLoader), parcel.readValue(Boolean::class.java.classLoader) as? Boolean, - parcel.readParcelable(Summary::class.java.classLoader, Summary::class.java), + parcel.readParcelable(Summary::class.java.classLoader), parcel.readString(), - parcel.readParcelable(Timeline::class.java.classLoader, Timeline::class.java), + parcel.readParcelable(Timeline::class.java.classLoader), ) override fun writeToParcel(parcel: Parcel, flags: Int) { diff --git a/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/loan/Timeline.kt b/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/loan/Timeline.kt index 84588efe9..ebd631513 100644 --- a/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/loan/Timeline.kt +++ b/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/loan/Timeline.kt @@ -9,10 +9,9 @@ */ package org.mifos.mobile.core.model.entity.accounts.loan +import android.os.Parcel import android.os.Parcelable -import kotlinx.parcelize.Parcelize -@Parcelize @Suppress("ktlint:standard:property-naming") data class Timeline( var submittedOnDate: List? = null, @@ -47,4 +46,74 @@ data class Timeline( var withdrawnOnDate: List, -) : Parcelable + ) : Parcelable { + constructor(parcel: Parcel) : this( + arrayListOf().apply { + parcel.readArrayList(Int::class.java.classLoader) + }, + parcel.readString(), + parcel.readString(), + parcel.readString(), + arrayListOf().apply { + parcel.readArrayList(Int::class.java.classLoader) + }, + parcel.readString(), + parcel.readString(), + parcel.readString(), + arrayListOf().apply { + parcel.readArrayList(Int::class.java.classLoader) + }, + arrayListOf().apply { + parcel.readArrayList(Int::class.java.classLoader) + }, + parcel.readString(), + parcel.readString(), + parcel.readString(), + arrayListOf().apply { + parcel.readArrayList(Int::class.java.classLoader) + }, + arrayListOf().apply { + parcel.readArrayList(Int::class.java.classLoader) + }, + arrayListOf().apply { + parcel.readArrayList(Int::class.java.classLoader) + }, + ) + + override fun writeToParcel(parcel: Parcel, flags: Int) { + parcel.writeList(submittedOnDate) + parcel.writeString(submittedByUsername) + parcel.writeString(submittedByFirstname) + parcel.writeString(submittedByLastname) + parcel.writeList(approvedOnDate) + parcel.writeString(approvedByUsername) + parcel.writeString(approvedByFirstname) + parcel.writeString(approvedByLastname) + parcel.writeList(expectedDisbursementDate) + parcel.writeList(actualDisbursementDate) + parcel.writeString(disbursedByUsername) + parcel.writeString(disbursedByFirstname) + parcel.writeString(disbursedByLastname) + parcel.writeList(closedOnDate) + parcel.writeList(expectedMaturityDate) + parcel.writeList(withdrawnOnDate) + } + + override fun describeContents(): Int { + return 0 + } + + companion object { + + @JvmField + var CREATOR: Parcelable.Creator = object : Parcelable.Creator { + override fun createFromParcel(parcel: Parcel): Timeline { + return Timeline(parcel) + } + + override fun newArray(size: Int): Array { + return arrayOfNulls(size) + } + } + } +} diff --git a/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/savings/TimeLine.kt b/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/savings/TimeLine.kt index cf226bb9c..e84247471 100644 --- a/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/savings/TimeLine.kt +++ b/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/savings/TimeLine.kt @@ -9,10 +9,9 @@ */ package org.mifos.mobile.core.model.entity.accounts.savings +import android.os.Parcel import android.os.Parcelable -import kotlinx.parcelize.Parcelize -@Parcelize data class TimeLine( var submittedOnDate: List = ArrayList(), @@ -40,4 +39,62 @@ data class TimeLine( var closedOnDate: List, -) : Parcelable + ) : Parcelable { + constructor(parcel: Parcel) : this( + arrayListOf().apply { + parcel.readArrayList(Int::class.java.classLoader) + }, + parcel.readString(), + parcel.readString(), + parcel.readString(), + arrayListOf().apply { + parcel.readArrayList(Int::class.java.classLoader) + }, + parcel.readString(), + parcel.readString(), + parcel.readString(), + arrayListOf().apply { + parcel.readArrayList(Int::class.java.classLoader) + }, + parcel.readString(), + parcel.readString(), + parcel.readString(), + arrayListOf().apply { + parcel.readArrayList(Int::class.java.classLoader) + }, + ) + + override fun writeToParcel(parcel: Parcel, flags: Int) { + parcel.writeList(submittedOnDate) + parcel.writeString(submittedByUsername) + parcel.writeString(submittedByFirstname) + parcel.writeString(submittedByLastname) + parcel.writeList(approvedOnDate) + parcel.writeString(approvedByUsername) + parcel.writeString(approvedByFirstname) + parcel.writeString(approvedByLastname) + parcel.writeList(activatedOnDate) + parcel.writeString(activatedByUsername) + parcel.writeString(activatedByFirstname) + parcel.writeString(activatedByLastname) + parcel.writeList(closedOnDate) + } + + override fun describeContents(): Int { + return 0 + } + + companion object { + + @JvmField + val CREATOR: Parcelable.Creator = object : Parcelable.Creator { + override fun createFromParcel(parcel: Parcel): TimeLine { + return TimeLine(parcel) + } + + override fun newArray(size: Int): Array { + return arrayOfNulls(size) + } + } + } +} diff --git a/core/model/src/main/java/org/mifos/mobile/core/model/entity/guarantor/GuarantorPayload.kt b/core/model/src/main/java/org/mifos/mobile/core/model/entity/guarantor/GuarantorPayload.kt index c827b565e..9cf9ebd3b 100644 --- a/core/model/src/main/java/org/mifos/mobile/core/model/entity/guarantor/GuarantorPayload.kt +++ b/core/model/src/main/java/org/mifos/mobile/core/model/entity/guarantor/GuarantorPayload.kt @@ -14,6 +14,7 @@ package org.mifos.mobile.core.model.entity.guarantor */ import android.os.Parcelable +import kotlinx.android.parcel.RawValue import kotlinx.parcelize.Parcelize @Parcelize @@ -25,7 +26,7 @@ data class GuarantorPayload( var lastname: String? = null, - var guarantorType: GuarantorType? = null, + var guarantorType: @RawValue GuarantorType? = null, var firstname: String? = null, diff --git a/feature/account/src/main/java/org/mifos/mobile/feature/account/clientAccount/screens/ClientAccountsScreen.kt b/feature/account/src/main/java/org/mifos/mobile/feature/account/clientAccount/screens/ClientAccountsScreen.kt index 3a029669f..e465435c6 100644 --- a/feature/account/src/main/java/org/mifos/mobile/feature/account/clientAccount/screens/ClientAccountsScreen.kt +++ b/feature/account/src/main/java/org/mifos/mobile/feature/account/clientAccount/screens/ClientAccountsScreen.kt @@ -181,7 +181,7 @@ private fun ClientAccountsTabRow( modifier: Modifier = Modifier, ) { var page by remember { mutableIntStateOf(currentPage) } - val pagerState = androidx.compose.foundation.pager.rememberPagerState { page } + val pagerState = rememberPagerState() val tabs = listOf( stringResource(id = R.string.feature_account_savings), diff --git a/libs/pullrefresh/src/main/kotlin/com.mifos.library.pullrefresh/PullRefreshIndicatorTransform.kt b/libs/pullrefresh/src/main/kotlin/com.mifos.library.pullrefresh/PullRefreshIndicatorTransform.kt index 94aa52145..08b24bcf0 100644 --- a/libs/pullrefresh/src/main/kotlin/com.mifos.library.pullrefresh/PullRefreshIndicatorTransform.kt +++ b/libs/pullrefresh/src/main/kotlin/com.mifos.library.pullrefresh/PullRefreshIndicatorTransform.kt @@ -13,11 +13,11 @@ package com.mifos.library.pullrefresh import androidx.compose.animation.core.LinearOutSlowInEasing import androidx.compose.ui.Modifier -import androidx.compose.ui.composed import androidx.compose.ui.draw.drawWithContent import androidx.compose.ui.graphics.drawscope.clipRect import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.platform.debugInspectorInfo +import androidx.compose.ui.platform.inspectable /** * A modifier for translating the position and scaling the size of a pull-to-refresh indicator @@ -28,11 +28,7 @@ import androidx.compose.ui.platform.debugInspectorInfo * @param state The [PullRefreshState] which determines the position of the indicator. * @param scale A boolean controlling whether the indicator's size scales with pull progress or not. */ - -fun Modifier.pullRefreshIndicatorTransform( - state: PullRefreshState, - scale: Boolean = false, -): Modifier = composed( +fun Modifier.pullRefreshIndicatorTransform(state: PullRefreshState, scale: Boolean = false) = inspectable( inspectorInfo = debugInspectorInfo { name = "pullRefreshIndicatorTransform" properties["state"] = state @@ -40,6 +36,12 @@ fun Modifier.pullRefreshIndicatorTransform( }, ) { Modifier + // Essentially we only want to clip the at the top, so the indicator will not appear when + // the position is 0. It is preferable to clip the indicator as opposed to the layout that + // contains the indicator, as this would also end up clipping shadows drawn by items in a + // list for example - so we leave the clipping to the scrolling container. We use MAX_VALUE + // for the other dimensions to allow for more room for elevation / arbitrary indicators - we + // only ever really want to clip at the top edge. .drawWithContent { clipRect( top = 0f, From 508c1561d59d5c02d7dceae796c3a2b42d7c223a Mon Sep 17 00:00:00 2001 From: Darkeye14 Date: Fri, 10 Jan 2025 23:31:18 +0530 Subject: [PATCH 3/5] MM-110 --- .../mifos/mobile/core/model/entity/accounts/loan/LoanAccount.kt | 2 +- .../mifos/mobile/core/model/entity/accounts/loan/Timeline.kt | 2 +- .../mifos/mobile/core/model/entity/accounts/savings/TimeLine.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/loan/LoanAccount.kt b/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/loan/LoanAccount.kt index 6a8e7baee..432c21cfa 100644 --- a/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/loan/LoanAccount.kt +++ b/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/loan/LoanAccount.kt @@ -56,7 +56,7 @@ data class LoanAccount( var timeline: Timeline?, - ) : Account(), Parcelable { +) : Account(), Parcelable { constructor(parcel: Parcel) : this( parcel.readLong(), parcel.readString(), diff --git a/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/loan/Timeline.kt b/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/loan/Timeline.kt index ebd631513..49d780426 100644 --- a/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/loan/Timeline.kt +++ b/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/loan/Timeline.kt @@ -46,7 +46,7 @@ data class Timeline( var withdrawnOnDate: List, - ) : Parcelable { +) : Parcelable { constructor(parcel: Parcel) : this( arrayListOf().apply { parcel.readArrayList(Int::class.java.classLoader) diff --git a/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/savings/TimeLine.kt b/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/savings/TimeLine.kt index e84247471..12d87fd29 100644 --- a/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/savings/TimeLine.kt +++ b/core/model/src/main/java/org/mifos/mobile/core/model/entity/accounts/savings/TimeLine.kt @@ -39,7 +39,7 @@ data class TimeLine( var closedOnDate: List, - ) : Parcelable { +) : Parcelable { constructor(parcel: Parcel) : this( arrayListOf().apply { parcel.readArrayList(Int::class.java.classLoader) From de84dfa4a0555b64bc73cda9b5df01eb432162e5 Mon Sep 17 00:00:00 2001 From: Darkeye14 Date: Sat, 11 Jan 2025 16:56:22 +0530 Subject: [PATCH 4/5] MM-110 --- core/model/build.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/core/model/build.gradle.kts b/core/model/build.gradle.kts index 0aab29000..2a7083558 100644 --- a/core/model/build.gradle.kts +++ b/core/model/build.gradle.kts @@ -30,7 +30,6 @@ dependencies { // For Serialized name implementation(libs.squareup.retrofit.converter.gson) - implementation(libs.androidx.annotation.jvm) testImplementation(libs.junit) androidTestImplementation(libs.androidx.test.ext.junit) From eb731f6b45f55cd897459f31d0bc2dea34834395 Mon Sep 17 00:00:00 2001 From: Darkeye14 Date: Mon, 13 Jan 2025 23:05:32 +0530 Subject: [PATCH 5/5] spotless issue --- .../src/demo/res/mipmap-anydpi-v26/ic_launcher.xml | 9 +++++++++ .../src/demo/res/mipmap-anydpi-v26/ic_launcher_round.xml | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/androidApp/src/demo/res/mipmap-anydpi-v26/ic_launcher.xml b/androidApp/src/demo/res/mipmap-anydpi-v26/ic_launcher.xml index 036d09bc5..1c76cd711 100644 --- a/androidApp/src/demo/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/androidApp/src/demo/res/mipmap-anydpi-v26/ic_launcher.xml @@ -1,4 +1,13 @@ + diff --git a/androidApp/src/demo/res/mipmap-anydpi-v26/ic_launcher_round.xml b/androidApp/src/demo/res/mipmap-anydpi-v26/ic_launcher_round.xml index 036d09bc5..1c76cd711 100644 --- a/androidApp/src/demo/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ b/androidApp/src/demo/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -1,4 +1,13 @@ +