Show/hide banner only for instant subscriptions
This commit is contained in:
parent
30f7059172
commit
e402bbf381
1 changed files with 10 additions and 7 deletions
|
@ -113,6 +113,9 @@ class MainActivity : AppCompatActivity(), ActionMode.Callback, AddFragment.Subsc
|
||||||
Log.addScrubTerm(shortUrl(s.baseUrl), Log.TermType.Domain)
|
Log.addScrubTerm(shortUrl(s.baseUrl), Log.TermType.Domain)
|
||||||
Log.addScrubTerm(s.topic)
|
Log.addScrubTerm(s.topic)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update battery banner
|
||||||
|
showHideBatteryBanner(subscriptions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,18 +157,18 @@ class MainActivity : AppCompatActivity(), ActionMode.Callback, AddFragment.Subsc
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
|
||||||
// Menu and main list
|
|
||||||
showHideNotificationMenuItems()
|
showHideNotificationMenuItems()
|
||||||
redrawList()
|
redrawList()
|
||||||
|
}
|
||||||
|
|
||||||
// Battery banner
|
private fun showHideBatteryBanner(subscriptions: List<Subscription>) {
|
||||||
|
val hasInstantSubscriptions = subscriptions.count { it.instant } > 0
|
||||||
val batteryRemindTimeReached = repository.getBatteryOptimizationsRemindTime() < System.currentTimeMillis()
|
val batteryRemindTimeReached = repository.getBatteryOptimizationsRemindTime() < System.currentTimeMillis()
|
||||||
val ignoringBatteryOptimizations = isIgnoringBatteryOptimizations(this)
|
val ignoringOptimizations = isIgnoringBatteryOptimizations(this@MainActivity)
|
||||||
val showBatteryBanner = batteryRemindTimeReached && !ignoringBatteryOptimizations
|
val showBanner = hasInstantSubscriptions && batteryRemindTimeReached && !ignoringOptimizations
|
||||||
val batteryBanner = findViewById<View>(R.id.main_banner_battery)
|
val batteryBanner = findViewById<View>(R.id.main_banner_battery)
|
||||||
batteryBanner.visibility = if (showBatteryBanner) View.VISIBLE else View.GONE
|
batteryBanner.visibility = if (showBanner) View.VISIBLE else View.GONE
|
||||||
Log.d(TAG, "Battery: ignoring optimizations = $ignoringBatteryOptimizations (we want this to be true); remind time reached = $batteryRemindTimeReached")
|
Log.d(TAG, "Battery: ignoring optimizations = $ignoringOptimizations (we want this to be true); instant subscriptions = $hasInstantSubscriptions; remind time reached = $batteryRemindTimeReached; banner = $showBanner")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun startPeriodicPollWorker() {
|
private fun startPeriodicPollWorker() {
|
||||||
|
|
Loading…
Reference in a new issue