TP-53637 | Spotless | Pulse, Base, Design, Analytics (#9266)

This commit is contained in:
Shivam Goyal
2024-01-09 00:22:02 +05:30
committed by GitHub
parent 4f3ac0a004
commit c8ee42a7b9
92 changed files with 766 additions and 765 deletions

View File

@@ -3,6 +3,7 @@ name: Android Checkstyle CI
on:
pull_request:
branches: [ development ]
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022-2023 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -24,4 +24,3 @@ const val CONFIG_VERSION_CAMEL_CASE = "configVersion"
const val CUSTOMER_ID = "customer_id"
const val CHAT_DEEPLINK_APPEARS = "chat_deeplink_appears"
const val METHOD_NAME = "method_name"

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2023 by Navi Technologies Limited
* * Copyright © 2023-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -20,18 +20,23 @@ abstract class NaviSharedDatabase : RoomDatabase() {
abstract fun naviCacheDao(): NaviCacheDao
/**
* This function will be used only in HL and PL dynamic modules.
* From other modules please use Hilt only
* This function will be used only in HL and PL dynamic modules. From other modules please use
* Hilt only
*/
companion object {
@Volatile
private var naviSharedDatabase: NaviSharedDatabase? = null
@Volatile private var naviSharedDatabase: NaviSharedDatabase? = null
fun getInstance(context: Context): NaviSharedDatabase {
synchronized(this) {
if (naviSharedDatabase == null) {
naviSharedDatabase = Room.databaseBuilder(context, NaviSharedDatabase::class.java, NaviSharedDBConstant.DB_NAME)
.build()
naviSharedDatabase =
Room.databaseBuilder(
context,
NaviSharedDatabase::class.java,
NaviSharedDBConstant.DB_NAME
)
.build()
}
return naviSharedDatabase as NaviSharedDatabase
}

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2023 by Navi Technologies Limited
* * Copyright © 2023-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -47,7 +47,9 @@ abstract class NaviBaseBindingModule {
@Singleton
@Binds
abstract fun bindsNaviCacheRepository(naviCacheRepositoryImpl: NaviCacheRepositoryImpl): NaviCacheRepository
abstract fun bindsNaviCacheRepository(
naviCacheRepositoryImpl: NaviCacheRepositoryImpl
): NaviCacheRepository
@Singleton
@Binds
@@ -55,5 +57,7 @@ abstract class NaviBaseBindingModule {
@Singleton
@Binds
abstract fun bindsFirestoreDataProvider(firestoreDataProviderImpl: FirestoreDataProviderImpl): FirestoreDataProvider
abstract fun bindsFirestoreDataProvider(
firestoreDataProviderImpl: FirestoreDataProviderImpl
): FirestoreDataProvider
}

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2023 by Navi Technologies Limited
* * Copyright © 2023-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -10,9 +10,9 @@ package com.navi.base.cache.repository
import com.navi.base.cache.dao.NaviCacheDao
import com.navi.base.cache.model.NaviCacheAltSourceEntity
import com.navi.base.cache.model.NaviCacheEntity
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject
interface NaviCacheRepository {
@@ -34,12 +34,14 @@ interface NaviCacheRepository {
key: String,
version: Long? = null,
getDataFromAltSource: suspend () -> NaviCacheAltSourceEntity,
isCurrentAndAltDataSame: (currentData: NaviCacheEntity?, altData: NaviCacheAltSourceEntity) -> Boolean
= fun(currentData, altData): Boolean {
isCurrentAndAltDataSame:
(currentData: NaviCacheEntity?, altData: NaviCacheAltSourceEntity) -> Boolean =
fun(currentData, altData): Boolean {
val currentDataValue = currentData?.value ?: return false
val altDataValue = altData.value ?: return false
return currentData.version == altData.version && currentDataValue.hashCode() == altDataValue.hashCode()
return currentData.version == altData.version &&
currentDataValue.hashCode() == altDataValue.hashCode()
},
emitMultipleValues: Boolean = false
): Flow<NaviCacheEntity?>
@@ -72,7 +74,8 @@ class NaviCacheRepositoryImpl @Inject constructor(private val naviCacheDao: Navi
val currentValueInDB = get(key = key)
if (checkIfDBValueIsValidElseRemoveEntry(
if (
checkIfDBValueIsValidElseRemoveEntry(
naviCacheEntity = currentValueInDB,
version = version,
key = key
@@ -84,21 +87,23 @@ class NaviCacheRepositoryImpl @Inject constructor(private val naviCacheDao: Navi
// DB value is invalid
val naviCacheValueEntityFromAltSource = getDataFromAltSource.invoke()
if (!naviCacheValueEntityFromAltSource.isSuccess ||
naviCacheValueEntityFromAltSource.value == null
if (
!naviCacheValueEntityFromAltSource.isSuccess ||
naviCacheValueEntityFromAltSource.value == null
) { // alternate source data invalid
return null
}
// Got data from alt source
val naviCacheEntity = NaviCacheEntity(
key = key,
value = naviCacheValueEntityFromAltSource.value,
version = naviCacheValueEntityFromAltSource.version ?: 1,
ttl = naviCacheValueEntityFromAltSource.ttl,
clearOnLogout = naviCacheValueEntityFromAltSource.clearOnLogout,
metaData = naviCacheValueEntityFromAltSource.metaData
)
val naviCacheEntity =
NaviCacheEntity(
key = key,
value = naviCacheValueEntityFromAltSource.value,
version = naviCacheValueEntityFromAltSource.version ?: 1,
ttl = naviCacheValueEntityFromAltSource.ttl,
clearOnLogout = naviCacheValueEntityFromAltSource.clearOnLogout,
metaData = naviCacheValueEntityFromAltSource.metaData
)
save(naviCacheEntity = naviCacheEntity)
@@ -109,15 +114,16 @@ class NaviCacheRepositoryImpl @Inject constructor(private val naviCacheDao: Navi
key: String,
version: Long?,
getDataFromAltSource: suspend () -> NaviCacheAltSourceEntity,
isCurrentAndAltDataSame: (currentData: NaviCacheEntity?, altData: NaviCacheAltSourceEntity) -> Boolean,
isCurrentAndAltDataSame:
(currentData: NaviCacheEntity?, altData: NaviCacheAltSourceEntity) -> Boolean,
emitMultipleValues: Boolean
) = flow {
var isValueEmitted = false
val currentValueInDB = get(key = key)
if (checkIfDBValueIsValidElseRemoveEntry(
if (
checkIfDBValueIsValidElseRemoveEntry(
naviCacheEntity = currentValueInDB,
version = version,
key = key
@@ -129,20 +135,22 @@ class NaviCacheRepositoryImpl @Inject constructor(private val naviCacheDao: Navi
val naviCacheValueEntityFromAltSource = getDataFromAltSource.invoke()
if (!naviCacheValueEntityFromAltSource.isSuccess ||
naviCacheValueEntityFromAltSource.value == null
if (
!naviCacheValueEntityFromAltSource.isSuccess ||
naviCacheValueEntityFromAltSource.value == null
) { // alternate source data invalid
return@flow
}
val naviCacheEntity = NaviCacheEntity(
key = key,
value = naviCacheValueEntityFromAltSource.value,
version = naviCacheValueEntityFromAltSource.version ?: 1,
ttl = naviCacheValueEntityFromAltSource.ttl,
clearOnLogout = naviCacheValueEntityFromAltSource.clearOnLogout,
metaData = naviCacheValueEntityFromAltSource.metaData
)
val naviCacheEntity =
NaviCacheEntity(
key = key,
value = naviCacheValueEntityFromAltSource.value,
version = naviCacheValueEntityFromAltSource.version ?: 1,
ttl = naviCacheValueEntityFromAltSource.ttl,
clearOnLogout = naviCacheValueEntityFromAltSource.clearOnLogout,
metaData = naviCacheValueEntityFromAltSource.metaData
)
if (isCurrentAndAltDataSame(currentValueInDB, naviCacheValueEntityFromAltSource)) {
return@flow
@@ -163,15 +171,16 @@ class NaviCacheRepositoryImpl @Inject constructor(private val naviCacheDao: Navi
key: String
): Boolean {
if (naviCacheEntity == null) // value not present
return false
return false
if (version != null && naviCacheEntity.version < version) { // outdated version
clear(key = key)
return false
}
if (naviCacheEntity.ttl != -1L &&
((System.currentTimeMillis() - naviCacheEntity.updatedAt) >
if (
naviCacheEntity.ttl != -1L &&
((System.currentTimeMillis() - naviCacheEntity.updatedAt) >
naviCacheEntity.ttl) // ttl expired
) {
clear(key = key)

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022-2023 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -37,22 +37,17 @@ data class PaddingData(
@SerializedName("topDp") var topDp: Float = 0.0f,
@SerializedName("bottomDp") var bottomDp: Float = 0.0f
) : Parcelable, NaviClickAction()
@Parcelize
data class ActionButtonStyle(
@SerializedName("bgColor")
val bgColor: String? = null,
@SerializedName("radius")
val radius: Radius? = null
@SerializedName("bgColor") val bgColor: String? = null,
@SerializedName("radius") val radius: Radius? = null
) : Parcelable
@Parcelize
data class Radius(
@SerializedName("leftTop")
val leftTop: Int? = null,
@SerializedName("leftBottom")
val leftBottom: Int? = null,
@SerializedName("rightTop")
val rightTop: Int? = null,
@SerializedName("rightBottom")
val rightBottom: Int? = null
@SerializedName("leftTop") val leftTop: Int? = null,
@SerializedName("leftBottom") val leftBottom: Int? = null,
@SerializedName("rightTop") val rightTop: Int? = null,
@SerializedName("rightBottom") val rightBottom: Int? = null
) : Parcelable

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2020-2023 by Navi Technologies Limited
* * Copyright © 2020-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2020-2023 by Navi Technologies Limited
* * Copyright © 2020-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -16,7 +16,7 @@ import kotlinx.parcelize.Parcelize
open class LineItem(
@SerializedName("key") val key: String? = null,
@SerializedName("value") var value: String? = null,
@SerializedName("expressionValue") val expressionValue : String? = null,
@SerializedName("expressionValue") val expressionValue: String? = null,
@SerializedName("subtitle") val subtitle: String? = null,
@SerializedName("subValue") val subValue: String? = null,
@SerializedName("iconCode") val iconCode: String? = null,

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2021-2023 by Navi Technologies Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -10,8 +10,8 @@ package com.navi.base.model
import android.os.Bundle
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize
import java.io.Serializable
import kotlinx.parcelize.Parcelize
open class NaviClickAction

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2023 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2019-2023 by Navi Technologies Limited
* * Copyright © 2019-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -235,6 +235,7 @@ object PreferenceManager {
editor.putString(key, defValue)
editor.apply()
}
fun getStringPreferenceApp(key: String, defValue: String? = null): String? {
return sharedPreferencesForApp.getString(key, defValue)
}
@@ -350,7 +351,6 @@ object PreferenceManager {
val editor = it.edit()
keys.forEach { key -> editor.remove(key) }
editor.apply()
}
?: run { clearKeyBasedSessionPreferenceData(keys = keys) }
} ?: run { clearKeyBasedSessionPreferenceData(keys = keys) }
}
}

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022-2023 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -31,7 +31,7 @@ const val THOUSAND = 1000L
const val INT_ZERO = 0
const val PAN_VERIFY_POLLING = "PAN_VERIFY_POLLING"
const val SKIP_LOADER = "skipLoader"
const val PAN_VERIFY_POLLING_FAIL="PAN_VERIFY_POLLING_FAIL"
const val PAN_VERIFY_POLLING_FAIL = "PAN_VERIFY_POLLING_FAIL"
const val APPLICATION_JSON = "application/json"
const val EXCLUDE_FROM_HASH_ENCRYPTION = "excludeFromHashEncryption"
const val QA_RELEASE_LOGS_FILE_NAME = "NAVI_QA_RELEASE_LOGS.txt"

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2021-2023 by Navi Technologies Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -13,10 +13,10 @@ import com.google.gson.Gson
import com.navi.base.model.AnalyticsEvent
import com.navi.base.model.CtaData
import com.navi.base.utils.AppLaunchUtils.TRUE
import okhttp3.Headers
import org.json.JSONObject
import kotlin.math.ceil
import kotlin.math.floor
import okhttp3.Headers
import org.json.JSONObject
fun String?.isNotNullAndNotEmpty(): Boolean = !this.isNullOrEmpty()

View File

@@ -10,16 +10,16 @@ package com.navi.base.utils
import com.google.firebase.firestore.DocumentSnapshot
import com.google.firebase.firestore.ktx.firestore
import com.google.firebase.ktx.Firebase
import javax.inject.Inject
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow
import javax.inject.Inject
/**
* For any/all usages of Firestore, use this interface.
* Add methods as needed in interface & attach a corresponding implementation in [FirestoreDataProviderImpl]
* attachSnapShotListenerAndGetDocumentsForCollection -> Attach listener & keep getting callbacks for any changes to a particular path of collection. Returns list of [DocumentSnapshot]
* For any/all usages of Firestore, use this interface. Add methods as needed in interface & attach
* a corresponding implementation in [FirestoreDataProviderImpl]
* attachSnapShotListenerAndGetDocumentsForCollection -> Attach listener & keep getting callbacks
* for any changes to a particular path of collection. Returns list of [DocumentSnapshot]
*/
interface FirestoreDataProvider {
@@ -28,8 +28,7 @@ interface FirestoreDataProvider {
): Flow<List<DocumentSnapshot>>
}
class FirestoreDataProviderImpl @Inject constructor() :
FirestoreDataProvider {
class FirestoreDataProviderImpl @Inject constructor() : FirestoreDataProvider {
val db = Firebase.firestore
@@ -37,22 +36,17 @@ class FirestoreDataProviderImpl @Inject constructor() :
collectionPath: String
): Flow<List<DocumentSnapshot>> {
return callbackFlow {
val listener = db.collection(collectionPath)
.addSnapshotListener { querySnapshot, error ->
val listener =
db.collection(collectionPath).addSnapshotListener { querySnapshot, error ->
if (error != null) {
close(cause = error)
return@addSnapshotListener
}
querySnapshot?.let {
trySend(it.documents)
}
querySnapshot?.let { trySend(it.documents) }
}
awaitClose {
listener.remove()
}
awaitClose { listener.remove() }
}
}
}

View File

@@ -1,3 +1,10 @@
/*
*
* * Copyright © 2023-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
package com.navi.base.utils
import android.content.Context
@@ -5,9 +12,6 @@ import com.google.gson.Gson
import com.google.gson.JsonObject
import com.google.gson.JsonParser
import com.navi.base.BuildConfig
import kotlinx.coroutines.asCoroutineDispatcher
import okhttp3.Request
import okhttp3.Response
import java.io.File
import java.io.FileOutputStream
import java.io.OutputStreamWriter
@@ -16,6 +20,9 @@ import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
import java.util.concurrent.Executors
import kotlinx.coroutines.asCoroutineDispatcher
import okhttp3.Request
import okhttp3.Response
object QaReleaseLogUtil {
@@ -43,7 +50,8 @@ object QaReleaseLogUtil {
coroutineDispatcher.executor.execute {
val logData = hashMapOf<String, Any>()
val timestamp =
SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()).format(Date())
SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
.format(Date())
.toString()
var endPoint = ""
when (logType) {
@@ -51,80 +59,87 @@ object QaReleaseLogUtil {
val networkData: HashMap<String, Any> = hashMapOf()
endPoint = URL(request?.url.toString()).path
val responseJsonString = try {
Gson().toJson(responseData)
} catch (e: Exception) {
""
}
val responseObject = try {
JsonParser.parseString(responseJsonString).asJsonObject
} catch (e: Exception) {
JsonObject()
}
val responseJsonString =
try {
Gson().toJson(responseData)
} catch (e: Exception) {
""
}
val responseObject =
try {
JsonParser.parseString(responseJsonString).asJsonObject
} catch (e: Exception) {
JsonObject()
}
networkData["RESPONSE_BODY"] = responseObject
networkData["RESPONSE_CODE"] = statusCode.toString()
val requestJsonString = try {
Gson().toJson(responseData)
} catch (e: Exception) {
""
}
val requestObject = try {
JsonParser.parseString(requestJsonString).asJsonObject
} catch (e: Exception) {
JsonObject()
}
val requestJsonString =
try {
Gson().toJson(responseData)
} catch (e: Exception) {
""
}
val requestObject =
try {
JsonParser.parseString(requestJsonString).asJsonObject
} catch (e: Exception) {
JsonObject()
}
networkData["REQUEST_BODY"] = requestObject
networkData["URL"] = request?.url.toString()
val requestHeaderMap: HashMap<String, Any> = hashMapOf()
request?.headers?.forEach {
requestHeaderMap[it.first] = it.second
}
request?.headers?.forEach { requestHeaderMap[it.first] = it.second }
val requestHeaderJsonString = try {
Gson().toJson(requestHeaderMap)
} catch (e: Exception) {
EMPTY
}
val requestHeaderObject = try {
JsonParser.parseString(requestHeaderJsonString).asJsonObject
} catch (e: Exception) {
JsonObject()
}
val requestHeaderJsonString =
try {
Gson().toJson(requestHeaderMap)
} catch (e: Exception) {
EMPTY
}
val requestHeaderObject =
try {
JsonParser.parseString(requestHeaderJsonString).asJsonObject
} catch (e: Exception) {
JsonObject()
}
networkData["REQUEST_HEADER"] = requestHeaderObject
val responseHeaderMap: HashMap<String, Any> = hashMapOf()
response?.headers?.forEach {
responseHeaderMap[it.first] = it.second
}
response?.headers?.forEach { responseHeaderMap[it.first] = it.second }
val responseHeaderJsonString = try {
Gson().toJson(responseHeaderMap)
} catch (e: Exception) {
EMPTY
}
val responseHeaderObject = try {
JsonParser.parseString(responseHeaderJsonString).asJsonObject
} catch (e: Exception) {
JsonObject()
}
val responseHeaderJsonString =
try {
Gson().toJson(responseHeaderMap)
} catch (e: Exception) {
EMPTY
}
val responseHeaderObject =
try {
JsonParser.parseString(responseHeaderJsonString).asJsonObject
} catch (e: Exception) {
JsonObject()
}
networkData["RESPONSE_HEADER"] = responseHeaderObject
networkData["REQUEST_METHOD"] = requestMethod.toString()
logData[timestamp] = networkData
}
ReleaseLogType.ANR_LOG.name, ReleaseLogType.CRASH_LOG.name -> {
ReleaseLogType.ANR_LOG.name,
ReleaseLogType.CRASH_LOG.name -> {
logData[timestamp] = data as HashMap<String, String>
}
else -> {}
}
val logMessage = Gson().toJson(logData)
writeLogToFile(
logMessage = logMessage, logType, timestamp, endPoint, statusCode, requestMethod
logMessage = logMessage,
logType,
timestamp,
endPoint,
statusCode,
requestMethod
)
}
}
@@ -171,5 +186,4 @@ object QaReleaseLogUtil {
CRASH_LOG,
ANR_LOG
}
}

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2023 by Navi Technologies Limited
* * Copyright © 2023-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/

View File

@@ -1,3 +1,10 @@
/*
*
* * Copyright © 2023-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
package com.navi.base.utils
import android.content.Context
@@ -6,14 +13,18 @@ import android.os.Bundle
import com.google.firebase.analytics.FirebaseAnalytics
import java.io.File
object SoUtils {
private const val ARM_64 = "arm64"
private const val ARM_64_V8A = "arm64-v8a"
private const val ARM_V7A = "armeabi-v7a"
private const val ARMEABI = "armeabi"
fun getLibFileFromPath(context: Context, library: String, path: String? = null, firebaseAnalytics: FirebaseAnalytics? = null): File? {
fun getLibFileFromPath(
context: Context,
library: String,
path: String? = null,
firebaseAnalytics: FirebaseAnalytics? = null
): File? {
val libName = System.mapLibraryName(library)
var file: File? = null
val bundle = Bundle()
@@ -21,9 +32,7 @@ object SoUtils {
bundle.putString("libName", libName)
bundle.putString("path_to_load", path)
firebaseAnalytics?.logEvent("NaviLibSOFileOpeningFromPath", bundle)
file = File(
path ?: context.applicationInfo.nativeLibraryDir, libName
)
file = File(path ?: context.applicationInfo.nativeLibraryDir, libName)
} catch (e: Exception) {
bundle.putString(
"FILE_NOT_FOUND_PATH",

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2020-2022 by Navi Technologies Limited
* * Copyright © 2020-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -8,9 +8,6 @@
package com.navi.common.utils;
import androidx.annotation.Nullable;
import com.navi.analytics.utils.NaviTrackEvent;
import java.math.BigDecimal;
import java.math.RoundingMode;
import org.joda.money.BigMoney;
@@ -40,10 +37,14 @@ public class EmiCalculator {
amount =
principalLoanAmount
.getAmount()
.divide(BigDecimal.valueOf(loanTenureInMonths), 0, RoundingMode.FLOOR);
.divide(
BigDecimal.valueOf(loanTenureInMonths),
0,
RoundingMode.FLOOR);
} else {
BigDecimal monthlyInterestRate = monthlyInterestRate();
BigDecimal numerator = BigDecimal.ONE.add(monthlyInterestRate).pow(loanTenureInMonths);
BigDecimal numerator =
BigDecimal.ONE.add(monthlyInterestRate).pow(loanTenureInMonths);
BigDecimal denominator = numerator.subtract(BigDecimal.ONE);
amount =
principalLoanAmount

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -112,9 +112,14 @@ constructor(
}
?: kotlin.run {
setTextColor(ResourcesCompat.getColor(resources, R.color.white, null))
typeface = ResourcesCompat.getFont(context, getFontStyle(FontWeightEnum.TT_MEDIUM))
typeface =
ResourcesCompat.getFont(context, getFontStyle(FontWeightEnum.TT_MEDIUM))
background =
ResourcesCompat.getDrawable(resources, R.drawable.circular_purple_16dp, null)
ResourcesCompat.getDrawable(
resources,
R.drawable.circular_purple_16dp,
null
)
}
}
}

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022-2023 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -24,7 +24,6 @@ import com.navi.design.calendar.model.ViewPaddingParams
import com.navi.design.databinding.NaviCalendarListViewBinding
import com.navi.design.utils.Constants.DATE_FORMAT_YYYY_MM_DD
import com.navi.design.utils.getTotalNumberOfDayInMonth
import com.navi.design.utils.parseDateFromOneToAnother
import com.navi.design.utils.parseDateToString
import java.util.*
import kotlinx.coroutines.*
@@ -195,26 +194,32 @@ constructor(context: Context, attrs: AttributeSet? = null) : ConstraintLayout(co
date = currentDate
isViewSelected = currentDate.equals(defaultDate)
isViewHighlighted = currentDate.equals(highlightedDate)
isDateAvailable = selectableDates?.let {
it.firstOrNull { it == currentDateString }?.let { true } ?: false
} ?: run {
if (noSelectDates?.contains(it).orFalse()) false
else
(currentDate.after(startDate) || currentDate.equals(startDate)) &&
(currentDate.before(endDate) || currentDate.equals(endDate))
}
selectableDates ?: run {
if (
isDateAvailable &&
skipDateConfig?.startDate != null &&
skipDateConfig.endDate != null && selectableDates.isNullOrEmpty()
) {
isDateAvailable = !((currentDate.after(skipDateConfig.startDate) ||
currentDate.equals(skipDateConfig.startDate)) &&
(currentDate.before(skipDateConfig.endDate) ||
currentDate.equals(skipDateConfig.endDate)))
isDateAvailable =
selectableDates?.let {
it.firstOrNull { it == currentDateString }?.let { true } ?: false
}
?: run {
if (noSelectDates?.contains(it).orFalse()) false
else
(currentDate.after(startDate) ||
currentDate.equals(startDate)) &&
(currentDate.before(endDate) || currentDate.equals(endDate))
}
selectableDates
?: run {
if (
isDateAvailable &&
skipDateConfig?.startDate != null &&
skipDateConfig.endDate != null &&
selectableDates.isNullOrEmpty()
) {
isDateAvailable =
!((currentDate.after(skipDateConfig.startDate) ||
currentDate.equals(skipDateConfig.startDate)) &&
(currentDate.before(skipDateConfig.endDate) ||
currentDate.equals(skipDateConfig.endDate)))
}
}
}
}
listData.add(dateData)
currentDate = incrementDayByOne(currentDate)

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -9,7 +9,10 @@ package com.navi.design.calendar.view
interface NaviCalendarToolTip {
fun showCurrentDateToolTip(drawPosition: Int): Unit
fun showSelectedDateToolTip(drawPosition: Int): Unit
fun removeCurrentDateToolTip(drawPosition: Int): Unit
fun removeToolTipsOfCurrentRv(): Unit
}

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -9,8 +9,8 @@ package com.navi.design.common
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize
import java.io.Serializable
import kotlinx.parcelize.Parcelize
open class CommonViewProperty(
var layoutId: String? = null,

View File

@@ -1,3 +1,10 @@
/*
*
* * Copyright © 2023-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
package com.navi.design.common
import androidx.compose.animation.animateContentSize
@@ -28,9 +35,9 @@ fun ExpandableText(
modifier: Modifier,
textModifier: Modifier,
text: String,
isExpanded : Boolean,
onTextClicked : () -> Unit,
lineHeight : TextUnit = 22.sp,
isExpanded: Boolean,
onTextClicked: () -> Unit,
lineHeight: TextUnit = 22.sp,
textFontSize: TextUnit = 12.sp,
textColor: Color = FF444444,
textFontWeight: FontWeight = getFontWeight(FontWeightEnum.NAVI_BODY_REGULAR),
@@ -42,12 +49,7 @@ fun ExpandableText(
) {
var clickable by remember { mutableStateOf(false) }
var lastCharIndex by remember { mutableStateOf(0) }
Box(modifier = Modifier
.clickable(clickable) {
onTextClicked()
}
.then(modifier)
) {
Box(modifier = Modifier.clickable(clickable) { onTextClicked() }.then(modifier)) {
Text(
modifier = textModifier.animateContentSize(),
fontSize = textFontSize,
@@ -55,22 +57,25 @@ fun ExpandableText(
fontFamily = ttComposeFontFamily,
color = textColor,
fontWeight = textFontWeight,
text = buildAnnotatedString {
if (clickable) {
if (isExpanded) {
append(text)
withStyle(style = showLessStyle) { append(showLessText) }
text =
buildAnnotatedString {
if (clickable) {
if (isExpanded) {
append(text)
withStyle(style = showLessStyle) { append(showLessText) }
} else {
val adjustText =
text
.substring(startIndex = 0, endIndex = lastCharIndex)
.dropLast(showMoreText.length)
.dropLastWhile { Character.isWhitespace(it) || it == '.' }
append(adjustText)
withStyle(style = showMoreStyle) { append(showMoreText) }
}
} else {
val adjustText = text.substring(startIndex = 0, endIndex = lastCharIndex)
.dropLast(showMoreText.length)
.dropLastWhile { Character.isWhitespace(it) || it == '.' }
append(adjustText)
withStyle(style = showMoreStyle) { append(showMoreText) }
append(text)
}
} else {
append(text)
}
},
},
maxLines = if (isExpanded) Int.MAX_VALUE else collapsedMaxLine,
onTextLayout = { textLayoutResult ->
if (!isExpanded && textLayoutResult.hasVisualOverflow) {

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -89,7 +89,8 @@ fun TextView.setStyleDetails(textStyle: TextStyle) {
// Retrieve values from typography and set on text view
apply {
textSize = typography.fontSize.value
typeface = ResourcesCompat.getFont(context, typography.fontWeight.getFont(typography.fontFamily))
typeface =
ResourcesCompat.getFont(context, typography.fontWeight.getFont(typography.fontFamily))
letterSpacing = context.spToPx(typography.letterSpacing.value)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022 by Navi Technologies Limited
* * Copyright © 2023-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/

View File

@@ -1,13 +1,12 @@
/*
*
* * Copyright © 2023 by Navi Technologies Limited
* * Copyright © 2023-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
package com.navi.design.customview
import android.animation.ValueAnimator
import android.content.Context
import android.content.res.ColorStateList
@@ -24,19 +23,17 @@ import com.google.android.material.chip.Chip
import com.navi.design.R
import kotlin.math.abs
open class LoadingButtonView @JvmOverloads constructor(
context: Context,
attributeSet: AttributeSet? = null,
defStyleAttr: Int = 0
) : Chip(context, attributeSet, defStyleAttr) {
open class LoadingButtonView
@JvmOverloads
constructor(context: Context, attributeSet: AttributeSet? = null, defStyleAttr: Int = 0) :
Chip(context, attributeSet, defStyleAttr) {
private lateinit var borderPath: Path
private lateinit var pathMeasure: PathMeasure
private lateinit var loaderAnimator: ValueAnimator
private var badScroll = 0f
var lapDuration = 2000L
var loaderWidth = 5f
var loaderColor = ContextCompat.getColor(context,R.color.noticeOrangeColor)
var loaderColor = ContextCompat.getColor(context, R.color.noticeOrangeColor)
var loadingTextColor: Int? = null
private var originalText = ""
private var originalTextColor: ColorStateList? = null
@@ -54,11 +51,12 @@ open class LoadingButtonView @JvmOverloads constructor(
private var reversed = false
private var wrappedClickListener: OnClickListener? = null
var shouldStartLoadingOnClick = true
private val loaderPaint = Paint().apply {
isAntiAlias = true
style = Paint.Style.STROKE
textAlign = Paint.Align.CENTER
}
private val loaderPaint =
Paint().apply {
isAntiAlias = true
style = Paint.Style.STROKE
textAlign = Paint.Align.CENTER
}
inner class ReverseDecelerateInterpolator : DecelerateInterpolator() {
override fun getInterpolation(input: Float): Float {
@@ -104,15 +102,15 @@ open class LoadingButtonView @JvmOverloads constructor(
}
}
init {
if (attributeSet != null) {
val ta = context.obtainStyledAttributes(
attributeSet,
R.styleable.LoaderButton,
defStyleAttr,
0
)
val ta =
context.obtainStyledAttributes(
attributeSet,
R.styleable.LoaderButton,
defStyleAttr,
0
)
reverseEffectEnabled = ta.getBoolean(R.styleable.LoaderButton_reverseEffect, false)
when (ta.getInt(R.styleable.LoaderButton_loaderStyle, 7)) {
@@ -153,7 +151,10 @@ open class LoadingButtonView @JvmOverloads constructor(
shouldStartLoadingOnClick = ta.getBoolean(R.styleable.LoaderButton_loadOnClick, true)
loadingText = ta.getString(R.styleable.LoaderButton_loadingText)
loadingTextColor = ta.getColor(R.styleable.LoaderButton_loadingTextColor, Color.GRAY)
if (ta.hasValue(R.styleable.LoaderButton_loaderColorStart) && ta.hasValue(R.styleable.LoaderButton_loaderColorEnd)) {
if (
ta.hasValue(R.styleable.LoaderButton_loaderColorStart) &&
ta.hasValue(R.styleable.LoaderButton_loaderColorEnd)
) {
loaderStartColor =
ta.getColor(R.styleable.LoaderButton_loaderColorStart, Color.WHITE)
loaderEndColor = ta.getColor(R.styleable.LoaderButton_loaderColorEnd, Color.WHITE)
@@ -201,7 +202,6 @@ open class LoadingButtonView @JvmOverloads constructor(
loaderAnimator.end()
}
fun startLoading() {
if (!shouldLoad) {
shouldLoad = true
@@ -224,39 +224,39 @@ open class LoadingButtonView @JvmOverloads constructor(
}
private fun setupPaths() {
borderPath = Path().apply {
val halfStrokeWidth = loaderPaint.strokeWidth / 2f
addRoundRect(
chipDrawable.bounds.left.toFloat() + halfStrokeWidth,
chipDrawable.bounds.top.toFloat() + halfStrokeWidth,
chipDrawable.bounds.right.toFloat() - halfStrokeWidth,
chipDrawable.bounds.bottom.toFloat() - halfStrokeWidth,
chipCornerRadius,
chipCornerRadius,
Path.Direction.CW
)
}
borderPath =
Path().apply {
val halfStrokeWidth = loaderPaint.strokeWidth / 2f
addRoundRect(
chipDrawable.bounds.left.toFloat() + halfStrokeWidth,
chipDrawable.bounds.top.toFloat() + halfStrokeWidth,
chipDrawable.bounds.right.toFloat() - halfStrokeWidth,
chipDrawable.bounds.bottom.toFloat() - halfStrokeWidth,
chipCornerRadius,
chipCornerRadius,
Path.Direction.CW
)
}
pathMeasure = PathMeasure(borderPath, true)
}
private fun setupAnimator() {
loaderAnimator = ValueAnimator.ofFloat(0f, 1f).apply {
duration = lapDuration
this.interpolator = this@LoadingButtonView.interpolator
addUpdateListener {
val animatedValue = it.animatedValue as Float
loaderEnd = animatedValue * pathMeasure.length
loaderStart = loaderEnd - ((0.5f - abs(animatedValue - 0.5f)) * pathMeasure.length)
invalidate()
loaderAnimator =
ValueAnimator.ofFloat(0f, 1f).apply {
duration = lapDuration
this.interpolator = this@LoadingButtonView.interpolator
addUpdateListener {
val animatedValue = it.animatedValue as Float
loaderEnd = animatedValue * pathMeasure.length
loaderStart =
loaderEnd - ((0.5f - abs(animatedValue - 0.5f)) * pathMeasure.length)
invalidate()
}
}
}
loaderAnimator.doOnStart {
reversed = !reversed
}
loaderAnimator.doOnStart { reversed = !reversed }
loaderAnimator.doOnEnd {
if (reverseEffectEnabled) {
loaderAnimator.interpolator =
if (reversed) interpolator else reverseInterpolator
loaderAnimator.interpolator = if (reversed) interpolator else reverseInterpolator
}
loaderAnimator.start()
}
@@ -265,15 +265,16 @@ open class LoadingButtonView @JvmOverloads constructor(
private fun handleGradient() {
if (drawingGradient) {
loaderPaint.shader = LinearGradient(
0f,
0f,
pathMeasure.length / 3f,
loaderWidth,
loaderStartColor,
loaderEndColor,
Shader.TileMode.CLAMP
)
loaderPaint.shader =
LinearGradient(
0f,
0f,
pathMeasure.length / 3f,
loaderWidth,
loaderStartColor,
loaderEndColor,
Shader.TileMode.CLAMP
)
} else {
loaderPaint.color = loaderColor
}

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -102,7 +102,7 @@ class ParallelogramView(context: Context?, attrs: AttributeSet?) : View(context,
override fun onAttachedToWindow() {
super.onAttachedToWindow()
if(isReset) {
if (isReset) {
initView()
requestLayout()
}

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022-2023 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -40,7 +40,7 @@ class TooltipView @JvmOverloads constructor(context: Context, attrs: AttributeSe
binding.tooltipTv.text = tooltipTitle
}
fun setTooltipColor(colorId : Int){
fun setTooltipColor(colorId: Int) {
binding.triangleView.setColorWithColorId(colorId)
binding.tooltipTv.setBgColor(colorId)
}
@@ -52,6 +52,7 @@ class TooltipView @JvmOverloads constructor(context: Context, attrs: AttributeSe
fun getTriangleView(): TriangleView {
return binding.triangleView
}
fun setProperties(style: Int? = null, textAllignment: Int? = null, padding: Padding? = null) {
textAllignment?.let {
try {

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022-2023 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -36,7 +36,8 @@ class TriangleView @JvmOverloads constructor(context: Context?, attrs: Attribute
paint.color = ResourcesCompat.getColor(resources, colorId, null)
invalidate()
}
fun setColorWithColorId(colorId : Int){
fun setColorWithColorId(colorId: Int) {
paint.color = colorId
invalidate()
}

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -48,6 +48,7 @@ class WaveDividerView @JvmOverloads constructor(context: Context?, attrs: Attrib
endY = 0F
SPACING = (viewWidth - NUMBER_OF_BARS) / (NUMBER_OF_BARS - 1)
}
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
viewWidth = MeasureSpec.getSize(widthMeasureSpec).toFloat()
viewHeight = MeasureSpec.getSize(heightMeasureSpec).toFloat()

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2023 by Navi Technologies Limited
* * Copyright © 2023-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -15,8 +15,7 @@ class GridSpacingItemDecoration(
private val spanCount: Int,
private val spacing: Int,
private val includeEdge: Boolean
) :
RecyclerView.ItemDecoration() {
) : RecyclerView.ItemDecoration() {
override fun getItemOffsets(
outRect: Rect,
@@ -28,7 +27,8 @@ class GridSpacingItemDecoration(
val column = position % spanCount // item column
if (includeEdge) {
outRect.left =
spacing - column * spacing / spanCount // spacing - column * ((1f / spanCount) * spacing)
spacing -
column * spacing / spanCount // spacing - column * ((1f / spanCount) * spacing)
outRect.right =
(column + 1) * spacing / spanCount // (column + 1) * ((1f / spanCount) * spacing)
if (position < spanCount) { // top edge
@@ -38,11 +38,12 @@ class GridSpacingItemDecoration(
} else {
outRect.left = column * spacing / spanCount // column * ((1f / spanCount) * spacing)
outRect.right =
spacing - (column + 1) * spacing / spanCount // spacing - (column + 1) * ((1f / spanCount) * spacing)
spacing -
(column + 1) * spacing /
spanCount // spacing - (column + 1) * ((1f / spanCount) * spacing)
if (position >= spanCount) {
outRect.top = spacing // item top
}
}
}
}

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2020-2023 by Navi Technologies Limited
* * Copyright © 2020-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -81,7 +81,6 @@ class NaviEditText(context: Context, attrs: AttributeSet) : AppCompatEditText(co
typeface = ResourcesCompat.getFont(context, getFontStyle(fontName))
}
fun setTextStyle(textStyle: Int) {
setTypeface(typeface, textStyle)
}

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022-2023 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -20,89 +20,45 @@ enum class FontWeightEnum {
/** Navi Headline - Bold (700) */
TT_BOLD,
/** For Navi Pay usage only **/
/** For Navi Pay usage only * */
NAVI_HEADLINE_REGULAR,
NAVI_HEADLINE_BOLD,
NAVI_BODY_REGULAR,
NAVI_BODY_DEMI_BOLD,
@Deprecated(
"Use 'TT_REGULAR' instead.",
ReplaceWith("TT_REGULAR"),
DeprecationLevel.WARNING
)
@Deprecated("Use 'TT_REGULAR' instead.", ReplaceWith("TT_REGULAR"), DeprecationLevel.WARNING)
ROBOTO_REGULAR,
@Deprecated(
"Use 'TT_MEDIUM' instead.",
ReplaceWith("TT_MEDIUM"),
DeprecationLevel.WARNING
)
@Deprecated("Use 'TT_MEDIUM' instead.", ReplaceWith("TT_MEDIUM"), DeprecationLevel.WARNING)
ROBOTO_MEDIUM,
@Deprecated(
"Use 'TT_SEMI_BOLD' instead.",
ReplaceWith("TT_SEMI_BOLD"),
DeprecationLevel.WARNING
)
ROBOTO_BOLD,
@Deprecated(
"Use 'TT_REGULAR' instead.",
ReplaceWith("TT_REGULAR"),
DeprecationLevel.WARNING
)
@Deprecated("Use 'TT_REGULAR' instead.", ReplaceWith("TT_REGULAR"), DeprecationLevel.WARNING)
REGULAR,
@Deprecated(
"Use 'TT_REGULAR' instead.",
ReplaceWith("TT_REGULAR"),
DeprecationLevel.WARNING
)
@Deprecated("Use 'TT_REGULAR' instead.", ReplaceWith("TT_REGULAR"), DeprecationLevel.WARNING)
SEMI_BOLD,
@Deprecated(
"Use 'TT_MEDIUM' instead.",
ReplaceWith("TT_MEDIUM"),
DeprecationLevel.WARNING
)
@Deprecated("Use 'TT_MEDIUM' instead.", ReplaceWith("TT_MEDIUM"), DeprecationLevel.WARNING)
BOLD,
@Deprecated(
"Use 'TT_SEMI_BOLD' instead.",
ReplaceWith("TT_SEMI_BOLD"),
DeprecationLevel.WARNING
)
EXTRA_BOLD,
@Deprecated(
"Use 'TT_REGULAR' instead.",
ReplaceWith("TT_REGULAR"),
DeprecationLevel.WARNING
)
@Deprecated("Use 'TT_REGULAR' instead.", ReplaceWith("TT_REGULAR"), DeprecationLevel.WARNING)
NAVI_REGULAR,
@Deprecated(
"Use 'TT_REGULAR' instead.",
ReplaceWith("TT_REGULAR"),
DeprecationLevel.WARNING
)
@Deprecated("Use 'TT_REGULAR' instead.", ReplaceWith("TT_REGULAR"), DeprecationLevel.WARNING)
NAVI_SEMI_BOLD,
@Deprecated(
"Use 'TT_MEDIUM' instead.",
ReplaceWith("TT_MEDIUM"),
DeprecationLevel.WARNING
)
@Deprecated("Use 'TT_MEDIUM' instead.", ReplaceWith("TT_MEDIUM"), DeprecationLevel.WARNING)
NAVI_BOLD,
@Deprecated(
"Use 'TT_SEMI_BOLD' instead.",
ReplaceWith("TT_SEMI_BOLD"),
DeprecationLevel.WARNING
)
NAVI_EXTRA_BOLD,
@Deprecated(
"Use 'TT_SEMI_BOLD' instead.",
ReplaceWith("TT_SEMI_BOLD"),

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -25,6 +25,7 @@ class ScrollAwareRecyclerView(
private var scrolling = false
constructor(@NonNull context: Context) : this(context, null) {}
constructor(
@NonNull context: Context,
@Nullable attrs: AttributeSet?

View File

@@ -1,3 +1,10 @@
/*
*
* * Copyright © 2023-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
package com.navi.design.snackbar
import androidx.annotation.DrawableRes
@@ -64,15 +71,11 @@ fun NaviSnackBar(
val snackScope = rememberCoroutineScope()
val dismissSnackBar = {
snackScope.launch {
snackState.currentSnackbarData?.dismiss()
}
snackScope.launch { snackState.currentSnackbarData?.dismiss() }
Unit
}
SnackbarHost(
modifier = modifier, hostState = snackState
) {
SnackbarHost(modifier = modifier, hostState = snackState) {
Snackbar(
backgroundColor = backgroundColor,
elevation = 0.dp,
@@ -86,18 +89,15 @@ fun NaviSnackBar(
Image(
painter = painterResource(id = snackBarConfig.iconResId),
contentDescription = null,
modifier = Modifier
.align(alignment = Alignment.CenterVertically)
.clickable {
modifier =
Modifier.align(alignment = Alignment.CenterVertically).clickable {
onIconClick?.invoke()
}
)
Spacer(modifier = Modifier.width(16.dp))
}
Column(
modifier = Modifier
.height(IntrinsicSize.Min)
.weight(1f),
modifier = Modifier.height(IntrinsicSize.Min).weight(1f),
verticalArrangement = Arrangement.Center
) {
Text(
@@ -120,8 +120,8 @@ fun NaviSnackBar(
if (snackBarConfig.actionIconResId != null) {
Spacer(modifier = Modifier.width(16.dp))
Image(
modifier = Modifier
.clickable {
modifier =
Modifier.clickable {
dismissSnackBar()
onActionClick?.invoke()
},
@@ -136,9 +136,7 @@ fun NaviSnackBar(
if (show) {
LaunchedEffect(Unit) {
val result = snackState.showSnackbar(
snackBarConfig.title, duration = snackbarDuration
)
val result = snackState.showSnackbar(snackBarConfig.title, duration = snackbarDuration)
if (result == SnackbarResult.Dismissed) {
onDismissed?.invoke()
}

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022 by Navi Technologies Limited
* * Copyright © 2023-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -179,8 +179,8 @@ private class ScrollableTabData(
/**
* @return the offset required to horizontally center the tab inside this TabRow. If the tab is
* at the start / end, and there is not enough space to fully centre the tab, this will just
* clamp to the min / max position given the max width.
* at the start / end, and there is not enough space to fully centre the tab, this will just
* clamp to the min / max position given the max width.
*/
private fun TabPosition.calculateTabOffset(
density: Density,

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2019-2022 by Navi Technologies Limited
* * Copyright © 2023-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -87,8 +87,9 @@ private fun TabBaselineLayout(
val tabWidth = max(textPlaceable?.width ?: 0, iconPlaceable?.width ?: 0)
val tabHeight =
(iconPlaceable?.height
?: 0) + (textPlaceable?.height ?: 0) + iconDistanceFromBaseline.roundToPx()
(iconPlaceable?.height ?: 0) +
(textPlaceable?.height ?: 0) +
iconDistanceFromBaseline.roundToPx()
val firstBaseline = textPlaceable?.get(FirstBaseline)
val lastBaseline = textPlaceable?.get(LastBaseline)

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022-2023 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -23,9 +23,9 @@ import com.navi.design.R
import com.navi.design.utils.dpToPxInInt
import com.navi.design.utils.getStyle
import com.navi.design.utils.setViewBackground
import timber.log.Timber
class NaviTextView(context: Context, attrs: AttributeSet? = null) : AppCompatTextView(context, attrs) {
class NaviTextView(context: Context, attrs: AttributeSet? = null) :
AppCompatTextView(context, attrs) {
init {
context.theme.obtainStyledAttributes(attrs, R.styleable.NaviView, 0, 0).apply {
try {
@@ -97,7 +97,7 @@ class NaviTextView(context: Context, attrs: AttributeSet? = null) : AppCompatTex
}
}
fun setBgColor(colorId : Int){
fun setBgColor(colorId: Int) {
setBackgroundColor(colorId)
}

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022-2023 by Navi Technologies Limited
* * Copyright © 2023-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -14,11 +14,10 @@ import android.text.SpannableString
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatTextView
class VerticalTextView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyle: Int = 0
) : AppCompatTextView(context, attrs, defStyle) {
class VerticalTextView
@JvmOverloads
constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0) :
AppCompatTextView(context, attrs, defStyle) {
private var _measuredWidth: Int = 0
private var _measuredHeight: Int = 0

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022-2023 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -56,14 +56,24 @@ data class NaviSpan(
interface SpanInterface {
fun endSpan(): Int?
fun startSpan(): Int?
fun spanColor(): String?
fun spanBgColor(): String?
fun fontName(): String?
fun fontSize(): Double?
fun lineSpacing(): Float?
fun style(): String?
fun gravity(): String?
fun underLine(): Boolean?
fun cta(): ActionData?
}

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022-2023 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -9,8 +9,8 @@ package com.navi.design.textview.model
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize
import java.io.Serializable
import kotlinx.parcelize.Parcelize
@Parcelize
data class TextWithStyle(

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022-2023 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -39,26 +39,22 @@ fun getFontWeight(fontWeight: FontWeightEnum): FontWeight {
FontWeightEnum.REGULAR,
FontWeightEnum.TT_REGULAR,
FontWeightEnum.NAVI_BODY_REGULAR -> FontWeight.Normal
FontWeightEnum.SEMI_BOLD,
FontWeightEnum.TT_SEMI_BOLD,
FontWeightEnum.NAVI_BODY_DEMI_BOLD -> FontWeight.SemiBold
FontWeightEnum.ROBOTO_MEDIUM,
FontWeightEnum.TT_MEDIUM,
FontWeightEnum.NAVI_HEADLINE_REGULAR -> FontWeight.Medium
FontWeightEnum.ROBOTO_BOLD,
FontWeightEnum.TT_BOLD,
FontWeightEnum.BOLD,
FontWeightEnum.NAVI_HEADLINE_BOLD -> FontWeight.Bold
FontWeightEnum.EXTRA_BOLD -> FontWeight.ExtraBold
else -> FontWeight.Normal
}
}
fun getFontFamily(fontFamily:String?): FontFamily {
fun getFontFamily(fontFamily: String?): FontFamily {
return when (fontFamily) {
TT_FONT_FAMILY -> ttComposeFontFamily
else -> composeFontFamily
@@ -69,14 +65,14 @@ fun getFontWeight(fontWeight: String?): FontWeight {
return when (fontWeight) {
FontWeightEnum.TT_REGULAR.name,
FontWeightEnum.ROBOTO_REGULAR.name,
FontWeightEnum.REGULAR.name ,
FontWeightEnum.NAVI_REGULAR.name-> FontWeight.Normal
FontWeightEnum.REGULAR.name,
FontWeightEnum.NAVI_REGULAR.name -> FontWeight.Normal
FontWeightEnum.TT_SEMI_BOLD.name,
FontWeightEnum.SEMI_BOLD.name ,
FontWeightEnum.NAVI_EXTRA_BOLD.name-> FontWeight.SemiBold
FontWeightEnum.SEMI_BOLD.name,
FontWeightEnum.NAVI_EXTRA_BOLD.name -> FontWeight.SemiBold
FontWeightEnum.ROBOTO_MEDIUM.name,
FontWeightEnum.TT_MEDIUM.name,
FontWeightEnum.NAVI_BOLD.name-> FontWeight.Medium
FontWeightEnum.NAVI_BOLD.name -> FontWeight.Medium
FontWeightEnum.ROBOTO_BOLD.name,
FontWeightEnum.TT_BOLD.name,
FontWeightEnum.BOLD.name -> FontWeight.Bold

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -15,61 +15,61 @@ import androidx.compose.ui.unit.sp
val typography =
Typography(
h1 =
TextStyle(
fontFamily = composeFontFamily,
fontWeight = FontWeight.Bold,
fontSize = 32.sp,
letterSpacing = 0.6.sp,
),
TextStyle(
fontFamily = composeFontFamily,
fontWeight = FontWeight.Bold,
fontSize = 32.sp,
letterSpacing = 0.6.sp,
),
h2 =
TextStyle(
fontFamily = composeFontFamily,
fontWeight = FontWeight.Bold,
fontSize = 28.sp,
letterSpacing = 0.3.sp
),
TextStyle(
fontFamily = composeFontFamily,
fontWeight = FontWeight.Bold,
fontSize = 28.sp,
letterSpacing = 0.3.sp
),
h3 =
TextStyle(
fontFamily = composeFontFamily,
fontWeight = FontWeight.SemiBold,
fontSize = 24.sp,
letterSpacing = 0.2.sp
),
TextStyle(
fontFamily = composeFontFamily,
fontWeight = FontWeight.SemiBold,
fontSize = 24.sp,
letterSpacing = 0.2.sp
),
h4 =
TextStyle(
fontFamily = composeFontFamily,
fontWeight = FontWeight.Medium,
fontSize = 20.sp,
letterSpacing = 0.2.sp
),
TextStyle(
fontFamily = composeFontFamily,
fontWeight = FontWeight.Medium,
fontSize = 20.sp,
letterSpacing = 0.2.sp
),
subtitle1 =
TextStyle(
fontFamily = composeFontFamily,
fontWeight = FontWeight.Medium,
fontSize = 16.sp,
letterSpacing = 0.3.sp
),
TextStyle(
fontFamily = composeFontFamily,
fontWeight = FontWeight.Medium,
fontSize = 16.sp,
letterSpacing = 0.3.sp
),
subtitle2 =
TextStyle(
fontFamily = composeFontFamily,
fontWeight = FontWeight.Normal,
fontSize = 14.sp,
letterSpacing = 0.3.sp
),
TextStyle(
fontFamily = composeFontFamily,
fontWeight = FontWeight.Normal,
fontSize = 14.sp,
letterSpacing = 0.3.sp
),
body1 =
TextStyle(
fontFamily = composeFontFamily,
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
letterSpacing = 0.2.sp
),
TextStyle(
fontFamily = composeFontFamily,
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
letterSpacing = 0.2.sp
),
body2 =
TextStyle(
fontFamily = composeFontFamily,
fontWeight = FontWeight.Normal,
fontSize = 14.sp,
letterSpacing = 0.3.sp
),
TextStyle(
fontFamily = composeFontFamily,
fontWeight = FontWeight.Normal,
fontSize = 14.sp,
letterSpacing = 0.3.sp
),
)
val Typography.title1: TextStyle

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022-2023 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -40,6 +40,7 @@ fun moveViewWithDistance(
}
.start()
}
fun moveViewWithDistanceAnimator(
view: View?,
distance: Int,
@@ -47,23 +48,22 @@ fun moveViewWithDistanceAnimator(
isRepeatable: Boolean = true,
repeatDelay: Long? = null
): ObjectAnimator {
return ObjectAnimator.ofFloat(view, "translationX", distance.toFloat())
.apply {
duration = animDuration
if (isRepeatable) {
repeatCount = ObjectAnimator.INFINITE
repeatMode = ObjectAnimator.RESTART
} else {
repeatDelay?.let {
doOnEnd {
startDelay = repeatDelay
start()
}
return ObjectAnimator.ofFloat(view, "translationX", distance.toFloat()).apply {
duration = animDuration
if (isRepeatable) {
repeatCount = ObjectAnimator.INFINITE
repeatMode = ObjectAnimator.RESTART
} else {
repeatDelay?.let {
doOnEnd {
startDelay = repeatDelay
start()
}
}
doOnStart { view?.isVisible = true }
start()
}
doOnStart { view?.isVisible = true }
start()
}
}
fun setShakeAnimation(vararg views: View) {
@@ -76,5 +76,5 @@ fun setShakeAnimation(vararg views: View) {
}
views.forEach { it.animation = animation }
animation.start()
} catch (_: Exception) { }
} catch (_: Exception) {}
}

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022 by Navi Technologies Limited
* * Copyright © 2023-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022-2023 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -58,7 +58,7 @@ fun TextView.setIconifiedText(textComponent: TextWithStyle?, @DrawableRes iconRe
val strLen = textComponent?.text?.length ?: 0
var startInd = 0
var endInd = 0
if(strLen > 0) {
if (strLen > 0) {
startInd = strLen - 1
endInd = strLen
}
@@ -89,10 +89,7 @@ fun String?.parseColorSafe(
Color.parseColor(default)
}
fun String?.parseColorSafe(
default: Int = R.color.outrageous_orange,
context: Context
): Int =
fun String?.parseColorSafe(default: Int = R.color.outrageous_orange, context: Context): Int =
try {
when {
this == null -> ContextCompat.getColor(context, default)
@@ -127,9 +124,9 @@ fun String?.spannedText(
span?.forEach {
if (
it.isNotNull() &&
it.spanColor().isNotNullAndNotEmpty() &&
it.startSpan().isNotNull() &&
it.endSpan().isNotNull()
it.spanColor().isNotNullAndNotEmpty() &&
it.startSpan().isNotNull() &&
it.endSpan().isNotNull()
) {
val startSpan = kotlin.math.max(it.startSpan()!!, 0)
val endSpan = kotlin.math.min(it.endSpan()!!, this.length)
@@ -202,9 +199,10 @@ fun TextView.setSpannableString(
styleVariation: String? = null,
clickListener: ((ActionData) -> Unit)? = null
) {
val selectedVariation = if (styleVariation != null) {
textData?.styleVariations?.get(styleVariation) ?: textData?.style
} else textData?.style
val selectedVariation =
if (styleVariation != null) {
textData?.styleVariations?.get(styleVariation) ?: textData?.style
} else textData?.style
setSpannableString(textData?.text, selectedVariation, clickListener)
}
@@ -215,9 +213,10 @@ fun TextView.setSpannableString(
invokeListenerOnlyOnUpdate: Boolean? = null,
clickListener: ((ActionData) -> Unit)? = null
) {
val selectedVariation = if (styleVariation != null) {
textData?.styleVariations?.get(styleVariation) ?: textData?.style
} else textData?.style
val selectedVariation =
if (styleVariation != null) {
textData?.styleVariations?.get(styleVariation) ?: textData?.style
} else textData?.style
setSpannableString(textData?.text, selectedVariation, clickListener, invokeListenerOnlyOnUpdate)
}
@@ -395,9 +394,7 @@ fun ViewGroup.replaceLayout(layoutId: Int): ViewDataBinding? {
}
fun updateFontToTTMedium(style: List<NaviSpan>?) {
style?.forEach {
it.fontName = FontWeightEnum.TT_MEDIUM.name
}
style?.forEach { it.fontName = FontWeightEnum.TT_MEDIUM.name }
}
fun hexColorCodePrefix(opacity: Float): String {
@@ -440,30 +437,29 @@ fun hexColorCodePrefix(opacity: Float): String {
else if (opacity <= 36) return "5C"
else if (opacity <= 37) return "5E"
else if (opacity <= 38) return "61"
else if (opacity <= 39) return "63"
else if (opacity <= 40) return "66"
else return ""
else if (opacity <= 39) return "63" else if (opacity <= 40) return "66" else return ""
}
typealias onCommonClick = (CommonViewData) -> Unit
fun EditText.hideCutCopyMenuPopUp() {
customSelectionActionModeCallback = object : ActionMode.Callback {
override fun onCreateActionMode(mode: ActionMode?, menu: Menu?): Boolean {
return true
}
customSelectionActionModeCallback =
object : ActionMode.Callback {
override fun onCreateActionMode(mode: ActionMode?, menu: Menu?): Boolean {
return true
}
override fun onPrepareActionMode(mode: ActionMode?, menu: Menu): Boolean {
menu.clear()
return false
}
override fun onPrepareActionMode(mode: ActionMode?, menu: Menu): Boolean {
menu.clear()
return false
}
override fun onActionItemClicked(mode: ActionMode?, item: MenuItem?): Boolean {
return false
}
override fun onActionItemClicked(mode: ActionMode?, item: MenuItem?): Boolean {
return false
}
override fun onDestroyActionMode(mode: ActionMode?) {}
}
override fun onDestroyActionMode(mode: ActionMode?) {}
}
}
fun isValidHexColor(colorCode: String?): Boolean {

View File

@@ -1,13 +1,12 @@
/*
*
* * Copyright © 2022-2023 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
package com.navi.design.utils
import android.graphics.Color
import android.text.SpannableString
import android.text.SpannableStringBuilder
import android.text.style.ForegroundColorSpan
@@ -16,34 +15,31 @@ import androidx.core.content.res.ResourcesCompat
import com.navi.design.R
import com.navi.design.font.FontWeightEnum
fun getFontStyle(fontWeightName: String?) = when (fontWeightName) {
FontWeightEnum.TT_REGULAR.name,
FontWeightEnum.ROBOTO_REGULAR.name,
FontWeightEnum.SEMI_BOLD.name,
FontWeightEnum.NAVI_SEMI_BOLD.name,
FontWeightEnum.REGULAR.name,
FontWeightEnum.NAVI_REGULAR.name,
FontWeightEnum.NAVI_BODY_REGULAR.name -> R.font.tt_regular
FontWeightEnum.TT_MEDIUM.name,
FontWeightEnum.ROBOTO_MEDIUM.name,
FontWeightEnum.BOLD.name,
FontWeightEnum.NAVI_BOLD.name,
FontWeightEnum.TT_MEDIUM.name,
FontWeightEnum.NAVI_HEADLINE_REGULAR.name -> R.font.tt_medium
FontWeightEnum.TT_SEMI_BOLD.name,
FontWeightEnum.ROBOTO_BOLD.name,
FontWeightEnum.EXTRA_BOLD.name,
FontWeightEnum.NAVI_EXTRA_BOLD.name,
FontWeightEnum.NAVI_BLACK.name,
FontWeightEnum.NAVI_BODY_DEMI_BOLD.name -> R.font.tt_semi_bold
FontWeightEnum.TT_BOLD.name,
FontWeightEnum.NAVI_HEADLINE_BOLD.name -> R.font.tt_bold
else -> R.font.tt_regular
}
fun getFontStyle(fontWeightName: String?) =
when (fontWeightName) {
FontWeightEnum.TT_REGULAR.name,
FontWeightEnum.ROBOTO_REGULAR.name,
FontWeightEnum.SEMI_BOLD.name,
FontWeightEnum.NAVI_SEMI_BOLD.name,
FontWeightEnum.REGULAR.name,
FontWeightEnum.NAVI_REGULAR.name,
FontWeightEnum.NAVI_BODY_REGULAR.name -> R.font.tt_regular
FontWeightEnum.TT_MEDIUM.name,
FontWeightEnum.ROBOTO_MEDIUM.name,
FontWeightEnum.BOLD.name,
FontWeightEnum.NAVI_BOLD.name,
FontWeightEnum.TT_MEDIUM.name,
FontWeightEnum.NAVI_HEADLINE_REGULAR.name -> R.font.tt_medium
FontWeightEnum.TT_SEMI_BOLD.name,
FontWeightEnum.ROBOTO_BOLD.name,
FontWeightEnum.EXTRA_BOLD.name,
FontWeightEnum.NAVI_EXTRA_BOLD.name,
FontWeightEnum.NAVI_BLACK.name,
FontWeightEnum.NAVI_BODY_DEMI_BOLD.name -> R.font.tt_semi_bold
FontWeightEnum.TT_BOLD.name,
FontWeightEnum.NAVI_HEADLINE_BOLD.name -> R.font.tt_bold
else -> R.font.tt_regular
}
fun getFontStyle(fontWeight: FontWeightEnum?): Int = getFontStyle(fontWeight?.name)

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022-2023 by Navi Technologies Limited
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -108,7 +108,9 @@ fun getNaviDrawableFromBackend(
}
}
fun getNaviDrawableFromDrawableData(backgroundDrawableData: BackgroundDrawableData?): GradientDrawable {
fun getNaviDrawableFromDrawableData(
backgroundDrawableData: BackgroundDrawableData?
): GradientDrawable {
return backgroundDrawableData?.let {
getNaviDrawable(
shape = getDrawableShapeFromString(it.shape),
@@ -122,7 +124,9 @@ fun getNaviDrawableFromDrawableData(backgroundDrawableData: BackgroundDrawableDa
} ?: getNaviDrawable()
}
private fun getDrawableShapeFromString(string: String? = DrawableShape.RECTANGLE.name): DrawableShape {
private fun getDrawableShapeFromString(
string: String? = DrawableShape.RECTANGLE.name
): DrawableShape {
return when (string) {
DrawableShape.RECTANGLE.name -> DrawableShape.RECTANGLE
DrawableShape.LINE.name -> DrawableShape.LINE
@@ -195,10 +199,12 @@ data class BackgroundDrawableData(
@SerializedName("strokeColor") val strokeColor: String? = null,
@SerializedName("gradientColors") val gradientColors: List<String>? = null,
@SerializedName("gradientOrientation") val gradientOrientation: String? = null,
@SerializedName("radii") val radii: CornerRadius = CornerRadius(
R.integer.zero.toFloat(),
R.integer.zero.toFloat(),
R.integer.zero.toFloat(),
R.integer.zero.toFloat()
)
@SerializedName("radii")
val radii: CornerRadius =
CornerRadius(
R.integer.zero.toFloat(),
R.integer.zero.toFloat(),
R.integer.zero.toFloat(),
R.integer.zero.toFloat()
)
) : Parcelable

View File

@@ -1,3 +1,10 @@
/*
*
* * Copyright © 2023-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
package com.navi.design.utils
import androidx.compose.animation.core.AnimationState
@@ -7,7 +14,6 @@ import androidx.compose.foundation.gestures.FlingBehavior
import androidx.compose.foundation.gestures.ScrollScope
import kotlin.math.abs
class ScrollSpeedFlingBehavior(
private val flingDecay: DecayAnimationSpec<Float>,
private val maxVelocity: Float,
@@ -23,16 +29,17 @@ class ScrollSpeedFlingBehavior(
var velocityLeft = newVelocity
var lastValue = 0f
AnimationState(
initialValue = 0f,
initialVelocity = newVelocity,
).animateDecay(flingDecay) {
val delta = value - lastValue
val consumed = scrollBy(delta)
lastValue = value
velocityLeft = this.velocity
// avoid rounding errors and stop if anything is unconsumed
if (abs(delta - consumed) > 0.5f) this.cancelAnimation()
}
initialValue = 0f,
initialVelocity = newVelocity,
)
.animateDecay(flingDecay) {
val delta = value - lastValue
val consumed = scrollBy(delta)
lastValue = value
velocityLeft = this.velocity
// avoid rounding errors and stop if anything is unconsumed
if (abs(delta - consumed) > 0.5f) this.cancelAnimation()
}
velocityLeft
} else newVelocity
}

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2021-2023 by Navi Technologies Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -94,6 +94,7 @@ fun parseDateFromOneToAnother(dateInString: String?, formatString: String): Date
return null
}
}
@SuppressLint("SimpleDateFormat")
fun parseDateToString(dateInString: Date?, formatString: String): String? {
if (dateInString.isNull()) return null

View File

@@ -1,17 +1,16 @@
/*
*
* * Copyright © 2023 by Navi Technologies Limited
* * Copyright © 2023-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
package com.navi.design.utils
import com.navi.design.R as DesignR
import android.content.Context
import android.graphics.Color
import android.view.View
import androidx.core.content.ContextCompat
import com.navi.design.R as DesignR
import io.mockk.*
import org.junit.Assert.*
import org.junit.Test
@@ -26,7 +25,7 @@ class ExtKtTest {
assertEquals(1001, "#FF5732".parseColorSafe())
assertEquals(1001, "FF5732".parseColorSafe())
assertEquals(1000, "#asdfgh".parseColorSafe())
val nullColor:String? = null
val nullColor: String? = null
assertEquals(1000, nullColor.parseColorSafe())
}
@@ -40,98 +39,96 @@ class ExtKtTest {
assertEquals(1000, "#000000".parseColorSafe(context = context))
assertEquals(1000, "000000".parseColorSafe(context = context))
assertEquals(1001, "#asdfgh".parseColorSafe(context = context))
val nullColor:String? = null
val nullColor: String? = null
assertEquals(1001, nullColor.parseColorSafe(context = context))
}
@Test
fun testHexColorCodePrefix() {
assertEquals("00",hexColorCodePrefix(-0.5f))
assertEquals("00",hexColorCodePrefix(0f))
assertEquals("03",hexColorCodePrefix(1f))
assertEquals("03",hexColorCodePrefix(0.5f))
assertEquals("05",hexColorCodePrefix(2f))
assertEquals("05",hexColorCodePrefix(1.5f))
assertEquals("08",hexColorCodePrefix(3f))
assertEquals("08",hexColorCodePrefix(2.5f))
assertEquals("0A",hexColorCodePrefix(4f))
assertEquals("0A",hexColorCodePrefix(3.5f))
assertEquals("0D",hexColorCodePrefix(5f))
assertEquals("0D",hexColorCodePrefix(4.5f))
assertEquals("0F",hexColorCodePrefix(6f))
assertEquals("0F",hexColorCodePrefix(5.5f))
assertEquals("12",hexColorCodePrefix(7f))
assertEquals("12",hexColorCodePrefix(6.5f))
assertEquals("14",hexColorCodePrefix(8f))
assertEquals("14",hexColorCodePrefix(7.5f))
assertEquals("17",hexColorCodePrefix(9f))
assertEquals("17",hexColorCodePrefix(8.5f))
assertEquals("1A",hexColorCodePrefix(10f))
assertEquals("1A",hexColorCodePrefix(9.5f))
assertEquals("1C",hexColorCodePrefix(11f))
assertEquals("1C",hexColorCodePrefix(10.5f))
assertEquals("1F",hexColorCodePrefix(12f))
assertEquals("1F",hexColorCodePrefix(11.5f))
assertEquals("21",hexColorCodePrefix(13f))
assertEquals("21",hexColorCodePrefix(12.5f))
assertEquals("24",hexColorCodePrefix(14f))
assertEquals("24",hexColorCodePrefix(13.5f))
assertEquals("26",hexColorCodePrefix(15f))
assertEquals("26",hexColorCodePrefix(14.5f))
assertEquals("29",hexColorCodePrefix(16f))
assertEquals("29",hexColorCodePrefix(15.5f))
assertEquals("2B",hexColorCodePrefix(17f))
assertEquals("2B",hexColorCodePrefix(16.5f))
assertEquals("2E",hexColorCodePrefix(18f))
assertEquals("2E",hexColorCodePrefix(17.5f))
assertEquals("30",hexColorCodePrefix(19f))
assertEquals("30",hexColorCodePrefix(18.5f))
assertEquals("33",hexColorCodePrefix(20f))
assertEquals("33",hexColorCodePrefix(19.5f))
assertEquals("36",hexColorCodePrefix(21f))
assertEquals("36",hexColorCodePrefix(20.5f))
assertEquals("38",hexColorCodePrefix(22f))
assertEquals("38",hexColorCodePrefix(21.5f))
assertEquals("3B",hexColorCodePrefix(23f))
assertEquals("3B",hexColorCodePrefix(22.5f))
assertEquals("3D",hexColorCodePrefix(24f))
assertEquals("3D",hexColorCodePrefix(23.5f))
assertEquals("40",hexColorCodePrefix(25f))
assertEquals("40",hexColorCodePrefix(24.5f))
assertEquals("42",hexColorCodePrefix(26f))
assertEquals("42",hexColorCodePrefix(25.5f))
assertEquals("45",hexColorCodePrefix(27f))
assertEquals("45",hexColorCodePrefix(26.5f))
assertEquals("47",hexColorCodePrefix(28f))
assertEquals("47",hexColorCodePrefix(27.5f))
assertEquals("4A",hexColorCodePrefix(29f))
assertEquals("4A",hexColorCodePrefix(28.5f))
assertEquals("4D",hexColorCodePrefix(30f))
assertEquals("4D",hexColorCodePrefix(29.5f))
assertEquals("4F",hexColorCodePrefix(31f))
assertEquals("4F",hexColorCodePrefix(30.5f))
assertEquals("52",hexColorCodePrefix(32f))
assertEquals("52",hexColorCodePrefix(31.5f))
assertEquals("54",hexColorCodePrefix(33f))
assertEquals("54",hexColorCodePrefix(32.5f))
assertEquals("57",hexColorCodePrefix(34f))
assertEquals("57",hexColorCodePrefix(33.5f))
assertEquals("59",hexColorCodePrefix(35f))
assertEquals("59",hexColorCodePrefix(34.5f))
assertEquals("5C",hexColorCodePrefix(36f))
assertEquals("5C",hexColorCodePrefix(35.5f))
assertEquals("5E",hexColorCodePrefix(37f))
assertEquals("5E",hexColorCodePrefix(36.5f))
assertEquals("61",hexColorCodePrefix(38f))
assertEquals("61",hexColorCodePrefix(37.5f))
assertEquals("63",hexColorCodePrefix(39f))
assertEquals("63",hexColorCodePrefix(38.5f))
assertEquals("66",hexColorCodePrefix(40f))
assertEquals("66",hexColorCodePrefix(39.5f))
assertEquals("",hexColorCodePrefix(41f))
assertEquals("",hexColorCodePrefix(40.5f))
assertEquals("00", hexColorCodePrefix(-0.5f))
assertEquals("00", hexColorCodePrefix(0f))
assertEquals("03", hexColorCodePrefix(1f))
assertEquals("03", hexColorCodePrefix(0.5f))
assertEquals("05", hexColorCodePrefix(2f))
assertEquals("05", hexColorCodePrefix(1.5f))
assertEquals("08", hexColorCodePrefix(3f))
assertEquals("08", hexColorCodePrefix(2.5f))
assertEquals("0A", hexColorCodePrefix(4f))
assertEquals("0A", hexColorCodePrefix(3.5f))
assertEquals("0D", hexColorCodePrefix(5f))
assertEquals("0D", hexColorCodePrefix(4.5f))
assertEquals("0F", hexColorCodePrefix(6f))
assertEquals("0F", hexColorCodePrefix(5.5f))
assertEquals("12", hexColorCodePrefix(7f))
assertEquals("12", hexColorCodePrefix(6.5f))
assertEquals("14", hexColorCodePrefix(8f))
assertEquals("14", hexColorCodePrefix(7.5f))
assertEquals("17", hexColorCodePrefix(9f))
assertEquals("17", hexColorCodePrefix(8.5f))
assertEquals("1A", hexColorCodePrefix(10f))
assertEquals("1A", hexColorCodePrefix(9.5f))
assertEquals("1C", hexColorCodePrefix(11f))
assertEquals("1C", hexColorCodePrefix(10.5f))
assertEquals("1F", hexColorCodePrefix(12f))
assertEquals("1F", hexColorCodePrefix(11.5f))
assertEquals("21", hexColorCodePrefix(13f))
assertEquals("21", hexColorCodePrefix(12.5f))
assertEquals("24", hexColorCodePrefix(14f))
assertEquals("24", hexColorCodePrefix(13.5f))
assertEquals("26", hexColorCodePrefix(15f))
assertEquals("26", hexColorCodePrefix(14.5f))
assertEquals("29", hexColorCodePrefix(16f))
assertEquals("29", hexColorCodePrefix(15.5f))
assertEquals("2B", hexColorCodePrefix(17f))
assertEquals("2B", hexColorCodePrefix(16.5f))
assertEquals("2E", hexColorCodePrefix(18f))
assertEquals("2E", hexColorCodePrefix(17.5f))
assertEquals("30", hexColorCodePrefix(19f))
assertEquals("30", hexColorCodePrefix(18.5f))
assertEquals("33", hexColorCodePrefix(20f))
assertEquals("33", hexColorCodePrefix(19.5f))
assertEquals("36", hexColorCodePrefix(21f))
assertEquals("36", hexColorCodePrefix(20.5f))
assertEquals("38", hexColorCodePrefix(22f))
assertEquals("38", hexColorCodePrefix(21.5f))
assertEquals("3B", hexColorCodePrefix(23f))
assertEquals("3B", hexColorCodePrefix(22.5f))
assertEquals("3D", hexColorCodePrefix(24f))
assertEquals("3D", hexColorCodePrefix(23.5f))
assertEquals("40", hexColorCodePrefix(25f))
assertEquals("40", hexColorCodePrefix(24.5f))
assertEquals("42", hexColorCodePrefix(26f))
assertEquals("42", hexColorCodePrefix(25.5f))
assertEquals("45", hexColorCodePrefix(27f))
assertEquals("45", hexColorCodePrefix(26.5f))
assertEquals("47", hexColorCodePrefix(28f))
assertEquals("47", hexColorCodePrefix(27.5f))
assertEquals("4A", hexColorCodePrefix(29f))
assertEquals("4A", hexColorCodePrefix(28.5f))
assertEquals("4D", hexColorCodePrefix(30f))
assertEquals("4D", hexColorCodePrefix(29.5f))
assertEquals("4F", hexColorCodePrefix(31f))
assertEquals("4F", hexColorCodePrefix(30.5f))
assertEquals("52", hexColorCodePrefix(32f))
assertEquals("52", hexColorCodePrefix(31.5f))
assertEquals("54", hexColorCodePrefix(33f))
assertEquals("54", hexColorCodePrefix(32.5f))
assertEquals("57", hexColorCodePrefix(34f))
assertEquals("57", hexColorCodePrefix(33.5f))
assertEquals("59", hexColorCodePrefix(35f))
assertEquals("59", hexColorCodePrefix(34.5f))
assertEquals("5C", hexColorCodePrefix(36f))
assertEquals("5C", hexColorCodePrefix(35.5f))
assertEquals("5E", hexColorCodePrefix(37f))
assertEquals("5E", hexColorCodePrefix(36.5f))
assertEquals("61", hexColorCodePrefix(38f))
assertEquals("61", hexColorCodePrefix(37.5f))
assertEquals("63", hexColorCodePrefix(39f))
assertEquals("63", hexColorCodePrefix(38.5f))
assertEquals("66", hexColorCodePrefix(40f))
assertEquals("66", hexColorCodePrefix(39.5f))
assertEquals("", hexColorCodePrefix(41f))
assertEquals("", hexColorCodePrefix(40.5f))
}
@Test

View File

@@ -1,18 +1,17 @@
/*
*
* * Copyright © 2023 by Navi Technologies Limited
* * Copyright © 2023-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
package com.navi.design.utils
import com.navi.design.R as DesignR
import com.navi.base.utils.EMPTY
import DesignR.font.tt_bold
import DesignR.font.tt_medium
import DesignR.font.tt_regular
import DesignR.font.tt_semi_bold
import com.navi.base.utils.EMPTY
import com.navi.design.font.FontWeightEnum
import org.junit.Assert.assertEquals
import org.junit.Test

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2023 by Navi Technologies Limited
* * Copyright © 2023-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -8,11 +8,9 @@
package com.navi.design.utils
import com.navi.design.R as DesignR
import org.junit.Assert.*
import org.junit.Test
import java.text.SimpleDateFormat
import org.junit.Assert.*
import org.junit.Test
class UtilsKtTest {
@@ -29,7 +27,6 @@ class UtilsKtTest {
assertEquals(DesignR.style.Title5TextStyle, getStyle("Title5TextStyle"))
assertEquals(DesignR.style.Title5BoldTextStyle, getStyle("Title5BoldTextStyle"))
assertEquals(null, getStyle("NotDefinedTextStyle"))
}
@Test
@@ -42,18 +39,18 @@ class UtilsKtTest {
@Test
fun testParseDateFromOneToAnother() {
val jan2nd2023 = SimpleDateFormat("yyyy-MM-dd").parse("2023-01-02")
assertEquals(jan2nd2023, parseDateFromOneToAnother("02-01-2023","dd-MM-yyyy"))
assertEquals(jan2nd2023, parseDateFromOneToAnother("02-01-2023", "dd-MM-yyyy"))
assertEquals(null, parseDateFromOneToAnother("2023-02-02","xxxx-MM-dd"))
assertEquals(null, parseDateFromOneToAnother("2023-02-02", "xxxx-MM-dd"))
}
@Test
fun testParseDateToString() {
val jan2nd2023 = SimpleDateFormat("yyyy-MM-dd").parse("2023-01-02")
assertEquals("02-01-2023", parseDateToString(jan2nd2023,"dd-MM-yyyy"))
assertEquals("02-01-2023", parseDateToString(jan2nd2023, "dd-MM-yyyy"))
val feb2nd2023 = SimpleDateFormat("yyyy-MM-dd").parse("2023-02-02")
assertEquals(null, parseDateToString(feb2nd2023,"xxxx-MM-dd"))
assertEquals(null, parseDateToString(feb2nd2023, "xxxx-MM-dd"))
}
@Test
@@ -111,5 +108,4 @@ class UtilsKtTest {
assertEquals("523,123.5", decimalFormatForAmount.format(523123.50f))
assertEquals("423,342.12", decimalFormatForAmount.format(423342.12f))
}
}

View File

@@ -1,9 +1,10 @@
/*
*
* * Copyright © 2021 by Navi Technologies Private Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
package com.navi.insurance.common.custom_view;
import android.content.res.Resources;
@@ -14,7 +15,6 @@ import android.graphics.Rect;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Interpolator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@@ -25,28 +25,19 @@ public class CirclePagerIndicatorDecoration extends RecyclerView.ItemDecoration
private static final float DP = Resources.getSystem().getDisplayMetrics().density;
/**
* Height of the space the indicator takes up at the bottom of the view.
*/
/** Height of the space the indicator takes up at the bottom of the view. */
private final int mIndicatorHeight = (int) (DP * 20);
/**
* Indicator stroke width.
*/
/** Indicator stroke width. */
private final float mIndicatorStrokeWidth = DP * 4;
/**
* Indicator width.
*/
/** Indicator width. */
private final float mIndicatorItemLength = DP * 4;
/**
* Padding between indicators.
*/
/** Padding between indicators. */
private final float mIndicatorItemPadding = DP * 12;
/**
* Some more natural animation interpolation
*/
/** Some more natural animation interpolation */
private final Interpolator mInterpolator = new AccelerateDecelerateInterpolator();
private final Paint mPaint = new Paint();
@@ -61,13 +52,12 @@ public class CirclePagerIndicatorDecoration extends RecyclerView.ItemDecoration
@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
super.onDrawOver(c, parent, state);
if(parent.getAdapter() == null) {
if (parent.getAdapter() == null) {
return;
}
int itemCount = parent.getAdapter().getItemCount();
if (itemCount <= 1)
return;
if (itemCount <= 1) return;
// center horizontally, calculate width and subtract half from center
float totalLength = mIndicatorItemLength * itemCount;
@@ -100,7 +90,8 @@ public class CirclePagerIndicatorDecoration extends RecyclerView.ItemDecoration
drawHighlights(c, indicatorStartX, indicatorPosY, activePosition, progress);
}
private void drawInactiveIndicators(Canvas c, float indicatorStartX, float indicatorPosY, int itemCount) {
private void drawInactiveIndicators(
Canvas c, float indicatorStartX, float indicatorPosY, int itemCount) {
mPaint.setColor(colorInactive);
// width of item indicator including padding
@@ -115,8 +106,12 @@ public class CirclePagerIndicatorDecoration extends RecyclerView.ItemDecoration
}
}
private void drawHighlights(Canvas c, float indicatorStartX, float indicatorPosY,
int highlightPosition, float progress) {
private void drawHighlights(
Canvas c,
float indicatorStartX,
float indicatorPosY,
int highlightPosition,
float progress) {
mPaint.setColor(colorActive);
// width of item indicator including padding
@@ -131,14 +126,20 @@ public class CirclePagerIndicatorDecoration extends RecyclerView.ItemDecoration
} else {
float highlightStart = indicatorStartX + itemWidth * highlightPosition;
// calculate partial highlight
float partialLength = mIndicatorItemLength * progress + mIndicatorItemPadding*progress;
float partialLength =
mIndicatorItemLength * progress + mIndicatorItemPadding * progress;
c.drawCircle(highlightStart + partialLength, indicatorPosY, mIndicatorItemLength / 2F, mPaint);
c.drawCircle(
highlightStart + partialLength,
indicatorPosY,
mIndicatorItemLength / 2F,
mPaint);
}
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
public void getItemOffsets(
Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
outRect.bottom = mIndicatorHeight;
}

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2019 by Navi Technologies Private Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -57,5 +57,3 @@ public class NaviFireBaseMessagingService extends FirebaseMessagingService {
}
*/

View File

@@ -1,15 +1,15 @@
/*
*
* * Copyright © 2019 by Navi Technologies Private Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
package com.travijuu.numberpicker.library.Enums;
/**
* Created by travijuu on 26/05/16.
*/
/** Created by travijuu on 26/05/16. */
public enum ActionEnum {
INCREMENT, DECREMENT, MANUAL
INCREMENT,
DECREMENT,
MANUAL
}

View File

@@ -1,15 +1,13 @@
/*
*
* * Copyright © 2019 by Navi Technologies Private Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
package com.travijuu.numberpicker.library.Interface;
/**
* Created by travijuu on 26/05/16.
*/
/** Created by travijuu on 26/05/16. */
public interface LimitExceededListener {
void limitExceeded(int limit, int exceededValue);

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2019 by Navi Technologies Private Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -9,10 +9,7 @@ package com.travijuu.numberpicker.library.Interface;
import com.travijuu.numberpicker.library.Enums.ActionEnum;
/**
* Created by travijuu on 19/12/16.
*/
/** Created by travijuu on 19/12/16. */
public interface ValueChangedListener {
void valueChanged(int value, ActionEnum action);

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2019 by Navi Technologies Private Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -9,13 +9,10 @@ package com.travijuu.numberpicker.library.Listener;
import android.view.View;
import android.widget.TextView;
import com.travijuu.numberpicker.library.Enums.ActionEnum;
import com.travijuu.numberpicker.library.NumberPicker;
/**
* Created by travijuu on 26/05/16.
*/
/** Created by travijuu on 26/05/16. */
public class ActionListener implements View.OnClickListener {
NumberPicker layout;

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2019 by Navi Technologies Private Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -8,17 +8,17 @@
package com.travijuu.numberpicker.library.Listener;
import android.util.Log;
import com.travijuu.numberpicker.library.Interface.LimitExceededListener;
/**
* Created by travijuu on 26/05/16.
*/
/** Created by travijuu on 26/05/16. */
public class DefaultLimitExceededListener implements LimitExceededListener {
public void limitExceeded(int limit, int exceededValue) {
String message = String.format("NumberPicker cannot set to %d because the limit is %d.", exceededValue, limit);
String message =
String.format(
"NumberPicker cannot set to %d because the limit is %d.",
exceededValue, limit);
Log.v(this.getClass().getSimpleName(), message);
}
}

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2019 by Navi Technologies Private Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -10,14 +10,10 @@ package com.travijuu.numberpicker.library.Listener;
import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo;
import android.widget.TextView;
import com.travijuu.numberpicker.library.Enums.ActionEnum;
import com.travijuu.numberpicker.library.NumberPicker;
/**
* Created by travijuu on 13/04/17.
*/
/** Created by travijuu on 13/04/17. */
public class DefaultOnEditorActionListener implements TextView.OnEditorActionListener {
NumberPicker layout;

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2019 by Navi Technologies Private Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -9,14 +9,10 @@ package com.travijuu.numberpicker.library.Listener;
import android.view.View;
import android.widget.EditText;
import com.travijuu.numberpicker.library.Enums.ActionEnum;
import com.travijuu.numberpicker.library.NumberPicker;
/**
* Created by travijuu on 03/06/17.
*/
/** Created by travijuu on 03/06/17. */
public class DefaultOnFocusChangeListener implements View.OnFocusChangeListener {
NumberPicker layout;

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2019 by Navi Technologies Private Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -8,19 +8,18 @@
package com.travijuu.numberpicker.library.Listener;
import android.util.Log;
import com.travijuu.numberpicker.library.Enums.ActionEnum;
import com.travijuu.numberpicker.library.Interface.ValueChangedListener;
/**
* Created by travijuu on 19/12/16.
*/
/** Created by travijuu on 19/12/16. */
public class DefaultValueChangedListener implements ValueChangedListener {
public void valueChanged(int value, ActionEnum action) {
String actionText = action == ActionEnum.MANUAL ? "manually set" : (action == ActionEnum.INCREMENT ? "incremented" : "decremented");
String actionText =
action == ActionEnum.MANUAL
? "manually set"
: (action == ActionEnum.INCREMENT ? "incremented" : "decremented");
String message = String.format("NumberPicker is %s to %d", actionText, value);
Log.v(this.getClass().getSimpleName(), message);
}

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2019 by Navi Technologies Private Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -14,7 +14,6 @@ import android.view.LayoutInflater;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.navi.insurance.R;
import com.travijuu.numberpicker.library.Enums.ActionEnum;
import com.travijuu.numberpicker.library.Interface.LimitExceededListener;
@@ -25,9 +24,7 @@ import com.travijuu.numberpicker.library.Listener.DefaultOnEditorActionListener;
import com.travijuu.numberpicker.library.Listener.DefaultOnFocusChangeListener;
import com.travijuu.numberpicker.library.Listener.DefaultValueChangedListener;
/**
* Created by travijuu on 26/05/16.
*/
/** Created by travijuu on 26/05/16. */
public class NumberPicker extends LinearLayout {
// default values
@@ -71,15 +68,20 @@ public class NumberPicker extends LinearLayout {
}
private void initialize(Context context, AttributeSet attrs) {
TypedArray attributes = context.getTheme().obtainStyledAttributes(attrs, R.styleable.NumberPicker, 0, 0);
TypedArray attributes =
context.getTheme().obtainStyledAttributes(attrs, R.styleable.NumberPicker, 0, 0);
// set required variables with values of xml layout attributes or default ones
this.minValue = attributes.getInteger(R.styleable.NumberPicker_min, this.DEFAULT_MIN);
this.maxValue = attributes.getInteger(R.styleable.NumberPicker_max, this.DEFAULT_MAX);
this.currentValue = attributes.getInteger(R.styleable.NumberPicker_value, this.DEFAULT_VALUE);
this.currentValue =
attributes.getInteger(R.styleable.NumberPicker_value, this.DEFAULT_VALUE);
this.unit = attributes.getInteger(R.styleable.NumberPicker_unit, this.DEFAULT_UNIT);
this.layout = attributes.getResourceId(R.styleable.NumberPicker_custom_layout, this.DEFAULT_LAYOUT);
this.focusable = attributes.getBoolean(R.styleable.NumberPicker_focusable, this.DEFAULT_FOCUSABLE);
this.layout =
attributes.getResourceId(
R.styleable.NumberPicker_custom_layout, this.DEFAULT_LAYOUT);
this.focusable =
attributes.getBoolean(R.styleable.NumberPicker_focusable, this.DEFAULT_FOCUSABLE);
this.mContext = context;
// if current value is greater than the max. value, decrement it to the max. value
@@ -97,8 +99,10 @@ public class NumberPicker extends LinearLayout {
this.displayTextView = (TextView) findViewById(R.id.display);
// register button click and action listeners
this.incrementButton.setOnClickListener(new ActionListener(this, this.displayTextView, ActionEnum.INCREMENT));
this.decrementButton.setOnClickListener(new ActionListener(this, this.displayTextView, ActionEnum.DECREMENT));
this.incrementButton.setOnClickListener(
new ActionListener(this, this.displayTextView, ActionEnum.INCREMENT));
this.decrementButton.setOnClickListener(
new ActionListener(this, this.displayTextView, ActionEnum.DECREMENT));
// init listener for exceeding upper and lower limits
this.setLimitExceededListener(new DefaultLimitExceededListener());
@@ -158,7 +162,8 @@ public class NumberPicker extends LinearLayout {
public void setValue(int value) {
if (!this.valueIsAllowed(value)) {
this.limitExceededListener.limitExceeded(value < this.minValue ? this.minValue : this.maxValue, value);
this.limitExceededListener.limitExceeded(
value < this.minValue ? this.minValue : this.maxValue, value);
return;
}
@@ -229,7 +234,8 @@ public class NumberPicker extends LinearLayout {
this.setValue(this.currentValue + unit);
if (oldValue != this.getValue()) {
this.valueChangedListener.valueChanged(this.getValue(), unit > 0 ? ActionEnum.INCREMENT : ActionEnum.DECREMENT);
this.valueChangedListener.valueChanged(
this.getValue(), unit > 0 ? ActionEnum.INCREMENT : ActionEnum.DECREMENT);
}
}
}

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2021 by Navi Technologies Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2021-2022 by Navi Technologies Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2021-2022 by Navi Technologies Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2021-2022 by Navi Technologies Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2021-2022 by Navi Technologies Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2021-2022 by Navi Technologies Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2021-2022 by Navi Technologies Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2021-2023 by Navi Technologies Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2021-2022 by Navi Technologies Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2021-2022 by Navi Technologies Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2021-2022 by Navi Technologies Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2021-2022 by Navi Technologies Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2021-2022 by Navi Technologies Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2021-2022 by Navi Technologies Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2021 by Navi Technologies Limited
* * Copyright © 2021-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/

View File

@@ -10,7 +10,7 @@ spotless {
}
kotlin {
target '**/*.kt'
target '**/navi-base/**/*.kt', '**/navi-design/**/*.kt', '**/pulse/**/*.kt', '**/navi-analytics/**/*.kt'
licenseHeaderFile rootProject.file('spotless.license')
trimTrailingWhitespace()