Skip to content

Commit

Permalink
Use extensions
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <[email protected]>
  • Loading branch information
alperozturk96 committed Nov 15, 2023
1 parent 2989439 commit b773a14
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/

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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -63,26 +61,21 @@ 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),
getString(R.string.translation_link),
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(
Expand All @@ -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() {
Expand Down

0 comments on commit b773a14

Please sign in to comment.