Skip to content

Commit

Permalink
Send additional analytics from FM
Browse files Browse the repository at this point in the history
  • Loading branch information
max-kammerer committed Apr 21, 2024
1 parent 0b28f32 commit 31ecdf3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ class FireBaseAnalytics : Analytics() {
}
}

override fun permissionEvent(screen: String, state: Boolean) {
logEvent("permissionResult") {
param("screen", screen)
param("state", state.toString())
}
}

private inline fun logEvent(
event: String,
crossinline block: ParametersBuilder.() -> Unit = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ open class Analytics {

}

open fun permissionEvent(screen: String, state: Boolean) {

}

companion object {

fun initialize(contentResolver: ContentResolver, analytics: Analytics): Analytics {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,16 +222,6 @@ abstract class OrionFileManagerActivityBase @JvmOverloads constructor(
showPermissionRequestDialog()
}

override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
if (Permissions.ASK_READ_PERMISSION_FOR_FILE_MANAGER == requestCode) {
log("Permission callback: " + permissions.joinToString() + " " + grantResults.joinToString())
if (checkPermissionGranted(grantResults, permissions, Manifest.permission.READ_EXTERNAL_STORAGE)) {
refreshFolder()
}
}
}

private fun refreshFolder() {
val list = findViewById<ListView>(R.id.listView)
val adapter = list.adapter
Expand All @@ -242,14 +232,28 @@ abstract class OrionFileManagerActivityBase @JvmOverloads constructor(
}
}

override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
if (Permissions.ASK_READ_PERMISSION_FOR_FILE_MANAGER == requestCode) {
log("Permission callback: " + permissions.joinToString() + " " + grantResults.joinToString())
actualizePermissions()
}
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
log("FileManager: On activity result requestCode=$requestCode resultCode=$resultCode")
if (requestCode == Permissions.ASK_READ_PERMISSION_FOR_FILE_MANAGER) {
if (hasReadStoragePermission(this)) {
refreshFolder()
}
actualizePermissions()
}
}

private fun actualizePermissions() {
val hasReadStoragePermission = hasReadStoragePermission(this)
if (hasReadStoragePermission) {
refreshFolder()
}
analytics.permissionEvent(this.javaClass.name, hasReadStoragePermission)
}

private fun showPermissionRequestDialog() {
Expand Down

0 comments on commit 31ecdf3

Please sign in to comment.