Commit 582e2c94 authored by Konstantin Tskhovrebov's avatar Konstantin Tskhovrebov 🤖

changed webview to textview for showing markdown text

parent eb9a5f3c
......@@ -16,7 +16,7 @@ import ru.terrakok.gitlabclient.toothpick.qualifier.IssueId
import ru.terrakok.gitlabclient.toothpick.qualifier.ProjectId
import javax.inject.Inject
private typealias IssueLinker = BiFunction<Pair<Issue, String>, Project, IssueInfoView.IssueInfo>
private typealias IssueLinker = BiFunction<Pair<Issue, CharSequence>, Project, IssueInfoView.IssueInfo>
/**
* Created by Konstantin Tskhovrebov (aka @terrakok) on 05.01.18.
......@@ -44,7 +44,7 @@ class IssueInfoPresenter @Inject constructor(
.getIssue(projectId, issueId)
.flatMap { issue ->
mdConverter
.markdownToHtml(issue.description ?: "")
.markdownToSpannable(issue.description ?: "")
.map { Pair(issue, it) }
},
projectInteractor.getProject(projectId),
......
......@@ -12,7 +12,7 @@ import ru.terrakok.gitlabclient.entity.issue.Issue
*/
@StateStrategyType(AddToEndSingleStrategy::class)
interface IssueInfoView : MvpView {
data class IssueInfo(val issue: Issue, val project: Project, val htmlDescription: String)
data class IssueInfo(val issue: Issue, val project: Project, val mdDescription: CharSequence)
fun showIssue(issueInfo: IssueInfo)
fun showProgress(show: Boolean)
......
......@@ -16,7 +16,7 @@ import ru.terrakok.gitlabclient.toothpick.qualifier.MergeRequestId
import ru.terrakok.gitlabclient.toothpick.qualifier.ProjectId
import javax.inject.Inject
private typealias MergeRequestLinker = BiFunction<Pair<MergeRequest, String>, Project, MergeRequestInfoView.MergeRequestInfo>
private typealias MergeRequestLinker = BiFunction<Pair<MergeRequest, CharSequence>, Project, MergeRequestInfoView.MergeRequestInfo>
/**
* Created by Konstantin Tskhovrebov (aka @terrakok) on 05.01.18.
......@@ -44,7 +44,7 @@ class MergeRequestInfoPresenter @Inject constructor(
.getMergeRequest(projectId, mrId)
.flatMap { mr ->
mdConverter
.markdownToHtml(mr.description ?: "")
.markdownToSpannable(mr.description ?: "")
.map { Pair(mr, it) }
},
projectInteractor.getProject(projectId),
......
......@@ -12,7 +12,7 @@ import ru.terrakok.gitlabclient.entity.mergerequest.MergeRequest
*/
@StateStrategyType(AddToEndSingleStrategy::class)
interface MergeRequestInfoView : MvpView {
data class MergeRequestInfo(val mr: MergeRequest, val project: Project, val htmlDescription: String)
data class MergeRequestInfo(val mr: MergeRequest, val project: Project, val mdDescription: CharSequence)
fun showMergeRequest(mrInfo: MergeRequestInfo)
fun showProgress(show: Boolean)
......
......@@ -32,7 +32,7 @@ class ProjectInfoPresenter @Inject constructor(
.flatMap { project ->
projectInteractor
.getProjectReadme(project.id, project.defaultBranch)
.flatMap { mdConverter.markdownToHtml(it) }
.flatMap { mdConverter.markdownToSpannable(it) }
}
.doOnSubscribe { viewState.showProgress(true) }
.doAfterTerminate { viewState.showProgress(false) }
......
......@@ -13,7 +13,7 @@ import ru.terrakok.gitlabclient.entity.Project
interface ProjectInfoView : MvpView {
fun showProjectInfo(project: Project)
fun showProgress(show: Boolean)
fun showReadmeFile(html: String)
fun showReadmeFile(mdReadme: CharSequence)
@StateStrategyType(OneExecutionStateStrategy::class)
fun showMessage(message: String)
......
......@@ -4,6 +4,7 @@ import android.os.Bundle
import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter
import kotlinx.android.synthetic.main.fragment_issue_info.*
import ru.noties.markwon.Markwon
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.entity.issue.IssueState
import ru.terrakok.gitlabclient.extension.color
......@@ -60,7 +61,7 @@ class IssueInfoFragment : BaseFragment(), IssueInfoView {
}
}
avatarImageView.loadRoundedImage(issue.author.avatarUrl, context)
descriptionWebView.loadData(issueInfo.htmlDescription, "text/html", "UTF-8")
Markwon.setText(descriptionTextView, issueInfo.mdDescription)
}
override fun showProgress(show: Boolean) {
......
......@@ -4,6 +4,7 @@ import android.os.Bundle
import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter
import kotlinx.android.synthetic.main.fragment_mr_info.*
import ru.noties.markwon.Markwon
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.entity.mergerequest.MergeRequestState
import ru.terrakok.gitlabclient.extension.color
......@@ -65,7 +66,7 @@ class MergeRequestInfoFragment : BaseFragment(), MergeRequestInfoView {
}
}
avatarImageView.loadRoundedImage(mergeRequest.author.avatarUrl, context)
descriptionWebView.loadData(mrInfo.htmlDescription, "text/html", "UTF-8")
Markwon.setText(descriptionTextView, mrInfo.mdDescription)
}
override fun showProgress(show: Boolean) {
......
......@@ -4,6 +4,7 @@ import android.os.Bundle
import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter
import kotlinx.android.synthetic.main.fragment_project_info.*
import ru.noties.markwon.Markwon
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.entity.Project
import ru.terrakok.gitlabclient.entity.Visibility
......@@ -66,8 +67,8 @@ class ProjectInfoFragment : BaseFragment(), ProjectInfoView {
showProgressDialog(show)
}
override fun showReadmeFile(html: String) {
webView.loadData(html, "text/html", "UTF-8")
override fun showReadmeFile(mdReadme: CharSequence) {
Markwon.setText(readmeTextView, mdReadme)
}
override fun showMessage(message: String) {
......
......@@ -81,12 +81,12 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/subtitleTextView"/>
<WebView
android:id="@+id/descriptionWebView"
<TextView
android:id="@+id/descriptionTextView"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/lightGrey"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_height="wrap_content"
android:linksClickable="true"
android:padding="16dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/divider"/>
......
......@@ -81,12 +81,12 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/subtitleTextView"/>
<WebView
android:id="@+id/descriptionWebView"
<TextView
android:id="@+id/descriptionTextView"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/lightGrey"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_height="wrap_content"
android:linksClickable="true"
android:padding="16dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/divider"/>
......
......@@ -122,11 +122,11 @@
</android.support.constraint.ConstraintLayout>
<WebView
android:id="@+id/webView"
<TextView
android:id="@+id/readmeTextView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/lightGrey"/>
android:padding="16dp"/>
</LinearLayout>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment