Skip to content

Commit

Permalink
Fix links in licenses dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecorry31 committed Sep 19, 2024
1 parent 3386e76 commit f017fbf
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.kylecorry.trail_sense.settings.licenses

import android.os.Bundle
import android.text.util.Linkify.WEB_URLS
import androidx.core.text.toSpannable
import androidx.core.text.util.LinkifyCompat
import androidx.preference.Preference
import androidx.preference.PreferenceCategory
import androidx.preference.PreferenceFragmentCompat
Expand All @@ -13,19 +16,23 @@ class LicenseFragment : PreferenceFragmentCompat() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.licenses, rootKey)

val licenseSection = preferenceManager.findPreference<PreferenceCategory>(getString(R.string.pref_category_licenses))
val licenseSection =
preferenceManager.findPreference<PreferenceCategory>(getString(R.string.pref_category_licenses))

for (library in Licenses.libraries){
for (library in Licenses.libraries) {
val pref = Preference(requireContext())
pref.title = library.name
pref.summary = library.url
pref.isIconSpaceReserved = false
pref.isSingleLineTitle = false
pref.setOnPreferenceClickListener {
val content = (library.url + "\n\n" + library.license()).toSpannable()
LinkifyCompat.addLinks(content, WEB_URLS)

Alerts.dialog(
requireContext(),
library.name,
library.url + "\n\n" + library.license(),
content,
cancelText = null,
allowLinks = true
)
Expand All @@ -36,5 +43,4 @@ class LicenseFragment : PreferenceFragmentCompat() {
}



}

0 comments on commit f017fbf

Please sign in to comment.