Skip to content

Commit

Permalink
Remove share persisted log if file logger is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
jdelga committed Dec 12, 2024
1 parent 49457ba commit a9cb4db
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ internal fun getLogs(): LiveData<List<LogEntry>> =
internal fun getCategories(): List<LogCategory> =
appLoggerBLInstance?.categories ?: emptyList()

internal fun arePersistedLogsEnabled() : Boolean =
appLoggerBLInstance?.arePersistedLogsEnabled() ?: false

internal fun getPersistedLogs(callback: TaskCallback<Uri>) {
appLoggerBLInstance?.getPersistedLogs(callback)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ internal open class AppLoggerBL(
open fun getLogs(): LiveData<List<LogEntry>> =
logsData

open fun arePersistedLogsEnabled(): Boolean =
fileLogger != null

open fun getPersistedLogs(callback: TaskCallback<Uri>) {
fileLogger?.getReport(callback)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import com.google.android.material.chip.Chip
import com.google.android.material.chip.ChipGroup
import com.telefonica.androidlogger.R
import com.telefonica.androidlogger.domain.LogCategory
import com.telefonica.androidlogger.domain.arePersistedLogsEnabled
import com.telefonica.androidlogger.io.executor.TaskCallback
import com.telefonica.androidlogger.ui.adapter.LogListAdapter
import com.telefonica.androidlogger.ui.viewmodel.AppLoggerViewModel
Expand Down Expand Up @@ -79,7 +80,9 @@ class AppLoggerActivity : AppCompatActivity() {

override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_app_logger, menu)

if (!arePersistedLogsEnabled()) {
menu.removeItem(R.id.action_share_all)
}
searchView = (menu.findItem(R.id.action_search).actionView as SearchView).apply {
val searchManager = getSystemService(Context.SEARCH_SERVICE) as SearchManager
setSearchableInfo(searchManager.getSearchableInfo(componentName))
Expand Down

0 comments on commit a9cb4db

Please sign in to comment.