NTP-71531 | Increased timing for dark knight & added footer logo in pdf (#16494)
This commit is contained in:
@@ -14,6 +14,8 @@ import androidx.work.NetworkType
|
||||
import androidx.work.PeriodicWorkRequestBuilder
|
||||
import androidx.work.WorkManager
|
||||
import com.navi.base.utils.TrustedTimeAccessor
|
||||
import com.navi.pay.utils.DARK_KNIGHT_TRIGGER_MAX_HOUR
|
||||
import com.navi.pay.utils.DARK_KNIGHT_TRIGGER_MIN_HOUR
|
||||
import com.navi.pay.utils.DARK_KNIGHT_WORKER
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import java.util.concurrent.TimeUnit
|
||||
@@ -30,9 +32,6 @@ class DarkKnightSchedulerImpl
|
||||
@Inject
|
||||
constructor(@ApplicationContext private val context: Context) : DarkKnightScheduler {
|
||||
|
||||
private val EARLIEST_HOUR = 1 // 1AM
|
||||
private val LATEST_HOUR = 5 // 5AM
|
||||
|
||||
override suspend fun schedulePeriodicSync() {
|
||||
|
||||
val constraints =
|
||||
@@ -67,8 +66,10 @@ constructor(@ApplicationContext private val context: Context) : DarkKnightSchedu
|
||||
|
||||
val startDateTimeOfFollowingDay = currentDateTime.plusDays(1).withTimeAtStartOfDay()
|
||||
|
||||
val startIntervalDateTime = startDateTimeOfFollowingDay.plusHours(EARLIEST_HOUR)
|
||||
val endIntervalDateTime = startDateTimeOfFollowingDay.plusHours(LATEST_HOUR)
|
||||
val startIntervalDateTime =
|
||||
startDateTimeOfFollowingDay.plusHours(DARK_KNIGHT_TRIGGER_MIN_HOUR)
|
||||
val endIntervalDateTime =
|
||||
startDateTimeOfFollowingDay.plusHours(DARK_KNIGHT_TRIGGER_MAX_HOUR)
|
||||
|
||||
val durationInMinutes = Duration(startIntervalDateTime, endIntervalDateTime).standardMinutes
|
||||
val randomOffsetInMinutes =
|
||||
|
||||
@@ -31,6 +31,8 @@ import com.navi.pay.npcicl.NpciKeysResponse
|
||||
import com.navi.pay.tstore.list.model.view.OrderStatusOfView
|
||||
import com.navi.pay.tstore.list.repository.OrderRepository
|
||||
import com.navi.pay.tstore.utils.error.OrderErrorMappingManager
|
||||
import com.navi.pay.utils.DARK_KNIGHT_TRIGGER_MAX_HOUR
|
||||
import com.navi.pay.utils.DARK_KNIGHT_TRIGGER_MIN_HOUR
|
||||
import com.navi.pay.utils.DARK_KNIGHT_WORKER
|
||||
import com.navi.pay.utils.NAVI_PAY_LITMUS_EXPERIMENTS
|
||||
import com.navi.payments.shared.feature.arc.usecase.ArcNudgeSyncUseCase
|
||||
@@ -81,7 +83,9 @@ constructor(
|
||||
}
|
||||
|
||||
val currentHour = DateTime(TrustedTimeAccessor.getCurrentTimeMillis()).hourOfDay
|
||||
val isTriggeredWithinOffHours = currentHour >= 1 && currentHour < 5
|
||||
val isTriggeredWithinOffHours =
|
||||
currentHour >= DARK_KNIGHT_TRIGGER_MIN_HOUR &&
|
||||
currentHour <= DARK_KNIGHT_TRIGGER_MAX_HOUR
|
||||
|
||||
naviPayAnalytics.onDarkKnightTriggered(
|
||||
isTriggeredWithinOffHours = isTriggeredWithinOffHours
|
||||
|
||||
@@ -111,6 +111,29 @@ fun Canvas.drawVerticallyCentredScaledBitmap(
|
||||
)
|
||||
}
|
||||
|
||||
fun Canvas.drawHorizontallyCentredScaledBitmap(
|
||||
drawable: Drawable,
|
||||
y: Int,
|
||||
startX: Int,
|
||||
endX: Int,
|
||||
width: Int,
|
||||
height: Int,
|
||||
scaleFactor: Int,
|
||||
) {
|
||||
|
||||
val availableWidth = endX - startX
|
||||
val x = startX + (availableWidth - width) / 2
|
||||
|
||||
drawScaledBitmap(
|
||||
drawable = drawable,
|
||||
x = x,
|
||||
y = y,
|
||||
width = width,
|
||||
height = height,
|
||||
scaleFactor = scaleFactor,
|
||||
)
|
||||
}
|
||||
|
||||
fun Context.getDrawableFromUrl(urlString: String): Drawable? {
|
||||
return try {
|
||||
val url = URL(urlString)
|
||||
|
||||
@@ -70,7 +70,6 @@ suspend fun getIconDrawableAccountInfoTextPair(
|
||||
orderEntity: OrderEntity,
|
||||
accountsRepository: AccountsRepository,
|
||||
naviPayConfigUseCase: NaviPayConfigUseCase,
|
||||
screenName: String,
|
||||
context: Context,
|
||||
logoCache: LruCache<String, Drawable?>,
|
||||
): Pair<Drawable?, String> {
|
||||
@@ -86,7 +85,6 @@ suspend fun getIconDrawableAccountInfoTextPair(
|
||||
orderEntity = orderEntity,
|
||||
accountsRepository = accountsRepository,
|
||||
naviPayConfigUseCase = naviPayConfigUseCase,
|
||||
screenName = screenName,
|
||||
context = context,
|
||||
logoCache = logoCache,
|
||||
)
|
||||
@@ -284,7 +282,6 @@ private suspend fun getIconDrawableAccountInfoTextPairForBbps(
|
||||
orderEntity: OrderEntity,
|
||||
accountsRepository: AccountsRepository,
|
||||
naviPayConfigUseCase: NaviPayConfigUseCase,
|
||||
screenName: String,
|
||||
context: Context,
|
||||
logoCache: LruCache<String, Drawable?>,
|
||||
): Pair<Drawable?, String> {
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
package com.navi.pay.tstore.list.util
|
||||
|
||||
import android.R.attr.startX
|
||||
import android.R.attr.startY
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import android.graphics.Canvas
|
||||
@@ -36,6 +38,7 @@ import com.navi.pay.utils.DATE_TIME_FORMAT_DATE_MONTH_NAME_YEAR
|
||||
import com.navi.pay.utils.DATE_TIME_FORMAT_DATE_MONTH_YEAR_WITHOUT_SEPARATOR
|
||||
import com.navi.pay.utils.DATE_TIME_FORMAT_DATE_MONTH_YEAR_WITH_TIME_WITHOUT_SEPARATOR
|
||||
import com.navi.pay.utils.NAVI_PAY_MIME_TYPE_PDF
|
||||
import com.navi.pay.utils.NAVI_PAY_ORDER_HISTORY_STATEMENT_GLOBAL_FOOTER_ICON_URL
|
||||
import com.navi.pay.utils.NAVI_PAY_ORDER_HISTORY_STATEMENT_GLOBAL_HEADER_ICON_URL
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import java.io.File
|
||||
@@ -53,7 +56,6 @@ interface OrderPdfGenerator {
|
||||
contactNumber: String,
|
||||
startDate: DateTime,
|
||||
endDate: DateTime,
|
||||
screenName: String,
|
||||
): Uri?
|
||||
}
|
||||
|
||||
@@ -91,7 +93,6 @@ constructor(
|
||||
contactNumber: String,
|
||||
startDate: DateTime,
|
||||
endDate: DateTime,
|
||||
screenName: String,
|
||||
): Uri? {
|
||||
val pdfDocument = PdfDocument()
|
||||
|
||||
@@ -129,12 +130,7 @@ constructor(
|
||||
|
||||
drawTableHeader(canvas = canvas)
|
||||
|
||||
drawTransactions(
|
||||
canvas = canvas,
|
||||
fetchPageOrders = fetchOrders,
|
||||
pageNum = pageNum,
|
||||
screenName = screenName,
|
||||
)
|
||||
drawTransactions(canvas = canvas, fetchPageOrders = fetchOrders, pageNum = pageNum)
|
||||
|
||||
drawFooter(canvas = canvas)
|
||||
|
||||
@@ -377,7 +373,6 @@ constructor(
|
||||
canvas: Canvas,
|
||||
fetchPageOrders: suspend (offset: Int, limit: Int) -> List<OrderEntity>,
|
||||
pageNum: Int,
|
||||
screenName: String,
|
||||
) {
|
||||
val rowHeight = 84f
|
||||
|
||||
@@ -400,7 +395,6 @@ constructor(
|
||||
startY = currentY,
|
||||
endY = currentY + rowHeight,
|
||||
orderEntity = pageOrders[index],
|
||||
screenName = screenName,
|
||||
)
|
||||
|
||||
currentY += rowHeight
|
||||
@@ -413,7 +407,6 @@ constructor(
|
||||
startY: Float,
|
||||
endY: Float,
|
||||
orderEntity: OrderEntity,
|
||||
screenName: String,
|
||||
) {
|
||||
|
||||
val startPadding = 16
|
||||
@@ -472,7 +465,6 @@ constructor(
|
||||
startY = startY + topPadding,
|
||||
endX = amountX - columnSpacing,
|
||||
orderEntity = orderEntity,
|
||||
screenName = screenName,
|
||||
)
|
||||
|
||||
drawAmountValue(
|
||||
@@ -483,8 +475,8 @@ constructor(
|
||||
)
|
||||
}
|
||||
|
||||
private fun drawFooter(canvas: Canvas) {
|
||||
val footerHeight = 12f
|
||||
private suspend fun drawFooter(canvas: Canvas) {
|
||||
val footerColorHeight = 12f
|
||||
|
||||
val footerPaint =
|
||||
Paint().apply {
|
||||
@@ -494,11 +486,40 @@ constructor(
|
||||
|
||||
canvas.drawRect(
|
||||
0f,
|
||||
totalPageHeight - footerHeight,
|
||||
totalPageHeight - footerColorHeight,
|
||||
totalPageWidth,
|
||||
totalPageHeight,
|
||||
footerPaint,
|
||||
)
|
||||
|
||||
val footerLogoBottomPadding = 12
|
||||
val footerLogoWidth = 80
|
||||
val footerLogoHeight = 20
|
||||
|
||||
val footerDrawable =
|
||||
getLogoDrawable(
|
||||
logoUrl = NAVI_PAY_ORDER_HISTORY_STATEMENT_GLOBAL_FOOTER_ICON_URL,
|
||||
logoCache = logoCache,
|
||||
context = context,
|
||||
defaultDrawableResId = null,
|
||||
)
|
||||
|
||||
footerDrawable?.let {
|
||||
canvas.drawHorizontallyCentredScaledBitmap(
|
||||
drawable = it,
|
||||
y =
|
||||
(totalPageHeight -
|
||||
footerColorHeight -
|
||||
footerLogoBottomPadding -
|
||||
footerLogoHeight)
|
||||
.toInt(),
|
||||
width = footerLogoWidth,
|
||||
height = footerLogoHeight,
|
||||
scaleFactor = drawableScaleFactor,
|
||||
startX = 0,
|
||||
endX = totalPageWidth.toInt(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun drawDateValue(
|
||||
@@ -613,7 +634,6 @@ constructor(
|
||||
startY: Float,
|
||||
endX: Float,
|
||||
orderEntity: OrderEntity,
|
||||
screenName: String,
|
||||
) {
|
||||
val textPaint =
|
||||
Paint().apply {
|
||||
@@ -629,7 +649,6 @@ constructor(
|
||||
orderEntity = orderEntity,
|
||||
accountsRepository = accountsRepository,
|
||||
naviPayConfigUseCase = naviPayConfigUseCase,
|
||||
screenName = screenName,
|
||||
context = context,
|
||||
logoCache = logoCache,
|
||||
)
|
||||
|
||||
@@ -1515,7 +1515,6 @@ constructor(
|
||||
},
|
||||
startDate = startDate.withZone(DateTimeZone.getDefault()),
|
||||
endDate = endDate.withZone(DateTimeZone.getDefault()),
|
||||
screenName = screenName,
|
||||
)
|
||||
|
||||
if (pdfGenerationUri != null) {
|
||||
|
||||
@@ -36,6 +36,8 @@ const val ORDER_HISTORY_LOCAL_SYNC_BATCH_LIMIT = 500
|
||||
const val UPI_LITE_SCREEN_SOURCE_KEY = "UPILiteScreenSource"
|
||||
const val DEFAULT_TOP_UP_AMOUNT = "10"
|
||||
const val NAVI_PAY_MIME_TYPE_PDF = "application/pdf"
|
||||
const val DARK_KNIGHT_TRIGGER_MIN_HOUR = 0
|
||||
const val DARK_KNIGHT_TRIGGER_MAX_HOUR = 6
|
||||
|
||||
const val MAX_VISIBLE_TRANSACTION_ITEMS_IN_SCREEN_HEIGHT = 5
|
||||
const val NAVI_UPI = "Navi UPI"
|
||||
@@ -471,6 +473,8 @@ const val NAVI_PAY_ORDER_HISTORY_DOWNLOAD_IN_PROGRESS_ICON_URL =
|
||||
"https://public-assets.prod.navi-pay.in/svg/statement_download_in_progress.svg"
|
||||
const val NAVI_PAY_ORDER_HISTORY_STATEMENT_GLOBAL_HEADER_ICON_URL =
|
||||
"https://public-assets.prod.navi-sa.in/navi-pay/png/pdf_statement_global_header.png"
|
||||
const val NAVI_PAY_ORDER_HISTORY_STATEMENT_GLOBAL_FOOTER_ICON_URL =
|
||||
"https://public-assets.prod.navi-sa.in/navi-pay/png/pdf_statement_global_footer.png"
|
||||
|
||||
const val RCC_LANDING_PAGE_BOTTOM_BG_URL =
|
||||
"https://public-assets.prod.navi-sa.in/navi-pay/svg/ic_rcc_landing_bottom_bg.svg"
|
||||
|
||||
Reference in New Issue
Block a user