Skip to content

Commit 2150ad1

Browse files
committed
properly update some colors on change
1 parent b526ae5 commit 2150ad1

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,8 @@ class MainActivity : SimpleActivity() {
8080

8181
override fun onResume() {
8282
super.onResume()
83-
val adjustedPrimaryColor = getAdjustedPrimaryColor()
8483
getAllFragments().forEach {
85-
it?.setupColors(config.textColor, adjustedPrimaryColor)
84+
it?.setupColors(config.textColor, config.primaryColor)
8685
}
8786

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

103+
val adjustedPrimaryColor = getAdjustedPrimaryColor()
104104
main_tabs_holder.background = ColorDrawable(config.backgroundColor)
105-
main_tabs_holder.setSelectedTabIndicatorColor(getAdjustedPrimaryColor())
106-
main_tabs_holder.getTabAt(main_view_pager.currentItem)?.icon?.applyColorFilter(getAdjustedPrimaryColor())
105+
main_tabs_holder.setSelectedTabIndicatorColor(adjustedPrimaryColor)
106+
main_tabs_holder.getTabAt(main_view_pager.currentItem)?.icon?.applyColorFilter(adjustedPrimaryColor)
107107

108108
if (main_view_pager.adapter == null) {
109109
initFragments()

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/adapters/ViewPagerAdapter.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package com.simplemobiletools.filemanager.pro.adapters
33
import android.view.View
44
import android.view.ViewGroup
55
import androidx.viewpager.widget.PagerAdapter
6-
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
76
import com.simplemobiletools.filemanager.pro.R
87
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity
98
import com.simplemobiletools.filemanager.pro.extensions.config
@@ -18,7 +17,7 @@ class ViewPagerAdapter(val activity: SimpleActivity) : PagerAdapter() {
1817

1918
(view as MyViewPagerFragment).apply {
2019
setupFragment(activity)
21-
setupColors(activity.config.textColor, activity.getAdjustedPrimaryColor())
20+
setupColors(activity.config.textColor, activity.config.primaryColor)
2221
}
2322

2423
return view

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/ItemsFragment.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,12 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
4747
}
4848
}
4949

50-
override fun setupColors(textColor: Int, adjustedPrimaryColor: Int) {
50+
override fun setupColors(textColor: Int, primaryColor: Int) {
5151
context!!.updateTextColors(this)
5252
items_fastscroller.updatePrimaryColor()
5353
storedItems = ArrayList()
5454
getRecyclerAdapter()?.apply {
55+
updatePrimaryColor(primaryColor)
5556
updateTextColor(textColor)
5657
initDrawables()
5758
}

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/MyViewPagerFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
3636

3737
abstract fun setupFragment(activity: SimpleActivity)
3838

39-
abstract fun setupColors(textColor: Int, adjustedPrimaryColor: Int)
39+
abstract fun setupColors(textColor: Int, primaryColor: Int)
4040

4141
abstract fun setupFontSize()
4242

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/RecentsFragment.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,15 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
5959
recents_list.scheduleLayoutAnimation()
6060
}
6161

62-
override fun setupColors(textColor: Int, adjustedPrimaryColor: Int) {}
62+
override fun setupColors(textColor: Int, primaryColor: Int) {
63+
recents_placeholder.setTextColor(textColor)
64+
65+
getRecyclerAdapter()?.apply {
66+
updatePrimaryColor(primaryColor)
67+
updateTextColor(textColor)
68+
initDrawables()
69+
}
70+
}
6371

6472
private fun setupLayoutManager() {
6573
if (context!!.config.getFolderViewType(currentPath) == VIEW_TYPE_GRID) {

0 commit comments

Comments
 (0)