Skip to content

Commit

Permalink
[fix]: updates to settings with logging paused
Browse files Browse the repository at this point in the history
  • Loading branch information
F0x1d committed Nov 4, 2023
1 parent 1b8bf7f commit 8997f43
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.f0x1d.logfox.ui.fragment
package com.f0x1d.logfox.ui.fragment.logs

import android.os.Bundle
import android.view.LayoutInflater
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.f0x1d.logfox.ui.fragment
package com.f0x1d.logfox.ui.fragment.logs

import android.content.SharedPreferences
import android.os.Bundle
Expand Down Expand Up @@ -146,7 +146,7 @@ class LogsFragment: BaseViewModelFragment<LogsViewModel, FragmentLogsBinding>(),

viewModel.logs.observe(viewLifecycleOwner) {
adapter.submitList(null)
adapter.submitList(it ?: return@observe) {
adapter.submitList(it) {
scrollLogToBottom()
}
}
Expand Down Expand Up @@ -222,8 +222,15 @@ class LogsFragment: BaseViewModelFragment<LogsViewModel, FragmentLogsBinding>(),

override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
viewModel.appPreferences.apply {
if (key == "pref_logs_text_size") adapter.textSize = logsTextSize.toFloat()
else if (key == "pref_logs_expanded") adapter.logsExpanded = logsExpanded
when (key) {
"pref_logs_text_size" -> adapter.textSize = logsTextSize.toFloat()
"pref_logs_expanded" -> adapter.logsExpanded = logsExpanded

"pref_date_format", "pref_time_format" -> adapter.notifyItemRangeChanged(
0,
adapter.itemCount
)
}

if (key?.startsWith("pref_show_log") == true) adapter.logsFormat = showLogValues
}
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/com/f0x1d/logfox/viewmodel/LogsViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,13 @@ class LogsViewModel @Inject constructor(
LogsData(logs, filters, query, paused)
}.scan(null as LogsData?) { accumulator, data ->
when {
accumulator == null -> data.copy(passing = false)

!data.paused -> data

data.query != accumulator?.query -> data.copy(logs = accumulator?.logs ?: emptyList())
data.filters != accumulator?.filters -> data.copy(logs = accumulator?.logs ?: emptyList())
data.query != accumulator.query || data.filters != accumulator.filters -> data.copy(
logs = accumulator.logs
)

else -> data.copy(logs = accumulator.logs, passing = false)
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/navigation/logs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<fragment
android:id="@+id/logsFragment"
android:name="com.f0x1d.logfox.ui.fragment.LogsFragment"
android:name="com.f0x1d.logfox.ui.fragment.logs.LogsFragment"
android:label="LogsFragment" >
<argument
android:name="file_uri"
Expand Down Expand Up @@ -34,7 +34,7 @@
</fragment>
<fragment
android:id="@+id/logsExtendedCopyFragment"
android:name="com.f0x1d.logfox.ui.fragment.LogsExtendedCopyFragment"
android:name="com.f0x1d.logfox.ui.fragment.logs.LogsExtendedCopyFragment"
android:label="ExtendedCopyFragment" >
<argument
android:name="content"
Expand Down

0 comments on commit 8997f43

Please sign in to comment.