diff --git a/app/src/main/java/com/infomaniak/drive/ui/fileList/FileListFragment.kt b/app/src/main/java/com/infomaniak/drive/ui/fileList/FileListFragment.kt index 62c6bf4827..19c6d6e74b 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/fileList/FileListFragment.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/fileList/FileListFragment.kt @@ -70,7 +70,7 @@ import com.infomaniak.lib.core.utils.showProgress import kotlinx.android.synthetic.main.activity_main.* import kotlinx.coroutines.* -open class FileListFragment : MultiSelectFragment(), SwipeRefreshLayout.OnRefreshListener { +open class FileListFragment : MultiSelectFragment(MATOMO_CATEGORY), SwipeRefreshLayout.OnRefreshListener { private lateinit var binding: FragmentFileListBinding @@ -113,6 +113,8 @@ open class FileListFragment : MultiSelectFragment(), SwipeRefreshLayout.OnRefres // Beware, if this value is modified, the Categories' layouts should be modified accordingly. const val MAX_DISPLAYED_CATEGORIES = 3 + + const val MATOMO_CATEGORY = "fileListFileAction" } override fun onCreate(savedInstanceState: Bundle?) { diff --git a/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/FileListMultiSelectActionsBottomSheetDialog.kt b/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/FileListMultiSelectActionsBottomSheetDialog.kt index 3f1b636fc4..35aef288e5 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/FileListMultiSelectActionsBottomSheetDialog.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/FileListMultiSelectActionsBottomSheetDialog.kt @@ -22,9 +22,10 @@ import androidx.core.view.isVisible import androidx.fragment.app.activityViewModels import com.infomaniak.drive.data.cache.FileController import com.infomaniak.drive.ui.MainViewModel +import com.infomaniak.drive.ui.fileList.FileListFragment import kotlinx.android.synthetic.main.fragment_bottom_sheet_multi_select_actions.* -class FileListMultiSelectActionsBottomSheetDialog : MultiSelectActionsBottomSheetDialog() { +class FileListMultiSelectActionsBottomSheetDialog : MultiSelectActionsBottomSheetDialog(FileListFragment.MATOMO_CATEGORY) { private val mainViewModel: MainViewModel by activityViewModels() diff --git a/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/MultiSelectActionsBottomSheetDialog.kt b/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/MultiSelectActionsBottomSheetDialog.kt index 7774d6bbdd..d320bf75bb 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/MultiSelectActionsBottomSheetDialog.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/MultiSelectActionsBottomSheetDialog.kt @@ -31,13 +31,12 @@ import com.infomaniak.drive.data.api.ApiRepository import com.infomaniak.drive.data.api.ApiRoutes import com.infomaniak.drive.data.models.BulkOperationType import com.infomaniak.drive.utils.* -import com.infomaniak.drive.utils.MatomoUtils.trackBulkActionEvent import com.infomaniak.drive.utils.MatomoUtils.trackEvent import kotlinx.android.synthetic.main.fragment_bottom_sheet_multi_select_actions.* import kotlinx.android.synthetic.main.view_file_info_actions.view.* import kotlinx.coroutines.Dispatchers -abstract class MultiSelectActionsBottomSheetDialog : BottomSheetDialogFragment() { +abstract class MultiSelectActionsBottomSheetDialog(private val matomoCategory: String) : BottomSheetDialogFragment() { val navigationArgs: MultiSelectActionsBottomSheetDialogArgs by navArgs() @@ -94,13 +93,15 @@ abstract class MultiSelectActionsBottomSheetDialog : BottomSheetDialogFragment() if (authorized) downloadFileArchive() } } + downloadFile.apply { setOnClickListener { if (drivePermissions.checkWriteStoragePermission()) { - context?.applicationContext?.trackEvent("FileAction", TrackerAction.CLICK, "bulkDownload") + context?.applicationContext?.trackEvent(matomoCategory, TrackerAction.CLICK, "bulkDownload") downloadFileArchive() } } + isVisible = navigationArgs.fileIds.isNotEmpty() } } @@ -143,7 +144,6 @@ abstract class MultiSelectActionsBottomSheetDialog : BottomSheetDialogFragment() if (finalType == null) { closeMultiSelect() } else { - context?.applicationContext?.trackBulkActionEvent(finalType, navigationArgs.fileIds.size) when (finalType) { BulkOperationType.COPY -> duplicateFiles() BulkOperationType.COLOR_FOLDER -> colorFolders() diff --git a/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/MultiSelectFragment.kt b/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/MultiSelectFragment.kt index c550d0766d..06e079f062 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/MultiSelectFragment.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/MultiSelectFragment.kt @@ -60,7 +60,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking -abstract class MultiSelectFragment : Fragment(), MultiSelectResult { +abstract class MultiSelectFragment(private val matomoCategory: String) : Fragment(), MultiSelectResult { protected val mainViewModel: MainViewModel by activityViewModels() protected val multiSelectManager = MultiSelectManager() @@ -169,12 +169,12 @@ abstract class MultiSelectFragment : Fragment(), MultiSelectResult { val selectedFiles = multiSelectManager.getValidSelectedItems(type) val fileCount = allSelectedFileCount ?: selectedFiles.size + applicationContext?.trackBulkActionEvent(matomoCategory, type, fileCount) + val sendActions: (dialog: Dialog?) -> Unit = sendActions( type, areAllFromTheSameFolder, fileCount, selectedFiles, destinationFolder, color ) - applicationContext?.trackBulkActionEvent(type, fileCount) - if (type == BulkOperationType.TRASH) { Utils.createConfirmation( context = this, diff --git a/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/PicturesMultiSelectActionsBottomSheetDialog.kt b/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/PicturesMultiSelectActionsBottomSheetDialog.kt index 248b4565bf..b193d1056f 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/PicturesMultiSelectActionsBottomSheetDialog.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/PicturesMultiSelectActionsBottomSheetDialog.kt @@ -18,9 +18,10 @@ package com.infomaniak.drive.ui.fileList.multiSelect import androidx.core.view.isGone +import com.infomaniak.drive.ui.menu.PicturesFragment import kotlinx.android.synthetic.main.fragment_bottom_sheet_multi_select_actions.* -class PicturesMultiSelectActionsBottomSheetDialog : MultiSelectActionsBottomSheetDialog() { +class PicturesMultiSelectActionsBottomSheetDialog : MultiSelectActionsBottomSheetDialog(PicturesFragment.MATOMO_CATEGORY) { override fun configureColoredFolder(areIndividualActionsVisible: Boolean) { coloredFolder.isGone = true diff --git a/app/src/main/java/com/infomaniak/drive/ui/menu/PicturesFragment.kt b/app/src/main/java/com/infomaniak/drive/ui/menu/PicturesFragment.kt index bfc8dbb47e..18fe284912 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/menu/PicturesFragment.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/menu/PicturesFragment.kt @@ -51,7 +51,7 @@ import kotlinx.coroutines.runBlocking import kotlin.math.max import kotlin.math.min -class PicturesFragment(private val onFinish: (() -> Unit)? = null) : MultiSelectFragment() { +class PicturesFragment(private val onFinish: (() -> Unit)? = null) : MultiSelectFragment(MATOMO_CATEGORY) { private val picturesViewModel: PicturesViewModel by viewModels() private lateinit var picturesAdapter: PicturesAdapter @@ -269,7 +269,8 @@ class PicturesFragment(private val onFinish: (() -> Unit)? = null) : MultiSelect picturesAdapter.updateFileProgressByFileId(fileId, progress, onComplete) } - private companion object { - const val NUMBER_ITEMS_LOADER = 12 + companion object { + private const val NUMBER_ITEMS_LOADER = 12 + const val MATOMO_CATEGORY = "picturesFileAction" } } diff --git a/app/src/main/java/com/infomaniak/drive/utils/MatomoUtils.kt b/app/src/main/java/com/infomaniak/drive/utils/MatomoUtils.kt index a50fef8af5..f3b4bbf015 100644 --- a/app/src/main/java/com/infomaniak/drive/utils/MatomoUtils.kt +++ b/app/src/main/java/com/infomaniak/drive/utils/MatomoUtils.kt @@ -69,9 +69,9 @@ object MatomoUtils { context?.applicationContext?.trackEvent(category, action, trackerName, trackerValue) } - fun Context.trackBulkActionEvent(action: BulkOperationType, modifiedFileNumber: Int) { - val trackerName = "bulk" + if (modifiedFileNumber == 1) "Single" else "" + action.toString() - trackEvent("FileAction", TrackerAction.CLICK, trackerName, modifiedFileNumber.toFloat()) + fun Context.trackBulkActionEvent(category: String, action: BulkOperationType, modifiedFileNumber: Int) { + val trackerName = "bulk" + (if (modifiedFileNumber == 1) "Single" else "") + action.toString() + trackEvent(category, TrackerAction.CLICK, trackerName, modifiedFileNumber.toFloat()) } fun Context.trackEventWithBooleanValue(category: String, trackerName: String, trackerValue: Boolean?) { @@ -99,7 +99,7 @@ object MatomoUtils { } } -fun Boolean.toFloat() = if (this) 1f else 0f +fun Boolean.toFloat() = if (this) 1.0f else 0.0f enum class TrackerAction { CLICK, INPUT;