updating Recents + adding handling for placeholders

This commit is contained in:
tibbi
2020-05-07 22:50:19 +02:00
parent dc20b20037
commit e604a3e88b
10 changed files with 123 additions and 56 deletions

View File

@ -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()
}
}
}