mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-06-05 21:49:23 +02:00
Improved onFontChange listener
This commit is contained in:
@ -44,6 +44,7 @@ import me.grantland.widget.AutofitHelper
|
||||
class MainActivity : SimpleActivity() {
|
||||
private var launchedDialer = false
|
||||
private var storedShowTabs = 0
|
||||
private var storedFontSize = 0
|
||||
private var storedStartNameWithSurname = false
|
||||
var cachedContacts = ArrayList<Contact>()
|
||||
|
||||
@ -121,6 +122,13 @@ class MainActivity : SimpleActivity() {
|
||||
refreshItems(true)
|
||||
}
|
||||
|
||||
val configFontSize = config.fontSize
|
||||
if (storedFontSize != configFontSize) {
|
||||
getAllFragments().forEach {
|
||||
it?.fontSizeChanged()
|
||||
}
|
||||
}
|
||||
|
||||
checkShortcuts()
|
||||
Handler().postDelayed({
|
||||
recents_fragment?.refreshItems()
|
||||
|
@ -48,8 +48,7 @@ class ContactsAdapter(
|
||||
ItemTouchHelperContract, MyRecyclerView.MyZoomListener {
|
||||
|
||||
private var textToHighlight = highlightText
|
||||
private val fontSize: Float
|
||||
get() = activity.getTextSize()
|
||||
var fontSize: Float = activity.getTextSize()
|
||||
private var touchHelper: ItemTouchHelper? = null
|
||||
private var startReorderDragListener: StartReorderDragListener? = null
|
||||
var onDragEndListener: (() -> Unit)? = null
|
||||
|
@ -38,8 +38,7 @@ class RecentCallsAdapter(
|
||||
private lateinit var outgoingCallIcon: Drawable
|
||||
private lateinit var incomingCallIcon: Drawable
|
||||
private lateinit var incomingMissedCallIcon: Drawable
|
||||
private val fontSize: Float
|
||||
get() = activity.getTextSize()
|
||||
var fontSize: Float = activity.getTextSize()
|
||||
private val areMultipleSIMsAvailable = activity.areMultipleSIMsAvailable()
|
||||
private val redColor = resources.getColor(R.color.md_red_700)
|
||||
private var textToHighlight = ""
|
||||
|
@ -6,15 +6,17 @@ import android.widget.RelativeLayout
|
||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||
import com.simplemobiletools.commons.extensions.getProperPrimaryColor
|
||||
import com.simplemobiletools.commons.extensions.getProperTextColor
|
||||
import com.simplemobiletools.commons.extensions.getTextSize
|
||||
import com.simplemobiletools.commons.helpers.SORT_BY_FIRST_NAME
|
||||
import com.simplemobiletools.commons.helpers.SORT_BY_SURNAME
|
||||
import com.simplemobiletools.dialer.activities.MainActivity
|
||||
import com.simplemobiletools.dialer.activities.SimpleActivity
|
||||
import com.simplemobiletools.dialer.adapters.ContactsAdapter
|
||||
import com.simplemobiletools.dialer.adapters.RecentCallsAdapter
|
||||
import com.simplemobiletools.dialer.extensions.config
|
||||
import com.simplemobiletools.dialer.helpers.Config
|
||||
import kotlinx.android.synthetic.main.fragment_letters_layout.view.*
|
||||
import kotlinx.android.synthetic.main.fragment_recents.view.*
|
||||
import kotlinx.android.synthetic.main.fragment_letters_layout.view.fragment_list
|
||||
import kotlinx.android.synthetic.main.fragment_recents.view.recents_list
|
||||
|
||||
abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) : RelativeLayout(context, attributeSet) {
|
||||
protected var activity: SimpleActivity? = null
|
||||
@ -45,6 +47,20 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
||||
(recents_list?.adapter as? MyRecyclerViewAdapter)?.finishActMode()
|
||||
}
|
||||
|
||||
fun fontSizeChanged() {
|
||||
if (this is RecentsFragment) {
|
||||
(fragment_list.adapter as? RecentCallsAdapter)?.apply {
|
||||
fontSize = activity.getTextSize()
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
} else {
|
||||
(fragment_list.adapter as? ContactsAdapter)?.apply {
|
||||
fontSize = activity.getTextSize()
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun setupFragment()
|
||||
|
||||
abstract fun setupColors(textColor: Int, primaryColor: Int, properPrimaryColor: Int)
|
||||
|
Reference in New Issue
Block a user