Skip to content

Commit 6a49ff4

Browse files
committed
fix #46, allow changing the font size
1 parent 32f7309 commit 6a49ff4

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import android.graphics.drawable.Drawable
1212
import android.graphics.drawable.Icon
1313
import android.graphics.drawable.LayerDrawable
1414
import android.net.Uri
15+
import android.util.TypedValue
1516
import android.view.Menu
1617
import android.view.View
1718
import android.view.ViewGroup
@@ -61,11 +62,15 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
6162
private var currentItemsHash = listItems.hashCode()
6263
private var textToHighlight = ""
6364
private val hasOTGConnected = activity.hasOTGConnected()
65+
private var fontSize = 0f
66+
private var smallerFontSize = 0f
67+
6468
var adjustedPrimaryColor = activity.getAdjustedPrimaryColor()
6569

6670
init {
6771
setupDragListener(true)
6872
initDrawables()
73+
updateFontSizes()
6974
}
7075

7176
override fun getActionMenuId() = R.menu.cab
@@ -660,6 +665,12 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
660665
fastScroller?.measureRecyclerView()
661666
}
662667

668+
fun updateFontSizes() {
669+
fontSize = activity.getTextSize()
670+
smallerFontSize = fontSize * 0.8f
671+
notifyDataSetChanged()
672+
}
673+
663674
override fun onViewRecycled(holder: ViewHolder) {
664675
super.onViewRecycled(holder)
665676
if (!activity.isDestroyed && !activity.isFinishing) {
@@ -676,13 +687,19 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
676687
if (listItem.isSectionTitle) {
677688
item_section.text = listItem.mName
678689
item_section.setTextColor(textColor)
690+
item_section.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
679691
} else {
680692
item_frame.isSelected = isSelected
681693
val fileName = listItem.name
682694
item_name.text = if (textToHighlight.isEmpty()) fileName else fileName.highlightTextPart(textToHighlight, adjustedPrimaryColor)
683695
item_name.setTextColor(textColor)
696+
item_name.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
697+
684698
item_details.setTextColor(textColor)
699+
item_details.setTextSize(TypedValue.COMPLEX_UNIT_PX, smallerFontSize)
700+
685701
item_date.setTextColor(textColor)
702+
item_date.setTextSize(TypedValue.COMPLEX_UNIT_PX, smallerFontSize)
686703

687704
if (listItem.isDirectory) {
688705
item_icon.setImageDrawable(folderDrawable)

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
4646

4747
private var storedItems = ArrayList<ListItem>()
4848
private var storedTextColor = 0
49+
private var storedFontSize = 0
4950

5051
lateinit var mView: View
5152

@@ -92,6 +93,12 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
9293
storedTextColor = newTextColor
9394
}
9495

96+
val configFontSize = context!!.config.fontSize
97+
if (storedFontSize != configFontSize) {
98+
getRecyclerAdapter()?.updateFontSizes()
99+
storedFontSize = configFontSize
100+
}
101+
95102
mView.items_fastscroller.updateBubbleColors()
96103
mView.items_fastscroller.allowBubbleDisplay = true
97104
if (!isFirstResume) {
@@ -109,6 +116,7 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
109116
private fun storeStateVariables() {
110117
context!!.config.apply {
111118
storedTextColor = textColor
119+
storedFontSize = fontSize
112120
}
113121
}
114122

0 commit comments

Comments
 (0)