fix #46, allow changing the font size
This commit is contained in:
parent
32f730940f
commit
6a49ff4cf7
|
@ -12,6 +12,7 @@ import android.graphics.drawable.Drawable
|
|||
import android.graphics.drawable.Icon
|
||||
import android.graphics.drawable.LayerDrawable
|
||||
import android.net.Uri
|
||||
import android.util.TypedValue
|
||||
import android.view.Menu
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
@ -61,11 +62,15 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
|
|||
private var currentItemsHash = listItems.hashCode()
|
||||
private var textToHighlight = ""
|
||||
private val hasOTGConnected = activity.hasOTGConnected()
|
||||
private var fontSize = 0f
|
||||
private var smallerFontSize = 0f
|
||||
|
||||
var adjustedPrimaryColor = activity.getAdjustedPrimaryColor()
|
||||
|
||||
init {
|
||||
setupDragListener(true)
|
||||
initDrawables()
|
||||
updateFontSizes()
|
||||
}
|
||||
|
||||
override fun getActionMenuId() = R.menu.cab
|
||||
|
@ -660,6 +665,12 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
|
|||
fastScroller?.measureRecyclerView()
|
||||
}
|
||||
|
||||
fun updateFontSizes() {
|
||||
fontSize = activity.getTextSize()
|
||||
smallerFontSize = fontSize * 0.8f
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onViewRecycled(holder: ViewHolder) {
|
||||
super.onViewRecycled(holder)
|
||||
if (!activity.isDestroyed && !activity.isFinishing) {
|
||||
|
@ -676,13 +687,19 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
|
|||
if (listItem.isSectionTitle) {
|
||||
item_section.text = listItem.mName
|
||||
item_section.setTextColor(textColor)
|
||||
item_section.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
||||
} else {
|
||||
item_frame.isSelected = isSelected
|
||||
val fileName = listItem.name
|
||||
item_name.text = if (textToHighlight.isEmpty()) fileName else fileName.highlightTextPart(textToHighlight, adjustedPrimaryColor)
|
||||
item_name.setTextColor(textColor)
|
||||
item_name.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
||||
|
||||
item_details.setTextColor(textColor)
|
||||
item_details.setTextSize(TypedValue.COMPLEX_UNIT_PX, smallerFontSize)
|
||||
|
||||
item_date.setTextColor(textColor)
|
||||
item_date.setTextSize(TypedValue.COMPLEX_UNIT_PX, smallerFontSize)
|
||||
|
||||
if (listItem.isDirectory) {
|
||||
item_icon.setImageDrawable(folderDrawable)
|
||||
|
|
|
@ -46,6 +46,7 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
|
|||
|
||||
private var storedItems = ArrayList<ListItem>()
|
||||
private var storedTextColor = 0
|
||||
private var storedFontSize = 0
|
||||
|
||||
lateinit var mView: View
|
||||
|
||||
|
@ -92,6 +93,12 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
|
|||
storedTextColor = newTextColor
|
||||
}
|
||||
|
||||
val configFontSize = context!!.config.fontSize
|
||||
if (storedFontSize != configFontSize) {
|
||||
getRecyclerAdapter()?.updateFontSizes()
|
||||
storedFontSize = configFontSize
|
||||
}
|
||||
|
||||
mView.items_fastscroller.updateBubbleColors()
|
||||
mView.items_fastscroller.allowBubbleDisplay = true
|
||||
if (!isFirstResume) {
|
||||
|
@ -109,6 +116,7 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
|
|||
private fun storeStateVariables() {
|
||||
context!!.config.apply {
|
||||
storedTextColor = textColor
|
||||
storedFontSize = fontSize
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue