DevInfoLayout: Switch to property access syntax everywhere

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2025-01-11 17:54:40 +07:00
parent 516af19172
commit 4e0fc54d6e
2 changed files with 21 additions and 22 deletions

View File

@@ -22,9 +22,8 @@ package com.aurora.store.view.custom.layouts
import android.content.Context
import android.util.AttributeSet
import android.widget.RelativeLayout
import androidx.annotation.ColorRes
import androidx.annotation.ColorInt
import androidx.appcompat.widget.AppCompatImageView
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import com.aurora.store.R
import com.aurora.store.databinding.ViewDevInfoBinding
@@ -43,6 +42,16 @@ class DevInfoLayout : RelativeLayout {
get() = binding.txtSubtitle.text.toString()
set(value) = setTxtSubtitle(value)
@get:ColorInt
var titleColor: Int
get() = binding.txtTitle.currentTextColor
set(value) = binding.txtTitle.setTextColor(value)
@get:ColorInt
var subTitleColor: Int
get() = binding.txtSubtitle.currentTextColor
set(value) = binding.txtSubtitle.setTextColor(value)
constructor(context: Context) : super(context) {
init(context, null)
}
@@ -78,23 +87,15 @@ class DevInfoLayout : RelativeLayout {
typedArray.recycle()
}
fun setTxtTitle(text: String?) {
private fun setTxtTitle(text: String?) {
binding.txtTitle.text = text
binding.txtTitle.isVisible = text != null
invalidate()
}
fun setTxtSubtitle(text: String?) {
private fun setTxtSubtitle(text: String?) {
binding.txtSubtitle.text = text
binding.txtSubtitle.isVisible = text != null
invalidate()
}
fun setTitleColor(@ColorRes color: Int) {
binding.txtTitle.setTextColor(ContextCompat.getColor(context, color))
}
fun setSubtitleColor(@ColorRes color: Int) {
binding.txtSubtitle.setTextColor(ContextCompat.getColor(context, color))
}
}

View File

@@ -878,26 +878,24 @@ class AppDetailsFragment : BaseFragment<FragmentDetailsBinding>() {
binding.layoutDetailsDev.apply {
if (app.developerAddress.isNotEmpty()) {
devAddress.apply {
setTxtSubtitle(
HtmlCompat.fromHtml(
app.developerAddress,
HtmlCompat.FROM_HTML_MODE_LEGACY
).toString()
)
subTitle = HtmlCompat.fromHtml(
app.developerAddress,
HtmlCompat.FROM_HTML_MODE_LEGACY
).toString()
visibility = View.VISIBLE
}
}
if (app.developerWebsite.isNotEmpty()) {
devWeb.apply {
setTxtSubtitle(app.developerWebsite)
subTitle = app.developerWebsite
visibility = View.VISIBLE
}
}
if (app.developerEmail.isNotEmpty()) {
devMail.apply {
setTxtSubtitle(app.developerEmail)
subTitle = app.developerEmail
visibility = View.VISIBLE
}
}
@@ -1042,7 +1040,7 @@ class AppDetailsFragment : BaseFragment<FragmentDetailsBinding>() {
binding.layoutDetailsCompatibility.txtGmsDependency.apply {
title = getString(R.string.details_compatibility_gms_required_title)
subTitle = getString(R.string.details_compatibility_gms_required_subtitle)
setTitleColor(R.color.colorRed)
titleColor = ContextCompat.getColor(context, R.color.colorRed)
}
binding.layoutDetailsCompatibility.compatibilityStatusLayout.isVisible = true
@@ -1050,7 +1048,7 @@ class AppDetailsFragment : BaseFragment<FragmentDetailsBinding>() {
binding.layoutDetailsCompatibility.txtGmsDependency.apply {
title = getString(R.string.details_compatibility_gms_not_required_title)
subTitle = getString(R.string.details_compatibility_gms_not_required_subtitle)
setTitleColor(R.color.colorGreen)
titleColor = ContextCompat.getColor(context, R.color.colorRed)
}
}
}