diff --git a/navi-alfred/build.gradle b/navi-alfred/build.gradle index 31cb077..b09ae2f 100644 --- a/navi-alfred/build.gradle +++ b/navi-alfred/build.gradle @@ -6,7 +6,7 @@ plugins { id 'kotlin-parcelize' } -def VERSION_NAME = "1.0.16" +def VERSION_NAME = "1.0.17" android { namespace 'com.navi.alfred' diff --git a/navi-alfred/src/main/java/com/navi/alfred/repository/ComposeMaskingRepo.kt b/navi-alfred/src/main/java/com/navi/alfred/repository/ComposeMaskingRepo.kt index 20c937a..af68cfe 100644 --- a/navi-alfred/src/main/java/com/navi/alfred/repository/ComposeMaskingRepo.kt +++ b/navi-alfred/src/main/java/com/navi/alfred/repository/ComposeMaskingRepo.kt @@ -6,4 +6,5 @@ import com.navi.alfred.model.MaskingBounds interface ComposeMaskingRepo { fun maskSensitiveComposable(id: String, coordinates: MaskingBounds?, currentView: View?) fun removeSensitiveComposable(id: String) + fun blurSensitiveScreen(isVisible: Boolean) } \ No newline at end of file diff --git a/navi-alfred/src/main/java/com/navi/alfred/repository/ComposeMaskingRepoImpl.kt b/navi-alfred/src/main/java/com/navi/alfred/repository/ComposeMaskingRepoImpl.kt index dd50e0a..0ffa5ef 100644 --- a/navi-alfred/src/main/java/com/navi/alfred/repository/ComposeMaskingRepoImpl.kt +++ b/navi-alfred/src/main/java/com/navi/alfred/repository/ComposeMaskingRepoImpl.kt @@ -1,29 +1,41 @@ package com.navi.alfred.repository import android.view.View +import com.navi.alfred.AlfredManager import com.navi.alfred.model.MaskingBounds import java.lang.ref.WeakReference class ComposeMaskingRepoImpl : ComposeMaskingRepo { private val sensitiveCoordinates = mutableMapOf() private var rootView = WeakReference(null) + private var blurSensitiveScreen = false override fun maskSensitiveComposable( id: String, coordinates: MaskingBounds?, rootView: View? ) { - if (rootView != this.rootView.get()) { - removeAllSensitiveComposables() - } - if (coordinates != null) { - this.rootView = WeakReference(rootView) - sensitiveCoordinates[id] = coordinates + if (AlfredManager.isAlfredRecordingEnabled()) { + if (rootView != this.rootView.get()) { + removeAllSensitiveComposables() + } + if (coordinates != null) { + this.rootView = WeakReference(rootView) + sensitiveCoordinates[id] = coordinates + } } } override fun removeSensitiveComposable(id: String) { - if (sensitiveCoordinates.containsKey(id)) { - sensitiveCoordinates.remove(id) + if (AlfredManager.isAlfredRecordingEnabled()) { + if (sensitiveCoordinates.containsKey(id)) { + sensitiveCoordinates.remove(id) + } + } + } + + override fun blurSensitiveScreen(isVisible: Boolean) { + if (AlfredManager.isAlfredRecordingEnabled()) { + blurSensitiveScreen = isVisible } } @@ -38,4 +50,8 @@ class ComposeMaskingRepoImpl : ComposeMaskingRepo { internal fun getRootViewOfComposeScreen(): View? { return rootView.get() } + + internal fun getBlurSensitiveScreenStatus(): Boolean { + return blurSensitiveScreen + } } \ No newline at end of file diff --git a/navi-alfred/src/main/java/com/navi/alfred/utils/ScreenShotUtils.kt b/navi-alfred/src/main/java/com/navi/alfred/utils/ScreenShotUtils.kt index 900dcc6..b0a291d 100644 --- a/navi-alfred/src/main/java/com/navi/alfred/utils/ScreenShotUtils.kt +++ b/navi-alfred/src/main/java/com/navi/alfred/utils/ScreenShotUtils.kt @@ -200,14 +200,16 @@ internal suspend fun captureScreen( if (isMaskingEnabled(screenName) || (v.tag == AlfredConstants.SENSITIVE_VIEW_TAG) || (v.tag == AlfredConstants.SENSITIVE_COMPOSE_VIEW_TAG)) { try { if (currentScreen.isComposeScreen == true) { - if (sensitiveCoordinates.isNotEmpty() && rootView != null) { - withContext(Dispatchers.Main) { - captureComposeViewWithMasking(canvas, sensitiveCoordinates, rootView) - } - } else { + if (AlfredManager.sensitiveComposeRepository.getBlurSensitiveScreenStatus()) { withContext(Dispatchers.Main) { blurScreen(canvas, v) } + } else { + if (rootView != null) { + withContext(Dispatchers.Main) { + captureComposeViewWithMasking(canvas, sensitiveCoordinates, rootView) + } + } } } else { val maskedViewsList = findViewWithTagRecursive( @@ -311,12 +313,14 @@ internal fun captureComposeViewWithMasking( rootView: View ) { rootView.draw(canvas) - val paint = Paint() - paint.color = Color.BLACK + if (sensitiveCoordinates.isNotEmpty()) { + val paint = Paint() + paint.color = Color.BLACK - sensitiveCoordinates.forEach { bounds -> - if (bounds.bottom > 0 && bounds.top < rootView.height && bounds.height > 0 && bounds.width > 0) { - canvas.drawRect(bounds.left, bounds.top, bounds.right, bounds.bottom, paint) + sensitiveCoordinates.forEach { bounds -> + if (bounds.bottom > 0 && bounds.top < rootView.height && bounds.height > 0 && bounds.width > 0) { + canvas.drawRect(bounds.left, bounds.top, bounds.right, bounds.bottom, paint) + } } } } @@ -328,7 +332,7 @@ internal fun blurScreen( rootView.draw(canvas) val paint = Paint() paint.color = Color.GRAY - paint.alpha = 90 + paint.alpha = 240 canvas.drawRect( rootView.left.toFloat(), rootView.top.toFloat(),