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.content.Context
import android.util.AttributeSet import android.util.AttributeSet
import android.widget.RelativeLayout import android.widget.RelativeLayout
import androidx.annotation.ColorRes import androidx.annotation.ColorInt
import androidx.appcompat.widget.AppCompatImageView import androidx.appcompat.widget.AppCompatImageView
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible import androidx.core.view.isVisible
import com.aurora.store.R import com.aurora.store.R
import com.aurora.store.databinding.ViewDevInfoBinding import com.aurora.store.databinding.ViewDevInfoBinding
@@ -43,6 +42,16 @@ class DevInfoLayout : RelativeLayout {
get() = binding.txtSubtitle.text.toString() get() = binding.txtSubtitle.text.toString()
set(value) = setTxtSubtitle(value) 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) { constructor(context: Context) : super(context) {
init(context, null) init(context, null)
} }
@@ -78,23 +87,15 @@ class DevInfoLayout : RelativeLayout {
typedArray.recycle() typedArray.recycle()
} }
fun setTxtTitle(text: String?) { private fun setTxtTitle(text: String?) {
binding.txtTitle.text = text binding.txtTitle.text = text
binding.txtTitle.isVisible = text != null binding.txtTitle.isVisible = text != null
invalidate() invalidate()
} }
fun setTxtSubtitle(text: String?) { private fun setTxtSubtitle(text: String?) {
binding.txtSubtitle.text = text binding.txtSubtitle.text = text
binding.txtSubtitle.isVisible = text != null binding.txtSubtitle.isVisible = text != null
invalidate() 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 { binding.layoutDetailsDev.apply {
if (app.developerAddress.isNotEmpty()) { if (app.developerAddress.isNotEmpty()) {
devAddress.apply { devAddress.apply {
setTxtSubtitle( subTitle = HtmlCompat.fromHtml(
HtmlCompat.fromHtml( app.developerAddress,
app.developerAddress, HtmlCompat.FROM_HTML_MODE_LEGACY
HtmlCompat.FROM_HTML_MODE_LEGACY ).toString()
).toString()
)
visibility = View.VISIBLE visibility = View.VISIBLE
} }
} }
if (app.developerWebsite.isNotEmpty()) { if (app.developerWebsite.isNotEmpty()) {
devWeb.apply { devWeb.apply {
setTxtSubtitle(app.developerWebsite) subTitle = app.developerWebsite
visibility = View.VISIBLE visibility = View.VISIBLE
} }
} }
if (app.developerEmail.isNotEmpty()) { if (app.developerEmail.isNotEmpty()) {
devMail.apply { devMail.apply {
setTxtSubtitle(app.developerEmail) subTitle = app.developerEmail
visibility = View.VISIBLE visibility = View.VISIBLE
} }
} }
@@ -1042,7 +1040,7 @@ class AppDetailsFragment : BaseFragment<FragmentDetailsBinding>() {
binding.layoutDetailsCompatibility.txtGmsDependency.apply { binding.layoutDetailsCompatibility.txtGmsDependency.apply {
title = getString(R.string.details_compatibility_gms_required_title) title = getString(R.string.details_compatibility_gms_required_title)
subTitle = getString(R.string.details_compatibility_gms_required_subtitle) 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 binding.layoutDetailsCompatibility.compatibilityStatusLayout.isVisible = true
@@ -1050,7 +1048,7 @@ class AppDetailsFragment : BaseFragment<FragmentDetailsBinding>() {
binding.layoutDetailsCompatibility.txtGmsDependency.apply { binding.layoutDetailsCompatibility.txtGmsDependency.apply {
title = getString(R.string.details_compatibility_gms_not_required_title) title = getString(R.string.details_compatibility_gms_not_required_title)
subTitle = getString(R.string.details_compatibility_gms_not_required_subtitle) subTitle = getString(R.string.details_compatibility_gms_not_required_subtitle)
setTitleColor(R.color.colorGreen) titleColor = ContextCompat.getColor(context, R.color.colorRed)
} }
} }
} }