Skip to content

Commit

Permalink
Fix Battery Optimization banner not disappearing
Browse files Browse the repository at this point in the history
  • Loading branch information
Iamlooker committed Aug 1, 2024
1 parent 5f82e22 commit 90c3f2d
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import com.looker.droidify.databinding.SettingsPageBinding
import com.looker.droidify.databinding.SwitchTypeBinding
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import java.util.Locale
import kotlin.time.Duration
Expand Down Expand Up @@ -313,11 +314,10 @@ class SettingsFragment : Fragment() {
}
}
launch {
viewModel.settingsFlow.collect(::updateSettings)
}
launch {
viewModel.backgroundTask.collect {
binding.allowBackgroundWork.root.isVisible = !it
viewModel.settingsFlow.collect { setting ->
updateSettings(setting)
binding.allowBackgroundWork.root.isVisible = !viewModel.backgroundTask.first()
&& setting.autoSync != AutoSync.NEVER
}
}
}
Expand Down Expand Up @@ -392,7 +392,6 @@ class SettingsFragment : Fragment() {

private fun updateSettings(settings: Settings) {
with(binding) {
allowBackgroundWork.root.isVisible = settings.autoSync != AutoSync.NEVER
val allowProxies = settings.proxy.type != ProxyType.DIRECT
proxyHost.root.isVisible = allowProxies
proxyPort.root.isVisible = allowProxies
Expand Down

0 comments on commit 90c3f2d

Please sign in to comment.