Loading commons/src/main/kotlin/com/simplemobiletools/commons/activities/LicenseActivity.kt +11 −17 Original line number Diff line number Diff line package com.simplemobiletools.commons.activities import android.graphics.Color import android.os.Bundle import android.text.SpannableString import android.text.style.UnderlineSpan import android.view.LayoutInflater import com.simplemobiletools.commons.R import com.simplemobiletools.commons.extensions.baseConfig import com.simplemobiletools.commons.extensions.isBlackAndWhiteTheme import com.simplemobiletools.commons.extensions.launchViewIntent import com.simplemobiletools.commons.extensions.updateTextColors import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.models.License import kotlinx.android.synthetic.main.activity_license.* Loading @@ -20,7 +14,7 @@ class LicenseActivity : BaseSimpleActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_license) val linkColor = if (isBlackAndWhiteTheme()) Color.WHITE else baseConfig.primaryColor val linkColor = getAdjustedPrimaryColor() updateTextColors(licenses_holder) val inflater = LayoutInflater.from(this) Loading @@ -30,9 +24,15 @@ class LicenseActivity : BaseSimpleActivity() { val license = it val view = inflater.inflate(R.layout.license_item, null) view.apply { license_title.text = getUnderlinedTitle(getString(license.titleId)) license_title.setOnClickListener { launchViewIntent(license.urlId) } license_title.setTextColor(linkColor) license_title.apply { text = getString(license.titleId) underlineText() setTextColor(linkColor) setOnClickListener { launchViewIntent(license.urlId) } } license_text.text = getString(license.textId) license_text.setTextColor(baseConfig.textColor) licenses_holder.addView(this) Loading @@ -40,12 +40,6 @@ class LicenseActivity : BaseSimpleActivity() { } } private fun getUnderlinedTitle(title: String): SpannableString { val underlined = SpannableString(title) underlined.setSpan(UnderlineSpan(), 0, title.length, 0) return underlined } private fun initLicenses() = arrayOf( License(LICENSE_KOTLIN, R.string.kotlin_title, R.string.kotlin_text, R.string.kotlin_url), Loading commons/src/main/kotlin/com/simplemobiletools/commons/extensions/TextView.kt +5 −0 Original line number Diff line number Diff line package com.simplemobiletools.commons.extensions import android.graphics.Paint import android.widget.TextView val TextView.value: String get() = text.toString().trim() fun TextView.underlineText() { paintFlags = paintFlags or Paint.UNDERLINE_TEXT_FLAG } Loading
commons/src/main/kotlin/com/simplemobiletools/commons/activities/LicenseActivity.kt +11 −17 Original line number Diff line number Diff line package com.simplemobiletools.commons.activities import android.graphics.Color import android.os.Bundle import android.text.SpannableString import android.text.style.UnderlineSpan import android.view.LayoutInflater import com.simplemobiletools.commons.R import com.simplemobiletools.commons.extensions.baseConfig import com.simplemobiletools.commons.extensions.isBlackAndWhiteTheme import com.simplemobiletools.commons.extensions.launchViewIntent import com.simplemobiletools.commons.extensions.updateTextColors import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.models.License import kotlinx.android.synthetic.main.activity_license.* Loading @@ -20,7 +14,7 @@ class LicenseActivity : BaseSimpleActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_license) val linkColor = if (isBlackAndWhiteTheme()) Color.WHITE else baseConfig.primaryColor val linkColor = getAdjustedPrimaryColor() updateTextColors(licenses_holder) val inflater = LayoutInflater.from(this) Loading @@ -30,9 +24,15 @@ class LicenseActivity : BaseSimpleActivity() { val license = it val view = inflater.inflate(R.layout.license_item, null) view.apply { license_title.text = getUnderlinedTitle(getString(license.titleId)) license_title.setOnClickListener { launchViewIntent(license.urlId) } license_title.setTextColor(linkColor) license_title.apply { text = getString(license.titleId) underlineText() setTextColor(linkColor) setOnClickListener { launchViewIntent(license.urlId) } } license_text.text = getString(license.textId) license_text.setTextColor(baseConfig.textColor) licenses_holder.addView(this) Loading @@ -40,12 +40,6 @@ class LicenseActivity : BaseSimpleActivity() { } } private fun getUnderlinedTitle(title: String): SpannableString { val underlined = SpannableString(title) underlined.setSpan(UnderlineSpan(), 0, title.length, 0) return underlined } private fun initLicenses() = arrayOf( License(LICENSE_KOTLIN, R.string.kotlin_title, R.string.kotlin_text, R.string.kotlin_url), Loading
commons/src/main/kotlin/com/simplemobiletools/commons/extensions/TextView.kt +5 −0 Original line number Diff line number Diff line package com.simplemobiletools.commons.extensions import android.graphics.Paint import android.widget.TextView val TextView.value: String get() = text.toString().trim() fun TextView.underlineText() { paintFlags = paintFlags or Paint.UNDERLINE_TEXT_FLAG }