update text colors on resume if they changed

This commit is contained in:
tibbi 2018-03-13 19:26:16 +01:00
parent 8d9e7181a0
commit 579a4057c6
4 changed files with 49 additions and 1 deletions

View File

@ -151,7 +151,7 @@ class MainActivity : SimpleActivity() {
}
}
private fun getInactiveTabIndexes(activeIndex: Int) = arrayListOf(0, 1, 2).filter { it != activeIndex }
private fun getInactiveTabIndexes(activeIndex: Int) = arrayListOf(0, 1, 2, 3).filter { it != activeIndex }
private fun launchSettings() {
startActivity(Intent(applicationContext, SettingsActivity::class.java))

View File

@ -20,9 +20,13 @@ import java.util.*
class AlarmFragment : Fragment(), ToggleAlarmInterface {
private var alarms = ArrayList<Alarm>()
private var storedTextColor = 0
lateinit var view: ViewGroup
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
storeStateVariables()
view = inflater.inflate(R.layout.fragment_alarm, container, false) as ViewGroup
return view
}
@ -30,6 +34,20 @@ class AlarmFragment : Fragment(), ToggleAlarmInterface {
override fun onResume() {
super.onResume()
setupViews()
val configTextColor = context!!.config.textColor
if (storedTextColor != configTextColor) {
(view.alarms_list.adapter as AlarmsAdapter).updateTextColor(configTextColor)
}
}
override fun onPause() {
super.onPause()
storeStateVariables()
}
private fun storeStateVariables() {
storedTextColor = context!!.config.textColor
}
private fun setupViews() {

View File

@ -29,9 +29,12 @@ class ClockFragment : Fragment() {
private var calendar = Calendar.getInstance()
private val updateHandler = Handler()
private var storedTextColor = 0
lateinit var view: ViewGroup
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
storeStateVariables()
view = inflater.inflate(R.layout.fragment_clock, container, false) as ViewGroup
return view
}
@ -40,11 +43,21 @@ class ClockFragment : Fragment() {
super.onResume()
displayOtherTimeZones = context!!.config.displayOtherTimeZones
setupDateTime()
val configTextColor = context!!.config.textColor
if (storedTextColor != configTextColor) {
(view.time_zones_list.adapter as? TimeZonesAdapter)?.updateTextColor(configTextColor)
}
}
override fun onPause() {
super.onPause()
updateHandler.removeCallbacksAndMessages(null)
storeStateVariables()
}
private fun storeStateVariables() {
storedTextColor = context!!.config.textColor
}
private fun setupDateTime() {

View File

@ -36,10 +36,13 @@ class StopwatchFragment : Fragment() {
private var sorting = SORT_BY_LAP or SORT_DESCENDING
private var laps = ArrayList<Lap>()
private var storedTextColor = 0
lateinit var stopwatchAdapter: StopwatchAdapter
lateinit var view: ViewGroup
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
storeStateVariables()
view = (inflater.inflate(R.layout.fragment_stopwatch, container, false) as ViewGroup).apply {
stopwatch_time.setOnClickListener {
togglePlayPause()
@ -96,6 +99,16 @@ class StopwatchFragment : Fragment() {
override fun onResume() {
super.onResume()
setupViews()
val configTextColor = context!!.config.textColor
if (storedTextColor != configTextColor) {
stopwatchAdapter.updateTextColor(configTextColor)
}
}
override fun onPause() {
super.onPause()
storeStateVariables()
}
override fun onDestroy() {
@ -107,6 +120,10 @@ class StopwatchFragment : Fragment() {
updateHandler.removeCallbacks(updateRunnable)
}
private fun storeStateVariables() {
storedTextColor = context!!.config.textColor
}
private fun setupViews() {
val adjustedPrimaryColor = context!!.getAdjustedPrimaryColor()
view.apply {