using low privacy log from the vector module for code within vector, instead of the sdk flag

This commit is contained in:
Adam Brown 2022-07-29 13:34:48 +01:00
parent 9b1def3c1d
commit 3c1e183ed6
2 changed files with 13 additions and 10 deletions

View file

@ -23,9 +23,9 @@ import android.os.Bundle
import androidx.activity.result.ActivityResultLauncher
import im.vector.app.core.dialogs.PhotoOrVideoDialog
import im.vector.app.core.platform.Restorable
import im.vector.app.core.resources.BuildMeta
import im.vector.app.features.settings.VectorPreferences
import im.vector.lib.multipicker.MultiPicker
import org.matrix.android.sdk.BuildConfig
import org.matrix.android.sdk.api.session.content.ContentAttachmentData
import timber.log.Timber
@ -35,15 +35,14 @@ private const val PENDING_TYPE_KEY = "PENDING_TYPE_KEY"
/**
* This class helps to handle attachments by providing simple methods.
*/
class AttachmentsHelper(val context: Context, val callback: Callback) : Restorable {
class AttachmentsHelper(
val context: Context,
val callback: Callback,
private val buildMeta: BuildMeta,
) : Restorable {
interface Callback {
fun onContactAttachmentReady(contactAttachment: ContactAttachment) {
if (BuildConfig.LOG_PRIVATE_DATA) {
Timber.v("On contact attachment ready: $contactAttachment")
}
}
fun onContactAttachmentReady(contactAttachment: ContactAttachment)
fun onContentAttachmentsReady(attachments: List<ContentAttachmentData>)
}
@ -144,6 +143,9 @@ class AttachmentsHelper(val context: Context, val callback: Callback) : Restorab
.firstOrNull()
?.toContactAttachment()
?.let {
if (buildMeta.lowPrivacyLoggingEnabled) {
Timber.v("On contact attachment ready: $it")
}
callback.onContactAttachmentReady(it)
}
}

View file

@ -91,6 +91,7 @@ import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.core.platform.VectorMenuProvider
import im.vector.app.core.platform.lifecycleAwareLazy
import im.vector.app.core.platform.showOptimizedSnackbar
import im.vector.app.core.resources.BuildMeta
import im.vector.app.core.resources.ColorProvider
import im.vector.app.core.resources.UserPreferencesProvider
import im.vector.app.core.time.Clock
@ -277,6 +278,7 @@ class TimelineFragment @Inject constructor(
private val shareIntentHandler: ShareIntentHandler,
private val clock: Clock,
private val vectorFeatures: VectorFeatures,
private val buildMeta: BuildMeta,
) :
VectorBaseFragment<FragmentTimelineBinding>(),
TimelineEventController.Callback,
@ -373,7 +375,7 @@ class TimelineFragment @Inject constructor(
sharedActionViewModel = activityViewModelProvider.get(MessageSharedActionViewModel::class.java)
sharedActivityActionViewModel = activityViewModelProvider.get(RoomDetailSharedActionViewModel::class.java)
knownCallsViewModel = activityViewModelProvider.get(SharedKnownCallsViewModel::class.java)
attachmentsHelper = AttachmentsHelper(requireContext(), this).register()
attachmentsHelper = AttachmentsHelper(requireContext(), this, buildMeta).register()
callActionsHandler = StartCallActionsHandler(
roomId = timelineArgs.roomId,
fragment = this,
@ -2647,7 +2649,6 @@ class TimelineFragment @Inject constructor(
}
override fun onContactAttachmentReady(contactAttachment: ContactAttachment) {
super.onContactAttachmentReady(contactAttachment)
val formattedContact = contactAttachment.toHumanReadable()
messageComposerViewModel.handle(MessageComposerAction.SendMessage(formattedContact, false))
}