Skip to content

Commit

Permalink
MIFOSAC-293 Applied Spotless And Detekt in Core: Common (#2253)
Browse files Browse the repository at this point in the history
  • Loading branch information
kapmaurya authored Dec 6, 2024
1 parent b460b21 commit a6299d9
Show file tree
Hide file tree
Showing 23 changed files with 290 additions and 135 deletions.
9 changes: 9 additions & 0 deletions core/common/build.gradle.kts
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
*/
plugins {
alias(libs.plugins.mifos.android.library)
alias(libs.plugins.mifos.android.hilt)
Expand Down
9 changes: 9 additions & 0 deletions core/common/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
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.common.enums

enum class MifosAppLanguage(val code: String, val displayName: String) {
Expand All @@ -19,7 +28,8 @@ enum class MifosAppLanguage(val code: String, val displayName: String) {
PORTUGUESE("pt", "Português"),
RUSSIAN("ru", "русский"),
SWAHILI("sw", "Kiswahili"),
FARSI("fa", "فارسی");
FARSI("fa", "فارسی"),
;

companion object {
fun fromCode(code: String): MifosAppLanguage {
Expand All @@ -30,4 +40,4 @@ enum class MifosAppLanguage(val code: String, val displayName: String) {
override fun toString(): String {
return displayName
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/*
* This project is licensed under the open source MPL V2.
* 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.common.model.user
Expand All @@ -12,5 +17,5 @@ data class Role(

var name: String? = null,

var description: String? = null
)
var description: String? = null,
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/*
* This project is licensed under the open source MPL V2.
* 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.common.model.user
Expand All @@ -20,4 +25,4 @@ class User {
var roles: List<Role> = ArrayList()

var permissions: List<String> = ArrayList()
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +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.common.network

import javax.inject.Qualifier
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.common.network.di

import com.mifos.core.common.network.Dispatcher
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.common.network.di

import com.mifos.core.common.network.Dispatcher
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.common.utils

import android.os.Build
Expand All @@ -14,4 +23,4 @@ object AndroidVersionUtil {
fun isApiVersionGreaterOrEqual(thisVersion: Int): Boolean {
return Build.VERSION.SDK_INT >= thisVersion
}
}
}
11 changes: 10 additions & 1 deletion core/common/src/main/java/com/mifos/core/common/utils/BaseUrl.kt
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.common.utils

import com.mifos.core.common.BuildConfig
Expand All @@ -17,4 +26,4 @@ object BaseUrl {
val PORT = configs.port

val TENANT = configs.tenant
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/*
* This project is licensed under the open source MPL V2.
* 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.common.utils
Expand All @@ -26,7 +31,7 @@ object Constants {
const val ENTITY_TYPE_STAFF = "staff"
const val ENTITY_TYPE_CLIENT_IDENTIFIERS = "client_identifiers"

//Search Entities
// Search Entities
const val SEARCH_ENTITY_CLIENT = "CLIENT"
const val SEARCH_ENTITY_GROUP = "GROUP"
const val SEARCH_ENTITY_LOAN = "LOAN"
Expand Down Expand Up @@ -94,7 +99,7 @@ object Constants {
const val SAVED = "SAVED"
const val FILLNOW = "FillNow"

//This needs to be 8 bits because validateRequestPermissionsRequestCode
// This needs to be 8 bits because validateRequestPermissionsRequestCode
// in FragmentActivity requires requestCode to be of 8 bits, meaning the range is from 0 to 255.
const val REQUEST_PERMISSION_SETTING = 254

Expand Down Expand Up @@ -206,7 +211,6 @@ object Constants {
const val IS_TO_UPDATE_PASS_CODE = "updatePassCode"
const val HAS_SETTING_CHANGED = "hasSettingsChanged"


const val TENANT = "tenant"
const val BASE_URL = "base_url"
const val PASSCODE = "preferences_mifos_passcode_string"
Expand All @@ -221,4 +225,4 @@ object Constants {
const val DATA_TABLE_NAV_DATA = "data_table_nav_data"
const val DATA_TABLE_DATA_NAV_DATA = "data_table_data_nav_data"
const val DATA_TABLE_LIST_NAV_DATA = "data_table_list_nav_data"
}
}
24 changes: 13 additions & 11 deletions core/common/src/main/java/com/mifos/core/common/utils/DateHelper.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/*
* This project is licensed under the open source MPL V2.
* 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.common.utils
Expand Down Expand Up @@ -66,7 +71,7 @@ object DateHelper {
builder.append(splittedDate[2])
}
return builder.toString()
//Return as dd-mmm-yyyy
// Return as dd-mmm-yyyy
}

/**
Expand All @@ -87,7 +92,7 @@ object DateHelper {
builder.append(splittedDate[2])
}
return builder.toString()
//Return as dd-mmm-yyyy
// Return as dd-mmm-yyyy
}

/**
Expand Down Expand Up @@ -155,23 +160,20 @@ object DateHelper {
* and negative int if date1 < date2
*/
fun dateComparator(date1: List<Int>, date2: List<Int>): Int {

/*
* Each List contains 3 items
* index 0 = Year
* index 1 = Month
* index 2 = Day
*
* Format is YYYY - MM - DD
*/
*/

//comparing years
// comparing years
return if (date1[0] == date2[0]) {

//now that years are equal lets compare months
// now that years are equal lets compare months
if (date1[1] == date2[1]) {

//now that months are also equal lets compare days
// now that months are also equal lets compare days
if (date1[2] == date2[2]) {
0
} else if (date1[2] > date2[2]) {
Expand Down Expand Up @@ -280,4 +282,4 @@ object DateHelper {
else -> -1
}
}
}
}
Loading

0 comments on commit a6299d9

Please sign in to comment.