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

fix: assembleRelease and build issues #2736

Open
wants to merge 6 commits into
base: development
Choose a base branch
from
Open
Changes from 1 commit
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
Next Next commit
Lint issues MM-110
  • Loading branch information
Darkeye14 committed Jan 10, 2025
commit 3fe7174f911e9added7a4e56236b22eed44e9e34
23 changes: 23 additions & 0 deletions androidApp/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -9,6 +9,9 @@
See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
-->
<resources>
<string name="change_account_password">Change Account Password</string>
<string name="new_password">New Password</string>
<string name="current_password">Current Password</string>
<string name="feature_about_app_name">Mifos Mobile</string>
<string name="login">Login</string>
<string name="toast_welcome">Welcome %1$s</string>
@@ -609,6 +612,26 @@
<item>فارسی</item>
</string-array>

<string-array name="faq_qs">
<item>How to apply for a new account?</item>
<item>Where can I view my profile information?</item>
<item>Where can I see my savings account transactions?</item>
<item>What is the use of a QR code?</item>
<item>How to create a beneficiary using a QR code?</item>
<item>How to make a payment for a loan account?</item>
</string-array>

<string-array name="faq_ans">
<item>To apply for a loan account, click on "Report loan application" on the home screen.</item>
<item>You can view your profile information by clicking on the profile picture on the main page of the application.</item>
<item>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.</item>
<item>The QR code of all loan or savings accounts can be shared with other users which will allow them to create a beneficiary.</item>
<item>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.</item>
<item>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.</item>
</string-array>

<string-array name="core_common_languages_value" translatable="false">
<item>System_Language</item>
<item>en</item>
2 changes: 1 addition & 1 deletion config/detekt/detekt.yml
Original file line number Diff line number Diff line change
@@ -828,7 +828,7 @@ style:
active: false
ReturnCount:
active: true
max: 2
max: 4
excludedFunctions:
- "equals"
excludeLabeled: false
6 changes: 6 additions & 0 deletions core/common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -14,8 +14,14 @@ plugins {

android {
namespace = "org.mifos.mobile.core.common"

lint {
disable.add( "NullSafeMutableLiveData" )
}

}

dependencies {

implementation(libs.androidx.preference.ktx)
}
146 changes: 46 additions & 100 deletions core/common/src/main/java/org/mifos/mobile/core/common/Network.kt
Original file line number Diff line number Diff line change
@@ -12,120 +12,66 @@ 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
*
* @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)
}
Original file line number Diff line number Diff line change
@@ -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!!))
}
}

Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -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)
}
}
Original file line number Diff line number Diff line change
@@ -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,
Original file line number Diff line number Diff line change
@@ -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,
)
}
}
1 change: 1 addition & 0 deletions core/model/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@ dependencies {

// For Serialized name
implementation(libs.squareup.retrofit.converter.gson)
implementation(libs.androidx.annotation.jvm)
Darkeye14 marked this conversation as resolved.
Show resolved Hide resolved

testImplementation(libs.junit)
androidTestImplementation(libs.androidx.test.ext.junit)
Loading