Skip to content

Commit

Permalink
format politeia description using markwon RTF(no webview)
Browse files Browse the repository at this point in the history
  • Loading branch information
dreacot committed May 18, 2021
1 parent 4d7ecdf commit 0586bb5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ dependencies {
// JSON serialization & deserialization
implementation 'com.google.code.gson:gson:2.8.6'

// Rich Text Formatting (No WebView)
implementation "io.noties.markwon:core:$markwon_version"

androidTestImplementation 'androidx.test:rules:1.4.0-alpha06'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0-alpha06'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.dcrandroid.data.Proposal
import com.dcrandroid.extensions.hide
import com.dcrandroid.extensions.show
import com.dcrandroid.util.Utils
import io.noties.markwon.Markwon
import kotlinx.android.synthetic.main.activity_proposal_details.*
import kotlinx.android.synthetic.main.info_dialog.*
import kotlinx.coroutines.*
Expand Down Expand Up @@ -77,7 +78,9 @@ class ProposalDetailsActivity : BaseActivity() {

// load file from server if it is not yet loaded or outdated.
if (proposal.indexFile!!.isNotEmpty() && proposal.indexFileVersion == proposal.version) {
proposal_description.text = proposal.indexFile
// set markdown
Markwon.create(this)
.setMarkdown(proposal_description, proposal.indexFile!!)
} else {
description_progress.show()

Expand All @@ -88,7 +91,9 @@ class ProposalDetailsActivity : BaseActivity() {
val description = multiWallet!!.politeia.fetchProposalDescription(proposal.token)
withContext(Dispatchers.Main) {
description_progress?.hide()
proposal_description?.text = description
// set markdown
Markwon.create(applicationContext)
.setMarkdown(proposal_description, description)
}

break
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

buildscript {
ext.kotlin_version = '1.4.31'
ext.markwon_version = '4.6.2'

repositories {
mavenCentral()
Expand Down

0 comments on commit 0586bb5

Please sign in to comment.