Skip to content

Commit

Permalink
properly update some colors on change
Browse files Browse the repository at this point in the history
  • Loading branch information
tibbi committed May 19, 2021
1 parent b526ae5 commit 2150ad1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ class MainActivity : SimpleActivity() {

override fun onResume() {
super.onResume()
val adjustedPrimaryColor = getAdjustedPrimaryColor()
getAllFragments().forEach {
it?.setupColors(config.textColor, adjustedPrimaryColor)
it?.setupColors(config.textColor, config.primaryColor)
}

if (storedFontSize != config.fontSize) {
Expand All @@ -101,9 +100,10 @@ class MainActivity : SimpleActivity() {
main_tabs_holder.getTabAt(it)?.icon?.applyColorFilter(config.textColor)
}

val adjustedPrimaryColor = getAdjustedPrimaryColor()
main_tabs_holder.background = ColorDrawable(config.backgroundColor)
main_tabs_holder.setSelectedTabIndicatorColor(getAdjustedPrimaryColor())
main_tabs_holder.getTabAt(main_view_pager.currentItem)?.icon?.applyColorFilter(getAdjustedPrimaryColor())
main_tabs_holder.setSelectedTabIndicatorColor(adjustedPrimaryColor)
main_tabs_holder.getTabAt(main_view_pager.currentItem)?.icon?.applyColorFilter(adjustedPrimaryColor)

if (main_view_pager.adapter == null) {
initFragments()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.simplemobiletools.filemanager.pro.adapters
import android.view.View
import android.view.ViewGroup
import androidx.viewpager.widget.PagerAdapter
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
import com.simplemobiletools.filemanager.pro.R
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity
import com.simplemobiletools.filemanager.pro.extensions.config
Expand All @@ -18,7 +17,7 @@ class ViewPagerAdapter(val activity: SimpleActivity) : PagerAdapter() {

(view as MyViewPagerFragment).apply {
setupFragment(activity)
setupColors(activity.config.textColor, activity.getAdjustedPrimaryColor())
setupColors(activity.config.textColor, activity.config.primaryColor)
}

return view
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
}
}

override fun setupColors(textColor: Int, adjustedPrimaryColor: Int) {
override fun setupColors(textColor: Int, primaryColor: Int) {
context!!.updateTextColors(this)
items_fastscroller.updatePrimaryColor()
storedItems = ArrayList()
getRecyclerAdapter()?.apply {
updatePrimaryColor(primaryColor)
updateTextColor(textColor)
initDrawables()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)

abstract fun setupFragment(activity: SimpleActivity)

abstract fun setupColors(textColor: Int, adjustedPrimaryColor: Int)
abstract fun setupColors(textColor: Int, primaryColor: Int)

abstract fun setupFontSize()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,15 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
recents_list.scheduleLayoutAnimation()
}

override fun setupColors(textColor: Int, adjustedPrimaryColor: Int) {}
override fun setupColors(textColor: Int, primaryColor: Int) {
recents_placeholder.setTextColor(textColor)

getRecyclerAdapter()?.apply {
updatePrimaryColor(primaryColor)
updateTextColor(textColor)
initDrawables()
}
}

private fun setupLayoutManager() {
if (context!!.config.getFolderViewType(currentPath) == VIEW_TYPE_GRID) {
Expand Down

0 comments on commit 2150ad1

Please sign in to comment.