Skip to content

Commit

Permalink
minor ui fix: other dns list
Browse files Browse the repository at this point in the history
  • Loading branch information
hussainmohd-a committed Sep 21, 2023
1 parent fec99eb commit f0f16ff
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,19 @@ class ConfigureOtherDnsActivity : AppCompatActivity(R.layout.activity_configure_
}
}

TabLayoutMediator(b.dnsDetailActTabLayout, b.dnsDetailActViewpager) { tab, position ->
tab.text = getString(R.string.dns_act_configure_tab)
TabLayoutMediator(b.dnsDetailActTabLayout, b.dnsDetailActViewpager) { tab, _ ->
tab.text = getDnsTypeName(dnsType)
}
.attach()
}

private fun getDnsTypeName(type: Int): String {
return when (DnsScreen.getDnsType(type)) {
DnsScreen.DOH -> getString(R.string.other_dns_list_tab1)
DnsScreen.DNS_CRYPT -> getString(R.string.other_dns_list_tab2)
DnsScreen.DNS_PROXY -> getString(R.string.other_dns_list_tab3)
DnsScreen.DOT -> getString(R.string.lbl_dot)
DnsScreen.ODOH -> getString(R.string.lbl_odoh)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,6 @@ class DnsListActivity : AppCompatActivity(R.layout.activity_other_dns_list) {
}

private fun init() {

when (appConfig.getDnsType()) {
AppConfig.DnsType.DOH -> {
b.dohText.setTextColor(fetchColor(this, R.attr.secondaryTextColor))
}
AppConfig.DnsType.DNS_PROXY -> {
b.dnsProxyText.setTextColor(fetchColor(this, R.attr.secondaryTextColor))
}
AppConfig.DnsType.DNSCRYPT -> {
b.dnsCryptText.setTextColor(fetchColor(this, R.attr.secondaryTextColor))
}
AppConfig.DnsType.DOT -> {
b.dotText.setTextColor(fetchColor(this, R.attr.secondaryTextColor))
}
AppConfig.DnsType.ODOH -> {
b.odohText.setTextColor(fetchColor(this, R.attr.secondaryTextColor))
}
else -> {
// no-op
}
}

b.dnsCryptCard.setOnClickListener {
startActivity(
ConfigureOtherDnsActivity.getIntent(
Expand Down Expand Up @@ -113,4 +91,28 @@ class DnsListActivity : AppCompatActivity(R.layout.activity_other_dns_list) {
)
}
}

override fun onResume() {
super.onResume()
when (appConfig.getDnsType()) {
AppConfig.DnsType.DOH -> {
b.dohText.setTextColor(fetchColor(this, R.attr.secondaryTextColor))
}
AppConfig.DnsType.DNS_PROXY -> {
b.dnsProxyText.setTextColor(fetchColor(this, R.attr.secondaryTextColor))
}
AppConfig.DnsType.DNSCRYPT -> {
b.dnsCryptText.setTextColor(fetchColor(this, R.attr.secondaryTextColor))
}
AppConfig.DnsType.DOT -> {
b.dotText.setTextColor(fetchColor(this, R.attr.secondaryTextColor))
}
AppConfig.DnsType.ODOH -> {
b.odohText.setTextColor(fetchColor(this, R.attr.secondaryTextColor))
}
else -> {
// no-op
}
}
}
}

0 comments on commit f0f16ff

Please sign in to comment.