diff --git a/app/src/main/java/com/nextcloud/utils/extensions/TextViewExtensions.kt b/app/src/main/java/com/nextcloud/utils/extensions/TextViewExtensions.kt new file mode 100644 index 0000000000..2ba96c0e77 --- /dev/null +++ b/app/src/main/java/com/nextcloud/utils/extensions/TextViewExtensions.kt @@ -0,0 +1,31 @@ +/* + * Nextcloud Android client application + * + * @author Alper Ozturk + * Copyright (C) 2023 Alper Ozturk + * Copyright (C) 2023 Nextcloud GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package com.nextcloud.utils.extensions + +import android.text.method.LinkMovementMethod +import android.widget.TextView +import androidx.core.text.HtmlCompat + +fun TextView.setHtmlContent(value: String) { + movementMethod = LinkMovementMethod.getInstance() + text = HtmlCompat.fromHtml(value, HtmlCompat.FROM_HTML_MODE_LEGACY) +} \ No newline at end of file diff --git a/app/src/main/java/com/owncloud/android/ui/activity/CommunityActivity.kt b/app/src/main/java/com/owncloud/android/ui/activity/CommunityActivity.kt index 150ed44b4f..f60593923e 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/CommunityActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/activity/CommunityActivity.kt @@ -24,7 +24,7 @@ package com.owncloud.android.ui.activity import android.os.Bundle import android.text.method.LinkMovementMethod import android.view.MenuItem -import androidx.core.text.HtmlCompat +import com.nextcloud.utils.extensions.setHtmlContent import com.owncloud.android.R import com.owncloud.android.databinding.CommunityLayoutBinding import com.owncloud.android.utils.DisplayUtils @@ -53,8 +53,6 @@ class CommunityActivity : DrawerActivity() { } private fun setupContributeForumView() { - val contributeForumView = binding.communityContributeForumText - contributeForumView.movementMethod = LinkMovementMethod.getInstance() val htmlContent = getString(R.string.community_contribute_forum_text) + " " + getString( R.string.community_contribute_forum_text_link, @@ -63,12 +61,10 @@ class CommunityActivity : DrawerActivity() { getString(R.string.help_link), getString(R.string.community_contribute_forum_forum) ) - contributeForumView.text = HtmlCompat.fromHtml(htmlContent, HtmlCompat.FROM_HTML_MODE_LEGACY) + binding.communityContributeForumText.setHtmlContent(htmlContent) } private fun setupContributeTranslationView() { - val contributeTranslationView = binding.communityContributeTranslateText - contributeTranslationView.movementMethod = LinkMovementMethod.getInstance() val htmlContent = getString( R.string.community_contribute_translate_link, viewThemeUtils.files.primaryColorToHexString(this), @@ -76,13 +72,10 @@ class CommunityActivity : DrawerActivity() { getString(R.string.community_contribute_translate_translate) ) + " " + getString(R.string.community_contribute_translate_text) - - contributeTranslationView.text = HtmlCompat.fromHtml(htmlContent, HtmlCompat.FROM_HTML_MODE_LEGACY) + binding.communityContributeTranslateText.setHtmlContent(htmlContent) } private fun setupContributeGithubView() { - val contributeGithubView = binding.communityContributeGithubText - contributeGithubView.movementMethod = LinkMovementMethod.getInstance() val htmlContent = getString( R.string.community_contribute_github_text, getString( @@ -91,10 +84,7 @@ class CommunityActivity : DrawerActivity() { getString(R.string.contributing_link) ) ) - contributeGithubView.text = HtmlCompat.fromHtml( - htmlContent, - HtmlCompat.FROM_HTML_MODE_LEGACY - ) + binding.communityContributeGithubText.setHtmlContent(htmlContent) } private fun setupReportButton() {