mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-06-05 21:49:23 +02:00
updating Recents + adding handling for placeholders
This commit is contained in:
@ -2,5 +2,41 @@ package com.simplemobiletools.dialer.fragments
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CALL_LOG
|
||||
import com.simplemobiletools.dialer.R
|
||||
import com.simplemobiletools.dialer.extensions.config
|
||||
import com.simplemobiletools.dialer.models.RecentCall
|
||||
import kotlinx.android.synthetic.main.fragment_recents.view.*
|
||||
|
||||
class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet)
|
||||
class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet) {
|
||||
override fun setupFragment() {
|
||||
val placeholderResId = if (context.hasPermission(PERMISSION_READ_CALL_LOG)) {
|
||||
R.string.no_previous_calls
|
||||
} else {
|
||||
R.string.could_not_access_the_call_history
|
||||
}
|
||||
|
||||
recents_placeholder.text = context.getString(placeholderResId)
|
||||
|
||||
recents_placeholder_2.apply {
|
||||
setTextColor(context.config.primaryColor)
|
||||
underlineText()
|
||||
setOnClickListener {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun updateRecents(recents: ArrayList<RecentCall>) {
|
||||
if (recents.isEmpty()) {
|
||||
recents_placeholder.beVisible()
|
||||
recents_placeholder_2.beVisibleIf(!context.hasPermission(PERMISSION_READ_CALL_LOG))
|
||||
recents_list.beGone()
|
||||
} else {
|
||||
recents_placeholder.beGone()
|
||||
recents_placeholder_2.beGone()
|
||||
recents_list.beVisible()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user